mirror of https://github.com/CGAL/cgal
Merge pull request #4283 from sloriot/SMSeg-more_robust
Be more robust to degenerate and almost degenerate faces
This commit is contained in:
commit
dd734e3098
|
|
@ -126,6 +126,7 @@ private:
|
||||||
typename GeomTraits::Construct_normal_3 normal_functor;
|
typename GeomTraits::Construct_normal_3 normal_functor;
|
||||||
typename GeomTraits::Construct_translated_point_3 translated_point_functor;
|
typename GeomTraits::Construct_translated_point_3 translated_point_functor;
|
||||||
typename GeomTraits::Construct_centroid_3 centroid_functor;
|
typename GeomTraits::Construct_centroid_3 centroid_functor;
|
||||||
|
typename GeomTraits::Collinear_3 collinear_functor;
|
||||||
|
|
||||||
Tree tree;
|
Tree tree;
|
||||||
|
|
||||||
|
|
@ -153,11 +154,11 @@ public:
|
||||||
normal_functor(traits.construct_normal_3_object()),
|
normal_functor(traits.construct_normal_3_object()),
|
||||||
translated_point_functor(traits.construct_translated_point_3_object()),
|
translated_point_functor(traits.construct_translated_point_3_object()),
|
||||||
centroid_functor(traits.construct_centroid_3_object()),
|
centroid_functor(traits.construct_centroid_3_object()),
|
||||||
|
collinear_functor(traits.collinear_3_object()),
|
||||||
tree(create_traits(mesh, vertex_point_map)),
|
tree(create_traits(mesh, vertex_point_map)),
|
||||||
use_diagonal(use_diagonal)
|
use_diagonal(use_diagonal)
|
||||||
{
|
{
|
||||||
typedef typename boost::property_traits<VertexPointPmap>::reference Point_ref;
|
typedef typename boost::property_traits<VertexPointPmap>::reference Point_ref;
|
||||||
typename GeomTraits::Collinear_3 collinear = traits.collinear_3_object();
|
|
||||||
face_iterator it, end;
|
face_iterator it, end;
|
||||||
for(it = faces(mesh).begin(), end = faces(mesh).end(); it!=end; it++)
|
for(it = faces(mesh).begin(), end = faces(mesh).end(); it!=end; it++)
|
||||||
{
|
{
|
||||||
|
|
@ -167,7 +168,7 @@ public:
|
||||||
Point_ref b(get(vertex_point_map,target(h, mesh)));
|
Point_ref b(get(vertex_point_map,target(h, mesh)));
|
||||||
h = next(h, mesh);
|
h = next(h, mesh);
|
||||||
Point_ref c(get(vertex_point_map, target(h, mesh)));
|
Point_ref c(get(vertex_point_map, target(h, mesh)));
|
||||||
bool test = collinear(a,b,c);
|
bool test = collinear_functor(a,b,c);
|
||||||
if(!test)
|
if(!test)
|
||||||
tree.insert(Primitive(it, mesh, vertex_point_map));
|
tree.insert(Primitive(it, mesh, vertex_point_map));
|
||||||
}
|
}
|
||||||
|
|
@ -388,10 +389,11 @@ private:
|
||||||
const Point p2 = get(vertex_point_map,target(next(halfedge(facet,mesh),mesh),mesh));
|
const Point p2 = get(vertex_point_map,target(next(halfedge(facet,mesh),mesh),mesh));
|
||||||
const Point p3 = get(vertex_point_map,target(prev(halfedge(facet,mesh),mesh),mesh));
|
const Point p3 = get(vertex_point_map,target(prev(halfedge(facet,mesh),mesh),mesh));
|
||||||
const Point center = centroid_functor(p1, p2, p3);
|
const Point center = centroid_functor(p1, p2, p3);
|
||||||
|
if (collinear_functor(p1, p2, p3)) return boost::none;
|
||||||
Vector normal = normal_functor(p2, p1, p3);
|
Vector normal = normal_functor(p2, p1, p3);
|
||||||
normal=scale_functor(normal,
|
normal=scale_functor(normal,
|
||||||
FT(1.0/std::sqrt(to_double(normal.squared_length()))));
|
FT(1.0/std::sqrt(to_double(normal.squared_length()))));
|
||||||
|
if (normal!=normal) return boost::none;
|
||||||
CGAL::internal::SkipPrimitiveFunctor<face_handle>
|
CGAL::internal::SkipPrimitiveFunctor<face_handle>
|
||||||
skip(facet);
|
skip(facet);
|
||||||
CGAL::internal::FirstIntersectionVisitor<face_handle>
|
CGAL::internal::FirstIntersectionVisitor<face_handle>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue