mirror of https://github.com/CGAL/cgal
face descriptor is now stored in the candidate triangle to remember the realizing triangle
This commit is contained in:
parent
56b77cfd9f
commit
81513fc860
|
|
@ -1345,6 +1345,7 @@ double bounded_error_Hausdorff_impl(
|
|||
typedef typename Kernel::Triangle_3 Triangle_3;
|
||||
|
||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||
using Candidate = Candidate_triangle<Kernel, face_descriptor>;
|
||||
|
||||
typename Kernel::Compute_squared_distance_3 squared_distance;
|
||||
|
||||
|
|
@ -1400,13 +1401,15 @@ double bounded_error_Hausdorff_impl(
|
|||
// Can already build a sorted structure while collecting the candidates
|
||||
auto& candidate_triangles = traversal_traits_tm1.get_candidate_triangles();
|
||||
auto global_bounds = traversal_traits_tm1.get_global_bounds();
|
||||
// std::cout << candidate_triangles.size() << std::endl;
|
||||
|
||||
// std::cout << "number of candidate triangles 1: " <<
|
||||
// candidate_triangles.size() << std::endl;
|
||||
|
||||
const FT squared_error_bound = error_bound * error_bound;
|
||||
while ( (global_bounds.second - global_bounds.first > error_bound) && !candidate_triangles.empty() ) {
|
||||
|
||||
// Get the first triangle and its Hausdorff bounds from the candidate set
|
||||
const Candidate_triangle<Kernel> triangle_and_bound = candidate_triangles.top();
|
||||
const Candidate triangle_and_bound = candidate_triangles.top();
|
||||
// Remove it from the candidate set as it will be processed now
|
||||
candidate_triangles.pop();
|
||||
|
||||
|
|
@ -1414,11 +1417,11 @@ double bounded_error_Hausdorff_impl(
|
|||
// i.e. if its Upper Bound is higher than the currently known best lower bound
|
||||
// and the difference between the bounds to be obtained is larger than the
|
||||
// user given error.
|
||||
const auto& triangle_bounds = triangle_and_bound.m_bounds;
|
||||
const auto& triangle_bounds = triangle_and_bound.bounds;
|
||||
|
||||
if ( (triangle_bounds.second > global_bounds.first) && (triangle_bounds.second - triangle_bounds.first > error_bound) ) {
|
||||
// Get the triangle that is to be subdivided and read its vertices
|
||||
const Triangle_3& triangle_for_subdivision = triangle_and_bound.m_triangle;
|
||||
const Triangle_3& triangle_for_subdivision = triangle_and_bound.triangle;
|
||||
const Point_3 v0 = triangle_for_subdivision.vertex(0);
|
||||
const Point_3 v1 = triangle_for_subdivision.vertex(1);
|
||||
const Point_3 v2 = triangle_for_subdivision.vertex(2);
|
||||
|
|
@ -1479,16 +1482,18 @@ double bounded_error_Hausdorff_impl(
|
|||
// TODO Additionally store the face descriptor of the parent from TM1 in the Candidate_triangle.
|
||||
// Add the subtriangle to the candidate list
|
||||
candidate_triangles.push(
|
||||
Candidate_triangle<Kernel>(sub_triangles[i], local_bounds)
|
||||
);
|
||||
Candidate(sub_triangles[i], local_bounds, triangle_and_bound.face) );
|
||||
}
|
||||
|
||||
// Update global upper Hausdorff bound after subdivision
|
||||
const FT current_max = candidate_triangles.top().m_bounds.second;
|
||||
const FT current_max = candidate_triangles.top().bounds.second;
|
||||
global_bounds.second = std::max(current_max, global_bounds.first);
|
||||
}
|
||||
}
|
||||
|
||||
// std::cout << "number of candidate triangles 2: " <<
|
||||
// candidate_triangles.size() << std::endl;
|
||||
|
||||
// Return linear interpolation between found lower and upper bound
|
||||
return CGAL::to_double((global_bounds.first + global_bounds.second) / FT(2));
|
||||
|
||||
|
|
|
|||
|
|
@ -29,21 +29,25 @@ namespace CGAL {
|
|||
return FT(1000000000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @struct Candidate_triangle
|
||||
*/
|
||||
template<typename Kernel>
|
||||
// Candidate triangle.
|
||||
template<typename Kernel, typename FaceDescriptor>
|
||||
struct Candidate_triangle {
|
||||
using FT = typename Kernel::FT;
|
||||
typedef typename Kernel::Triangle_3 Triangle_3;
|
||||
using Triangle_3 = typename Kernel::Triangle_3;
|
||||
|
||||
Candidate_triangle(const Triangle_3& triangle, const std::pair<FT, FT>& bounds)
|
||||
: m_triangle(triangle), m_bounds(bounds) {}
|
||||
Candidate_triangle(
|
||||
const Triangle_3& triangle,
|
||||
const std::pair<FT, FT>& bounds,
|
||||
const FaceDescriptor& face) :
|
||||
triangle(triangle), bounds(bounds), face(face)
|
||||
{ }
|
||||
|
||||
Triangle_3 m_triangle;
|
||||
std::pair<FT, FT> m_bounds;
|
||||
bool operator>(const Candidate_triangle& other) const { return m_bounds.second < other.m_bounds.second; }
|
||||
bool operator<(const Candidate_triangle& other) const { return m_bounds.second > other.m_bounds.second; }
|
||||
Triangle_3 triangle;
|
||||
std::pair<FT, FT> bounds;
|
||||
FaceDescriptor face;
|
||||
|
||||
bool operator>(const Candidate_triangle& other) const { return bounds.second < other.bounds.second; }
|
||||
bool operator<(const Candidate_triangle& other) const { return bounds.second > other.bounds.second; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -229,7 +233,8 @@ namespace CGAL {
|
|||
typedef AABB_tree< AABB_traits<Kernel, TM2_primitive> > TM2_tree;
|
||||
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<TriangleMesh>::face_descriptor face_descriptor;
|
||||
typedef std::priority_queue< Candidate_triangle<Kernel> > Heap_type;
|
||||
using Candidate = Candidate_triangle<Kernel, face_descriptor>;
|
||||
typedef std::priority_queue<Candidate> Heap_type;
|
||||
|
||||
public:
|
||||
typedef FT Priority;
|
||||
|
|
@ -255,7 +260,7 @@ namespace CGAL {
|
|||
{
|
||||
// Map to transform faces of TM1 to actual triangles
|
||||
const Triangle_from_face_descriptor_map<TriangleMesh, VPM1> m_face_to_triangle_map( &m_tm1, m_vpm1 );
|
||||
const Triangle_3 candidate_triangle = get(m_face_to_triangle_map, primitive.id());
|
||||
const Triangle_3 triangle = get(m_face_to_triangle_map, primitive.id());
|
||||
|
||||
// TODO Can we initialize the bounds here, s.t. we don't start with infty?
|
||||
// Can we initialize the bounds depending on the closest points in tm2
|
||||
|
|
@ -271,7 +276,7 @@ namespace CGAL {
|
|||
infinity_value<FT>(),
|
||||
infinity_value<FT>()
|
||||
);
|
||||
m_tm2_tree.traversal_with_priority(candidate_triangle, traversal_traits_tm2);
|
||||
m_tm2_tree.traversal_with_priority(triangle, traversal_traits_tm2);
|
||||
|
||||
// Update global Hausdorff bounds according to the obtained local bounds
|
||||
const auto local_bounds = traversal_traits_tm2.get_local_bounds();
|
||||
|
|
@ -286,7 +291,7 @@ namespace CGAL {
|
|||
// Store the triangle given as primitive here as candidate triangle
|
||||
// together with the local bounds it obtained to sind it to subdivision
|
||||
// later
|
||||
m_candidiate_triangles.push( Candidate_triangle<Kernel>(candidate_triangle, local_bounds) );
|
||||
m_candidiate_triangles.push( Candidate(triangle, local_bounds, primitive.id()) );
|
||||
}
|
||||
|
||||
// Determine whether child nodes will still contribute to a larger
|
||||
|
|
|
|||
Loading…
Reference in New Issue