

Hello everybody out there.
I am working on an application written in C++ which, among other
things, manipulates 2D triangular meshes–you can have a look to a Python
prototype on FramaGit ( https://framagit.org/ylebars/UWWatch). To
manipulate meshes, I have chosen CGAL, which lead me here.
I have been able to mesh a set of points with CGAL. Now, I need to load
previously created meshes which are stored in Gmsh format
( http://gmsh.info/). That is, not only do I know what are the nodes of
the mesh, but also its faces. I have been looking in CGAL documentation
and dozens other websites, but I have not found any hint on how to set
up faces on a mesh. The only thing almost relevant I have found is this:
https://stackoverflow.com/questions/38954435/manuallyinsertmeshintocgalwithpointsandcells But it turned out I have found no way to get rid of this compilation error:
error: ‘ex_vertex’ does not name a type
Anyway, I am quite certain some have already open existing meshes with
CGAL. Can someone point me some any documentation on how to do this?
Well, as a workaround I can translate the mesh from Gmsh file format
into OFF file format and then load it, but it means to store the mesh
two times and anyway it is not really an elegant way to deal with this
issue.
Best regards.

Yoann LE BARS
http://lebars.net/yoann*Diaspora : [hidden email]

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


Hi, Oh no! That is my SO answer... In my code I took this from, I extent the vertex_base class to allow for storing more information within the node. I forgot to remove that when I wrote that answer. I've updated it to correct this.
The general gist of most of these triangulation formats is there is a list of vertices, a list of faces comprised of verticies, and then adjacency information. It is then just a matter of book keeping to ensure the right vertex go with the right face.
and figure out how it's stored  I'm not sure which of these formats you have
I would imagine it's similar to something like this vertexes = [
[x1,y1,z1],
[x2,y2,z2],
[x3,y3,z3]
]
# a single triangle made up of vertexes 0,1, and 2
triangles = [
[0,1,2]
] Hopefully this helps get you on the right track,
Cheers Chris
Hello everybody out there.
I am working on an application written in C++ which, among other
things, manipulates 2D triangular meshes–you can have a look to a Python
prototype on FramaGit (https://framagit.org/ylebars/UWWatch). To
manipulate meshes, I have chosen CGAL, which lead me here.
I have been able to mesh a set of points with CGAL. Now, I need to load
previously created meshes which are stored in Gmsh format
(http://gmsh.info/). That is, not only do I know what are the nodes of
the mesh, but also its faces. I have been looking in CGAL documentation
and dozens other websites, but I have not found any hint on how to set
up faces on a mesh. The only thing almost relevant I have found is this:
https://stackoverflow.com/questions/38954435/manuallyinsertmeshintocgalwithpointsandcells
But it turned out I have found no way to get rid of this compilation error:
error: ‘ex_vertex’ does not name a type
Anyway, I am quite certain some have already open existing meshes with
CGAL. Can someone point me some any documentation on how to do this?
Well, as a workaround I can translate the mesh from Gmsh file format
into OFF file format and then load it, but it means to store the mesh
two times and anyway it is not really an elegant way to deal with this
issue.
Best regards.

Yoann LE BARS
http://lebars.net/yoann
*Diaspora : [hidden email]

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


Hello everybody out there!
On 2018/11/08 at 6:34 pm, Chris Marsh wrote:
> Oh no! That is my SO answer...
Well, everyone can do a mistake, especially me. Still, thank you for
the answer on Stackoverflow and here, it does help.
> In my code I took this from, I extent the
> vertex_base class to allow for storing more information within the node.
> I forgot to remove that when I wrote that answer.
> I've updated it to correct this.
Thank you for this. I think there is still one line specific to your
code. I cannot compile it anyway. Here is the line:
typedef face<Gt> Fb; //custom face class, use default face and vertex as
required
According to your comment, I should be using the default face class.
The thing is, I am discovering CGAL and I have not been able to find
which one I should use.
> I would look here
> http://gmsh.info/doc/texinfo/gmsh.html#MSHfileformat_0028version4_0029> and figure out how it's stored  I'm not sure which of these formats
> you have
Yes, indeed. Anyway, I do master the mesh formats I am dealing with.
Right now, my trouble is, I am discovering CGAL and as it is quite an
extensive library, I am still a bit lost in it.
Once again, thank you for your answer.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/Diaspora* : [hidden email]

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


Arg. I'm really sorry about that.
I've updated the SO post with a full working example w/ all header
includes & a cmake script to build it. It adds 3 vertices and
inserts 1 face. Because I am using this for terrain, I use
x,y,z points and use the projection trait to allow for using this 3D
point in a 2D triangulation. I've kept it this way as it may be of use
to you.
The example on SO uses this triangulation data structure
I hope this helps,
Cheers Chris
Hello everybody out there!
On 2018/11/08 at 6:34 pm, Chris Marsh wrote:
> Oh no! That is my SO answer...
Well, everyone can do a mistake, especially me. Still, thank you for
the answer on Stackoverflow and here, it does help.
> In my code I took this from, I extent the
> vertex_base class to allow for storing more information within the node.
> I forgot to remove that when I wrote that answer.
> I've updated it to correct this.
Thank you for this. I think there is still one line specific to your
code. I cannot compile it anyway. Here is the line:
typedef face<Gt> Fb; //custom face class, use default face and vertex as
required
According to your comment, I should be using the default face class.
The thing is, I am discovering CGAL and I have not been able to find
which one I should use.
> I would look here
> http://gmsh.info/doc/texinfo/gmsh.html#MSHfileformat_0028version4_0029
> and figure out how it's stored  I'm not sure which of these formats
> you have
Yes, indeed. Anyway, I do master the mesh formats I am dealing with.
Right now, my trouble is, I am discovering CGAL and as it is quite an
extensive library, I am still a bit lost in it.
Once again, thank you for your answer.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/
Diaspora* : [hidden email]

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


Hello everybody out there!
On 2018/11/08 at 11:31 pm, Chris Marsh wrote:
> I've updated the SO post with a full working example w/ all header
> includes & a cmake script to build it. It adds 3 vertices and inserts 1
> face.
Far more than I could have expected, thank you. I have used it to check
my own CMake script, it turned out there was several mistakes.
Now, as there are thousands of vertices and thousands of faces in the
meshes I am using, I cannot create a new variable for each. I need to
stock them in vectors, and cannot use “auto”. Therefore, I am looking
for the appropriate type. It turned out
“CGAL::Triangulation_data_structure_2::Vertex_handle” is not
appropriate, as it does not provide “set_point”:
/home/yoann/program/UWWatchtest/src/gmsh.cpp:131:27: error:
‘__gnu_cxx::__alloc_traits<std::allocator<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false> >,
CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false>
>::value_type’ {aka ‘class
CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false>’} has no
member named ‘set_point’
> Because I am using this for terrain, I use x,y,z points and use the
> projection trait to allow for using this 3D point in a 2D triangulation.
> I've kept it this way as it may be of use to you.
So far, I am using purely 2D points (no “z” coordinate) for a 2D
triangulation. I may be using 3D meshes later, but not now.
> I hope this helps,
Well, I have spent a couple of days trying to sort this out by myself
and failed. Now, I am making some progress, so it clearly helps.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/Diaspora* : [hidden email]

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


Oh, no auto is too bad. In this case, it's triangulation::Vertex_handle and triangulation::Face_handle. You have to use the template derived class.
I've updated the SO to make this more clear. Does this let you compile now?
So far, I am using purely 2D points (no “z” coordinate) for a 2D
triangulation. I may be using 3D meshes later, but not now.
Ok, with my example just set z to be 0 then. You can use a different geometry trait instead, but I'll be honest, I don't know which one that is. At the moment having a z=0 won't impact you at all.
I fear it won't really help you, but on off chance it does, this is a section of code where I build the CGAL data structure from a file
The file that is being read in has 3 components: a vertex list, a face (elem) list, and a neighbour list. The vertex list is a tuple holding the x,y,z coordinates (this is an earth surface model). The face list is a tuple where each item is an index into the vertex list  so [567,1,299] would mean that this ith face is made up of the 567th, 1th, and 299th vertexes
The neigh list is a tuple but is an index into the face list, for which faces are neighbours. e.g.,
vertexes = [
[x1,y1,z1],
[x2,y2,z2],
[x3,y3,z3]
]
# a single triangle made up of vertexes 0,1, and 2
triangles = [
[0,1,2]
] This is a pretty common format, and I suspect the gmsh format uses something like this.
Now, as there are thousands of vertices and thousands of faces in the
meshes I am using, I cannot create a new variable for each.
The general approach with millions of faces is to, while reading in the gmsh/whatever file, you create the 3 vertexes, insert the face, and move on.
Hello everybody out there!
On 2018/11/08 at 11:31 pm, Chris Marsh wrote:
> I've updated the SO post with a full working example w/ all header
> includes & a cmake script to build it. It adds 3 vertices and inserts 1
> face.
Far more than I could have expected, thank you. I have used it to check
my own CMake script, it turned out there was several mistakes.
Now, as there are thousands of vertices and thousands of faces in the
meshes I am using, I cannot create a new variable for each. I need to
stock them in vectors, and cannot use “auto”. Therefore, I am looking
for the appropriate type. It turned out
“CGAL::Triangulation_data_structure_2::Vertex_handle” is not
appropriate, as it does not provide “set_point”:
/home/yoann/program/UWWatchtest/src/gmsh.cpp:131:27: error:
‘__gnu_cxx::__alloc_traits<std::allocator<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false> >,
CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false>
>::value_type’ {aka ‘class
CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false>’} has no
member named ‘set_point’
> Because I am using this for terrain, I use x,y,z points and use the
> projection trait to allow for using this 3D point in a 2D triangulation.
> I've kept it this way as it may be of use to you.
So far, I am using purely 2D points (no “z” coordinate) for a 2D
triangulation. I may be using 3D meshes later, but not now.
> I hope this helps,
Well, I have spent a couple of days trying to sort this out by myself
and failed. Now, I am making some progress, so it clearly helps.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/
Diaspora* : [hidden email]

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


Hello everybody out there!
On 2018/11/09 at 01:47 am, Chris Marsh wrote:
> Oh, no auto is too bad. In this case, it's triangulation::Vertex_handle
> and triangulation::Face_handle. You have to use the template derived class.
> I've updated the SO to make this more clear. Does this let you compile now?
Well, I cannot see any difference on Stackoverflow.
Anyway, as I indicated in the previous message, in my own code when I
use “Triangulation::Vertex_handle”, I have this compilation error
indicating it does not provide “set_point”.
> I fear it won't really help you, but on off chance it does, this is a
> section of code where I build the CGAL data structure from a file
> https://github.com/Chrismarsh/CHM/blob/master/src/mesh/triangulation.cpp#L232 I have started to read this, I will take some times to investigate it.
> The general approach with millions of faces is to, while reading in the
> gmsh/whatever file, you create the 3 vertexes, insert the face, and move
> on.
It sounds quite reasonable, but I do not know how to do this, as a
vertex usually belongs to several faces. With this described approach, I
will create several times the same point.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/Diaspora* : [hidden email]

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


Ah I just made a note of the type in the comments. I think auto is stillpreferable for the overall example.
I'm sorry to hear this is being so problematic. I've attached the code and cmake file to this email  I hope the list doesn't strip it out. I've cc'd you on this email just to be sure. This code correctly compiles and runs for me.
> With this described approach, I
will create several times the same point. You're right, I was being too general sorry.
I'll describe what I do:
Since the Vertex_handle is just a pointer, you can store them with low overhead. Then, when you read a face that uses it, you just use that existing ith vertex. For example:
here I read and make all the vertexes
then I grab the ith vertex when I make the new face, so I never duplicate a vertex
I hope that's more clear,
Cheers Chris
Hello everybody out there!
On 2018/11/09 at 01:47 am, Chris Marsh wrote:
> Oh, no auto is too bad. In this case, it's triangulation::Vertex_handle
> and triangulation::Face_handle. You have to use the template derived class.
> I've updated the SO to make this more clear. Does this let you compile now?
Well, I cannot see any difference on Stackoverflow.
Anyway, as I indicated in the previous message, in my own code when I
use “Triangulation::Vertex_handle”, I have this compilation error
indicating it does not provide “set_point”.
> I fear it won't really help you, but on off chance it does, this is a
> section of code where I build the CGAL data structure from a file
> https://github.com/Chrismarsh/CHM/blob/master/src/mesh/triangulation.cpp#L232
I have started to read this, I will take some times to investigate it.
> The general approach with millions of faces is to, while reading in the
> gmsh/whatever file, you create the 3 vertexes, insert the face, and move
> on.
It sounds quite reasonable, but I do not know how to do this, as a
vertex usually belongs to several faces. With this described approach, I
will create several times the same point.
Best regards.

Yoann LE BARS
http://lebars.net/yoann/
Diaspora* : [hidden email]

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


Hello everybody out there!
On 2018/11/09 at 04:28 am, Chris Marsh wrote:
> I'm sorry to hear this is being so problematic. I've attached the code
> and cmake file to this email  I hope the list doesn't strip it out.
> I've cc'd you on this email just to be sure.
> This code correctly compiles and runs for me.
Well, I have received it anyway, thank you.
I have been able to compile and run it (I just add “#include
<iostream>” at the beginning of “main.cpp”). Here is the result of the run:
$ ./main
#veterx=3
#faces=1
The result is the one expected.
Still, I have this compilation error on my own code:
/home/lebarsy/Codes/UWWatchtest/src/gmsh.cpp:131:27: error:
‘__gnu_cxx::__alloc_traits<std::allocator<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false> >
>::value_type {aka class
CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>,
CGAL::Triangulation_ds_vertex_base_2<CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
>,
CGAL::Constrained_triangulation_face_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>
> > > >, CGAL::Default, CGAL::Default, CGAL::Default>, false>}’ has no
member named ‘set_point’
I am investigating it, but I have not found what is wrong yet.
Just to let you know, here are my definitions:
/// \brief Type for CGAL mesh kernel.
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
/// \brief CGAL 2D points type.
typedef K::Point_2 Point;
/// \brief CGAL 3D points type.
typedef K::Point_3 Point3;
/// \brief Allows for using 2D algorithms on the 3D points.
typedef CGAL::Projection_traits_xy_3<K> Gt;
/// \brief Vertex class.
typedef CGAL::Triangulation_vertex_base_2<Gt> Vb;
/// \brief Custom face class, use default face and vertex as required.
typedef CGAL::Constrained_triangulation_face_base_2<Gt> Fb;
/// \brief Type for 2D triangulation with CGAL.
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Triangulation;
/// \brief Mesh vertex type.
typedef Triangulation::Vertex_handle Vertex;
And here are the lines that cannot be compiled:
// Mesh vertices set.
std::vector<Vertex> vertex (x.size());
for (std::size_t i = 0; i < x.size(); ++i) {
// Current point coordinates.
const Point p (x[i], y[i]);
vertex[i] = mesh.create_vertex();
vertex[i].set_point(p);
}
I have already tested without using “const” when creating “p” and using
“Point3” rather “Point”, the error is still the same.
Well, as I have a running example, I should be able to solve the problem.
Best regards.

Yoann LE BARS
http://lebars.net/yoann*Diaspora : [hidden email]

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


Hello everybody out there!
Le 09/11/2018 à 12:10, Yoann LE BARS a écrit :
> Still, I have this compilation error on my own code:
Well, I had to walk away right after I sent this email and the
solution popped in my mind (always go for a walk when you face some
blocking situation). Here is a corrected code:
std::vector<Vertex> vertex (x.size());
for (std::size_t i = 0; i < x.size(); ++i) {
// Current point coordinates.
const Point3 p (x[i], y[i], 0.);
vertex[i] = mesh.create_vertex();
vertex[i]>set_point(p);
}
As Chris mentioned, the vertex is stocked as a pointer. Therefore, you
have to use it as a pointer, not a variable …
Well, problem solved and my thanks to Chris.
Best regards.

Yoann LE BARS
http://lebars.net/yoann*Diaspora : [hidden email]

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


Hi Yoann, Great to hear that example is working and your code is also compiling.
Cheers Chris
Hello everybody out there!
Le 09/11/2018 à 12:10, Yoann LE BARS a écrit :
> Still, I have this compilation error on my own code:
Well, I had to walk away right after I sent this email and the
solution popped in my mind (always go for a walk when you face some
blocking situation). Here is a corrected code:
std::vector<Vertex> vertex (x.size());
for (std::size_t i = 0; i < x.size(); ++i) {
// Current point coordinates.
const Point3 p (x[i], y[i], 0.);
vertex[i] = mesh.create_vertex();
vertex[i]>set_point(p);
}
As Chris mentioned, the vertex is stocked as a pointer. Therefore, you
have to use it as a pointer, not a variable …
Well, problem solved and my thanks to Chris.
Best regards.

Yoann LE BARS
http://lebars.net/yoann
*Diaspora : [hidden email]

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

