Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to read .OFF file color information ?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to read .OFF file color information ?


Chronological Thread 
  • From: "J. Scheurich" <>
  • To:
  • Subject: Re: [cgal-discuss] How to read .OFF file color information ?
  • Date: Wed, 22 Jan 2020 07:18:36 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:kSsMrxc/HoThjkQ1xpIX0Yf1lGMj4u6mDksu8pMizoh2WeGdxcS4YB7h7PlgxGXEQZ/co6odzbaP7+a5CCdQvd7B6ClELMUXEUddyI0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0IufrymUoHdgN6q2O+s5pbdfxtHhCanYbN1MR66sRjdutMZjId/Jas90AbFr39Hd+lVym5jOFafkwrh6suq85Nv7ipdt+g9+8JcVKnxYrg1Q6FfADk6KW4++dfltQPETQuB53scVnsZnx9VCAXb7x/0Q4n8vDLiuuVyxCeVM8v2TaspWTu59KdkVAXoiCYcODEn9mzcl9F9g7haoBKloBx/3pLUbYSIP/dwYq/RYdUXTndHU81MVSJOH5m8YpMSAeQfM+ZWr4rzqVUAohSxBwajGOzhxyRUhn/vx6A2z/gtHA/E0QEmAtkAsG7UrNLwNKoKX+y7yLPExijeYfxK2Tfy9pXIcgogof6QXbJ8f9faxE4qFwPYgFWQtY3lMy6I2ukWvWmU8fFvWfiyhGE5sgx8pCWkyMkrionMnI0Vy1bE+D12wIY0Od24SFN7bsW+HJRMsCGaMpN6Qtg+Q25ypCk6yboGuYClcygQxpQnwxnfavKdf4eU5RLjUf6dITljhHJ4Yr6wmQu98VWmx+bhVce0yE5HojRYntTOrHwA1QLf5tKaRvZ54EutwzSC2gPL5uxHIk04j7fXJp4/zrIqi5YeskvOEjXolEnriqKda18q9fKy6+v9Z7Xrvp+cOJFwigH5Kqkun8u/AfkkMgQUUWmU5/+z2Kf+8kLnWLlKj/s2nbfFsJ3CO8gXu6y0DxVX34o98RqzEjOr3MoCkXQFL19JYBeHgJLoO1HKLvD4F/C/g1G0nTdu2vDGMKHhApTQInTei7rgc6hy5FVGxAUu099T/4hUBa0ZIPLvRk/xs8TVAQM2MwOux+brEchy1oIFWW2TH6+ZK7jSvEST5uMvJumMfJUatCz8K/gj/f7ujGU2lUUTfamzjtMrbyWzEf1iZkmYenHxmcwpEGEQvwN4Qva5pkeFVGsZRTD6ZKk86ywhCYmmR8+XQ52jnL3YhQ+kE5cQam0QWQPEKmvha4jRA6REUymVOMI0ymVYB4jkcJco0FSVjCG/06BufrjL9ydeuZ+xjIEktd2Wrgk78HlPN+rY1miMS29umWZYFSA71uZzrB4kkwrR4e1Dm/VdUOdrybZJXwM9bMWOyutnF5btVwiHctrbEFs=



On 21.01.20 21:35, Sebastien Loriot (GeometryFactory) wrote:
OFF should be replaced by COFF according to the file format (or CNOFF
if you have normals).

If i add COFF instead of OFF in facecube.off, i still get "color do not
exist" in the test program.

https://github.com/CGAL/cgal/pull/1013

talks about Scanner_OFF.h, how to use it ?

so long
MUFTI
How to read .OFF file color information via CGaL ?

I wrote the following test program accoording to

https://stackoverflow.com/questions/55955579/cgal-how-can-i-access-vertex-colors-after-loading-an-off-file


$ cat readoff.cpp


// compile:   g++ -g -O0 readoff.cpp -lCGAL
// test data: https://people.sc.fsu.edu/~jburkardt/data/off/facecube.off
// output:
// $ ./a.out
// facecube.off: Success
// color do not exist

#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> Kernel;
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/boost/graph/dijkstra_shortest_paths.h>
#include <CGAL/exceptions.h>
#include <CGAL/IO/Color.h>
#include <boost/graph/prim_minimum_spanning_tree.hpp>
#include <boost/foreach.hpp>
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Surface;
typedef CGAL::Surface_mesh<Point> SurfaceMesh;
typedef CGAL::Color Color;
typedef Surface::Vertex_index vertex_index;
typedef boost::graph_traits<Surface>::vertex_descriptor
vertex_descriptor;
typedef boost::graph_traits<Surface>::face_descriptor face_descriptor;
typedef boost::graph_traits<Surface>::halfedge_descriptor
halfedge_descriptor;
std::vector<Point> verts;
std::vector<Color> cols;

int main(int argc, char **argv)
{
     const char *filename = "facecube.off";
     std::ifstream input(filename);
     SurfaceMesh *mesh = new SurfaceMesh();

     if (!input || !(input >> *mesh)) {
         perror(filename);
     }

     SurfaceMesh::Property_map<SurfaceMesh::Vertex_index, CGAL::Color>
vcolors =
         mesh->property_map<SurfaceMesh::Vertex_index, CGAL::Color >
         ("v:color").first;

     bool colorExists = mesh->property_map
         <SurfaceMesh::Vertex_index, CGAL::Color>("v:color").second;
     if (colorExists )
         printf("color exists\n");
     else
         printf("color do not exist\n");
}




Archive powered by MHonArc 2.6.18.

Top of Page