ITK  4.2.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< class TCellInterface >
38 class ITK_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 public:
93 
95  itkTypeMacro(QuadEdgeMeshPolygonCell, TCellInterface);
96 
100  virtual ~QuadEdgeMeshPolygonCell();
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);
118 
119  virtual CellGeometry GetType() const { return ( Superclass::POLYGON_CELL ); }
120 
122  static int GetTopologyId()
123  {
124  return ( Superclass::POLYGON_CELL );
125  }
126 
127  virtual unsigned int GetDimension() const
128  {
129  return ( Self::CellDimension );
130  }
131 
132  virtual unsigned int GetNumberOfPoints() const;
133 
134  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
135 
136  virtual bool GetBoundaryFeature(int dimension,
137  CellFeatureIdentifier cellId,
138  CellAutoPointer & cell);
139 
141  virtual void MakeCopy(CellAutoPointer & cell) const
142  {
143  const PointIdentifier numberOfPoints = this->GetNumberOfPoints();
144  Self * newPolygonCell = new Self(numberOfPoints);
146 
147  cell.TakeOwnership(newPolygonCell);
148  if ( numberOfPoints )
149  {
150  for ( PointIdentifier i = 0; i < numberOfPoints; i++ )
151  {
152  newPolygonCell->SetPointId( i, this->GetPointId(i) );
153  }
154  }
155  }
156 
158  virtual void SetPointIds(PointIdConstIterator first);
159 
160  virtual void SetPointIds(PointIdConstIterator first,
161  PointIdConstIterator last);
162 
163  virtual void SetPointId(int localId, PointIdentifier pId);
164 
165  virtual PointIdentifier GetPointId(int localId) const;
166 
167  virtual PointIdIterator PointIdsBegin()
168  {
169  // NOTE ALEX: should update the array on the fly to make it faster
170  MakePointIds();
171  if ( m_PointIds.size() == 0 )
172  {
173  return ( static_cast< PointIdIterator >( 0 ) );
174  }
175  else
176  {
177  return &*( m_PointIds.begin() );
178  }
179  }
180 
181  virtual PointIdIterator PointIdsEnd()
182  {
183  // NOTE ALEX: should update the array on the fly to make it faster
184  if ( m_PointIds.size() == 0 )
185  {
186  return ( static_cast< PointIdIterator >( 0 ) );
187  }
188  else
189  {
190  return &m_PointIds[m_PointIds.size() - 1] + 1;
191  }
192  }
193 
194  virtual PointIdConstIterator PointIdsBegin() const
195  {
196  // NOTE ALEX: should update the array on the fly to make it faster
197  MakePointIds();
198  if ( m_PointIds.size() == 0 )
199  {
200  return ( static_cast< PointIdIterator >( 0 ) );
201  }
202  else
203  {
204  return &*( m_PointIds.begin() );
205  }
206  }
207 
208  virtual PointIdConstIterator PointIdsEnd() const
209  {
210  // NOTE ALEX: should update the array on the fly to make it faster
211  if ( m_PointIds.size() == 0 )
212  {
213  return ( static_cast< PointIdIterator >( 0 ) );
214  }
215  else
216  {
217  return &m_PointIds[m_PointIds.size() - 1] + 1;
218  }
219  }
220 
222  virtual void InternalSetPointIds(PointIdInternalConstIterator first);
223 
224  virtual void InternalSetPointIds(PointIdInternalConstIterator first,
225  PointIdInternalConstIterator last);
226 
227  virtual PointIdInternalIterator InternalPointIdsBegin();
228 
229  virtual PointIdInternalIterator InternalPointIdsEnd();
230 
231  virtual PointIdInternalConstIterator InternalGetPointIds() const;
232 
233  virtual PointIdInternalConstIterator InternalPointIdsBegin() const;
234 
235  virtual PointIdInternalConstIterator InternalPointIdsEnd() const;
236 
237 protected:
238  typedef std::vector< PointIdentifier > PointIDListType;
240 private:
241  QuadEdgeMeshPolygonCell(const Self &); // Not impl.
242  void operator=(const Self &); // Not impl.
243 
244  void MakePointIds() const
245  {
246  if ( !this->GetNumberOfPoints() )
247  {
248  return;
249  }
250 
251  // NOTE ALEX: very inefficient way of doing it ...
252  // you want to support old API, you pay for it.
253  m_PointIds.clear();
254  for ( PointIdentifier i = 0; i < this->GetNumberOfPoints(); i++ )
255  {
256  m_PointIds.push_back( GetPointId(i) );
257  }
258  }
259 
264 
269 
274 };
275 } // end namespace itk
276 
277 #ifndef ITK_MANUAL_INSTANTIATION
278 #include "itkQuadEdgeMeshPolygonCell.hxx"
279 #endif
280 
281 #endif
282