Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] h->opposite()->facet() always invalid using Polyhedron_incremental_builder_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] h->opposite()->facet() always invalid using Polyhedron_incremental_builder_3


Chronological Thread 
  • From: Evan Behar <>
  • To:
  • Subject: Re: [cgal-discuss] h->opposite()->facet() always invalid using Polyhedron_incremental_builder_3
  • Date: Wed, 6 Mar 2013 02:28:57 -0500

Ah, nevermind. As I was preparing code to send you to look at, I discovered that I was incorrectly loading the geometry from the file, which was resulting in problems with the polyhedron--it wasn't the fault of the builder at all.

Thanks for your help!


On Wed, Mar 6, 2013 at 12:56 AM, Sebastien Loriot (GeometryFactory) <> wrote:
The code looks OK.
Do you call delegate several times on the same polyhedron?
Having an example I can compile and run would be nice as I have no other idea for now.

Sebastien.


On 03/06/2013 06:43 AM, Evan Behar wrote:
I am loading the model from an OBJ file--first I read in the vertices
and facets from the OBJ file and then I am constructing the polyhedron
using those values. I add the vertices all at once and then construct
the facets using the vertex indices, so I am almost certainly reusing
the vertices. The modifier code is below:

class Build_polyhedron : public
CGAL::Modifier_base<Polyhedron::HalfedgeDS> {
   public:
     Build_polyhedron() {}
     void operator()(Polyhedron::HalfedgeDS& hds) {
       CGAL::Polyhedron_incremental_builder_3<Polyhedron::HalfedgeDS>
builder(hds,true);
       const std::vector<Point>& vertices = OBJReader::vertices;
       const std::vector<std::vector<int> >& facets = OBJReader::facets;

       builder.begin_surface(vertices.size(),facets.size());

       // add vertices
       for (int i=0;i<vertices.size();i++) {
         builder.add_vertex(vertices[i]);
       }

       // add facets
       for (int i=0;i<facets.size();i++) {
         builder.begin_facet();

         for (int j=0;j<facets[i].size();j++) {
           builder.add_vertex_to_facet(facets[i][j]);
         }

         Halfedge_handle h = builder.end_facet();
         std::cout << "Validating...\n";
         if (h->opposite()->facet() != Facet_handle()) {
           std::cout << "Opposite halfedge's facet not invalid!\n";
         }
       }

       builder.end_surface();
     }
};



On Wed, Mar 6, 2013 at 12:37 AM, Sebastien Loriot (GeometryFactory)
< <mailto:>> wrote:

    Can you give more information like the modifier you wrote for example?

    A common mistake is not reusing the vertices. If you add two vertices
    with the same coordinates, they will be consider as different.

    Sebastien.

    On 03/06/2013 05:51 AM, Evan Behar wrote:

        I have constructed a Polyhedron_3, /P/, using the

        Polyhedron_incremental___builder_3, and I am running into the

        problem that
        none of the halfedges in the structure are being associated with any
        opposite halfedges that have been previously constructed.

        After construction, retrieving a Halfedge_handle /h/ from /P /and
        calling /h->opposite()->facet()/ always results in an invalid
        Facet_handle.


        Is this expected behavior from
        Polyhedron_incremental___builder_3? Do I

        have to stitch the facets together manually?



    --
    You are currently subscribed to cgal-discuss.
    To unsubscribe or access the archives, go to
    https://sympa.inria.fr/sympa/__info/cgal-discuss
    <https://sympa.inria.fr/sympa/info/cgal-discuss>





--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss






Archive powered by MHonArc 2.6.18.

Top of Page