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 InputCoordinateType = typename InputMeshType::CoordinateType;
53#ifndef ITK_FUTURE_LEGACY_REMOVE
54 using InputCoordRepType ITK_FUTURE_DEPRECATED(
55 "ITK 6 discourages using `InputCoordRepType`. Please use `InputCoordinateType` instead!") = InputCoordinateType;
56#endif
58 using InputPointIdentifier = typename InputMeshType::PointIdentifier;
59 using InputQEPrimal = typename InputMeshType::QEPrimal;
61
62 using InputPointDataContainer = typename InputMeshType::PointDataContainer;
63 using InputCellDataContainer = typename InputMeshType::CellDataContainer;
64
66 using InputPointsContainerConstIterator = typename InputMeshType::PointsContainerConstIterator;
67 using InputPointsContainerConstPointer = typename InputMeshType::PointsContainerConstPointer;
68 using InputCellsContainerConstIterator = typename InputMeshType::CellsContainerConstIterator;
69 using InputCellsContainerConstPointer = typename InputMeshType::CellsContainerConstPointer;
70
71 using InputEdgeCellType = typename InputMeshType::EdgeCellType;
72 using InputPolygonCellType = typename InputMeshType::PolygonCellType;
73 using InputPointIdList = typename InputMeshType::PointIdList;
74 using InputCellTraits = typename InputMeshType::CellTraits;
75 using InputPointsIdInternalIterator = typename InputCellTraits::PointIdInternalIterator;
76
77 using InputQEIterator = typename InputQEPrimal::IteratorGeom;
78
80 using OutputMeshType = TOutputMesh;
83 using OutputCoordinateType = typename OutputMeshType::CoordinateType;
84#ifndef ITK_FUTURE_LEGACY_REMOVE
85 using OutputCoordRepType ITK_FUTURE_DEPRECATED(
86 "ITK 6 discourages using `OutputCoordRepType`. Please use `OutputCoordinateType` instead!") = OutputCoordinateType;
87#endif
89 using OutputPointIdentifier = typename OutputMeshType::PointIdentifier;
90 using OutputQEPrimal = typename OutputMeshType::QEPrimal;
92 using OutputQEIterator = typename OutputQEPrimal::IteratorGeom;
93 using OutputPointsContainerIterator = typename OutputMeshType::PointsContainerIterator;
94 using OutputPointsContainerPointer = typename OutputMeshType::PointsContainerPointer;
95 using OutputPointsContainerConstPointer = typename OutputMeshType::PointsContainerConstPointer;
96
97 using OutputPointDataContainer = typename OutputMeshType::PointDataContainer;
98 using OutputCellDataContainer = typename OutputMeshType::CellDataContainer;
99
100public:
101 itkNewMacro(Self);
102 itkOverrideGetNameOfClassMacro(QuadEdgeMeshToQuadEdgeMeshFilter);
103
104protected:
107
108 virtual void
110
111 virtual void
113
114 virtual void
116
117 virtual void
119
120 virtual void
122
123 virtual void
125
126 virtual void
128
129 virtual void
131};
132
133//
134// Helper functions that copy selected pieces of a Mesh.
135// These functions should be templated here in order to
136// facilitate their reuse in multiple scenarios.
137//
138template <typename TInputMesh, typename TOutputMesh>
139void
140CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out)
141{
142 CopyMeshToMeshPoints(in, out);
144 CopyMeshToMeshCells(in, out);
146 CopyMeshToMeshCellData(in, out);
147}
148
149// ---------------------------------------------------------------------
150template <typename TInputMesh, typename TOutputMesh>
151void
152CopyMeshToMeshCellData(const TInputMesh * in, TOutputMesh * out)
153{
154 using InputCellDataContainer = typename TInputMesh::CellDataContainer;
155 using OutputCellDataContainer = typename TOutputMesh::CellDataContainer;
156 using InputCellDataContainerConstPointer = typename InputCellDataContainer::ConstPointer;
157 using OutputCellDataContainerPointer = typename OutputCellDataContainer::Pointer;
158
159 const InputCellDataContainerConstPointer inputCellData = in->GetCellData();
160
161 if (inputCellData == nullptr)
162 {
163 // There is nothing to copy
164 return;
165 }
166
167 const OutputCellDataContainerPointer outputCellData = OutputCellDataContainer::New();
168 outputCellData->Reserve(inputCellData->Size());
169
170 // Copy point data
171 using InputCellDataContainerConstIterator = typename InputCellDataContainer::ConstIterator;
172 InputCellDataContainerConstIterator inIt = inputCellData->Begin();
173 while (inIt != inputCellData->End())
174 {
175 const typename OutputCellDataContainer::Element point(inIt.Value());
176 outputCellData->SetElement(inIt.Index(), point);
177 ++inIt;
178 }
179
180 out->SetCellData(outputCellData);
181}
182
183// ---------------------------------------------------------------------
184template <typename TInputMesh, typename TOutputMesh>
185void
186CopyMeshToMeshPointData(const TInputMesh * in, TOutputMesh * out)
187{
188 using OutputPointDataContainer = typename TOutputMesh::PointDataContainer;
189 using OutputPointDataContainerPointer = typename OutputPointDataContainer::Pointer;
190 using InputPointDataContainer = typename TInputMesh::PointDataContainer;
191
192 const InputPointDataContainer * inputPointData = in->GetPointData();
193
194 if (inputPointData == nullptr)
195 {
196 // There is nothing to copy
197 return;
198 }
199
200 const OutputPointDataContainerPointer outputPointData = OutputPointDataContainer::New();
201 outputPointData->Reserve(inputPointData->Size());
202
203 // Copy point data
204 using InputPointDataContainerConstIterator = typename InputPointDataContainer::ConstIterator;
205 InputPointDataContainerConstIterator inIt = inputPointData->Begin();
206 while (inIt != inputPointData->End())
207 {
208 const typename OutputPointDataContainer::Element point(inIt.Value());
209 outputPointData->SetElement(inIt.Index(), point);
210 ++inIt;
211 }
212
213 out->SetPointData(outputPointData);
214}
215
216// ---------------------------------------------------------------------
217template <typename TInputMesh, typename TOutputMesh>
218void
219CopyMeshToMeshCells(const TInputMesh * in, TOutputMesh * out)
220{
221 // Copy cells
222 using InputCellsContainer = typename TInputMesh::CellsContainer;
223 using InputCellsContainerConstPointer = typename InputCellsContainer::ConstPointer;
224 using InputCellsContainerConstIterator = typename InputCellsContainer::ConstIterator;
225 using InputPolygonCellType = typename TInputMesh::PolygonCellType;
226 using InputPointIdList = typename TInputMesh::PointIdList;
227 using InputCellTraits = typename TInputMesh::CellTraits;
228 using InputPointsIdInternalIterator = typename InputCellTraits::PointIdInternalIterator;
229
231
232 const InputCellsContainerConstPointer inCells = in->GetCells();
233
234 if (inCells == nullptr)
235 {
236 // There is nothing to copy
237 return;
238 }
239
240 InputCellsContainerConstIterator cIt = inCells->Begin();
241 const InputCellsContainerConstIterator cEnd = inCells->End();
242 while (cIt != cEnd)
243 {
244 auto * pe = dynamic_cast<InputPolygonCellType *>(cIt.Value());
245 if (pe)
246 {
247 InputPointIdList points;
248 InputPointsIdInternalIterator pIt = pe->InternalPointIdsBegin();
249 const InputPointsIdInternalIterator pEnd = pe->InternalPointIdsEnd();
250
251 while (pIt != pEnd)
252 {
253 points.push_back((*pIt));
254 ++pIt;
255 }
256 out->AddFaceWithSecurePointList(points, false);
257 }
258 ++cIt;
259 }
260}
261
262// ---------------------------------------------------------------------
263template <typename TInputMesh, typename TOutputMesh>
264void
265CopyMeshToMeshEdgeCells(const TInputMesh * in, TOutputMesh * out)
266{
267 // Copy Edge Cells
268 using InputCellsContainer = typename TInputMesh::CellsContainer;
269 using InputCellsContainerConstPointer = typename InputCellsContainer::ConstPointer;
270 using InputCellsContainerConstIterator = typename InputCellsContainer::ConstIterator;
271 using InputEdgeCellType = typename TInputMesh::EdgeCellType;
272
273 const InputCellsContainerConstPointer inEdgeCells = in->GetEdgeCells();
274
275 if (inEdgeCells == nullptr)
276 {
277 // There is nothing to copy
278 return;
279 }
280
281 InputCellsContainerConstIterator ecIt = inEdgeCells->Begin();
282 const InputCellsContainerConstIterator ecEnd = inEdgeCells->End();
283
284 while (ecIt != ecEnd)
285 {
286 auto * pe = dynamic_cast<InputEdgeCellType *>(ecIt.Value());
287 if (pe)
288 {
289 out->AddEdgeWithSecurePointList(pe->GetQEGeom()->GetOrigin(), pe->GetQEGeom()->GetDestination());
290 }
291 ++ecIt;
292 }
293}
294
295// ---------------------------------------------------------------------
296template <typename TInputMesh, typename TOutputMesh>
297void
298CopyMeshToMeshPoints(const TInputMesh * in, TOutputMesh * out)
299{
300 // Copy points
301 using InputPointsContainerConstPointer = typename TInputMesh::PointsContainerConstPointer;
302 using InputPointsContainerConstIterator = typename TInputMesh::PointsContainerConstIterator;
303
304 using OutputPointsContainer = typename TOutputMesh::PointsContainer;
305 using OutputPointsContainerPointer = typename TOutputMesh::PointsContainerPointer;
306 using OutputPointType = typename TOutputMesh::PointType;
307
308 const InputPointsContainerConstPointer inPoints = in->GetPoints();
309
310 if (inPoints == nullptr)
311 {
312 // There is nothing to copy
313 return;
314 }
315
316 InputPointsContainerConstIterator inIt = inPoints->Begin();
317 const InputPointsContainerConstIterator inEnd = inPoints->End();
318
319 OutputPointsContainerPointer oPoints = out->GetPoints();
320 if (oPoints == nullptr)
321 {
322 oPoints = OutputPointsContainer::New();
323 out->SetPoints(oPoints);
324 }
325 OutputPointType pOut;
326
327 while (inIt != inEnd)
328 {
329 pOut.CastFrom(inIt.Value());
330 oPoints->InsertElement(inIt.Index(), pOut);
331 ++inIt;
332 }
333}
334} // end namespace itk
335
336#ifndef ITK_MANUAL_INSTANTIATION
337# include "itkQuadEdgeMeshToQuadEdgeMeshFilter.hxx"
338#endif
339
340#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::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 OutputMeshType::CoordinateType OutputCoordinateType
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 InputMeshType::CoordinateType InputCoordinateType
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)