ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshPolygonCell.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 {
37 template< typename TCellInterface >
38 class ITK_TEMPLATE_EXPORT QuadEdgeMeshPolygonCell:public TCellInterface
39 {
40 public:
41  ITK_DISALLOW_COPY_AND_ASSIGN(QuadEdgeMeshPolygonCell);
42 
44  // itkCellCommonTypedefs
48  using RawPointer = Self *;
49  using ConstRawPointer = const Self *;
50 
51  // itkCellInheritedTypedefs
52  using Superclass = TCellInterface;
53  using PixelType = typename Superclass::PixelType;
54  using CellType = typename Superclass::CellType;
55  using CellAutoPointer = typename Superclass::CellAutoPointer;
56  using CellConstAutoPointer = typename Superclass::CellConstAutoPointer;
57  using CellRawPointer = typename Superclass::CellRawPointer;
58  using CellConstRawPointer = typename Superclass::CellConstRawPointer;
59  using CellTraits = typename Superclass::CellTraits;
60  using CoordRepType = typename Superclass::CoordRepType;
61  using InterpolationWeightType = typename Superclass::InterpolationWeightType;
62  using PointIdentifier = typename Superclass::PointIdentifier;
63  using CellIdentifier = typename Superclass::CellIdentifier;
64  using CellFeatureIdentifier = typename Superclass::CellFeatureIdentifier;
65  using CellFeatureCount = typename Superclass::CellFeatureIdentifier;
66  using PointType = typename Superclass::PointType;
67  using PointsContainer = typename Superclass::PointsContainer;
68  using UsingCellsContainer = typename Superclass::UsingCellsContainer;
69  using CellGeometry = typename Superclass::CellGeometry;
70  using ParametricCoordArrayType = typename Superclass::ParametricCoordArrayType;
71  using ShapeFunctionsArrayType = 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  itkTypeMacro(QuadEdgeMeshPolygonCell, TCellInterface);
98 
102  ~QuadEdgeMeshPolygonCell() override;
104 
106  void SetIdent(CellIdentifier cid) { m_Ident = cid; }
107  CellIdentifier GetIdent() { return ( m_Ident ); }
109 
111  QuadEdgeType * GetEdgeRingEntry() const { return ( m_EdgeRingEntry ); }
112  void SetEdgeRingEntry(QuadEdgeType *entry) { m_EdgeRingEntry = entry; }
114 
116  SelfAutoPointer New();
117 
119  void Accept(CellIdentifier cellId, MultiVisitor *mv) override;
120 
121  CellGeometry GetType() const override { return ( Superclass::POLYGON_CELL ); }
122 
124  static int GetTopologyId()
125  {
126  return ( Superclass::POLYGON_CELL );
127  }
128 
129  unsigned int GetDimension() const override
130  {
131  return ( Self::CellDimension );
132  }
133 
134  unsigned int GetNumberOfPoints() const override;
135 
136  CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override;
137 
138  bool GetBoundaryFeature(int dimension,
139  CellFeatureIdentifier cellId,
140  CellAutoPointer & cell) override;
141 
143  void MakeCopy(CellAutoPointer & cell) const override
144  {
145  const PointIdentifier numberOfPoints = this->GetNumberOfPoints();
146  auto * newPolygonCell = new Self(numberOfPoints);
148 
149  cell.TakeOwnership(newPolygonCell);
150  if ( numberOfPoints )
151  {
152  PointIdentifier i = 0;
153 
154  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
155  PointIdInternalConstIterator end = this->InternalPointIdsEnd();
156 
157  while( it != end )
158  {
159  newPolygonCell->SetPointId( i, it.Value()->GetOrigin() );
160  ++i;
161  ++it;
162  }
163  }
164  }
165 
167  void SetPointIds(PointIdConstIterator first) override;
168 
169  void SetPointIds(PointIdConstIterator first,
170  PointIdConstIterator last) override;
171 
172  void SetPointId(int localId, PointIdentifier pId) override;
173 
174  virtual PointIdentifier GetPointId(int localId) const;
175 
177  {
178  // NOTE ALEX: should update the array on the fly to make it faster
179  MakePointIds();
180  if ( m_PointIds.empty() )
181  {
182  return ( static_cast< PointIdIterator >( nullptr ) );
183  }
184  else
185  {
186  return &*( m_PointIds.begin() );
187  }
188  }
189 
191  {
192  // NOTE ALEX: should update the array on the fly to make it faster
193  if ( m_PointIds.empty() )
194  {
195  return ( static_cast< PointIdIterator >( nullptr ) );
196  }
197  else
198  {
199  return &m_PointIds[m_PointIds.size() - 1] + 1;
200  }
201  }
202 
204  {
205  // NOTE ALEX: should update the array on the fly to make it faster
206  MakePointIds();
207  if ( m_PointIds.empty() )
208  {
209  return ( static_cast< PointIdIterator >( nullptr ) );
210  }
211  else
212  {
213  return &*( m_PointIds.begin() );
214  }
215  }
216 
218  {
219  // NOTE ALEX: should update the array on the fly to make it faster
220  if ( m_PointIds.empty() )
221  {
222  return ( static_cast< PointIdIterator >( nullptr ) );
223  }
224  else
225  {
226  return &m_PointIds[m_PointIds.size() - 1] + 1;
227  }
228  }
229 
231  virtual void InternalSetPointIds(PointIdInternalConstIterator first);
232 
233  virtual void InternalSetPointIds(PointIdInternalConstIterator first,
234  PointIdInternalConstIterator last);
235 
236  virtual PointIdInternalIterator InternalPointIdsBegin();
237 
238  virtual PointIdInternalIterator InternalPointIdsEnd();
239 
240  virtual PointIdInternalConstIterator InternalGetPointIds() const;
241 
242  virtual PointIdInternalConstIterator InternalPointIdsBegin() const;
243 
244  virtual PointIdInternalConstIterator InternalPointIdsEnd() const;
245 
246 protected:
247  using PointIDListType = std::vector< PointIdentifier >;
249 
250 private:
251  void MakePointIds() const
252  {
253  m_PointIds.clear();
254 
255  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
256  PointIdInternalConstIterator end = this->InternalPointIdsEnd();
257 
258  while( it != end )
259  {
260  m_PointIds.push_back( it.Value()->GetOrigin() );
261  ++it;
262  }
263  }
264 
269 
274 
279 };
280 } // end namespace itk
281 
282 #ifndef ITK_MANUAL_INSTANTIATION
283 #include "itkQuadEdgeMeshPolygonCell.hxx"
284 #endif
285 
286 #endif
typename CellTraits::PointIdConstIterator PointIdConstIterator
typename Superclass::CellIdentifier CellIdentifier
typename Superclass::CoordRepType CoordRepType
typename Superclass::InterpolationWeightType InterpolationWeightType
PointIdIterator PointIdsEnd() override
typename CellTraits::QuadEdgeType QuadEdgeType
typename Superclass::CellRawPointer CellRawPointer
typename Superclass::CellConstAutoPointer CellConstAutoPointer
typename QuadEdgeType::DualOriginRefType FaceRefType
typename Superclass::ShapeFunctionsArrayType ShapeFunctionsArrayType
typename CellTraits::PointIdInternalIterator PointIdInternalIterator
QuadEdgeType * GetEdgeRingEntry() const
typename QuadEdgeType::DualDataType DualDataType
typename Superclass::CellGeometry CellGeometry
typename Superclass::UsingCellsContainer UsingCellsContainer
void MakeCopy(CellAutoPointer &cell) const override
void SetEdgeRingEntry(QuadEdgeType *entry)
unsigned int GetDimension() const override
typename Superclass::CellFeatureIdentifier CellFeatureCount
typename Superclass::ParametricCoordArrayType ParametricCoordArrayType
typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator
typename Superclass::CellType CellType
PointIdConstIterator PointIdsBegin() const override
typename QuadEdgeType::PrimalDataType PrimalDataType
CellGeometry GetType() const override
typename Superclass::PointsContainer PointsContainer
typename CellType::MultiVisitor MultiVisitor
typename Superclass::CellAutoPointer CellAutoPointer
std::vector< PointIdentifier > PointIDListType
typename CellTraits::PointIdIterator PointIdIterator
typename QuadEdgeType::DualType QEDual
typename Superclass::PointType PointType
typename Superclass::PixelType PixelType
Implements an Automatic Pointer to an object.
static constexpr double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:53
PointIdConstIterator PointIdsEnd() const override
typename Superclass::CellFeatureIdentifier CellFeatureIdentifier
typename Superclass::PointIdentifier PointIdentifier
std::vector< EdgeCellType * > EdgeCellListType
typename QuadEdgeType::OriginRefType VertexRefType
typename Superclass::CellTraits CellTraits
Class that connects the QuadEdgeMesh with the Mesh.
typename Superclass::CellConstRawPointer CellConstRawPointer
PointIdIterator PointIdsBegin() override