Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
vtkSegmentationConverter.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 __vtkSegmentationConverter_h
22#define __vtkSegmentationConverter_h
23
24// VTK includes
25#include <vtkObject.h>
26#include <vtkSmartPointer.h>
27#include <vtkStringArray.h>
28
29// STD includes
30#include <map>
31#include <set>
32#include <utility>
33#include <vector>
34
35// Segmentation includes
36#include "vtkSegmentationCoreConfigure.h"
37
40
41class vtkAbstractTransform;
42class vtkSegment;
43class vtkMatrix4x4;
44class vtkImageData;
46
48class vtkSegmentationCore_EXPORT vtkSegmentationConverter : public vtkObject
49{
50public:
51
54 static const char* GetSegmentationBinaryLabelmapRepresentationName() { return "Binary labelmap"; };
55 static const char* GetSegmentationFractionalLabelmapRepresentationName() { return "Fractional labelmap"; };
56 static const char* GetSegmentationPlanarContourRepresentationName() { return "Planar contour"; };
57 static const char* GetSegmentationClosedSurfaceRepresentationName() { return "Closed surface"; };
62
63 // Common conversion parameters
64 // ----------------------------
67 static const std::string GetReferenceImageGeometryParameterName() { return "Reference image geometry"; };
68
70 static const char* GetScalarRangeFieldName() {return "ScalarRange";};
71 static const char* GetThresholdValueFieldName() {return "ThresholdValue";};
72 static const char* GetInterpolationTypeFieldName() {return "InterpolationType";};
73
74public:
76 vtkTypeMacro(vtkSegmentationConverter, vtkObject);
77 void PrintSelf(ostream& os, vtkIndent indent) override;
78
80 virtual void DeepCopy(vtkSegmentationConverter* aConverter);
81
83 void GetAvailableRepresentationNames(std::set<std::string>& representationNames);
84
86 void GetPossibleConversions(const std::string& sourceRepresentationName,
87 const std::string& targetRepresentationName, vtkSegmentationConversionPaths* paths);
88
91
94
97
99 void SetConversionParameter(const std::string& name, const std::string& value, const std::string& description="");
100
103 std::string GetConversionParameter(const std::string& name);
104
107 std::string GetConversionParameterDescription(const std::string& description);
108
112
115 void DeserializeConversionParameters(std::string conversionParametersString);
116
120 void ApplyTransformOnReferenceImageGeometry(vtkAbstractTransform* transform);
121
122// Utility functions
123public:
126
128 static std::string SerializeImageGeometry(vtkOrientedImageData* orientedImageData);
129
131 static std::string SerializeImageGeometry(vtkMatrix4x4* geometryMatrix, vtkImageData* imageData);
132
134 static std::string SerializeImageGeometry(vtkMatrix4x4* geometryMatrix, int extent[6]);
135
143 static bool DeserializeImageGeometry(std::string geometryString, vtkOrientedImageData* orientedImageData, bool allocateScalars=true, int scalarType=VTK_VOID, int numberOfScalarsComponents=-1);
144
150 static bool DeserializeImageGeometry(std::string geometryString, vtkMatrix4x4* geometryMatrix, int extent[6]);
151
152protected:
155
165 void FindPath(const std::string& sourceRepresentationName, const std::string& targetRepresentationName,
166 vtkSegmentationConversionPaths* paths, vtkStringArray* skipRepresentations);
167
168protected:
171
172protected:
173 typedef std::vector< vtkSmartPointer<vtkSegmentationConverterRule> > ConverterRulesListType;
174
179
181 typedef std::vector<vtkSegmentationConverterRule*> RulesListType;
183 typedef std::map<std::string, RulesListType> RepresentationToRepresentationToRuleMapType;
184
187
190 vtkSmartPointer<vtkSegmentationConversionParameters> CustomConversionParameters;
191
192private:
194 void operator=(const vtkSegmentationConverter&) = delete;
195};
196
197#endif
Image data containing orientation information.
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:45
Store a segmentation conversion path.
Store multiple segmentation conversion paths.
static const char * GetFractionalLabelmapRepresentationName()
static std::string SerializeImageGeometry(vtkMatrix4x4 *geometryMatrix, vtkImageData *imageData)
Utility function for serializing geometry of a complete geometry matrix and regular image data (provi...
std::vector< vtkSegmentationConverterRule * > RulesListType
For each "to" representation (first) stores a rule (second)
static vtkSegmentationConverter * New()
std::map< std::string, RulesListType > RepresentationToRepresentationToRuleMapType
For each "from" representation (first) stores an array of rules (second)
static const char * GetSegmentationFractionalLabelmapRepresentationName()
static const char * GetInterpolationTypeFieldName()
static std::string SerializeImageGeometry(vtkOrientedImageData *orientedImageData)
Utility function for serializing geometry of oriented image data.
static bool DeserializeImageGeometry(std::string geometryString, vtkMatrix4x4 *geometryMatrix, int extent[6])
static const char * GetSegmentationPlanarContourRepresentationName()
vtkSmartPointer< vtkSegmentationConversionParameters > CustomConversionParameters
static const std::string GetReferenceImageGeometryParameterName()
static const char * GetBinaryLabelmapRepresentationName()
std::vector< vtkSmartPointer< vtkSegmentationConverterRule > > ConverterRulesListType
void ApplyTransformOnReferenceImageGeometry(vtkAbstractTransform *transform)
static const char * GetSegmentationClosedSurfaceRepresentationName()
static const char * GetThresholdValueFieldName()
void RebuildRulesGraph()
Build a graph from ConverterRules list to facilitate faster finding of rules from a specific represen...
static const char * GetScalarRangeFieldName()
Field names for 2D display parameters.
static const char * GetClosedSurfaceRepresentationName()
std::string SerializeAllConversionParameters()
void GetConversionParametersForPath(vtkSegmentationConversionParameters *conversionParameters, vtkSegmentationConversionPath *path)
Get all conversion parameters used by the selected conversion path.
void PrintSelf(ostream &os, vtkIndent indent) override
void GetPossibleConversions(const std::string &sourceRepresentationName, const std::string &targetRepresentationName, vtkSegmentationConversionPaths *paths)
Get all possible conversions between two representations.
static vtkSegmentationConversionPath * GetCheapestPath(vtkSegmentationConversionPaths *paths)
Return cheapest path from a list of paths with costs.
std::string GetConversionParameterDescription(const std::string &description)
static bool DeserializeImageGeometry(std::string geometryString, vtkOrientedImageData *orientedImageData, bool allocateScalars=true, int scalarType=VTK_VOID, int numberOfScalarsComponents=-1)
std::string GetConversionParameter(const std::string &name)
void GetAllConversionParameters(vtkSegmentationConversionParameters *conversionParameters)
Get all conversion parameters in this converter. Aggregates all parameters from all rules.
void SetConversionParameters(vtkSegmentationConversionParameters *parameters)
Set a list of conversion parameters to all rules (cannot change the description, only the value)
static std::string SerializeImageGeometry(vtkMatrix4x4 *geometryMatrix, int extent[6])
Utility function for serializing geometry of a complete geometry matrix and given extents.
static const char * GetSegmentationBinaryLabelmapRepresentationName()
~vtkSegmentationConverter() override
void FindPath(const std::string &sourceRepresentationName, const std::string &targetRepresentationName, vtkSegmentationConversionPaths *paths, vtkStringArray *skipRepresentations)
void SetConversionParameter(const std::string &name, const std::string &value, const std::string &description="")
Set a conversion parameter to all rules having this parameter.
ConverterRulesListType ConverterRules
static const char * GetPlanarContourRepresentationName()
void GetAvailableRepresentationNames(std::set< std::string > &representationNames)
Get all representations supported by the converter.
virtual void DeepCopy(vtkSegmentationConverter *aConverter)
Deep copy one converter into another.
RepresentationToRepresentationToRuleMapType RulesGraph
Source representation to target representation rule graph.
void DeserializeConversionParameters(std::string conversionParametersString)