Slicer  4.10
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;
40 class vtkPolyData;
41 
52 class VTK_MRML_EXPORT vtkMRMLSegmentationNode : public vtkMRMLDisplayableNode
53 {
54 public:
55  // Define constants
56  static const char* GetSegmentIDAttributeName() { return "segmentID"; };
57 
58  static vtkMRMLSegmentationNode *New();
60  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
61 
63  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
64 
66  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
67 
69  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
70 
72  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
73 
75  virtual void DeepCopy(vtkMRMLNode* node);
76 
78  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Segmentation";};
79 
84  virtual void GetRASBounds(double bounds[6]) VTK_OVERRIDE;
85 
89  virtual void GetBounds(double bounds[6]) VTK_OVERRIDE;
90 
93  virtual bool CanApplyNonLinearTransforms()const VTK_OVERRIDE;
94 
97  virtual void ApplyTransformMatrix(vtkMatrix4x4* transformMatrix) VTK_OVERRIDE;
98 
101  virtual void ApplyTransform(vtkAbstractTransform* transform) VTK_OVERRIDE;
102 
104  virtual vtkMRMLStorageNode* CreateDefaultStorageNode() VTK_OVERRIDE;
105 
107  virtual void CreateDefaultDisplayNodes() VTK_OVERRIDE;
108 
116  virtual void OnSubjectHierarchyUIDAdded(vtkMRMLSubjectHierarchyNode* shNode, vtkIdType itemWithNewUID);
117 
122  virtual vtkIdType GetSegmentSubjectHierarchyItem(std::string segmentID, vtkMRMLSubjectHierarchyNode* shNode);
123 
124 #ifndef __VTK_WRAP__
125 //BTX
134  virtual bool GenerateMergedLabelmap(vtkOrientedImageData* mergedImageData, int extentComputationMode, vtkOrientedImageData* mergedLabelmapGeometry = NULL, const std::vector<std::string>& segmentIDs = std::vector<std::string>());
135 //ETX
136 #endif // __VTK_WRAP__
137 
142  virtual bool GenerateMergedLabelmapForAllSegments(vtkOrientedImageData* mergedImageData,
143  int extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS,
144  vtkOrientedImageData* mergedLabelmapGeometry = NULL, vtkStringArray* segmentIDs = NULL);
145 
146  enum
147  {
149  EditAllowedEverywhere = 0,
161  EditAllowed_Last
162  };
163 
175  virtual bool GenerateEditMask(vtkOrientedImageData* maskImage, int editMode,
176  vtkOrientedImageData* referenceGeometry,
177  std::string editedSegmentID="", std::string maskSegmentID="",
178  vtkOrientedImageData* masterVolume = NULL, double editableIntensityRange[2] = NULL,
179  vtkMRMLSegmentationDisplayNode* displayNode = NULL);
180 
182  static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
184  virtual void SetReferenceImageGeometryParameterFromVolumeNode(vtkMRMLScalarVolumeNode* volumeNode);
185 
187  vtkGetObjectMacro(Segmentation, vtkSegmentation);
189  void SetAndObserveSegmentation(vtkSegmentation* segmentation);
190 
191  // Convenience functions for commonly needed features
192 
195  virtual bool SetMasterRepresentationToBinaryLabelmap();
198  virtual bool SetMasterRepresentationToClosedSurface();
199 
201  virtual bool CreateBinaryLabelmapRepresentation();
202 
204  virtual void RemoveBinaryLabelmapRepresentation();
205 
210  virtual vtkOrientedImageData* GetBinaryLabelmapRepresentation(const std::string segmentId);
211 
214  virtual bool CreateClosedSurfaceRepresentation();
215 
217  virtual void RemoveClosedSurfaceRepresentation();
218 
223  virtual vtkPolyData* GetClosedSurfaceRepresentation(const std::string segmentId);
224 
227  virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData,
228  std::string segmentName = "", double color[3] = NULL, std::string segmentId = "");
229 
232  std::string AddSegmentFromBinaryLabelmapRepresentation(vtkOrientedImageData* imageData,
233  std::string segmentName = "", double color[3] = NULL, std::string segmentId = "");
234 
236  void RemoveSegment(const std::string& segmentID);
237 
239  double* GetSegmentCenter(const std::string& segmentID);
240 
244  double* GetSegmentCenterRAS(const std::string& segmentID);
245 
246 protected:
248  vtkSetObjectMacro(Segmentation, vtkSegmentation);
249 
251  static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
252 
255  void OnMasterRepresentationModified();
256 
259  void OnSegmentAdded(const char* segmentId);
260 
263  void OnSegmentRemoved(const char* segmentId);
264 
267  void OnSegmentModified(const char* segmentId);
268 
269 protected:
271  virtual ~vtkMRMLSegmentationNode();
273  void operator=(const vtkMRMLSegmentationNode&);
274 
277 
279  vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
280 
283  double SegmentCenterTmp[4];
284 };
285 
286 #endif // __vtkMRMLSegmentationNode_h
vtkSmartPointer< vtkCallbackCommand > SegmentationModifiedCallbackCommand
Command handling events from segmentation object.
Modification is allowed outside all visible segments.
static std::string GetReferenceImageGeometryReferenceRole()
Expose reference identifier to get the volume node defining the reference image geometry if any...
Modification is allowed inside all visible segments.
virtual void GetBounds(double bounds[6])
LRU Cache.
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
Modification is allowed inside all segments.
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.
MRML node for representing segmentation display attributes.
static const char * GetSegmentIDAttributeName()
Modification is allowed only over the area covered by segment specified in MaskSegmentID.
A superclass for other storage nodes.
Modification is allowed outside all segments.
Extent is computed as union of effective extent of all segments.
virtual bool CanApplyNonLinearTransforms() const
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
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 ...