Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Facet soup to solids

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Facet soup to solids


Chronological Thread 
  • From: GIS Worx <>
  • To:
  • Subject: Re: [cgal-discuss] Facet soup to solids
  • Date: Wed, 9 May 2012 13:54:26 -0700

Here's a simple example of what I mean:

I have 13 faces (not all explicitly defined for simplicity here), 6 stitch into one cube, 6 stitch into another cube, one does not nicely stitch into either cube. The two cubes touch along a face, I would like to see the two cube output, not simply the simplified union of the two cubes.

/// 
  CGAL::Nef_nary_union_3<CGALNefPolyhedron> nary_union;
  
   typedef CGALNefPolyhedron::Point_3 Point3;
   typedef CGALNefPolyhedron::Vector_3 Vector3;

   //These define a first unit cube
   Point3 face1[4] = {Point3(0,0,0),Point3(0,1,0),Point3(1,1,0),Point3(1,0,0)};
   Point3 face2[4] = {Point3(0,1,0),Point3(0,0,0),Point3(0,0,1),Point3(0,1,1)};
   Point3 face3[4] = {Point3(1,0,0),Point3(1,1,0),Point3(1,1,1),Point3(1,0,1)};
   Point3 face4[4] = {Point3(0,0,0),Point3(1,0,0),Point3(1,0,1),Point3(0,0,1)};
   Point3 face5[4] = {Point3(1,1,0),Point3(0,1,0),Point3(0,1,1),Point3(1,1,1)};
   Point3 face6[4] = {Point3(0,0,1),Point3(1,0,1),Point3(1,1,1),Point3(0,1,1)};

   CGALNefPolyhedron currNef1(&face1[0], &face1[0]+4, Vector3(0,0,-1));
   if(!currNef1.is_empty()) { nary_union.add_polyhedron(currNef1); }
   CGALNefPolyhedron currNef2(&face2[0], &face2[0]+4, Vector3(-1,0,0));
   if(!currNef2.is_empty()) { nary_union.add_polyhedron(currNef2); }
   CGALNefPolyhedron currNef3(&face3[0], &face3[0]+4, Vector3(1,0,0));
   if(!currNef3.is_empty()) { nary_union.add_polyhedron(currNef3); }
   CGALNefPolyhedron currNef4(&face4[0], &face4[0]+4, Vector3(0,-1,0));
   if(!currNef4.is_empty()) { nary_union.add_polyhedron(currNef4); }
   CGALNefPolyhedron currNef5(&face5[0], &face5[0]+4, Vector3(0,1,0));
   if(!currNef5.is_empty()) { nary_union.add_polyhedron(currNef5); }
   CGALNefPolyhedron currNef6(&face6[0], &face6[0]+4, Vector3(0,0,1));
   if(!currNef6.is_empty()) { nary_union.add_polyhedron(currNef6); }
  
   //Here's the first cube
   CGALNefPolyhedron firstCube = nary_union.get_union();

   //These define an irrelevant face that touches the cubes
   Point3 face7[4] = {Point3(0,0,0),Point3(10,0,0),Point3(10,10,0),Point3(0,10,0)};
   CGALNefPolyhedron extraFace(&face7[0], &face7[0]+4, Vector3(0,0,1));
 
   //This defines a unit cube next to the first
   CGALNefPolyhedron::Aff_transformation_3 transl(CGAL::TRANSLATION, Vector3(1, 0, 0));
   CGALNefPolyhedron secondCube(firstCube);
   secondCube.transform(transl);
  
   CGAL::Nef_nary_union_3<CGALNefPolyhedron> scene;
   scene.add_polyhedron(firstCube);
   scene.add_polyhedron(secondCube);
   scene.add_polyhedron(extraFace);
   CGALNefPolyhedron scene_union = scene.get_union();


   CGAL::Mark_bounded_volumes<CGALNefPolyhedron> mbv (true);
   scene_union.delegate(mbv);
   size_t numVols = scene_union.number_of_volumes();
   size_t numFaces = scene_union.number_of_facets();
   size_t numSFaces = scene_union.number_of_sfaces();
   size_t numVertices = scene_union.number_of_vertices();
   size_t numLoops = scene_union.number_of_shalfloops();
///

This example is the one I was referring to in my earlier post, what I'd expect to see is numVols=4 and numFaces=13.

In answer to your questions:
The input will not be necessarily clean like this, although we can assume that there is no ugly intersections between input facets. Solids will not necessarily be valid 2-manifolds when other solids are also taken into consideration. We could have some dangling faces (facets) at the end of the process, not all input faces are guaranteed to participate in a solid. I need to be able to navigate the populated data structure so that I can determine which input faces contributed to what solid construction and also to retrieve the dangling/isolated faces. The touching facets between solids may not be perfectly matched (there may be a small cube sitting along side a very large cube (only part of the facet being shared).

The general goal is to go from an unorganized collection of faces to a collection containing as many constructed solids as possible as well as the remaining faces.

Thanks!

On Tue, May 8, 2012 at 11:40 PM, Sebastien Loriot (GeometryFactory) <> wrote:

Do you have a minimal example to share?

I am not sure to fully understand what your input are.
Is the facet shared by your cubes perfectly match (in term of
coordinates of the vertices) in each cube?
Could you have some dangling edges later on?
Do you have some boolean operation to do on this structure then
of is it simply to navigate inside?

I am asking these questions because you might be interested by these packages:
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Linear_cell_complex/Chapter_main.html
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Combinatorial_map/Chapter_main.html

Sebastien.


On 05/09/2012 12:38 AM, GIS Worx wrote:
Thank you for the suggestion Cody.

So I've attempted to construct a simple example, with two unit cubes,
constructing each using the Nef_polyhedra constructor that takes a
boundary and a normal as a separate Nef polyhedron, and then adding it
to a Nef_nary_union_3. Looking at the methods in this class, it doesn't
appear that any calls to .simplify() are made, I would assume this is
what you mean by regularizing the result.

However, inspecting the result of the Nef_nary_union of these 12 faces
defining two cubes (which are touching along a face), I see
number_of_facets() = 6 and number_of_volumes() = 2. Based on the manual
descriptions, I would hope to see the answers here be 12, and 4, so that
I have two independent cubes in the result.

There doesn't seem to be anything I can do to prevent the loss of that
shared face.

On Tue, May 8, 2012 at 10:59 AM, Cody Rose <
<mailto:>> wrote:

   Would taking the union without regularizing the result do what you need?

   On May 8, 2012, at 10:38 AM, GIS Worx <
   <mailto:>> wrote:

    > Hi everyone,
    >
    > I've spent quite a bit of time reading documentation and trying
   to devise a way to accomplish the following:
    >
    > Given a bag of planar facets, seal them, where possible, into
   closed polyhedrons, and return the remnants, as well as the newly
   constructed polyhedrons.
    >
    > Reading the Polyhedron_3 and Nef_Polyhedron documentation, it
   seems like the approach that comes closest is this:
    >
    > Use Nef_Polyhedron to define each facet, and then take the union
   of every facet, then the closed volumes can be marked and it's
   possible to iterate through the results. My problem with this method
   is that it will remove 'seams' between solids according to the union
   operation.
    >
    > If you imagine a two cubes, side by side, each defined by six
   faces, I would like two cubes back, each represented by six faces,
   not a single unified solid.
    >
    > I am not immediately concerned with performance, which can be
   solved externally to this particular problem.
    >
    > Is there a pathway to accomplish this within CGAL that I am
   missing? Is there a way to 'merge' two Nef_Polyhedra in a way that
   will maintain shared faces?
    >

   --
   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





Archive powered by MHonArc 2.6.16.

Top of Page