Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Joining faces in polyhedron

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Joining faces in polyhedron


Chronological Thread 
  • From: Mathieu Brédif <>
  • To:
  • Subject: Re: [cgal-discuss] Joining faces in polyhedron
  • Date: Wed, 6 May 2009 18:08:43 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :content-transfer-encoding; b=DOCBqAXe8BI6iGtP6j+oHlJV3qrhK6baeiAcwsx170L/o4zYOYAL6noEQ5fMdusrOS MqSSAsSHdACNfK4UA7MLQ+ymhKsB4zPZzEXBlQn3cCaRjObPbGILd2LSihPfOIt0AKf1 4wVKPKHTL63IlT4D4mptXre5bdFGMAoqZmNuU=

Hi,

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 the copy
> in the body of the loop.
> This is because the halfedges are in an in-place list, your join operation
> removes 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 stored
> consecutively.
> 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 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
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>



Archive powered by MHonArc 2.6.16.

Top of Page