ITK  4.8.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 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();
102 
104  void SetIdent(CellIdentifier cid) { m_Ident = cid; }
105  CellIdentifier GetIdent() { return ( m_Ident ); }
107 
112 
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 
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 
230 
233 
235 
237 
239 
241 
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 
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
virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override
QuadEdgeMeshLineCell< CellType > EdgeCellType
Superclass::PointsContainer PointsContainer
virtual void InternalSetPointIds(PointIdInternalConstIterator first)
std::vector< EdgeCellType * > EdgeCellListType
virtual PointIdIterator PointIdsBegin() override
Superclass::CellConstAutoPointer CellConstAutoPointer
static const unsigned int PointDimension
virtual void SetPointId(int localId, PointIdentifier pId) override
static const double e
The base of the natural logarithm or Euler&#39;s number
Definition: itkMath.h:45
QuadEdgeType * GetEdgeRingEntry() const
QuadEdgeMeshPolygonCell(PointIdentifier nPoints=0)
virtual void MakeCopy(CellAutoPointer &cell) const override
virtual CellGeometry GetType() const override
void SetEdgeRingEntry(QuadEdgeType *entry)
Superclass::CellFeatureIdentifier CellFeatureCount
virtual void SetPointIds(PointIdConstIterator first) override
Superclass::ParametricCoordArrayType ParametricCoordArrayType
QuadEdgeType::PrimalDataType PrimalDataType
Superclass::CellConstRawPointer CellConstRawPointer
Superclass::CellIdentifier CellIdentifier
static const unsigned int CellDimension
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
virtual void Accept(CellIdentifier cellId, MultiVisitor *mv) override
QuadEdgeType::DualOriginRefType FaceRefType
virtual unsigned int GetDimension() const override
virtual unsigned int GetNumberOfPoints() const override
Superclass::InterpolationWeightType InterpolationWeightType
CellTraits::PointIdIterator PointIdIterator
virtual PointIdentifier GetPointId(int localId) const
CellTraits::PointIdConstIterator PointIdConstIterator
Implements an Automatic Pointer to an object.
QuadEdgeType::DualDataType DualDataType
virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier cellId, CellAutoPointer &cell) override
virtual PointIdInternalIterator InternalPointIdsBegin()
Superclass::CellAutoPointer CellAutoPointer
Superclass::ShapeFunctionsArrayType ShapeFunctionsArrayType
void operator=(const Self &)
virtual PointIdConstIterator PointIdsEnd() const override
virtual PointIdInternalConstIterator InternalGetPointIds() const
virtual PointIdIterator PointIdsEnd() override
Superclass::CellGeometry CellGeometry
Class that connects the QuadEdgeMesh with the Mesh.
virtual PointIdInternalIterator InternalPointIdsEnd()