Slicer 5.8
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, int extentComputationMode, vtkOrientedImageData* mergedLabelmapGeometry = nullptr,
137 const std::vector<std::string>& segmentIDs = std::vector<std::string>(), vtkIntArray* labelValues = nullptr);
138//ETX
139#endif // __VTK_WRAP__
140
155 int extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS,
156 vtkOrientedImageData* mergedLabelmapGeometry = nullptr, vtkStringArray* segmentIDs = nullptr, vtkIntArray* labelValues = nullptr);
157
158 enum
159 {
161 EditAllowedEverywhere = 0,
173 EditAllowed_Last
174 };
175
177
178 static const char* ConvertMaskModeToString(int mode);
179 static int ConvertMaskModeFromString(const char* modeStr);
181
193 virtual bool GenerateEditMask(vtkOrientedImageData* maskImage, int editMode,
194 vtkOrientedImageData* referenceGeometry,
195 std::string editedSegmentID="", std::string maskSegmentID="",
196 vtkOrientedImageData* sourceVolume = nullptr, double editableIntensityRange[2] = nullptr,
197 vtkMRMLSegmentationDisplayNode* displayNode = nullptr);
198
200 static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
203
205 vtkGetObjectMacro(Segmentation, vtkSegmentation);
208
209 // Convenience functions for commonly needed features
210
217
220 {
221 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToBinaryLabelmap() method is deprecated, please use SetSourceRepresentationToBinaryLabelmap method instead");
222 return this->SetSourceRepresentationToClosedSurface();
223 };
226 {
227 vtkWarningMacro("vtkSegmentation::SetMasterRepresentationToClosedSurface() method is deprecated, please use SetSourceRepresentationToClosedSurface method instead");
228 return this->SetSourceRepresentationToClosedSurface();
229 };
230
233
236
241 virtual bool GetBinaryLabelmapRepresentation(const std::string segmentId, vtkOrientedImageData* outputBinaryLabelmap);
242
250
254
257
262 virtual bool GetClosedSurfaceRepresentation(const std::string segmentId, vtkPolyData* outputClosedSurface);
263
270 virtual vtkPolyData* GetClosedSurfaceInternalRepresentation(const std::string segmentId);
271
274 virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData,
275 std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
276
280 std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
281
283 void RemoveSegment(const std::string& segmentID);
284
286 double* GetSegmentCenter(const std::string& segmentID) VTK_SIZEHINT(3);
289 void GetSegmentCenter(const std::string& segmentID, double center[3]);
290
294 double* GetSegmentCenterRAS(const std::string& segmentID) VTK_SIZEHINT(3);
297 void GetSegmentCenterRAS(const std::string& segmentID, double centerRAS[3]);
298
300 vtkSetMacro(SegmentListFilterEnabled, bool);
301 vtkGetMacro(SegmentListFilterEnabled, bool);
302 vtkBooleanMacro(SegmentListFilterEnabled, bool);
303
305 vtkSetMacro(SegmentListFilterOptions, std::string);
306 vtkGetMacro(SegmentListFilterOptions, std::string);
307
311 void SetLabelmapConversionColorTableNodeID(const char* labelmapConversionColorTableNodeID);
313
316 enum
317 {
318 ReferenceImageGeometryChangedEvent = 23000,
319 SegmentationChangedEvent
320 };
321
322protected:
324 vtkSetObjectMacro(Segmentation, vtkSegmentation);
325
327 static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
328
332
335 void OnSegmentAdded(const char* segmentId);
336
339 void OnSegmentRemoved(const char* segmentId);
340
343 void OnSegmentModified(const char* segmentId);
344
345 static const char* GetLabelmapConversionColorTableNodeReferenceRole() { return "labelmapConversionColorTableNode"; };
346 static const char* GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName() { return "labelmapConversionColorTableNodeRef"; };
347
350
353
356
357protected:
362
365
367 vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
368
371 double SegmentCenterTmp[4];
372
375};
376
377#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)
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)
@ 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 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.