Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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
49class vtkSegmentationCore_EXPORT vtkSegmentationConverter : public vtkObject
50{
51public:
52
55 static const char* GetSegmentationBinaryLabelmapRepresentationName() { return "Binary labelmap"; };
56 static const char* GetSegmentationFractionalLabelmapRepresentationName() { return "Fractional labelmap"; };
57 static const char* GetSegmentationPlanarContourRepresentationName() { return "Planar contour"; };
58 static const char* GetSegmentationClosedSurfaceRepresentationName() { return "Closed surface"; };
59 static const char* GetBinaryLabelmapRepresentationName() { return GetSegmentationBinaryLabelmapRepresentationName(); };
60 static const char* GetFractionalLabelmapRepresentationName() { return GetSegmentationFractionalLabelmapRepresentationName(); };
61 static const char* GetPlanarContourRepresentationName() { return GetSegmentationPlanarContourRepresentationName(); };
62 static const char* GetClosedSurfaceRepresentationName() { return GetSegmentationClosedSurfaceRepresentationName(); };
63
64 // Common conversion parameters
65 // ----------------------------
68 static const std::string GetReferenceImageGeometryParameterName() { return "Reference image geometry"; };
69
71 static const char* GetScalarRangeFieldName() {return "ScalarRange";};
72 static const char* GetThresholdValueFieldName() {return "ThresholdValue";};
73 static const char* GetInterpolationTypeFieldName() {return "InterpolationType";};
74
75public:
77 vtkTypeMacro(vtkSegmentationConverter, vtkObject);
78 void PrintSelf(ostream& os, vtkIndent indent) override;
79
81 virtual void DeepCopy(vtkSegmentationConverter* aConverter);
82
84 void GetAvailableRepresentationNames(std::set<std::string>& representationNames);
85
87 void GetPossibleConversions(const std::string& sourceRepresentationName,
88 const std::string& targetRepresentationName, vtkSegmentationConversionPaths* paths);
89
92
95
98
100 void SetConversionParameter(const std::string& name, const std::string& value, const std::string& description="");
101
104 std::string GetConversionParameter(const std::string& name);
105
108 std::string GetConversionParameterDescription(const std::string& description);
109
113
116 void DeserializeConversionParameters(std::string conversionParametersString);
117
121 void ApplyTransformOnReferenceImageGeometry(vtkAbstractTransform* transform);
122
123// Utility functions
124public:
127
129 static std::string SerializeImageGeometry(vtkOrientedImageData* orientedImageData);
130
132 static std::string SerializeImageGeometry(vtkMatrix4x4* geometryMatrix, vtkImageData* imageData);
133
135 static std::string SerializeImageGeometry(vtkMatrix4x4* geometryMatrix, int extent[6]);
136
144 static bool DeserializeImageGeometry(std::string geometryString, vtkOrientedImageData* orientedImageData, bool allocateScalars=true, int scalarType=VTK_VOID, int numberOfScalarsComponents=-1);
145
151 static bool DeserializeImageGeometry(std::string geometryString, vtkMatrix4x4* geometryMatrix, int extent[6]);
152
153protected:
156
166 void FindPath(const std::string& sourceRepresentationName, const std::string& targetRepresentationName,
167 vtkSegmentationConversionPaths* paths, vtkStringArray* skipRepresentations);
168
169protected:
172
173protected:
174 typedef std::vector< vtkSmartPointer<vtkSegmentationConverterRule> > ConverterRulesListType;
175
180
182 typedef std::vector<vtkSegmentationConverterRule*> RulesListType;
184 typedef std::map<std::string, RulesListType> RepresentationToRepresentationToRuleMapType;
185
188
189private:
191 void operator=(const vtkSegmentationConverter&) = delete;
192};
193
194#endif
Image data containing orientation information.
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:46
Store a segmentation conversion path.
Store multiple segmentation conversion paths.
Class that can convert between different representations of a segment.
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()
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)