【问题标题】:Some CGAL examples (e.g. Jet Smoothing and Normal Orientation) fail to compile一些 CGAL 示例(例如 Jet Smoothing 和 Normal Orientation)无法编译
【发布时间】:2016-02-04 11:09:37
【问题描述】:

我目前正在开展一个项目,在该项目中,使用一些 CGAL 算法进行点集处理将非常有利。

除其他外,我需要运行喷射平滑算法 - 示例如下: http://doc.cgal.org/latest/Point_set_processing_3/

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/jet_smooth_point_set.h>
#include <vector>

// types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;

int main(void)
{
  // generate point set
  std::vector<Point> points;
  points.push_back(Point( 0.0, 0.0, 0.001));
  points.push_back(Point(-0.1,-0.1, 0.002));
  points.push_back(Point(-0.1,-0.2, 0.001));
  points.push_back(Point(-0.1, 0.1, 0.002));
  points.push_back(Point( 0.1,-0.1, 0.000));
  points.push_back(Point( 0.1, 0.2, 0.001));
  points.push_back(Point( 0.2, 0.0, 0.002));
  points.push_back(Point( 0.2, 0.1, 0.000));
  points.push_back(Point( 0.0,-0.1, 0.001));

  // Smoothing.
  const unsigned int nb_neighbors = 8; // default is 24 for real-life point sets
  CGAL::jet_smooth_point_set(points.begin(), points.end(), nb_neighbors);
  return EXIT_SUCCESS;
}

编译时(使用 CMake),我遇到以下错误:

   error: no matching function for call to ‘jet_smooth_point_set(std::vector<CGAL::Point_3<CGAL::Epick> >::iterator, std::vector<CGAL::Point_3<CGAL::Epick> >::iterator, const unsigned int&)’
   CGAL::jet_smooth_point_set(points.begin(), points.end(), nb_neighbors);

   jet_smooth_point_set.h:177:1: note: candidate: template<class Concurrency_tag, class InputIterator, class PointPMap, class Kernel, class SvdTraits> void CGAL::jet_smooth_point_set(InputIterator, InputIterator, PointPMap, unsigned int, const Kernel&, unsigned int, unsigned int)

   note:   candidate expects 7 arguments, 3 provided
   CGAL::jet_smooth_point_set(points.begin(), points.end(), nb_neighbors);

错误似乎暗示包含的头文件中没有指定函数?然而,标题的位置似乎正确?

CGAL 存储库附带的示例中也会出现同样的问题。

我的设置是 Ubuntu 15.10、GCC 5.2.1、CMake 3.2.2,我使用 Ubuntu 存储库中的 CGAL 4.6 和从 Github 存储库编译的 CGAL 4.8-beta 产生了这个错误。

不管怎样,异常值删除示例以及输入/输出示例都能正确编译和执行。

我觉得有点卡在这一点上,希望能得到任何帮助。

【问题讨论】:

  • 并行版本将在 CGAL-4.8 中添加。请参阅this 更新示例。但是,该代码应该适用于 4.7 及更早版本。
  • 谢谢;是的,我偶然发现了该示例的并行版本。但是,如下所述,问题似乎是我没有设法将 Eigen3 包含在我的 CGAL 编译中。
  • 那么,如果您使用的是 cmake,则缺少 `find_package(Eigen3 3.1.0) if (EIGEN3_FOUND) include( ${EIGEN3_USE_FILE} ) endif(). If not but your compiler knows where to find eigen, simply define CGAL_EIGEN3_ENABLED`,如文档所述@ 987654323@
  • 谢谢 - 正如您在 cmets 中看到的答案,我已经包含 Eigen3,并且我的编译器确实找到了 Eigen3_use_file。我还尝试过定义 CGAL_EIGEN3_ENABLED。在编译相关示例时,它会导致以下错误: CGAL/Kernel_23/include/CGAL/Dimension.h:28:22: fatal error: Eigen/Core: No such file or directory ,这对我来说意味着 EIgen3 有实际上没有正确编译?
  • Eigen 是一个只有头文件的库,你只需要将它添加到编译器的包含目录中

标签: c++ cmake cgal


【解决方案1】:

在 git 中查看了&lt;CGAL/jet_smooth_point_set.h&gt;,位于

jet_smooth_point_set.h

我发现最后 2 个参数是默认的 5 参数重载,在第 320 行定义,

template <typename Concurrency_tag,
          typename InputIterator>
void jet_smooth_point_set(
    InputIterator first, ///< iterator over the first input point
    InputIterator beyond, ///< past-the-end iterator
    unsigned int k, ///< number of neighbors.
    const unsigned int degree_fitting = 2,
    const unsigned int degree_monge = 2)

在示例代码中使用,在第 263 行被以下 #ifdef 包围:

#if defined(CGAL_EIGEN3_ENABLED) || defined(CGAL_LAPACK_ENABLED)

因此我得出结论,CGAL 是在没有上述两个库 Eigen3 和 LAPACK 的情况下构建的。尝试在支持其中任何一个的情况下重建 CGAL(注意 #ifdef 中的 || 条件运算符)。为此,请安装相应的软件包以及 devel 软件包(我是 RedHat 人,所以不知道 Ubuntu 如何拆分开发包和非开发包)。您希望安装这些库的标头以针对它们编译 CGAl。然后,重新运行 cmake,确保它找到了库(调用 ccmake 或密切关注 cmake 配置输出,例如“found Eigen3”)并重建 CGAL。

【讨论】:

  • 我已经安装了 libeigen3-dev(v. 3.2.5:CGAL 需要 3.1 或更高版本),但正如您得出的结论,我没有手动将其包含在 CMakeLists.txt 中。我使用“INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR})”来执行此操作,其中 EIGEN3_INCLUDE_DIR 是从命令行参数“-DEIGEN3_INCLUDE_DIR=/usr/include/eigen3”(signature_of_eigen3_matrix_library 的目录)传递的。在使用简单的 IF 语句进行测试后,似乎路径定位正确。然而,当使用我新编译的 CGAL 版本编译原始帖子中的示例时,错误仍然存​​在。
  • 您是在谈论您自己的项目(即本示例)的 CMakeLists.txt 还是 CGAL 源代码树的?我的意思是,您想在启用 Eigen 或 Lapack 的情况下重建实际的 CGAL 源代码树。至少那是代码所暗示的。检查 CGAL 构建目录中的输出 ccmake . 以查看是否启用并构建了 Eigen3。
  • 对不起,我应该指定我在谈论 CGAL 的源代码树中的 CMakelists.txt。根据 ccmake, WITH_Eigen3 没有设置为 ON,所以我猜,你是对的。但是,更改此设置后,cmake 会生成以下关于 Eigen3 的文本: -- Eigen3 已预先配置: -- UseEigen3-file: UseEigen3 -- Eigen3 include: /usr/include/eigen3 -- Eigen3 库: -- Eigen3 定义:Yet错误似乎仍然存在。我没有正确包含库吗?
  • 好吧,既然我也在学习 CG,并且即将投资学习 CGAL,让我尝试重现您的设置并在一天内报告。
  • 谢谢!非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-07
  • 2012-03-30
相关资源
最近更新 更多