18 #include <Eigen/Dense>
32 template<
typename PointCloud,
33 typename VertexCurvatureMap >
36 const VertexCurvatureMap &v_curvm,
43 size_t vertices_nbr = 0;
47 auto vi = iterator_pair.first;
48 auto vi_end = iterator_pair.second;
49 for(; vi != vi_end; ++vi)
51 auto curv =
get(v_curvm, *vi);
58 mean = sum_x / vertices_nbr;
61 stdev = std::sqrt((sum_x2 / vertices_nbr) -
mean*
mean);
72 template<
typename PointCloud,
73 typename VertexCurvatureMap,
74 typename VertexColorMap >
77 const VertexCurvatureMap &v_curvm,
81 auto v_curvm_abs = FEVV::make_vertex_property_map< PointCloud, double >(pc);
83 auto vi = iterator_pair.first;
84 auto vi_end = iterator_pair.second;
85 for(; vi != vi_end; ++vi)
87 auto curv =
get(v_curvm, *vi);
88 put(v_curvm_abs, *vi, std::abs(curv));
92 double curv_mean, curv_stdev;
96 double curv_range_min = 0;
97 double curv_range_max = curv_mean + 2*curv_stdev;
101 pc, v_curvm_abs, v_cm, curv_range_min, curv_range_max);
118 template<
typename Point,
120 typename NNIdsVector,
121 typename GeometryTraits >
125 const NNIdsVector &neighbors_ids,
126 const GeometryTraits >)
132 size_t nneighbors = neighbors_ids.size();
134 for (
size_t i = 0; i < nneighbors; ++i)
136 Point p =
get(pm, neighbors_ids[i]);
137 Eigen::Vector3d neighbor(gt.get_x(p), gt.get_y(p), gt.get_z(p));
139 M = M + neighbor*neighbor.transpose();
142 mu = mu / ((double)nneighbors);
143 M = 1. / ((double)nneighbors)*M - mu*mu.transpose();
146 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> eig(M);
148 Eigen::Vector3d t1 = eig.eigenvectors().col(2);
149 Eigen::Vector3d t2 = eig.eigenvectors().col(1);
150 Eigen::Vector3d n = eig.eigenvectors().col(0);
152 Eigen::MatrixXd A(nneighbors, 6);
153 Eigen::VectorXd B(nneighbors);
156 for (
size_t i = 0; i < nneighbors; ++i)
158 Point p =
get(pm, neighbors_ids[i]);
159 double xglob = gt.get_x(p) - gt.get_x(origin);
160 double yglob = gt.get_y(p) - gt.get_y(origin);
161 double zglob = gt.get_z(p) - gt.get_z(origin);
162 Eigen::Vector3d v(xglob, yglob, zglob);
163 double x = v.transpose()*t1;
164 double y = v.transpose()*t2;
165 double z = v.transpose()*n;
177 Eigen::VectorXd coeffs = A.colPivHouseholderQr().solve(B);
180 double fxx = 2 * coeffs(0);
181 double fyy = 2 * coeffs(1);
182 double fxy = coeffs(2);
183 double fx = coeffs(3);
184 double fy = coeffs(4);
186 double H = 0.5*((1 + fx*fx)*fyy + (1 + fy*fy)*fxx - 2 * fxy*fx*fy) / pow(1 + fx*fx + fy*fy, 1.5);
206 template<
typename PointCloud,
208 typename VertexCurvatureMap,
209 typename VertexColorMap,
216 VertexCurvatureMap &v_curvm,
217 VertexColorMap &v_cm,
218 const GeometryTraits >)
225 auto vi = iterator_pair.first;
226 auto vi_end = iterator_pair.second;
227 for(; vi != vi_end; ++vi)
230 auto point =
get(pm, *vi);
233 decltype(
kNN_search(*kd_tree_ptr, k, point, pc)) result;
237 result =
kNN_search(*kd_tree_ptr, k, point, pc);
244 auto neighbors_ids = result.first;
250 put(v_curvm, *vi, curv);
270 template<
typename PointCloud,
272 typename VertexCurvatureMap,
273 typename VertexColorMap,
280 VertexCurvatureMap &v_curvm,
281 VertexColorMap &v_cm)
283 GeometryTraits gt(pc);