使用 Cgals 的 mst_orient_normals() 定向点法线,同时保持原始点顺序

问题描述

Cgals 的 mst_orient_normals() 方法修改输入点的顺序,以便首先打包所有成功定向的点,并在第一个点上返回一个具有无方向法线的迭代器。我想保持输入点的顺序。为了实现这一点,我目前需要使用如下所示的专用索引(请注意,此代码仅供参考)。有没有更有效的方法来实现这一点,而不涉及向元组添加索引然后按该索引排序?

#include <Cgal/pca_estimate_normals.h>
#include <Cgal/mst_orient_normals.h>
#include <Cgal/property_map.h>
#include <Cgal/Exact_predicates_inexact_constructions_kernel.h>
#include <Cgal/tags.h>
typedef Cgal::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point3;
typedef Kernel::Vector_3 Vector;
typedef std::tuple<int,Point3,Vector> PointVectorTuple;
typedef std::vector<PointVectorTuple> PointListwithindex;
typedef Cgal::Parallel_if_available_tag Concurrency_tag;

int main(int argc,char*argv[])
{

  unsigned int nb_neighbors_pca_normals = 18; // K-nearest neighbors = 3 rings (estimate normals by PCA)
  unsigned int nb_neighbors_mst = 18; // K-nearest neighbors (orient normals by MST)

  PointListwithindex pointswithindex;

  /**
  Load indices,coordinates,and zero vector (normal in this case) into pointswithindex
  **/

  // Estimates normals direction.
  Cgal::pca_estimate_normals<Concurrency_tag>(pointswithindex,nb_neighbors_pca_normals,Cgal::parameters::point_map (Cgal::Nth_of_tuple_property_map<1,PointVectorTuple>()).
                                                      normal_map (Cgal::Nth_of_tuple_property_map<2,PointVectorTuple>()));

  // Orients normals.
  PointListwithindex::iterator unoriented_points_begin =
          Cgal::mst_orient_normals(pointswithindex,nb_neighbors_mst,PointVectorTuple>()).
                                           normal_map(Cgal::Nth_of_tuple_property_map<2,PointVectorTuple>()));

  // Sort list back by into original order using the index
  std::sort(pointswithindex.begin(),pointswithindex.end(),[](const PointVectorTuple & a,const PointVectorTuple & b) {
                return (std::get<0>(a) < std::get<0>(b));
            });

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)