Subject: CGAL users discussion list
List archive
- From:
- To:
- Subject: [cgal-discuss] Joining faces in polyhedron
- Date: Wed, 06 May 2009 17:36:41 +0200
Hi!
I am trying to convert a triangle mesh to a polyhedron, i.e. I want to join
all faces which are adjacent and have the same normal
As an easy example I chose a flat patch consisting of triangles in .off
format. As a result I want to have a polyhedron consisting of a single
polygon.
I was able to load the file, but the follwoing did not work:
for ( Halfedge_iterator i = polyhedron.halfedges_begin(); i !=
polyhedron.halfedges_end(); ++i)
{
if( i->is_border_edge() )
continue;
Polyhedron::Facet_handle f1 = i->facet();
Polyhedron::Facet_handle f2 = i->opposite()->facet();
Halfedge_handle he1 = f1->halfedge();
Point_3 p0 = he1->vertex()->point();
Point_3 p1 = he1->next()->vertex()->point();
Point_3 p2 = he1->next()->next()->vertex()->point();
Kernel::Vector_3 n_i = CGAL::cross_product(p0-p2, p1-p2);
n_i = n_i / sqrt(n_i.squared_length());
Halfedge_handle he2 = f2->halfedge();
p0 = he2->vertex()->point();
p1 = he2->next()->vertex()->point();
p2 = he2->next()->next()->vertex()->point();
Kernel::Vector_3 n_j = CGAL::cross_product(p0-p2, p1-p2);
n_j = n_j / sqrt(n_j.squared_length());
if(n_i == n_j)
{
if( circulator_size(i->opposite()->vertex_begin()) >= 3 &&
circulator_size(i->vertex_begin()) >= 3 )
polyhedron.join_facet(i);
}
}
There seem to be 2 problems:
- after joining to faces the iterator becomes invalid
- some faces cannot be joined, but why and how can I change that?
Can anyone help me please?
Have a nice day,
Joel
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen:
http://www.gmx.net/de/go/multimessenger01
- [cgal-discuss] Joining faces in polyhedron, joelMynes78, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Andreas Fabri, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Mathieu Brédif, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Dr. J.K. Becker, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, joelMynes78, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Andreas Fabri, 05/07/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Dr. J.K. Becker, 05/07/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Andreas Fabri, 05/07/2009
- Re: [cgal-discuss] Joining faces in polyhedron, joelMynes78, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Dr. J.K. Becker, 05/06/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Mathieu Brédif, 05/06/2009
- <Possible follow-up(s)>
- Re: [cgal-discuss] Joining faces in polyhedron, joelMynes78, 05/07/2009
- Re: [cgal-discuss] Joining faces in polyhedron, Andreas Fabri, 05/06/2009
Archive powered by MHonArc 2.6.16.