ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
47template <typename TCoordinate>
48class ITK_TEMPLATE_EXPORT VoronoiDiagram2DGenerator : public MeshSource<VoronoiDiagram2D<TCoordinate>>
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(VoronoiDiagram2DGenerator);
52
57
59 itkNewMacro(Self);
60
62 itkOverrideGetNameOfClassMacro(VoronoiDiagram2DGenerator);
63
68 using OutputType = typename VDMesh::Pointer;
69 using PointType = typename VDMesh::PointType;
70 using SeedsType = typename VDMesh::SeedsType;
71 using EdgeInfo = typename VDMesh::EdgeInfo;
74#ifndef ITK_FUTURE_LEGACY_REMOVE
75 using CoordRepType ITK_FUTURE_DEPRECATED(
76 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
77#endif
79
81 itkGetConstMacro(NumberOfSeeds, unsigned int);
82
86 void
87 SetSeeds(int num, SeedsIterator begin);
88
90 void
91 AddSeeds(int num, SeedsIterator begin);
92
95
97 void
99
101 void
103 {}
104
106 void
108
110 void
112
113 void
115
117 void
119
122 GetSeed(int SeedID);
123
124protected:
126 ~VoronoiDiagram2DGenerator() override = default;
127 void
128 PrintSelf(std::ostream & os, Indent indent) const override;
129
131 void
132 GenerateData() override;
133
134private:
135 unsigned int m_NumberOfSeeds{ 0 };
139
141 static bool
143
150 class FortuneSite;
151 class FortuneEdge;
152 class FortuneHalfEdge;
153
154 // All private nested classes must be friend classes to work with SunOS-CC
155 // compiler. If not, the private nested classes will not be able to access
156 // each other.
157 friend class FortuneSite;
158 friend class FortuneEdge;
159 friend class FortuneHalfEdge;
160
162 {
163 public:
166
168 : m_Sitenbr(NumericTraits<int>::max())
169 {
171 }
172
173 ~FortuneSite() = default;
174 };
175
177 {
178 public:
179 float m_A{ 0.0 }, m_B{ 0.0 }, m_C{ 0.0 }; // explicit line function: Ax + By = C;
182 int m_Edgenbr{ 0 };
183
184 FortuneEdge() { m_Ep[0] = m_Ep[1] = m_Reg[0] = m_Reg[1] = nullptr; }
185
186 ~FortuneEdge() = default;
187 };
188
190 {
191 public:
195 bool m_RorL{ false };
197 double m_Ystar{ 0.0 };
199
201 : m_Left(nullptr)
202 , m_Right(nullptr)
203 , m_Edge(nullptr)
204 , m_Vert(nullptr)
205 , m_Next(nullptr)
206 {}
207
209 : m_Left(edge.m_Left)
210 , m_Right(edge.m_Right)
211 , m_Edge(edge.m_Edge)
212 , m_RorL(edge.m_RorL)
213 , m_Vert(edge.m_Vert)
214 , m_Ystar(edge.m_Ystar)
215 , m_Next(edge.m_Next)
216 {}
217
218 ~FortuneHalfEdge() = default;
219 };
220
221 double m_Pxmin{ 0.0 };
222 double m_Pxmax{ 0.0 };
223 double m_Pymin{ 0.0 };
224 double m_Pymax{ 0.0 };
225 double m_Deltax{ 0.0 };
226 double m_Deltay{ 0.0 };
227 double m_SqrtNSites{ 0.0 };
228
229 unsigned int m_PQcount{ 0 };
230 int m_PQmin{ 0 };
231 unsigned int m_PQhashsize{ 0 };
232 unsigned int m_Nedges{ 0 };
233 unsigned int m_Nvert{ 0 };
234 FortuneSite * m_BottomSite{};
235 std::vector<FortuneHalfEdge> m_PQHash{};
236
237 unsigned int m_ELhashsize{ 0 };
238 FortuneHalfEdge m_ELleftend{};
239 FortuneHalfEdge m_ELrightend{};
240 std::vector<FortuneHalfEdge *> m_ELHash{};
241
242 FortuneEdge m_DELETED{};
243 std::vector<FortuneSite> m_SeedSites{};
244
248 bool
250
251 bool
253
254 unsigned char
255 Pointonbnd(int VertID);
256
257 void
259
260 void
262
263 void
264 createHalfEdge(FortuneHalfEdge * task, FortuneEdge * e, bool pm);
265
266 void
268
269 FortuneHalfEdge *
271
272 FortuneHalfEdge *
273 ELgethash(int b);
274
279 bool
280 right_of(FortuneHalfEdge * el, PointType * p);
281
282 FortuneSite *
283 getRightReg(FortuneHalfEdge * he);
284
285 FortuneSite *
286 getLeftReg(FortuneHalfEdge * he);
287
288 void
289 bisect(FortuneEdge *, FortuneSite * s1, FortuneSite * s2);
290
291 void
292 insertEdgeList(FortuneHalfEdge * lbase, FortuneHalfEdge * lnew);
293
294 void
295 intersect(FortuneSite * newV, FortuneHalfEdge * el1, FortuneHalfEdge * el2);
296
297 void
298 deletePQ(FortuneHalfEdge * task);
299
300 void
301 deleteEdgeList(FortuneHalfEdge * task);
302
303 int
304 PQbucket(FortuneHalfEdge * task);
305
306 void
307 clip_line(FortuneEdge * task);
308
309 void
310 insertPQ(FortuneHalfEdge * he, FortuneSite * v, double offset);
311
312 double
313 dist(FortuneSite * s1, FortuneSite * s2);
314
315 FortuneHalfEdge *
317
318 void
319 makeEndPoint(FortuneEdge * task, bool lr, FortuneSite * ends);
320};
321} // end namespace itk
322
323#ifndef ITK_MANUAL_INSTANTIATION
324# include "itkVoronoiDiagram2DGenerator.hxx"
325#endif
326
327#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
Define additional traits for native types such as int or float.
static constexpr T max(const T &)
Implements transparent reference counting.
Small data structures for Fortune's Method and some public variables/methods not for external access.
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)
MeshSource< VoronoiDiagram2D< TCoordinate > > Superclass
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)
VoronoiDiagram2D< TCoordinate > VoronoidDiagramType
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
typename MeshTraits::PointType PointType
SmartPointer< Self > Pointer
std::deque< EdgeInfo > EdgeInfoDQ
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....