diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index 22a6be53523..85d4ff65c29 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -17,14 +17,13 @@ // SPDX-License-Identifier: GPL-3.0+ // // -// Author(s) : Maxime Gimeno and Sebastien Loriot +// Author(s) : Maxime Gimeno, Sebastien Loriot, Martin Skrodzki #ifndef CGAL_POLYGON_MESH_PROCESSING_DISTANCE_H #define CGAL_POLYGON_MESH_PROCESSING_DISTANCE_H #include - #include #include #include @@ -41,6 +40,8 @@ #include #include +#include + #ifdef CGAL_LINKED_WITH_TBB #include #include @@ -874,8 +875,12 @@ double bounded_error_Hausdorff_impl( CGAL_assertion_msg (is_triangle, "One of the meshes is not triangulated. Distance computing impossible."); + typedef AABB_face_graph_triangle_primitive TM1_primitive; typedef AABB_face_graph_triangle_primitive TM2_primitive; + typedef AABB_tree< AABB_traits > TM1_tree; typedef AABB_tree< AABB_traits > TM2_tree; + typedef typename AABB_tree< AABB_traits >::AABB_traits Tree_traits; + typedef typename Kernel::Point_3 Point_3; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -904,6 +909,15 @@ double bounded_error_Hausdorff_impl( tm1_vertices.end(), Search_traits_3(vpm1) ); + // Build an AABB tree on tm1 + TM1_tree tm1_tree( faces(tm1).begin(), faces(tm1).end(), tm1, vpm1 ); + tm1_tree.build(); + tm1_tree.accelerate_distance_queries(); + + // Build traversal traits for tm1_tree + Hausdorff_primitive_traits traversal_traits( tm1_tree.traits() ); + tm1_tree.traversal( Point_3(0,0,0), traversal_traits ); + // Build an AABB tree on tm2 TM2_tree tm2_tree( faces(tm2).begin(), faces(tm2).end(), tm2, vpm2 ); tm2_tree.build(); @@ -1026,6 +1040,8 @@ double bounded_error_Hausdorff_impl( } } + + // TODO Iterate over candidate_triangles and kill those which cannot contribute anymore // TODO Send the remaining triangles to the Subdivision diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h new file mode 100644 index 00000000000..58bf1d85805 --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h @@ -0,0 +1,80 @@ +// Copyright (c) 2019 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0+ +// +// +// Author(s) : Sebastien Loriot, Martin Skrodzki +// + +#ifndef CGAL_PMP_INTERNAL_AABB_TRAVERSAL_TRAITS_WITH_HAUSDORFF_DISTANCE +#define CGAL_PMP_INTERNAL_AABB_TRAVERSAL_TRAITS_WITH_HAUSDORFF_DISTANCE + +#include + +namespace CGAL { + + /** + * @class Hausdorff_primitive_traits + */ + template + class Hausdorff_primitive_traits + { + typedef typename AABBTraits::Primitive Primitive; + typedef ::CGAL::AABB_node Node; + + public: + Hausdorff_primitive_traits(const AABBTraits& traits) + : m_traits(traits) {} + + // Explore the whole tree, i.e. always enter children if the methods + // do_intersect() below determines that it is worthwhile. + bool go_further() const { return true; } + + // Compute the explicit Hausdorff distance to the given primitive + void intersection(const Query& query, const Primitive& primitive) + { + // Have reached a single triangle + std::cout << "Reached Triangle " << primitive.id() << '\n'; + + /* TODO implement handling of a single triangle + / - Call Culling on B (First maybe don't cull, but only consider closest + / triangle), obtain local bounds for the triangle + / - Update global Hausdorff bounds according to the obtained local bounds + / - return the current best known global bounds + */ + } + + bool do_intersect(const Query& query, const Node& node) const + { + // Have reached a node, determine whether or not to enter it + + /* TODO implement processing of an AABB node + / - Determine distance of the node's bounding box (node.bbox()) to the + / closest point in B (First maybe any point) + / - If the distance is larger than the global lower bound, enter the + / node, i.e. return true. + */ + return true; + //return m_traits.do_intersect_object()(query, node.bbox()); + } + + private: + const AABBTraits& m_traits; + }; +} + +#endif //CGAL_PMP_INTERNAL_AABB_TRAVERSAL_TRAITS_WITH_HAUSDORFF_DISTANCE