GCC Code Coverage Report


Directory: ./
File: lib/exploragram/hexdom/spherical_harmonics_l4.h
Date: 2026-09-07 02:37:58
Exec Total Coverage
Lines: 0 39 0.0%
Functions: 0 14 0.0%
Branches: 0 12 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_HEXDOM_ALGO_SPHERICALHARMONICSL4_H
41 #define H_HEXDOM_ALGO_SPHERICALHARMONICSL4_H
42
43 #include <exploragram/basic/common.h>
44 #include <exploragram/hexdom/basic.h>
45 #include <geogram/mesh/mesh.h>
46 #include <geogram/basic/attributes.h>
47
48 namespace GEO {
49
50 struct EXPLORAGRAM_API SphericalHarmonicL4 {
51 vecng<9, Numeric::float64> coeff;
52
53 SphericalHarmonicL4() {
54 FOR(i, 9) coeff[i] = 0.;
55 }
56
57 SphericalHarmonicL4(const vecng<9, Numeric::float64>& rhs) : coeff(rhs){
58 }
59
60 SphericalHarmonicL4(double *fv) {
61 FOR(i, 9) coeff[i] = fv[i];
62 }
63
64 SphericalHarmonicL4(
65 double x0, double x1, double x2,
66 double x3, double x4, double x5,
67 double x6, double x7, double x8
68 ) {
69 coeff[0] = x0; coeff[1] = x1; coeff[2] = x2;
70 coeff[3] = x3; coeff[4] = x4; coeff[5] = x5;
71 coeff[6] = x6; coeff[7] = x7; coeff[8] = x8;
72 }
73
74 double& operator[](index_t i) {
75 geo_debug_assert(i<9);
76 return coeff[i];
77 }
78
79 double norm() const {
80 return coeff.length();
81 }
82
83 double operator *(const SphericalHarmonicL4 &other) const {
84 return dot(coeff, other.coeff);
85 }
86
87 SphericalHarmonicL4 operator -(const SphericalHarmonicL4 &other) const {
88 return SphericalHarmonicL4(coeff - other.coeff);
89 }
90
91 SphericalHarmonicL4 operator *(double s) const {
92 return SphericalHarmonicL4(s*coeff);
93 }
94
95 SphericalHarmonicL4 operator /(double s) const {
96 return SphericalHarmonicL4(coeff / s);
97 }
98
99 SphericalHarmonicL4 operator +(const SphericalHarmonicL4 &v) const {
100 return SphericalHarmonicL4(coeff + v.coeff);
101 }
102
103 double value(const vec3& v) const {
104 double res = 0;
105 FOR(i, 9)res += coeff[i]*basis(i,v);
106 return res;
107 }
108
109 static double basis(index_t id, const vec3& v);
110
111 void Rz(double alpha);
112 void Ry(double alpha);
113 void Rx(double alpha);
114
115 void euler_rot(const vec3& rot_vec) {
116 Rx(rot_vec[0]);
117 Ry(rot_vec[1]);
118 Rz(rot_vec[2]);
119 }
120
121 SphericalHarmonicL4 Ex() const;
122 SphericalHarmonicL4 Ey() const;
123 SphericalHarmonicL4 Ez() const;
124
125 static SphericalHarmonicL4 rest_frame() {
126 return SphericalHarmonicL4(0, 0, 0, 0, std::sqrt(7. / 12.), 0, 0, 0, std::sqrt(5. / 12.));
127 }
128
129 mat3 project_mat3(double grad_threshold = 1e-3, double dot_threshold = 1e-5, vec3* euler_prev = nullptr);
130
131 };
132
133 inline std::istream& operator>> (std::istream& input, SphericalHarmonicL4 &gna) {
134 return input >> gna.coeff;
135 }
136
137 inline std::ostream& operator<< (std::ostream& output, const SphericalHarmonicL4 &gna) {
138 return output << gna.coeff;
139 }
140
141 /*
142 template <> struct can_be_used_as_attribute<SphericalHarmonicL4> {
143 static constexpr auto value = std::integral_constant<bool,true>();
144 };
145 */
146 }
147
148
149 #endif //__SPHERICALHARMONICSL4_H__
150