Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

hossan.nazmul
Dear CGAL mailing list,

I am a CGAL beginner and have few problems using Polyhedron_3 class.

Problem description:
I have a LoD2 3D CityGML building that has to be decomposed and stored in a topological data structure such like Half edge data structure. I was searching for an example CGAL program that takes the Polygon (Vertices) as an input and is able to store it into Half edge data structure. The LinearRing is consists of points which represent actually a polygon:

for an example: (my polygon looks like following)
<gml:Polygon gml:id="GEOM_629113">
<gml:exterior>
<gml:LinearRing gml:id="GEOM_629113_0_">
<gml:posList srsDimension="3">390839.695902067 5819139.47788488 33.8699989318848 390839.20858174 5819139.44457522 33.8699989318848 390838.722880716 5819139.49639365 33.8699989318848 390841.021950274 5819140.0657906 33.8699989318848 390840.616573399 5819139.79328419 33.8699989318848 </gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>

Questions:
Q1: How do I store these 3D points/vertices into a CGAL half edge data structure?
Q2: How do I know from the data that which is the next half edge, previous half edge, incident vertex and etc
Q3: I can make a triangle with three points and create a CGAL Polyhedron object. How can I combine all points and store into half edge data structure?

I hope someone from this CGAL discussion group can help me to find the possible solution to my problem. It would be a great help if you can share some example code so that I can understand it easily.

Thanks and regards,
Nazmul
Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

Sebastien Loriot (GeometryFactory)
If you want to stick to Polyhedron_3, the original mechanism was using
the incremental builder:
http://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__incremental__builder__3.html

If you can switch to Surface_mesh, then you have function available
doing exactly what you want:
http://doc.cgal.org/latest/Surface_mesh/classCGAL_1_1Surface__mesh.html#ad2e8dedad669cb3637d6a7f8207caed5
http://doc.cgal.org/latest/Surface_mesh/classCGAL_1_1Surface__mesh.html#a47c2561d1430def60b9e538482ea2adb

If you want to write code that does not depend on the data structure,
you can use the BGL API:

put(get(CGAL::vertex_point, sm), add_vertex(sm), point_coordinates);

and use the helper function for creating a face:

http://doc.cgal.org/latest/BGL/group__PkgBGLEulerOperations.html#gada1dd2320a083dbfe09ddacafdaf8b19

Sebastien.

On 03/18/2017 08:10 PM, hossan.nazmul wrote:

> Dear CGAL mailing list,
>
> I am a CGAL beginner and have few problems using Polyhedron_3 class.
>
> Problem description:
> I have a LoD2 3D CityGML building that has to be decomposed and stored in a
> topological data structure such like Half edge data structure. I was
> searching for an example CGAL program that takes the Polygon (Vertices) as
> an input and is able to store it into Half edge data structure. The
> LinearRing is consists of points which represent actually a polygon:
>
> for an example: (my polygon looks like following)
> <gml:Polygon gml:id="GEOM_629113">
> <gml:exterior>
> <gml:LinearRing gml:id="GEOM_629113_0_">
> <gml:posList srsDimension="3">390839.695902067 5819139.47788488
> 33.8699989318848 390839.20858174 5819139.44457522 33.8699989318848
> 390838.722880716 5819139.49639365 33.8699989318848 390841.021950274
> 5819140.0657906 33.8699989318848 390840.616573399 5819139.79328419
> 33.8699989318848 </gml:posList>
> </gml:LinearRing>
> </gml:exterior>
> </gml:Polygon>
>
> Questions:
> Q1: How do I store these 3D points/vertices into a CGAL half edge data
> structure?
> Q2: How do I know from the data that which is the next half edge, previous
> half edge, incident vertex and etc
> Q3: I can make a triangle with three points and create a CGAL Polyhedron
> object. How can I combine all points and store into half edge data
> structure?
>
> I hope someone from this CGAL discussion group can help me to find the
> possible solution to my problem. It would be a great help if you can share
> some example code so that I can understand it easily.
>
> Thanks and regards,
> Nazmul
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Store-a-polygon-into-a-half-edge-data-structure-using-CGAL-Polyhedron-3-class-tp4662587.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>


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


Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

hossan.nazmul
This post was updated on .
Hello Sebastien,
Thanks a lot for your reply. I played a little and now is able to store my points into the CGAL::Surface_mesh<Point_3>. I have Linear Rings which are the faces of the Polyhedron/Surface mesh (I presume). If I use CGAL::Surface_mesh the I have two possibility to insert those points to faces. e.g.

        vertex_descriptor u = mesh.add_vertex(Kernel::Point_3(0, 0, 0));
        vertex_descriptor v = mesh.add_vertex(Kernel::Point_3(1, 0, 0));
        vertex_descriptor w = mesh.add_vertex(Kernel::Point_3(1, 1, 0));
        vertex_descriptor x = mesh.add_vertex(Kernel::Point_3(0, 1, 0));
        vertex_descriptor z = mesh.add_vertex(Kernel::Point_3(0.5, 0.5, 0));
       
        face_descriptor face1 =mesh.add_face(v, w, z);
        face_descriptor face2 =mesh.add_face(x, z, w);
        face_descriptor face3 =mesh.add_face(x, u, z);
        //or (I use this like following)
        vertex_range range=mesh.vertices();
        face_descriptor face=mesh.add_face(range);
This operation adds all of the vertices into one face which is not the case. I would like to add each linear ring into one face (or polygon). I have 7 Linear rings and I like to insert them into 7 faces.  (see the attached .gml file). test_data_set_1.gml 

how can I do it with Surface_Mesh/Polyhedron? Thanks in advance.

Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

Sebastien Loriot (GeometryFactory)
I don't understand what's not working. Could you elaborate what you want
to do and what you're missing?

Thanks,

Sebastien.

On 04/06/2017 02:45 AM, hossan.nazmul wrote:

> Hello Sebastien,
> Thanks a lot for your reply. I played a little and now is able to store my
> points into the CGAL::Surface_mesh<Point_3>. I have Linear Rings which are
> the faces of the Polyhedron/Surface mesh (I presume). If I use
> CGAL::Surface_mesh the I have two possibility to insert those points to
> faces. e.g.
>
> vertex_descriptor u = mesh.add_vertex(Kernel::Point_3(0, 0, 0));
> vertex_descriptor v = mesh.add_vertex(Kernel::Point_3(1, 0, 0));
> vertex_descriptor w = mesh.add_vertex(Kernel::Point_3(1, 1, 0));
> vertex_descriptor x = mesh.add_vertex(Kernel::Point_3(0, 1, 0));
> vertex_descriptor z = mesh.add_vertex(Kernel::Point_3(0.5, 0.5, 0));
>
> face_descriptor face2 =mesh.add_face(v, w, z);
> face_descriptor face2 =mesh.add_face(x, z, w);
> face_descriptor face3 =mesh.add_face(x, u, z);
>         //or (I use this like following)
>         vertex_range range=mesh.vertices();
>         face_descriptor face=mesh.add_face(range);
> This operation adds all of the vertices into one face which is not the case.
> I would like to add each linear ring into one face (or polygon). I have 7
> Linear rings and I like to insert them into 7 faces.  (see the attached .gml
> file).  test_data_set_1.gml
> <http://cgal-discuss.949826.n4.nabble.com/file/n4662635/test_data_set_1.gml>
>
> how can I do it with Surface_Mesh/Polyhedron? Thanks in advance.
>
>
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Store-a-polygon-into-a-half-edge-data-structure-using-CGAL-Polyhedron-3-class-tp4662587p4662635.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>


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


Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

hossan.nazmul
This post was updated on .
Hello Sebastien,
Can you please have a look at my data. CityGML_LoD2_building.gml

My goal is to store this CityGML building geometry into a CGAL Halfedge Data Structure so that I can do some geometric operations. According to your suggestion, I am trying to use CGAL Surface_mesh to store the geometries according to vertices and faces. I can add vertices but I can not add vertices into that particular face. I tried with add_face function: e.g.
{mesh.add_face(point1, point2, point3);} and
{vertex_range range=mesh.vertices(); face_descriptor face=mesh.add_face(range);}
but If you see my data, you will see that it has 7 different faces and the number of points in each face is not always same. I would like to add exactly those vertices into faces from the dataset. My question is, how can I add these arbitrary vertices into 7 different faces. or any idea how do I do that in CGAL? Would it be useful if I can convert my CityGML dataset to OFF(Object File Format)?

Thank you so much for your time.

Best,
Nazmul
Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

Sebastien Loriot (GeometryFactory)
I copy-pasted your point faces in string and wrote the attached program
that is working nicely. The nasty part in the file format is that the
first and last point of each face are identical.

Sebastien.

On 05/17/2017 10:44 PM, hossan.nazmul wrote:

> Hello Sebastien,
> Can you please have a look at my data.  CityGML_LoD2_building.gml
> <http://cgal-discuss.949826.n4.nabble.com/file/n4662730/CityGML_LoD2_building.gml>
>
> My goal is to store this CityGML building geometry into a CGAL Halfedge Data
> Structure so that I can do some geometric operations. According to your
> suggestion, I am trying to use CGAL Surface_mesh to store the geometries
> according to vertices and faces. I can add vertices but I can not add
> vertices into that particular face. I tried with *add_face* function: e.g.
> {mesh.add_face(point1, point2, point3);} and
> {vertex_range range=mesh.vertices(); face_descriptor
> face=mesh.add_face(range);}
> but If you see my data, you will see that it has 7 different faces and the
> number of points in each face is not always same. I would like to add
> exactly those vertices into faces from the dataset. My question is, how can
> I add these arbitrary vertices into 7 different faces. or any idea how do I
> do that in CGAL?
>
> Thank you so much for your time.
>
> Best,
> Nazmul
>
>
>
>
> --
> View this message in context: http://cgal-discuss.949826.n4.nabble.com/Store-a-polygon-into-a-half-edge-data-structure-using-CGAL-Polyhedron-3-class-tp4662587p4662730.html
> Sent from the cgal-discuss mailing list archive at Nabble.com.
>

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



main.cpp (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Store a polygon into a half edge data structure using CGAL Polyhedron_3 class

hossan.nazmul
Hello Sebastien,

Thanks a lot for your help. I really appreciated it!

.Nazmul