Geogram Version 1.9.2
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>
49
50namespace GEOGen {
51 class SymbolicVertex;
52 class Polygon;
53 class ConvexCell;
54}
55
56namespace GEO {
57 class RVDVertexMap;
58 class Mesh;
59}
60
67namespace GEO {
68
69 /***************************************************************/
70
76 class GEOGRAM_API RVDCallback {
77 public:
78
83
87 virtual ~RVDCallback();
88
92 virtual void begin();
93
97 virtual void end();
98
107 index_t seed() const {
108 return seed_;
109 }
110
120 index_t simplex() const {
121 return simplex_;
122 }
123
131 void set_spinlocks(Process::SpinLockArray* spinlocks) {
132 spinlocks_ = spinlocks;
133 }
134
135 protected:
136 index_t seed_;
137 index_t simplex_;
138 Process::SpinLockArray* spinlocks_;
139 };
140
141 /***************************************************************/
142
153 class GEOGRAM_API RVDPolygonCallback : public RVDCallback {
154 public:
155
160
165
169 void begin() override;
170
174 void end() override;
175
183 virtual void operator() (
184 index_t v,
185 index_t t,
186 const GEOGen::Polygon& C
187 ) const;
188
189 };
190
191 /***************************************************************/
192
202 class GEOGRAM_API RVDPolyhedronCallback : public RVDCallback {
203 public:
204
209
214
218 void begin() override;
219
223 void end() override;
224
225
238 virtual void operator() (
239 index_t v,
240 index_t t,
241 const GEOGen::ConvexCell& C
242 ) const;
243
244
252 virtual void begin_polyhedron(index_t seed, index_t tetrahedron);
253
266 virtual void begin_facet(index_t facet_seed, index_t facet_tet);
267
273 virtual void vertex(
274 const double* geometry, const GEOGen::SymbolicVertex& symb
275 );
276
280 virtual void end_facet();
281
285 virtual void end_polyhedron();
286
295 index_t tet() const {
296 return simplex();
297 }
298
309 return facet_seed_;
310 }
311
323 return facet_tet_;
324 }
325
337 simplify_internal_tet_facets_ = x;
338 }
339
351 simplify_voronoi_facets_ = x;
352 if(x) {
353 set_simplify_internal_tet_facets(true);
354 set_use_mesh(true);
355 }
356 }
357
372 void set_simplify_boundary_facets(bool x, double angle_threshold=45.0) {
373 simplify_boundary_facets_ = x;
374 if(x) {
375 set_simplify_voronoi_facets(true);
376 simplify_boundary_facets_angle_threshold_ = angle_threshold;
377 } else {
378 simplify_boundary_facets_angle_threshold_ = 0.0;
379 }
380 }
381
389 tessellate_non_convex_facets_ = x;
390 }
391
392
400 void set_use_mesh(bool x);
401
409 if(use_mesh_) {
410 mesh_.vertices.set_dimension(dim);
411 }
412 }
413
414 protected:
422 index_t seed, index_t tetrahedron
423 );
424
432 index_t facet_seed, index_t facet_tet
433 );
434
441 virtual void vertex_internal(
442 const double* geometry, const GEOGen::SymbolicVertex& symb
443 );
444
451 virtual void end_facet_internal();
452
460
472
473 protected:
474
475 index_t facet_seed_;
476 index_t facet_tet_;
477 index_t last_seed_;
478
479 bool simplify_internal_tet_facets_;
480 bool simplify_voronoi_facets_;
481 bool simplify_boundary_facets_;
482 double simplify_boundary_facets_angle_threshold_;
483 bool tessellate_non_convex_facets_;
484
485 bool use_mesh_;
486 bool facet_is_skipped_;
487
488 Mesh mesh_;
489 Attribute<GEOGen::SymbolicVertex> mesh_vertex_sym_;
490 Attribute<index_t> mesh_facet_seed_;
491 Attribute<index_t> mesh_facet_tet_;
492 RVDVertexMap* vertex_map_;
493 vector<index_t> base_current_facet_;
494 };
495
496 /***************************************************************/
497
505 class GEOGRAM_API BuildRVDMesh : public RVDPolyhedronCallback {
506 public:
507
512 BuildRVDMesh(Mesh& output_mesh);
513
517 ~BuildRVDMesh() override;
518
530 void set_generate_ids(bool x);
531
537 void set_shrink(double x);
538
542 void begin() override;
543
547 void end() override;
548
555 void begin_polyhedron(index_t seed, index_t tetrahedron) override;
556
560 void begin_facet(index_t facet_seed, index_t facet_tet_facet) override;
561
565 void vertex(
566 const double* geometry, const GEOGen::SymbolicVertex& symb
567 ) override;
568
572 void end_facet() override;
573
577 void end_polyhedron() override;
578
582 void process_polyhedron_mesh() override;
583
584 private:
585 vector<index_t> current_facet_;
586 Mesh& output_mesh_;
587 RVDVertexMap* global_vertex_map_;
588 RVDVertexMap* cell_vertex_map_;
589 double shrink_;
590 bool generate_ids_;
591 Attribute<int> cell_id_;
592 Attribute<int> seed_id_;
593 Attribute<int> vertex_id_;
594 Attribute<int> facet_seed_id_;
595 index_t current_cell_id_;
596 };
597
598
599 /***************************************************************/
600
601}
602
603#endif
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:2701
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:660
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:65
GEOGen::SymbolicVertex SymbolicVertex
Symbolic representation of a RestrictedVoronoiDiagram vertex.
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:329
Types and functions for numbers manipulation.
Functions and classes for process manipulation.