Subject: CGAL users discussion list
List archive
- From: Andreas Fabri <>
- To:
- Subject: Re: [cgal-discuss] Joining faces in polyhedron
- Date: Thu, 07 May 2009 08:11:14 +0200
Joel,
it would be helpful, if you saved the polyhedron just before the join
operation fails.
Ideally, you provide a minimalistic example, and you tell us on which edge,
that is
which two points, it fails. Then we can try to have a look.
andreas
wrote:
Thanks for the help, the iteration works now.
Sorry, I dont really know what an antenna is in the context of a polyhedron.
I will try to clarify what I want to do:
My input mesh is a triangle mesh, for example a cube.
This cube consists of 12 triangles, 2 for each side.
What I want to have is a polyhedron with 6 polygons (quads in this case).
For the simple example of the cube it works well, but when I want to do the
same with a triangulated quad consisting of many triangles, there are many
edges which can not be joined via polyhedron.join_facet(...).
I dont really know the reason for that, it would be nice if someone could
explain that.
Joel
-------- Original-Nachricht --------
Datum: Wed, 06 May 2009 21:48:52 +0200
Von: "Dr. J.K. Becker"
<>
An:
Betreff: Re: [cgal-discuss] Joining faces in polyhedron
I am not sure if I really understood this Mathieu, but would that not be
an antenna which CGAL really does not like at all anyway (CGAL is happy
to produce one, but any further operations on a polyhedron with an
antenna will fail, at least it does for me)? And no, as far as I know,
there are no build in checks for antennas...
Anyway, polyhedra (or polygons) can have holes, no problem with that in
CGAL.
Joel, I am not sure I understood what you want to do correctly, but if
you want to join all incident facets of a 3D triangulation that have
the same normal, you will not join anything really (at least you will
most likely never end up with a closed polyhedron)?! Except if you
started of with a regular grid of points for the triangulation, but in
that case you dont really need to triangulate anything? I am trying to
figure out something very similar (and have not solved it) so maybe I am
completely wrong....
Jens
On Wed, 2009-05-06 at 18:08 +0200, Mathieu Brédif wrote:
Hi,the copy
If I am not mistaken, polyhedral facets may not have holes in CGAL.
This means that you can only remove edges if they are not adjacent to
the same face on both sides.
Mathieu
On Wed, May 6, 2009 at 5:52 PM, Andreas Fabri
<>
wrote:
Hi Joel,
You must make a copy of the iterator, increment it and then work on
operationin the body of the loop.
This is because the halfedges are in an in-place list, your join
storedremoves them and the iterator
no longer points on something reasonable
for ( Halfedge_iterator j = polyhedron.halfedges_begin(); j !=
polyhedron.halfedges_end(); ){
Halfedge_iterator i = j;
++j;
// and now your code again
.
.
}
I think you have even to increment j twice, as the twin halfedges are
toconsecutively.
Alternatively you should use an Edge_iterator.
andreas
wrote:
Hi!
I am trying to convert a triangle mesh to a polyhedron, i.e. I want
.offjoin all faces which are adjacent and have the same normal
As an easy example I chose a flat patch consisting of triangles in
singleformat. As a result I want to have a polyhedron consisting of a
becomespolygon.
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
--invalid--
- some faces cannot be joined, but why and how can I change that?
Can anyone help me please?
Have a nice day,
Joel
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [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.