GCC Code Coverage Report


Directory: ./
File: lib/exploragram/hexdom/FF_visu.cpp
Date: 2026-09-07 02:28:19
Exec Total Coverage
Lines: 0 61 0.0%
Functions: 0 2 0.0%
Branches: 0 132 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 #include <exploragram/hexdom/FF_visu.h>
41 #include <exploragram/hexdom/basic.h>
42 #include <exploragram/hexdom/mesh_utils.h>
43 #include <exploragram/hexdom/frame.h>
44 #include <exploragram/hexdom/spherical_harmonics_l4.h>
45 #include <exploragram/hexdom/sphere_model.h> // a sphere for sh glyph
46
47 #include <cmath>
48
49 namespace GEO {
50
51 void view_FF_with_gyphs(Mesh* m, Mesh* render, bool SH, double scale_in) {
52 double scale = scale_in;
53
54 if (!SH) {
55
56 Attribute<double> orient(render->facets.attributes(), "orient");
57 render->clear();
58 Attribute<mat3> B;
59 B.bind_if_is_defined(m->vertices.attributes(), "B");
60 if (B.is_bound()) {
61 FOR(v, m->vertices.nb()) {
62 vec3 dir[3];
63 FOR(i, 3)dir[i]= col(B[v], i);
64 for (int dim = 0; dim < 3; dim++) {
65 for (double sign = -1.; sign < 2.; sign += 2.) {
66 vec3 x = 0.5*scale * sign*dir[dim];
67 vec3 y = 0.5*scale * sign*dir[(dim + 1) % 3];
68 vec3 z = 0.5*scale * sign*dir[(dim + 2) % 3];
69 index_t off_v = render->vertices.create_vertices(4);
70 X(render)[off_v] = X(m)[v] + x - y - z;
71 X(render)[off_v + 1] = X(m)[v] + x + y - z;
72 X(render)[off_v + 2] = X(m)[v] + x + y + z;
73 X(render)[off_v + 3] = X(m)[v] + x - y + z;
74 index_t f = render->facets.create_quad(off_v + 0, off_v + 1, off_v + 2, off_v + 3);
75 orient[f] = dim * 2 + (sign + 1) / 2; //sign * (dim + 1);
76 }
77 }
78 }
79 }
80 }
81 Attribute<SphericalHarmonicL4> sh;
82 sh.bind_if_is_defined(m->vertices.attributes(), "sh");
83 if (SH && sh.is_bound()) {
84 if (m->cells.nb() > 0)
85 scale *= get_cell_average_edge_size(m);
86 else {
87 double ave = 0;
88 FOR(f, m->facets.nb())FOR(e, m->facets.nb_vertices(f))
89 ave += (X(m)[m->facets.vertex(f, e)] - X(m)[m->facets.vertex(f, (e + 1) % m->facets.nb_vertices(f))]).length();
90 ave /= m->facet_corners.nb();
91 scale *= ave;
92 }
93 plop(scale);
94 Attribute<double> val(render->vertices.attributes(), "SH");
95
96 FOR(v, m->vertices.nb()) {
97 index_t off_v = render->vertices.create_vertices(SPHERE_MODEL_NB_PTS);
98 FOR(vs, SPHERE_MODEL_NB_PTS) {
99 vec3 q = SPHERE_MODEL_PTS[vs];
100 val[off_v + vs] = .5 + (sh[v].value(q) - .5) / .64;
101 X(render)[off_v + vs] = X(m)[v] + scale * (3.+2. * (val[off_v + vs]))*q;
102 }
103
104 index_t off_f = render->facets.create_triangles(SPHERE_MODEL_NB_TRIANGLES);
105 FOR(i, SPHERE_MODEL_NB_TRIANGLES)FOR(j, 3) {
106 render->facets.set_vertex(off_f + i, j, off_v + SPHERE_MODEL_TRIANGLES[i][j]);
107 }
108 }
109
110 }
111 }
112
113
114 void view_U_locks(Mesh* m, Mesh* render, double scale_in,bool extractall) {
115 double scale =scale_in;
116 if (!m->vertices.attributes().is_defined("B")) return;
117 if (!m->vertices.attributes().is_defined("lockU")) return;
118
119 Attribute<mat3> B(m->vertices.attributes(), "B");
120 Attribute<vec3> lockU(m->vertices.attributes(), "lockU");// how many dimensions are locked
121
122
123 if (m->cells.nb() > 0)
124 scale *= get_cell_average_edge_size(m);
125 else {
126 double ave = 0;
127 FOR(f, m->facets.nb())FOR(e, m->facets.nb_vertices(f))
128 ave += (X(m)[m->facets.vertex(f, e)] - X(m)[m->facets.vertex(f, (e + 1) % m->facets.nb_vertices(f))]).length();
129 ave /= m->facet_corners.nb();
130 scale *= ave;
131 }
132
133 Attribute<double> orient(render->edges.attributes(), "orient");
134 render->clear();
135 FOR(v, m->vertices.nb()) {
136 vec3 dir[3];
137 FOR(i, 3)dir[i] = col(B[v], i);
138
139 int extracteddim = 0;
140 for (index_t dim = 0; dim < 3; dim++) {
141 if (lockU[v][dim] == 0 && !extractall) continue;
142 extracteddim++;
143 vec3 x = scale * dir[dim];
144 index_t off_v = render->vertices.create_vertices(2);
145 X(render)[off_v] = X(m)[v] + x ;
146 X(render)[off_v + 1] = X(m)[v] - x ;
147 index_t f = render->edges.create_edge(off_v + 0, off_v + 1);
148 //orient[f] = dim;
149 orient[f] = extracteddim;
150 }
151 }
152 }
153
154
155 }
156