ITK  5.4.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
31
33#include "itkConceptChecking.h"
34
35
36namespace itk
37{
50template <typename TPixel,
51 unsigned int VDimension,
52 typename TTraits = QuadEdgeMeshTraits<TPixel, VDimension, bool, bool>>
53class ITK_TEMPLATE_EXPORT QuadEdgeMesh : public Mesh<TPixel, VDimension, TTraits>
54{
55public:
56 ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMesh);
57
59 using Traits = TTraits;
60 using PixelType = TPixel;
61
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::CoordRepType;
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 = CoordRepType[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;
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 *>;
156
158
161
164
165public:
167 itkNewMacro(Self);
168 itkOverrideGetNameOfClassMacro(QuadEdgeMesh);
171#if !defined(ITK_WRAPPING_PARSER)
174#endif
175
176public:
177 // Multithreading framework: not tested yet.
178 bool
180 {
181 return (false);
182 }
183
184 void
185 Initialize() override;
186
188 virtual void
190
193 {
194 return m_EdgeCellsContainer;
195 }
196 const CellsContainer *
198 {
199 return m_EdgeCellsContainer;
200 }
201 void
203 {
204 m_EdgeCellsContainer = edgeCells;
205 }
206 void
208 {
209 m_EdgeCellsContainer->InsertElement(cellId, cellPointer.ReleaseOwnership());
210 }
211
218 void
219 CopyInformation(const DataObject * data) override
220 {
221 (void)data;
222 }
223 void
224 Graft(const DataObject * data) override;
228 void
230
232 void
234 {}
235
236#if !defined(ITK_WRAPPING_PARSER)
238 void
240 {
241 (void)dimension;
242 (void)container;
243 }
247 BoundaryAssignmentsContainerPointer
249 {
250 (void)dimension;
251 return (nullptr);
252 }
256 const BoundaryAssignmentsContainerPointer
257 GetBoundaryAssignments(int dimension) const
258 {
259 (void)dimension;
260 return (nullptr);
261 }
264#endif
265
267 void
269 CellIdentifier cellId,
270 CellFeatureIdentifier featureId,
271 CellIdentifier boundaryId)
272 {
273 (void)dimension;
274 (void)cellId;
275 (void)featureId;
276 (void)boundaryId;
277 }
281 bool
283 CellIdentifier cellId,
284 CellFeatureIdentifier featureId,
285 CellIdentifier * boundaryId) const
286 {
287 (void)dimension;
288 (void)cellId;
289 (void)featureId;
290 (void)boundaryId;
291 return (false); // ALEX: is it the good way?
292 }
296 bool
298 {
299 (void)dimension;
300 (void)cellId;
301 (void)featureId;
302 return (false); // ALEX: is it the good way?
303 }
307 bool
309 CellIdentifier cellId,
310 CellFeatureIdentifier featureId,
311 CellAutoPointer & cellAP) const
312 {
313 (void)dimension;
314 (void)cellId;
315 (void)featureId;
316 (void)cellAP;
317 return (false);
318 }
322 CellIdentifier
324 CellIdentifier cellId,
325 CellFeatureIdentifier featureId,
326 std::set<CellIdentifier> * cellSet)
327 {
328 (void)dimension;
329 (void)cellId;
330 (void)featureId;
331 (void)cellSet;
332 return CellIdentifier{};
333 }
337 CellIdentifier
338 GetCellNeighbors(CellIdentifier itkNotUsed(cellId), std::set<CellIdentifier> * itkNotUsed(cellSet))
339 {
340 return CellIdentifier{};
341 }
342
344 bool
346 CellIdentifier cellId,
347 CellFeatureIdentifier featureId,
348 CellAutoPointer & cellAP) const
349 {
350 (void)dimension;
351 (void)cellId;
352 (void)featureId;
353 (void)cellAP;
354 return (false); // ALEX: is it the good way?
355 }
359 void
361
363 virtual PointIdentifier
365
366 virtual CellIdentifier
368
369 virtual void
371
372 // Adding Point/Edge/Face methods
373 virtual PointIdentifier
374 AddPoint(const PointType & p);
375
377 virtual QEPrimal *
378 AddEdge(const PointIdentifier & orgPid, const PointIdentifier & destPid);
379
380 virtual QEPrimal *
382
384 virtual void
386
391 virtual QEPrimal *
392 AddFace(const PointIdList & points);
393
394 virtual QEPrimal *
396
397 virtual QEPrimal *
398 AddFaceWithSecurePointList(const PointIdList & points, bool CheckEdges);
399
401 virtual QEPrimal *
402 AddFaceTriangle(const PointIdentifier & aPid, const PointIdentifier & bPid, const PointIdentifier & cPid);
403
405 virtual void
407
408 virtual void
409 DeleteEdge(const PointIdentifier & orgPid, const PointIdentifier & destPid);
410
411 virtual void
413
414 virtual void
416
417 virtual void
419
420 virtual void
421 DeleteFace(FaceRefType faceToDelete);
422
423 //
424 bool
426 {
427 return (Superclass::GetPoint(pid, pt));
428 }
429
430 virtual PointType
431 GetPoint(const PointIdentifier & pid) const;
432
433 virtual VectorType
434 GetVector(const PointIdentifier & pid) const;
435
436 virtual QEPrimal *
437 GetEdge() const;
438
439 virtual QEPrimal *
440 GetEdge(const CellIdentifier & eid) const;
441
442 virtual QEPrimal *
443 FindEdge(const PointIdentifier & pid0) const;
444
445 virtual QEPrimal *
446 FindEdge(const PointIdentifier & pid0, const PointIdentifier & pid1) const;
447
448 virtual EdgeCellType *
449 FindEdgeCell(const PointIdentifier & pid0, const PointIdentifier & pid1) const;
450
454
457
460
463
466
467#ifdef ITK_USE_CONCEPT_CHECKING
468 // Begin concept checking
469 // End concept checking
470#endif
471
472 // for reusability of a mesh in the MeshToMesh filter
473 void
475 {
476 while (!this->m_FreePointIndexes.empty())
477 {
478 this->m_FreePointIndexes.pop();
479 }
480 while (!this->m_FreeCellIndexes.empty())
481 {
482 this->m_FreeCellIndexes.pop();
483 }
484 }
485
486 CellIdentifier
488 {
489 return (m_NumberOfFaces);
490 }
491 CellIdentifier
493 {
494 return (m_NumberOfEdges);
495 }
496
497protected:
500 ~QuadEdgeMesh() override;
504 virtual void
506
507 CellsContainerPointer m_EdgeCellsContainer{};
508
509private:
510 CellIdentifier m_NumberOfFaces{};
511 CellIdentifier m_NumberOfEdges{};
512
513protected:
514 FreePointIndexesType m_FreePointIndexes{};
515 FreeCellIndexesType m_FreeCellIndexes{};
516};
517} // namespace itk
518
519#ifndef ITK_MANUAL_INSTANTIATION
520# include "itkQuadEdgeMesh.hxx"
521#endif
522
523#endif
Base class for all data objects in ITK.
A wrapper of the STL "map" container.
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:127
Base class for most ITK classes.
Definition: itkObject.h:62
Class that connects the QuadEdgeMesh with the Mesh.
Mesh class for 2D manifolds embedded in ND space.
void BuildCellLinks() const
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
void SetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier boundaryId)
void SetCell(CellIdentifier cId, CellAutoPointer &cell)
CellIdentifier GetNumberOfEdges() const
virtual QEPrimal * FindEdge(const PointIdentifier &pid0) const
const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension) const
virtual QEPrimal * GetEdge(const CellIdentifier &eid) const
virtual void AddFace(QEPrimal *entry)
bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellAutoPointer &cellAP) const
CellIdentifier ComputeNumberOfFaces() const
virtual void DeleteEdge(const PointIdentifier &orgPid, const PointIdentifier &destPid)
virtual QEPrimal * FindEdge(const PointIdentifier &pid0, const PointIdentifier &pid1) const
const CellsContainer * GetEdgeCells() const
virtual QEPrimal * AddFaceTriangle(const PointIdentifier &aPid, const PointIdentifier &bPid, const PointIdentifier &cPid)
virtual VectorType GetVector(const PointIdentifier &pid) const
virtual void DeletePoint(const PointIdentifier &pid)
virtual void LightWeightDeleteEdge(EdgeCellType *edgeCell)
typename Traits::VertexRefType VertexRefType
void SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer *container)
virtual void DeleteFace(FaceRefType faceToDelete)
bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId)
typename Traits::QEPrimal QEType
bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellAutoPointer &cellAP) const
std::vector< PointIdentifier > PointIdList
virtual QEPrimal * AddFaceWithSecurePointList(const PointIdList &points, bool CheckEdges)
typename Traits::PrimalDataType PrimalDataType
CellsContainer * GetEdgeCells()
virtual CellIdentifier FindFirstUnusedCellIndex()
CellIdentifier GetNumberOfFaces() const
CellIdentifier GetCellBoundaryFeatureNeighbors(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, std::set< CellIdentifier > *cellSet)
void SetEdgeCell(CellIdentifier cellId, CellAutoPointer &cellPointer)
virtual void PushOnContainer(EdgeCellType *newEdge)
typename CellTraits::PointIdIterator PointIdIterator
virtual QEPrimal * AddFace(const PointIdList &points)
EdgeListType * EdgeListPointerType
virtual PointIdentifier AddPoint(const PointType &p)
BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
typename Traits::DualDataType DualDataType
virtual void Clear()
virtual PointIdentifier FindFirstUnusedPointIndex()
void Graft(const DataObject *data) override
CoordRepType ComputeEdgeLength(QEPrimal *e)
Compute the euclidean length of argument edge.
std::list< QEPrimal * > EdgeListType
virtual PointType GetPoint(const PointIdentifier &pid) const
virtual void LightWeightDeleteEdge(QEPrimal *e)
CellIdentifier ComputeNumberOfEdges() const
virtual QEPrimal * AddFaceWithSecurePointList(const PointIdList &points)
PointIdentifier ComputeNumberOfPoints() const
std::queue< CellIdentifier > FreeCellIndexesType
~QuadEdgeMesh() override
std::queue< PointIdentifier > FreePointIndexesType
PointIdentifier Splice(QEPrimal *a, QEPrimal *b)
static const PointIdentifier m_NoPoint
typename Traits::QEPrimal QEPrimal
virtual void DeleteEdge(QEPrimal *e)
void Initialize() override
typename Traits::VectorType VectorType
virtual void ClearCellsContainer()
virtual QEPrimal * AddEdge(const PointIdentifier &orgPid, const PointIdentifier &destPid)
static const CellIdentifier m_NoFace
void ClearFreePointAndCellIndexesLists()
typename Traits::FaceRefType FaceRefType
void SetEdgeCells(CellsContainer *edgeCells)
virtual QEPrimal * AddEdgeWithSecurePointList(const PointIdentifier &orgPid, const PointIdentifier &destPid)
typename Traits::QEDual QEDual
CellIdentifier GetCellNeighbors(CellIdentifier, std::set< CellIdentifier > *)
virtual QEPrimal * GetEdge() const
virtual EdgeCellType * FindEdgeCell(const PointIdentifier &pid0, const PointIdentifier &pid1) const
void CopyInformation(const DataObject *data) override
bool GetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier *boundaryId) const
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
CoordRepType[Self::PointDimension] CoordRepArrayType
itkQEDefineFrontIteratorMethodsMacro(Self)
bool GetPoint(PointIdentifier pid, PointType *pt) const
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....