ITK  6.0.0
Insight Toolkit
itkQuadEdgeMeshPolygonCell.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 itkQuadEdgeMeshPolygonCell_h
19#define itkQuadEdgeMeshPolygonCell_h
20
21#include "itkTriangleCell.h"
23namespace itk
24{
38template <typename TCellInterface>
39class ITK_TEMPLATE_EXPORT QuadEdgeMeshPolygonCell : public TCellInterface
40{
41public:
42 ITK_DISALLOW_COPY_AND_MOVE(QuadEdgeMeshPolygonCell);
43
45 // itkCellCommonTypedefs
49 using RawPointer = Self *;
50 using ConstRawPointer = const Self *;
51
52 // itkCellInheritedTypedefs
53 using Superclass = TCellInterface;
54 using typename Superclass::PixelType;
55 using CellType = typename Superclass::CellType;
56 using typename Superclass::CellAutoPointer;
57 using typename Superclass::CellConstAutoPointer;
58 using typename Superclass::CellRawPointer;
59 using typename Superclass::CellConstRawPointer;
60 using CellTraits = typename Superclass::CellTraits;
61 using typename Superclass::CoordinateType;
62 using typename Superclass::InterpolationWeightType;
63 using typename Superclass::PointIdentifier;
64 using typename Superclass::CellIdentifier;
65 using typename Superclass::CellFeatureIdentifier;
66 using CellFeatureCount = typename Superclass::CellFeatureIdentifier;
67 using typename Superclass::PointType;
68 using typename Superclass::PointsContainer;
69 using typename Superclass::UsingCellsContainer;
70 using typename Superclass::ParametricCoordArrayType;
71 using typename Superclass::ShapeFunctionsArrayType;
72 static constexpr unsigned int PointDimension = Superclass::PointDimension;
73 static constexpr unsigned int CellDimension = 2;
74
76 using MultiVisitor = typename CellType::MultiVisitor;
77
79 using EdgeCellListType = std::vector<EdgeCellType *>;
80
82 using PointIdIterator = typename CellTraits::PointIdIterator;
83 using PointIdConstIterator = typename CellTraits::PointIdConstIterator;
84 using PointIdInternalIterator = typename CellTraits::PointIdInternalIterator;
85 using PointIdInternalConstIterator = typename CellTraits::PointIdInternalConstIterator;
86
88 using QuadEdgeType = typename CellTraits::QuadEdgeType;
89 using VertexRefType = typename QuadEdgeType::OriginRefType;
90 using FaceRefType = typename QuadEdgeType::DualOriginRefType;
91 using PrimalDataType = typename QuadEdgeType::PrimalDataType;
92 using DualDataType = typename QuadEdgeType::DualDataType;
93 using QEDual = typename QuadEdgeType::DualType;
94
95public:
97 itkOverrideGetNameOfClassMacro(QuadEdgeMeshPolygonCell);
98
100 QuadEdgeMeshPolygonCell(PointIdentifier nPoints = 0);
106 void
107 SetIdent(CellIdentifier cid)
108 {
109 m_Ident = cid;
110 }
111 CellIdentifier
113 {
114 return (m_Ident);
115 }
119 QuadEdgeType *
121 {
122 return (m_EdgeRingEntry);
123 }
124 void
126 {
127 m_EdgeRingEntry = entry;
128 }
132 SelfAutoPointer
134
136 void
137 Accept(CellIdentifier cellId, MultiVisitor * mv) override;
138
140 GetType() const override
141 {
143 }
144
146 static constexpr CellGeometryEnum
148 {
150 }
151
152 unsigned int
153 GetDimension() const override
154 {
155 return (Self::CellDimension);
156 }
157
158 unsigned int
159 GetNumberOfPoints() const override;
160
162 GetNumberOfBoundaryFeatures(int dimension) const override;
163
164 bool
165 GetBoundaryFeature(int dimension, CellFeatureIdentifier cellId, CellAutoPointer & cell) override;
166
168 void
169 MakeCopy(CellAutoPointer & cell) const override
170 {
171 const PointIdentifier numberOfPoints = this->GetNumberOfPoints();
172 auto * newPolygonCell = new Self(numberOfPoints);
175 cell.TakeOwnership(newPolygonCell);
176 if (numberOfPoints)
177 {
178 PointIdentifier i = 0;
179
180 PointIdInternalConstIterator it = this->InternalPointIdsBegin();
181 const PointIdInternalConstIterator end = this->InternalPointIdsEnd();
182
183 while (it != end)
184 {
185 newPolygonCell->SetPointId(i, it.Value()->GetOrigin());
186 ++i;
187 ++it;
188 }
189 }
190 }
191
193 void
195
196 void
198
199 void
200 SetPointId(int localId, PointIdentifier pId) override;
201
202 virtual PointIdentifier
203 GetPointId(int localId) const;
204
206 PointIdsBegin() override
207 {
208 // NOTE ALEX: should update the array on the fly to make it faster
209 MakePointIds();
210 if (m_PointIds.empty())
211 {
212 return (static_cast<PointIdIterator>(nullptr));
213 }
214
215 return &m_PointIds.front();
216 }
217
218 PointIdIterator
219 PointIdsEnd() override
220 {
221 // NOTE ALEX: should update the array on the fly to make it faster
222 if (m_PointIds.empty())
223 {
224 return (static_cast<PointIdIterator>(nullptr));
225 }
226
227 return &m_PointIds.back() + 1;
228 }
229
230 PointIdConstIterator
231 PointIdsBegin() const override
232 {
233 // NOTE ALEX: should update the array on the fly to make it faster
234 MakePointIds();
235 if (m_PointIds.empty())
236 {
237 return (static_cast<PointIdIterator>(nullptr));
238 }
239
240 return &m_PointIds.front();
241 }
242
243 PointIdConstIterator
244 PointIdsEnd() const override
245 {
246 // NOTE ALEX: should update the array on the fly to make it faster
247 if (m_PointIds.empty())
248 {
249 return (static_cast<PointIdIterator>(nullptr));
250 }
251
252 return &m_PointIds.back() + 1;
253 }
254
256 virtual void
258
259 virtual void
261
264
267
270
273
276
277protected:
278 using PointIDListType = std::vector<PointIdentifier>;
279 mutable PointIDListType m_PointIds{};
280
281private:
282 void
284 {
285 m_PointIds.clear();
286
287 PointIdInternalConstIterator it = this->InternalPointIdsBegin();
288 const PointIdInternalConstIterator end = this->InternalPointIdsEnd();
289
290 while (it != end)
291 {
292 m_PointIds.push_back(it.Value()->GetOrigin());
293 ++it;
294 }
295 }
296
300 CellIdentifier m_Ident{};
301
305 QuadEdgeType * m_EdgeRingEntry{};
306
310 EdgeCellListType m_EdgeCellList{};
311};
312} // end namespace itk
313
314#ifndef ITK_MANUAL_INSTANTIATION
315# include "itkQuadEdgeMeshPolygonCell.hxx"
316#endif
317
318#endif
Implements an Automatic Pointer to an object.
Class that connects the QuadEdgeMesh with the Mesh.
QuadEdgeMeshPolygonCell(PointIdentifier nPoints=0)
PointIdConstIterator PointIdsEnd() const override
void SetPointId(int localId, PointIdentifier pId) override
void MakeCopy(CellAutoPointer &cell) const override
typename CellTraits::QuadEdgeType QuadEdgeType
virtual PointIdentifier GetPointId(int localId) const
void SetEdgeRingEntry(QuadEdgeType *entry)
typename QuadEdgeType::DualType QEDual
virtual PointIdInternalConstIterator InternalPointIdsBegin() const
typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
void Accept(CellIdentifier cellId, MultiVisitor *mv) override
typename CellType::MultiVisitor MultiVisitor
std::vector< PointIdentifier > PointIDListType
typename Superclass::CellType CellType
virtual PointIdInternalConstIterator InternalPointIdsEnd() const
bool GetBoundaryFeature(int dimension, CellFeatureIdentifier cellId, CellAutoPointer &cell) override
PointIdConstIterator PointIdsBegin() const override
QuadEdgeMeshPolygonCell(QuadEdgeType *e)
virtual PointIdInternalIterator InternalPointIdsEnd()
typename QuadEdgeType::DualOriginRefType FaceRefType
typename Superclass::CellTraits CellTraits
typename QuadEdgeType::PrimalDataType PrimalDataType
typename QuadEdgeType::DualDataType DualDataType
PointIdIterator PointIdsEnd() override
typename CellTraits::PointIdIterator PointIdIterator
typename CellTraits::PointIdConstIterator PointIdConstIterator
CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override
void SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override
PointIdIterator PointIdsBegin() override
typename QuadEdgeType::OriginRefType VertexRefType
unsigned int GetNumberOfPoints() const override
virtual PointIdInternalConstIterator InternalGetPointIds() const
CellGeometryEnum GetType() const override
virtual void InternalSetPointIds(PointIdInternalConstIterator first)
unsigned int GetDimension() const override
virtual void InternalSetPointIds(PointIdInternalConstIterator first, PointIdInternalConstIterator last)
std::vector< EdgeCellType * > EdgeCellListType
virtual PointIdInternalIterator InternalPointIdsBegin()
void SetPointIds(PointIdConstIterator first) override
typename Superclass::CellFeatureIdentifier CellFeatureCount
static constexpr CellGeometryEnum GetTopologyId()
AddImageFilter Self
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....