GCC Code Coverage Report


Directory: ./
File: lib/exploragram/optimal_transport/optimal_transport_3d.h
Date: 2026-09-07 02:28:19
Exec Total Coverage
Lines: 0 1 0.0%
Functions: 0 0 -%
Branches: 0 6 0.0%

Line Branch Exec Source
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 H_EXPLORAGRAM_OPTIMAL_TRANSPORT_OPTIMAL_TRANSPORT_3D_H
41 #define H_EXPLORAGRAM_OPTIMAL_TRANSPORT_OPTIMAL_TRANSPORT_3D_H
42
43 #include <exploragram/basic/common.h>
44 #include <exploragram/optimal_transport/optimal_transport.h>
45
46 /**
47 * \file exploragram/optimal_transport/optimal_transport_3d.h
48 * \brief Solver for semi-discrete optimal transport in 3d (
49 * multilevel and Newton).
50 */
51
52 namespace GEO {
53
54 class RVDPolyhedronCallback;
55
56 /**
57 * \brief Computes the centroids of the Laguerre cells that
58 * correspond to optimal transport.
59 * \param[in] omega a reference to the mesh that represents the
60 * domain
61 * \param[in] nb_points number of points
62 * \param[in] points a pointer to the coordinates of the points
63 * \param[out] centroids a pointer to the computed centroids of
64 * the Laguerre cells that correspond to the optimal transport of
65 * the uniform measure to the points
66 * \param[in] cb an optional RVD polyhedron callback to be called on the
67 * restricted power diagram once it is computed.
68 */
69 void EXPLORAGRAM_API compute_Laguerre_centroids_3d(
70 Mesh* omega,
71 index_t nb_points,
72 const double* points,
73 double* centroids,
74 RVDPolyhedronCallback* cb=nullptr,
75 bool verbose=false,
76 index_t nb_iter=2000
77 );
78
79 /**
80 * \brief Computes semi-discrete optimal transport maps.
81 * \details Computes an optimal transport map between two
82 * distributions in 3D. The first distribution is represented
83 * by a 3D tetrahedral mesh. The second distribution is a sum
84 * of Diracs.
85 * The algorithm is described in the following references:
86 * - 3D algorithm: http://arxiv.org/abs/1409.1279
87 * - Earlier 2D version by Quentin M\'erigot:
88 * Q. Merigot. A multiscale approach to optimal transport.
89 * Computer Graphics Forum 30 (5) 1583--1592, 2011 (Proc SGP 2011).
90 * - Earlier article on OT and power diagrams:
91 * F. Aurenhammer, F. Hoffmann, and B. Aronov. Minkowski-type theorems
92 * and least-squares clustering. Algorithmica, 20:61-76, 1998.
93 */
94 class EXPLORAGRAM_API OptimalTransportMap3d : public OptimalTransportMap {
95 public:
96 /**
97 * \brief OptimalTransportMap3d constructor.
98 * \param[in] mesh the source distribution, represented as a 3d mesh
99 * \param[in] delaunay factory name of the Delaunay triangulation, one
100 * of "PDEL" (parallel), "BPOW" (sequential)
101 * \param[in] BRIO true if vertices are already ordered using BRIO
102 */
103 OptimalTransportMap3d(
104 Mesh* mesh,
105 const std::string& delaunay = "PDEL",
106 bool BRIO = false
107 );
108
109 /**
110 * \brief OptimalTransportMap destructor.
111 */
112 ~OptimalTransportMap3d() override;
113
114 /**
115 * \copydoc OptimalTransportMap::get_RVD()
116 */
117 void get_RVD(Mesh& M) override;
118
119 /**
120 * \copydoc OptimalTransportMap::compute_Laguerre_centroids()
121 */
122 void compute_Laguerre_centroids(double* centroids) override;
123
124 /**
125 * \brief Gets the total mass of the mesh.
126 * \details Take the weights into account if they are present.
127 * \return the total mass of the mesh.
128 */
129 double total_mesh_mass() const;
130
131 protected:
132 /**
133 * \copydoc OptimalTransportMap::call_callback_on_RVD()
134 */
135 void call_callback_on_RVD() override;
136 };
137
138 /**********************************************************************/
139
140 /**
141 * \brief Computes a shape that interpolates the two input tet
142 * meshes.
143 * \details The shape is composed of tetrahedra
144 * \param [in] CVT the Centroidal Voronoi Tesselation
145 * used to sample the second shape
146 * \param [in] OTM the Optimal Transport Map
147 * \param [out] morph mesh where to store the morphing shape. It uses
148 * 6d coordinates (original location + final location).
149 * \param[in] filter_tets if true, remove the tetrahedra that are outside
150 * the source mesh.
151 */
152 void EXPLORAGRAM_API compute_morph(
153 CentroidalVoronoiTesselation& CVT,
154 OptimalTransportMap3d& OTM,
155 Mesh& morph,
156 bool filter_tets=true
157 );
158
159
160 /**
161 * \brief Computes the surface that corresponds to discontinuities
162 * in the optimal transport map.
163 * \details The surface is determined as the facets of Voronoi cells
164 * that are adjacent in Pow(X)|M1 but not in Vor(X)|M2
165 * \param [in] CVT the Centroidal Voronoi Tesselation
166 * used to sample the second shape M2
167 * \param [in] OTM the Optimal Transport Map with the
168 * power diagram that samples the first shape M1
169 * \param [out] singular_set where to store the singular surface
170 */
171 void EXPLORAGRAM_API compute_singular_surface(
172 CentroidalVoronoiTesselation& CVT,
173 OptimalTransportMap3d& OTM,
174 Mesh& singular_set
175 );
176
177 }
178
179 #endif
180