-1

I had some code that wrote skeletons to ply using tinyPLY. Recently, CGAL has added IO for several formats, including PLY. Out of curiosity, I thought I would use the built-in methods and try and remove tinyPly. I need to write both surface_mesh and skeletons derived from CGAL::Mean_curvature_flow_skeletonization. Saving the surface_mesh worked very well, and simplified my code.. Nice! (just calling CGAL::IO::write_PLY(outputStream, mesh);)

For the skeleton, if I try and call the same I get compilation errors. I figured one way around would be just to convert the skeleton to a surface_mesh by iterating through the verts and edges of the skeleton and adding them to a newly constructed surface_mesh, then calling write_PLY. This kind of works.. but only the vertices and not the edges are written, though I have confirmed that the mesh object has the appropriate number of edges/halfedges.

So the question: Is there a way that I can call CGAL::IO::write_PLY directly on the skeleton and get it to compile correctly? And/or is there a different type that I could convert my skeleton too that would write correctly? I know I can go back to tinyPLY, but I figured that figuring this out might help me better understand the data structure and simplify the code.

The specific compilation error when calling CGAL::IO::write_PLY(outputStream, skeleton) are:

C2146   syntax error: missing ';' before identifier 'Point_3'

And this is called on line 336 of PLY.H :

typedef typename boost::property_traits<Vpm>::reference    Point_3;

I understand that this means that reference is likely not defined, but I can't figure out what to do about it...

1 Answers1

0

In order to get it to work with the approach of converting the skeleton to a surface_mesh, I 'tricked' it a bit by adding a property map to the edges.

skelmesh.add_property_map<Mesh::edge_index, boost::int64_t>("e:weight");

When there are properties for edges, surface_mesh's write_PLY will add an edge element. However, it writes them with the properties 'v0' and 'v1' rather than what is in the PLY standard, 'vertex1' and 'vertex2', which causes it to not read correctly into common software such as Blender or Meshlab. This can just be changed in the file header, but I will either submit an issue or a pull request. Getting PLY writing working directly on the skeleton (which would use boost\graph\IO\PLY.h) would be harder for me to get to work, as there is not currently support for writing edges, but maybe that would be the better way to do it. Another possible solution would be to write some IO support into mean_curvatute_flow_skeletonization.