Orfeo Toolbox  4.0
itkVoronoiDiagram2D.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 __itkVoronoiDiagram2D_h
19 #define __itkVoronoiDiagram2D_h
20 
21 
22 #include "itkMesh.h"
24 #include "itkPolygonCell.h"
25 #include <vector>
26 
27 #ifndef NULL
28 #define NULL 0
29 #endif
30 
31 namespace itk
32 {
50 template< typename TCoordType >
52  public Mesh< TCoordType, 2,
53  DefaultDynamicMeshTraits< TCoordType, 2, 2, TCoordType > >
54 {
55 public:
61 
63  itkNewMacro(Self);
64 
66  itkTypeMacro(VoronoiDiagram2D, Mesh);
67 
70 
72  itkStaticConstMacro(PointDimension, unsigned int,
74  itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
76 
78  typedef typename MeshTraits::PixelType
80  typedef typename MeshTraits::CoordRepType
84  typedef typename MeshTraits::PointIdentifier
86  typedef typename MeshTraits::CellIdentifier
88  typedef typename MeshTraits::CellFeatureIdentifier
90  typedef typename MeshTraits::PointType
92  typedef typename MeshTraits::PointsContainer
94  typedef typename MeshTraits::CellTraits
96  typedef typename MeshTraits::CellsContainer
100  typedef typename MeshTraits::CellLinksContainer
102  typedef typename MeshTraits::PointDataContainer
104  typedef typename MeshTraits::CellDataContainer
106  typedef typename MeshTraits::CellAutoPointer
108  typedef BoundingBox< PointIdentifier, itkGetStaticConstMacro(PointDimension), CoordRepType,
110  typedef typename PointsContainer::Pointer
112  typedef typename CellsContainer::Pointer
114  typedef typename CellLinksContainer::Pointer
116  typedef typename PointDataContainer::Pointer
118  typedef typename CellDataContainer::Pointer
120  typedef typename BoundingBoxType::Pointer
122  typedef typename PointsContainer::ConstIterator
124  typedef typename PointsContainer::Iterator
126  typedef typename CellsContainer::ConstIterator
128  typedef typename CellsContainer::Iterator
130  typedef typename CellLinksContainer::ConstIterator
132  typedef typename PointDataContainer::ConstIterator
134  typedef typename CellDataContainer::ConstIterator
136  typedef typename PointCellLinksContainer::const_iterator
138 
140  typedef typename Superclass::CellType CellType;
144  typedef std::deque< EdgeInfo > EdgeInfoDQ;
145  typedef typename CellType::MultiVisitor CellMultiVisitorType;
146  typedef std::vector< PointType > SeedsType;
147  typedef typename SeedsType::iterator SeedsIterator;
149  typedef typename Edge::SelfAutoPointer EdgeAutoPointer;
150  typedef std::list< PointType > PointList;
151  typedef std::vector< int > INTvector;
152  typedef typename INTvector::iterator NeighborIdIterator;
155  itkGetConstMacro(NumberOfSeeds, unsigned int);
156 
159  void SetSeeds(int num, SeedsIterator begin);
160 
162  void SetBoundary(PointType vorsize);
163 
164  void SetOrigin(PointType vorsize);
165 
168 
170 
173 
175 
177  PointType GetSeed(int SeedID);
178 
180  void GetCellId(CellIdentifier cellId, CellAutoPointer &);
181 
183  void GetPoint(int pId, PointType *answer);
184 
186  {
187 public:
190  int m_LeftID;
192  int m_LineID;
195  };
196 
198  typedef typename std::vector< VoronoiEdge >::iterator VoronoiEdgeIterator;
199 
202 
204 
207 
208  /********************************************************/
209 
210  void Reset();
211 
212  void InsertCells();
213 
215  {
216  m_CellNeighborsID[x[0]].push_back(x[1]);
217  m_CellNeighborsID[x[1]].push_back(x[0]);
218  }
219 
220  void ClearRegion(int i)
221  { m_VoronoiRegions[i]->ClearPoints(); }
222  void VoronoiRegionAddPointId(int id, int x)
223  { m_VoronoiRegions[id]->AddPointId(x); }
224  void BuildEdge(int id)
225  { m_VoronoiRegions[id]->BuildEdges(); }
226 
227  void LineListClear(){ m_LineList.clear(); }
228  void EdgeListClear(){ m_EdgeList.clear(); }
230  {
231  if ( this->m_PointsContainer.IsNull() )
232  {
234  }
235 
236  this->m_PointsContainer->Initialize();
237  }
238 
239  int LineListSize(){ return static_cast< int >( m_LineList.size() ); }
240  int EdgeListSize(){ return static_cast< int >( m_EdgeList.size() ); }
241  int VertexListSize(){ return static_cast< int >(this->m_PointsContainer->Size()); }
242  void AddLine(EdgeInfo x){ m_LineList.push_back(x); }
243  void AddEdge(VoronoiEdge x){ m_EdgeList.push_back(x); }
244  void AddVert(PointType x){ this->m_PointsContainer->InsertElement(this->m_PointsContainer->Size(), x);}
245  EdgeInfo GetLine(int id){ return m_LineList[id]; }
246  VoronoiEdge GetEdge(int id){ return m_EdgeList[id]; }
247  PointType GetVertex(int id){ return this-> m_PointsContainer->ElementAt(id); }
249  {
250  EdgeInfo x;
251 
252  x[0] = m_EdgeList[id].m_LeftID;
253  x[1] = m_EdgeList[id].m_RightID;
254  return x;
255  }
256 
257  int GetEdgeLineID(int id){ return m_EdgeList[id].m_LineID; }
258 
259 protected:
262  virtual void PrintSelf(std::ostream & os, Indent indent) const;
263 
264 private:
265  VoronoiDiagram2D(const Self &); //purposely not implemented
266  void operator=(const Self &); //purposely not implemented
267 
269  unsigned int m_NumberOfSeeds;
270  std::vector< PolygonCellType * > m_VoronoiRegions;
273  std::vector< std::vector< int > > m_CellNeighborsID;
274 
275  std::vector< EdgeInfo > m_LineList;
276  std::vector< VoronoiEdge > m_EdgeList;
277 }; // end class: VoronoiDiagram2D
278 } // end namespace itk
279 
280 #ifndef ITK_MANUAL_INSTANTIATION
281 #include "itkVoronoiDiagram2D.hxx"
282 #endif
283 
284 #endif

Generated at Sat Mar 8 2014 15:44:45 for Orfeo Toolbox with doxygen 1.8.3.1