![](/img/trans.png)
[英]CGAL - wrong vertices index retrieved after Delaunay Triangulation in 3d
[英]Issue with CGAL 3D periodic Delaunay triangulation with info
我想使用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的代碼幾乎相同。
讓我知道它是怎么回事,如果你需要幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.