Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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 
30 class vtkDataObject;
31 class vtkSegmentation;
32 class 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
45 class vtkSegmentationCore_EXPORT vtkSegmentationConverterRule : public vtkObject
55 {
56 public:
57 
60  static unsigned int GetConversionInfiniteCost() { return 10000000; };
61 
62 public:
63  //static vtkSegmentationConverterRule* New();
64  vtkTypeMacro(vtkSegmentationConverterRule, vtkObject);
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
69  virtual vtkSegmentationConverterRule* CreateRuleInstance() = 0;
70 
72  virtual vtkSegmentationConverterRule* Clone();
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 
134 protected:
136  virtual bool CreateTargetRepresentation(vtkSegment* segment);
137 
139  ~vtkSegmentationConverterRule() override;
140  void operator=(const vtkSegmentationConverterRule&);
141 
142 protected:
148  vtkNew<vtkSegmentationConversionParameters> ConversionParameters;
149 
154  bool ReplaceTargetRepresentation{false};
155 
157 };
158 
159 #endif // __vtkSegmentationConverterRule_h
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
virtual bool PostConvert(vtkSegmentation *vtkNotUsed(segmentation))
Abstract converter rule class. Subclasses perform conversions between specific representation types...
virtual unsigned int GetConversionCost(vtkDataObject *sourceRepresentation=nullptr, vtkDataObject *targetRepresentation=nullptr)
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
virtual bool PreConvert(vtkSegmentation *vtkNotUsed(segmentation))
Store a list of conversion parameters.
vtkNew< vtkSegmentationConversionParameters > ConversionParameters
Class that can convert between different representations of a segment.