Slicer 5.9
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
52class VTK_MRML_EXPORT vtkMRMLSegmentationNode : public vtkMRMLDisplayableNode
53{
54public:
55 // Define constants
56 static const char* GetSegmentIDAttributeName() { return "segmentID"; };
57
60 void PrintSelf(ostream& os, vtkIndent indent) override;
61
64
66 void ReadXMLAttributes(const char** atts) override;
67
69 void WriteXML(ostream& of, int indent) override;
70
74
76 const char* GetNodeTagName() override { return "Segmentation"; };
77
82 void GetRASBounds(double bounds[6]) override;
83
87 void GetBounds(double bounds[6]) override;
88
91 bool CanApplyNonLinearTransforms() const override;
92
95 void ApplyTransformMatrix(vtkMatrix4x4* transformMatrix) override;
96
99 void ApplyTransform(vtkAbstractTransform* transform) override;
100
103
106
114 virtual void OnSubjectHierarchyUIDAdded(vtkMRMLSubjectHierarchyNode* shNode, vtkIdType itemWithNewUID);
115
120 virtual vtkIdType GetSegmentSubjectHierarchyItem(std::string segmentID, vtkMRMLSubjectHierarchyNode* shNode);
121
122#ifndef __VTK_WRAP__
123 // BTX
136 virtual bool GenerateMergedLabelmap(vtkOrientedImageData* mergedImageData,
137 int extentComputationMode,
138 vtkOrientedImageData* mergedLabelmapGeometry = nullptr,
139 const std::vector<std::string>& segmentIDs = std::vector<std::string>(),
140 vtkIntArray* labelValues = nullptr);
141// ETX
142#endif // __VTK_WRAP__
143
158 int extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS,
159 vtkOrientedImageData* mergedLabelmapGeometry = nullptr,
160 vtkStringArray* segmentIDs = nullptr,
161 vtkIntArray* labelValues = nullptr);
162
163 enum
164 {
179 };
180
182
183 static const char* ConvertMaskModeToString(int mode);
184 static int ConvertMaskModeFromString(const char* modeStr);
186
198 virtual bool GenerateEditMask(vtkOrientedImageData* maskImage,
199 int editMode,
200 vtkOrientedImageData* referenceGeometry,
201 std::string editedSegmentID = "",
202 std::string maskSegmentID = "",
203 vtkOrientedImageData* sourceVolume = nullptr,
204 double editableIntensityRange[2] = nullptr,
205 vtkMRMLSegmentationDisplayNode* displayNode = nullptr);
206
208 static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
211
213 vtkGetObjectMacro(Segmentation, vtkSegmentation);
216
217 // Convenience functions for commonly needed features
218
220
225
228 {
229 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToBinaryLabelmap() method is deprecated, please use SetSourceRepresentationToBinaryLabelmap method instead");
231 };
232
234 {
235 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToClosedSurface() method is deprecated, please use SetSourceRepresentationToClosedSurface method instead");
237 };
238
241
244
249 virtual bool GetBinaryLabelmapRepresentation(const std::string segmentId, vtkOrientedImageData* outputBinaryLabelmap);
250
258
262
265
270 virtual bool GetClosedSurfaceRepresentation(const std::string segmentId, vtkPolyData* outputClosedSurface);
271
278 virtual vtkPolyData* GetClosedSurfaceInternalRepresentation(const std::string segmentId);
279
282 virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData, std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
283
286 std::string AddSegmentFromBinaryLabelmapRepresentation(vtkOrientedImageData* imageData, std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
287
289 void RemoveSegment(const std::string& segmentID);
290
292 double* GetSegmentCenter(const std::string& segmentID) VTK_SIZEHINT(3);
295 void GetSegmentCenter(const std::string& segmentID, double center[3]);
296
298
301 double* GetSegmentCenterRAS(const std::string& segmentID) VTK_SIZEHINT(3);
304 void GetSegmentCenterRAS(const std::string& segmentID, double centerRAS[3]);
306
308
309 vtkSetMacro(SegmentListFilterEnabled, bool);
310 vtkGetMacro(SegmentListFilterEnabled, bool);
311 vtkBooleanMacro(SegmentListFilterEnabled, bool);
313
315
316 vtkSetMacro(SegmentListFilterOptions, std::string);
317 vtkGetMacro(SegmentListFilterOptions, std::string);
319
321
324 void SetLabelmapConversionColorTableNodeID(const char* labelmapConversionColorTableNodeID);
328
331 enum
332 {
335 };
336
337protected:
339 vtkSetObjectMacro(Segmentation, vtkSegmentation);
340
342 static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
343
347
350 void OnSegmentAdded(const char* segmentId);
351
354 void OnSegmentRemoved(const char* segmentId);
355
358 void OnSegmentModified(const char* segmentId);
359
360 static const char* GetLabelmapConversionColorTableNodeReferenceRole() { return "labelmapConversionColorTableNode"; };
361 static const char* GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName() { return "labelmapConversionColorTableNodeRef"; };
362
365
368
371
372protected:
377
380
382 vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
383
387
390};
391
392#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.
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)
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
@ EditAllowedEverywhere
Modification is allowed everywhere.
@ EditAllowed_Last
Insert valid types above this line.
@ 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 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)
const char * GetLabelmapConversionColorTableNodeID()
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.