首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我的cgal代码3d delaunay三角剖分错误

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

Stack Overflow用户
提问于 2019-06-20 03:39:05
回答 1查看 165关注 0票数 0

我传入该点以进行三角剖分并输出单元格数据。但是返回的值是错误的,因为单元数据违反了三角剖分的原则。

代码语言:javascript
复制
   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); 
  }

// -期望-正如您在上面看到的。我有5个点(-400.0,400.0,0.0),(200,400.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)的单元格。

// - Result -但它是如何拆分错误的( 0,1,2,3)和(0,1,3,4)的。如果我把z从3和4减少到300和-300,它就会吐出3 cell。( 0,1,2,3),(4,0,2,3)和(1,4,2,3)。

//-更新1.

所以我改变了提取顶点的方式。我直接从itCell->vertext->point()转换,并正确地得到了我想要的顶点。但它仍然给了我很多与其他细胞相交的细胞。我认为集合应该是唯一的,并且不会与其他细胞相交。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56674754

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档