Orfeo Toolbox  3.16
itkQuadEdgeMeshPolygonCell.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkQuadEdgeMeshPolygonCell.h,v $
5  Language: C++
6  Date: $Date: 2008-10-03 22:05:05 $
7  Version: $Revision: 1.22 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkQuadEdgeMeshPolygonCell_h
19 #define __itkQuadEdgeMeshPolygonCell_h
20 
21 namespace itk
22 {
23 
35 template< class TCellInterface >
36 class QuadEdgeMeshPolygonCell : public TCellInterface
37 {
38 public:
40  // itkCellCommonTypedefs
44  typedef Self* RawPointer;
45  typedef const Self* ConstRawPointer;
46 
47  // itkCellInheritedTypedefs
48  typedef TCellInterface Superclass;
49  typedef typename Superclass::PixelType PixelType;
50  typedef typename Superclass::CellType CellType;
51  typedef typename Superclass::CellAutoPointer CellAutoPointer;
52  typedef typename Superclass::CellConstAutoPointer CellConstAutoPointer;
53  typedef typename Superclass::CellRawPointer CellRawPointer;
54  typedef typename Superclass::CellConstRawPointer CellConstRawPointer;
55  typedef typename Superclass::CellTraits CellTraits;
56  typedef typename Superclass::CoordRepType CoordRepType;
57  typedef typename Superclass::InterpolationWeightType InterpolationWeightType;
58  typedef typename Superclass::PointIdentifier PointIdentifier;
59  typedef typename Superclass::CellIdentifier CellIdentifier;
60  typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier;
61  typedef typename Superclass::CellFeatureIdentifier CellFeatureCount;
62  typedef typename Superclass::PointType PointType;
63  typedef typename Superclass::PointsContainer PointsContainer;
64  typedef typename Superclass::UsingCellsContainer UsingCellsContainer;
65  typedef typename Superclass::CellGeometry CellGeometry;
66  typedef typename Superclass::ParametricCoordArrayType ParametricCoordArrayType;
67  typedef typename Superclass::ShapeFunctionsArrayType ShapeFunctionsArrayType;
68  itkStaticConstMacro( PointDimension, unsigned int, Superclass::PointDimension );
69  itkStaticConstMacro( CellDimension, unsigned int, 2 );
70 
72  typedef typename CellType::MultiVisitor MultiVisitor;
73 
75  typedef std::vector< EdgeCellType* > EdgeCellListType;
76 
77  //** */
78  typedef typename CellTraits::PointIdIterator PointIdIterator;
79  typedef typename CellTraits::PointIdConstIterator PointIdConstIterator;
80  typedef typename CellTraits::PointIdInternalIterator PointIdInternalIterator;
81  typedef typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator;
82 
84  typedef typename CellTraits::QuadEdgeType QuadEdgeType;
85  typedef typename QuadEdgeType::OriginRefType VertexRefType;
86  typedef typename QuadEdgeType::DualOriginRefType FaceRefType;
87  typedef typename QuadEdgeType::PrimalDataType PrimalDataType;
88  typedef typename QuadEdgeType::DualDataType DualDataType;
89  typedef typename QuadEdgeType::DualType QEDual;
90 
91 public:
93  itkTypeMacro( QuadEdgeMeshPolygonCell, TCellInterface );
94 
98  virtual ~QuadEdgeMeshPolygonCell();
99 
101  void SetIdent( CellIdentifier cid ) { m_Ident = cid; }
102  CellIdentifier GetIdent() { return( m_Ident ); }
103 
106  void SetEdgeRingEntry( QuadEdgeType* entry ) { m_EdgeRingEntry = entry; }
107 
110 
112  virtual void Accept( unsigned long cellId, MultiVisitor* mv );
113  virtual CellGeometry GetType() const { return( Superclass::POLYGON_CELL );}
114 
116  static int GetTopologyId()
117  {
118  return( Superclass::POLYGON_CELL );
119  }
120  virtual unsigned int GetDimension() const
121  {
122  return( Self::CellDimension );
123  }
124  virtual unsigned int GetNumberOfPoints() const;
125  virtual CellFeatureCount GetNumberOfBoundaryFeatures( int dimension ) const;
126  virtual bool GetBoundaryFeature( int dimension,
127  CellFeatureIdentifier cellId,
128  CellAutoPointer& cell );
129 
131  virtual void MakeCopy( CellAutoPointer& cell ) const
132  {
133  const unsigned long numberOfPoints = this->GetNumberOfPoints();
134  Self * newPolygonCell = new Self( numberOfPoints );
135  cell.TakeOwnership( newPolygonCell );
136  if ( numberOfPoints )
137  {
138  for( unsigned long i = 0; i < numberOfPoints; i++ )
139  {
140  newPolygonCell->SetPointId( i, this->GetPointId( i ) );
141  }
142  }
143  }
144 
145 
147  virtual void SetPointIds( PointIdConstIterator first );
148  virtual void SetPointIds( PointIdConstIterator first,
149  PointIdConstIterator last );
150  virtual void SetPointId( int localId, PointIdentifier pId );
151 
152  virtual PointIdentifier GetPointId( int localId ) const;
153 
155  {
156  // NOTE ALEX: should update the array on the fly to make it faster
157  MakePointIds();
158  if (m_PointIds.size() == 0)
159  {
160  return (static_cast<PointIdIterator>(0));
161  }
162  else
163  {
164  return &*(m_PointIds.begin());
165  }
166  }
167 
169  {
170  // NOTE ALEX: should update the array on the fly to make it faster
171  if (m_PointIds.size() == 0)
172  {
173  return (static_cast<PointIdIterator>(0));
174  }
175  else
176  {
177  return &m_PointIds[m_PointIds.size()-1] + 1;
178  }
179  }
180 
182  {
183  // NOTE ALEX: should update the array on the fly to make it faster
184  MakePointIds();
185  if (m_PointIds.size() == 0)
186  {
187  return (static_cast<PointIdIterator>(0));
188  }
189  else
190  {
191  return &*(m_PointIds.begin());
192  }
193  }
194 
196  {
197  // NOTE ALEX: should update the array on the fly to make it faster
198  if (m_PointIds.size() == 0)
199  {
200  return (static_cast<PointIdIterator>(0));
201  }
202  else
203  {
204  return &m_PointIds[m_PointIds.size()-1] + 1;
205  }
206  }
207 
212 
215 
219 
220 protected:
221  typedef std::vector<PointIdentifier> PointIDListType;
223 
224 private:
225  QuadEdgeMeshPolygonCell( const Self& ); // Not impl.
226  void operator=( const Self& ); // Not impl.
227 
228  void MakePointIds() const
229  {
230  if( !this->GetNumberOfPoints( ) )
231  {
232  return;
233  }
234 
235  // NOTE ALEX: very inefficient way of doing it ...
236  // you wanna support old API, you pay for it.
237  m_PointIds.clear();
238  for( PointIdentifier i = 0; i < this->GetNumberOfPoints( ); i++ )
239  {
240  m_PointIds.push_back( GetPointId( i ) );
241  }
242  }
243 
248 
253 
258 
259 };
260 
261 } // end namespace itk
262 
263 #ifndef ITK_MANUAL_INSTANTIATION
265 #endif
266 
267 #endif

Generated at Sun Feb 3 2013 00:00:58 for Orfeo Toolbox with doxygen 1.8.1.1