Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] How to read color information for faces with CGAL ?

Subject: CGAL users discussion list

List archive

[cgal-discuss] How to read color information for faces with CGAL ?


Chronological Thread 
  • From: "J. Scheurich" <>
  • To:
  • Subject: [cgal-discuss] How to read color information for faces with CGAL ?
  • Date: Mon, 10 Feb 2020 00:45:45 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:CPvsnR9HhBvAX/9uRHKM819IXTAuvvDOBiVQ1KB42u8cTK2v8tzYMVDF4r011RmVBNmdtqMP0reN++C4ACpcuM3H6ChDOLV3FDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3OgV6PPn6FZDPhMqrye+y54fTYwJVjzahfL9+Nhq7oRjeu8UMgYZvLqk9xgbJr3ZGZu9awX9kKU+Jkxvz+8u98oRv/zhMt/4k6sVNTbj0c6MkQLJCET8oKXo15MrltRnCSQuA+H4RWXgInxRLHgbI8gj0Uo/+vSXmuOV93jKaPdDtQrAvRTui9aZrRwT2hyoBKjU07XvYis10jKJcvRKhuxlyyJPabY2JKPZzeL7WcNUHTmRDQ8lRTTRMDJ28YYUSDOQPM+hXoIbhqFUBtha+GRCsCfnzxjNUiHL736s32PkhHwHc2wwgGsoDvHrQotnvKawcTPy6zKnWwjXedfNW2Cvy6IjGfhs8pvyMWK9wccTNyUkuCg/Jk06dqIL7MDyOzOgCrnaU4vNmWOmyhWAnrARxrSKuxscqkoTJgZ8Vykrc9SVjx4Y1J8O3R1JnYdK+F5tQrS6aO5N4QsM5XmFkojg1xaAbuZO9YSMEy4wnygbBZ/CabYSE+AzvWPiTLDtimX5oeqiziwus/US4yuDwTNS43VlLoyZfj9XBsm4B2wbN5sSaRfZw+Fqq1yyV2ADJ8O5EJFg5larFJJ4lxb49jp8TsUPeHi/qgkn3grGZeV4+9ue19evrerTmppmCOI9okgzyLLkiltKlDegmLAQDXXKX9fm+2bH54EH1Xq1GjvgsnanYtJDaK94bpqm8AwJN14Yj9hi/Dyun0NgFgHUKN1xEdwycgITzJl7BPuj0De2jjFS0jDdr2/fGM6X9DZXCNHfDlK7tcqt8605H1AUz0Mtf54lPB7EaIPPzX1fxu8bCAh84NQy02efnB89n2oMQQ2LcSpOeZajduFvN6uM0KPSXf6cUviz8Ir4r/a3Al3g8zBU/O+GS1psadWq5FfQsaxGcfHTwg45YOXgHtEwyQbq52xW5TTdPaiPqDOoH7TYhBdf+VNqRdsWWmLWEmRyDMNhWa2RBUwveFHD1a8ObVv1KZC/AepY9wAxBbqCoTsoa7T/rrBXzm+h4I+CS9iBK7cuyhugw3PXakFQJzRIxCs2c12+XSGQkzHwFTXk60fImrA==

Hi,

I am a programmer working on white_dune.
White_dune can now read colored .OFF files, but only if the color are on
vertices, not on Faces.

How to read the face information of .OFF files with CGAL ?

I have the following  test program, but i prints "color do not exist" 8-(

// compile:   g++ -g -O0 readoff.cpp -lCGAL
// test data: http://wdune.ourproject.org/examples/facecube.off
// copy of https://people.sc.fsu.edu/~jburkardt/data/off/facecube.off
without comments
// 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::Face_index, CGAL::Color>
vcolors =
        mesh->property_map<SurfaceMesh::Face_index, CGAL::Color >
        ("f:color").first;

    bool colorExists = mesh->property_map
        <SurfaceMesh::Face_index, CGAL::Color>("f:color").second;

    if (colorExists )
        printf("color exists\n");
    else
        printf("color do not exist\n");
}

The amazing thing is the execution of "perror(filename)" even if the
file exists.
It looks like the curŕent OFF reader (CGAL 4.11-2 on Ubuntu 18.04) can
not handle face colors 8-(

so long
MUFFTI



Archive powered by MHonArc 2.6.18.

Top of Page