ITK  6.0.0
Insight Toolkit
itkQuadEdgeMeshToQuadEdgeMeshFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkQuadEdgeMeshToQuadEdgeMeshFilter_h
19#define itkQuadEdgeMeshToQuadEdgeMeshFilter_h
20
21#include "itkMeshToMeshFilter.h"
22
23namespace itk
24{
36template <typename TInputMesh, typename TOutputMesh>
37class ITK_TEMPLATE_EXPORT QuadEdgeMeshToQuadEdgeMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
38{
39public:
40 ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMeshToQuadEdgeMeshFilter);
41
47
49 using InputMeshType = TInputMesh;
52 using InputCoordRepType = typename InputMeshType::CoordRepType;
54 using InputPointIdentifier = typename InputMeshType::PointIdentifier;
55 using InputQEPrimal = typename InputMeshType::QEPrimal;
57
58 using InputPointDataContainer = typename InputMeshType::PointDataContainer;
59 using InputCellDataContainer = typename InputMeshType::CellDataContainer;
60
62 using InputPointsContainerConstIterator = typename InputMeshType::PointsContainerConstIterator;
63 using InputPointsContainerConstPointer = typename InputMeshType::PointsContainerConstPointer;
64 using InputCellsContainerConstIterator = typename InputMeshType::CellsContainerConstIterator;
65 using InputCellsContainerConstPointer = typename InputMeshType::CellsContainerConstPointer;
66
67 using InputEdgeCellType = typename InputMeshType::EdgeCellType;
68 using InputPolygonCellType = typename InputMeshType::PolygonCellType;
69 using InputPointIdList = typename InputMeshType::PointIdList;
70 using InputCellTraits = typename InputMeshType::CellTraits;
71 using InputPointsIdInternalIterator = typename InputCellTraits::PointIdInternalIterator;
72
73 using InputQEIterator = typename InputQEPrimal::IteratorGeom;
74
76 using OutputMeshType = TOutputMesh;
79 using OutputCoordRepType = typename OutputMeshType::CoordRepType;
81 using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
82 using OutputQEPrimal = typename OutputMeshType::QEPrimal;
84 using OutputQEIterator = typename OutputQEPrimal::IteratorGeom;
85 using OutputPointsContainerIterator = typename OutputMeshType::PointsContainerIterator;
86 using OutputPointsContainerPointer = typename OutputMeshType::PointsContainerPointer;
87 using OutputPointsContainerConstPointer = typename OutputMeshType::PointsContainerConstPointer;
88
89 using OutputPointDataContainer = typename OutputMeshType::PointDataContainer;
90 using OutputCellDataContainer = typename OutputMeshType::CellDataContainer;
91
92public:
93 itkNewMacro(Self);
94 itkOverrideGetNameOfClassMacro(QuadEdgeMeshToQuadEdgeMeshFilter);
95
96protected:
99
100 virtual void
102
103 virtual void
105
106 virtual void
108
109 virtual void
111
112 virtual void
114
115 virtual void
117
118 virtual void
120
121 virtual void
123};
124
125//
126// Helper functions that copy selected pieces of a Mesh.
127// These functions should be templated here in order to
128// facilitate their reuse in multiple scenarios.
129//
130template <typename TInputMesh, typename TOutputMesh>
131void
132CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out)
133{
134 CopyMeshToMeshPoints(in, out);
136 CopyMeshToMeshCells(in, out);
138 CopyMeshToMeshCellData(in, out);
139}
140
141// ---------------------------------------------------------------------
142template <typename TInputMesh, typename TOutputMesh>
143void
144CopyMeshToMeshCellData(const TInputMesh * in, TOutputMesh * out)
145{
146 using InputCellDataContainer = typename TInputMesh::CellDataContainer;
147 using OutputCellDataContainer = typename TOutputMesh::CellDataContainer;
148 using InputCellDataContainerConstPointer = typename InputCellDataContainer::ConstPointer;
149 using OutputCellDataContainerPointer = typename OutputCellDataContainer::Pointer;
150
151 InputCellDataContainerConstPointer inputCellData = in->GetCellData();
152
153 if (inputCellData == nullptr)
154 {
155 // There is nothing to copy
156 return;
157 }
158
159 OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New();
160 outputCellData->Reserve(inputCellData->Size());
161
162 // Copy point data
163 using InputCellDataContainerConstIterator = typename InputCellDataContainer::ConstIterator;
164 InputCellDataContainerConstIterator inIt = inputCellData->Begin();
165 while (inIt != inputCellData->End())
166 {
167 typename OutputCellDataContainer::Element point(inIt.Value());
168 outputCellData->SetElement(inIt.Index(), point);
169 ++inIt;
170 }
171
172 out->SetCellData(outputCellData);
173}
174
175// ---------------------------------------------------------------------
176template <typename TInputMesh, typename TOutputMesh>
177void
178CopyMeshToMeshPointData(const TInputMesh * in, TOutputMesh * out)
179{
180 using OutputPointDataContainer = typename TOutputMesh::PointDataContainer;
181 using OutputPointDataContainerPointer = typename OutputPointDataContainer::Pointer;
182 using InputPointDataContainer = typename TInputMesh::PointDataContainer;
183
184 const InputPointDataContainer * inputPointData = in->GetPointData();
185
186 if (inputPointData == nullptr)
187 {
188 // There is nothing to copy
189 return;
190 }
191
192 OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New();
193 outputPointData->Reserve(inputPointData->Size());
194
195 // Copy point data
196 using InputPointDataContainerConstIterator = typename InputPointDataContainer::ConstIterator;
197 InputPointDataContainerConstIterator inIt = inputPointData->Begin();
198 while (inIt != inputPointData->End())
199 {
200 typename OutputPointDataContainer::Element point(inIt.Value());
201 outputPointData->SetElement(inIt.Index(), point);
202 ++inIt;
203 }
204
205 out->SetPointData(outputPointData);
206}
207
208// ---------------------------------------------------------------------
209template <typename TInputMesh, typename TOutputMesh>
210void
211CopyMeshToMeshCells(const TInputMesh * in, TOutputMesh * out)
212{
213 // Copy cells
214 using InputCellsContainer = typename TInputMesh::CellsContainer;
215 using InputCellsContainerConstPointer = typename InputCellsContainer::ConstPointer;
216 using InputCellsContainerConstIterator = typename InputCellsContainer::ConstIterator;
217 using InputPolygonCellType = typename TInputMesh::PolygonCellType;
218 using InputPointIdList = typename TInputMesh::PointIdList;
219 using InputCellTraits = typename TInputMesh::CellTraits;
220 using InputPointsIdInternalIterator = typename InputCellTraits::PointIdInternalIterator;
221
223
224 InputCellsContainerConstPointer inCells = in->GetCells();
225
226 if (inCells == nullptr)
227 {
228 // There is nothing to copy
229 return;
230 }
231
232 InputCellsContainerConstIterator cIt = inCells->Begin();
233 InputCellsContainerConstIterator cEnd = inCells->End();
234 while (cIt != cEnd)
235 {
236 auto * pe = dynamic_cast<InputPolygonCellType *>(cIt.Value());
237 if (pe)
238 {
239 InputPointIdList points;
240 InputPointsIdInternalIterator pIt = pe->InternalPointIdsBegin();
241 InputPointsIdInternalIterator pEnd = pe->InternalPointIdsEnd();
242
243 while (pIt != pEnd)
244 {
245 points.push_back((*pIt));
246 ++pIt;
247 }
248 out->AddFaceWithSecurePointList(points, false);
249 }
250 ++cIt;
251 }
252}
253
254// ---------------------------------------------------------------------
255template <typename TInputMesh, typename TOutputMesh>
256void
257CopyMeshToMeshEdgeCells(const TInputMesh * in, TOutputMesh * out)
258{
259 // Copy Edge Cells
260 using InputCellsContainer = typename TInputMesh::CellsContainer;
261 using InputCellsContainerConstPointer = typename InputCellsContainer::ConstPointer;
262 using InputCellsContainerConstIterator = typename InputCellsContainer::ConstIterator;
263 using InputEdgeCellType = typename TInputMesh::EdgeCellType;
264
265 InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells();
266
267 if (inEdgeCells == nullptr)
268 {
269 // There is nothing to copy
270 return;
271 }
272
273 InputCellsContainerConstIterator ecIt = inEdgeCells->Begin();
274 InputCellsContainerConstIterator ecEnd = inEdgeCells->End();
275
276 while (ecIt != ecEnd)
277 {
278 auto * pe = dynamic_cast<InputEdgeCellType *>(ecIt.Value());
279 if (pe)
280 {
281 out->AddEdgeWithSecurePointList(pe->GetQEGeom()->GetOrigin(), pe->GetQEGeom()->GetDestination());
282 }
283 ++ecIt;
284 }
285}
286
287// ---------------------------------------------------------------------
288template <typename TInputMesh, typename TOutputMesh>
289void
290CopyMeshToMeshPoints(const TInputMesh * in, TOutputMesh * out)
291{
292 // Copy points
293 using InputPointsContainerConstPointer = typename TInputMesh::PointsContainerConstPointer;
294 using InputPointsContainerConstIterator = typename TInputMesh::PointsContainerConstIterator;
295
296 using OutputPointsContainer = typename TOutputMesh::PointsContainer;
297 using OutputPointsContainerPointer = typename TOutputMesh::PointsContainerPointer;
298 using OutputPointType = typename TOutputMesh::PointType;
299
300 InputPointsContainerConstPointer inPoints = in->GetPoints();
301
302 if (inPoints == nullptr)
303 {
304 // There is nothing to copy
305 return;
306 }
307
308 InputPointsContainerConstIterator inIt = inPoints->Begin();
309 InputPointsContainerConstIterator inEnd = inPoints->End();
310
311 OutputPointsContainerPointer oPoints = out->GetPoints();
312 if (oPoints == nullptr)
313 {
314 oPoints = OutputPointsContainer::New();
315 out->SetPoints(oPoints);
316 }
317 OutputPointType pOut;
318
319 while (inIt != inEnd)
320 {
321 pOut.CastFrom(inIt.Value());
322 oPoints->InsertElement(inIt.Index(), pOut);
323 ++inIt;
324 }
325}
326} // end namespace itk
327
328#ifndef ITK_MANUAL_INSTANTIATION
329# include "itkQuadEdgeMeshToQuadEdgeMeshFilter.hxx"
330#endif
331
332#endif
Iterator Begin()
Light weight base class for most itk classes.
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkMeshSource.h:69
TOutputMesh OutputMeshType
Definition: itkMeshSource.h:68
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
typename InputMeshType::Pointer InputMeshPointer
typename InputMeshType::CellsContainerConstPointer InputCellsContainerConstPointer
virtual void CopyInputMeshToOutputMeshEdgeCells()
virtual void CopyInputMeshToOutputMeshGeometry()
typename OutputQEPrimal::IteratorGeom OutputQEIterator
typename OutputMeshType::PointsContainerConstPointer OutputPointsContainerConstPointer
typename OutputMeshType::CellDataContainer OutputCellDataContainer
typename InputMeshType::PointsContainerConstPointer InputPointsContainerConstPointer
typename InputMeshType::ConstPointer InputMeshConstPointer
typename InputMeshType::CoordRepType InputCoordRepType
typename InputMeshType::PointDataContainer InputPointDataContainer
typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
typename InputQEPrimal::IteratorGeom InputQEIterator
typename InputMeshType::PolygonCellType InputPolygonCellType
typename OutputMeshType::ConstPointer OutputMeshConstPointer
typename OutputMeshType::PointIdentifier OutputPointIdentifier
typename OutputMeshType::PointDataContainer OutputPointDataContainer
virtual void CopyInputMeshToOutputMeshFieldData()
typename InputMeshType::PointIdentifier InputPointIdentifier
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
typename InputMeshType::PointIdList InputPointIdList
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
typename InputCellTraits::PointIdInternalIterator InputPointsIdInternalIterator
typename OutputMeshType::VectorType OutputVectorType
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
typename InputPointDataContainer::ConstPointer InputPointDataContainerConstPointer
typename InputMeshType::EdgeCellType InputEdgeCellType
virtual void CopyInputMeshToOutputMeshCellData()
~QuadEdgeMeshToQuadEdgeMeshFilter() override=default
virtual void CopyInputMeshToOutputMeshPointData()
typename OutputMeshType::CoordRepType OutputCoordRepType
typename InputMeshType::CellDataContainer InputCellDataContainer
SmartPointer< const Self > ConstPointer
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
void CopyMeshToMeshPointData(const TInputMesh *in, TOutputMesh *out)
void CopyMeshToMeshPoints(const TInputMesh *in, TOutputMesh *out)
void CopyMeshToMesh(const TInputMesh *in, TOutputMesh *out)
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
void CopyMeshToMeshCells(const TInputMesh *in, TOutputMesh *out)
void CopyMeshToMeshCellData(const TInputMesh *in, TOutputMesh *out)
void CopyMeshToMeshEdgeCells(const TInputMesh *in, TOutputMesh *out)