Subject: CGAL users discussion list
List archive
- From: Chris Theis <>
- To:
- Subject: [cgal-discuss] Polyhedron validity and closure
- Date: Wed, 20 Feb 2013 02:47:20 -0800 (PST)
Hello,
I've been trying to do some boolean ops on polyhedra and encountered a
number of spurious asserts which I could trace back to problems in my
polyhedron definition. However, I can't really see the problem and maybe
there is some fundamental misunderstanding on my side.
I'm trying to create for example a simple triangulated box. For this purpose
I have written a builder function:
---------------------------------------------------------------------------------------------------------
void operator()( HDS& HalfEdgeDS ) {
CGAL::Polyhedron_incremental_builder_3<HDS> BuilderObj( HalfEdgeDS,
true);
assert( !(m_Vertices.size() % 3) ); // m_Vertices = vector keeping
all vertices of the polyhedron
for( size_t i = 0; i < m_Vertices.size(); i += 3 ) {
BuilderObj.begin_surface( 3, 1 );
BuilderObj.add_vertex( Point( m_Vertices[i].X, m_Vertices[i].Y,
m_Vertices[i].Z ) );
BuilderObj.add_vertex( Point( m_Vertices[i+1].X, m_Vertices[i+1].Y,
m_Vertices[i+1].Z ) );
BuilderObj.add_vertex( Point( m_Vertices[i+2].X, m_Vertices[i+2].Y,
m_Vertices[i+2].Z ) );
BuilderObj.begin_facet();
BuilderObj.add_vertex_to_facet( 0 );
BuilderObj.add_vertex_to_facet( 1 );
BuilderObj.add_vertex_to_facet( 2 );
BuilderObj.end_facet();
BuilderObj.end_surface();
}
}
---------------------------------------------------------------------------------------------------------
When I then create a box I can export it to an OFF file and view it without
any problem. However, if I call the is_valid() function I'm told that my
structure is not valid. It contains 72 half-edges (I would have expected 6
faces * 2 triangles = 36 half-edges) and every second HE is reported as a
border half edge. Consequently, the solid does not classify as closed and
boolean ops with nef-polyhedra fail.
As a test I tried to build the solid with the make_triangle function like
this:
---------------------------------------------------------------------------------------------------------
Poly.make_triangle( CGPoint( 0.0, 0.0, 0.0 ), CGPoint( 0.0, 1.0, 0.0 ),
CGPoint( 1.0, 0.0, 0.0 ) );
Poly.make_triangle( CGPoint( 1.0, 0.0, 0.0 ), CGPoint( 0.0, 1.0, 0.0 ),
CGPoint( 1.0, 1.0, 0.0 ) );
Poly.make_triangle( CGPoint( 0.0, 0.0, 0.0 ), CGPoint( 1.0, 0.0, 0.0 ),
CGPoint( 0.0, 0.0, 1.0 ) );
Poly.make_triangle( CGPoint( 0.0, 0.0, 1.0 ), CGPoint( 1.0, 0.0, 0.0 ),
CGPoint( 1.0, 0.0, 1.0 ) );
Poly.make_triangle( CGPoint( 0.0, 0.0, 0.0 ), CGPoint( 0.0, 0.0, 1.0 ),
CGPoint( 0.0, 1.0, 0.0 ) );
Poly.make_triangle( CGPoint( 0.0, 1.0, 0.0 ), CGPoint( 0.0, 0.0, 1.0 ),
CGPoint( 0.0, 1.0, 1.0 ) );
Poly.make_triangle( CGPoint( 0.0, 0.0, 1.0 ), CGPoint( 1.0, 0.0, 1.0 ),
CGPoint( 0.0, 1.0, 1.0 ) );
Poly.make_triangle( CGPoint( 0.0, 1.0, 1.0 ), CGPoint( 1.0, 0.0, 1.0 ),
CGPoint( 1.0, 1.0, 1.0 ) );
Poly.make_triangle( CGPoint( 1.0, 0.0, 0.0 ), CGPoint( 1.0, 1.0, 0.0 ),
CGPoint( 1.0, 0.0, 1.0 ) );
Poly.make_triangle( CGPoint( 1.0, 0.0, 1.0 ), CGPoint( 1.0, 1.0, 0.0 ),
CGPoint( 1.0, 1.0, 1.0 ) );
Poly.make_triangle( CGPoint( 0.0, 1.0, 0.0 ), CGPoint( 0.0, 1.0, 1.0 ),
CGPoint( 1.0, 1.0, 0.0 ) );
Poly.make_triangle( CGPoint( 1.0, 1.0, 0.0 ), CGPoint( 0.0, 1.0, 1.0 ),
CGPoint( 1.0, 1.0, 1.0 ) );
---------------------------------------------------------------------------------------------------------
However, the result was exactly the same.
I would appreciate if somebody could shed some light on this issue because I
do not really understand where the border half-edges come from. In my
current understanding border half edges are adjacent to holes and thus, have
no face connected to them. However, I do not have any holes in my polyhedron
or do I?
Thanks a lot
Chris
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Polyhedron-validity-and-closure-tp4656773.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Polyhedron validity and closure, Chris Theis, 02/20/2013
- Re: [cgal-discuss] Polyhedron validity and closure, Sebastien Loriot (GeometryFactory), 02/20/2013
- RE: [cgal-discuss] Polyhedron validity and closure, Chris Theis, 02/20/2013
- Re: [cgal-discuss] Polyhedron validity and closure, Sebastien Loriot (GeometryFactory), 02/20/2013
Archive powered by MHonArc 2.6.18.