CGAL 3D 周期性德劳内三角测量与信息的问题

Issue with CGAL 3D periodic Delaunay triangulation with info

本文关键字:测量 信息 问题 三角 3D 周期性 CGAL      更新时间:2023-10-16

我想使用 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) {};
};

CGAL 中的 3D 周期三角测量没有必要的代码来插入带有信息的点范围。这不是因为强大的障碍使它无法实施,它只是没有完成。

但是,将代码从 2D 周期三角测量转换为 3D 情况几乎应该是立即的:您可以查看函数insert_with_info()以及如何在类Periodic_2_Delaunay_triangulation_2中使用它。对于 3D,代码几乎相同。

让我知道它是怎么回事,如果你需要帮助。