Slicer  5.1
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 <vtkObject.h>
28 
29 // STD includes
30 #include <map>
31 #include <string>
32 #include <vector>
33 
34 class vtkDataObject;
35 class vtkSegmentation;
36 class vtkSegment;
37 
39 #ifndef vtkSegmentationConverterRuleNewMacro
40 #define vtkSegmentationConverterRuleNewMacro(newClass) \
41  vtkStandardNewMacro(newClass); \
42  vtkSegmentationConverterRule* newClass::CreateRuleInstance() \
43  { \
44  return newClass::New(); \
45  }
46 #endif
47 
52 class vtkSegmentationCore_EXPORT vtkSegmentationConverterRule : public vtkObject
53 {
54 public:
59  typedef std::map<std::string, std::pair<std::string, std::string> > ConversionParameterListType;
60 
63  static unsigned int GetConversionInfiniteCost() { return 10000000; };
64 
65 public:
66  //static vtkSegmentationConverterRule* New();
67  vtkTypeMacro(vtkSegmentationConverterRule, vtkObject);
68 
71  virtual vtkSegmentationConverterRule* CreateRuleInstance() = 0;
72 
74  virtual vtkSegmentationConverterRule* Clone();
75 
79  virtual vtkDataObject* ConstructRepresentationObjectByRepresentation(std::string representationName) = 0;
80 
84  virtual vtkDataObject* ConstructRepresentationObjectByClass(std::string className) = 0;
85 
88  virtual bool PreConvert(vtkSegmentation* vtkNotUsed(segmentation)) { return true; };
89 
93  virtual bool Convert(vtkSegment* segment) = 0;
94 
97  virtual bool PostConvert(vtkSegmentation* vtkNotUsed(segmentation)) { return true; };
98 
103  virtual unsigned int GetConversionCost(vtkDataObject* sourceRepresentation=nullptr, vtkDataObject* targetRepresentation=nullptr)
104  {
105  (void)(sourceRepresentation); // unused
106  (void)(targetRepresentation); // unused
107  return 100;
108  };
109 
111  virtual const char* GetName() = 0;
112 
114  virtual const char* GetSourceRepresentationName() = 0;
115 
117  virtual const char* GetTargetRepresentationName() = 0;
118 
121  virtual void GetRuleConversionParameters(ConversionParameterListType& conversionParameters);
122 
124  virtual void SetConversionParameter(const std::string& name, const std::string& value, const std::string& description="");
125 
127  virtual std::string GetConversionParameter(const std::string& name);
128 
130  virtual std::string GetConversionParameterDescription(const std::string& name);
131 
133  bool HasConversionParameter(const std::string& name);
134 
135 protected:
137  virtual bool CreateTargetRepresentation(vtkSegment* segment);
138 
140  ~vtkSegmentationConverterRule() override;
141  void operator=(const vtkSegmentationConverterRule&);
142 
143 protected:
150 
155  bool ReplaceTargetRepresentation{false};
156 
158 };
159 
160 #endif // __vtkSegmentationConverterRule_h
This class encapsulates a segment that is part of a segmentation.
Definition: vtkSegment.h:45
virtual bool PostConvert(vtkSegmentation *vtkNotUsed(segmentation))
ConversionParameterListType ConversionParameters
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...
std::map< std::string, std::pair< std::string, std::string > > ConversionParameterListType
virtual bool PreConvert(vtkSegmentation *vtkNotUsed(segmentation))
Class that can convert between different representations of a segment.