Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkSegmentationConverterRule.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 __vtkSegmentationConverterRule_h
22#define __vtkSegmentationConverterRule_h
23
24#include "vtkSegmentationCoreConfigure.h"
25
26// VTK includes
27#include <vtkNew.h>
28#include <vtkObject.h>
29
30class vtkDataObject;
31class vtkSegmentation;
32class vtkSegment;
33
35
37#ifndef vtkSegmentationConverterRuleNewMacro
38#define vtkSegmentationConverterRuleNewMacro(newClass) \
39 vtkStandardNewMacro(newClass); \
40 vtkSegmentationConverterRule* newClass::CreateRuleInstance() \
41 { \
42 return newClass::New(); \
43 }
44#endif
54class vtkSegmentationCore_EXPORT vtkSegmentationConverterRule : public vtkObject
55{
56public:
57
60 static unsigned int GetConversionInfiniteCost() { return 10000000; };
61
62public:
63 //static vtkSegmentationConverterRule* New();
64 vtkTypeMacro(vtkSegmentationConverterRule, vtkObject);
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
70
73
77 virtual vtkDataObject* ConstructRepresentationObjectByRepresentation(std::string representationName) = 0;
78
82 virtual vtkDataObject* ConstructRepresentationObjectByClass(std::string className) = 0;
83
86 virtual bool PreConvert(vtkSegmentation* vtkNotUsed(segmentation)) { return true; };
87
91 virtual bool Convert(vtkSegment* segment) = 0;
92
95 virtual bool PostConvert(vtkSegmentation* vtkNotUsed(segmentation)) { return true; };
96
101 virtual unsigned int GetConversionCost(vtkDataObject* sourceRepresentation=nullptr, vtkDataObject* targetRepresentation=nullptr)
102 {
103 (void)(sourceRepresentation); // unused
104 (void)(targetRepresentation); // unused
105 return 100;
106 };
107
109 virtual const char* GetName() = 0;
110
112 virtual const char* GetSourceRepresentationName() = 0;
113
115 virtual const char* GetTargetRepresentationName() = 0;
116
120 virtual void GetRuleConversionParameters(vtkSegmentationConversionParameters* conversionParameters) VTK_EXPECTS(conversionParameters != nullptr);
121
123 virtual void SetConversionParameter(const std::string& name, const std::string& value, const std::string& description="");
124
126 virtual std::string GetConversionParameter(const std::string& name);
127
129 virtual std::string GetConversionParameterDescription(const std::string& name);
130
132 bool HasConversionParameter(const std::string& name);
133
134protected:
137
141
142protected:
148 vtkNew<vtkSegmentationConversionParameters> ConversionParameters;
149
154 bool ReplaceTargetRepresentation{false};
155
157};
158
159#endif
This class encapsulates a segment that is part of a segmentation.
Definition vtkSegment.h:46
Abstract converter rule class. Subclasses perform conversions between specific representation types....
vtkNew< vtkSegmentationConversionParameters > ConversionParameters
virtual bool PreConvert(vtkSegmentation *vtkNotUsed(segmentation))
virtual unsigned int GetConversionCost(vtkDataObject *sourceRepresentation=nullptr, vtkDataObject *targetRepresentation=nullptr)
virtual bool Convert(vtkSegment *segment)=0
virtual vtkSegmentationConverterRule * Clone()
Create a new instance of this rule and copy its contents.
bool HasConversionParameter(const std::string &name)
Determine if the rule has a parameter with a certain name.
~vtkSegmentationConverterRule() override
virtual bool PostConvert(vtkSegmentation *vtkNotUsed(segmentation))
void operator=(const vtkSegmentationConverterRule &)
virtual void GetRuleConversionParameters(vtkSegmentationConversionParameters *conversionParameters) VTK_EXPECTS(conversionParameters !
virtual void SetConversionParameter(const std::string &name, const std::string &value, const std::string &description="")
Set a conversion parameter.
virtual const char * GetSourceRepresentationName()=0
Human-readable name of the source representation.
virtual const char * GetTargetRepresentationName()=0
Human-readable name of the target representation.
virtual vtkDataObject * ConstructRepresentationObjectByRepresentation(std::string representationName)=0
virtual const char * GetName()=0
Human-readable name of the converter rule.
virtual std::string GetConversionParameterDescription(const std::string &name)
Get a conversion parameter description.
virtual vtkDataObject * ConstructRepresentationObjectByClass(std::string className)=0
virtual std::string GetConversionParameter(const std::string &name)
Get a conversion parameter value.
virtual bool CreateTargetRepresentation(vtkSegment *segment)
Update the target representation based on the source representation.
virtual vtkSegmentationConverterRule * CreateRuleInstance()=0
void PrintSelf(ostream &os, vtkIndent indent) override
Class that can convert between different representations of a segment.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...