【问题标题】:Constructing Templated type for CGAL c++为 CGAL c++ 构造模板类型
【发布时间】:2013-06-13 04:08:29
【问题描述】:

所以我有以下应该为 CGAL 创建一个 Delaunay 三角形类型:

std::vector<Point> points = createPoints() // Fills points, This works. 
Delaunay dt(points.begin(), points.end());

根据this 问题和手册here。这应该可以,但是我收到以下错误:

[100%] Building CXX object src/utilities/TriangulationVolumeCalculation/CMakeFiles/calculateVolumeDifference.dir/CalculateVolumeDifference.cpp.o
/home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp: In function ‘void fillDelaunay(Delaunay&, std::vector<std::vector<double> >)’:
/home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp:31:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp: In function ‘int main(int, char**)’:
/home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp:50:27: error: no matching function for call to ‘CGAL::Delaunay_triangulation_2<CGAL::Projection_traits_xy_3<CGAL::Epick> >::Delaunay_triangulation_2(std::vector<CGAL::Point_3<CGAL::Epick> >::iterator&, std::vector<CGAL::Point_3<CGAL::Epick> >::iterator&)’
/home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp:50:27: note: candidates are:
In file included from /home/uqbdart/SMG/sao2/src/utilities/TriangulationVolumeCalculation/CalculateVolumeDifference.cpp:3:0:
/usr/local/include/CGAL/Delaunay_triangulation_2.h:89:3: note: CGAL::Delaunay_triangulation_2<Gt, Tds>::Delaunay_triangulation_2(const CGAL::Delaunay_triangulation_2<Gt, Tds>&) [with Gt = CGAL::Projection_traits_xy_3<CGAL::Epick>; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Triangulation_ds_face_base_2<void> >]
/usr/local/include/CGAL/Delaunay_triangulation_2.h:89:3: note:   candidate expects 1 argument, 2 provided
/usr/local/include/CGAL/Delaunay_triangulation_2.h:86:2: note: CGAL::Delaunay_triangulation_2<Gt, Tds>::Delaunay_triangulation_2(const Gt&) [with Gt = CGAL::Projection_traits_xy_3<CGAL::Epick>; Tds = CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Projection_traits_xy_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Triangulation_ds_face_base_2<void> >]
/usr/local/include/CGAL/Delaunay_triangulation_2.h:86:2: note:   candidate expects 1 argument, 2 provided
make[2]: *** [src/utilities/TriangulationVolumeCalculation/CMakeFiles/calculateVolumeDifference.dir/CalculateVolumeDifference.cpp.o] Error 1
make[1]: *** [src/utilities/TriangulationVolumeCalculation/CMakeFiles/calculateVolumeDifference.dir/all] Error 2
make: *** [all] Error 2

手册指出:

 Precondition:  The value_type of first and last is Point.

其中 first 和 last 是开始和结束迭代器。

编辑:我通过这样做解决了它:

Delaunay dt;
dt.insert(points.begin(), points.end());

虽然它是固定的,但根据手册,所需迭代器的类型声明是相同的。为什么它会在构造函数中失败,而不是在 insert 函数中。

【问题讨论】:

  • 你能复制粘贴用于定义类型Delaunay的typedef链吗?

标签: c++ templates cgal


【解决方案1】:

您是否会使用旧版本的 CGAL ?如果我没记错的话,这个 range 的构造函数是在 insert() 函数之后引入的。好吧,只需检查代码。

【讨论】:

  • 确实是4.2引入的
  • 我使用的是最新版本的 GAL,另外,编译器不会抱怨该类型的构造函数不存在而是输入错误吗?
  • 请仔细检查您使用的 CGAL 版本。代码必须是 4.2 才能工作。
  • 是的,你是对的,我有 CGAL 版本 4.1,我想知道这是怎么发生的。
【解决方案2】:

问题可能是您的Point 类没有成为Delaunay_triangulation_2 模板参数所需的方法(我猜你曾经定义过Delaunay 类)

DelaunayPoint 类的定义是什么?

有用的例子可以在这里找到: http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_2/Chapter_main.html

【讨论】:

  • 没有一点是 CGAL 库的一部分。它是这样的 typedef:typedef K::Point_3 Point;
  • 好的,看到你的编辑了。然后我不知道为什么它在插入而不是在构造函数中起作用。不过,文档为insert() 指定了概念PointInputIterator,为构造函数指定了InputIterator。也许存在细微差别,但我无法帮助您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-31
  • 1970-01-01
相关资源
最近更新 更多