Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
RVD_callback.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef GEOGRAM_VORONOI_RVD_CALLBACK
41#define GEOGRAM_VORONOI_RVD_CALLBACK
42
45#include <geogram/mesh/mesh.h>
48
49namespace GEOGen {
50 class SymbolicVertex;
51 class Polygon;
52 class ConvexCell;
53}
54
55namespace GEO {
56 class RVDVertexMap;
57 class Mesh;
58
59 namespace Process {
60 class SpinLockArray;
61 }
62}
63
70namespace GEO {
71
72 /***************************************************************/
73
79 class GEOGRAM_API RVDCallback {
80 public:
81
86
90 virtual ~RVDCallback();
91
95 virtual void begin();
96
100 virtual void end();
101
110 index_t seed() const {
111 return seed_;
112 }
113
123 index_t simplex() const {
124 return simplex_;
125 }
126
135 spinlocks_ = spinlocks;
136 }
137
138 protected:
139 index_t seed_;
140 index_t simplex_;
141 Process::SpinLockArray* spinlocks_;
142 };
143
144 /***************************************************************/
145
156 class GEOGRAM_API RVDPolygonCallback : public RVDCallback {
157 public:
158
163
168
172 void begin() override;
173
177 void end() override;
178
186 virtual void operator() (
187 index_t v,
188 index_t t,
189 const GEOGen::Polygon& C
190 ) const;
191
192 };
193
194 /***************************************************************/
195
205 class GEOGRAM_API RVDPolyhedronCallback : public RVDCallback {
206 public:
207
212
217
221 void begin() override;
222
226 void end() override;
227
228
241 virtual void operator() (
242 index_t v,
243 index_t t,
244 const GEOGen::ConvexCell& C
245 ) const;
246
247
255 virtual void begin_polyhedron(index_t seed, index_t tetrahedron);
256
269 virtual void begin_facet(index_t facet_seed, index_t facet_tet);
270
276 virtual void vertex(
277 const double* geometry, const GEOGen::SymbolicVertex& symb
278 );
279
283 virtual void end_facet();
284
288 virtual void end_polyhedron();
289
298 index_t tet() const {
299 return simplex();
300 }
301
312 return facet_seed_;
313 }
314
326 return facet_tet_;
327 }
328
340 simplify_internal_tet_facets_ = x;
341 }
342
354 simplify_voronoi_facets_ = x;
355 if(x) {
356 set_simplify_internal_tet_facets(true);
357 set_use_mesh(true);
358 }
359 }
360
375 void set_simplify_boundary_facets(bool x, double angle_threshold=45.0) {
376 simplify_boundary_facets_ = x;
377 if(x) {
378 set_simplify_voronoi_facets(true);
379 simplify_boundary_facets_angle_threshold_ = angle_threshold;
380 } else {
381 simplify_boundary_facets_angle_threshold_ = 0.0;
382 }
383 }
384
392 tessellate_non_convex_facets_ = x;
393 }
394
395
403 void set_use_mesh(bool x);
404
412 if(use_mesh_) {
413 mesh_.vertices.set_dimension(dim);
414 }
415 }
416
417 protected:
425 index_t seed, index_t tetrahedron
426 );
427
435 index_t facet_seed, index_t facet_tet
436 );
437
444 virtual void vertex_internal(
445 const double* geometry, const GEOGen::SymbolicVertex& symb
446 );
447
454 virtual void end_facet_internal();
455
463
475
476 protected:
477
478 index_t facet_seed_;
479 index_t facet_tet_;
480 index_t last_seed_;
481
482 bool simplify_internal_tet_facets_;
483 bool simplify_voronoi_facets_;
484 bool simplify_boundary_facets_;
485 double simplify_boundary_facets_angle_threshold_;
486 bool tessellate_non_convex_facets_;
487
488 bool use_mesh_;
489 bool facet_is_skipped_;
490
491 Mesh mesh_;
492 Attribute<GEOGen::SymbolicVertex> mesh_vertex_sym_;
493 Attribute<index_t> mesh_facet_seed_;
494 Attribute<index_t> mesh_facet_tet_;
495 RVDVertexMap* vertex_map_;
496 vector<index_t> base_current_facet_;
497 };
498
499 /***************************************************************/
500
508 class GEOGRAM_API BuildRVDMesh : public RVDPolyhedronCallback {
509 public:
510
515 BuildRVDMesh(Mesh& output_mesh);
516
520 ~BuildRVDMesh() override;
521
533 void set_generate_ids(bool x);
534
540 void set_shrink(double x);
541
545 void begin() override;
546
550 void end() override;
551
558 void begin_polyhedron(index_t seed, index_t tetrahedron) override;
559
563 void begin_facet(index_t facet_seed, index_t facet_tet_facet) override;
564
568 void vertex(
569 const double* geometry, const GEOGen::SymbolicVertex& symb
570 ) override;
571
575 void end_facet() override;
576
580 void end_polyhedron() override;
581
585 void process_polyhedron_mesh() override;
586
587 private:
588 vector<index_t> current_facet_;
589 Mesh& output_mesh_;
590 RVDVertexMap* global_vertex_map_;
591 RVDVertexMap* cell_vertex_map_;
592 double shrink_;
593 bool generate_ids_;
594 Attribute<int> cell_id_;
595 Attribute<int> seed_id_;
596 Attribute<int> vertex_id_;
597 Attribute<int> facet_seed_id_;
598 index_t current_cell_id_;
599 };
600
601
602 /***************************************************************/
603
604}
605
606#endif
607
Generic mechanism for attributes.
Common include file, providing basic definitions. Should be included before anything else by all head...
Computes the intersection between a set of halfspaces.
Internal representation of polygons for GenericVoronoiDiagram.
A set of three integers that encodes the equation of a vertex in GenericVoronoiDiagram.
Manages an attribute attached to a set of object.
Constructs a polyhedral mesh from a restricted Voronoi diagram.
void end() override
Called at the end of RVD traversal.
void begin_facet(index_t facet_seed, index_t facet_tet_facet) override
Called at the beginning of each facet of each intersection polyhedron.
void end_polyhedron() override
Called at the end of each polyhedron.
BuildRVDMesh(Mesh &output_mesh)
BuildRVDMesh constructor.
void begin() override
Called at the beginning of RVD traversal.
void set_generate_ids(bool x)
Specifies whether ids should be generated.
void begin_polyhedron(index_t seed, index_t tetrahedron) override
Called at the beginning of each RVD polyhedron.
~BuildRVDMesh() override
BuildRVDMesh destructor.
void end_facet() override
Called at the end of each polyhedron facet.
void set_shrink(double x)
Defines the optional shrink factor for cells.
void vertex(const double *geometry, const GEOGen::SymbolicVertex &symb) override
Called for each vertex of the current facet.
void process_polyhedron_mesh() override
If use_mesh is set, then this function is called for each generated mesh.
Represents a mesh.
Definition mesh.h:2648
An array of light-weight synchronisation primitives (spinlocks).
Baseclass for user functions called for each element (polygon or polyhedron) of a restricted Voronoi ...
index_t simplex() const
Gets the index of the simplex that corresponds to the current polygon/polyhedron.
void set_spinlocks(Process::SpinLockArray *spinlocks)
Sets the spinlocks array.
virtual ~RVDCallback()
RVDCallback destructor.
virtual void end()
Called at the end of the RVD traversal.
virtual void begin()
Called at the beginning of the RVD traversal.
index_t seed() const
Gets the index of the seed that corresponds to the current polygon/polyhedron.
RVDCallback()
RVDCallback constructor.
Baseclass for user functions called for each polygon of a surfacic restricted Voronoi diagram.
void end() override
Called at the end of the RVD traversal.
RVDPolygonCallback()
PolyhedronCallback constructor.
void begin() override
Called at the beginning of the RVD traversal.
~RVDPolygonCallback() override
PolyhedronCallback destructor.
Baseclass for user functions called for each polyhedron of a volumetric restricted Voronoi diagram.
~RVDPolyhedronCallback() override
PolyhedronCallback destructor.
virtual void vertex(const double *geometry, const GEOGen::SymbolicVertex &symb)
Called for each vertex of the current facet.
void set_simplify_boundary_facets(bool x, double angle_threshold=45.0)
Specifies whether boundary facets should be simplified.
virtual void begin_facet(index_t facet_seed, index_t facet_tet)
Called at the beginning of each facet of each intersection polyhedron.
RVDPolyhedronCallback()
PolyhedronCallback constructor.
void begin() override
Called at the beginning of the RVD traversal.
virtual void end_polyhedron()
Called at the end of each polyhedron.
void set_simplify_voronoi_facets(bool x)
Specifies whether Voronoi facets should be simplified.
void set_use_mesh(bool x)
Specifies whether a mesh should be built for each traversed polyhedron.
index_t tet() const
Gets the index of the tetrahedron that corresponds to the current polyhedron.
virtual void end_facet_internal()
Filters callbacks between operator() and client callbacks.
void set_simplify_internal_tet_facets(bool x)
Specifies whether internal tetrahedron facets should be removed.
void end() override
Called at the end of the RVD traversal.
virtual void end_polyhedron_internal()
Filters callbacks between operator() and client callbacks.
virtual void begin_facet_internal(index_t facet_seed, index_t facet_tet)
Filters callbacks between operator() and client callbacks.
virtual void begin_polyhedron_internal(index_t seed, index_t tetrahedron)
Filters callbacks between operator() and client callbacks.
index_t facet_tet() const
Gets the index of the tetrahedron adjacent to the current facet or index_t(-1) if there is no such fa...
virtual void begin_polyhedron(index_t seed, index_t tetrahedron)
Called at the beginning of each intersection polyhedron.
index_t facet_seed() const
Gets the index of the seed that defines the bisector on which the current facet lies,...
void set_dimension(index_t dim)
Sets the dimension of the internal mesh if need be.
void set_tessellate_non_convex_facets(bool x)
Specifies whether non-convex facets should be tessellated.
virtual void vertex_internal(const double *geometry, const GEOGen::SymbolicVertex &symb)
Filters callbacks between operator() and client callbacks.
virtual void process_polyhedron_mesh()
If use_mesh is set, then this function is called for each generated mesh.
virtual void end_facet()
Called at the end of each polyhedron facet.
RVDVertexMap maps symbolic vertices to unique ids.
Vector with aligned memory allocation.
Definition memory.h:623
Types and utilities for manipulating vertices in geometric and symbolic forms in restricted Voronoi d...
The class that represents a mesh.
Global Vorpaline namespace.
Definition algorithm.h:64
GEOGen::SymbolicVertex SymbolicVertex
Symbolic representation of a RestrictedVoronoiDiagram vertex.
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:287
Types and functions for numbers manipulation.