1

I want to load a coff file (a mesh with color) using CGAL::read_OFF(). and next attempt would be combining these info into a mesh variable (something similar to polygon_soup_to_polygon_mesh function, but not sure about it, because this command also doesn't support color info). do you know how can I read a COFF file and merge them as a mesh that contains color info?

  bool
  read_OFF( std::istream& in,
            std::vector< Point_3 >& points,
            std::vector< Polygon_3 >& polygons,
            std::vector<Color_rgb>& fcolors,
            std::vector<Color_rgb>& vcolors,
            bool /* verbose */ = false)

and then

here is an example for COFF file that I want to load:

COFF
12 12 0
-0.4 -4.898587e-17 0.85 158 138 122 255 
-0.4 -4.898587e-17 -0.9 255 0 122 255 
0.4 4.898587e-17 -0.9 0 255 122 255 
0.4 4.898587e-17 0.85 158 138 122 255 
-0.4 -1.2 0.85 158 0 255 255 
-0.4 -1.2 -0.9 158 138 122 255 
0.4 -1.2 -0.9 158 138 122 255 
0.4 -1.2 0.85 158 138 122 255 
-0.4 -1.2 0.85 158 138 122 255 
-0.4 -1.2 -0.9 100 255 0 255 
0.4 -1.2 -0.9 222 0 122 255 
0.4 -1.2 0.85 222 0 122 255 
3 3 1 0
3 3 2 1
3 1 4 0
3 5 4 1
3 2 5 1
3 6 5 2
3 7 2 3
3 7 6 2
3 4 3 0
3 4 7 3
3 9 11 8
3 10 11 9
A. Fasih
  • 73
  • 1
  • 10

1 Answers1

0

You can use the Surface_mesh data structure, it has a read_off() fuction that supports COFF files, which is called by the operator>>(). So juste define a Surface_mesh(Point_3), let's call it sm, an istream of your COFF file, let's call it is, and call

is>>sm; 

That should fill your surface_mesh with your mesh and the right colors. In the case of your example, the colors will be per vertex.

mgimeno
  • 726
  • 1
  • 4
  • 7