Add traversal trait for Hausdorff-based AABB traversal on the first triangle mesh.
This commit is contained in:
@@ -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 <CGAL/license/Polygon_mesh_processing/distance.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <CGAL/AABB_tree.h>
|
||||
@@ -41,6 +40,8 @@
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/internal/mesh_to_point_set_hausdorff_distance.h>
|
||||
#include <CGAL/Polygon_mesh_processing/internal/AABB_traversal_traits_with_Hausdorff_distance.h>
|
||||
|
||||
#ifdef CGAL_LINKED_WITH_TBB
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
@@ -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<TriangleMesh, VPM1> TM1_primitive;
|
||||
typedef AABB_face_graph_triangle_primitive<TriangleMesh, VPM2> TM2_primitive;
|
||||
typedef AABB_tree< AABB_traits<Kernel, TM1_primitive> > TM1_tree;
|
||||
typedef AABB_tree< AABB_traits<Kernel, TM2_primitive> > TM2_tree;
|
||||
typedef typename AABB_tree< AABB_traits<Kernel, TM2_primitive> >::AABB_traits Tree_traits;
|
||||
|
||||
typedef typename Kernel::Point_3 Point_3;
|
||||
|
||||
typedef typename boost::graph_traits<TriangleMesh>::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<Tree_traits, Point_3> 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
|
||||
|
||||
+80
@@ -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 <iostream>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/**
|
||||
* @class Hausdorff_primitive_traits
|
||||
*/
|
||||
template<typename AABBTraits, typename Query>
|
||||
class Hausdorff_primitive_traits
|
||||
{
|
||||
typedef typename AABBTraits::Primitive Primitive;
|
||||
typedef ::CGAL::AABB_node<AABBTraits> 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
|
||||
Reference in New Issue
Block a user