14 #include <boost/graph/graph_traits.hpp>
15 #include <boost/graph/properties.hpp>
17 #include <CGAL/Polygon_mesh_processing/distance.h>
18 #include <CGAL/Polygon_mesh_processing/remesh.h>
19 #include <CGAL/AABB_tree.h>
20 #include <CGAL/AABB_traits.h>
21 #include <CGAL/AABB_face_graph_triangle_primitive.h>
29 #if defined(CGAL_LINKED_WITH_TBB)
30 #define TAG CGAL::Parallel_tag
32 #define TAG CGAL::Sequential_tag
48 template <
typename HalfedgeGraph,
50 typename face_iterator =
typename boost::graph_traits<HalfedgeGraph>::face_iterator,
57 typedef CGAL::Exact_predicates_inexact_constructions_kernel
K;
58 typedef CGAL::AABB_face_graph_triangle_primitive<HalfedgeGraph>
AABB_primitive;
59 typedef CGAL::AABB_traits<CGALKernel, AABB_primitive>
AABB_traits;
74 return CGAL::Polygon_mesh_processing::approximate_Hausdorff_distance<TAG>(LoD,
81 return CGAL::Polygon_mesh_processing::approximate_Hausdorff_distance<TAG>(
_LoD_init,
89 std::pair<face_iterator, face_iterator> f_range_it=
faces(
_LoD_init);
90 face_iterator orig_begin = f_range_it.first;
91 face_iterator orig_end = f_range_it.second;
102 std::vector<double> empty_vector;
107 std::list<Point> empty_list;
114 CGAL::Polygon_mesh_processing::sample_triangle_mesh(
_LoD_init,
117 CGAL::Polygon_mesh_processing::parameters::use_grid_sampling(
true)
134 bool compute_RMSE_instead_of_max
139 using Point_and_primitive_id =
typename AABB_tree::Point_and_primitive_id;
141 double L2_error = 0.0;
145 std::list<Point> samples;
146 CGAL::Polygon_mesh_processing::sample_triangle_mesh(mesh_to_sample,
147 std::back_inserter(samples),
150 CGAL::Polygon_mesh_processing::parameters::use_grid_sampling(
true)
159 std::cout <<
"L2 cas 0: " << samples.size() <<
" samples" << std::endl;
161 for(
auto it = samples.begin(); it != samples.end(); ++it)
164 Point_and_primitive_id pp =
_LoD_init_tree.closest_point_and_primitive(*it);
166 Vector d = gt.sub_p(pp.first, *it);
167 if(compute_RMSE_instead_of_max)
168 L2_error += gt.length2(d);
171 auto dist = gt.length(d);
176 if(compute_RMSE_instead_of_max)
177 L2_error = std::sqrt( L2_error / (
double)samples.size() );
181 std::pair<face_iterator, face_iterator> f_range_it =
faces(mesh_to_sample);
182 face_iterator orig_begin = f_range_it.first;
183 face_iterator orig_end = f_range_it.second;
185 AABB_tree tree(orig_begin, orig_end, mesh_to_sample);
186 tree.accelerate_distance_queries();
187 std::cout <<
"L2 cas 1: " <<
_samples_LoD_init.size() <<
" init samples" << std::endl;
192 Point_and_primitive_id pp = tree.closest_point_and_primitive(*it);
194 Vector d = gt.sub_p(pp.first, *it);
195 if(compute_RMSE_instead_of_max)
196 L2_error += gt.length2(d);
199 auto dist = gt.length(d);
204 if(compute_RMSE_instead_of_max)
213 double d_LoD_to_mesh_init = this->
compute_L2(LoD, 0, compute_RMSE_instead_of_max);
214 double d_mesh_init_to_LoD = this->
compute_L2(LoD, 1, compute_RMSE_instead_of_max);
217 double d_max = (d_LoD_to_mesh_init < d_mesh_init_to_LoD) ? d_mesh_init_to_LoD : d_LoD_to_mesh_init;