Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Polyhedron validity and closure

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Polyhedron validity and closure


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Polyhedron validity and closure
  • Date: Wed, 20 Feb 2013 11:54:04 +0100
  • Organization: GeometryFactory

make_triangle creates 3 new vertices each time, even if a vertex with the same point exists.

The same goes for the incremental builder, each time you call
add_vertex, a new vertex is created. You need a side data-structure
to check if you already created a given vertex and get its index.

If you can't make everything in one builder call, you'll need to look
at the indexing mode documented here:

http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Polyhedron_ref/Class_Polyhedron_incremental_builder_3.html

Sebastien.


On 02/20/2013 11:47 AM, Chris Theis wrote:
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.





Archive powered by MHonArc 2.6.18.

Top of Page