首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CGAL组合图和Geomview

CGAL组合图和Geomview
EN

Stack Overflow用户
提问于 2015-06-17 00:02:39
回答 1查看 164关注 0票数 0

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

例如(来自CGAL示例):

代码语言:javascript
复制
#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);行将导致编译成功。

类似地:

代码语言:javascript
复制
#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,并按如下方式编译我的文件:

代码语言:javascript
复制
cgal_create_CMakeList
cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/  .
make 

当我通过以下方式切换到GNU g++编译器时:

代码语言:javascript
复制
cmake -DCGAL_DIR=/usr/local/Cellar/cgal/4.6/ -DCMAKE_CXX_COMPILER:FILEPATH=g++-5 -DCMAKE_C_COMPILER:FILEPATH=gcc-5  .

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

代码语言:javascript
复制
#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;
}

结果如下:

代码语言:javascript
复制
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编译。

EN

回答 1

Stack Overflow用户

发布于 2015-06-17 01:40:46

我认为这是你的clang编译器中的一个bug (我的一个同事也观察到了类似的行为)。

你能告诉我你用的是哪种编译器吗?

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

纪劳姆

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30872706

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档