Rendering Polyhedron

26 views
Skip to first unread message

Rol

unread,
Feb 5, 2014, 3:54:33 AM2/5/14
to cgal-bindi...@googlegroups.com
Hello,

I'm using cgal-bindings with CGAL 4.3 and trying to render a polyhedron using processing 2. I've found that the hasNext() method of Polyhedron_3_Halfedge_around_facet_circulator seems to always return true. I've resorted to the following but it's obviously not ideal:

public void draw_facet(Polyhedron_3_Facet_handle fh) 
    { 
        // revolve around current face to get vertices 
        Polyhedron_3_Halfedge_around_facet_circulator   hec = fh.facet_begin(); 
        
        int i = 0;
        beginShape();
        while(i<3){
          Polyhedron_3_Halfedge_handle current  = hec.next();
          Point_3  point = current.vertex().point();
          vertex((float) point.x()*800f, (float) point.y() *800f, (float) point.z()*800f);
          i++;
        }
        endShape(CLOSE);
       
    } 

I'd like to have the while loop look like this:

while(hec.hasNext()){
    Polyhedron_3_Halfedge_handle current  = hec.next();
    Point_3  point = current.vertex().point();
    vertex((float) point.x()*800f, (float) point.y() *800f, (float) point.z()*800f);
}

But due to the the problem with hasNext() always returning true this doesn't work. Any ideas on what I'm doing wrong here?

Thanks,

Roland

Sebastien Loriot (GeometryFactory)

unread,
Feb 5, 2014, 9:14:19 AM2/5/14
to cgal-bindi...@googlegroups.com
A circulator by definition does not have an end.
A solution is to store the first halfedge and stop when all are visited.

Polyhedron_3_Halfedge_handle current = hec.next();
while (current!=hec)
{
Point_3 point = current.vertex().point()
vertex((float) point.x()*800f, (float) point.y() *800f, (float)
point.z()*800f);
current=current.next();
}

Sebastien.
> --
> You received this message because you are subscribed to the Google
> Groups "CGAL Bindings discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cgal-bindings-di...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Rol

unread,
Feb 6, 2014, 3:14:21 AM2/6/14
to cgal-bindi...@googlegroups.com
That helped. The only issue I had worth noting for anyone else looking at this was that I had to compare the edges using the notequals method of the current half edge so:

while(current.not_equals(start))

rather than:

while(current != start)

Thanks for your help.

Reply all
Reply to author
Forward
0 new messages