17 #include <Information.hpp> 24 #define CIMat cimg_library::CImg<float> 25 #define CIMatL cimg_library::CImgList<float> 37 virtual float measure(
float ev1,
float ev2) = 0;
38 virtual std::string get_type() = 0;
44 float measure(
float ev1,
float ev2) {
47 std::string get_type() {
57 float measure(
float ev1,
float ev2) {
58 return (ev1 * ev1) + (ev2 * ev2);
60 std::string get_type() {
70 float measure(
float ev1,
float ev2) {
71 return sqrt((ev1 * ev1) + (ev2 * ev2));
73 std::string get_type() {
74 return "rootsumsquare";
83 float measure(
float ev1,
float ev2) {
84 return (ev1 + ev2) / 2;
86 std::string get_type() {
96 float measure(
float ev1,
float ev2) {
97 return std::min(fabs(ev1), fabs(ev2));
99 std::string get_type() {
109 float measure(
float ev1,
float ev2) {
110 return std::max(fabs(ev1), fabs(ev2));
112 std::string get_type() {
122 float measure(
float ev1,
float ev2) {
125 std::string get_type() {
135 float measure(
float ev1,
float ev2) {
136 return (ev1 * ev2 < 0 ? -1.0f : 1.0f) * (fabs(ev1) + fabs(ev2)) / 2.0f;
138 std::string get_type() {
139 return "signedaverageabs";
165 else if(s ==
"average")
167 else if(s ==
"minimal")
169 else if(s ==
"maximal")
171 else if(s ==
"sumsquare")
173 else if(s ==
"rootsumsquare")
175 else if(s ==
"signedaverageabs")
177 else if(s ==
"anisotropy")
195 cM = copy.cM->copy();
204 void update(
const std::vector<Point3f>& pos,
const std::vector<Point3f>& nrml)
208 if(nrml.size() > 0 && nrml.size() == pos.size()) {
211 update_local_Basis(nrml[0]);
214 int cnt = pos.size();
215 CIMat X = CIMat(7, 3 * (cnt - 1));
216 CIMat b = CIMat(1, 3 * (cnt - 1));
220 for(
int i = 1; i < cnt; i++) {
233 X(0,
id) = 0.5 * w1 * w1;
235 X(2,
id) = 0.5 * w2 * w2;
236 X(3,
id) = w1 * w1 * w1;
237 X(4,
id) = w1 * w1 * w2;
238 X(5,
id) = w1 * w2 * w2;
239 X(6,
id) = w2 * w2 * w2;
246 X(3,
id) = 3 * w1 * w1;
247 X(4,
id) = 2 * w1 * w2;
258 X(5,
id) = 2 * w1 * w2;
259 X(6,
id) = 3 * w2 * w2;
263 CIMat Xt = X.get_transpose();
270 if(!isnan(det) && !(det == 0)) {
276 W(1, 0) = W(0, 1) = b[1];
280 CIMatL bL = W.get_symmetric_eigen();
283 ed1 = -bL(1)(0, 0) * b1 - bL(1)(0, 1) * b2;
284 ed2 = -bL(1)(1, 0) * b1 - bL(1)(1, 1) * b2;
285 if(fabs(ev1) < fabs(ev2)) {
295 Information::out <<
"Error calculating curvature" << endl;
308 void get_eigenValues(
float& eval1,
float& eval2)
316 float get_curvature() {
317 return cM->measure(ev1, ev2);
321 std::string get_type() {
322 return cM->get_type();
336 void update_local_Basis(
Point3f nrml)
338 nrml = nrml / nrml.
norm();
340 b1 =
Point3f(cimg_library::cimg::rand(), cimg_library::cimg::rand(), cimg_library::cimg::rand());
342 }
while(fabs(b1 * nrml) == 1);
343 b1 = b1 - (b1 * nrml) * nrml;
Definition: Curvature.hpp:94
Definition: Curvature.hpp:107
Definition: Curvature.hpp:55
CU_HOST_DEVICE T norm() const
Euclidean norm of the vector.
Definition: Vector.hpp:532
Definition: Curvature.hpp:42
Definition: Curvature.hpp:146
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Definition: Curvature.hpp:68
Definition: Curvature.hpp:120
Definition: Curvature.hpp:133
Definition: Curvature.hpp:33
Definition: Curvature.hpp:81