Commit def134ab authored by Sauvage's avatar Sauvage

curvature Normal Cycles : collector en parametre

parent a49da21c
......@@ -27,6 +27,8 @@
#include "Geometry/basic.h"
#include "Algo/Selection/collector.h"
#include "Utils/convertType.h"
#include "OpenNL/linear_solver.h"
......@@ -94,6 +96,7 @@ template <typename PFP>
void cubicFittingAddVertexNormal(typename PFP::VEC3& v, typename PFP::VEC3& n, typename PFP::VEC3& p, typename PFP::MATRIX33& localFrame) ;
*/
/* normal cycles by [ACDLD03] : useful for parallel computing*/
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
typename PFP::MAP& map,
......@@ -134,6 +137,38 @@ void normalCycles_SortAndSetEigenComponents(
const typename PFP::VEC3& normal,
unsigned int thread=0) ;
/* normal cycles with collector as a parameter : not usable in parallel */
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
typename PFP::MAP& map,
Algo::Selection::Collector<PFP> & neigh,
const VertexAttribute<typename PFP::VEC3>& position,
const VertexAttribute<typename PFP::VEC3>& normal,
const EdgeAttribute<typename PFP::REAL>& edgeangle,
VertexAttribute<typename PFP::REAL>& kmax,
VertexAttribute<typename PFP::REAL>& kmin,
VertexAttribute<typename PFP::VEC3>& Kmax,
VertexAttribute<typename PFP::VEC3>& Kmin,
VertexAttribute<typename PFP::VEC3>& Knormal,
const FunctorSelect& select = allDarts, unsigned int thread=0) ;
template <typename PFP>
void computeCurvatureVertex_NormalCycles(
typename PFP::MAP& map,
Dart dart,
Algo::Selection::Collector<PFP> & neigh,
const VertexAttribute<typename PFP::VEC3>& position,
const VertexAttribute<typename PFP::VEC3>& normal,
const EdgeAttribute<typename PFP::REAL>& edgeangle,
VertexAttribute<typename PFP::REAL>& kmax,
VertexAttribute<typename PFP::REAL>& kmin,
VertexAttribute<typename PFP::VEC3>& Kmax,
VertexAttribute<typename PFP::VEC3>& Kmin,
VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread=0) ;
namespace Parallel
{
template <typename PFP>
......
......@@ -26,7 +26,6 @@
#include "Geometry/matrix.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Algo/Selection/collector.h"
extern "C"
{
......@@ -332,6 +331,60 @@ void computeCurvatureVertex_NormalCycles(
normalCycles_SortAndSetEigenComponents<PFP>(ev,evec,kmax[dart],kmin[dart],Kmax[dart],Kmin[dart],Knormal[dart],normal[dart],thread);
}
template <typename PFP>
void computeCurvatureVertices_NormalCycles(
typename PFP::MAP& map,
Algo::Selection::Collector<PFP> & neigh,
const VertexAttribute<typename PFP::VEC3>& position,
const VertexAttribute<typename PFP::VEC3>& normal,
const EdgeAttribute<typename PFP::REAL>& edgeangle,
VertexAttribute<typename PFP::REAL>& kmax,
VertexAttribute<typename PFP::REAL>& kmin,
VertexAttribute<typename PFP::VEC3>& Kmax,
VertexAttribute<typename PFP::VEC3>& Kmin,
VertexAttribute<typename PFP::VEC3>& Knormal,
const FunctorSelect& select, unsigned int thread)
{
TraversorV<typename PFP::MAP> t(map, select) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
computeCurvatureVertex_NormalCycles<PFP>(map, d, neigh, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal,thread) ;
}
template <typename PFP>
void computeCurvatureVertex_NormalCycles(
typename PFP::MAP& map,
Dart dart,
Algo::Selection::Collector<PFP> & neigh,
const VertexAttribute<typename PFP::VEC3>& position,
const VertexAttribute<typename PFP::VEC3>& normal,
const EdgeAttribute<typename PFP::REAL>& edgeangle,
VertexAttribute<typename PFP::REAL>& kmax,
VertexAttribute<typename PFP::REAL>& kmin,
VertexAttribute<typename PFP::VEC3>& Kmax,
VertexAttribute<typename PFP::VEC3>& Kmin,
VertexAttribute<typename PFP::VEC3>& Knormal, unsigned int thread)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
typedef Geom::Matrix<3,3,REAL> MATRIX;
typedef Eigen::Matrix<REAL,3,1> E_VEC3;
typedef Eigen::Matrix<REAL,3,3> E_MATRIX;
// collect the normal cycle tensor
neigh.collectAll(dart) ;
MATRIX tensor(0) ;
neigh.computeNormalCyclesTensor(position, edgeangle,tensor);
// solve eigen problem
Eigen::SelfAdjointEigenSolver<E_MATRIX> solver (Utils::convertRef<E_MATRIX>(tensor));
const VEC3& ev = Utils::convertRef<VEC3>(solver.eigenvalues());
const MATRIX& evec = Utils::convertRef<MATRIX>(solver.eigenvectors());
normalCycles_SortAndSetEigenComponents<PFP>(ev,evec,kmax[dart],kmin[dart],Kmax[dart],Kmin[dart],Knormal[dart],normal[dart],thread);
}
template <typename PFP>
void normalCycles_SortAndSetEigenComponents(
const typename PFP::VEC3& e_val,
......
......@@ -113,11 +113,11 @@ public:
template <typename PPFP>
friend std::ostream& operator<<(std::ostream &out, const Collector<PPFP>& c);
REAL computeArea (const VertexAttribute<VEC3>& pos) {
virtual REAL computeArea (const VertexAttribute<VEC3>& pos) {
assert(!"Warning: Collector<PFP>::computeArea() should be overloaded in non-virtual derived classes");
return 0.0;
}
void computeNormalCyclesTensor (const VertexAttribute<VEC3>& pos, const EdgeAttribute<REAL>& edgeangle, typename PFP::MATRIX33&) {assert(!"Warning: Collector<PFP>::computeNormalCyclesTensor() should be overloaded in non-virtual derived classes"); }
virtual void computeNormalCyclesTensor (const VertexAttribute<VEC3>& pos, const EdgeAttribute<REAL>& edgeangle, typename PFP::MATRIX33&) {assert(!"Warning: Collector<PFP>::computeNormalCyclesTensor() should be overloaded in non-virtual derived classes"); }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment