我的cgal代码3d delaunay三角剖分错误

我的cgal代码3d delaunay三角剖分错误,3d,cgal,delaunay,3d,Cgal,Delaunay,我通过点来进行三角测量,并吐出单元数据。但是值spit back是错误的,因为单元格数据违反了三角剖分的原则 typedef CGAL::Exact_predicates_exact_constructions_kernel K; typedef CGAL::Delaunay_triangulation_3<K> Delaunay; std::vector<K::Point_3> points; std::map<Delaunay::

我通过点来进行三角测量,并吐出单元数据。但是值spit back是错误的,因为单元格数据违反了三角剖分的原则

   typedef CGAL::Exact_predicates_exact_constructions_kernel K; 
   typedef CGAL::Delaunay_triangulation_3<K> Delaunay; 

   std::vector<K::Point_3> points; 
   std::map<Delaunay::Vertex_handle, int> index_of_vertex; 


   points.push_back(K::Point_3(-400.0, 0.0, 0.0)); 
   points.push_back(K::Point_3(200, 400.0, 0.0)); 
   points.push_back(K::Point_3(200, -400.0, 0.0)); 
   points.push_back(K::Point_3(0.0, 0.0, 600.0)); 
   points.push_back(K::Point_3(0.0, 0.0, -600.0)); 

   //And here I push the vector to Delaunay 
   Delaunay dt(points.begin(), points.end()); 

   // Keep track of vertex used 
   for (Delaunay::Finite_vertices_iterator it = t.finite_vertices_begin(); it != dt.finite_vertices_end(); ++it, ++j) 
    { 
        index_of_vertex[it.base()] = j; 
    } 

   // Iterate though and extract vertex and index in cell. 
   for (Delaunay::Finite_cells_iterator itCell = it.finite_cells_begin(), itend = dt.finite_cells_end();              itCell != itend; itCell++) 
    { 
        vector<double> verts; 
        vector<int> indx; 

        int ind0 = index_of_vertex[itCell->vertex(0)]; 
        int ind1 = index_of_vertex[itCell->vertex(1)]; 
        int ind2 = index_of_vertex[itCell->vertex(2)]; 
        int ind3 = index_of_vertex[itCell->vertex(3)]; 

        K::Point_3 v0 = points[ind0]; 
        K::Point_3 v1 = points[ind1]; 
        K::Point_3 v2 = points[ind2]; 
        K::Point_3 v3 = points[ind3]; 

        // Store the vertex 
        verts.push_back(CGAL::to_double(v0.x())); 
        ... 
        verts.push_back(CGAL::to_double(v3.z())); 

        // extract the index 
        int ind00 = Delaunay::vertex_triple_index(0, 0); 
        ... 
        int ind32 = Delaunay::vertex_triple_index(3, 2); 

        // Store the index 
        indx.push_back(ind00); 
        ... 
        indx.push_back(ind32); 
  }
typedef CGAL::Exact_谓词\u Exact_构造\u内核K;
typedef CGAL::Delaunay_三角剖分_3Delaunay;
std::向量点;
std::映射顶点的索引;
点。向后推(K::点3(-400.0,0.0,0.0));
点。向后推(K::点3(200400.0,0.0));
点。向后推(K::点3(200,-400.0,0.0));
点。向后推(K::点3(0.0,0.0600.0));
点。向后推(K::点3(0.0,0.0,-600.0));
//这里我把向量推到Delaunay
Delaunay dt(points.begin(),points.end());
//跟踪所使用的顶点
对于(Delaunay::Finite_vertices_iterator it=t.Finite_vertices_begin();it!=dt.Finite_vertices_end();++it,++j)
{ 
_顶点的索引[it.base()]=j;
} 
//迭代并提取单元格中的顶点和索引。
对于(Delaunay::Finite_cells\u iterator itCell=it.Finite_cells\u begin(),itend=dt.Finite_cells\u end();itCell!=itend;itCell++)
{ 
向量顶点;
向量indx;
int ind0=顶点的索引[itCell->顶点(0)];
int ind1=顶点的索引[itCell->顶点(1)];
int ind2=顶点的索引[itCell->顶点(2)];
int ind3=顶点的索引[itCell->顶点(3)];
K::点_3 v0=点[ind0];
K::点_3 v1=点[ind1];
K::Point_3 v2=points[ind2];
K::点_3 v3=点[ind3];
//存储顶点
垂直推回(CGAL::to_double(v0.x());
... 
向后推(CGAL::to double(v3.z());
//提取索引
int ind00=Delaunay::顶点三重指数(0,0);
... 
int ind32=Delaunay::顶点三重指数(3,2);
//存储索引
indx.推回(ind00);
... 
indx.推回(ind32);
}
//----期望-- 正如你在上面看到的。我得了5分(-400.0,0.0,0.0),(200400.0,0.0), (200, -400.0, 0.0), (0.0, 0.0, 600.0), (0.0, 0.0, -600.0). 所以,如果它吐出正确,我很可能是两个单元,顶点在索引处 (0,1,2,3)和(0,1,2,4)的

//----结果---- 但有些人认为它是如何分裂成错误的(0,1,2,3)和(0,1,3,4)。如果我减少 z为3和4,下降到300和-300,它吐出3个细胞。( 0, 1, 2, 3), (4, 0, 2,3)和(1,4,2,3)

//------更新1----

所以我改变了提取顶点的方法。我直接从itCell->vertext->point()转换得到我认为正确的顶点。但它仍然给了我很多细胞 与其他单元格相交。我认为这个集合应该是独一无二的,不会与其他单元相交

如文件所述,此函数不能保证按照PointInputIterator的顺序插入点。如果要设置与输入匹配的索引,最好使用。也行

相应函数的文档是。

如文档所述,此函数不保证按照PointInputIterator的顺序插入点。如果要设置与输入匹配的索引,最好使用。也行


相应函数的doc是。

因此,在推送到delaunay对象之前,必须以某种方式对点进行排序?。顺便说一句,我想要3d delaunay。那么这个2d代码是否也会以同样的方式工作呢?排序确实是在内部完成的,以加快插入速度。3D的工作原理是一样的。所以在推送到delaunay对象之前,你必须以某种方式对点进行排序?。顺便说一句,我想要3d delaunay。那么这个2d代码是否也会以同样的方式工作呢?排序确实是在内部完成的,以加快插入速度。3D也一样。