Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLSegmentationNode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
4 Queen's University, Kingston, ON, Canada. All Rights Reserved.
5
6 See COPYRIGHT.txt
7 or http://www.slicer.org/copyright/copyright.txt for details.
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
16 and was supported through the Applied Cancer Research Unit program of Cancer Care
17 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18
19==============================================================================*/
20
21#ifndef __vtkMRMLSegmentationNode_h
22#define __vtkMRMLSegmentationNode_h
23
24// MRML includes
25#include <vtkMRML.h>
28
29// STD includes
30#include <cstdlib>
31
32// vtkSegmentationCore includes
33#include "vtkSegmentation.h"
34
35class vtkCallbackCommand;
36class vtkIntArray;
37class vtkMRMLScene;
41class vtkPolyData;
42
53class VTK_MRML_EXPORT vtkMRMLSegmentationNode : public vtkMRMLDisplayableNode
54{
55public:
56 // Define constants
57 static const char* GetSegmentIDAttributeName() { return "segmentID"; };
58
61 void PrintSelf(ostream& os, vtkIndent indent) override;
62
65
67 void ReadXMLAttributes( const char** atts) override;
68
70 void WriteXML(ostream& of, int indent) override;
71
75
77 const char* GetNodeTagName() override {return "Segmentation";};
78
83 void GetRASBounds(double bounds[6]) override;
84
88 void GetBounds(double bounds[6]) override;
89
92 bool CanApplyNonLinearTransforms()const override;
93
96 void ApplyTransformMatrix(vtkMatrix4x4* transformMatrix) override;
97
100 void ApplyTransform(vtkAbstractTransform* transform) override;
101
104
107
115 virtual void OnSubjectHierarchyUIDAdded(vtkMRMLSubjectHierarchyNode* shNode, vtkIdType itemWithNewUID);
116
121 virtual vtkIdType GetSegmentSubjectHierarchyItem(std::string segmentID, vtkMRMLSubjectHierarchyNode* shNode);
122
123#ifndef __VTK_WRAP__
124//BTX
137 virtual bool GenerateMergedLabelmap(vtkOrientedImageData* mergedImageData, int extentComputationMode, vtkOrientedImageData* mergedLabelmapGeometry = nullptr,
138 const std::vector<std::string>& segmentIDs = std::vector<std::string>(), vtkIntArray* labelValues = nullptr);
139//ETX
140#endif // __VTK_WRAP__
141
156 int extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS,
157 vtkOrientedImageData* mergedLabelmapGeometry = nullptr, vtkStringArray* segmentIDs = nullptr, vtkIntArray* labelValues = nullptr);
158
159 enum
160 {
162 EditAllowedEverywhere = 0,
174 EditAllowed_Last
175 };
176
178
179 static const char* ConvertMaskModeToString(int mode);
180 static int ConvertMaskModeFromString(const char* modeStr);
182
194 virtual bool GenerateEditMask(vtkOrientedImageData* maskImage, int editMode,
195 vtkOrientedImageData* referenceGeometry,
196 std::string editedSegmentID="", std::string maskSegmentID="",
197 vtkOrientedImageData* sourceVolume = nullptr, double editableIntensityRange[2] = nullptr,
198 vtkMRMLSegmentationDisplayNode* displayNode = nullptr);
199
201 static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
204
206 vtkGetObjectMacro(Segmentation, vtkSegmentation);
209
210 // Convenience functions for commonly needed features
211
218
221 {
222 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToBinaryLabelmap() method is deprecated, please use SetSourceRepresentationToBinaryLabelmap method instead");
223 return this->SetSourceRepresentationToClosedSurface();
224 };
227 {
228 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToClosedSurface() method is deprecated, please use SetSourceRepresentationToClosedSurface method instead");
229 return this->SetSourceRepresentationToClosedSurface();
230 };
231
234
237
242 virtual bool GetBinaryLabelmapRepresentation(const std::string segmentId, vtkOrientedImageData* outputBinaryLabelmap);
243
251
255
258
263 virtual bool GetClosedSurfaceRepresentation(const std::string segmentId, vtkPolyData* outputClosedSurface);
264
271 virtual vtkPolyData* GetClosedSurfaceInternalRepresentation(const std::string segmentId);
272
275 virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData,
276 std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
277
281 std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
282
284 void RemoveSegment(const std::string& segmentID);
285
287 double* GetSegmentCenter(const std::string& segmentID) VTK_SIZEHINT(3);
290 void GetSegmentCenter(const std::string& segmentID, double center[3]);
291
295 double* GetSegmentCenterRAS(const std::string& segmentID) VTK_SIZEHINT(3);
298 void GetSegmentCenterRAS(const std::string& segmentID, double centerRAS[3]);
299
301 vtkSetMacro(SegmentListFilterEnabled, bool);
302 vtkGetMacro(SegmentListFilterEnabled, bool);
303 vtkBooleanMacro(SegmentListFilterEnabled, bool);
304
306 vtkSetMacro(SegmentListFilterOptions, std::string);
307 vtkGetMacro(SegmentListFilterOptions, std::string);
308
312 void SetLabelmapConversionColorTableNodeID(const char* labelmapConversionColorTableNodeID);
314
317 enum
318 {
319 ReferenceImageGeometryChangedEvent = 23000,
320 SegmentationChangedEvent
321 };
322
323protected:
325 vtkSetObjectMacro(Segmentation, vtkSegmentation);
326
328 static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
329
333
336 void OnSegmentAdded(const char* segmentId);
337
340 void OnSegmentRemoved(const char* segmentId);
341
344 void OnSegmentModified(const char* segmentId);
345
346 static const char* GetLabelmapConversionColorTableNodeReferenceRole() { return "labelmapConversionColorTableNode"; };
347 static const char* GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName() { return "labelmapConversionColorTableNodeRef"; };
348
351
354
357
358protected:
363
366
368 vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
369
372 double SegmentCenterTmp[4];
373
376};
377
378#endif
MRML node to represent discrete color information.
Class to hold information about a node reference.
Abstract Superclass for all specific types of MRML nodes.
MRML node for representing a volume (image stack).
A set of MRML Nodes that supports serialization and undo/redo.
MRML node for representing segmentation display attributes.
MRML node containing segmentations.
vtkMRMLSegmentationNode(const vtkMRMLSegmentationNode &)
void GetSegmentCenterRAS(const std::string &segmentID, double centerRAS[3])
void OnSegmentRemoved(const char *segmentId)
static void SegmentationModifiedCallback(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Callback function for all events from the segmentation object.
static vtkMRMLSegmentationNode * New()
void OnSourceRepresentationModified()
std::string AddSegmentFromBinaryLabelmapRepresentation(vtkOrientedImageData *imageData, std::string segmentName="", double color[3]=nullptr, std::string segmentId="")
virtual bool GetBinaryLabelmapRepresentation(const std::string segmentId, vtkOrientedImageData *outputBinaryLabelmap)
void SetLabelmapConversionColorTableNodeID(const char *labelmapConversionColorTableNodeID)
@ EditAllowedInsideAllSegments
Modification is allowed inside all segments.
@ EditAllowedOutsideVisibleSegments
Modification is allowed outside all visible segments.
@ EditAllowedInsideSingleSegment
Modification is allowed only over the area covered by segment specified in MaskSegmentID.
@ EditAllowedInsideVisibleSegments
Modification is allowed inside all visible segments.
@ EditAllowedOutsideAllSegments
Modification is allowed outside all segments.
void RemoveSegment(const std::string &segmentID)
Delete segment from segmentation.
void ApplyTransform(vtkAbstractTransform *transform) override
vtkSegmentation * Segmentation
Segmentation object to store the actual data.
void CreateDefaultDisplayNodes() override
Create and observe a segmentation display node.
static const char * ConvertMaskModeToString(int mode)
Convert between constants IDs to/from string.
static std::string GetReferenceImageGeometryReferenceRole()
Expose reference identifier to get the volume node defining the reference image geometry if any.
const char * GetNodeTagName() override
Get unique node XML tag name (like Volume, Model)
virtual bool CreateBinaryLabelmapRepresentation()
Generate binary labelmap representation for all segments.
virtual vtkIdType GetSegmentSubjectHierarchyItem(std::string segmentID, vtkMRMLSubjectHierarchyNode *shNode)
static int ConvertMaskModeFromString(const char *modeStr)
double * GetSegmentCenter(const std::string &segmentID) VTK_SIZEHINT(3)
Get position of the segment's center (in the segmentation node's coordinate system)
virtual bool SetMasterRepresentationToBinaryLabelmap()
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Reimplemented to invoke ReferenceImageGeometryChangedEvent.
void GetSegmentCenter(const std::string &segmentID, double center[3])
static const char * GetLabelmapConversionColorTableNodeReferenceRole()
virtual bool GenerateEditMask(vtkOrientedImageData *maskImage, int editMode, vtkOrientedImageData *referenceGeometry, std::string editedSegmentID="", std::string maskSegmentID="", vtkOrientedImageData *sourceVolume=nullptr, double editableIntensityRange[2]=nullptr, vtkMRMLSegmentationDisplayNode *displayNode=nullptr)
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Reimplemented to invoke ReferenceImageGeometryChangedEvent.
vtkSmartPointer< vtkCallbackCommand > SegmentationModifiedCallbackCommand
Command handling events from segmentation object.
virtual void OnSubjectHierarchyUIDAdded(vtkMRMLSubjectHierarchyNode *shNode, vtkIdType itemWithNewUID)
void SetAndObserveSegmentation(vtkSegmentation *segmentation)
Set and observe segmentation object.
void GetRASBounds(double bounds[6]) override
void OnSegmentAdded(const char *segmentId)
bool CanApplyNonLinearTransforms() const override
void OnSegmentModified(const char *segmentId)
virtual bool GenerateMergedLabelmap(vtkOrientedImageData *mergedImageData, int extentComputationMode, vtkOrientedImageData *mergedLabelmapGeometry=nullptr, const std::vector< std::string > &segmentIDs=std::vector< std::string >(), vtkIntArray *labelValues=nullptr)
virtual bool SetSourceRepresentationToBinaryLabelmap()
virtual bool GetClosedSurfaceRepresentation(const std::string segmentId, vtkPolyData *outputClosedSurface)
static const char * GetSegmentIDAttributeName()
void PrintSelf(ostream &os, vtkIndent indent) override
virtual bool SetMasterRepresentationToClosedSurface()
virtual void SetReferenceImageGeometryParameterFromVolumeNode(vtkMRMLScalarVolumeNode *volumeNode)
Set reference image geometry conversion parameter from the volume node, keeping reference.
virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData *polyData, std::string segmentName="", double color[3]=nullptr, std::string segmentId="")
virtual void RemoveBinaryLabelmapRepresentation()
Remove binary labelmap representation for all segments.
virtual bool CreateClosedSurfaceRepresentation()
virtual vtkPolyData * GetClosedSurfaceInternalRepresentation(const std::string segmentId)
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Reimplemented to invoke ReferenceImageGeometryChangedEvent.
~vtkMRMLSegmentationNode() override
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void GetBounds(double bounds[6]) override
virtual vtkOrientedImageData * GetBinaryLabelmapInternalRepresentation(const std::string segmentId)
vtkMRMLCopyContentMacro(vtkMRMLSegmentationNode)
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create a segmentation storage node.
virtual bool GenerateMergedLabelmapForAllSegments(vtkOrientedImageData *mergedImageData, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS, vtkOrientedImageData *mergedLabelmapGeometry=nullptr, vtkStringArray *segmentIDs=nullptr, vtkIntArray *labelValues=nullptr)
void operator=(const vtkMRMLSegmentationNode &)
void ApplyTransformMatrix(vtkMatrix4x4 *transformMatrix) override
static const char * GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName()
virtual bool SetSourceRepresentationToClosedSurface()
double * GetSegmentCenterRAS(const std::string &segmentID) VTK_SIZEHINT(3)
vtkMRMLColorTableNode * GetLabelmapConversionColorTableNode()
virtual void RemoveClosedSurfaceRepresentation()
Remove closed surface representation for all segments.
vtkMRMLNode * CreateNodeInstance() override
Create instance of a GAD node.
void ReadXMLAttributes(const char **atts) override
Set node attributes from name/value pairs.
A superclass for other storage nodes.
MRML node to represent a complete subject hierarchy tree.
Image data containing orientation information.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
@ EXTENT_UNION_OF_EFFECTIVE_SEGMENTS
Extent is computed as union of effective extent of all segments.