Orfeo Toolbox  3.16
itkVoronoiDiagram2DGenerator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkVoronoiDiagram2DGenerator.h,v $
5  Language: C++
6  Date: $Date: 2010-07-12 17:21:56 $
7  Version: $Revision: 1.19 $
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 #ifndef __itkVoronoiDiagram2DGenerator_h
18 #define __itkVoronoiDiagram2DGenerator_h
19 
20 #include "itkCellInterface.h"
21 #include "itkLineCell.h"
22 #include "itkMeshSource.h"
24 #include "itkPolygonCell.h"
25 #include "itkVoronoiDiagram2D.h"
26 
27 #include <vector>
28 
29 #ifndef NULL
30 #define NULL 0
31 #endif
32 
33 namespace itk
34 {
52 template <typename TCoordType>
54  public MeshSource <VoronoiDiagram2D<TCoordType> >
55 {
56 public:
61 
63  itkNewMacro(Self);
64 
67 
71  typedef typename VDMesh::Pointer OutputType;
72  typedef typename VDMesh::PointType PointType;
73  typedef typename VDMesh::SeedsType SeedsType;
74  typedef typename VDMesh::EdgeInfo EdgeInfo;
75  typedef typename VDMesh::EdgeInfoDQ EdgeInfoDQ;
77  typedef typename VDMesh::VoronoiEdge VoronoiEdge;
78 
80  itkGetConstMacro(NumberOfSeeds,unsigned int);
81 
84  void SetSeeds (int num, SeedsIterator begin);
85 
87  void AddSeeds(int num,SeedsIterator begin);
88  void AddOneSeed(PointType);
89 
91  void SortSeeds(void);
92 
94  virtual void GenerateOutputInformation() {}
95 
97  void UpdateDiagram(void);
98 
100  void SetBoundary(PointType vorsize);
101  void SetOrigin(PointType vorsize);
102 
104  void SetRandomSeeds(int num);
105 
107  PointType GetSeed(int SeedID);
108 
109 protected:
112  virtual void PrintSelf(std::ostream& os, Indent indent) const;
113 
115  void GenerateData(void);
116 
117 private:
118  VoronoiDiagram2DGenerator(const Self&); //purposely not implemented
119  void operator=(const Self&); //purposely not implemented
120 
121  unsigned int m_NumberOfSeeds;
125 
126  static bool comp(PointType arg1,PointType arg2);
130  class FortuneSite;
131  class FortuneEdge;
133 
136  friend class FortuneSite;
137  friend class FortuneEdge;
138  friend class FortuneHalfEdge;
139 
141  {
142  public:
145  FortuneSite() : m_Sitenbr(NumericTraits<int>::max()) { m_Coord.Fill(NumericTraits<CoordRepType>::max()); }
147  };
148 
150  {
151  public:
152  float m_A, m_B, m_C; // explicit line function: Ax + By = C;
153  FortuneSite *m_Ep[2];
154  FortuneSite *m_Reg[2];
156  FortuneEdge() : m_A(0.0), m_B(0.0), m_C(0.0) {m_Ep[0] = m_Ep[1] = m_Reg[0] = m_Reg[1] = 0; }
158  };
159 
161  {
162  public:
166  bool m_RorL;
168  double m_Ystar;
170  FortuneHalfEdge() : m_Left(0), m_Right(0), m_Edge(0), m_RorL( false ), m_Vert(0), m_Ystar(0.0), m_Next(0) {}
171  FortuneHalfEdge(const FortuneHalfEdge &edge) : m_Left(edge.m_Left),
172  m_Right(edge.m_Right),
173  m_Edge(edge.m_Edge),
174  m_RorL( edge.m_RorL ),
175  m_Vert( edge.m_Vert ),
176  m_Ystar( edge.m_Ystar ),
177  m_Next( edge.m_Next ) {}
179  };
180 
181  double m_Pxmin;
182  double m_Pxmax;
183  double m_Pymin;
184  double m_Pymax;
185  double m_Deltax;
186  double m_Deltay;
187  double m_SqrtNSites;
188 
189  unsigned int m_PQcount;
190  int m_PQmin;
191  unsigned int m_PQhashsize;
192  unsigned int m_Nedges;
193  unsigned int m_Nvert;
195  std::vector<FortuneHalfEdge> m_PQHash;
196 
197  unsigned int m_ELhashsize;
200  std::vector<FortuneHalfEdge *> m_ELHash;
201 
203  std::vector<FortuneSite> m_SeedSites;
204 
205  bool differentPoint(PointType p1,PointType p2);
206  bool almostsame(CoordRepType p1,CoordRepType p2);
207  unsigned char Pointonbnd(int VertID);
208 
209  void GenerateVDFortune(void);
210  void ConstructDiagram(void);
211 
212  void createHalfEdge(FortuneHalfEdge *task, FortuneEdge *e,bool pm);
213  void PQshowMin(PointType *task);
214  FortuneHalfEdge *findLeftHE(PointType *p);
215  FortuneHalfEdge *ELgethash(int b);
216  bool right_of(FortuneHalfEdge *el, PointType *p);
217  FortuneSite *getRightReg(FortuneHalfEdge *he);
218  FortuneSite *getLeftReg(FortuneHalfEdge *he);
219  void bisect(FortuneEdge *, FortuneSite *s1,FortuneSite *s2);
220  void insertEdgeList(FortuneHalfEdge *lbase, FortuneHalfEdge *lnew);
221  void intersect(FortuneSite *task,FortuneHalfEdge *el1,FortuneHalfEdge *el2);
222  void deletePQ(FortuneHalfEdge *task);
223  void deleteEdgeList(FortuneHalfEdge *task);
224  int PQbucket(FortuneHalfEdge *task);
225  void clip_line(FortuneEdge *task);
226  void insertPQ(FortuneHalfEdge *he, FortuneSite *v, double offset);
227  double dist(FortuneSite *s1,FortuneSite *s2);
228  FortuneHalfEdge *getPQmin(void);
229  void makeEndPoint(FortuneEdge *task, bool lr, FortuneSite *ends);
230 };
231 
232 } // end namespace itk
233 
234 #ifndef ITK_MANUAL_INSTANTIATION
236 #endif
237 
238 #endif

Generated at Sun May 19 2013 00:13:50 for Orfeo Toolbox with doxygen 1.8.3.1