Removed also from this file the deprecated dependencies from linalg. NOW EVERY PIECE OF THE VCG relies on eigen for linalgebra.
This commit is contained in:
parent
72d67f4a11
commit
12543d68a2
|
|
@ -30,8 +30,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vcg/math/base.h>
|
#include <vcg/math/base.h>
|
||||||
#include <vcg/math/matrix.h>
|
|
||||||
#include <vcg/math/lin_algebra.h>
|
|
||||||
#include <vcg/simplex/face/topology.h>
|
#include <vcg/simplex/face/topology.h>
|
||||||
#include <vcg/complex/algorithms/update/normal.h>
|
#include <vcg/complex/algorithms/update/normal.h>
|
||||||
#include <vcg/complex/algorithms/update/topology.h>
|
#include <vcg/complex/algorithms/update/topology.h>
|
||||||
|
|
@ -39,6 +37,7 @@
|
||||||
#include <vcg/complex/algorithms/clean.h>
|
#include <vcg/complex/algorithms/clean.h>
|
||||||
#include <vcg/space/point3.h>
|
#include <vcg/space/point3.h>
|
||||||
#include "emc_lookup_table.h"
|
#include "emc_lookup_table.h"
|
||||||
|
#include <eigenlib/Eigen/SVD>
|
||||||
|
|
||||||
namespace vcg
|
namespace vcg
|
||||||
{
|
{
|
||||||
|
|
@ -336,45 +335,58 @@ namespace vcg
|
||||||
rank = (c > cos(_featureAngle) ? 2 : 3);
|
rank = (c > cos(_featureAngle) ? 2 : 3);
|
||||||
|
|
||||||
// setup linear system (find intersection of tangent planes)
|
// setup linear system (find intersection of tangent planes)
|
||||||
vcg::ndim::Matrix<double> A((unsigned int) vertices_num, 3);
|
//--vcg::ndim::Matrix<double> A((unsigned int) vertices_num, 3);
|
||||||
double *b = new double[ vertices_num ];
|
Eigen::MatrixXd A(vertices_num,3);
|
||||||
|
|
||||||
|
//--double *b = new double[ vertices_num ];
|
||||||
|
Eigen::MatrixXd b(vertices_num,1);
|
||||||
|
|
||||||
for (i=0; i<vertices_num; ++i)
|
for (i=0; i<vertices_num; ++i)
|
||||||
{
|
{
|
||||||
A[i][0] = normals[i][0];
|
//--A[i][0] = normals[i][0];
|
||||||
A[i][1] = normals[i][1];
|
//--A[i][1] = normals[i][1];
|
||||||
A[i][2] = normals[i][2];
|
//--A[i][2] = normals[i][2];
|
||||||
b[i] = (points[i] * normals[i]);
|
//--b[i] = (points[i] * normals[i]);
|
||||||
|
A(i,0) = normals[i][0];
|
||||||
|
A(i,0) = normals[i][1];
|
||||||
|
A(i,0) = normals[i][2];
|
||||||
|
b(i) = (points[i] * normals[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SVD of matrix A
|
// SVD of matrix A
|
||||||
vcg::ndim::Matrix<double> V(3, 3);
|
Eigen::JacobiSVD<Eigen::MatrixXd> svd(A);
|
||||||
double *w = new double[vertices_num];
|
Eigen::MatrixXd sol(3,1);
|
||||||
vcg::SingularValueDecomposition< typename vcg::ndim::Matrix<double> > (A, w, V, LeaveUnsorted, 100);
|
sol=svd.solve(b);
|
||||||
|
|
||||||
|
// vcg::ndim::Matrix<double> V(3, 3);
|
||||||
|
// double *w = new double[vertices_num];
|
||||||
|
// vcg::SingularValueDecomposition< typename vcg::ndim::Matrix<double> > (A, w, V, LeaveUnsorted, 100);
|
||||||
|
|
||||||
// rank == 2 -> suppress smallest singular value
|
// rank == 2 -> suppress smallest singular value
|
||||||
if (rank == 2)
|
// if (rank == 2)
|
||||||
{
|
// {
|
||||||
double smin = DBL_MAX; // the max value, as defined in <float.h>
|
// double smin = DBL_MAX; // the max value, as defined in <float.h>
|
||||||
unsigned int sminid = 0;
|
// unsigned int sminid = 0;
|
||||||
unsigned int srank = std::min< unsigned int >(vertices_num, 3u);
|
// unsigned int srank = std::min< unsigned int >(vertices_num, 3u);
|
||||||
|
|
||||||
for (i=0; i<srank; ++i)
|
// for (i=0; i<srank; ++i)
|
||||||
{
|
// {
|
||||||
if (w[i] < smin)
|
// if (w[i] < smin)
|
||||||
{
|
// {
|
||||||
smin = w[i];
|
// smin = w[i];
|
||||||
sminid = i;
|
// sminid = i;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
w[sminid] = 0.0;
|
// w[sminid] = 0.0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// SVD backsubstitution -> least squares, least norm solution x
|
// // SVD backsubstitution -> least squares, least norm solution x
|
||||||
double *x = new double[3];
|
// double *x = new double[3];
|
||||||
vcg::SingularValueBacksubstitution< vcg::ndim::Matrix<double> >(A, w, V, x, b);
|
// vcg::SingularValueBacksubstitution< vcg::ndim::Matrix<double> >(A, w, V, x, b);
|
||||||
|
|
||||||
// transform x to world coords
|
// transform x to world coords
|
||||||
CoordType point((ScalarType) x[0], (ScalarType) x[1], (ScalarType) x[2]);
|
//--CoordType point((ScalarType) x[0], (ScalarType) x[1], (ScalarType) x[2]);
|
||||||
|
CoordType point((ScalarType) sol[0], (ScalarType) sol[1], (ScalarType) sol[2]);
|
||||||
point += center;
|
point += center;
|
||||||
|
|
||||||
// Safety check if the feature point found by svd is
|
// Safety check if the feature point found by svd is
|
||||||
|
|
@ -386,7 +398,7 @@ namespace vcg
|
||||||
mean_point->SetUserBit(_featureFlag);
|
mean_point->SetUserBit(_featureFlag);
|
||||||
mean_point->P() = point;
|
mean_point->P() = point;
|
||||||
mean_point->N().SetZero();
|
mean_point->N().SetZero();
|
||||||
delete []x;
|
// delete []x;
|
||||||
delete []points;
|
delete []points;
|
||||||
delete []normals;
|
delete []normals;
|
||||||
return mean_point;
|
return mean_point;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue