Drawing a colored mesh in CGAL

Viewed 400

In CGAL have a Surface_mesh<Point_3> with Surface_mesh::Property_map<Surface_mesh::Face_index, CGAL::Color>. I use CGAL::draw() method to draw this mesh, however the different colors of faces don't reflect. What am I missing?

2 Answers

The current version of basic viewer of Surface mesh does not take into account the color of faces.

However, it is easy to change the code.

  1. Have a look to the file draw_surface_mesh.h.
  2. Add a functor MyColorFunctorSM (inspired by the existing DefaultColorFunctorSM) that returns the color of a face given its index
  3. Replace in the draw function DefaultColorFunctorSM by your new functor MyColorFunctorSM.

(If you don't want to modity the CGAL file, you can define your functor in your code, and copy/paste the draw function in your code before to modify it).

I think you must hit the M key once in the viewer, to activate the 'multicolor' feature.

Related