Slicer  4.11
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 vtkIntArray;
37 class vtkMRMLScene;
41 class vtkPolyData;
42 
53 class VTK_MRML_EXPORT vtkMRMLSegmentationNode : public vtkMRMLDisplayableNode
54 {
55 public:
56  // Define constants
57  static const char* GetSegmentIDAttributeName() { return "segmentID"; };
58 
59  static vtkMRMLSegmentationNode *New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64  vtkMRMLNode* CreateNodeInstance() override;
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 
106  void CreateDefaultDisplayNodes() 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
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 
155  virtual bool GenerateMergedLabelmapForAllSegments(vtkOrientedImageData* mergedImageData,
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 
188  virtual bool GenerateEditMask(vtkOrientedImageData* maskImage, int editMode,
189  vtkOrientedImageData* referenceGeometry,
190  std::string editedSegmentID="", std::string maskSegmentID="",
191  vtkOrientedImageData* masterVolume = nullptr, double editableIntensityRange[2] = nullptr,
192  vtkMRMLSegmentationDisplayNode* displayNode = nullptr);
193 
195  static std::string GetReferenceImageGeometryReferenceRole() { return "referenceImageGeometryRef"; };
197  virtual void SetReferenceImageGeometryParameterFromVolumeNode(vtkMRMLScalarVolumeNode* volumeNode);
198 
200  vtkGetObjectMacro(Segmentation, vtkSegmentation);
202  void SetAndObserveSegmentation(vtkSegmentation* segmentation);
203 
204  // Convenience functions for commonly needed features
205 
208  virtual bool SetMasterRepresentationToBinaryLabelmap();
211  virtual bool SetMasterRepresentationToClosedSurface();
212 
214  virtual bool CreateBinaryLabelmapRepresentation();
215 
217  virtual void RemoveBinaryLabelmapRepresentation();
218 
223  virtual bool GetBinaryLabelmapRepresentation(const std::string segmentId, vtkOrientedImageData* outputBinaryLabelmap);
224 
231  virtual vtkOrientedImageData* GetBinaryLabelmapInternalRepresentation(const std::string segmentId);
232 
235  virtual bool CreateClosedSurfaceRepresentation();
236 
238  virtual void RemoveClosedSurfaceRepresentation();
239 
244  virtual bool GetClosedSurfaceRepresentation(const std::string segmentId, vtkPolyData* outputClosedSurface);
245 
249  virtual vtkPolyData* GetClosedSurfaceInternalRepresentation(const std::string segmentId);
250 
253  virtual std::string AddSegmentFromClosedSurfaceRepresentation(vtkPolyData* polyData,
254  std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
255 
258  std::string AddSegmentFromBinaryLabelmapRepresentation(vtkOrientedImageData* imageData,
259  std::string segmentName = "", double color[3] = nullptr, std::string segmentId = "");
260 
262  void RemoveSegment(const std::string& segmentID);
263 
265  double* GetSegmentCenter(const std::string& segmentID) VTK_SIZEHINT(3);
268  void GetSegmentCenter(const std::string& segmentID, double center[3]);
269 
273  double* GetSegmentCenterRAS(const std::string& segmentID) VTK_SIZEHINT(3);
276  void GetSegmentCenterRAS(const std::string& segmentID, double centerRAS[3]);
277 
279  vtkSetMacro(SegmentListFilterEnabled, bool);
280  vtkGetMacro(SegmentListFilterEnabled, bool);
281  vtkBooleanMacro(SegmentListFilterEnabled, bool);
282 
284  vtkSetMacro(SegmentListFilterOptions, std::string);
285  vtkGetMacro(SegmentListFilterOptions, std::string);
286 
290  void SetLabelmapConversionColorTableNodeID(const char* labelmapConversionColorTableNodeID);
291  vtkMRMLColorTableNode* GetLabelmapConversionColorTableNode();
292 
294  enum
295  {
296  ReferenceImageGeometryChangedEvent = 23000
297  };
298 
299 protected:
301  vtkSetObjectMacro(Segmentation, vtkSegmentation);
302 
304  static void SegmentationModifiedCallback(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
305 
308  void OnMasterRepresentationModified();
309 
312  void OnSegmentAdded(const char* segmentId);
313 
316  void OnSegmentRemoved(const char* segmentId);
317 
320  void OnSegmentModified(const char* segmentId);
321 
322  static const char* GetLabelmapConversionColorTableNodeReferenceRole() { return "labelmapConversionColorTableNode"; };
323  static const char* GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName() { return "labelmapConversionColorTableNodeRef"; };
324 
326  void OnNodeReferenceAdded(vtkMRMLNodeReference* reference) override;
327 
329  void OnNodeReferenceModified(vtkMRMLNodeReference* reference) override;
330 
332  void OnNodeReferenceRemoved(vtkMRMLNodeReference* reference) override;
333 
334 protected:
336  ~vtkMRMLSegmentationNode() override;
338  void operator=(const vtkMRMLSegmentationNode&);
339 
342 
344  vtkSmartPointer<vtkCallbackCommand> SegmentationModifiedCallbackCommand;
345 
348  double SegmentCenterTmp[4];
349 
352 };
353 
354 #endif // __vtkMRMLSegmentationNode_h
vtkSmartPointer< vtkCallbackCommand > SegmentationModifiedCallbackCommand
Command handling events from segmentation object.
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
static const char * GetLabelmapConversionColorTableNodeReferenceMRMLAttributeName()
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Called after a node reference ID is removed (list size decreased).
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])
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Called when a node reference ID is added (list size increased).
virtual void ApplyTransform(vtkAbstractTransform *transform)
Modification is allowed outside all visible segments.
const char * GetNodeTagName() override
Get unique node XML tag name (like Volume, Model)
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
void operator=(const vtkMRMLDisplayableNode &)
MRML node to represent a complete subject hierarchy tree.
Image data containing orientation information.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
void PrintSelf(ostream &os, vtkIndent indent) override
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)
Modification is allowed only over the area covered by segment specified in MaskSegmentID.
MRML node for representing segmentation display attributes.
static const char * GetSegmentIDAttributeName()
A superclass for other storage nodes.
Modification is allowed inside all segments.
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
Extent is computed as union of effective extent of all segments.
static const char * GetLabelmapConversionColorTableNodeReferenceRole()
vtkMRMLCopyContentMacro(vtkMRMLStorableNode)
virtual bool CanApplyNonLinearTransforms() const
MRML node for representing a volume (image stack).
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
MRML node to represent discrete color information.
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Called when a node reference ID is modified.
Modification is allowed inside all visible segments.
Modification is allowed outside all segments.
virtual void GetRASBounds(double bounds[6])
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...