| 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_FRAME_H | ||
| 41 | #define H_HEXDOM_ALGO_FRAME_H | ||
| 42 | |||
| 43 | #include <exploragram/basic/common.h> | ||
| 44 | #include <exploragram/hexdom/basic.h> | ||
| 45 | #include <exploragram/hexdom/spherical_harmonics_l4.h> // to compute average_frame(vector<mat3>& data) and representative_frame | ||
| 46 | #include <cmath> | ||
| 47 | |||
| 48 | |||
| 49 | namespace GEO { | ||
| 50 | |||
| 51 | /*** | ||
| 52 | * ___ __ __ __ | ||
| 53 | * |\/| /\ | |__) /\ /__` | / ` | ||
| 54 | * | | /~~\ | |__) /~~\ .__/ | \__, | ||
| 55 | * | ||
| 56 | */ | ||
| 57 | |||
| 58 | ✗ | inline bool is_identity_auvp(const mat3& m, double eps = 1e-15) { | |
| 59 | // [BL] TODO: test extra-diagonal elements ? (can be a big cow without that !!!) | ||
| 60 | ✗ | return std::abs(m(0, 0) - 1.) < eps && std::abs(m(1, 1) - 1.) < eps && std::abs(m(2, 2) - 1.) < eps; | |
| 61 | } | ||
| 62 | |||
| 63 | mat3 EXPLORAGRAM_API normalize_columns(const mat3& B); | ||
| 64 | mat3 EXPLORAGRAM_API invert_columns_norm(const mat3& B); | ||
| 65 | |||
| 66 | /*** | ||
| 67 | * ___ ___ ___ __ __ __ ___ | ||
| 68 | * |\/| /\ | |__ | | | |__ |__) |__) / \ | | ||
| 69 | * | | /~~\ | |___ \__/ |___ |___ | \ | \ \__/ | | ||
| 70 | * | ||
| 71 | */ | ||
| 72 | |||
| 73 | mat3 EXPLORAGRAM_API rotx(double angle); | ||
| 74 | mat3 EXPLORAGRAM_API roty(double angle); | ||
| 75 | mat3 EXPLORAGRAM_API rotz(double angle); | ||
| 76 | |||
| 77 | // non optimized version is "return rotz(xyz[2]) *roty(xyz[1]) *rotx(xyz[0]);" | ||
| 78 | mat3 euler_to_mat3(vec3 xyz); | ||
| 79 | |||
| 80 | //http://www.staff.city.ac.uk/~sbbh653/publications/euler.pdf | ||
| 81 | vec3 mat3_to_euler(const mat3& r); | ||
| 82 | |||
| 83 | /*** | ||
| 84 | * __ __ ___ __ ___ ___ __ | ||
| 85 | * /\ \_/ | /__` |__) |__ |__) |\/| | | | /\ | | / \ |\ | | ||
| 86 | * /~~\ / \ | .__/ | |___ | \ | | \__/ | /~~\ | | \__/ | \| | ||
| 87 | * | ||
| 88 | */ | ||
| 89 | |||
| 90 | |||
| 91 | struct EXPLORAGRAM_API AxisPermutation { | ||
| 92 | ✗ | AxisPermutation(index_t id=0) { mid = id; } | |
| 93 | void aligns_B_wrt_ref(mat3 ref, mat3 B); | ||
| 94 | void make_col2_equal_to_z(mat3 B, vec3 z); | ||
| 95 | const mat3& get_mat() const; | ||
| 96 | bool is_identity() { return mid == 0; } | ||
| 97 | double operator()(index_t i, index_t j) {return get_mat()(i, j); } | ||
| 98 | AxisPermutation inverse(); | ||
| 99 | |||
| 100 | index_t mid; | ||
| 101 | }; | ||
| 102 | |||
| 103 | ✗ | inline vec3i operator*(const AxisPermutation& p, const vec3i& v) { return p.get_mat()*v; } | |
| 104 | ✗ | inline vec3 operator*(const AxisPermutation& p, const vec3& v) { return p.get_mat()*v; } | |
| 105 | |||
| 106 | /*** | ||
| 107 | * ___ __ ___ | ||
| 108 | * |__ |__) /\ |\/| |__ | ||
| 109 | * | | \ /~~\ | | |___ | ||
| 110 | * | ||
| 111 | */ | ||
| 112 | |||
| 113 | struct EXPLORAGRAM_API Frame { | ||
| 114 | mat3& r; | ||
| 115 | ✗ | Frame(mat3& M) :r(M) {} | |
| 116 | |||
| 117 | ✗ | inline mat3 apply_permutation(AxisPermutation& ap) {return r*ap.get_mat();} | |
| 118 | |||
| 119 | void make_z_equal_to(vec3 z); | ||
| 120 | |||
| 121 | static mat3 average_frame(vector<mat3>& data); | ||
| 122 | static mat3 representative_frame(vector<vec3>& bunch_of_vectors, vector<double>& w); | ||
| 123 | static mat3 representative_frame(vector<vec3>& bunch_of_vectors); | ||
| 124 | }; | ||
| 125 | |||
| 126 | /*** | ||
| 127 | * ___ ___ ___ __ __ __ | ||
| 128 | * |__ |__ | / \ / \ | /__` | ||
| 129 | * | | | \__/ \__/ |___ .__/ | ||
| 130 | * | ||
| 131 | */ | ||
| 132 | |||
| 133 | AxisPermutation EXPLORAGRAM_API Rij(Mesh* m, Attribute<mat3>& B, index_t i, index_t j); | ||
| 134 | |||
| 135 | bool EXPLORAGRAM_API triangle_is_frame_singular(Mesh* m, Attribute<mat3>& B, index_t c, index_t cf); | ||
| 136 | |||
| 137 | bool triangle_is_frame_singular___give_stable_direction(Mesh* m, int& stable_dir_index, Attribute<mat3>& B, index_t c, index_t cf, index_t cfv=0); | ||
| 138 | bool triangle_is_frame_singular___give_stable_direction(Mesh* m, vec3& stable_dir_geom, Attribute<mat3>& B, index_t c, index_t cf, index_t cfv=0); | ||
| 139 | } | ||
| 140 | |||
| 141 | #endif | ||
| 142 |