Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkSegmentationConversionPath.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 ==============================================================================*/
16 
17 #ifndef __vtkSegmentationConversionPath_h
18 #define __vtkSegmentationConversionPath_h
19 
20 // VTK includes
21 #include <vtkCollection.h>
22 #include <vtkObject.h>
23 
24 // STD includes
25 #include <vector>
26 
27 // Segmentation includes
28 #include "vtkSegmentationCoreConfigure.h"
29 
31 
36 class vtkSegmentationCore_EXPORT vtkSegmentationConversionPath : public vtkObject
37 {
38 public:
39  static vtkSegmentationConversionPath* New();
40  vtkTypeMacro(vtkSegmentationConversionPath, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
46  unsigned int GetCost();
47 
49  int AddRule(vtkSegmentationConverterRule* rule);
50 
52  void AddRules(vtkSegmentationConversionPath* path);
53 
55  int GetNumberOfRules();
56 
58  vtkSegmentationConverterRule* GetRule(int index) VTK_EXPECTS(0 <= index && index < GetNumberOfRules());
59 
61  void RemoveRule(int index) VTK_EXPECTS(0 <= index && index < GetNumberOfRules());
62 
64  void RemoveAllRules();
65 
68  void Copy(vtkSegmentationConversionPath* source);
69 
70 protected:
71 
72  std::vector< vtkSmartPointer<vtkSegmentationConverterRule> > Rules;
73 
74 protected:
77 
78 private:
80  void operator=(const vtkSegmentationConversionPath&) = delete;
81 };
82 
83 
88 class vtkSegmentationCore_EXPORT vtkSegmentationConversionPaths : public vtkCollection
89 {
90 public:
91  vtkTypeMacro(vtkSegmentationConversionPaths, vtkCollection);
92  static vtkSegmentationConversionPaths* New();
93  void PrintSelf(ostream& os, vtkIndent indent) override;
94 
96  void AddPath(vtkSegmentationConversionPath*);
97 
99  void AddPaths(vtkSegmentationConversionPaths*);
100 
102  vtkSegmentationConversionPath* GetNextPath();
103 
105  vtkSegmentationConversionPath* GetPath(int index) { return vtkSegmentationConversionPath::SafeDownCast(this->GetItemAsObject(index)); }
106 
109  vtkSegmentationConversionPath* GetNextPath(vtkCollectionSimpleIterator& cookie);
110 
112  int GetNumberOfPaths() { return this->GetNumberOfItems(); };
113 
114 protected:
115  vtkSegmentationConversionPaths() = default;
116  ~vtkSegmentationConversionPaths() override = default;
117 
118 private:
119  // hide the standard AddItem from the user and the compiler.
120  void AddItem(vtkObject* o) { this->vtkCollection::AddItem(o); }
121 
122 private:
124  void operator=(const vtkSegmentationConversionPaths&) = delete;
125 };
126 
127 //----------------------------------------------------------------------------
129 {
130  this->vtkCollection::AddItem(f);
131 }
132 
133 //----------------------------------------------------------------------------
135 {
136  vtkSegmentationConversionPath* path = nullptr;
137  vtkCollectionSimpleIterator it;
138  for (paths->InitTraversal(it); (path = paths->GetNextPath(it));)
139  {
140  this->AddItem(path);
141  }
142 }
143 
144 //----------------------------------------------------------------------------
146 {
147  return static_cast<vtkSegmentationConversionPath*>(this->GetNextItemAsObject());
148 }
149 
150 #endif // __vtkSegment_h
std::vector< vtkSmartPointer< vtkSegmentationConverterRule > > Rules
void AddPath(vtkSegmentationConversionPath *)
Add a path to the list.
Abstract converter rule class. Subclasses perform conversions between specific representation types...
Store multiple segmentation conversion paths.
int GetNumberOfPaths()
Get number of conversion paths stored in the collection.
void AddPaths(vtkSegmentationConversionPaths *)
Add paths to the list.
Store a segmentation conversion path.
vtkSegmentationConversionPath * GetPath(int index)
Get the index-th path the list.
vtkSegmentationConversionPath * GetNextPath()
Get the next path in the list.
static vtkSegmentationConversionPath * SafeDownCast(vtkObject *o)