Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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>
26 #include <vtkMRMLDisplayableNode.h>
27 #include <vtkMRMLColorTableNode.h>
28 
29 // STD includes
30 #include <cstdlib>
31 
32 // vtkSegmentationCore includes
33 #include "vtkSegmentation.h"
34 
35 class vtkCallbackCommand;
36 class vtkMRMLScene;
39 class vtkPolyData;
40 
51 class VTK_MRML_EXPORT vtkMRMLSegmentationNode : public vtkMRMLDisplayableNode
52 {
53 public:
54  // Define constants
55  static const char* GetSegmentIDAttributeName() { return "segmentID"; };
56 
57  static vtkMRMLSegmentationNode *New();
59  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
60 
62  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
63 
65  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
66 
68  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
69 
71  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
72 
74  virtual void DeepCopy(vtkMRMLNode* node);
75 
77  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Segmentation";};
78 
83  virtual void GetRASBounds(double bounds[6]) VTK_OVERRIDE;
84 
88  virtual void GetBounds(double bounds[6]) VTK_OVERRIDE;
89 
92  virtual bool CanApplyNonLinearTransforms()const VTK_OVERRIDE;
93 
96  virtual void ApplyTransformMatrix(vtkMatrix4x4* transformMatrix) VTK_OVERRIDE;
97 
100  virtual void ApplyTransform(vtkAbstractTransform* transform) VTK_OVERRIDE;
101 
103  virtual vtkMRMLStorageNode* CreateDefaultStorageNode() VTK_OVERRIDE;
104 
106  virtual void CreateDefaultDisplayNodes() VTK_OVERRIDE;
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
133  virtual bool GenerateMergedLabelmap(vtkOrientedImageData* mergedImageData, int extentComputationMode, vtkOrientedImageData* mergedLabelmapGeometry = NULL, const std::vector<std::string>& segmentIDs = std::vector<std::string>());
134 //ETX
135 #endif // __VTK_WRAP__
136 
141  virtual bool GenerateMergedLabelmapForAllSegments(vtkOrientedImageData* mergedImageData,
142  int extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS,
143  vtkOrientedImageData* mergedLabelmapGeometry = NULL, vtkStringArray* segmentIDs = NULL);
144 
146  static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
148  virtual void SetReferenceImageGeometryParameterFromVolumeNode(vtkMRMLScalarVolumeNode* volumeNode);
149 
151  vtkGetObjectMacro(Segmentation, vtkSegmentation);
153  void SetAndObserveSegmentation(vtkSegmentation* segmentation);
154 
155  // Convenience functions for commonly needed features
156 
159  virtual bool SetMasterRepresentationToBinaryLabelmap();
162  virtual bool SetMasterRepresentationToClosedSurface();
163 
165  virtual bool CreateBinaryLabelmapRepresentation();
166 
168  virtual void RemoveBinaryLabelmapRepresentation();
169 
174  virtual vtkOrientedImageData* GetBinaryLabelmapRepresentation(const std::string segmentId);
175 
178  virtual bool CreateClosedSurfaceRepresentation();
179 
181  virtual void RemoveClosedSurfaceRepresentation();
182 
187  virtual vtkPolyData* GetClosedSurfaceRepresentation(const std::string segmentId);
188 
191  virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData,
192  std::string segmentName = "", double color[3] = NULL, std::string segmentId = "");
193 
196  std::string AddSegmentFromBinaryLabelmapRepresentation(vtkOrientedImageData* imageData,
197  std::string segmentName = "", double color[3] = NULL, std::string segmentId = "");
198 
200  void RemoveSegment(const std::string& segmentID);
201 
202 protected:
204  vtkSetObjectMacro(Segmentation, vtkSegmentation);
205 
207  static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
208 
211  void OnMasterRepresentationModified();
212 
215  void OnSegmentAdded(const char* segmentId);
216 
219  void OnSegmentRemoved(const char* segmentId);
220 
223  void OnSegmentModified(const char* segmentId);
224 
225 protected:
227  virtual ~vtkMRMLSegmentationNode();
229  void operator=(const vtkMRMLSegmentationNode&);
230 
233 
235  vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
236 };
237 
238 #endif // __vtkMRMLSegmentationNode_h
vtkSmartPointer< vtkCallbackCommand > SegmentationModifiedCallbackCommand
Command handling events from segmentation object.
static std::string GetReferenceImageGeometryReferenceRole()
Expose reference identifier to get the volume node defining the reference image geometry if any...
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
virtual void GetBounds(double bounds[6])
Extent is computed as union of effective extent of all segments.
virtual void ApplyTransform(vtkAbstractTransform *transform)
void operator=(const vtkMRMLDisplayableNode &)
MRML node to represent a complete subject hierarchy tree.
Image data containing orientation information.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
vtkSegmentation * Segmentation
Segmentation object to store the actual data.
virtual void CreateDefaultDisplayNodes()
virtual void ApplyTransformMatrix(vtkMatrix4x4 *transformMatrix)
static const char * GetSegmentIDAttributeName()
A supercalss for other storage nodes.
virtual bool CanApplyNonLinearTransforms() const
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
MRMLNode methods.
virtual void GetRASBounds(double bounds[6])
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...