CGAL组合地图和Geomview

CGAL Combinatorial map and Geomview

本文关键字:Geomview 地图 组合 CGAL      更新时间:2023-10-16

由于某种原因Combinatorial_map对象在被调用后会导致分段错误。

例如(来自CGAL示例):

#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;
} 

导致"分段错误:11",而注释cm.display_characteristics(std::cout);行会导致编译成功。

同样地:

#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;
}

导致分段故障,可以通过移除DartHandle d1 = lcc.make_tetrahedron( Point(-1,0,0), Point(0,2,0), Point(1,0,0), Point(1,1,2));线来修复。

我使用 Mac OS 10.10.3 并按如下方式编译我的文件:

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

当我通过以下方式更改为GNU g++编译器时:

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

Geomview 流停止工作,因此以下代码:

#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;
}

结果在:

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

但是用AppleClang编译。

我认为这是您的clang编译器中的一个错误(我的一位同事观察到了类似的行为)。

你能告诉我你使用哪个编译器吗?

如果是相同的问题,则在调试模式下编译时不会发生这种情况。你能试试吗?

纪尧姆