merge curvature stuff into this

This commit is contained in:
2021-11-12 17:08:19 +01:00
parent d51945ecaf
commit d01ba47b65
19 changed files with 672 additions and 129 deletions

163
src/curvature.h Normal file
View File

@ -0,0 +1,163 @@
#ifndef CURVATURE_H
#define CURVATURE_H
#include "my_mesh.h"
class MyQuad {
double _coefs[5] ; // a_0 x^2 + a1 xy + a2 y^2 + a3 x + a4 y + a5
public:
Eigen::AngleAxisd _r ;
Eigen::Translation3d _t ;
MyQuad(double *data,
const Eigen::AngleAxisd &r = Eigen::AngleAxisd(0, Eigen::Vector3d(0,0,1)),
const Eigen::Translation3d &t = Eigen::Translation3d(0,0,0))
: _r(r), _t(t)
{
for (size_t i=0; i<5; i++)
_coefs[i] = data[i] ;
}
MyQuad(const Eigen::VectorXd &v,
const Eigen::AngleAxisd &r = Eigen::AngleAxisd(0, Eigen::Vector3d(0,0,1)),
const Eigen::Translation3d &t = Eigen::Translation3d(0,0,0))
: _r(r), _t(t)
{
for (size_t i=0; i<5; i++)
_coefs[i] = v[i] ;
}
MyQuad(double a0=0, double a1=0, double a2=0, double a3=0, double a4=0,
const Eigen::AngleAxisd &r = Eigen::AngleAxisd(0, Eigen::Vector3d(0,0,1)),
const Eigen::Translation3d &t = Eigen::Translation3d(0,0,0))
: _r(r), _t(t)
{
_coefs[0] = a0 ;
_coefs[1] = a1 ;
_coefs[2] = a2 ;
_coefs[3] = a3 ;
_coefs[4] = a4 ;
}
MyQuad(const MyQuad &q) : _r(q._r), _t(q._t)
{
for (size_t i=0; i<5; i++)
_coefs[i] = q._coefs[i] ;
}
MyQuad &operator=(const MyQuad &q) {
_r = q._r;
_t = q._t;
for (size_t i=0; i<5; i++)
_coefs[i] = q._coefs[i] ;
return *this;
}
double & operator[] (size_t i) {return _coefs[i] ; }
double quad_fun (double x, double y)
{
return _coefs[0] * x*x + _coefs[1] * x*y + _coefs[2] * y*y + _coefs[3] * x + _coefs[4] * y ;
}
double quad_fun (const OpenMesh::Vec2d &v)
{
return quad_fun(v[0], v[1]) ;
}
};
template <typename T>
class MyStats {
private:
std::vector<T> _distrib ;
public:
MyStats () {} ;
void push_back (T data)
{
_distrib.push_back(data) ;
}
T min ()
{
T tmp = _distrib.at(0) ;
for (size_t i=1 ; i<_distrib.size(); i++)
{
if (_distrib.at(i) < tmp)
tmp = _distrib.at(i) ;
}
return tmp ;
}
T max ()
{
T tmp = _distrib.at(0) ;
for (size_t i=1 ; i<_distrib.size(); i++)
{
if (_distrib.at(i) > tmp)
tmp = _distrib.at(i) ;
}
return tmp ;
}
T mean ()
{
T acc(0) ;
std::cout << "acc : " << acc << std::endl;
if (_distrib.size() > 0)
{
for(size_t i=0; i<_distrib.size(); i++)
{
acc += _distrib.at(i) ;
}
return acc/(_distrib.size()) ;
}
else
return acc ;
}
T stdev ()
{
return stdev(mean());
}
T stdev (T m)
{
T acc(0), tmp ;
if (_distrib.size() > 0)
{
for(size_t i=0; i<_distrib.size(); i++)
{
tmp = _distrib.at(i) - m ;
acc += tmp * tmp ;
}
return sqrt(acc/(_distrib.size())) ;
}
else
return acc ;
}
};
class Courbures {
private:
MyMesh &_mesh ;
public:
OpenMesh::VPropHandleT<double> vprop_K;
OpenMesh::VPropHandleT<double> vprop_H;
OpenMesh::VPropHandleT<MyQuad> vprop_quad;
Courbures(MyMesh &mesh) : _mesh(mesh) {}
void set_fixed_colors() ;
void normales_locales() ;
std::vector<MyMesh::VertexHandle> get_two_neighborhood(MyMesh::VertexHandle vh);
MyQuad fit_quad(MyMesh::VertexHandle vh) ;
void compute_KH() ;
void set_K_colors() ;
};
#endif