Subject: CGAL users discussion list
List archive
[cgal-discuss] Problems loading ply files using Polyhedron_incremental_builder_3
Chronological Thread
- From: Time4Breakfast <>
- To:
- Subject: [cgal-discuss] Problems loading ply files using Polyhedron_incremental_builder_3
- Date: Sun, 25 Dec 2011 11:10:00 -0800 (PST)
Hello,
I am new to CGAL and I am working with 3D data coming from a 3D scanner. The
format is ply and the code to read the vertices and faces in, looks as
follows:
void operator()( HalfedgeDS& hds )
{
CGAL::Polyhedron_incremental_builder_3<HalfedgeDS> builder( hds,
true);
builder.begin_surface( _v.size(), _fid.size()/3 );
// add the vertices
for( std::vector<VPosition>::const_iterator v = _v.begin();
v != _v.end(); ++v )
builder.add_vertex( HalfedgeDS::Vertex::Point( (*v)[0], (*v)[1],
(*v)[2] ));
// add the faces
for( std::vector<unsigned int>::const_iterator fid = _fid.begin();
fid != _fid.end(); )
{
builder.begin_facet();
for( int i = 0; i < 3; ++i, ++fid )
builder.add_vertex_to_facet( *fid );
builder.end_facet();
}
builder.end_surface();
}
The code works fine for all kinds of ply data, yet the data coming from the
scanner contains errors, which the Polyhedron_incremental_builder_3 from
CGAL detects throwing this exception (it occurs while adding the faces):
lookup_halfedge(): input error: facet 11363 shares a halfedge from vertex
42557 to vertex 42523 with facet 8714.
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: check_protocoll == 0
File: /usr/include/CGAL/Polyhedron_incremental_builder_3.h
Line: 198
As I cannot alter the data from the scanner, I have to alter the code, that
reads in the data. I thought about something like this:
// add the faces
for( std::vector<unsigned int>::const_iterator fid = _fid.begin();
fid != _fid.end(); )
{
builder.begin_facet();
CGAL::Failure_behaviour set_error_behaviour (
CGAL::Failure_behaviour eb);
enum Failure_behaviour { CONTINUE };
for( int i = 0; i < 3; ++i, ++fid )
builder.add_vertex_to_facet( *fid );
builder.end_facet();
}
builder.end_surface();
}
But this does not change anything (see preliminaries in the CGAL Manual):
"The CONTINUE value tells the checks to go on after diagnosing the error.
Note that since Cgal 3.4, CONTINUE has the same effect as THROW_EXCEPTION
for errors (but it keeps its meaning for warnings), it is not possible
anymore to let assertion failures simply continue (except by totally
disabling them)." But I don't want to globally disable assertion handling.
So my question is: how can I just ignore erroneous faces?
Best regards and a merry christmas
time4breakfast
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Problems-loading-ply-files-using-Polyhedron-incremental-builder-3-tp4233251p4233251.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Problems loading ply files using Polyhedron_incremental_builder_3, Time4Breakfast, 12/25/2011
- Re: [cgal-discuss] Problems loading ply files using Polyhedron_incremental_builder_3, Sebastien Loriot (GeometryFactory), 12/26/2011
- [cgal-discuss] Re: Problems loading ply files using Polyhedron_incremental_builder_3, Time4Breakfast, 12/27/2011
- Re: [cgal-discuss] Re: Problems loading ply files using Polyhedron_incremental_builder_3, Sebastien Loriot (GeometryFactory), 12/27/2011
- [cgal-discuss] Re: Problems loading ply files using Polyhedron_incremental_builder_3, Time4Breakfast, 12/27/2011
- Re: [cgal-discuss] Problems loading ply files using Polyhedron_incremental_builder_3, Sebastien Loriot (GeometryFactory), 12/26/2011
Archive powered by MHonArc 2.6.16.