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::CoordRepType;
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 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 else
215 {
216 return &m_PointIds.front();
217 }
218 }
219
220 PointIdIterator
221 PointIdsEnd() override
222 {
223 // NOTE ALEX: should update the array on the fly to make it faster
224 if (m_PointIds.empty())
225 {
226 return (static_cast<PointIdIterator>(nullptr));
227 }
228 else
229 {
230 return &m_PointIds.back() + 1;
231 }
232 }
233
234 PointIdConstIterator
235 PointIdsBegin() const override
236 {
237 // NOTE ALEX: should update the array on the fly to make it faster
238 MakePointIds();
239 if (m_PointIds.empty())
240 {
241 return (static_cast<PointIdIterator>(nullptr));
242 }
243 else
244 {
245 return &m_PointIds.front();
246 }
247 }
248
249 PointIdConstIterator
250 PointIdsEnd() const override
251 {
252 // NOTE ALEX: should update the array on the fly to make it faster
253 if (m_PointIds.empty())
254 {
255 return (static_cast<PointIdIterator>(nullptr));
256 }
257 else
258 {
259 return &m_PointIds.back() + 1;
260 }
261 }
262
264 virtual void
266
267 virtual void
269
272
275
278
281
284
285protected:
286 using PointIDListType = std::vector<PointIdentifier>;
287 mutable PointIDListType m_PointIds{};
288
289private:
290 void
292 {
293 m_PointIds.clear();
294
295 PointIdInternalConstIterator it = this->InternalPointIdsBegin();
296 PointIdInternalConstIterator end = this->InternalPointIdsEnd();
297
298 while (it != end)
299 {
300 m_PointIds.push_back(it.Value()->GetOrigin());
301 ++it;
302 }
303 }
304
308 CellIdentifier m_Ident{};
309
313 QuadEdgeType * m_EdgeRingEntry{};
314
318 EdgeCellListType m_EdgeCellList{};
319};
320} // end namespace itk
321
322#ifndef ITK_MANUAL_INSTANTIATION
323# include "itkQuadEdgeMeshPolygonCell.hxx"
324#endif
325
326#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....