ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMesh.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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, unsigned int VDimension,
51  typename TTraits = QuadEdgeMeshTraits< TPixel, VDimension, bool, bool > >
52 class ITK_TEMPLATE_EXPORT QuadEdgeMesh:public Mesh< TPixel, VDimension, TTraits >
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_ASSIGN(QuadEdgeMesh);
56 
58  using Traits = TTraits;
59  using PixelType = TPixel;
60 
62  using Self = QuadEdgeMesh;
66 
68  static constexpr unsigned int PointDimension = Traits::PointDimension;
69  static constexpr unsigned int MaxTopologicalDimension = Traits::MaxTopologicalDimension;
70 
72  using CellPixelType = typename Superclass::CellPixelType;
73  using CoordRepType = typename Superclass::CoordRepType;
74  using PointIdentifier = typename Superclass::PointIdentifier;
75  using PointHashType = typename Superclass::PointHashType;
76  using PointType = typename Superclass::PointType;
77  using CellTraits = typename Superclass::CellTraits;
78 
79  using PointIdInternalIterator = typename CellTraits::PointIdInternalIterator;
80  using PointIdIterator = typename CellTraits::PointIdIterator;
81 
82  // Point section:
83  using PointsContainer = typename Superclass::PointsContainer;
84  using PointsContainerPointer = typename Superclass::PointsContainerPointer;
85  typedef CoordRepType CoordRepArrayType[Self::PointDimension];
86 
87  // Point data section:
88  using PointDataContainer = typename Superclass::PointDataContainer;
89  using PointDataContainerPointer = typename Superclass::PointDataContainerPointer;
90  using PointDataContainerIterator = typename Superclass::PointDataContainerIterator;
91  using PointsContainerConstIterator = typename Superclass::PointsContainerConstIterator;
92  using PointsContainerIterator = typename Superclass::PointsContainerIterator;
93 
94  // Cell section:
96  using CellType = typename Superclass::CellType;
97  using CellAutoPointer = typename Superclass::CellAutoPointer;
98  using CellFeatureIdentifier = typename Superclass::CellFeatureIdentifier;
99  using CellFeatureCount = typename Superclass::CellFeatureCount;
100  using CellMultiVisitorType = typename Superclass::CellMultiVisitorType;
101  using CellsContainer = typename Superclass::CellsContainer;
103 
104  using CellsContainerConstIterator = typename Superclass::CellsContainerConstIterator;
105  using CellsContainerIterator = typename Superclass::CellsContainerIterator;
106 
107  using CellLinksContainer = typename Superclass::CellLinksContainer;
108  using CellLinksContainerPointer = typename Superclass::CellLinksContainerPointer;
109  using CellLinksContainerIterator = typename Superclass::CellLinksContainerIterator;
110 
111  // Cell data section:
112  using CellDataContainer = typename Superclass::CellDataContainer;
113  using CellDataContainerPointer = typename Superclass::CellDataContainerPointer;
114  using CellDataContainerIterator = typename Superclass::CellDataContainerIterator;
115 
116  // Point / Cell correspondance section:
117  using PointCellLinksContainer = typename Superclass::PointCellLinksContainer;
118  using PointCellLinksContainerIterator = typename Superclass::PointCellLinksContainerIterator;
119 
120  // BoundaryAssignMents section:
121  using BoundaryAssignmentsContainer = typename Superclass::BoundaryAssignmentsContainer;
122  using BoundaryAssignmentsContainerPointer = typename Superclass::BoundaryAssignmentsContainerPointer;
123  using BoundaryAssignmentsContainerVector = typename Superclass::BoundaryAssignmentsContainerVector;
124 
125  // Miscellaneous section:
126  using BoundingBoxPointer = typename Superclass::BoundingBoxPointer;
127  using BoundingBoxType = typename Superclass::BoundingBoxType;
129  using InterpolationWeightType = typename Superclass::InterpolationWeightType;
130 
132  using PrimalDataType = typename Traits::PrimalDataType;
133  using DualDataType = typename Traits::DualDataType;
134  using QEPrimal = typename Traits::QEPrimal;
135  using QEDual = typename Traits::QEDual;
136  using QEType = typename Traits::QEPrimal;
137  // See the TODO entry dated from 2005-05-28
138  // struct QEType : public QEPrimal, public QEDual {}
139  using VertexRefType = typename Traits::VertexRefType;
140  using FaceRefType = typename Traits::FaceRefType;
141  using VectorType = typename Traits::VectorType;
142 
146 
148  using FreePointIndexesType = std::queue< PointIdentifier >;
149  using FreeCellIndexesType = std::queue< CellIdentifier >;
150 
152  using PointIdList = std::vector< PointIdentifier >;
153  using EdgeListType = std::list< QEPrimal * >;
155 
158 
160  static const CellIdentifier m_NoFace;
161 
162 public:
163 
165  itkNewMacro(Self);
166  itkTypeMacro(QuadEdgeMesh, Mesh);
168 
169 #if !defined( ITK_WRAPPING_PARSER )
170 
172 #endif
173 
174 public:
175 
176  // Multithreading framework: not tested yet.
178  {
179  return ( false );
180  }
181 
182  void Initialize() override;
183 
185  virtual void Clear();
186 
187  CellsContainer * GetEdgeCells() { return m_EdgeCellsContainer; }
188  const CellsContainer * GetEdgeCells() const { return m_EdgeCellsContainer; }
189  void SetEdgeCells(CellsContainer *edgeCells)
190  { m_EdgeCellsContainer = edgeCells; }
191  void SetEdgeCell(CellIdentifier cellId, CellAutoPointer & cellPointer)
192  { m_EdgeCellsContainer->InsertElement( cellId, cellPointer.ReleaseOwnership() ); }
193 
200  void CopyInformation(const DataObject *data) override { (void)data; }
201  void Graft(const DataObject *data) override;
203 
205  void SqueezePointsIds();
206 
208  void BuildCellLinks() {}
209 
210 #if !defined( ITK_WRAPPING_PARSER )
211 
212  void SetBoundaryAssignments(int dimension,
213  BoundaryAssignmentsContainer *container)
214  {
215  (void)dimension;
216  (void)container;
217  }
219 
222  {
223  (void)dimension;
225  }
227 
230  int dimension) const
231  {
232  (void)dimension;
233  return ( (BoundaryAssignmentsContainerPointer)nullptr );
234  }
236 
237 #endif
238 
240  void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
241  CellFeatureIdentifier featureId,
242  CellIdentifier boundaryId)
243  {
244  (void)dimension;
245  (void)cellId;
246  (void)featureId;
247  (void)boundaryId;
248  }
250 
252  bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
253  CellFeatureIdentifier featureId,
254  CellIdentifier *boundaryId) const
255  {
256  (void)dimension;
257  (void)cellId;
258  (void)featureId;
259  (void)boundaryId;
260  return ( false ); // ALEX: is it the good way?
261  }
263 
265  bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
266  CellFeatureIdentifier featureId)
267  {
268  (void)dimension;
269  (void)cellId;
270  (void)featureId;
271  return ( false ); // ALEX: is it the good way?
272  }
274 
276  bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId,
277  CellFeatureIdentifier featureId,
278  CellAutoPointer & cellAP) const
279  {
280  (void)dimension;
281  (void)cellId;
282  (void)featureId;
283  (void)cellAP;
284  return ( false );
285  }
287 
290  CellIdentifier cellId,
291  CellFeatureIdentifier featureId,
292  std::set< CellIdentifier > *cellSet)
293  {
294  (void)dimension;
295  (void)cellId;
296  (void)featureId;
297  (void)cellSet;
299  }
301 
304  std::set< CellIdentifier > * itkNotUsed(cellSet))
305  {
307  }
308 
311  CellIdentifier cellId,
312  CellFeatureIdentifier featureId,
313  CellAutoPointer & cellAP) const
314  {
315  (void)dimension;
316  (void)cellId;
317  (void)featureId;
318  (void)cellAP;
319  return ( false ); // ALEX: is it the good way?
320  }
322 
324  void SetCell(CellIdentifier cId, CellAutoPointer & cell);
325 
327  virtual PointIdentifier FindFirstUnusedPointIndex();
328 
329  virtual CellIdentifier FindFirstUnusedCellIndex();
330 
331  virtual void PushOnContainer(EdgeCellType *newEdge);
332 
333  // Adding Point/Edge/Face methods
334  virtual PointIdentifier AddPoint(const PointType & p);
335 
337  virtual QEPrimal * AddEdge(const PointIdentifier & orgPid,
338  const PointIdentifier & destPid);
339 
340  virtual QEPrimal * AddEdgeWithSecurePointList(const PointIdentifier & orgPid,
341  const PointIdentifier & destPid);
342 
344  virtual void AddFace(QEPrimal *e);
345 
350  virtual QEPrimal * AddFace(const PointIdList & points);
351 
352  virtual QEPrimal * AddFaceWithSecurePointList(const PointIdList & points);
353 
354  virtual QEPrimal * AddFaceWithSecurePointList(const PointIdList & points,
355  bool CheckEdges);
356 
358  virtual QEPrimal * AddFaceTriangle(const PointIdentifier & aPid,
359  const PointIdentifier & bPid,
360  const PointIdentifier & cPid);
361 
363  virtual void DeletePoint(const PointIdentifier & pid);
364 
365  virtual void DeleteEdge(const PointIdentifier & orgPid,
366  const PointIdentifier & destPid);
367 
368  virtual void DeleteEdge(QEPrimal *e);
369 
370  virtual void LightWeightDeleteEdge(EdgeCellType *e);
371 
372  virtual void LightWeightDeleteEdge(QEPrimal *e);
373 
374  virtual void DeleteFace(FaceRefType faceToDelete);
375 
376  //
377  bool GetPoint(PointIdentifier pid, PointType *pt) const
378  {
379  return ( Superclass::GetPoint(pid, pt) );
380  }
381 
382  virtual PointType GetPoint(const PointIdentifier & pid) const;
383 
384  virtual VectorType GetVector(const PointIdentifier & pid) const;
385 
386  virtual QEPrimal * GetEdge() const;
387 
388  virtual QEPrimal * GetEdge(const CellIdentifier & eid) const;
389 
390  virtual QEPrimal * FindEdge(const PointIdentifier & pid0) const;
391 
392  virtual QEPrimal * FindEdge(const PointIdentifier & pid0,
393  const PointIdentifier & pid1) const;
394 
395  virtual EdgeCellType * FindEdgeCell(const PointIdentifier & pid0,
396  const PointIdentifier & pid1) const;
397 
399  CoordRepType ComputeEdgeLength(QEPrimal *e);
400 
401  PointIdentifier ComputeNumberOfPoints() const;
402 
403  CellIdentifier ComputeNumberOfFaces() const;
404 
405  CellIdentifier ComputeNumberOfEdges() const;
406 
407  PointIdentifier Splice(QEPrimal *a, QEPrimal *b);
408 
409 #ifdef ITK_USE_CONCEPT_CHECKING
410  // Begin concept checking
411  // End concept checking
412 #endif
413 
414  // for reusability of a mesh in the MeshToMesh filter
416  {
417  while ( !this->m_FreePointIndexes.empty() )
418  {
419  this->m_FreePointIndexes.pop();
420  }
421  while ( !this->m_FreeCellIndexes.empty() )
422  {
423  this->m_FreeCellIndexes.pop();
424  }
425  }
426 
427  CellIdentifier GetNumberOfFaces() const { return ( m_NumberOfFaces ); }
428  CellIdentifier GetNumberOfEdges() const { return ( m_NumberOfEdges ); }
429 
430 protected:
432  QuadEdgeMesh();
433  ~QuadEdgeMesh() override;
435 
437  virtual void ClearCellsContainer();
438 
440 
441 private:
444 
445 protected:
448 };
449 }
450 
451 #ifndef ITK_MANUAL_INSTANTIATION
452 #include "itkQuadEdgeMesh.hxx"
453 #endif
454 
455 #endif
CellsContainerPointer m_EdgeCellsContainer
typename Traits::VectorType VectorType
bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellAutoPointer &cellAP) const
typename Superclass::CellsContainerIterator CellsContainerIterator
typename Superclass::PointDataContainer PointDataContainer
typename Superclass::CellFeatureCount CellFeatureCount
const CellsContainer * GetEdgeCells() const
typename Superclass::CellsContainerPointer CellsContainerPointer
typename Superclass::BoundaryAssignmentsContainer BoundaryAssignmentsContainer
typename Superclass::CellTraits CellTraits
typename Superclass::CellPixelType CellPixelType
typename Superclass::CellLinksContainer CellLinksContainer
const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension) const
Define numeric traits for std::vector.
BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
typename Superclass::PointIdentifier PointIdentifier
typename Superclass::PointType PointType
typename Superclass::CellAutoPointer CellAutoPointer
typename Superclass::BoundingBoxPointer BoundingBoxPointer
typename Superclass::PointsContainerIterator PointsContainerIterator
bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId)
typename Superclass::BoundaryAssignmentsContainerVector BoundaryAssignmentsContainerVector
typename Superclass::BoundingBoxType BoundingBoxType
typename Traits::QEPrimal QEPrimal
static const PointIdentifier m_NoPoint
typename Superclass::CellIdentifier CellIdentifier
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:108
typename Superclass::RegionType RegionType
void CopyInformation(const DataObject *data) override
typename Traits::VertexRefType VertexRefType
typename Traits::DualDataType DualDataType
typename Superclass::PointsContainer PointsContainer
typename Superclass::BoundaryAssignmentsContainerPointer BoundaryAssignmentsContainerPointer
void SetEdgeCells(CellsContainer *edgeCells)
typename Traits::PrimalDataType PrimalDataType
CellsContainer * GetEdgeCells()
bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellAutoPointer &cellAP) const
void SetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier boundaryId)
FreePointIndexesType m_FreePointIndexes
typename Superclass::CellFeatureIdentifier CellFeatureIdentifier
void SetEdgeCell(CellIdentifier cellId, CellAutoPointer &cellPointer)
bool GetPoint(PointIdentifier pid, PointType *pt) const
typename Superclass::CellMultiVisitorType CellMultiVisitorType
typename Superclass::PointDataContainerPointer PointDataContainerPointer
typename Traits::QEPrimal QEType
typename Superclass::CellDataContainer CellDataContainer
static const CellIdentifier m_NoFace
typename Traits::QEDual QEDual
typename Traits::FaceRefType FaceRefType
CellIdentifier m_NumberOfEdges
std::list< QEPrimal * > EdgeListType
CellIdentifier GetCellNeighbors(CellIdentifier, std::set< CellIdentifier > *)
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
bool GetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier *boundaryId) const
typename Superclass::CellsContainerConstIterator CellsContainerConstIterator
typename Superclass::CellDataContainerPointer CellDataContainerPointer
typename CellsContainer::Pointer CellsContainerPointer
Definition: itkMesh.h:165
void SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer *container)
typename Superclass::CellLinksContainerIterator CellLinksContainerIterator
typename Superclass::PointCellLinksContainerIterator PointCellLinksContainerIterator
CellIdentifier GetCellBoundaryFeatureNeighbors(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, std::set< CellIdentifier > *cellSet)
void ClearFreePointAndCellIndexesLists()
typename Superclass::CellLinksContainerPointer CellLinksContainerPointer
typename CellTraits::PointIdIterator PointIdIterator
typename Superclass::PointHashType PointHashType
CellIdentifier m_NumberOfFaces
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
CellIdentifier GetNumberOfFaces() const
Mesh class for 2D manifolds embedded in ND space.
typename Superclass::CellsContainer CellsContainer
#define itkQEDefineFrontIteratorMethodsMacro(MeshTypeArg)
typename Superclass::PointDataContainerIterator PointDataContainerIterator
typename Superclass::PointCellLinksContainer PointCellLinksContainer
std::queue< PointIdentifier > FreePointIndexesType
typename Superclass::PointsContainerConstIterator PointsContainerConstIterator
typename MeshTraits::CellIdentifier CellIdentifier
Definition: itkMesh.h:147
Base class for most ITK classes.
Definition: itkObject.h:60
typename Superclass::PointsContainerPointer PointsContainerPointer
typename Superclass::CellType CellType
typename Superclass::CoordRepType CoordRepType
CellIdentifier GetNumberOfEdges() const
typename Superclass::InterpolationWeightType InterpolationWeightType
std::vector< PointIdentifier > PointIdList
std::queue< CellIdentifier > FreeCellIndexesType
Base class for all data objects in ITK.
Class that connects the QuadEdgeMesh with the Mesh.
FreeCellIndexesType m_FreeCellIndexes
EdgeListType * EdgeListPointerType
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
typename Superclass::CellDataContainerIterator CellDataContainerIterator