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
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 *>;
155#ifndef ITK_FUTURE_LEGACY_REMOVE
156 using EdgeListPointerType [[deprecated("Please just use `EdgeListType *` instead!")]] = EdgeListType *;
157#endif
159
162
165
166public:
168 itkNewMacro(Self);
169 itkOverrideGetNameOfClassMacro(QuadEdgeMesh);
172#if !defined(ITK_WRAPPING_PARSER)
175#endif
176
177public:
178 // Multithreading framework: not tested yet.
179 bool
181 {
182 return (false);
183 }
184
185 void
186 Initialize() override;
187
189 virtual void
191
194 {
195 return m_EdgeCellsContainer;
196 }
197 const CellsContainer *
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
228
230 void
232 {}
233
234#if !defined(ITK_WRAPPING_PARSER)
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
324
326 virtual PointIdentifier
328
329 virtual CellIdentifier
331
332 virtual void
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 *
345
347 virtual void
349
354 virtual QEPrimal *
355 AddFace(const PointIdList & points);
356
357 virtual QEPrimal *
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
370
371 virtual void
372 DeleteEdge(const PointIdentifier & orgPid, const PointIdentifier & destPid);
373
374 virtual void
376
377 virtual void
379
380 virtual void
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
417
420
423
426
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
460protected:
463 ~QuadEdgeMesh() override;
467 virtual void
469
470 CellsContainerPointer m_EdgeCellsContainer{};
471
472private:
473 CellIdentifier m_NumberOfFaces{};
474 CellIdentifier m_NumberOfEdges{};
475
476protected:
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
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
typename PointType::CoordRepType CoordRepType
Class that connects the QuadEdgeMesh with the Mesh.
Mesh class for 2D manifolds embedded in ND space.
void BuildCellLinks() const
bool RemoveBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier)
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
CellIdentifier GetCellBoundaryFeatureNeighbors(int, CellIdentifier, CellFeatureIdentifier, std::set< CellIdentifier > *)
void SetCell(CellIdentifier cId, CellAutoPointer &cell)
CellIdentifier GetNumberOfEdges() const
virtual QEPrimal * FindEdge(const PointIdentifier &pid0) const
virtual QEPrimal * GetEdge(const CellIdentifier &eid) const
virtual void AddFace(QEPrimal *entry)
CellIdentifier ComputeNumberOfFaces() const
virtual void DeleteEdge(const PointIdentifier &orgPid, const PointIdentifier &destPid)
virtual QEPrimal * FindEdge(const PointIdentifier &pid0, const PointIdentifier &pid1) const
bool GetCellBoundaryFeature(int, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) 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)
BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int)
virtual void LightWeightDeleteEdge(EdgeCellType *edgeCell)
typename Traits::VertexRefType VertexRefType
virtual void DeleteFace(FaceRefType faceToDelete)
typename Traits::QEPrimal QEType
std::vector< PointIdentifier > PointIdList
virtual QEPrimal * AddFaceWithSecurePointList(const PointIdList &points, bool CheckEdges)
typename Traits::PrimalDataType PrimalDataType
CellsContainer * GetEdgeCells()
virtual CellIdentifier FindFirstUnusedCellIndex()
CellIdentifier GetNumberOfFaces() const
const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int) const
void SetEdgeCell(CellIdentifier cellId, CellAutoPointer &cellPointer)
virtual void PushOnContainer(EdgeCellType *newEdge)
typename CellTraits::PointIdIterator PointIdIterator
virtual QEPrimal * AddFace(const PointIdList &points)
virtual PointIdentifier AddPoint(const PointType &p)
typename Traits::DualDataType DualDataType
bool GetBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier, CellIdentifier *)
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
bool GetAssignedCellBoundaryIfOneExists(int, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const
~QuadEdgeMesh() override
std::queue< PointIdentifier > FreePointIndexesType
PointIdentifier Splice(QEPrimal *a, QEPrimal *b)
static const PointIdentifier m_NoPoint
typename Traits::QEPrimal QEPrimal
void SetBoundaryAssignment(int, CellIdentifier, CellFeatureIdentifier, CellIdentifier)
virtual void DeleteEdge(QEPrimal *e)
void Initialize() override
typename Traits::VectorType VectorType
void SetBoundaryAssignments(int, BoundaryAssignmentsContainer *)
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)
void CopyInformation(const DataObject *) override
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
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....