33 template<
typename PointCloud,
39 const PointMap& pointMap,
44 const GeometryTraits >){
49 int cloud_size =
static_cast<int>(
num_vertices(pointCloud));
50 auto iterator_pair =
vertices(pointCloud);
51 auto vi = iterator_pair.first;
52 auto vi_end = iterator_pair.second;
54 if(n_neight > cloud_size)
55 throw std::invalid_argument(
"compute_weighted_pca() -> n_neight parameter value bigger than the point cloud's number of point.");
57 c.
pointcloud_ =
new Eigen::Matrix<float, Eigen::Dynamic, 3>(cloud_size+1, 3);
59 vi = iterator_pair.first;
61 for(; vi != vi_end; ++vi){
62 auto p =
get(pointMap, *vi);
72 std::cout<<
"cloud resolution : "<<res<<std::endl<<std::endl;
74 Eigen::Matrix<float, Eigen::Dynamic, 3>* pc = c.
getPC();
75 flann::Index<flann::L2<float>>* tree = c.
getTree();
82 std::cout<<
"estimated noise="<<noise<<std::endl<<std::endl;
83 std::cout<<
"minimum curvature radius tolerated="<<
curvature<<std::endl<<std::endl;
84 std::cout<<
"division factor="<<
div_fact<<std::endl<<std::endl;
86 std::vector<Eigen::Vector3f> normals(cloud_size);
87 std::vector<Eigen::Vector3f> points(cloud_size);
88 std::vector<int> onEdge(cloud_size);
90 std::cout<<
"------------------------------Computing normals------------------------------"<<std::endl<<std::endl;
92 std::cout<<
"Avancement : "<<std::endl;
93 auto t_tot1 = std::chrono::high_resolution_clock::now();
96 for (
int i = 0; i < cloud_size; ++i)
98 CApp app(pc, tree, i, noise);
99 Eigen::Vector3f point_ref = app.
getPoint();
104 std::cout<<((float)i/(
float)cloud_size) * 100<<
"%"<<std::endl;
137 std::cout<<
"nan normal or point :"<<i<<std::endl;
152 std::cout<<
"nan normal or point :"<<i<<std::endl;
157 points[i] = point_ref;
159 if(normals[i].dot(points[i])>0)
160 normals[i]=-normals[i];
163 auto t_tot2 = std::chrono::high_resolution_clock::now();
164 typedef typename boost::property_traits< NormalMap >::value_type Normal;
166 vi = iterator_pair.first;
167 for(
size_t i = 0; i < normals.size(); ++i){
168 Normal normal(normals[i][0], normals[i][1], normals[i][2]);
169 put(normalMap, *vi, normal);
173 std::cout<<
"total time to get normals :" <<std::chrono::duration_cast<std::chrono::milliseconds>(t_tot2-t_tot1).count()<<
" milliseconds"<<std::endl<<std::endl;
176 template<
typename PointCloud,
182 const PointMap& pointMap,
183 NormalMap& normalMap,
188 GeometryTraits gt(pointCloud);