Geogram  Version 1.9.1
A programming library of geometric algorithms
integration_simplex.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_INTEGRATION_SIMPLEX
41 #define GEOGRAM_VORONOI_INTEGRATION_SIMPLEX
42 
43 #include <geogram/basic/common.h>
44 #include <geogram/basic/numeric.h>
45 #include <geogram/basic/counted.h>
47 #include <geogram/basic/geometry.h>
49 
56 namespace GEOGen {
57  class Vertex;
58 }
59 
60 namespace GEO {
61 
62  class Mesh;
63 
72  class GEOGRAM_API IntegrationSimplex : public Counted {
73 
74  public:
75 
79  ~IntegrationSimplex() override;
80 
102  virtual double eval(
103  index_t center_vertex_index,
104  const GEOGen::Vertex& v0,
105  const GEOGen::Vertex& v1,
106  const GEOGen::Vertex& v2,
107  index_t t,
108  index_t t_adj = index_t(-1),
109  index_t v_adj = index_t(-1)
110  ) = 0;
111 
112 
131  coord_index_t dimension,
132  index_t nb_points,
133  const double* points,
134  double* g,
135  Process::SpinLockArray* spinlocks=nullptr
136  ) {
137  nb_points_ = nb_points;
138  points_stride_ = index_t(dimension);
139  points_ = points;
140  g_ = g;
141  spinlocks_ = spinlocks;
142  }
143 
153  bool volumetric() const {
154  return volumetric_;
155  }
156 
174  return varying_background_;
175  }
176 
186 
187  protected:
200  const Mesh& mesh,
201  bool volumetric,
202  index_t nb_frames,
203  index_t nb_comp_per_frame,
204  const double* frames
205  );
206 
207 
213  const double* point(index_t i) const {
214  geo_debug_assert(i < nb_points_);
215  return points_ + i * points_stride_;
216  }
217 
224  const double* frame(index_t i) const {
225  geo_debug_assert(i < nb_frames_);
226  return frames_ + i * nb_comp_per_frame_;
227  }
228 
229 
230  protected:
231  const Mesh& mesh_;
232  bool volumetric_;
233  index_t nb_points_;
234  index_t points_stride_;
235  const double* points_;
236  double* g_;
237  index_t nb_frames_;
238  index_t nb_comp_per_frame_;
239  const double* frames_;
240  Process::SpinLockArray* spinlocks_;
241  bool varying_background_;
242  };
243 
244  typedef SmartPointer<IntegrationSimplex>
245  IntegrationSimplex_var;
246 
247 }
248 
249 #endif
#define geo_debug_assert(x)
Verifies that a condition is met.
Definition: assert.h:196
Internal representation of vertices in GenericVoronoiDiagram.
Base class for reference-counted objects.
Definition: counted.h:71
Computes an objective function and its gradient over a restricted Voronoi diagram.
void set_points_and_gradient(coord_index_t dimension, index_t nb_points, const double *points, double *g, Process::SpinLockArray *spinlocks=nullptr)
Sets the input points and the location where the computed gradient will be stored.
const double * frame(index_t i) const
Gets a frame by index.
const double * point(index_t i) const
Gets a point by index.
bool volumetric() const
Tests whether this IntegrationSimplex is volumetric.
virtual void reset_thread_local_storage()
Before starting computation, resets thread local storage variables.
virtual double eval(index_t center_vertex_index, const GEOGen::Vertex &v0, const GEOGen::Vertex &v1, const GEOGen::Vertex &v2, index_t t, index_t t_adj=index_t(-1), index_t v_adj=index_t(-1))=0
Computes the contribution of a given integration simplex to the function and its gradient....
IntegrationSimplex(const Mesh &mesh, bool volumetric, index_t nb_frames, index_t nb_comp_per_frame, const double *frames)
Constructs a new IntegrationSimplex.
~IntegrationSimplex() override
IntegrationSimplex destructor.
bool background_mesh_has_varying_attribute() const
Specifies whether the background mesh has varying attributes used in the computation.
Represents a mesh.
Definition: mesh.h:2701
An array of light-weight synchronisation primitives (spinlocks).
Definition: thread_sync.h:301
Base class of reference-counted objects, to be used with smart pointers.
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
Global Vorpaline namespace.
Definition: basic.h:55
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Definition: numeric.h:363
Types and functions for numbers manipulation.
Pointers with automatic reference counting.
Functions and classes for process manipulation.