10 #if CGAL_VERSION_NR >= 1040100000
11 #define CGAL_LAPACK_ENABLED
13 #include <CGAL/Monge_via_jet_fitting.h>
14 #include <CGAL/Cartesian.h>
22 #ifdef NUKLEI_USE_CGAL
23 namespace cgal_jet_fitting_types
26 typedef CGAL::Cartesian<DFT> Data_Kernel;
27 typedef Data_Kernel::Point_3 DPoint;
28 typedef CGAL::Monge_via_jet_fitting<Data_Kernel> Monge_via_jet_fitting;
29 typedef Monge_via_jet_fitting::Monge_form Monge_form;
33 boost::tuple<Matrix3, Vector3, coord_t>
38 #ifdef NUKLEI_USE_CGAL
40 using namespace cgal_neighbor_search_types;
41 using namespace cgal_jet_fitting_types;
43 if (!deco_.has_key(NSTREE_KEY))
44 NUKLEI_THROW(
"Undefined neighbor search tree. Call buildNeighborSearchTree() first.");
46 boost::shared_ptr<Tree> tree(deco_.get< boost::shared_ptr<Tree> >(NSTREE_KEY));
48 Point_d center(loc.X(), loc.Y(), loc.Z());
50 std::vector<DPoint> in_points;
51 K_neighbor_search search(*tree, center, 16+1);
53 for (K_neighbor_search::iterator i = search.begin(); i != search.end(); ++i)
55 in_points.push_back(DPoint(i->first.x(), i->first.y(), i->first.z()));
61 if (in_points.size() != 16+1)
62 return boost::tuple<Matrix3, Vector3, coord_t>();
64 Monge_form monge_form;
65 Monge_via_jet_fitting monge_fit;
66 monge_form = monge_fit(in_points.begin(), in_points.end(), d_fitting, d_monge);
79 for (
int i = 0; i < 3; i++)
81 Vector3 v(monge_fit.pca_basis(i).second[0],
82 monge_fit.pca_basis(i).second[1],
83 monge_fit.pca_basis(i).second[2]);
84 eigenVectors.SetColumn(i, v);
85 eigenValues[i] = monge_fit.pca_basis(i).first;
88 conditionNumber = monge_fit.condition_number();
91 return boost::make_tuple(eigenVectors, eigenValues, conditionNumber);
94 NUKLEI_THROW(
"This function requires CGAL. See http://renaud-detry.net/nuklei/group__install.html");
104 if (!deco_.has_key(NSTREE_KEY))
106 "Call buildNeighborSearchTree() first.");
113 k.loc_ = i->getLoc();
114 boost::tuple<Matrix3, Vector3, coord_t> dp =
116 if (dp.get<2>() == 0)
121 k.dir_ = dp.get<0>().GetColumn(2);
123 if (i->hasDescriptor()) k.setDescriptor(i->getDescriptor());
127 NUKLEI_WARN(
"Skipped " << skipped <<
" kernels for which "
128 "CGAL couldn't compute local diff.");