Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLSegmentationStorageNode.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 Adam Rankin and Csaba Pinter, PerkLab, Queen's
16  University and was supported through the Applied Cancer Research Unit program of Cancer
17  Care Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
18 
19 ==============================================================================*/
20 
21 #ifndef __vtkMRMLSegmentationStorageNode_h
22 #define __vtkMRMLSegmentationStorageNode_h
23 
24 // Temporarily keep support for reading nrrd files that are saved as 4D spatial image.
25 // The current way of writing volume is 3 spatial dimension and a list.
26 #define SUPPORT_4D_SPATIAL_NRRD
27 
28 // MRML includes
29 #include "vtkMRMLStorageNode.h"
30 
31 #ifdef SUPPORT_4D_SPATIAL_NRRD
32  // ITK includes
33  #include <itkImageRegionIteratorWithIndex.h>
34 #endif
35 
37 class vtkMatrix4x4;
38 class vtkPolyData;
40 class vtkSegmentation;
42 class vtkSegment;
43 class vtkInformationStringKey;
44 class vtkInformationIntegerVectorKey;
45 
49 class VTK_MRML_EXPORT vtkMRMLSegmentationStorageNode : public vtkMRMLStorageNode
50 {
51 #ifdef SUPPORT_4D_SPATIAL_NRRD
52  // Although internally binary labelmap representations can be of unsigned char, unsigned short
53  // or short types, the output file is always unsigned char
54  //TODO: This is a limitation for now
55  typedef itk::Image<unsigned char, 4> BinaryLabelmap4DImageType;
56  typedef itk::ImageRegionIteratorWithIndex<BinaryLabelmap4DImageType> BinaryLabelmap4DIteratorType;
57 #endif
58 
59 public:
60  static vtkMRMLSegmentationStorageNode *New();
62  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
63 
64  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
65 
67  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
68 
70  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
71 
73  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
74 
76  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "SegmentationStorage";}
77 
81  virtual const char* GetDefaultWriteFileExtension() VTK_OVERRIDE;
82 
84  virtual bool CanReadInReferenceNode(vtkMRMLNode *refNode) VTK_OVERRIDE;
85 
87  void ResetSupportedWriteFileTypes();
88 
89 protected:
91  virtual void InitializeSupportedReadFileTypes() VTK_OVERRIDE;
92 
94  virtual void InitializeSupportedWriteFileTypes() VTK_OVERRIDE;
95 
97  vtkMRMLSegmentationNode* GetAssociatedDataNode();
98 
100  virtual int WriteDataInternal(vtkMRMLNode *refNode) VTK_OVERRIDE;
101 
103  virtual int WriteBinaryLabelmapRepresentation(vtkMRMLSegmentationNode* segmentationNode, std::string path);
104 
106  virtual int WritePolyDataRepresentation(vtkMRMLSegmentationNode* segmentationNode, std::string path);
107 
109  virtual int ReadDataInternal(vtkMRMLNode *refNode) VTK_OVERRIDE;
110 
112  virtual int ReadBinaryLabelmapRepresentation(vtkMRMLSegmentationNode* segmentationNode, std::string path);
113 
114 #ifdef SUPPORT_4D_SPATIAL_NRRD
115  virtual int ReadBinaryLabelmapRepresentation4DSpatial(vtkMRMLSegmentationNode* segmentationNode, std::string path);
117 #endif
118 
120  virtual int ReadPolyDataRepresentation(vtkMRMLSegmentationNode* segmentationNode, std::string path);
121 
124  void AddPolyDataFileNames(std::string path, vtkSegmentation* segmentation);
125 
127  std::string SerializeContainedRepresentationNames(vtkSegmentation* segmentation);
128 
130  void CreateRepresentationsBySerializedNames(vtkSegmentation* segmentation, std::string representationNames);
131 
132  static std::string GetSegmentMetaDataKey(int segmentIndex, const std::string& keyName);
133 
134  static std::string GetSegmentationMetaDataKey(const std::string& keyName);
135 
136  static std::string GetSegmentTagsAsString(vtkSegment* segment);
137  static void SetSegmentTagsFromString(vtkSegment* segment, std::string tagsValue);
138 
139  static std::string GetImageExtentAsString(vtkOrientedImageData* image);
140  static std::string GetImageExtentAsString(int extent[6]);
141  static void GetImageExtentFromString(int extent[6], std::string extentValue);
142 
143  static std::string GetSegmentColorAsString(vtkMRMLSegmentationNode* segmentationNode, const std::string& segmentId);
144  static void GetSegmentColorFromString(double color[3], std::string colorString);
145 
146 protected:
149 
150 private:
153 };
154 
155 #endif
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
LRU Cache.
MRML node for segmentation storage on disk.
virtual const char * GetDefaultWriteFileExtension()
Return default file extension for writing.
void operator=(const vtkMRMLStorageNode &)
Image data containing orientation information.
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
Create instance of the default node. Like New only virtual.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
A superclass for other storage nodes.
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:138
MRML node containing segmentationsSegmentation node stores a set of segments (also known as contours ...