Subject: CGAL users discussion list
List archive
- From: Stephen Wong <>
- To: "" <>
- Subject: [Nef_polyhedron_3] Crash during boolean operations execution
- Date: Tue, 29 Jan 2008 11:41:05 -0800
- Accept-language: en-US, en-CA
- Acceptlanguage: en-US, en-CA
Hi there, I have encountered a crash during execution of boolean operations
on a data set. The assertion is below. CGAL error: assertion
violation! Expr: itl !=
it->second.end() File: $(CGALROOT)\include\CGAL/Nef_3/SNC_external _structure.h Line: 567 If the assertion is ignored, a null-pointer reference occurs
in make_twins() a few lines below that code. I have attached the
offending files, and a modification of the example “interface_polyhedron”
program that demonstrates this error. The kernels I have used are Cartesian<Gmpq> and Exact_predicates_exact_constructions_kernel.
I know the input files are ugly (a.off is pretty ugly), but they pass
is_valid() and is_closed()/is_simple() tests both in Polyhedron_3 and
Nef_polyhedron_3. If anyone can provide any more details regarding how to
avoid this kind of error, or why this is happening, I am glad to hear it! Thanks, Stephen |
#include <CGAL/Gmpq.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/IO/Nef_polyhedron_iostream_3.h>
#include <iostream>
#include <fstream>
typedef CGAL::Cartesian<CGAL::Gmpq> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Aff_transformation_3 Aff_transformation_3;
Polyhedron* loadPolyFromFile( const char* file )
{
std::ifstream fin( file ) ;
if ( !fin.is_open() ) return NULL ;
Polyhedron* p = new Polyhedron() ;
fin >> *p ;
if ( p->is_closed() && p->is_valid() )
{
// Only return when closed and valid.
return p ;
}
else
{
delete p ;
return NULL ;
}
}
void savePolyToFile( const Polyhedron& p )
{
std::ofstream fout( "out.off" ) ;
fout << p ;
fout.close() ;
}
int main()
{
Polyhedron* p1 = loadPolyFromFile( "a.off" ) ;
Polyhedron* p2 = loadPolyFromFile( "a2.off" ) ;
Polyhedron* p3 = loadPolyFromFile( "b.off" ) ;
if ( !p1 || !p2 || !p3 )
{
std::cerr << "Error loading files..." << std::endl ;
exit( 1 ) ;
}
Nef_polyhedron n1( *p1 ) ;
if ( !n1.is_simple() || !n1.is_valid() )
{
std::cerr << "n1 is not a 2-manifold." << std::endl ;
exit( 1 ) ;
}
Nef_polyhedron n2( *p2 ) ;
if ( !n2.is_simple() || !n2.is_valid() )
{
std::cerr << "n2 is not a 2-manifold." << std::endl ;
exit( 1 ) ;
}
Nef_polyhedron n3( *p3 ) ;
if ( !n3.is_simple() || !n3.is_valid() )
{
std::cerr << "n3 is not a 2-manifold." << std::endl ;
exit( 1 ) ;
}
Nef_polyhedron n = n1 - n2 - n3 ; // <-- Crashes here...
if ( n.is_simple() )
{
Polyhedron p ;
n.convert_to_Polyhedron( p ) ;
savePolyToFile( p ) ;
}
else
{
std::cerr << "N1 is not a 2-manifold." << std::endl;
}
// Clean up.
delete p1 ;
delete p2 ;
delete p3 ;
exit( 0 ) ;
}
Attachment:
a.off
Description: a.off
Attachment:
a2.off
Description: a2.off
Attachment:
b.off
Description: b.off
- [Nef_polyhedron_3] Crash during boolean operations execution, Stephen Wong, 01/29/2008
- Re: [cgal-discuss] [Nef_polyhedron_3] Crash during boolean operations execution, Peter Hachenberger, 01/30/2008
Archive powered by MHonArc 2.6.16.