【发布时间】:2019-12-31 15:46:44
【问题描述】:
我想使用 CGAL 构造一个带有信息的周期性 3D Delaunay 三角剖分(在本例中为整数)。对于 2D,如果我构造一个成对的向量(点、信息)并将其传递给三角测量函数,则效果很好。但是,非常类似的 3D 代码无法编译。下面是一个示例,将我自己的“粒子”格式的点转换为 CGAL 点格式。
这是 CGAL 的问题还是我遗漏了什么?
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/periodic_3_triangulation_3_io.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <list>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_3_Delaunay_triangulation_traits_3<K> Gt;
typedef CGAL::Periodic_3_triangulation_ds_vertex_base_3<> VbDS;
typedef CGAL::Triangulation_vertex_base_3<Gt, VbDS> Vb;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, Gt, Vb> VbInfo;
typedef CGAL::Periodic_3_triangulation_ds_cell_base_3<> CbDS;
typedef CGAL::Triangulation_cell_base_3<Gt, CbDS> Cb;
typedef CGAL::Triangulation_data_structure_3<VbInfo, Cb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> DT3;
typedef CGAL::Periodic_3_Delaunay_triangulation_3<Gt, Tds> P3DT3;
typedef P3DT3::Point Point;
typedef P3DT3::Iso_cuboid Iso_cuboid;
void create_PDT_3D(const std::vector<particle>& grid )
{
// The cube for the periodic domain
Iso_cuboid domain(0,0,0,1,1,1);
// Convert "particle" format to "point with info" format
std::vector<Point> points_bare;
std::vector< std::pair<Point,unsigned> > points_info;
points_bare.reserve(grid.size());
points_info.reserve(grid.size());
// the "info" is just given by the index of the point
for (unsigned i = 0; i < grid.size(); ++i )
{
points_bare.emplace_back( Point(grid[i].x, grid[i].y, grid[i].z) );
points_info.emplace_back( std::make_pair( Point(grid[i].x, grid[i].y, grid[i].z), i ) );
}
// Triangulate
DT3 Ta ( points_bare.begin(), points_bare.end() ); // working
DT3 Tb ( points_info.begin(), points_info.end() ); // working
// Triangulate (periodic)
P3DT3 TTa ( points_bare.begin(), points_bare.end(), domain ); // working
P3DT3 TTb ( points_info.begin(), points_info.end(), domain ); // NOT working
}
其中“粒子”是一个非常简单的类
class particle
{
public:
double x, y, z;
particle(double xr=0, double yr=0, double zr=0) : x(xr), y(yr), z(zr) {};
};
【问题讨论】: