Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
CurvatureCalculator Class Reference
+ Collaboration diagram for CurvatureCalculator:

Classes

class  Quadric
 

Public Member Functions

IGL_INLINE CurvatureCalculator ()
 
IGL_INLINE void init (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
 
IGL_INLINE void finalEigenStuff (int, const std::vector< Eigen::Vector3d > &, Quadric &)
 
IGL_INLINE void fitQuadric (const Eigen::Vector3d &, const std::vector< Eigen::Vector3d > &ref, const std::vector< int > &, Quadric *)
 
IGL_INLINE void applyProjOnPlane (const Eigen::Vector3d &, const std::vector< int > &, std::vector< int > &)
 
IGL_INLINE void getSphere (const int, const double, std::vector< int > &, int min)
 
IGL_INLINE void getKRing (const int, const double, std::vector< int > &)
 
IGL_INLINE Eigen::Vector3d project (const Eigen::Vector3d &, const Eigen::Vector3d &, const Eigen::Vector3d &)
 
IGL_INLINE void computeReferenceFrame (int, const Eigen::Vector3d &, std::vector< Eigen::Vector3d > &)
 
IGL_INLINE void getAverageNormal (int, const std::vector< int > &, Eigen::Vector3d &)
 
IGL_INLINE void getProjPlane (int, const std::vector< int > &, Eigen::Vector3d &)
 
IGL_INLINE void applyMontecarlo (const std::vector< int > &, std::vector< int > *)
 
IGL_INLINE void computeCurvature ()
 
IGL_INLINE void printCurvature (const std::string &outpath)
 
IGL_INLINE double getAverageEdge ()
 

Static Public Member Functions

static IGL_INLINE int rotateForward (double *v0, double *v1, double *v2)
 
static IGL_INLINE void rotateBackward (int nr, double *v0, double *v1, double *v2)
 
static IGL_INLINE Eigen::Vector3d chooseMax (Eigen::Vector3d n, Eigen::Vector3d abc, double ab)
 

Public Attributes

std::vector< std::vector< double > > curv
 
std::vector< std::vector< Eigen::Vector3d > > curvDir
 
bool curvatureComputed
 
Eigen::MatrixXd vertices
 
Eigen::MatrixXi faces
 
std::vector< std::vector< int > > vertex_to_vertices
 
std::vector< std::vector< int > > vertex_to_faces
 
std::vector< std::vector< int > > vertex_to_faces_index
 
Eigen::MatrixXd face_normals
 
Eigen::MatrixXd vertex_normals
 
double sphereRadius
 
int kRing
 
bool localMode
 
bool projectionPlaneCheck
 
bool montecarlo
 
unsigned int montecarloN
 
searchType st
 
normalType nt
 
double lastRadius
 
double scaledRadius
 
std::string lastMeshName
 
bool expStep
 
int step
 
int maxSize
 

Detailed Description

Constructor & Destructor Documentation

◆ CurvatureCalculator()

IGL_INLINE CurvatureCalculator::CurvatureCalculator ( )
305{
306 this->localMode=true;
307 this->projectionPlaneCheck=true;
308 this->sphereRadius=5;
309 this->st=SPHERE_SEARCH;
310 this->nt=AVERAGE;
311 this->montecarlo=false;
312 this->montecarloN=0;
313 this->kRing=3;
314 this->curvatureComputed=false;
315 this->expStep=true;
316}
bool projectionPlaneCheck
Definition principal_curvature.cpp:160
double sphereRadius
Definition principal_curvature.cpp:156
bool montecarlo
Definition principal_curvature.cpp:161
bool curvatureComputed
Definition principal_curvature.cpp:50
normalType nt
Definition principal_curvature.cpp:165
bool localMode
Definition principal_curvature.cpp:159
int kRing
Definition principal_curvature.cpp:157
unsigned int montecarloN
Definition principal_curvature.cpp:162
bool expStep
Definition principal_curvature.cpp:172
searchType st
Definition principal_curvature.cpp:164
@ AVERAGE
Definition principal_curvature.cpp:35
@ SPHERE_SEARCH
Definition principal_curvature.cpp:29

References AVERAGE, curvatureComputed, expStep, kRing, localMode, montecarlo, montecarloN, nt, projectionPlaneCheck, SPHERE_SEARCH, sphereRadius, and st.

Member Function Documentation

◆ applyMontecarlo()

IGL_INLINE void CurvatureCalculator::applyMontecarlo ( const std::vector< int > &  vin,
std::vector< int > *  vout 
)
635{
636 if (montecarloN >= vin.size ())
637 {
638 *vout = vin;
639 return;
640 }
641
642 float p = ((float) montecarloN) / (float) vin.size();
643 for (std::vector<int>::const_iterator vpi = vin.begin(); vpi != vin.end(); ++vpi)
644 {
645 float r;
646 if ((r = ((float)rand () / RAND_MAX)) < p)
647 {
648 vout->push_back(*vpi);
649 }
650 }
651}

References montecarloN.

Referenced by computeCurvature().

+ Here is the caller graph for this function:

◆ applyProjOnPlane()

IGL_INLINE void CurvatureCalculator::applyProjOnPlane ( const Eigen::Vector3d &  ppn,
const std::vector< int > &  vin,
std::vector< int > &  vout 
)
628{
629 for (std::vector<int>::const_iterator vpi = vin.begin(); vpi != vin.end(); ++vpi)
630 if (vertex_normals.row(*vpi) * ppn > 0.0)
631 vout.push_back(*vpi);
632}
Eigen::MatrixXd vertex_normals
Definition principal_curvature.cpp:153

References vertex_normals.

Referenced by computeCurvature().

+ Here is the caller graph for this function:

◆ chooseMax()

static IGL_INLINE Eigen::Vector3d CurvatureCalculator::chooseMax ( Eigen::Vector3d  n,
Eigen::Vector3d  abc,
double  ab 
)
inlinestatic
224 {
225 int max_i;
226 double max_sp;
227 Eigen::Vector3d nt[8];
228
229 n.normalize ();
230 abc.normalize ();
231
232 max_sp = - std::numeric_limits<double>::max();
233
234 for (int i = 0; i < 4; ++i)
235 {
236 nt[i] = n;
237 if (ab > 0)
238 {
239 switch (i)
240 {
241 case 0:
242 break;
243
244 case 1:
245 nt[i][2] = -n[2];
246 break;
247
248 case 2:
249 nt[i][0] = -n[0];
250 nt[i][1] = -n[1];
251 break;
252
253 case 3:
254 nt[i][0] = -n[0];
255 nt[i][1] = -n[1];
256 nt[i][2] = -n[2];
257 break;
258 }
259 }
260 else
261 {
262 switch (i)
263 {
264 case 0:
265 nt[i][0] = -n[0];
266 break;
267
268 case 1:
269 nt[i][1] = -n[1];
270 break;
271
272 case 2:
273 nt[i][0] = -n[0];
274 nt[i][2] = -n[2];
275 break;
276
277 case 3:
278 nt[i][1] = -n[1];
279 nt[i][2] = -n[2];
280 break;
281 }
282 }
283
284 if (nt[i].dot(abc) > max_sp)
285 {
286 max_sp = nt[i].dot(abc);
287 max_i = i;
288 }
289 }
290 return nt[max_i];
291 }
IGL_INLINE double dot(const double *a, const double *b)
Definition dot.cpp:11

References nt.

Referenced by getProjPlane().

+ Here is the caller graph for this function:

◆ computeCurvature()

IGL_INLINE void CurvatureCalculator::computeCurvature ( )
654{
655 //CHECK che esista la mesh
656 const size_t vertices_count=vertices.rows();
657
658 if (vertices_count ==0)
659 return;
660
661 curvDir=std::vector< std::vector<Eigen::Vector3d> >(vertices_count);
662 curv=std::vector<std::vector<double> >(vertices_count);
663
664
665
667
668 std::vector<int> vv;
669 std::vector<int> vvtmp;
670 Eigen::Vector3d normal;
671
672 //double time_spent;
673 //double searchtime=0, ref_time=0, fit_time=0, final_time=0;
674
675 for (size_t i=0; i<vertices_count; ++i)
676 {
677 vv.clear();
678 vvtmp.clear();
679 Eigen::Vector3d me=vertices.row(i);
680 switch (st)
681 {
682 case SPHERE_SEARCH:
683 getSphere(i,scaledRadius,vv,6);
684 break;
685 case K_RING_SEARCH:
686 getKRing(i,kRing,vv);
687 break;
688 default:
689 fprintf(stderr,"Error: search type not recognized");
690 return;
691 }
692
693 if (vv.size()<6)
694 {
695 std::cerr << "Could not compute curvature of radius " << scaledRadius << std::endl;
696 return;
697 }
698
699
701 {
702 vvtmp.reserve (vv.size ());
703 applyProjOnPlane (vertex_normals.row(i), vv, vvtmp);
704 if (vvtmp.size() >= 6 && vvtmp.size()<vv.size())
705 vv = vvtmp;
706 }
707
708
709 switch (nt)
710 {
711 case AVERAGE:
712 getAverageNormal(i,vv,normal);
713 break;
714 case PROJ_PLANE:
715 getProjPlane(i,vv,normal);
716 break;
717 default:
718 fprintf(stderr,"Error: normal type not recognized");
719 return;
720 }
721 if (vv.size()<6)
722 {
723 std::cerr << "Could not compute curvature of radius " << scaledRadius << std::endl;
724 return;
725 }
726 if (montecarlo)
727 {
728 if(montecarloN<6)
729 break;
730 vvtmp.reserve(vv.size());
731 applyMontecarlo(vv,&vvtmp);
732 vv=vvtmp;
733 }
734
735 if (vv.size()<6)
736 return;
737 std::vector<Eigen::Vector3d> ref(3);
738 computeReferenceFrame(i,normal,ref);
739
740 Quadric q;
741 fitQuadric (me, ref, vv, &q);
742 finalEigenStuff(i,ref,q);
743 }
744
747}
IGL_INLINE void applyProjOnPlane(const Eigen::Vector3d &, const std::vector< int > &, std::vector< int > &)
Definition principal_curvature.cpp:627
std::vector< std::vector< Eigen::Vector3d > > curvDir
Definition principal_curvature.cpp:49
IGL_INLINE void getAverageNormal(int, const std::vector< int > &, Eigen::Vector3d &)
Definition principal_curvature.cpp:550
double scaledRadius
Definition principal_curvature.cpp:168
IGL_INLINE void fitQuadric(const Eigen::Vector3d &, const std::vector< Eigen::Vector3d > &ref, const std::vector< int > &, Quadric *)
Definition principal_curvature.cpp:334
IGL_INLINE void finalEigenStuff(int, const std::vector< Eigen::Vector3d > &, Quadric &)
Definition principal_curvature.cpp:362
double lastRadius
Definition principal_curvature.cpp:167
IGL_INLINE void getKRing(const int, const double, std::vector< int > &)
Definition principal_curvature.cpp:446
IGL_INLINE void computeReferenceFrame(int, const Eigen::Vector3d &, std::vector< Eigen::Vector3d > &)
Definition principal_curvature.cpp:535
IGL_INLINE void getSphere(const int, const double, std::vector< int > &, int min)
Definition principal_curvature.cpp:478
IGL_INLINE void applyMontecarlo(const std::vector< int > &, std::vector< int > *)
Definition principal_curvature.cpp:634
IGL_INLINE double getAverageEdge()
Definition principal_curvature.cpp:604
IGL_INLINE void getProjPlane(int, const std::vector< int > &, Eigen::Vector3d &)
Definition principal_curvature.cpp:563
Eigen::MatrixXd vertices
Definition principal_curvature.cpp:144
std::vector< std::vector< double > > curv
Definition principal_curvature.cpp:48
Vec< 3, T > normal(const std::array< Vec< 3, T >, 3 > &tri)
Definition Rotfinder.cpp:43
@ PROJ_PLANE
Definition principal_curvature.cpp:36
@ K_RING_SEARCH
Definition principal_curvature.cpp:30

References applyMontecarlo(), applyProjOnPlane(), AVERAGE, computeReferenceFrame(), curv, curvatureComputed, curvDir, finalEigenStuff(), fitQuadric(), getAverageEdge(), getAverageNormal(), getKRing(), getProjPlane(), getSphere(), K_RING_SEARCH, kRing, lastRadius, montecarlo, montecarloN, nt, PROJ_PLANE, projectionPlaneCheck, scaledRadius, SPHERE_SEARCH, sphereRadius, st, vertex_normals, and vertices.

Referenced by igl::principal_curvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeReferenceFrame()

IGL_INLINE void CurvatureCalculator::computeReferenceFrame ( int  i,
const Eigen::Vector3d &  normal,
std::vector< Eigen::Vector3d > &  ref 
)
536{
537
538 Eigen::Vector3d longest_v=Eigen::Vector3d(vertices.row(vertex_to_vertices[i][0]));
539
540 longest_v=(project(vertices.row(i),longest_v,normal)-Eigen::Vector3d(vertices.row(i))).normalized();
541
542 /* L'ultimo asse si ottiene come prodotto vettoriale tra i due
543 * calcolati */
544 Eigen::Vector3d y_axis=(normal.cross(longest_v)).normalized();
545 ref[0]=longest_v;
546 ref[1]=y_axis;
547 ref[2]=normal;
548}
std::vector< std::vector< int > > vertex_to_vertices
Definition principal_curvature.cpp:149
IGL_INLINE Eigen::Vector3d project(const Eigen::Vector3d &, const Eigen::Vector3d &, const Eigen::Vector3d &)
Definition principal_curvature.cpp:530

References project(), vertex_to_vertices, and vertices.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ finalEigenStuff()

IGL_INLINE void CurvatureCalculator::finalEigenStuff ( int  i,
const std::vector< Eigen::Vector3d > &  ref,
Quadric q 
)
363{
364
365 const double a = q.a();
366 const double b = q.b();
367 const double c = q.c();
368 const double d = q.d();
369 const double e = q.e();
370
371// if (fabs(a) < 10e-8 || fabs(b) < 10e-8)
372// {
373// std::cout << "Degenerate quadric: " << i << std::endl;
374// }
375
376 double E = 1.0 + d*d;
377 double F = d*e;
378 double G = 1.0 + e*e;
379
380 Eigen::Vector3d n = Eigen::Vector3d(-d,-e,1.0).normalized();
381
382 double L = 2.0 * a * n[2];
383 double M = b * n[2];
384 double N = 2 * c * n[2];
385
386
387 // ----------------- Eigen stuff
388 Eigen::Matrix2d m;
389 m << L*G - M*F, M*E-L*F, M*E-L*F, N*E-M*F;
390 m = m / (E*G-F*F);
392
393 Eigen::Vector2d c_val = eig.eigenvalues();
394 Eigen::Matrix2d c_vec = eig.eigenvectors();
395
396 // std::cerr << "c_val:" << c_val << std::endl;
397 // std::cerr << "c_vec:" << c_vec << std::endl;
398
399 // std::cerr << "c_vec:" << c_vec(0) << " " << c_vec(1) << std::endl;
400
401 c_val = -c_val;
402
403 Eigen::Vector3d v1, v2;
404 v1[0] = c_vec(0);
405 v1[1] = c_vec(1);
406 v1[2] = 0; //d * v1[0] + e * v1[1];
407
408 v2[0] = c_vec(2);
409 v2[1] = c_vec(3);
410 v2[2] = 0; //d * v2[0] + e * v2[1];
411
412
413 // v1 = v1.normalized();
414 // v2 = v2.normalized();
415
416 Eigen::Vector3d v1global = ref[0] * v1[0] + ref[1] * v1[1] + ref[2] * v1[2];
417 Eigen::Vector3d v2global = ref[0] * v2[0] + ref[1] * v2[1] + ref[2] * v2[2];
418
419 v1global.normalize();
420 v2global.normalize();
421
422 v1global *= c_val(0);
423 v2global *= c_val(1);
424
425 if (c_val[0] > c_val[1])
426 {
427 curv[i]=std::vector<double>(2);
428 curv[i][0]=c_val(1);
429 curv[i][1]=c_val(0);
430 curvDir[i]=std::vector<Eigen::Vector3d>(2);
431 curvDir[i][0]=v2global;
432 curvDir[i][1]=v1global;
433 }
434 else
435 {
436 curv[i]=std::vector<double>(2);
437 curv[i][0]=c_val(0);
438 curv[i][1]=c_val(1);
439 curvDir[i]=std::vector<Eigen::Vector3d>(2);
440 curvDir[i][0]=v1global;
441 curvDir[i][1]=v2global;
442 }
443 // ---- end Eigen stuff
444}
Computes eigenvalues and eigenvectors of selfadjoint matrices.
Definition SelfAdjointEigenSolver.h:71
@ F
Definition libslic3r.h:102
@ E
Definition libslic3r.h:101
#define L(s)
Definition I18N.hpp:18

References CurvatureCalculator::Quadric::a(), CurvatureCalculator::Quadric::b(), CurvatureCalculator::Quadric::c(), curv, curvDir, CurvatureCalculator::Quadric::d(), CurvatureCalculator::Quadric::e(), Eigen::SelfAdjointEigenSolver< _MatrixType >::eigenvalues(), Eigen::SelfAdjointEigenSolver< _MatrixType >::eigenvectors(), and L.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fitQuadric()

IGL_INLINE void CurvatureCalculator::fitQuadric ( const Eigen::Vector3d &  v,
const std::vector< Eigen::Vector3d > &  ref,
const std::vector< int > &  vv,
Quadric q 
)
335{
336 std::vector<Eigen::Vector3d> points;
337 points.reserve (vv.size());
338
339 for (unsigned int i = 0; i < vv.size(); ++i) {
340
341 Eigen::Vector3d cp = vertices.row(vv[i]);
342
343 // vtang non e` il v tangente!!!
344 Eigen::Vector3d vTang = cp - v;
345
346 double x = vTang.dot(ref[0]);
347 double y = vTang.dot(ref[1]);
348 double z = vTang.dot(ref[2]);
349 points.push_back(Eigen::Vector3d (x,y,z));
350 }
351 if (points.size() < 5)
352 {
353 std::cerr << "ASSERT FAILED! fit function requires at least 5 points: Only " << points.size() << " were given." << std::endl;
354 *q = Quadric(0,0,0,0,0);
355 }
356 else
357 {
358 *q = Quadric::fit (points);
359 }
360}
static IGL_INLINE Quadric fit(const std::vector< Eigen::Vector3d > &VV)
Definition principal_curvature.cpp:108
const Scalar & y
Definition MathFunctions.h:552
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

References CurvatureCalculator::Quadric::fit(), and vertices.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAverageEdge()

IGL_INLINE double CurvatureCalculator::getAverageEdge ( )
605{
606 double sum = 0;
607 int count = 0;
608
609 for (int i = 0; i<faces.rows(); ++i)
610 {
611 for (short unsigned j=0; j<3; ++j)
612 {
613 Eigen::Vector3d p1=vertices.row(faces.row(i)[j]);
614 Eigen::Vector3d p2=vertices.row(faces.row(i)[(j+1)%3]);
615
616 double l = (p1-p2).norm();
617
618 sum+=l;
619 ++count;
620 }
621 }
622
623 return (sum/(double)count);
624}
Eigen::MatrixXi faces
Definition principal_curvature.cpp:147
IGL_INLINE void count(const Eigen::SparseMatrix< XType > &X, const int dim, Eigen::SparseVector< SType > &S)
Definition count.cpp:12
IGL_INLINE void sum(const Eigen::SparseMatrix< T > &X, const int dim, Eigen::SparseVector< T > &S)
Definition sum.cpp:12

References faces, and vertices.

Referenced by computeCurvature().

+ Here is the caller graph for this function:

◆ getAverageNormal()

IGL_INLINE void CurvatureCalculator::getAverageNormal ( int  j,
const std::vector< int > &  vv,
Eigen::Vector3d &  normal 
)
551{
552 normal=(vertex_normals.row(j)).normalized();
553 if (localMode)
554 return;
555
556 for (unsigned int i=0; i<vv.size(); ++i)
557 {
558 normal+=vertex_normals.row(vv[i]).normalized();
559 }
560 normal.normalize();
561}

References localMode, and vertex_normals.

Referenced by computeCurvature().

+ Here is the caller graph for this function:

◆ getKRing()

IGL_INLINE void CurvatureCalculator::getKRing ( const int  start,
const double  r,
std::vector< int > &  vv 
)
447{
448 int bufsize=vertices.rows();
449 vv.reserve(bufsize);
450 std::list<std::pair<int,int> > queue;
451 bool* visited = (bool*)calloc(bufsize,sizeof(bool));
452 queue.push_back(std::pair<int,int>(start,0));
453 visited[start]=true;
454 while (!queue.empty())
455 {
456 int toVisit=queue.front().first;
457 int distance=queue.front().second;
458 queue.pop_front();
459 vv.push_back(toVisit);
460 if (distance<(int)r)
461 {
462 for (unsigned int i=0; i<vertex_to_vertices[toVisit].size(); ++i)
463 {
464 int neighbor=vertex_to_vertices[toVisit][i];
465 if (!visited[neighbor])
466 {
467 queue.push_back(std::pair<int,int> (neighbor,distance+1));
468 visited[neighbor]=true;
469 }
470 }
471 }
472 }
473 free(visited);
474 return;
475}
void free(void *)
double distance(const P &p1, const P &p2)
Definition geometry_traits.hpp:329

References free(), vertex_to_vertices, and vertices.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProjPlane()

IGL_INLINE void CurvatureCalculator::getProjPlane ( int  j,
const std::vector< int > &  vv,
Eigen::Vector3d &  ppn 
)
564{
565 int nr;
566 double a, b, c;
567 double nx, ny, nz;
568 double abcq;
569
570 a = b = c = 0;
571
572 if (localMode)
573 {
574 for (unsigned int i=0; i<vertex_to_faces.at(j).size(); ++i)
575 {
576 Eigen::Vector3d faceNormal=face_normals.row(vertex_to_faces.at(j).at(i));
577 a += faceNormal[0];
578 b += faceNormal[1];
579 c += faceNormal[2];
580 }
581 }
582 else
583 {
584 for (unsigned int i=0; i<vv.size(); ++i)
585 {
586 a+= vertex_normals.row(vv[i])[0];
587 b+= vertex_normals.row(vv[i])[1];
588 c+= vertex_normals.row(vv[i])[2];
589 }
590 }
591 nr = rotateForward (&a, &b, &c);
592 abcq = a*a + b*b + c*c;
593 nx = sqrt (a*a / abcq);
594 ny = sqrt (b*b / abcq);
595 nz = sqrt (1 - nx*nx - ny*ny);
596 rotateBackward (nr, &a, &b, &c);
597 rotateBackward (nr, &nx, &ny, &nz);
598
599 ppn = chooseMax (Eigen::Vector3d(nx, ny, nz), Eigen::Vector3d (a, b, c), a * b);
600 ppn.normalize();
601}
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Definition ArrayCwiseUnaryOps.h:152
static IGL_INLINE void rotateBackward(int nr, double *v0, double *v1, double *v2)
Definition principal_curvature.cpp:208
Eigen::MatrixXd face_normals
Definition principal_curvature.cpp:152
static IGL_INLINE Eigen::Vector3d chooseMax(Eigen::Vector3d n, Eigen::Vector3d abc, double ab)
Definition principal_curvature.cpp:223
std::vector< std::vector< int > > vertex_to_faces
Definition principal_curvature.cpp:150
static IGL_INLINE int rotateForward(double *v0, double *v1, double *v2)
Definition principal_curvature.cpp:193
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183

References chooseMax(), face_normals, localMode, rotateBackward(), rotateForward(), sqrt(), vertex_normals, and vertex_to_faces.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSphere()

IGL_INLINE void CurvatureCalculator::getSphere ( const int  start,
const double  r,
std::vector< int > &  vv,
int  min 
)
479{
480 int bufsize=vertices.rows();
481 vv.reserve(bufsize);
482 std::list<int>* queue= new std::list<int>();
483 bool* visited = (bool*)calloc(bufsize,sizeof(bool));
484 queue->push_back(start);
485 visited[start]=true;
486 Eigen::Vector3d me=vertices.row(start);
487 std::priority_queue<std::pair<int, double>, std::vector<std::pair<int, double> >, comparer >* extra_candidates= new std::priority_queue<std::pair<int, double>, std::vector<std::pair<int, double> >, comparer >();
488 while (!queue->empty())
489 {
490 int toVisit=queue->front();
491 queue->pop_front();
492 vv.push_back(toVisit);
493 for (unsigned int i=0; i<vertex_to_vertices[toVisit].size(); ++i)
494 {
495 int neighbor=vertex_to_vertices[toVisit][i];
496 if (!visited[neighbor])
497 {
498 Eigen::Vector3d neigh=vertices.row(neighbor);
499 double distance=(me-neigh).norm();
500 if (distance<r)
501 queue->push_back(neighbor);
502 else if ((int)vv.size()<min)
503 extra_candidates->push(std::pair<int,double>(neighbor,distance));
504 visited[neighbor]=true;
505 }
506 }
507 }
508 while (!extra_candidates->empty() && (int)vv.size()<min)
509 {
510 std::pair<int, double> cand=extra_candidates->top();
511 extra_candidates->pop();
512 vv.push_back(cand.first);
513 for (unsigned int i=0; i<vertex_to_vertices[cand.first].size(); ++i)
514 {
515 int neighbor=vertex_to_vertices[cand.first][i];
516 if (!visited[neighbor])
517 {
518 Eigen::Vector3d neigh=vertices.row(neighbor);
519 double distance=(me-neigh).norm();
520 extra_candidates->push(std::pair<int,double>(neighbor,distance));
521 visited[neighbor]=true;
522 }
523 }
524 }
525 free(extra_candidates);
526 free(queue);
527 free(visited);
528}
Definition principal_curvature.cpp:296
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() min(const half &a, const half &b)
Definition Half.h:507

References free(), vertex_to_vertices, and vertices.

Referenced by computeCurvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

IGL_INLINE void CurvatureCalculator::init ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F 
)
319{
320 // Normalize vertices
321 vertices = V;
322
323// vertices = vertices.array() - vertices.minCoeff();
324// vertices = vertices.array() / vertices.maxCoeff();
325// vertices = vertices.array() * (1.0/igl::avg_edge_length(V,F));
326
327 faces = F;
332}
std::vector< std::vector< int > > vertex_to_faces_index
Definition principal_curvature.cpp:151
IGL_INLINE void vertex_triangle_adjacency(const typename DerivedF::Scalar n, const Eigen::MatrixBase< DerivedF > &F, std::vector< std::vector< VFType > > &VF, std::vector< std::vector< VFiType > > &VFi)
Definition vertex_triangle_adjacency.cpp:12
IGL_INLINE void per_vertex_normals(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, const igl::PerVertexNormalsWeightingType weighting, Eigen::PlainObjectBase< DerivedN > &N)
Definition per_vertex_normals.cpp:20
IGL_INLINE void adjacency_list(const Eigen::PlainObjectBase< Index > &F, std::vector< std::vector< IndexVector > > &A, bool sorted=false)
Definition adjacency_list.cpp:14
IGL_INLINE void per_face_normals(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, const Eigen::MatrixBase< DerivedZ > &Z, Eigen::PlainObjectBase< DerivedN > &N)
Definition per_face_normals.cpp:13

References igl::adjacency_list(), face_normals, faces, igl::per_face_normals(), igl::per_vertex_normals(), vertex_normals, vertex_to_faces, vertex_to_faces_index, vertex_to_vertices, igl::vertex_triangle_adjacency(), and vertices.

Referenced by igl::principal_curvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printCurvature()

IGL_INLINE void CurvatureCalculator::printCurvature ( const std::string &  outpath)
750{
751 using namespace std;
753 return;
754
755 std::ofstream of;
756 of.open(outpath.c_str());
757
758 if (!of)
759 {
760 fprintf(stderr, "Error: could not open output file %s\n", outpath.c_str());
761 return;
762 }
763
764 int vertices_count=vertices.rows();
765 of << vertices_count << endl;
766 for (int i=0; i<vertices_count; ++i)
767 {
768 of << curv[i][0] << " " << curv[i][1] << " " << curvDir[i][0][0] << " " << curvDir[i][0][1] << " " << curvDir[i][0][2] << " " <<
769 curvDir[i][1][0] << " " << curvDir[i][1][1] << " " << curvDir[i][1][2] << endl;
770 }
771
772 of.close();
773
774}
STL namespace.

References curv, curvatureComputed, curvDir, and vertices.

◆ project()

IGL_INLINE Eigen::Vector3d CurvatureCalculator::project ( const Eigen::Vector3d &  v,
const Eigen::Vector3d &  vp,
const Eigen::Vector3d &  ppn 
)
531{
532 return (vp - (ppn * ((vp - v).dot(ppn))));
533}

Referenced by computeReferenceFrame().

+ Here is the caller graph for this function:

◆ rotateBackward()

static IGL_INLINE void CurvatureCalculator::rotateBackward ( int  nr,
double *  v0,
double *  v1,
double *  v2 
)
inlinestatic
209 {
210 double t;
211
212 if (nr == 0)
213 return;
214
215 t = *v2;
216 *v2 = *v0;
217 *v0 = *v1;
218 *v1 = t;
219
220 rotateBackward (nr - 1, v0, v1, v2);
221 }

References rotateBackward().

Referenced by getProjPlane(), and rotateBackward().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rotateForward()

static IGL_INLINE int CurvatureCalculator::rotateForward ( double *  v0,
double *  v1,
double *  v2 
)
inlinestatic
194 {
195 double t;
196
197 if (std::abs(*v2) >= std::abs(*v1) && std::abs(*v2) >= std::abs(*v0))
198 return 0;
199
200 t = *v0;
201 *v0 = *v2;
202 *v2 = *v1;
203 *v1 = t;
204
205 return 1 + rotateForward (v0, v1, v2);
206 }

References rotateForward().

Referenced by getProjPlane(), and rotateForward().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ curv

std::vector< std::vector<double> > CurvatureCalculator::curv

◆ curvatureComputed

bool CurvatureCalculator::curvatureComputed

◆ curvDir

std::vector< std::vector<Eigen::Vector3d> > CurvatureCalculator::curvDir

◆ expStep

bool CurvatureCalculator::expStep

Referenced by CurvatureCalculator().

◆ face_normals

Eigen::MatrixXd CurvatureCalculator::face_normals

Referenced by getProjPlane(), and init().

◆ faces

Eigen::MatrixXi CurvatureCalculator::faces

Referenced by getAverageEdge(), and init().

◆ kRing

int CurvatureCalculator::kRing

◆ lastMeshName

std::string CurvatureCalculator::lastMeshName

◆ lastRadius

double CurvatureCalculator::lastRadius

Referenced by computeCurvature().

◆ localMode

bool CurvatureCalculator::localMode

◆ maxSize

int CurvatureCalculator::maxSize

◆ montecarlo

bool CurvatureCalculator::montecarlo

◆ montecarloN

unsigned int CurvatureCalculator::montecarloN

◆ nt

normalType CurvatureCalculator::nt

◆ projectionPlaneCheck

bool CurvatureCalculator::projectionPlaneCheck

◆ scaledRadius

double CurvatureCalculator::scaledRadius

Referenced by computeCurvature().

◆ sphereRadius

double CurvatureCalculator::sphereRadius

◆ st

searchType CurvatureCalculator::st

◆ step

int CurvatureCalculator::step

◆ vertex_normals

Eigen::MatrixXd CurvatureCalculator::vertex_normals

◆ vertex_to_faces

std::vector<std::vector<int> > CurvatureCalculator::vertex_to_faces

Referenced by getProjPlane(), and init().

◆ vertex_to_faces_index

std::vector<std::vector<int> > CurvatureCalculator::vertex_to_faces_index

Referenced by init().

◆ vertex_to_vertices

std::vector<std::vector<int> > CurvatureCalculator::vertex_to_vertices

◆ vertices

Eigen::MatrixXd CurvatureCalculator::vertices

The documentation for this class was generated from the following file: