|
@@ -168,53 +168,53 @@ IGL_INLINE void igl::signed_distance_pseudonormal(
|
|
|
typedef typename Tree::Point_and_primitive_id Point_and_primitive_id;
|
|
|
|
|
|
pp = tree.closest_point_and_primitive(q);
|
|
|
- //Point_3 & p = pp.first;
|
|
|
- //const auto & qp = q-p;
|
|
|
- //sqrd = qp.squared_length();
|
|
|
- //Vector3d v(qp.x(),qp.y(),qp.z());
|
|
|
- //const int f = pp.second - T.begin();
|
|
|
- //const Triangle_3 & t = *pp.second;
|
|
|
- //// barycentric coordinates
|
|
|
- //const auto & area = [&p,&t](const int i, const int j)->FT
|
|
|
- //{
|
|
|
- // return sqrt(Triangle_3(p,t.vertex(i),t.vertex(j)).squared_area());
|
|
|
- //};
|
|
|
- //Vector3d b(area(1,2),area(2,0),area(0,1));
|
|
|
- //b /= b.sum();
|
|
|
- //// Determine which normal to use
|
|
|
- //const double epsilon = 1e-12;
|
|
|
- //const int type = (b.array()<=epsilon).cast<int>().sum();
|
|
|
- //switch(type)
|
|
|
- //{
|
|
|
- // case 2:
|
|
|
- // // Find vertex
|
|
|
- // for(int c = 0;c<3;c++)
|
|
|
- // {
|
|
|
- // if(b(c)>epsilon)
|
|
|
- // {
|
|
|
- // n = VN.row(F(f,c));
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // break;
|
|
|
- // case 1:
|
|
|
- // // Find edge
|
|
|
- // for(int c = 0;c<3;c++)
|
|
|
- // {
|
|
|
- // if(b(c)<=epsilon)
|
|
|
- // {
|
|
|
- // n = EN.row(EMAP(F.rows()*c+f));
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // break;
|
|
|
- // default:
|
|
|
- // assert(false && "all barycentric coords zero.");
|
|
|
- // case 0:
|
|
|
- // n = FN.row(f);
|
|
|
- // break;
|
|
|
- //}
|
|
|
- //s = (v.dot(n) >= 0 ? 1. : -1.);
|
|
|
+ Point_3 & p = pp.first;
|
|
|
+ const auto & qp = q-p;
|
|
|
+ sqrd = qp.squared_length();
|
|
|
+ Vector3d v(qp.x(),qp.y(),qp.z());
|
|
|
+ const int f = pp.second - T.begin();
|
|
|
+ const Triangle_3 & t = *pp.second;
|
|
|
+ // barycentric coordinates
|
|
|
+ const auto & area = [&p,&t](const int i, const int j)->FT
|
|
|
+ {
|
|
|
+ return sqrt(Triangle_3(p,t.vertex(i),t.vertex(j)).squared_area());
|
|
|
+ };
|
|
|
+ Vector3d b(area(1,2),area(2,0),area(0,1));
|
|
|
+ b /= b.sum();
|
|
|
+ // Determine which normal to use
|
|
|
+ const double epsilon = 1e-12;
|
|
|
+ const int type = (b.array()<=epsilon).cast<int>().sum();
|
|
|
+ switch(type)
|
|
|
+ {
|
|
|
+ case 2:
|
|
|
+ // Find vertex
|
|
|
+ for(int c = 0;c<3;c++)
|
|
|
+ {
|
|
|
+ if(b(c)>epsilon)
|
|
|
+ {
|
|
|
+ n = VN.row(F(f,c));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ // Find edge
|
|
|
+ for(int c = 0;c<3;c++)
|
|
|
+ {
|
|
|
+ if(b(c)<=epsilon)
|
|
|
+ {
|
|
|
+ n = EN.row(EMAP(F.rows()*c+f));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ assert(false && "all barycentric coords zero.");
|
|
|
+ case 0:
|
|
|
+ n = FN.row(f);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ s = (v.dot(n) >= 0 ? 1. : -1.);
|
|
|
}
|
|
|
|
|
|
template <typename Kernel>
|