Orfeo Toolbox  3.16
itkQuadEdgeMeshPolygonCell.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkQuadEdgeMeshPolygonCell.txx,v $
5  Language: C++
6  Date: $Date: 2008-01-11 18:30:38 $
7  Version: $Revision: 1.14 $
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_txx
19 #define __itkQuadEdgeMeshPolygonCell_txx
20 
22 
23 namespace itk
24 {
25 // ---------------------------------------------------------------------
26 template< class TCellInterface >
29 {
30  this->m_Ident = 0;
31 
32  // Create entry point
33  EdgeCellType* edge = new EdgeCellType;
34  m_EdgeCellList.push_back( edge );
35  m_EdgeRingEntry = edge->GetQEGeom( );
36 
37  // Create the rest
38  QuadEdgeType* last = m_EdgeRingEntry;
39  for( PointIdentifier i = 1; i < nPoints; i++ )
40  {
41  edge = new EdgeCellType( );
42  m_EdgeCellList.push_back( edge );
43  QuadEdgeType* edgeGeom = edge->GetQEGeom( );
44 
45  edgeGeom->Splice( last->GetSym() );
46  last = edgeGeom;
47  }
48 
49  // Last topological connection, i.e., close the face
50  m_EdgeRingEntry->Splice( last->GetSym() );
51 
52  //MakePointIds( );
53 
54 }
55 
56 // ---------------------------------------------------------------------
57 template< class TCellInterface >
60 {
61  this->m_Ident = 0;
62  this->m_EdgeRingEntry = e;
63 
64  //MakePointIds( );
65 }
66 
67 // ---------------------------------------------------------------------
68 template< class TCellInterface >
71 {
72  // this disconnect this cell from the
73  // QuadEdgeMesh container if there was any.
74  // poping this cell from the container is supposed to
75  // have been done beforehand.
76  this->m_Ident = 0;
77 
78  // first case, the polygon was created directly
79  // just delete the edges in the edge list
80  // the edgecell destructor should take care of the QuadEdges
81  while( !m_EdgeCellList.empty( ) )
82  {
83  EdgeCellType* edge = m_EdgeCellList.back( );
84  m_EdgeCellList.pop_back( );
85  delete edge;
86  }
87 
88  // second case, the polygon cell was created by
89  // QuadEdgeMesh::AddFace( ) and the QuadEdgeMesh
90  // should take care of everything.
91  // We could iterate around the face to check if all
92  // QuadEdges have now IsLeftSet( ) = false.
93  //
94  // TO BE DONE.
95 
96 }
97 
98 
99 // ---------------------------------------------------------------------
100 template< class TCellInterface >
104 {
105  SelfAutoPointer ptr( new Self );
106  ptr.TakeOwnership();
107  return( ptr );
108 }
109 
110 // ---------------------------------------------------------------------
111 template< class TCellInterface >
113 ::Accept( unsigned long cellId, MultiVisitor* mv )
114 {
116  typename IntVis::Pointer v = mv->GetVisitor( this->GetType() );
117  if( v )
118  {
119  v->VisitFromCell( cellId, this );
120  }
121 }
122 
123 // ---------------------------------------------------------------------
124 template< class TCellInterface >
127 {
128  // The constructor creates one edge by default
129  unsigned int n = 0;
130  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
131  while( it != this->InternalPointIdsEnd() )
132  {
133  it++;
134  n++;
135  }
136  // it's impossible to get n < 3 except the empty case
137  if( n > 2 )
138  {
139  return n;
140  }
141  else
142  {
143  return 0;
144  }
145 }
146 
147 // ---------------------------------------------------------------------
148 template< class TCellInterface >
151 ::GetNumberOfBoundaryFeatures( int dimension ) const
152 {
153  switch (dimension)
154  {
155  case 0: return( this->GetNumberOfPoints() );
156  case 1: return( this->GetNumberOfPoints() );
157  default: return( 0 );
158  }
159 }
160 
161 // ---------------------------------------------------------------------
162 template< class TCellInterface >
165  CellAutoPointer& cell )
166 {
168  (void)dimension;
169  (void)cellId;
170  (void)cell;
171  return( false );
172 }
173 
174 // ---------------------------------------------------------------------
175 template< class TCellInterface >
176 void
179 {
180  if( this->GetNumberOfPoints( ) > 2 )
181  {
182  PointIdConstIterator i2 = first;
183  PointIdInternalIterator i1 = this->InternalPointIdsBegin();
184  while( i1 != this->InternalPointIdsEnd() )
185  {
186  i1.Value()->SetOrigin( *i2 );
187  i1++;
188  i2++;
189  }
190  }
191 }
192 
193 // ---------------------------------------------------------------------
194 template< class TCellInterface >
195 void
198 {
199  if( this->GetNumberOfPoints( ) > 2 )
200  {
201  PointIdInternalConstIterator i2 = first;
202  PointIdInternalIterator i1 = this->InternalPointIdsBegin();
203  while( i1 != this->InternalPointIdsEnd() )
204  {
205  i1.Value()->SetOrigin( *i2 );
206  i1++;
207  i2++;
208  }
209  }
210 }
211 
212 // ---------------------------------------------------------------------
213 template< class TCellInterface >
216  PointIdConstIterator last )
217 {
218  PointIdInternalIterator i1 = this->InternalPointIdsBegin();
219  PointIdConstIterator i2 = first;
220  while( i1 != this->InternalPointIdsEnd() && i2 != last )
221  {
222  i1.Value()->SetOrigin( *i2 );
223  i1++;
224  i2++;
225  }
226 }
227 
228 // ---------------------------------------------------------------------
229 template< class TCellInterface >
233 {
234  PointIdInternalIterator i1 = this->InternalPointIdsBegin();
235  PointIdInternalConstIterator i2 = first;
236  while( i1 != this->InternalPointIdsEnd() && i2 != last )
237  {
238  i1.Value()->SetOrigin( *i2 );
239  i1++;
240  i2++;
241  }
242 }
243 
244 // ---------------------------------------------------------------------
245 template< class TCellInterface >
247 ::SetPointId( int localId, PointIdentifier pId )
248 {
249  int n = 0;
250  PointIdInternalIterator it = this->InternalPointIdsBegin();
251  while( it != this->InternalPointIdsEnd() && n <= localId )
252  {
253  if( n == localId )
254  {
255  it.Value()->SetOrigin( pId );
256  it.Value()->GetOnext()->SetOrigin( pId );
257  }
258  it++;
259  n++;
260  }
261 }
262 
263 // ---------------------------------------------------------------------
264 template< class TCellInterface >
267 ::GetPointId( int localId ) const
268 {
269  int n = 0;
270  PointIdInternalConstIterator it = this->InternalPointIdsBegin();
271  while( it != this->InternalPointIdsEnd() && n <= localId )
272  {
273  if( n == localId )
274  {
275  return( it.Value()->GetOrigin( ) );
276  }
277  it++;
278  n++;
279  }
280  return( PointIdentifier( -1 ) );
281 }
282 
283 // ---------------------------------------------------------------------
284 template< class TCellInterface >
288 {
289  return m_EdgeRingEntry->BeginGeomLnext();
290 }
291 
292 // ---------------------------------------------------------------------
293 template< class TCellInterface >
297 {
298  return m_EdgeRingEntry->EndGeomLnext();
299 }
300 
301 // ---------------------------------------------------------------------
302 template< class TCellInterface >
306 {
307  const QuadEdgeType* edge = const_cast< QuadEdgeType* >( m_EdgeRingEntry );
308  PointIdInternalConstIterator iterator( edge->BeginGeomLnext() );
309  return iterator;
310 }
311 
312 // ---------------------------------------------------------------------
313 template< class TCellInterface >
317 {
318  const QuadEdgeType* edge = const_cast< QuadEdgeType* >( m_EdgeRingEntry );
319  PointIdInternalConstIterator iterator( edge->BeginGeomLnext() );
320  return iterator;
321 }
322 
323 // ---------------------------------------------------------------------
324 template< class TCellInterface >
328 {
329  const QuadEdgeType * edge = const_cast< const QuadEdgeType* >( m_EdgeRingEntry );
330  PointIdInternalConstIterator iterator = edge->EndGeomLnext();
331  return iterator;
332 }
333 
334 } // end namespace itk
335 
336 #endif

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