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: Maxime Gimeno <>
  • To: "J. Scheurich" <>
  • Cc:
  • Subject: Re: [cgal-discuss] How to read .OFF file color information ?
  • Date: Fri, 24 Jan 2020 11:48:26 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:T4pSsxcB8RwgBEfEVaquidVwlGMj4u6mDksu8pMizoh2WeGdxcS/Zh7h7PlgxGXEQZ/co6odzbaP7+a6BSdZsd7B6ClELMUXEUddyI0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0IufrymUoHdgN6q2O+s5pbdfxtHhCanYbN1MR66sRjdutMZjId/Jas90AXFr3RHd+hLxm5jOFafkwrh6suq85Nv7ipdt+g9+8JcVKnxYrg1Q6FfADk6KW4++dfltQPETQuB53scVnsZnx9VCAXb7x/0Q4n8vDLiuuVyxCeVM8v2TaspWTu59KdkVAXoiCYcODEn9mzcl9F9g7haoBKloBx/3pLUbYSIP/dwYq/RYdUXTndHU81MVSJOH5m8YpMAAOoPP+lWr4fzqVgToxWgGQahH/ngxiNSi3LswaE2z+YsHAfb1wIgBdIOt3HUoc3yOqgIXuG1zazIwiveZP1X2Df97ZbHchYmofqRWr9wdNDeyEYuFwPAkFqcs4PlPzKQ1usTtWib6PFtVe2qi2E9qgFxpiKjydsrionMn48YzE3P+yt+wIYwP9K4SUh7bMa/EJtMrS6VK4h2QsQ8Q252oiY6xLkGuZm1fSQQ1JsnwBvfZ+SJc4iT/xLvTvieLiplhH9jZbmxhA6y/FC+xuHgUsS4ylVHoypfntXRt30A1Qbf5tWFR/dj+EqqxCyB2BrJ6u5eJEA5jarbJIAlwr43jpcTtF7MHi7ymEnvi6+Wd1go9vGm6+j6YLjquIWQN4BzigH5PaQuntKwDf4kPQgJWmiX4eW81Lv98k3lWLhGkOE6n63DvJ3ZJckXvLO1Dg5X34o59hqyDSmq3MwdnXYdLVJFfByHj5LuO1HLOP34CO2wglutkDdu2f/KJLLhApTILnfdlrfheq1w60FZyAUpzNBf44hYBa0GIPL2QkPxrsDXDgclMwyoxObqEMly1owEVmKLG6OWLaLSsUSU6eIyOOmMf5QYuC39Kvgg//7hl2U1mV4bfamz3JsYcmq0Hvp8IxbRXX25yPVHWVwBvgcjVu3hiBfKBTtOaWqzBvsU+TwxTo6rW9TtXIeo1ZmIzCa+E9V5Z2VLDFfERXLhZ4SBVrEDaSefJMhJnTkNVLznQIgkg0L9/DTmwqZqe7KHshYTsojugYAstr/j0Coq/DkxNPyzlmSETmV6hGQNHmZk06V2oEg7wVCGg/Eh365oUOdL7vYMaT8UcIbGxrUjWd/3UwPFONyOTQT+G4j0MXQKVts0huQ2TQN9FtGl1E6R2iOrB/oSluXOCsVrqOTT2H/+I8s7wHHDhvEs

Your test data does not have any color per vertex, they are all per face. In the SO message you refer to, it is written
"[...] If there are colors per face you can access it similarly but by searching for the property map called "f:color". [...]"

So you should use a property map like that :
  SurfaceMesh::Property_map<SurfaceMesh::Face_index, CGAL::Color>
fcolors =
        mesh->property_map<SurfaceMesh::Face_index, CGAL::Color >
        ("f:color").first;

Le ven. 24 janv. 2020 à 11:47, J. Scheurich <> a écrit :
Hi,

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");
}

What is the problem ?


so long

MUFTI




Archive powered by MHonArc 2.6.18.

Top of Page