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 
23 namespace itk
24 {
36 template <typename TInputMesh, typename TOutputMesh>
37 class ITK_TEMPLATE_EXPORT QuadEdgeMeshToQuadEdgeMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
38 {
39 public:
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 
92 public:
93  itkNewMacro(Self);
94  itkOverrideGetNameOfClassMacro(QuadEdgeMeshToQuadEdgeMeshFilter);
95 
96 protected:
98  ~QuadEdgeMeshToQuadEdgeMeshFilter() override = default;
99 
100  virtual void
101  CopyInputMeshToOutputMesh();
102 
103  virtual void
104  CopyInputMeshToOutputMeshGeometry();
105 
106  virtual void
107  CopyInputMeshToOutputMeshPoints();
108 
109  virtual void
110  CopyInputMeshToOutputMeshCells();
111 
112  virtual void
113  CopyInputMeshToOutputMeshEdgeCells();
114 
115  virtual void
116  CopyInputMeshToOutputMeshFieldData();
117 
118  virtual void
119  CopyInputMeshToOutputMeshPointData();
120 
121  virtual void
122  CopyInputMeshToOutputMeshCellData();
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 //
130 template <typename TInputMesh, typename TOutputMesh>
131 void
132 CopyMeshToMesh(const TInputMesh * in, TOutputMesh * out)
133 {
134  CopyMeshToMeshPoints(in, out);
135  CopyMeshToMeshEdgeCells(in, out);
136  CopyMeshToMeshCells(in, out);
137  CopyMeshToMeshPointData(in, out);
138  CopyMeshToMeshCellData(in, out);
139 }
140 
141 // ---------------------------------------------------------------------
142 template <typename TInputMesh, typename TOutputMesh>
143 void
144 CopyMeshToMeshCellData(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 // ---------------------------------------------------------------------
176 template <typename TInputMesh, typename TOutputMesh>
177 void
178 CopyMeshToMeshPointData(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 // ---------------------------------------------------------------------
209 template <typename TInputMesh, typename TOutputMesh>
210 void
211 CopyMeshToMeshCells(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 // ---------------------------------------------------------------------
255 template <typename TInputMesh, typename TOutputMesh>
256 void
257 CopyMeshToMeshEdgeCells(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 // ---------------------------------------------------------------------
288 template <typename TInputMesh, typename TOutputMesh>
289 void
290 CopyMeshToMeshPoints(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
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointDataContainerConstPointer
typename InputPointDataContainer::ConstPointer InputPointDataContainerConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:61
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputQEPrimal
typename OutputMeshType::QEPrimal OutputQEPrimal
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:82
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointDataContainer
typename OutputMeshType::PointDataContainer OutputPointDataContainer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:89
itk::CopyMeshToMeshCellData
void CopyMeshToMeshCellData(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:144
itk::MeshSource< TOutput >::OutputMeshPointer
typename OutputMeshType::Pointer OutputMeshPointer
Definition: itkMeshSource.h:69
itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointsContainerPointer
typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:86
itk::MeshToMeshFilter< TInput, TOutput >::InputMeshPointer
typename InputMeshType::Pointer InputMeshPointer
Definition: itkMeshToMeshFilter.h:66
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::CopyMeshToMeshPoints
void CopyMeshToMeshPoints(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:290
itk::FixedArray::Begin
Iterator Begin()
itk::CopyMeshToMeshEdgeCells
void CopyMeshToMeshEdgeCells(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:257
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputCellsContainerConstPointer
typename InputMeshType::CellsContainerConstPointer InputCellsContainerConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:65
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointsContainerConstPointer
typename OutputMeshType::PointsContainerConstPointer OutputPointsContainerConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:87
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointsContainerConstIterator
typename InputMeshType::PointsContainerConstIterator InputPointsContainerConstIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:62
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputCellDataContainer
typename OutputMeshType::CellDataContainer OutputCellDataContainer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:90
itk::SmartPointer< Self >
itk::MeshToMeshFilter< TInput, TOutput >::InputMeshType
TInput InputMeshType
Definition: itkMeshToMeshFilter.h:65
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputQEPrimal
typename InputMeshType::QEPrimal InputQEPrimal
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:55
itk::CopyMeshToMeshCells
void CopyMeshToMeshCells(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:211
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputMeshConstPointer
typename InputMeshType::ConstPointer InputMeshConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:51
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointType
typename InputMeshType::PointType InputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:53
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointIdList
typename InputMeshType::PointIdList InputPointIdList
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:69
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointIdentifier
typename InputMeshType::PointIdentifier InputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:54
itk::point
*par Constraints *The filter requires an 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
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputCellTraits
typename InputMeshType::CellTraits InputCellTraits
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:70
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputVectorType
typename OutputMeshType::VectorType OutputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:83
itk::CopyMeshToMesh
void CopyMeshToMesh(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:132
itk::QuadEdgeMeshToQuadEdgeMeshFilter
Duplicates the content of a Mesh.
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:37
itk::MeshToMeshFilter
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
Definition: itkMeshToMeshFilter.h:47
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputCoordRepType
typename OutputMeshType::CoordRepType OutputCoordRepType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:79
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputEdgeCellType
typename InputMeshType::EdgeCellType InputEdgeCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:67
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointDataContainer
typename InputMeshType::PointDataContainer InputPointDataContainer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:58
itkMeshToMeshFilter.h
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointsContainerConstPointer
typename InputMeshType::PointsContainerConstPointer InputPointsContainerConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:63
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputCoordRepType
typename InputMeshType::CoordRepType InputCoordRepType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:52
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPolygonCellType
typename InputMeshType::PolygonCellType InputPolygonCellType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:68
itk::CopyMeshToMeshPointData
void CopyMeshToMeshPointData(const TInputMesh *in, TOutputMesh *out)
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:178
itk::MeshSource< TOutput >::OutputMeshType
TOutput OutputMeshType
Definition: itkMeshSource.h:68
New
static Pointer New()
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputVectorType
typename InputMeshType::VectorType InputVectorType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:56
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputCellDataContainer
typename InputMeshType::CellDataContainer InputCellDataContainer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:59
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputQEIterator
typename OutputQEPrimal::IteratorGeom OutputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:84
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputPointsIdInternalIterator
typename InputCellTraits::PointIdInternalIterator InputPointsIdInternalIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:71
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointIdentifier
typename OutputMeshType::PointIdentifier OutputPointIdentifier
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:81
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointType
typename OutputMeshType::PointType OutputPointType
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:80
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputMeshConstPointer
typename OutputMeshType::ConstPointer OutputMeshConstPointer
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:78
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::OutputPointsContainerIterator
typename OutputMeshType::PointsContainerIterator OutputPointsContainerIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:85
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputCellsContainerConstIterator
typename InputMeshType::CellsContainerConstIterator InputCellsContainerConstIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:64
itk::QuadEdgeMeshToQuadEdgeMeshFilter< TInput, TOutput >::InputQEIterator
typename InputQEPrimal::IteratorGeom InputQEIterator
Definition: itkQuadEdgeMeshToQuadEdgeMeshFilter.h:73