ITK  6.0.0
Insight Toolkit
itkQuadEdgeMesh.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 itkQuadEdgeMesh_h
19 #define itkQuadEdgeMesh_h
20 
21 #include <cstdarg>
22 #include <queue>
23 #include <vector>
24 #include <list>
25 
26 #include "itkMesh.h"
27 
28 #include "itkQuadEdgeMeshTraits.h"
31 
33 #include "itkConceptChecking.h"
34 
35 
36 namespace itk
37 {
50 template <typename TPixel,
51  unsigned int VDimension,
52  typename TTraits = QuadEdgeMeshTraits<TPixel, VDimension, bool, bool>>
53 class ITK_TEMPLATE_EXPORT QuadEdgeMesh : public Mesh<TPixel, VDimension, TTraits>
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMesh);
57 
59  using Traits = TTraits;
60  using PixelType = TPixel;
61 
63  using Self = QuadEdgeMesh;
67 
69  static constexpr unsigned int PointDimension = Traits::PointDimension;
70  static constexpr unsigned int MaxTopologicalDimension = Traits::MaxTopologicalDimension;
71 
73  using typename Superclass::CellPixelType;
74  using typename Superclass::CoordinateType;
75  using typename Superclass::PointIdentifier;
76  using typename Superclass::PointHashType;
77  using typename Superclass::PointType;
78  using typename Superclass::CellTraits;
79 
80  using PointIdInternalIterator = typename CellTraits::PointIdInternalIterator;
81  using PointIdIterator = typename CellTraits::PointIdIterator;
82 
83  // Point section:
84  using typename Superclass::PointsContainer;
85  using typename Superclass::PointsContainerPointer;
86  using CoordRepArrayType = CoordinateType[Self::PointDimension];
87 
88  // Point data section:
89  using typename Superclass::PointDataContainer;
90  using typename Superclass::PointDataContainerPointer;
91  using typename Superclass::PointDataContainerIterator;
92  using typename Superclass::PointsContainerConstIterator;
93  using typename Superclass::PointsContainerIterator;
94 
95  // Cell section:
96  using typename Superclass::CellIdentifier;
97  using typename Superclass::CellType;
98  using typename Superclass::CellAutoPointer;
99  using typename Superclass::CellFeatureIdentifier;
100  using typename Superclass::CellFeatureCount;
101  using typename Superclass::CellMultiVisitorType;
102  using typename Superclass::CellsContainer;
103  using typename Superclass::CellsContainerPointer;
104 
105  using typename Superclass::CellsContainerConstIterator;
106  using typename Superclass::CellsContainerIterator;
107 
108  using typename Superclass::CellLinksContainer;
109  using typename Superclass::CellLinksContainerPointer;
110  using typename Superclass::CellLinksContainerIterator;
111 
112  // Cell data section:
113  using typename Superclass::CellDataContainer;
114  using typename Superclass::CellDataContainerPointer;
115  using typename Superclass::CellDataContainerIterator;
116 
117  // Point / Cell correspondence section:
118  using typename Superclass::PointCellLinksContainer;
119  using typename Superclass::PointCellLinksContainerIterator;
120 
121  // BoundaryAssignments section:
122  using typename Superclass::BoundaryAssignmentsContainer;
123  using typename Superclass::BoundaryAssignmentsContainerPointer;
124  using typename Superclass::BoundaryAssignmentsContainerVector;
125 
126  // Miscellaneous section:
127  using typename Superclass::BoundingBoxPointer;
128  using typename Superclass::BoundingBoxType;
129  using typename Superclass::RegionType;
130  using typename Superclass::InterpolationWeightType;
131 
133  using PrimalDataType = typename Traits::PrimalDataType;
134  using DualDataType = typename Traits::DualDataType;
135  using QEPrimal = typename Traits::QEPrimal;
136  using QEDual = typename Traits::QEDual;
137  using QEType = typename Traits::QEPrimal;
138  // See the TODO entry dated from 2005-05-28
139  // struct QEType : public QEPrimal, public QEDual {}
140  using VertexRefType = typename Traits::VertexRefType;
141  using FaceRefType = typename Traits::FaceRefType;
142  using VectorType = typename Traits::VectorType;
143 
147 
149  using FreePointIndexesType = std::queue<PointIdentifier>;
150  using FreeCellIndexesType = std::queue<CellIdentifier>;
151 
153  using PointIdList = std::vector<PointIdentifier>;
154  using EdgeListType = std::list<QEPrimal *>;
155 #ifndef ITK_FUTURE_LEGACY_REMOVE
156  using EdgeListPointerType [[deprecated("Please just use `EdgeListType *` instead!")]] = EdgeListType *;
157 #endif
159 
162 
164  static const CellIdentifier m_NoFace;
165 
166 public:
168  itkNewMacro(Self);
169  itkOverrideGetNameOfClassMacro(QuadEdgeMesh);
172 #if !defined(ITK_WRAPPING_PARSER)
173 
175 #endif
176 
177 public:
178  // Multithreading framework: not tested yet.
179  bool
181  {
182  return (false);
183  }
184 
185  void
186  Initialize() override;
187 
189  virtual void
190  Clear();
191 
192  CellsContainer *
194  {
195  return m_EdgeCellsContainer;
196  }
197  const CellsContainer *
198  GetEdgeCells() const
199  {
200  return m_EdgeCellsContainer;
201  }
202  void
204  {
205  m_EdgeCellsContainer = edgeCells;
206  }
207  void
209  {
210  m_EdgeCellsContainer->InsertElement(cellId, cellPointer.ReleaseOwnership());
211  }
212 
219  void
220  CopyInformation(const DataObject * itkNotUsed(data)) override
221  {}
222  void
223  Graft(const DataObject * data) override;
224 
226  void
227  SqueezePointsIds();
228 
230  void
232  {}
233 
234 #if !defined(ITK_WRAPPING_PARSER)
235 
236  void
237  SetBoundaryAssignments(int itkNotUsed(dimension), BoundaryAssignmentsContainer * itkNotUsed(container))
238  {}
239 
241  BoundaryAssignmentsContainerPointer
242  GetBoundaryAssignments(int itkNotUsed(dimension))
243  {
244  return (nullptr);
245  }
246 
248  const BoundaryAssignmentsContainerPointer
249  GetBoundaryAssignments(int itkNotUsed(dimension)) const
250  {
251  return (nullptr);
252  }
253 
254 #endif
255 
257  void
258  SetBoundaryAssignment(int itkNotUsed(dimension),
259  CellIdentifier itkNotUsed(cellId),
260  CellFeatureIdentifier itkNotUsed(featureId),
261  CellIdentifier itkNotUsed(boundaryId))
262  {}
263 
265  bool
266  GetBoundaryAssignment(int itkNotUsed(dimension),
267  CellIdentifier itkNotUsed(cellId),
268  CellFeatureIdentifier itkNotUsed(featureId),
269  CellIdentifier * itkNotUsed(boundaryId))
270  {
271  return (false); // ALEX: is it the good way?
272  }
273 
275  bool
276  RemoveBoundaryAssignment(int itkNotUsed(dimension),
277  CellIdentifier itkNotUsed(cellId),
278  CellFeatureIdentifier itkNotUsed(featureId))
279  {
280  return (false); // ALEX: is it the good way?
281  }
282 
284  bool
285  GetCellBoundaryFeature(int itkNotUsed(dimension),
286  CellIdentifier itkNotUsed(cellId),
287  CellFeatureIdentifier itkNotUsed(featureId),
288  CellAutoPointer & itkNotUsed(cellAP)) const
289  {
290  return (false);
291  }
292 
294  CellIdentifier
295  GetCellBoundaryFeatureNeighbors(int itkNotUsed(dimension),
296  CellIdentifier itkNotUsed(cellId),
297  CellFeatureIdentifier itkNotUsed(featureId),
298  std::set<CellIdentifier> * itkNotUsed(cellSet))
299  {
300  return CellIdentifier{};
301  }
305  CellIdentifier
306  GetCellNeighbors(CellIdentifier itkNotUsed(cellId), std::set<CellIdentifier> * itkNotUsed(cellSet))
307  {
308  return CellIdentifier{};
309  }
310 
312  bool
313  GetAssignedCellBoundaryIfOneExists(int itkNotUsed(dimension),
314  CellIdentifier itkNotUsed(cellId),
315  CellFeatureIdentifier itkNotUsed(featureId),
316  CellAutoPointer & itkNotUsed(cellAP)) const
317  {
318  return (false); // ALEX: is it the good way?
319  }
320 
322  void
323  SetCell(CellIdentifier cId, CellAutoPointer & cell);
324 
326  virtual PointIdentifier
327  FindFirstUnusedPointIndex();
328 
329  virtual CellIdentifier
330  FindFirstUnusedCellIndex();
331 
332  virtual void
333  PushOnContainer(EdgeCellType * newEdge);
334 
335  // Adding Point/Edge/Face methods
336  virtual PointIdentifier
337  AddPoint(const PointType & p);
338 
340  virtual QEPrimal *
341  AddEdge(const PointIdentifier & orgPid, const PointIdentifier & destPid);
342 
343  virtual QEPrimal *
344  AddEdgeWithSecurePointList(const PointIdentifier & orgPid, const PointIdentifier & destPid);
345 
347  virtual void
348  AddFace(QEPrimal * entry);
349 
354  virtual QEPrimal *
355  AddFace(const PointIdList & points);
356 
357  virtual QEPrimal *
358  AddFaceWithSecurePointList(const PointIdList & points);
359 
360  virtual QEPrimal *
361  AddFaceWithSecurePointList(const PointIdList & points, bool CheckEdges);
362 
364  virtual QEPrimal *
365  AddFaceTriangle(const PointIdentifier & aPid, const PointIdentifier & bPid, const PointIdentifier & cPid);
366 
368  virtual void
369  DeletePoint(const PointIdentifier & pid);
370 
371  virtual void
372  DeleteEdge(const PointIdentifier & orgPid, const PointIdentifier & destPid);
373 
374  virtual void
375  DeleteEdge(QEPrimal * e);
376 
377  virtual void
378  LightWeightDeleteEdge(EdgeCellType * edgeCell);
379 
380  virtual void
381  LightWeightDeleteEdge(QEPrimal * e);
382 
383  virtual void
384  DeleteFace(FaceRefType faceToDelete);
385 
386  //
387  bool
389  {
390  return (Superclass::GetPoint(pid, pt));
391  }
392 
393  virtual PointType
394  GetPoint(const PointIdentifier & pid) const;
395 
396  virtual VectorType
397  GetVector(const PointIdentifier & pid) const;
398 
399  virtual QEPrimal *
400  GetEdge() const;
401 
402  virtual QEPrimal *
403  GetEdge(const CellIdentifier & eid) const;
404 
405  virtual QEPrimal *
406  FindEdge(const PointIdentifier & pid0) const;
407 
408  virtual QEPrimal *
409  FindEdge(const PointIdentifier & pid0, const PointIdentifier & pid1) const;
410 
411  virtual EdgeCellType *
412  FindEdgeCell(const PointIdentifier & pid0, const PointIdentifier & pid1) const;
413 
415  CoordinateType
416  ComputeEdgeLength(QEPrimal * e);
417 
418  PointIdentifier
419  ComputeNumberOfPoints() const;
420 
421  CellIdentifier
422  ComputeNumberOfFaces() const;
423 
424  CellIdentifier
425  ComputeNumberOfEdges() const;
426 
427  PointIdentifier
428  Splice(QEPrimal * a, QEPrimal * b);
429 
430 #ifdef ITK_USE_CONCEPT_CHECKING
431  // Begin concept checking
432  // End concept checking
433 #endif
434 
435  // for reusability of a mesh in the MeshToMesh filter
436  void
438  {
439  while (!this->m_FreePointIndexes.empty())
440  {
441  this->m_FreePointIndexes.pop();
442  }
443  while (!this->m_FreeCellIndexes.empty())
444  {
445  this->m_FreeCellIndexes.pop();
446  }
447  }
448 
449  CellIdentifier
451  {
452  return (m_NumberOfFaces);
453  }
454  CellIdentifier
456  {
457  return (m_NumberOfEdges);
458  }
459 
460 protected:
462  QuadEdgeMesh();
463  ~QuadEdgeMesh() override;
467  virtual void
468  ClearCellsContainer();
469 
470  CellsContainerPointer m_EdgeCellsContainer{};
471 
472 private:
473  CellIdentifier m_NumberOfFaces{};
474  CellIdentifier m_NumberOfEdges{};
475 
476 protected:
477  FreePointIndexesType m_FreePointIndexes{};
478  FreeCellIndexesType m_FreeCellIndexes{};
479 };
480 } // namespace itk
481 
482 #ifndef ITK_MANUAL_INSTANTIATION
483 # include "itkQuadEdgeMesh.hxx"
484 #endif
485 
486 #endif
itk::QuadEdgeMesh::GetCellBoundaryFeature
bool GetCellBoundaryFeature(int, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const
Definition: itkQuadEdgeMesh.h:285
itk::QuadEdgeMesh::PixelType
TPixel PixelType
Definition: itkQuadEdgeMesh.h:60
itk::QuadEdgeMesh::FaceRefType
typename Traits::FaceRefType FaceRefType
Definition: itkQuadEdgeMesh.h:141
itk::QuadEdgeMesh::RequestedRegionIsOutsideOfTheBufferedRegion
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Definition: itkQuadEdgeMesh.h:180
itk::QuadEdgeMesh::CopyInformation
void CopyInformation(const DataObject *) override
Definition: itkQuadEdgeMesh.h:220
itk::PointSetBase< TTraits ::PointsContainer >::CoordinateType
typename PointType::CoordinateType CoordinateType
Definition: itkPointSetBase.h:74
itk::QuadEdgeMesh::DualDataType
typename Traits::DualDataType DualDataType
Definition: itkQuadEdgeMesh.h:134
itk::QuadEdgeMesh::GetCellNeighbors
CellIdentifier GetCellNeighbors(CellIdentifier, std::set< CellIdentifier > *)
Definition: itkQuadEdgeMesh.h:306
itk::QuadEdgeMesh::PrimalDataType
typename Traits::PrimalDataType PrimalDataType
Definition: itkQuadEdgeMesh.h:133
itk::QuadEdgeMesh::SetEdgeCell
void SetEdgeCell(CellIdentifier cellId, CellAutoPointer &cellPointer)
Definition: itkQuadEdgeMesh.h:208
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::QuadEdgeMesh::SetBoundaryAssignments
void SetBoundaryAssignments(int, BoundaryAssignmentsContainer *)
Definition: itkQuadEdgeMesh.h:237
itk::QuadEdgeMesh::QEDual
typename Traits::QEDual QEDual
Definition: itkQuadEdgeMesh.h:136
itk::QuadEdgeMesh::GetBoundaryAssignments
const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int) const
Definition: itkQuadEdgeMesh.h:249
itkConceptChecking.h
itk::QuadEdgeMesh::CoordRepArrayType
CoordinateType[Self::PointDimension] CoordRepArrayType
Definition: itkQuadEdgeMesh.h:86
itk::QuadEdgeMesh::Traits
TTraits Traits
Definition: itkQuadEdgeMesh.h:59
itk::SmartPointer< Self >
itk::QuadEdgeMesh::RemoveBoundaryAssignment
bool RemoveBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier)
Definition: itkQuadEdgeMesh.h:276
itk::QuadEdgeMesh::QEPrimal
typename Traits::QEPrimal QEPrimal
Definition: itkQuadEdgeMesh.h:135
itk::QuadEdgeMesh::SetBoundaryAssignment
void SetBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier, CellIdentifier)
Definition: itkQuadEdgeMesh.h:258
itk::QuadEdgeMesh::m_NoFace
static const CellIdentifier m_NoFace
Definition: itkQuadEdgeMesh.h:164
itk::MapContainer
A wrapper of the STL "map" container.
Definition: itkMapContainer.h:45
itk::QuadEdgeMesh::FreePointIndexesType
std::queue< PointIdentifier > FreePointIndexesType
Definition: itkQuadEdgeMesh.h:149
itk::Mesh< TPixel, VDimension, TTraits >::CellAutoPointer
typename CellType::CellAutoPointer CellAutoPointer
Definition: itkMesh.h:233
itk::Mesh< TPixel, VDimension, TTraits >::CellIdentifier
typename MeshTraits::CellIdentifier CellIdentifier
Definition: itkMesh.h:178
itk::QuadEdgeMesh::GetNumberOfFaces
CellIdentifier GetNumberOfFaces() const
Definition: itkQuadEdgeMesh.h:450
itk::QuadEdgeMesh::VertexRefType
typename Traits::VertexRefType VertexRefType
Definition: itkQuadEdgeMesh.h:140
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainer
typename MeshTraits::CellsContainer CellsContainer
Definition: itkMesh.h:184
itk::QuadEdgeMesh::EdgeListType
std::list< QEPrimal * > EdgeListType
Definition: itkQuadEdgeMesh.h:154
itk::PointSet< TPixel, VDimension, TTraits >::PointIdentifier
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:103
itk::QuadEdgeMesh::BuildCellLinks
void BuildCellLinks() const
Definition: itkQuadEdgeMesh.h:231
itk::QuadEdgeMesh::PointIdIterator
typename CellTraits::PointIdIterator PointIdIterator
Definition: itkQuadEdgeMesh.h:81
itk::QuadEdgeMesh::GetEdgeCells
const CellsContainer * GetEdgeCells() const
Definition: itkQuadEdgeMesh.h:198
itk::QuadEdgeMesh
Mesh class for 2D manifolds embedded in ND space.
Definition: itkQuadEdgeMesh.h:53
itk::QuadEdgeMesh::PointIdList
std::vector< PointIdentifier > PointIdList
Definition: itkQuadEdgeMesh.h:153
itk::QuadEdgeMesh::GetPoint
bool GetPoint(PointIdentifier pid, PointType *pt) const
Definition: itkQuadEdgeMesh.h:388
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::QuadEdgeMeshPolygonCell
Definition: itkQuadEdgeMeshPolygonCell.h:39
itk::QuadEdgeMesh::PointIdInternalIterator
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
Definition: itkQuadEdgeMesh.h:80
itk::QuadEdgeMesh::GetEdgeCells
CellsContainer * GetEdgeCells()
Definition: itkQuadEdgeMesh.h:193
itkMesh.h
itk::QuadEdgeMeshLineCell
Class that connects the QuadEdgeMesh with the Mesh.
Definition: itkQuadEdgeMeshLineCell.h:41
itkQuadEdgeMeshPolygonCell.h
itkQuadEdgeMeshFrontIterator.h
itk::QuadEdgeMesh::m_NoPoint
static const PointIdentifier m_NoPoint
Definition: itkQuadEdgeMesh.h:161
itk::MeshEnums::MeshClassCellsAllocationMethod
MeshClassCellsAllocationMethod
Definition: itkCommonEnums.h:192
itk::QuadEdgeMesh::VectorType
typename Traits::VectorType VectorType
Definition: itkQuadEdgeMesh.h:142
itk::QuadEdgeMesh::FreeCellIndexesType
std::queue< CellIdentifier > FreeCellIndexesType
Definition: itkQuadEdgeMesh.h:150
itk::Mesh< TPixel, VDimension, TTraits >::CellFeatureIdentifier
typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier
Definition: itkMesh.h:179
itk::QuadEdgeMesh::GetNumberOfEdges
CellIdentifier GetNumberOfEdges() const
Definition: itkQuadEdgeMesh.h:455
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::QuadEdgeMesh::GetAssignedCellBoundaryIfOneExists
bool GetAssignedCellBoundaryIfOneExists(int, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const
Definition: itkQuadEdgeMesh.h:313
itkQuadEdgeMeshLineCell.h
itk::QuadEdgeMesh::GetBoundaryAssignment
bool GetBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier, CellIdentifier *)
Definition: itkQuadEdgeMesh.h:266
itk::Mesh
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:126
itk::QuadEdgeMesh::SetEdgeCells
void SetEdgeCells(CellsContainer *edgeCells)
Definition: itkQuadEdgeMesh.h:203
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
itk::PointSet< TPixel, VDimension, TTraits >::PointType
typename MeshTraits::PointType PointType
Definition: itkPointSet.h:104
itk::QuadEdgeMesh::GetBoundaryAssignments
BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int)
Definition: itkQuadEdgeMesh.h:242
itk::QuadEdgeMesh::GetCellBoundaryFeatureNeighbors
CellIdentifier GetCellBoundaryFeatureNeighbors(int, CellIdentifier, CellFeatureIdentifier, std::set< CellIdentifier > *)
Definition: itkQuadEdgeMesh.h:295
itkQEDefineFrontIteratorMethodsMacro
#define itkQEDefineFrontIteratorMethodsMacro(MeshTypeArg)
Definition: itkQuadEdgeMeshFrontIterator.h:24
itk::QuadEdgeMesh::QEType
typename Traits::QEPrimal QEType
Definition: itkQuadEdgeMesh.h:137
itk::QuadEdgeMesh::ClearFreePointAndCellIndexesLists
void ClearFreePointAndCellIndexesLists()
Definition: itkQuadEdgeMesh.h:437
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itkQuadEdgeMeshTraits.h