fix when bbox has a 0-width + update testsuite

This commit is contained in:
Sébastien Loriot 2018-11-06 10:56:04 +01:00
parent 8a27676102
commit a51a153c31
2 changed files with 13 additions and 3 deletions

View File

@ -406,9 +406,9 @@ bool clip( TriangleMesh& tm,
CGAL::Bbox_3 bbox = ::CGAL::Polygon_mesh_processing::bbox(tm);
//extend the bbox a bit to avoid border cases
double xd=(bbox.xmax()-bbox.xmin())/100;
double yd=(bbox.ymax()-bbox.ymin())/100;
double zd=(bbox.zmax()-bbox.zmin())/100;
double xd=(std::max)(1.,(bbox.xmax()-bbox.xmin())/100);
double yd=(std::max)(1.,(bbox.ymax()-bbox.ymin())/100);
double zd=(std::max)(1.,(bbox.zmax()-bbox.zmin())/100);
bbox=CGAL::Bbox_3(bbox.xmin()-xd, bbox.ymin()-yd, bbox.zmin()-zd,
bbox.xmax()+xd, bbox.ymax()+yd, bbox.zmax()+zd);
TriangleMesh clipper;

View File

@ -206,6 +206,16 @@ void test()
CGAL::clear(tm1);
CGAL::clear(tm2);
// clip meshes with intersection polyline opened
make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 );
PMP::clip(tm1, K::Plane_3(1, 0, 0, -2));
assert(vertices(tm1).size()==4);
CGAL::clear(tm1);
make_triangle( K::Point_3(0, 0, 0), K::Point_3(0, 4, 0), K::Point_3(4, 0, 0), tm1 );
PMP::clip(tm1, K::Plane_3(-1, 0, 0, 2));
assert(vertices(tm1).size()==3);
CGAL::clear(tm1);
}
int main()