【问题标题】:Triangulation/polygonisation of approximataly coplanar 3d points近似共面 3d 点的三角剖分/多边形化
【发布时间】:2016-06-29 07:06:58
【问题描述】:

我有一个 3d 点列表(由 std::vector 表示)和给定平面 P,这样:

  1. 每个点与 P 的距离小于阈值。
  2. 点列表中没有重复项。

点在平面上的投影是一个二维多边形,可以复退化无孔

我想要这些点的三角剖分(或者,如果可能的话,多边形化),使得该三角剖分在平面上的投影对应于平面上点投影的二维三角剖分。换句话说,我需要操作之间的交换性:“Triangulate”和“project on plane”。

因此凸包并不令人满意。

CGAL 能做到吗?

【问题讨论】:

    标签: 3d geometry polygon cgal triangulation


    【解决方案1】:

    下面的代码应该做你想做的事。需要知道平面的正交向量(可以使用PCA包自动获取)。

    #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
    #include <CGAL/Constrained_Delaunay_triangulation_2.h>
    #include <CGAL/Triangulation_2_projection_traits_3.h>
    #include <CGAL/Triangulation_vertex_base_with_info_2.h>
    
    typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
    typedef CGAL::Triangulation_2_projection_traits_3<K> CDT_traits;
    typedef CGAL::Constrained_Delaunay_triangulation_2<CDT_traits> CDT;
    typedef std::pair<K::Point_3, K::Point_3> Constraint;
    
    int main()
    {
      K::Vector_3 plane_orthogonal_vector(1,1,0);
      CDT_traits traits(plane_orthogonal_vector);
      CDT cdt(traits);
    
      std::vector<CDT::Vertex_handle> vertices;
      vertices.push_back( cdt.insert(K::Point_3(0,0,0)) );
      vertices.push_back( cdt.insert(K::Point_3(1,1,0)) );
      vertices.push_back( cdt.insert(K::Point_3(1,1,1)) );
      vertices.push_back( cdt.insert(K::Point_3(0,0,1)) );
    
      cdt.insert_constraint(vertices[0],vertices[1]);
      cdt.insert_constraint(vertices[1],vertices[2]);
      cdt.insert_constraint(vertices[2],vertices[3]);
      cdt.insert_constraint(vertices[3],vertices[0]);
    }
    

    使用 CGAL 4.9,以下代码对于较大的多边形会更快(它适用于 4.8,但需要以下 patch):

    #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
    #include <CGAL/Constrained_Delaunay_triangulation_2.h>
    #include <CGAL/Triangulation_2_projection_traits_3.h>
    #include <CGAL/Triangulation_vertex_base_with_info_2.h>
    
    typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
    typedef CGAL::Triangulation_2_projection_traits_3<K> CDT_traits;
    typedef CGAL::Constrained_Delaunay_triangulation_2<CDT_traits> CDT;
    typedef std::pair<std::size_t, std::size_t> Index_pair;
    
    int main()
    {
      K::Vector_3 plane_orthogonal_vector(1,1,0);
      CDT_traits traits(plane_orthogonal_vector);
      CDT cdt(traits);
    
      std::vector<K::Point_3> points;
      points.push_back( K::Point_3(0,0,0) );
      points.push_back( K::Point_3(1,1,0) );
      points.push_back( K::Point_3(1,1,1) );
      points.push_back( K::Point_3(0,0,1) );
    
      std::vector<Index_pair > constraint_indices;
      constraint_indices.push_back( Index_pair(0,1) );
      constraint_indices.push_back( Index_pair(1,2) );
      constraint_indices.push_back( Index_pair(2,3) );
      constraint_indices.push_back( Index_pair(3,0) );
    
    
      cdt.insert_constraints( points.begin(), points.end(),
                              constraint_indices.begin(), constraint_indices.end() );
    
    }
    

    【讨论】:

    • 谢谢!但是还有 1 项任务需要完成:我的多边形在 2D 平面上的投影可能不是凸的。如果我理解正确,CGAL 三角剖分的外多边形是凸包。所以在三角测量之后,我必须删除所有站在多边形“外部”的三角形。
    • 看看这个exemple
    • 嗯...我看不出它对我有什么帮助
    • 解决这个问题的一种方法可能是遍历多边形的顶点,并且对于每个凹顶点,依次删除多边形“外部”的所有三角形。
    • 这个例子展示了如何标记多边形域内的所有三角形。
    猜你喜欢
    • 2011-01-24
    • 2017-04-09
    • 1970-01-01
    • 2012-09-28
    • 2015-03-19
    • 2011-01-14
    • 2011-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多