Skip to content

CGAL exception while reading CNOFF file #4499

@sloriot

Description

@sloriot

From CGAL-discuss, demo also crashes when trying to open the file:


Hi,

When i run the following program under Ubuntu 18.04 (X86_64)...

// compile:   g++ -g -O0 readoff_vertexcolor.cpp -lCGAL
// test data:  https://wdune.ourproject.org/examples/test.off

#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 = "test.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;

    for (SurfaceMesh::Vertex_index vi : mesh->vertices()) {
        verts.push_back(mesh->point(vi));
        if (colorExists )
            cols.push_back(vcolors[vi]);
    }
}

I get:

$ ./a.out
terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: n > 2
File: /usr/include/CGAL/boost/graph/Euler_operations.h
Line: 588
Aborted (core dumped)

What is wrong ?

so long
MUFTI



-- 
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions