CGAL Combinatorial map and Geomview

211 Views Asked by At

For some reason Combinatorial_map objects cause segmentation fault after being called.

For instance (from CGAL examples):

#include <CGAL/Combinatorial_map.h>
#include <CGAL/Combinatorial_map_constructors.h>
#include <iostream>
#include <cstdlib>
typedef CGAL::Combinatorial_map<3> CMap_3;
typedef CMap_3::Dart_const_handle Dart_const_handle;
  int main() 
  { 
    CMap_3 cm;
    // Create two tetrahedra.  
    Dart_const_handle dh1 = CGAL::make_combinatorial_tetrahedron(cm); 
    Dart_const_handle dh2 = CGAL::make_combinatorial_tetrahedron(cm);

    // Display the combinatorial map characteristics.
    cm.display_characteristics(std::cout); 
    return EXIT_SUCCESS;
} 

Results in 'Segmentation fault: 11', while commenting cm.display_characteristics(std::cout); line results in successful compilation.

Similarly:

#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/IO/Geomview_stream.h>
#include <iostream>
#include <algorithm>

typedef CGAL::Linear_cell_complex<3> LCC3;
typedef LCC3::Dart_handle   DartHandle;
typedef LCC3::Point Point;
typedef LCC3::FT    FT;
typedef CGAL::Geomview_stream GVS;

int main(){
LCC3 lcc;

    DartHandle d1 = lcc.make_tetrahedron( Point(-1,0,0), Point(0,2,0), Point(1,0,0), Point(1,1,2));
    return 0;
}

Results in segmentation fault, which can be cured by removing DartHandle d1 = lcc.make_tetrahedron( Point(-1,0,0), Point(0,2,0), Point(1,0,0), Point(1,1,2)); line.

I use Mac OS 10.10.3 and compile my files as follows:

cgal_create_CMakeList
cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/  .
make 

When I changed to GNU g++ compiler by:

cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/ -DCMAKE_CXX_COMPILER:FILEPATH=g++-5 -DCMAKE_C_COMPILER:FILEPATH=gcc-5  .

The Geomview stream stopped working, so the following code:

#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/IO/Geomview_stream.h>
#include <iostream>
#include <algorithm>

typedef CGAL::Linear_cell_complex<3> LCC3;
typedef LCC3::Dart_handle   DartHandle;
typedef LCC3::Point Point;
typedef LCC3::FT    FT;
typedef CGAL::Geomview_stream GVS;

int main(){

    GVS gvs( CGAL::Bbox_3(-10, -10, -10, 120, 60, 60) );
    gvs.set_line_width(4);
    gvs.set_bg_color(CGAL::Color(0,200,200));
    gvs.set_vertex_radius(20);
    gvs << CGAL::BLUE;
    gvs << Point(0,0,0);

    std::cout << "Enter a key to finish" << std::endl;
    char ch;
    std::cin >> ch;

    return 0;
}

results in:

Undefined symbols for architecture x86_64:
  "CGAL::Geomview_stream::get_new_id(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      void CGAL::output_point<double>(CGAL::Geomview_stream&, double const&, double const&, double const&) in cell_complex.cpp.o
  "CGAL::Geomview_stream::operator<<(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      void CGAL::output_point<double>(CGAL::Geomview_stream&, double const&, double const&, double const&) in cell_complex.cpp.o

But compiles with AppleClang.

1

There are 1 best solutions below

3
On

I think this is a bug in your clang compiler (one of my colleague has observed a similar behaviour).

Could you told me which compiler you use ?

And if it is the same problem, this does not occur when you compile in debug mode. Could you try ?

Guillaume