ITK  4.13.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:
42  // itkCellCommonTypedefs
46  typedef Self * RawPointer;
47  typedef const Self * ConstRawPointer;
48 
49  // itkCellInheritedTypedefs
50  typedef TCellInterface Superclass;
51  typedef typename Superclass::PixelType PixelType;
52  typedef typename Superclass::CellType CellType;
53  typedef typename Superclass::CellAutoPointer CellAutoPointer;
54  typedef typename Superclass::CellConstAutoPointer CellConstAutoPointer;
55  typedef typename Superclass::CellRawPointer CellRawPointer;
56  typedef typename Superclass::CellConstRawPointer CellConstRawPointer;
57  typedef typename Superclass::CellTraits CellTraits;
58  typedef typename Superclass::CoordRepType CoordRepType;
59  typedef typename Superclass::InterpolationWeightType InterpolationWeightType;
60  typedef typename Superclass::PointIdentifier PointIdentifier;
61  typedef typename Superclass::CellIdentifier CellIdentifier;
62  typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier;
63  typedef typename Superclass::CellFeatureIdentifier CellFeatureCount;
64  typedef typename Superclass::PointType PointType;
65  typedef typename Superclass::PointsContainer PointsContainer;
66  typedef typename Superclass::UsingCellsContainer UsingCellsContainer;
67  typedef typename Superclass::CellGeometry CellGeometry;
68  typedef typename Superclass::ParametricCoordArrayType ParametricCoordArrayType;
69  typedef typename Superclass::ShapeFunctionsArrayType ShapeFunctionsArrayType;
70  itkStaticConstMacro(PointDimension, unsigned int, Superclass::PointDimension);
71  itkStaticConstMacro(CellDimension, unsigned int, 2);
72 
74  typedef typename CellType::MultiVisitor MultiVisitor;
75 
77  typedef std::vector< EdgeCellType * > EdgeCellListType;
78 
80  typedef typename CellTraits::PointIdIterator PointIdIterator;
81  typedef typename CellTraits::PointIdConstIterator PointIdConstIterator;
82  typedef typename CellTraits::PointIdInternalIterator PointIdInternalIterator;
83  typedef typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator;
84 
86  typedef typename CellTraits::QuadEdgeType QuadEdgeType;
87  typedef typename QuadEdgeType::OriginRefType VertexRefType;
88  typedef typename QuadEdgeType::DualOriginRefType FaceRefType;
89  typedef typename QuadEdgeType::PrimalDataType PrimalDataType;
90  typedef typename QuadEdgeType::DualDataType DualDataType;
91  typedef typename QuadEdgeType::DualType QEDual;
92 
93 public:
95  itkTypeMacro(QuadEdgeMeshPolygonCell, TCellInterface);
96 
100  virtual ~QuadEdgeMeshPolygonCell() ITK_OVERRIDE;
102 
104  void SetIdent(CellIdentifier cid) { m_Ident = cid; }
105  CellIdentifier GetIdent() { return ( m_Ident ); }
107 
109  QuadEdgeType * GetEdgeRingEntry() const { return ( m_EdgeRingEntry ); }
110  void SetEdgeRingEntry(QuadEdgeType *entry) { m_EdgeRingEntry = entry; }
112 
114  SelfAutoPointer New();
115 
117  virtual void Accept(CellIdentifier cellId, MultiVisitor *mv) ITK_OVERRIDE;
118 
119  virtual CellGeometry GetType() const ITK_OVERRIDE { return ( Superclass::POLYGON_CELL ); }
120 
122  static int GetTopologyId()
123  {
124  return ( Superclass::POLYGON_CELL );
125  }
126 
127  virtual unsigned int GetDimension() const ITK_OVERRIDE
128  {
129  return ( Self::CellDimension );
130  }
131 
132  virtual unsigned int GetNumberOfPoints() const ITK_OVERRIDE;
133 
134  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const ITK_OVERRIDE;
135 
136  virtual bool GetBoundaryFeature(int dimension,
137  CellFeatureIdentifier cellId,
138  CellAutoPointer & cell) ITK_OVERRIDE;
139 
141  virtual void MakeCopy(CellAutoPointer & cell) const ITK_OVERRIDE
142  {
143  const PointIdentifier numberOfPoints = this->GetNumberOfPoints();
144  Self * newPolygonCell = new Self(numberOfPoints);
146 
147  cell.TakeOwnership(newPolygonCell);
148  if ( numberOfPoints )
149  {
150  PointIdentifier i = 0;
151 
152  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
153  PointIdInternalConstIterator end = this->InternalPointIdsEnd();
154 
155  while( it != end )
156  {
157  newPolygonCell->SetPointId( i, it.Value()->GetOrigin() );
158  ++i;
159  ++it;
160  }
161  }
162  }
163 
165  virtual void SetPointIds(PointIdConstIterator first) ITK_OVERRIDE;
166 
167  virtual void SetPointIds(PointIdConstIterator first,
168  PointIdConstIterator last) ITK_OVERRIDE;
169 
170  virtual void SetPointId(int localId, PointIdentifier pId) ITK_OVERRIDE;
171 
172  virtual PointIdentifier GetPointId(int localId) const;
173 
174  virtual PointIdIterator PointIdsBegin() ITK_OVERRIDE
175  {
176  // NOTE ALEX: should update the array on the fly to make it faster
177  MakePointIds();
178  if ( m_PointIds.size() == 0 )
179  {
180  return ( static_cast< PointIdIterator >( ITK_NULLPTR ) );
181  }
182  else
183  {
184  return &*( m_PointIds.begin() );
185  }
186  }
187 
188  virtual PointIdIterator PointIdsEnd() ITK_OVERRIDE
189  {
190  // NOTE ALEX: should update the array on the fly to make it faster
191  if ( m_PointIds.size() == 0 )
192  {
193  return ( static_cast< PointIdIterator >( ITK_NULLPTR ) );
194  }
195  else
196  {
197  return &m_PointIds[m_PointIds.size() - 1] + 1;
198  }
199  }
200 
201  virtual PointIdConstIterator PointIdsBegin() const ITK_OVERRIDE
202  {
203  // NOTE ALEX: should update the array on the fly to make it faster
204  MakePointIds();
205  if ( m_PointIds.size() == 0 )
206  {
207  return ( static_cast< PointIdIterator >( ITK_NULLPTR ) );
208  }
209  else
210  {
211  return &*( m_PointIds.begin() );
212  }
213  }
214 
215  virtual PointIdConstIterator PointIdsEnd() const ITK_OVERRIDE
216  {
217  // NOTE ALEX: should update the array on the fly to make it faster
218  if ( m_PointIds.size() == 0 )
219  {
220  return ( static_cast< PointIdIterator >( ITK_NULLPTR ) );
221  }
222  else
223  {
224  return &m_PointIds[m_PointIds.size() - 1] + 1;
225  }
226  }
227 
229  virtual void InternalSetPointIds(PointIdInternalConstIterator first);
230 
231  virtual void InternalSetPointIds(PointIdInternalConstIterator first,
232  PointIdInternalConstIterator last);
233 
234  virtual PointIdInternalIterator InternalPointIdsBegin();
235 
236  virtual PointIdInternalIterator InternalPointIdsEnd();
237 
238  virtual PointIdInternalConstIterator InternalGetPointIds() const;
239 
240  virtual PointIdInternalConstIterator InternalPointIdsBegin() const;
241 
242  virtual PointIdInternalConstIterator InternalPointIdsEnd() const;
243 
244 protected:
245  typedef std::vector< PointIdentifier > PointIDListType;
247 
248 private:
249  QuadEdgeMeshPolygonCell(const Self &); // Not impl.
250  void operator=(const Self &); // Not impl.
251 
252  void MakePointIds() const
253  {
254  m_PointIds.clear();
255 
256  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
257  PointIdInternalConstIterator end = this->InternalPointIdsEnd();
258 
259  while( it != end )
260  {
261  m_PointIds.push_back( it.Value()->GetOrigin() );
262  ++it;
263  }
264  }
265 
270 
275 
280 };
281 } // end namespace itk
282 
283 #ifndef ITK_MANUAL_INSTANTIATION
284 #include "itkQuadEdgeMeshPolygonCell.hxx"
285 #endif
286 
287 #endif
CellTraits::QuadEdgeType QuadEdgeType
QuadEdgeType::OriginRefType VertexRefType
virtual PointIdConstIterator PointIdsBegin() const override
CellTraits::PointIdInternalIterator PointIdInternalIterator
QuadEdgeMeshLineCell< CellType > EdgeCellType
Superclass::PointsContainer PointsContainer
std::vector< EdgeCellType * > EdgeCellListType
virtual PointIdIterator PointIdsBegin() override
Superclass::CellConstAutoPointer CellConstAutoPointer
virtual void SetPointId(int localId, PointIdentifier pId) override
QuadEdgeType * GetEdgeRingEntry() const
virtual CellGeometry GetType() const override
void SetEdgeRingEntry(QuadEdgeType *entry)
Superclass::CellFeatureIdentifier CellFeatureCount
Superclass::ParametricCoordArrayType ParametricCoordArrayType
QuadEdgeType::PrimalDataType PrimalDataType
Superclass::CellConstRawPointer CellConstRawPointer
Superclass::CellIdentifier CellIdentifier
Superclass::PointIdentifier PointIdentifier
CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator
AutoPointer< const Self > ConstSelfAutoPointer
Superclass::CoordRepType CoordRepType
Superclass::CellFeatureIdentifier CellFeatureIdentifier
std::vector< PointIdentifier > PointIDListType
Superclass::CellRawPointer CellRawPointer
Superclass::UsingCellsContainer UsingCellsContainer
QuadEdgeType::DualOriginRefType FaceRefType
virtual unsigned int GetDimension() const override
Superclass::InterpolationWeightType InterpolationWeightType
CellTraits::PointIdIterator PointIdIterator
CellTraits::PointIdConstIterator PointIdConstIterator
Implements an Automatic Pointer to an object.
QuadEdgeType::DualDataType DualDataType
Superclass::CellAutoPointer CellAutoPointer
Superclass::ShapeFunctionsArrayType ShapeFunctionsArrayType
static ITK_CONSTEXPR_VAR double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:56
virtual PointIdConstIterator PointIdsEnd() const override
virtual PointIdIterator PointIdsEnd() override
Superclass::CellGeometry CellGeometry
Class that connects the QuadEdgeMesh with the Mesh.