RegisteredSurface.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_RegisteredSurface_H
21 #define MIRTK_RegisteredSurface_H
22 
23 #include "mirtk/RegisteredPointSet.h"
24 
25 #include "vtkPolyData.h"
26 #include "vtkCellArray.h"
27 
28 
29 namespace mirtk {
30 
31 
32 /**
33  * Registered boundary surface (vtkPolyData)
34  */
36 {
37  mirtkObjectMacro(RegisteredSurface);
38 
39 public:
40 
41  // ---------------------------------------------------------------------------
42  // Construction/Destruction
43 
44  /// Constructor
45  RegisteredSurface(vtkPolyData * = NULL, const class Transformation * = NULL);
46 
47  /// Copy constructor
49 
50  /// Assignment operator
52 
53  /// Destructor
55 
56  /// Initialize dataset after input and parameters are set
57  void Initialize();
58 
59  // ---------------------------------------------------------------------------
60  // Polydata access
61 
62  /// Set input surface
63  void InputSurface(vtkPolyData *);
64 
65  /// Get number of vertices
66  int NumberOfVerts() const;
67 
68  /// Get number of lines
69  int NumberOfLines() const;
70 
71  /// Get number of polygons
72  int NumberOfPolys() const;
73 
74  /// Get number of triangle strips
75  int NumberOfStrips() const;
76 
77  /// Get (transformed) polydata
78  vtkPolyData *PolyData() const;
79 
80  /// Get the cell array defining vertices. If there are no vertices, an
81  /// empty array will be returned (convenience to simplify traversal).
82  vtkCellArray *Verts() const;
83 
84  /// Get the cell array defining lines. If there are no lines, an
85  /// empty array will be returned (convenience to simplify traversal).
86  vtkCellArray *Lines() const;
87 
88  /// Get the cell array defining polygons. If there are no polygons, an
89  /// empty array will be returned (convenience to simplify traversal).
90  vtkCellArray *Polys() const;
91 
92  /// Get the cell array defining triangle strips. If there are no triangle strips,
93  /// an empty array will be returned (convenience to simplify traversal).
94  vtkCellArray *Strips() const;
95 
96  /// Get pointer to IDs of points defining a cell
97  void GetCellPoints(int, vtkIdType &, const vtkIdType *&) const;
98 
99 };
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 // Inline definitions
103 ////////////////////////////////////////////////////////////////////////////////
104 
105 // =============================================================================
106 // Polydata access
107 // =============================================================================
108 
109 // -----------------------------------------------------------------------------
110 inline void RegisteredSurface::InputSurface(vtkPolyData *surface)
111 {
112  _InputPointSet = surface;
113 }
114 
115 // -----------------------------------------------------------------------------
116 inline vtkCellArray *RegisteredSurface::Verts() const
117 {
118  return _OutputSurface->GetVerts();
119 }
120 
121 // -----------------------------------------------------------------------------
122 inline vtkCellArray *RegisteredSurface::Lines() const
123 {
124  return _OutputSurface->GetLines();
125 }
126 
127 // -----------------------------------------------------------------------------
128 inline vtkCellArray *RegisteredSurface::Polys() const
129 {
130  return _OutputSurface->GetPolys();
131 }
132 
133 // -----------------------------------------------------------------------------
134 inline vtkCellArray *RegisteredSurface::Strips() const
135 {
136  return _OutputSurface->GetStrips();
137 }
138 
139 // -----------------------------------------------------------------------------
141 {
142  return static_cast<int>(Verts()->GetNumberOfCells());
143 }
144 
145 // -----------------------------------------------------------------------------
147 {
148  return static_cast<int>(Lines()->GetNumberOfCells());
149 }
150 
151 // -----------------------------------------------------------------------------
153 {
154  return static_cast<int>(Polys()->GetNumberOfCells());
155 }
156 
157 // -----------------------------------------------------------------------------
159 {
160  return static_cast<int>(Strips()->GetNumberOfCells());
161 }
162 
163 // -----------------------------------------------------------------------------
164 inline void RegisteredSurface::GetCellPoints(int i, vtkIdType &npts, const vtkIdType *&pts) const
165 {
166  _OutputSurface->GetCellPoints(i, npts, const_cast<vtkIdType *&>(pts));
167 }
168 
169 
170 } // namespace mirtk
171 
172 #endif // MIRTK_RegisteredSurface_H
vtkCellArray * Polys() const
void InputSurface(vtkPolyData *)
Set input surface.
vtkCellArray * Lines() const
int NumberOfPolys() const
Get number of polygons.
RegisteredSurface & operator=(const RegisteredSurface &)
Assignment operator.
Definition: IOConfig.h:41
void GetCellPoints(int, vtkIdType &, const vtkIdType *&) const
Get pointer to IDs of points defining a cell.
void Initialize()
Initialize dataset after input and parameters are set.
~RegisteredSurface()
Destructor.
vtkCellArray * Verts() const
int NumberOfStrips() const
Get number of triangle strips.
vtkCellArray * Strips() const
int NumberOfVerts() const
Get number of vertices.
int NumberOfLines() const
Get number of lines.
RegisteredSurface(vtkPolyData *=NULL, const class Transformation *=NULL)
Constructor.
vtkPolyData * PolyData() const
Get (transformed) polydata.