Undefined behaviour in CGAL when using difference3D
Created by: DRC1Spatial
I have 3 test cases which reproduce these crashes. On Linux they manifest as segfaults (first two cases) and floating exception (third case), on Windows as access violations (first two cases) and divide by zero (third case). I've reproduced these using three machines and toolchains, with the master code of SFCGAL and CGAL and also an earlier version of each - I can fill in more of those details later but more important at this point is the code to reproduce, so that these cases can be tried in a completely different environment.
Any of these three cases, inserted at the end of DifferenceTest.cpp, should produce one of the crashes:
BOOST_AUTO_TEST_CASE( testDifferenceCrash1 )
{
// Hard crash in CGAL when using difference3D
{
std::auto_ptr<Geometry> g1 = io::readWkt("GEOMETRYCOLLECTION(SOLID((((1.00000 1.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 -1.00000 -1.00000,1.00000 1.00000 -1.00000,1.00000 1.00000 1.00000)),((1.00000 1.00000 1.00000,1.00000 1.00000 -1.00000,-1.00000 1.00000 -1.00000,-1.00000 1.00000 1.00000,1.00000 1.00000 1.00000)),((-1.00000 1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 -1.00000 1.00000,-1.00000 1.00000 1.00000,-1.00000 1.00000 -1.00000)),((1.00000 -1.00000 1.00000,-1.00000 -1.00000 1.00000,-1.00000 -1.00000 -1.00000,1.00000 -1.00000 -1.00000,1.00000 -1.00000 1.00000)),((1.00000 1.00000 -1.00000,1.00000 -1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 1.00000 -1.00000,1.00000 1.00000 -1.00000)),((1.00000 1.00000 1.00000,-1.00000 1.00000 1.00000,-1.00000 -1.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 1.00000 1.00000)))),SOLID((((0.00000 2.00000 0.00000,2.00000 0.00000 0.00000,0.00000 0.00000 -2.00000,0.00000 2.00000 0.00000)),((0.00000 2.00000 0.00000,0.00000 0.00000 2.00000,2.00000 0.00000 0.00000,0.00000 2.00000 0.00000)),((0.00000 2.00000 0.00000,-2.00000 0.00000 0.00000,0.00000 0.00000 2.00000,0.00000 2.00000 0.00000)),((0.00000 2.00000 0.00000,0.00000 0.00000 -2.00000,-2.00000 0.00000 0.00000,0.00000 2.00000 0.00000)),((0.00000 -2.00000 0.00000,0.00000 0.00000 -2.00000,2.00000 0.00000 0.00000,0.00000 -2.00000 0.00000)),((0.00000 -2.00000 0.00000,2.00000 0.00000 0.00000,0.00000 0.00000 2.00000,0.00000 -2.00000 0.00000)),((0.00000 -2.00000 0.00000,0.00000 0.00000 2.00000,-2.00000 0.00000 0.00000,0.00000 -2.00000 0.00000)),((0.00000 -2.00000 0.00000,-2.00000 0.00000 0.00000,0.00000 0.00000 -2.00000,0.00000 -2.00000 0.00000)))))");
std::auto_ptr<Geometry> g2 = io::readWkt("SOLID((((1.00000 -1.00000 1.00000,0.50000 -0.50000 1.00000,-0.00000 -1.00000 1.00000,1.00000 -1.00000 1.00000)),((0.50000 -0.50000 1.00000,1.00000 -1.00000 1.00000,1.00000 -0.00000 1.00000,0.50000 -0.50000 1.00000)),((-0.00000 -1.00000 1.00000,0.50000 -0.50000 1.00000,0.00000 0.00000 2.00000,-0.00000 -1.00000 1.00000)),((1.00000 -1.00000 1.00000,-0.00000 -1.00000 1.00000,1.00000 -1.00000 -0.00000,1.00000 -1.00000 1.00000)),((1.00000 -0.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 -0.50000 0.50000,1.00000 -0.00000 1.00000)),((0.50000 -0.50000 1.00000,1.00000 -0.00000 1.00000,0.00000 0.00000 2.00000,0.50000 -0.50000 1.00000)),((-0.00000 -1.00000 1.00000,0.00000 0.00000 2.00000,-1.00000 -0.00000 1.00000,-0.00000 -1.00000 1.00000)),((1.00000 -1.00000 -0.00000,-0.00000 -1.00000 1.00000,0.00000 -2.00000 0.00000,1.00000 -1.00000 -0.00000)),((1.00000 -1.00000 1.00000,1.00000 -1.00000 -0.00000,1.00000 -0.50000 0.50000,1.00000 -1.00000 1.00000)),((1.00000 -0.00000 1.00000,1.00000 -0.50000 0.50000,2.00000 0.00000 0.00000,1.00000 -0.00000 1.00000)),((0.00000 0.00000 2.00000,1.00000 -0.00000 1.00000,-0.00000 1.00000 1.00000,0.00000 0.00000 2.00000)),((-1.00000 -0.00000 1.00000,0.00000 0.00000 2.00000,-0.50000 0.50000 1.00000,-1.00000 -0.00000 1.00000)),((-0.00000 -1.00000 1.00000,-1.00000 -0.00000 1.00000,-1.00000 -1.00000 1.00000,-0.00000 -1.00000 1.00000)),((0.00000 -2.00000 0.00000,-0.00000 -1.00000 1.00000,-0.50000 -1.00000 0.50000,0.00000 -2.00000 0.00000)),((1.00000 -1.00000 -0.00000,0.00000 -2.00000 0.00000,0.50000 -1.00000 -0.50000,1.00000 -1.00000 -0.00000)),((1.00000 -0.50000 0.50000,1.00000 -1.00000 -0.00000,2.00000 0.00000 0.00000,1.00000 -0.50000 0.50000)),((1.00000 -0.00000 1.00000,2.00000 0.00000 0.00000,1.00000 1.00000 -0.00000,1.00000 -0.00000 1.00000)),((-0.00000 1.00000 1.00000,1.00000 -0.00000 1.00000,1.00000 1.00000 1.00000,-0.00000 1.00000 1.00000)),((0.00000 0.00000 2.00000,-0.00000 1.00000 1.00000,-0.50000 0.50000 1.00000,0.00000 0.00000 2.00000)),((-1.00000 -0.00000 1.00000,-0.50000 0.50000 1.00000,-1.00000 1.00000 1.00000,-1.00000 -0.00000 1.00000)),((-1.00000 -1.00000 1.00000,-1.00000 -0.00000 1.00000,-1.00000 -1.00000 -0.00000,-1.00000 -1.00000 1.00000)),((-0.00000 -1.00000 1.00000,-1.00000 -1.00000 1.00000,-0.50000 -1.00000 0.50000,-0.00000 -1.00000 1.00000)),((0.00000 -2.00000 0.00000,-0.50000 -1.00000 0.50000,-1.00000 -1.00000 -0.00000,0.00000 -2.00000 0.00000)),((0.50000 -1.00000 -0.50000,0.00000 -2.00000 0.00000,-0.00000 -1.00000 -1.00000,0.50000 -1.00000 -0.50000)),((1.00000 -1.00000 -0.00000,0.50000 -1.00000 -0.50000,1.00000 -1.00000 -1.00000,1.00000 -1.00000 -0.00000)),((2.00000 0.00000 0.00000,1.00000 -1.00000 -0.00000,1.00000 -0.00000 -1.00000,2.00000 0.00000 0.00000)),((1.00000 1.00000 -0.00000,2.00000 0.00000 0.00000,1.00000 0.50000 -0.50000,1.00000 1.00000 -0.00000)),((1.00000 -0.00000 1.00000,1.00000 1.00000 -0.00000,1.00000 1.00000 1.00000,1.00000 -0.00000 1.00000)),((-0.00000 1.00000 1.00000,1.00000 1.00000 1.00000,0.50000 1.00000 0.50000,-0.00000 1.00000 1.00000)),((-0.50000 0.50000 1.00000,-0.00000 1.00000 1.00000,-1.00000 1.00000 1.00000,-0.50000 0.50000 1.00000)),((-1.00000 -0.00000 1.00000,-1.00000 1.00000 1.00000,-1.00000 0.50000 0.50000,-1.00000 -0.00000 1.00000)),((-1.00000 -1.00000 -0.00000,-1.00000 -0.00000 1.00000,-2.00000 0.00000 0.00000,-1.00000 -1.00000 -0.00000)),((-1.00000 -1.00000 1.00000,-1.00000 -1.00000 -0.00000,-0.50000 -1.00000 0.50000,-1.00000 -1.00000 1.00000)),((0.00000 -2.00000 0.00000,-1.00000 -1.00000 -0.00000,-0.00000 -1.00000 -1.00000,0.00000 -2.00000 0.00000)),((0.50000 -1.00000 -0.50000,-0.00000 -1.00000 -1.00000,1.00000 -1.00000 -1.00000,0.50000 -1.00000 -0.50000)),((1.00000 -1.00000 -0.00000,1.00000 -1.00000 -1.00000,1.00000 -0.00000 -1.00000,1.00000 -1.00000 -0.00000)),((2.00000 0.00000 0.00000,1.00000 -0.00000 -1.00000,1.00000 0.50000 -0.50000,2.00000 0.00000 0.00000)),((1.00000 1.00000 -0.00000,1.00000 0.50000 -0.50000,1.00000 1.00000 -1.00000,1.00000 1.00000 -0.00000)),((1.00000 1.00000 1.00000,1.00000 1.00000 -0.00000,0.50000 1.00000 0.50000,1.00000 1.00000 1.00000)),((-0.00000 1.00000 1.00000,0.50000 1.00000 0.50000,0.00000 2.00000 0.00000,-0.00000 1.00000 1.00000)),((-1.00000 1.00000 1.00000,-0.00000 1.00000 1.00000,-1.00000 1.00000 -0.00000,-1.00000 1.00000 1.00000)),((-1.00000 0.50000 0.50000,-1.00000 1.00000 1.00000,-1.00000 1.00000 -0.00000,-1.00000 0.50000 0.50000)),((-1.00000 -0.00000 1.00000,-1.00000 0.50000 0.50000,-2.00000 0.00000 0.00000,-1.00000 -0.00000 1.00000)),((-1.00000 -1.00000 -0.00000,-2.00000 0.00000 0.00000,-1.00000 -0.50000 -0.50000,-1.00000 -1.00000 -0.00000)),((-0.00000 -1.00000 -1.00000,-1.00000 -1.00000 -0.00000,-1.00000 -1.00000 -1.00000,-0.00000 -1.00000 -1.00000)),((1.00000 -1.00000 -1.00000,-0.00000 -1.00000 -1.00000,1.00000 -0.00000 -1.00000,1.00000 -1.00000 -1.00000)),((1.00000 0.50000 -0.50000,1.00000 -0.00000 -1.00000,1.00000 1.00000 -1.00000,1.00000 0.50000 -0.50000)),((1.00000 1.00000 -0.00000,1.00000 1.00000 -1.00000,-0.00000 1.00000 -1.00000,1.00000 1.00000 -0.00000)),((0.50000 1.00000 0.50000,1.00000 1.00000 -0.00000,0.00000 2.00000 0.00000,0.50000 1.00000 0.50000)),((-0.00000 1.00000 1.00000,0.00000 2.00000 0.00000,-1.00000 1.00000 -0.00000,-0.00000 1.00000 1.00000)),((-1.00000 0.50000 0.50000,-1.00000 1.00000 -0.00000,-2.00000 0.00000 0.00000,-1.00000 0.50000 0.50000)),((-1.00000 -0.50000 -0.50000,-2.00000 0.00000 0.00000,-1.00000 -0.00000 -1.00000,-1.00000 -0.50000 -0.50000)),((-1.00000 -1.00000 -0.00000,-1.00000 -0.50000 -0.50000,-1.00000 -1.00000 -1.00000,-1.00000 -1.00000 -0.00000)),((-0.00000 -1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-0.50000 -0.50000 -1.00000,-0.00000 -1.00000 -1.00000)),((1.00000 -0.00000 -1.00000,-0.00000 -1.00000 -1.00000,0.00000 0.00000 -2.00000,1.00000 -0.00000 -1.00000)),((1.00000 1.00000 -1.00000,1.00000 -0.00000 -1.00000,0.50000 0.50000 -1.00000,1.00000 1.00000 -1.00000)),((-0.00000 1.00000 -1.00000,1.00000 1.00000 -1.00000,0.50000 0.50000 -1.00000,-0.00000 1.00000 -1.00000)),((1.00000 1.00000 -0.00000,-0.00000 1.00000 -1.00000,0.00000 2.00000 0.00000,1.00000 1.00000 -0.00000)),((-1.00000 1.00000 -0.00000,0.00000 2.00000 0.00000,-0.50000 1.00000 -0.50000,-1.00000 1.00000 -0.00000)),((-2.00000 0.00000 0.00000,-1.00000 1.00000 -0.00000,-1.00000 -0.00000 -1.00000,-2.00000 0.00000 0.00000)),((-1.00000 -0.50000 -0.50000,-1.00000 -0.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 -0.50000 -0.50000)),((-0.50000 -0.50000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 -0.00000 -1.00000,-0.50000 -0.50000 -1.00000)),((-0.00000 -1.00000 -1.00000,-0.50000 -0.50000 -1.00000,0.00000 0.00000 -2.00000,-0.00000 -1.00000 -1.00000)),((1.00000 -0.00000 -1.00000,0.00000 0.00000 -2.00000,0.50000 0.50000 -1.00000,1.00000 -0.00000 -1.00000)),((-0.00000 1.00000 -1.00000,0.50000 0.50000 -1.00000,0.00000 0.00000 -2.00000,-0.00000 1.00000 -1.00000)),((0.00000 2.00000 0.00000,-0.00000 1.00000 -1.00000,-0.50000 1.00000 -0.50000,0.00000 2.00000 0.00000)),((-1.00000 1.00000 -0.00000,-0.50000 1.00000 -0.50000,-1.00000 1.00000 -1.00000,-1.00000 1.00000 -0.00000)),((-1.00000 -0.00000 -1.00000,-1.00000 1.00000 -0.00000,-1.00000 1.00000 -1.00000,-1.00000 -0.00000 -1.00000)),((-0.50000 -0.50000 -1.00000,-1.00000 -0.00000 -1.00000,0.00000 0.00000 -2.00000,-0.50000 -0.50000 -1.00000)),((-0.00000 1.00000 -1.00000,0.00000 0.00000 -2.00000,-1.00000 -0.00000 -1.00000,-0.00000 1.00000 -1.00000)),((-0.50000 1.00000 -0.50000,-0.00000 1.00000 -1.00000,-1.00000 1.00000 -1.00000,-0.50000 1.00000 -0.50000)),((-1.00000 -0.00000 -1.00000,-1.00000 1.00000 -1.00000,-0.00000 1.00000 -1.00000,-1.00000 -0.00000 -1.00000))))");
std::auto_ptr<Geometry> diff1 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> diff2 = algorithm::difference3D( *g2, *g1 );
}
}
BOOST_AUTO_TEST_CASE( testDifferenceCrash2 )
{
// Intermittent hard crash in CGAL when using difference3D, dependent on memory state
{
std::auto_ptr<Geometry> g1 = io::readWkt("GEOMETRYCOLLECTION(SOLID((((1.00000 1.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 -1.00000 -1.00000,1.00000 1.00000 -1.00000,1.00000 1.00000 1.00000)),((1.00000 1.00000 1.00000,1.00000 1.00000 -1.00000,-1.00000 1.00000 -1.00000,-1.00000 1.00000 1.00000,1.00000 1.00000 1.00000)),((-1.00000 1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 -1.00000 1.00000,-1.00000 1.00000 1.00000,-1.00000 1.00000 -1.00000)),((1.00000 -1.00000 1.00000,-1.00000 -1.00000 1.00000,-1.00000 -1.00000 -1.00000,1.00000 -1.00000 -1.00000,1.00000 -1.00000 1.00000)),((1.00000 1.00000 -1.00000,1.00000 -1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 1.00000 -1.00000,1.00000 1.00000 -1.00000)),((1.00000 1.00000 1.00000,-1.00000 1.00000 1.00000,-1.00000 -1.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 1.00000 1.00000)))),POLYGON((0.00000 0.00000 0.00000,0.00000 2.00000 0.00000,2.00000 2.00000 0.00000,2.00000 0.00000 0.00000,0.00000 0.00000 0.00000),(0.50000 0.50000 0.00000,1.50000 0.50000 0.00000,1.50000 1.50000 0.00000,0.50000 1.50000 0.00000,0.50000 0.50000 0.00000)),POLYGON((0.00000 0.00000 0.00000,0.00000 0.00000 2.00000,0.00000 2.00000 2.00000,0.00000 2.00000 0.00000,0.00000 0.00000 0.00000),(0.00000 0.50000 0.50000,0.00000 1.50000 0.50000,0.00000 1.50000 1.50000,0.00000 0.50000 1.50000,0.00000 0.50000 0.50000)))");
std::auto_ptr<Geometry> g2 = io::readWkt("GEOMETRYCOLLECTION(TIN(((1.50000 1.50000 -0.00000,-0.00000 2.00000 -0.00000,2.00000 2.00000 -0.00000,1.50000 1.50000 -0.00000)),((0.50000 1.50000 -0.00000,0.33333 1.00000 0.00000,-0.00000 1.00000 -0.00000,0.50000 1.50000 -0.00000)),((-0.00000 2.00000 -0.00000,0.50000 1.50000 -0.00000,-0.00000 1.00000 -0.00000,-0.00000 2.00000 -0.00000)),((0.50000 1.50000 -0.00000,0.50000 1.00000 -0.00000,0.33333 1.00000 0.00000,0.50000 1.50000 -0.00000)),((1.50000 0.50000 -0.00000,1.00000 0.33333 0.00000,1.00000 0.50000 -0.00000,1.50000 0.50000 -0.00000)),((1.50000 0.50000 -0.00000,1.00000 -0.00000 -0.00000,1.00000 0.33333 0.00000,1.50000 0.50000 -0.00000)),((1.50000 0.50000 -0.00000,2.00000 -0.00000 -0.00000,1.00000 -0.00000 -0.00000,1.50000 0.50000 -0.00000)),((1.50000 1.50000 -0.00000,0.50000 1.50000 -0.00000,-0.00000 2.00000 -0.00000,1.50000 1.50000 -0.00000)),((-0.00000 1.50000 1.50000,-0.00000 -0.00000 2.00000,-0.00000 2.00000 2.00000,-0.00000 1.50000 1.50000)),((-0.00000 0.50000 1.50000,0.00000 0.33333 1.00000,-0.00000 -0.00000 1.00000,-0.00000 0.50000 1.50000)),((-0.00000 -0.00000 2.00000,-0.00000 0.50000 1.50000,-0.00000 -0.00000 1.00000,-0.00000 -0.00000 2.00000)),((-0.00000 0.50000 1.50000,-0.00000 0.50000 1.00000,0.00000 0.33333 1.00000,-0.00000 0.50000 1.50000)),((-0.00000 1.50000 0.50000,0.00000 1.00000 0.33333,-0.00000 1.00000 0.50000,-0.00000 1.50000 0.50000)),((-0.00000 2.00000 -0.00000,-0.00000 1.50000 0.50000,-0.00000 2.00000 2.00000,-0.00000 2.00000 -0.00000)),((-0.00000 1.50000 0.50000,-0.00000 1.00000 -0.00000,0.00000 1.00000 0.33333,-0.00000 1.50000 0.50000)),((-0.00000 1.50000 0.50000,-0.00000 2.00000 -0.00000,-0.00000 1.00000 -0.00000,-0.00000 1.50000 0.50000)),((-0.00000 1.50000 0.50000,-0.00000 1.50000 1.50000,-0.00000 2.00000 2.00000,-0.00000 1.50000 0.50000)),((-0.00000 1.50000 1.50000,-0.00000 0.50000 1.50000,-0.00000 -0.00000 2.00000,-0.00000 1.50000 1.50000)),((2.00000 -0.00000 -0.00000,1.50000 0.50000 -0.00000,2.00000 2.00000 -0.00000,2.00000 -0.00000 -0.00000)),((1.50000 0.50000 -0.00000,1.50000 1.50000 -0.00000,2.00000 2.00000 -0.00000,1.50000 0.50000 -0.00000))),SOLID((((1.00000 -1.00000 1.00000,1.00000 -1.00000 -1.00000,1.00000 0.00000 0.00000,1.00000 -1.00000 1.00000)),((1.00000 0.33333 0.00000,1.00000 1.00000 -1.00000,1.00000 0.50000 0.00000,1.00000 0.33333 0.00000)),((0.00000 1.00000 0.00000,1.00000 1.00000 -1.00000,-1.00000 1.00000 -1.00000,0.00000 1.00000 0.00000)),((-1.00000 1.00000 -1.00000,-1.00000 1.00000 1.00000,0.00000 1.00000 0.00000,-1.00000 1.00000 -1.00000)),((-1.00000 1.00000 1.00000,-1.00000 -1.00000 -1.00000,-1.00000 -1.00000 1.00000,-1.00000 1.00000 1.00000)),((-1.00000 1.00000 1.00000,-1.00000 1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 1.00000 1.00000)),((1.00000 -1.00000 -1.00000,-1.00000 -1.00000 1.00000,-1.00000 -1.00000 -1.00000,1.00000 -1.00000 -1.00000)),((1.00000 -1.00000 -1.00000,1.00000 -1.00000 1.00000,-1.00000 -1.00000 1.00000,1.00000 -1.00000 -1.00000)),((1.00000 1.00000 -1.00000,1.00000 -1.00000 -1.00000,-1.00000 -1.00000 -1.00000,1.00000 1.00000 -1.00000)),((-1.00000 1.00000 -1.00000,1.00000 1.00000 -1.00000,-1.00000 -1.00000 -1.00000,-1.00000 1.00000 -1.00000)),((-1.00000 1.00000 1.00000,-1.00000 -1.00000 1.00000,0.00000 0.00000 1.00000,-1.00000 1.00000 1.00000)),((0.00000 0.33333 1.00000,1.00000 1.00000 1.00000,0.00000 0.50000 1.00000,0.00000 0.33333 1.00000)),((0.00000 1.00000 0.00000,-1.00000 1.00000 1.00000,0.00000 1.00000 0.33333,0.00000 1.00000 0.00000)),((0.33333 1.00000 0.00000,1.00000 1.00000 1.00000,0.50000 1.00000 0.00000,0.33333 1.00000 0.00000)),((0.00000 1.00000 0.00000,1.00000 1.00000 1.00000,0.33333 1.00000 0.00000,0.00000 1.00000 0.00000)),((1.00000 1.00000 -1.00000,0.00000 1.00000 0.00000,0.33333 1.00000 0.00000,1.00000 1.00000 -1.00000)),((0.50000 1.00000 0.00000,1.00000 1.00000 -1.00000,0.33333 1.00000 0.00000,0.50000 1.00000 0.00000)),((0.50000 1.00000 0.00000,1.00000 1.00000 1.00000,1.00000 1.00000 -1.00000,0.50000 1.00000 0.00000)),((1.00000 0.50000 0.00000,1.00000 1.00000 1.00000,1.00000 0.33333 0.00000,1.00000 0.50000 0.00000)),((1.00000 1.00000 -1.00000,1.00000 0.33333 0.00000,1.00000 0.00000 0.00000,1.00000 1.00000 -1.00000)),((1.00000 0.50000 0.00000,1.00000 1.00000 -1.00000,1.00000 1.00000 1.00000,1.00000 0.50000 0.00000)),((1.00000 1.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 0.33333 0.00000,1.00000 1.00000 1.00000)),((1.00000 0.00000 0.00000,1.00000 -1.00000 -1.00000,1.00000 1.00000 -1.00000,1.00000 0.00000 0.00000)),((1.00000 0.00000 0.00000,1.00000 0.33333 0.00000,1.00000 -1.00000 1.00000,1.00000 0.00000 0.00000)),((0.00000 0.00000 1.00000,-1.00000 -1.00000 1.00000,1.00000 -1.00000 1.00000,0.00000 0.00000 1.00000)),((0.00000 0.33333 1.00000,0.00000 0.00000 1.00000,1.00000 1.00000 1.00000,0.00000 0.33333 1.00000)),((0.00000 0.00000 1.00000,1.00000 -1.00000 1.00000,1.00000 1.00000 1.00000,0.00000 0.00000 1.00000)),((-1.00000 1.00000 1.00000,0.00000 0.00000 1.00000,0.00000 0.33333 1.00000,-1.00000 1.00000 1.00000)),((0.00000 0.50000 1.00000,-1.00000 1.00000 1.00000,0.00000 0.33333 1.00000,0.00000 0.50000 1.00000)),((0.00000 0.50000 1.00000,1.00000 1.00000 1.00000,-1.00000 1.00000 1.00000,0.00000 0.50000 1.00000)),((0.00000 1.00000 0.33333,-1.00000 1.00000 1.00000,0.00000 1.00000 0.50000,0.00000 1.00000 0.33333)),((0.00000 1.00000 0.33333,1.00000 1.00000 1.00000,0.00000 1.00000 0.00000,0.00000 1.00000 0.33333)),((0.00000 1.00000 0.50000,-1.00000 1.00000 1.00000,1.00000 1.00000 1.00000,0.00000 1.00000 0.50000)),((0.00000 1.00000 0.50000,1.00000 1.00000 1.00000,0.00000 1.00000 0.33333,0.00000 1.00000 0.50000)))))");
for (int i=0; i < 10; ++i)
{
std::auto_ptr<Geometry> d1 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d2 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d3 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d4 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d5 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d6 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d7 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d8 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d9 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d10 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d11 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d12 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d13 = algorithm::difference3D( *g1, *g2 );
std::auto_ptr<Geometry> d14 = algorithm::difference3D( *g2, *g1 );
std::auto_ptr<Geometry> d15 = algorithm::difference3D( *g1, *g2 );
}
}
}
BOOST_AUTO_TEST_CASE( testDifferenceCrash3 )
{
// Hard crash in CGAL when using difference3D with NoValidityCheck
{
std::auto_ptr<Geometry> g1 = io::readWkt("SOLID((((1 1 0.5,0.5 1 0.5,0.5 1.5 0.5,1 1 0.5)),((0.5 1 0.5,1 1 0.5,1 1 -1,0.5 1 0.5)),((0.5 1.5 0.5,0.5 1 0.5,0.5 1 1,0.5 1.5 0.5)),((1 1 0.5,0.5 1.5 0.5,1.5 1.5 0.5,1 1 0.5)),((1 1 -1,1 1 0.5,1 0.5 0.5,1 1 -1)),((0.5 1 0.5,1 1 -1,-1 1 -1,0.5 1 0.5)),((0.5 1 1,0.5 1 0.5,-1 1 1,0.5 1 1)),((0.5 1.5 0.5,0.5 1 1,0.5 1.5 1.5,0.5 1.5 0.5)),((1.5 1.5 0.5,0.5 1.5 0.5,1.5 1.5 1.5,1.5 1.5 0.5)),((1 1 0.5,1.5 1.5 0.5,1 0.5 0.5,1 1 0.5)),((1 1 -1,1 0.5 0.5,1 -1 -1,1 1 -1)),((-1 1 -1,1 1 -1,-1 -1 -1,-1 1 -1)),((0.5 1 0.5,-1 1 -1,-1 1 1,0.5 1 0.5)),((0.5 1 1,-1 1 1,0.5 0.5 1,0.5 1 1)),((0.5 1.5 1.5,0.5 1 1,0.5 0.5 1,0.5 1.5 1.5)),((0.5 1.5 0.5,0.5 1.5 1.5,1.5 1.5 1.5,0.5 1.5 0.5)),((1.5 1.5 0.5,1.5 1.5 1.5,1.5 0.5 1.5,1.5 1.5 0.5)),((1 0.5 0.5,1.5 1.5 0.5,1.5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0.5 -0.5,1.5 -0.5 -0.5,1 -0.5 -0,1 -0.5 -0.5)),((1 -1 -1,1 -0.5 -0.5,1 -0.5 -0,1 -1 -1)),((1 -1 1,1 -0.5 -0,1 -0.5 0.5,1 -1 1)),((0.5 -0.5 1,1 -1 1,1 -0.5 1,0.5 -0.5 1)),((1.5 -0.5 1.5,1 -0.5 1,1 -0.5 0.5,1.5 -0.5 1.5)),((1.5 -0.5 -0.5,1 -0.5 0.5,1 -0.5 -0,1.5 -0.5 -0.5)),((1 -1 1,1 -0.5 0.5,1 -0.5 1,1 -1 1))))");
std::auto_ptr<Geometry> diff1 = algorithm::difference3D( *g1, *g2, algorithm::NoValidityCheck() );
std::auto_ptr<Geometry> diff2 = algorithm::difference3D( *g2, *g1, algorithm::NoValidityCheck() );
}
}