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 TCoordinate>
50class ITK_TEMPLATE_EXPORT VoronoiDiagram2DGenerator : public MeshSource<VoronoiDiagram2D<TCoordinate>>
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;
76#ifndef ITK_FUTURE_LEGACY_REMOVE
77 using CoordRepType ITK_FUTURE_DEPRECATED(
78 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
79#endif
81
83 itkGetConstMacro(NumberOfSeeds, unsigned int);
84
88 void
89 SetSeeds(int num, SeedsIterator begin);
90
92 void
93 AddSeeds(int num, SeedsIterator begin);
94
97
99 void
101
103 void
105 {}
106
108 void
110
112 void
114
115 void
117
119 void
121
124 GetSeed(int SeedID);
125
126protected:
128 ~VoronoiDiagram2DGenerator() override = default;
129 void
130 PrintSelf(std::ostream & os, Indent indent) const override;
131
133 void
134 GenerateData() override;
135
136private:
137 unsigned int m_NumberOfSeeds{ 0 };
138 PointType m_VorBoundary{};
139 OutputType m_OutputVD{};
140 SeedsType m_Seeds{};
141
143 static bool
145
152 class FortuneSite;
153 class FortuneEdge;
154 class FortuneHalfEdge;
155
156 // All private nested classes must be friend classes to work with SunOS-CC
157 // compiler. If not, the private nested classes will not be able to access
158 // each other.
159 friend class FortuneSite;
160 friend class FortuneEdge;
161 friend class FortuneHalfEdge;
162
164 {
165 public:
168
170 : m_Sitenbr(NumericTraits<int>::max())
171 {
173 }
174
175 ~FortuneSite() = default;
176 };
177
179 {
180 public:
181 float m_A{ 0.0 }, m_B{ 0.0 }, m_C{ 0.0 }; // explicit line function: Ax + By = C;
182 FortuneSite * m_Ep[2];
183 FortuneSite * m_Reg[2];
184 int m_Edgenbr{ 0 };
185
186 FortuneEdge() { m_Ep[0] = m_Ep[1] = m_Reg[0] = m_Reg[1] = nullptr; }
187
188 ~FortuneEdge() = default;
189 };
190
192 {
193 public:
197 bool m_RorL{ false };
199 double m_Ystar{ 0.0 };
201
203 : m_Left(nullptr)
204 , m_Right(nullptr)
205 , m_Edge(nullptr)
206 , m_Vert(nullptr)
207 , m_Next(nullptr)
208 {}
209
211 : m_Left(edge.m_Left)
212 , m_Right(edge.m_Right)
213 , m_Edge(edge.m_Edge)
214 , m_RorL(edge.m_RorL)
215 , m_Vert(edge.m_Vert)
216 , m_Ystar(edge.m_Ystar)
217 , m_Next(edge.m_Next)
218 {}
219
220 ~FortuneHalfEdge() = default;
221 };
222
223 double m_Pxmin{ 0.0 };
224 double m_Pxmax{ 0.0 };
225 double m_Pymin{ 0.0 };
226 double m_Pymax{ 0.0 };
227 double m_Deltax{ 0.0 };
228 double m_Deltay{ 0.0 };
229 double m_SqrtNSites{ 0.0 };
230
231 unsigned int m_PQcount{ 0 };
232 int m_PQmin{ 0 };
233 unsigned int m_PQhashsize{ 0 };
234 unsigned int m_Nedges{ 0 };
235 unsigned int m_Nvert{ 0 };
236 FortuneSite * m_BottomSite{};
237 std::vector<FortuneHalfEdge> m_PQHash{};
238
239 unsigned int m_ELhashsize{ 0 };
240 FortuneHalfEdge m_ELleftend{};
241 FortuneHalfEdge m_ELrightend{};
242 std::vector<FortuneHalfEdge *> m_ELHash{};
243
244 FortuneEdge m_DELETED{};
245 std::vector<FortuneSite> m_SeedSites{};
246
250 bool
252
253 bool
255
256 unsigned char
257 Pointonbnd(int VertID);
258
259 void
261
262 void
264
265 void
267
268 void
270
273
275 ELgethash(int b);
276
281 bool
283
286
289
290 void
292
293 void
295
296 void
298
299 void
301
302 void
304
305 int
307
308 void
310
311 void
312 insertPQ(FortuneHalfEdge * he, FortuneSite * v, double offset);
313
314 double
316
319
320 void
321 makeEndPoint(FortuneEdge * task, bool lr, FortuneSite * ends);
322};
323} // end namespace itk
324
325#ifndef ITK_MANUAL_INSTANTIATION
326# include "itkVoronoiDiagram2DGenerator.hxx"
327#endif
328
329#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.
typename VDMesh::EdgeInfoDQ EdgeInfoDQ
void PrintSelf(std::ostream &os, Indent indent) const override
FortuneHalfEdge * ELgethash(int b)
void SetOrigin(PointType vorsize)
void SetSeeds(int num, SeedsIterator begin)
FortuneHalfEdge * getPQmin()
void insertEdgeList(FortuneHalfEdge *lbase, FortuneHalfEdge *lnew)
double dist(FortuneSite *s1, FortuneSite *s2)
~VoronoiDiagram2DGenerator() override=default
void insertPQ(FortuneHalfEdge *he, FortuneSite *v, double offset)
bool almostsame(CoordinateType p1, CoordinateType p2)
typename VDMesh::SeedsIterator SeedsIterator
FortuneSite * getLeftReg(FortuneHalfEdge *he)
int PQbucket(FortuneHalfEdge *task)
void PQshowMin(PointType *answer)
typename VDMesh::CoordinateType CoordinateType
void bisect(FortuneEdge *, FortuneSite *s1, FortuneSite *s2)
void deletePQ(FortuneHalfEdge *task)
FortuneSite * getRightReg(FortuneHalfEdge *he)
bool differentPoint(PointType p1, PointType p2)
void AddSeeds(int num, SeedsIterator begin)
typename VDMesh::VoronoiEdge VoronoiEdge
void clip_line(FortuneEdge *task)
void createHalfEdge(FortuneHalfEdge *task, FortuneEdge *e, bool pm)
bool right_of(FortuneHalfEdge *el, PointType *p)
void intersect(FortuneSite *newV, FortuneHalfEdge *el1, FortuneHalfEdge *el2)
void makeEndPoint(FortuneEdge *task, bool lr, FortuneSite *ends)
void SetBoundary(PointType vorsize)
void deleteEdgeList(FortuneHalfEdge *task)
static bool comp(PointType arg1, PointType arg2)
unsigned char Pointonbnd(int VertID)
PointType GetSeed(int SeedID)
FortuneHalfEdge * findLeftHE(PointType *p)
Implements the 2-Dimensional Voronoi Diagram.
typename SeedsType::iterator SeedsIterator
std::vector< PointType > SeedsType
typename MeshTraits::CoordinateType CoordinateType
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....