解决cgal中的surface_mesh_deformation,代码copy到别处报错

我只想说我遇到过多少奇葩的bug啊。。。这么奇葩的错误我竟然能debug出来真是醉醉的


cgal4.5之后,有实现surface_mesh_deformation的example。

1.如何正常编译example?

最好是在编译cgal的时候,cmake中的entry就有,勾选上with_eigen,然后配置include目录即可。

这样以后省事,所以编译cgal的时候,要好好检查外置的库,会用到的都先加上。

如果不想重新编译cgal,在重新用cmake编译surface_mesh_deformation这个example和demo时,选择with_eigen即可。


2.当你正常运行example之后,把代码原样copy到自己的project中,编译会报错TTTTTTT

1>C:\Program Files\CGAL-4.6.1\include\CGAL/Surface_mesh_deformation.h(212): error C2039: 'Matrix' : is not a member of 'CGAL::Default' 
1>          C:\Program Files\CGAL-4.6.1\include\CGAL/Default.h(31) : see declaration of 'CGAL::Default' 
1>          ModelDecompoent.cpp(245) : see reference to class template instantiation 'CGAL::Surface_mesh_deformation' being compiled 
1>          with 
1>          [ 
1>              HG=Polyhedron 
1>          ] 

......
一堆错

说加上#define CGAL_EIGEN3_ENABLED
因为看CGAL/Surface_mesh_deformation.h代码中:
#if defined(CGAL_EIGEN3_ENABLED)
#include  // for sparse linear system solver
#include  // for 3x3 closest rotation computer
#endif
就是说CGAL_EIGEN3_ENABLED被define了才可以。

然而我加上并没有用!!!

为什么呢?
因为顺序反了= =

正确的顺序:
#define CGAL_EIGEN3_ENABLED
#include


错误的顺序:
#include
#define CGAL_EIGEN3_ENABLED //这样子都include完了,define还有什么用。。。

真是奇葩的bug

你可能感兴趣的:(cgal)