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"
23 namespace itk
24 {
38 template <typename TCellInterface>
39 class ITK_TEMPLATE_EXPORT QuadEdgeMeshPolygonCell : public TCellInterface
40 {
41 public:
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 
95 public:
97  itkOverrideGetNameOfClassMacro(QuadEdgeMeshPolygonCell);
98 
100  QuadEdgeMeshPolygonCell(PointIdentifier nPoints = 0);
102  ~QuadEdgeMeshPolygonCell() override;
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
133  New();
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 
161  CellFeatureCount
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
194  SetPointIds(PointIdConstIterator first) override;
195 
196  void
197  SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override;
198 
199  void
200  SetPointId(int localId, PointIdentifier pId) override;
201 
202  virtual PointIdentifier
203  GetPointId(int localId) const;
204 
205  PointIdIterator
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
265  InternalSetPointIds(PointIdInternalConstIterator first);
266 
267  virtual void
268  InternalSetPointIds(PointIdInternalConstIterator first, PointIdInternalConstIterator last);
269 
270  virtual PointIdInternalIterator
271  InternalPointIdsBegin();
272 
273  virtual PointIdInternalIterator
274  InternalPointIdsEnd();
275 
276  virtual PointIdInternalConstIterator
277  InternalGetPointIds() const;
278 
279  virtual PointIdInternalConstIterator
280  InternalPointIdsBegin() const;
281 
282  virtual PointIdInternalConstIterator
283  InternalPointIdsEnd() const;
284 
285 protected:
286  using PointIDListType = std::vector<PointIdentifier>;
287  mutable PointIDListType m_PointIds{};
288 
289 private:
290  void
291  MakePointIds() const
292  {
293  m_PointIds.clear();
294 
295  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
296  const 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
itk::QuadEdgeMeshPolygonCell::VertexRefType
typename QuadEdgeType::OriginRefType VertexRefType
Definition: itkQuadEdgeMeshPolygonCell.h:89
itk::CommonEnums::CellGeometry::POLYGON_CELL
itk::AutoPointer
Implements an Automatic Pointer to an object.
Definition: itkAutoPointer.h:46
itk::QuadEdgeMeshPolygonCell::CellType
typename Superclass::CellType CellType
Definition: itkQuadEdgeMeshPolygonCell.h:55
itk::QuadEdgeMeshPolygonCell::SetIdent
void SetIdent(CellIdentifier cid)
Definition: itkQuadEdgeMeshPolygonCell.h:107
itk::QuadEdgeMeshPolygonCell::GetIdent
CellIdentifier GetIdent()
Definition: itkQuadEdgeMeshPolygonCell.h:112
Self
AddImageFilter Self
Definition: itkAddImageFilter.h:89
itk::QuadEdgeMeshPolygonCell::GetEdgeRingEntry
QuadEdgeType * GetEdgeRingEntry() const
Definition: itkQuadEdgeMeshPolygonCell.h:120
itk::QuadEdgeMeshPolygonCell::FaceRefType
typename QuadEdgeType::DualOriginRefType FaceRefType
Definition: itkQuadEdgeMeshPolygonCell.h:90
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::QuadEdgeMeshPolygonCell::SetEdgeRingEntry
void SetEdgeRingEntry(QuadEdgeType *entry)
Definition: itkQuadEdgeMeshPolygonCell.h:125
itk::QuadEdgeMeshPolygonCell::GetTopologyId
static constexpr CellGeometryEnum GetTopologyId()
Definition: itkQuadEdgeMeshPolygonCell.h:147
itk::QuadEdgeMeshPolygonCell::PrimalDataType
typename QuadEdgeType::PrimalDataType PrimalDataType
Definition: itkQuadEdgeMeshPolygonCell.h:91
itk::QuadEdgeMeshPolygonCell::GetType
CellGeometryEnum GetType() const override
Definition: itkQuadEdgeMeshPolygonCell.h:140
itk::CommonEnums::CellGeometry
CellGeometry
Definition: itkCommonEnums.h:132
itk::QuadEdgeMeshPolygonCell::Superclass
TCellInterface Superclass
Definition: itkQuadEdgeMeshPolygonCell.h:53
itk::QuadEdgeMeshPolygonCell::CellFeatureCount
typename Superclass::CellFeatureIdentifier CellFeatureCount
Definition: itkQuadEdgeMeshPolygonCell.h:66
itk::QuadEdgeMeshPolygonCell
Definition: itkQuadEdgeMeshPolygonCell.h:39
itk::QuadEdgeMeshPolygonCell::PointIdsBegin
PointIdConstIterator PointIdsBegin() const override
Definition: itkQuadEdgeMeshPolygonCell.h:235
itk::QuadEdgeMeshLineCell
Class that connects the QuadEdgeMesh with the Mesh.
Definition: itkQuadEdgeMeshLineCell.h:41
itk::QuadEdgeMeshPolygonCell::PointIdsEnd
PointIdConstIterator PointIdsEnd() const override
Definition: itkQuadEdgeMeshPolygonCell.h:250
itk::QuadEdgeMeshPolygonCell::PointIdConstIterator
typename CellTraits::PointIdConstIterator PointIdConstIterator
Definition: itkQuadEdgeMeshPolygonCell.h:83
itk::QuadEdgeMeshPolygonCell::PointIdInternalConstIterator
typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator
Definition: itkQuadEdgeMeshPolygonCell.h:85
itk::QuadEdgeMeshPolygonCell::PointIDListType
std::vector< PointIdentifier > PointIDListType
Definition: itkQuadEdgeMeshPolygonCell.h:286
itk::QuadEdgeMeshPolygonCell::GetDimension
unsigned int GetDimension() const override
Definition: itkQuadEdgeMeshPolygonCell.h:153
itk::QuadEdgeMeshPolygonCell::MakePointIds
void MakePointIds() const
Definition: itkQuadEdgeMeshPolygonCell.h:291
itk::QuadEdgeMeshPolygonCell::QEDual
typename QuadEdgeType::DualType QEDual
Definition: itkQuadEdgeMeshPolygonCell.h:93
itk::QuadEdgeMeshPolygonCell::DualDataType
typename QuadEdgeType::DualDataType DualDataType
Definition: itkQuadEdgeMeshPolygonCell.h:92
itk::QuadEdgeMeshPolygonCell::PointIdsEnd
PointIdIterator PointIdsEnd() override
Definition: itkQuadEdgeMeshPolygonCell.h:221
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::QuadEdgeMeshPolygonCell::PointIdIterator
typename CellTraits::PointIdIterator PointIdIterator
Definition: itkQuadEdgeMeshPolygonCell.h:82
itkQuadEdgeMeshLineCell.h
itk::QuadEdgeMeshPolygonCell::MakeCopy
void MakeCopy(CellAutoPointer &cell) const override
Definition: itkQuadEdgeMeshPolygonCell.h:169
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
itk::QuadEdgeMeshPolygonCell::CellTraits
typename Superclass::CellTraits CellTraits
Definition: itkQuadEdgeMeshPolygonCell.h:60
itk::QuadEdgeMeshPolygonCell::EdgeCellListType
std::vector< EdgeCellType * > EdgeCellListType
Definition: itkQuadEdgeMeshPolygonCell.h:79
New
static Pointer New()
itk::QuadEdgeMeshPolygonCell::MultiVisitor
typename CellType::MultiVisitor MultiVisitor
Definition: itkQuadEdgeMeshPolygonCell.h:76
itk::QuadEdgeMeshPolygonCell::PointIdsBegin
PointIdIterator PointIdsBegin() override
Definition: itkQuadEdgeMeshPolygonCell.h:206
itkTriangleCell.h
itk::QuadEdgeMeshPolygonCell::QuadEdgeType
typename CellTraits::QuadEdgeType QuadEdgeType
Definition: itkQuadEdgeMeshPolygonCell.h:88
itk::QuadEdgeMeshPolygonCell::PointIdInternalIterator
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
Definition: itkQuadEdgeMeshPolygonCell.h:84