ITK  6.0.0
Insight Toolkit
itkVoronoiDiagram2DGenerator.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 itkVoronoiDiagram2DGenerator_h
19#define itkVoronoiDiagram2DGenerator_h
20
21#include "itkMeshSource.h"
22#include "itkVoronoiDiagram2D.h"
23
24#include <vector>
25
26namespace itk
27{
49template <typename TCoordType>
50class ITK_TEMPLATE_EXPORT VoronoiDiagram2DGenerator : public MeshSource<VoronoiDiagram2D<TCoordType>>
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(VoronoiDiagram2DGenerator);
54
59
61 itkNewMacro(Self);
62
64 itkOverrideGetNameOfClassMacro(VoronoiDiagram2DGenerator);
65
70 using OutputType = typename VDMesh::Pointer;
71 using PointType = typename VDMesh::PointType;
72 using SeedsType = typename VDMesh::SeedsType;
73 using EdgeInfo = typename VDMesh::EdgeInfo;
77
79 itkGetConstMacro(NumberOfSeeds, unsigned int);
80
84 void
85 SetSeeds(int num, SeedsIterator begin);
86
88 void
89 AddSeeds(int num, SeedsIterator begin);
90
93
95 void
97
99 void
101 {}
102
104 void
106
108 void
110
111 void
113
115 void
117
120 GetSeed(int SeedID);
121
122protected:
124 ~VoronoiDiagram2DGenerator() override = default;
125 void
126 PrintSelf(std::ostream & os, Indent indent) const override;
127
129 void
130 GenerateData() override;
131
132private:
133 unsigned int m_NumberOfSeeds{ 0 };
134 PointType m_VorBoundary{};
135 OutputType m_OutputVD{};
136 SeedsType m_Seeds{};
137
139 static bool
141
148 class FortuneSite;
149 class FortuneEdge;
150 class FortuneHalfEdge;
151
152 // All private nested classes must be friend classes to work with SunOS-CC
153 // compiler. If not, the private nested classes will not be able to access
154 // each other.
155 friend class FortuneSite;
156 friend class FortuneEdge;
157 friend class FortuneHalfEdge;
158
160 {
161 public:
164
166 : m_Sitenbr(NumericTraits<int>::max())
167 {
168 m_Coord.Fill(NumericTraits<CoordRepType>::max());
169 }
170
171 ~FortuneSite() = default;
172 };
173
175 {
176 public:
177 float m_A{ 0.0 }, m_B{ 0.0 }, m_C{ 0.0 }; // explicit line function: Ax + By = C;
178 FortuneSite * m_Ep[2];
179 FortuneSite * m_Reg[2];
180 int m_Edgenbr{ 0 };
181
182 FortuneEdge() { m_Ep[0] = m_Ep[1] = m_Reg[0] = m_Reg[1] = nullptr; }
183
184 ~FortuneEdge() = default;
185 };
186
188 {
189 public:
193 bool m_RorL{ false };
195 double m_Ystar{ 0.0 };
197
199 : m_Left(nullptr)
200 , m_Right(nullptr)
201 , m_Edge(nullptr)
202 , m_Vert(nullptr)
203 , m_Next(nullptr)
204 {}
205
207 : m_Left(edge.m_Left)
208 , m_Right(edge.m_Right)
209 , m_Edge(edge.m_Edge)
210 , m_RorL(edge.m_RorL)
211 , m_Vert(edge.m_Vert)
212 , m_Ystar(edge.m_Ystar)
213 , m_Next(edge.m_Next)
214 {}
215
216 ~FortuneHalfEdge() = default;
217 };
218
219 double m_Pxmin{ 0.0 };
220 double m_Pxmax{ 0.0 };
221 double m_Pymin{ 0.0 };
222 double m_Pymax{ 0.0 };
223 double m_Deltax{ 0.0 };
224 double m_Deltay{ 0.0 };
225 double m_SqrtNSites{ 0.0 };
226
227 unsigned int m_PQcount{ 0 };
228 int m_PQmin{ 0 };
229 unsigned int m_PQhashsize{ 0 };
230 unsigned int m_Nedges{ 0 };
231 unsigned int m_Nvert{ 0 };
232 FortuneSite * m_BottomSite{};
233 std::vector<FortuneHalfEdge> m_PQHash{};
234
235 unsigned int m_ELhashsize{ 0 };
236 FortuneHalfEdge m_ELleftend{};
237 FortuneHalfEdge m_ELrightend{};
238 std::vector<FortuneHalfEdge *> m_ELHash{};
239
240 FortuneEdge m_DELETED{};
241 std::vector<FortuneSite> m_SeedSites{};
242
246 bool
248
249 bool
251
252 unsigned char
253 Pointonbnd(int VertID);
254
255 void
257
258 void
260
261 void
263
264 void
266
269
271 ELgethash(int b);
272
277 bool
279
282
285
286 void
288
289 void
291
292 void
294
295 void
297
298 void
300
301 int
303
304 void
306
307 void
308 insertPQ(FortuneHalfEdge * he, FortuneSite * v, double offset);
309
310 double
312
315
316 void
317 makeEndPoint(FortuneEdge * task, bool lr, FortuneSite * ends);
318};
319} // end namespace itk
320
321#ifndef ITK_MANUAL_INSTANTIATION
322# include "itkVoronoiDiagram2DGenerator.hxx"
323#endif
324
325#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Base class for all process objects that output mesh data.
Definition: itkMeshSource.h:50
Define additional traits for native types such as int or float.
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Small data structures for Fortune's Method and some public variables/methods not for external access.
Implement the Sweep Line Algorithm for the construction of the 2D Voronoi Diagram.
void SetOrigin(PointType vorsize)
void deletePQ(FortuneHalfEdge *task)
FortuneHalfEdge * findLeftHE(PointType *p)
void intersect(FortuneSite *newV, FortuneHalfEdge *el1, FortuneHalfEdge *el2)
void insertPQ(FortuneHalfEdge *he, FortuneSite *v, double offset)
bool almostsame(CoordRepType p1, CoordRepType p2)
void bisect(FortuneEdge *, FortuneSite *s1, FortuneSite *s2)
PointType GetSeed(int SeedID)
void SetBoundary(PointType vorsize)
unsigned char Pointonbnd(int VertID)
void PQshowMin(PointType *answer)
FortuneHalfEdge * getPQmin()
void deleteEdgeList(FortuneHalfEdge *task)
void PrintSelf(std::ostream &os, Indent indent) const override
void createHalfEdge(FortuneHalfEdge *task, FortuneEdge *e, bool pm)
bool right_of(FortuneHalfEdge *el, PointType *p)
FortuneHalfEdge * ELgethash(int b)
int PQbucket(FortuneHalfEdge *task)
void AddSeeds(int num, SeedsIterator begin)
void SetSeeds(int num, SeedsIterator begin)
static bool comp(PointType arg1, PointType arg2)
typename VDMesh::SeedsIterator SeedsIterator
typename VDMesh::CoordRepType CoordRepType
bool differentPoint(PointType p1, PointType p2)
FortuneSite * getRightReg(FortuneHalfEdge *he)
typename VDMesh::VoronoiEdge VoronoiEdge
void clip_line(FortuneEdge *task)
FortuneSite * getLeftReg(FortuneHalfEdge *he)
void insertEdgeList(FortuneHalfEdge *lbase, FortuneHalfEdge *lnew)
void makeEndPoint(FortuneEdge *task, bool lr, FortuneSite *ends)
typename VDMesh::EdgeInfoDQ EdgeInfoDQ
~VoronoiDiagram2DGenerator() override=default
double dist(FortuneSite *s1, FortuneSite *s2)
Implements the 2-Dimensional Voronoi Diagram.
typename MeshTraits::CoordRepType CoordRepType
typename SeedsType::iterator SeedsIterator
std::vector< PointType > SeedsType
std::deque< EdgeInfo > EdgeInfoDQ
SmartPointer< Self > Pointer
static constexpr double e
Definition: itkMath.h:56
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....