Orfeo Toolbox  4.0
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 
79  //** */
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();
101 
103  void SetIdent(CellIdentifier cid) { m_Ident = cid; }
104  CellIdentifier GetIdent() { return ( m_Ident ); }
105 
109 
112 
114  virtual void Accept(CellIdentifier cellId, MultiVisitor *mv);
115 
116  virtual CellGeometry GetType() const { return ( Superclass::POLYGON_CELL ); }
117 
119  static int GetTopologyId()
120  {
121  return ( Superclass::POLYGON_CELL );
122  }
123 
124  virtual unsigned int GetDimension() const
125  {
126  return ( Self::CellDimension );
127  }
128 
129  virtual unsigned int GetNumberOfPoints() const;
130 
131  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
132 
133  virtual bool GetBoundaryFeature(int dimension,
134  CellFeatureIdentifier cellId,
135  CellAutoPointer & cell);
136 
138  virtual void MakeCopy(CellAutoPointer & cell) const
139  {
140  const PointIdentifier numberOfPoints = this->GetNumberOfPoints();
141  Self * newPolygonCell = new Self(numberOfPoints);
142 
143  cell.TakeOwnership(newPolygonCell);
144  if ( numberOfPoints )
145  {
146  PointIdentifier i = 0;
147 
150 
151  while( it != end )
152  {
153  newPolygonCell->SetPointId( i, it.Value()->GetOrigin() );
154  ++i;
155  ++it;
156  }
157  }
158  }
159 
161  virtual void SetPointIds(PointIdConstIterator first);
162 
163  virtual void SetPointIds(PointIdConstIterator first,
164  PointIdConstIterator last);
165 
166  virtual void SetPointId(int localId, PointIdentifier pId);
167 
168  virtual PointIdentifier GetPointId(int localId) const;
169 
171  {
172  // NOTE ALEX: should update the array on the fly to make it faster
173  MakePointIds();
174  if ( m_PointIds.size() == 0 )
175  {
176  return ( static_cast< PointIdIterator >( 0 ) );
177  }
178  else
179  {
180  return &*( m_PointIds.begin() );
181  }
182  }
183 
185  {
186  // NOTE ALEX: should update the array on the fly to make it faster
187  if ( m_PointIds.size() == 0 )
188  {
189  return ( static_cast< PointIdIterator >( 0 ) );
190  }
191  else
192  {
193  return &m_PointIds[m_PointIds.size() - 1] + 1;
194  }
195  }
196 
198  {
199  // NOTE ALEX: should update the array on the fly to make it faster
200  MakePointIds();
201  if ( m_PointIds.size() == 0 )
202  {
203  return ( static_cast< PointIdIterator >( 0 ) );
204  }
205  else
206  {
207  return &*( m_PointIds.begin() );
208  }
209  }
210 
212  {
213  // NOTE ALEX: should update the array on the fly to make it faster
214  if ( m_PointIds.size() == 0 )
215  {
216  return ( static_cast< PointIdIterator >( 0 ) );
217  }
218  else
219  {
220  return &m_PointIds[m_PointIds.size() - 1] + 1;
221  }
222  }
223 
226 
229 
231 
233 
235 
237 
239 
240 protected:
241  typedef std::vector< PointIdentifier > PointIDListType;
243 
244 private:
245  QuadEdgeMeshPolygonCell(const Self &); // Not impl.
246  void operator=(const Self &); // Not impl.
247 
248  void MakePointIds() const
249  {
250  m_PointIds.clear();
251 
254 
255  while( it != end )
256  {
257  m_PointIds.push_back( it.Value()->GetOrigin() );
258  ++it;
259  }
260  }
261 
266 
271 
276 };
277 } // end namespace itk
278 
279 #ifndef ITK_MANUAL_INSTANTIATION
281 #endif
282 
283 #endif

Generated at Sat Mar 8 2014 15:24:38 for Orfeo Toolbox with doxygen 1.8.3.1