Implement a non-trivial toy example to test subdivision with. Intended solution is: Hausdorff distance will be attained at Point (0,0,1) and should be sqrt(3).

This commit is contained in:
Martin Skrodzki 2019-06-24 03:42:48 +02:00
parent 7ec6c4ca32
commit 2a523825a7
2 changed files with 39 additions and 14 deletions

View File

@ -10,21 +10,45 @@
#endif #endif
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point; typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<K::Point_3> Mesh; typedef K::Triangle_3 Triangle_3;
typedef CGAL::Surface_mesh<Point_3> Mesh;
typedef Mesh::Vertex_index Vertex_index;
namespace PMP = CGAL::Polygon_mesh_processing; namespace PMP = CGAL::Polygon_mesh_processing;
int main() int main()
{ {
Mesh tm1, tm2; Mesh tm1, tm2;
CGAL::make_tetrahedron(Point(.0,.0,.0), /*
Point(2,.0,.0), CGAL::make_tetrahedron(Point_3(.0,.0,.0),
Point(1,1,1), Point_3(2,.0,.0),
Point(1,.0,2), Point_3(1,1,1),
Point_3(1,.0,2),
tm1); tm1);
tm2=tm1; tm2=tm1;
CGAL::Polygon_mesh_processing::isotropic_remeshing(tm2.faces(),.05, tm2); CGAL::Polygon_mesh_processing::isotropic_remeshing(tm2.faces(),.05, tm2);
*/
tm1 = Mesh();
tm1.add_vertex( Point_3(-1.,1.,1.) );
tm1.add_vertex( Point_3(0.,-1.,1.) );
tm1.add_vertex( Point_3(1.,1.,1.) );
tm1.add_face( tm1.vertices() );
std::cout << "TM1 is valid: " << (tm1.is_valid() ? "true" : "false") << std::endl;
tm2 = Mesh();
Vertex_index w0 = tm2.add_vertex( Point_3(-1.,1.,0.) );
Vertex_index w1 = tm2.add_vertex( Point_3(0.,-1.,0.) );
Vertex_index w2 = tm2.add_vertex( Point_3(1.,1.,0.) );
Vertex_index w3 = tm2.add_vertex( Point_3(0.,1.,-1.) );
Vertex_index w4 = tm2.add_vertex( Point_3(-0.5,0.,-1.) );
Vertex_index w5 = tm2.add_vertex( Point_3(0.5,0.,-1.) );
tm2.add_face( w0, w3, w4 );
tm2.add_face( w1, w4, w5 );
tm2.add_face( w2, w5, w3 );
std::cout << "TM2 is valid: " << (tm2.is_valid() ? "true" : "false") << std::endl;
std::cout << "Approximated Hausdorff distance: " std::cout << "Approximated Hausdorff distance: "
<< CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance << CGAL::Polygon_mesh_processing::bounded_error_Hausdorff_distance

View File

@ -67,8 +67,7 @@ namespace CGAL {
// Compute the explicit Hausdorff distance to the given primitive // Compute the explicit Hausdorff distance to the given primitive
void intersection(const Query& query, const Primitive& primitive) void intersection(const Query& query, const Primitive& primitive)
{ {
// Have reached a single triangle /* Have reached a single triangle, process it */
std::cout << "Reached Triangle in TM2:" << primitive.id() << '\n';
/* /*
/ Determine the distance accroding to / Determine the distance accroding to
@ -222,8 +221,7 @@ namespace CGAL {
// Compute the explicit Hausdorff distance to the given primitive // Compute the explicit Hausdorff distance to the given primitive
void intersection(const Query& query, const Primitive& primitive) void intersection(const Query& query, const Primitive& primitive)
{ {
// Have reached a single triangle /* Have reached a single triangle, process it */
std::cout << "Reached Triangle in TM1: " << primitive.id() << '\n';
// Map to transform faces of TM1 to actual triangles // Map to transform faces of TM1 to actual triangles
Triangle_from_face_descriptor_map<TriangleMesh, VPM1> m_face_to_triangle_map( &m_tm1, m_vpm1 ); Triangle_from_face_descriptor_map<TriangleMesh, VPM1> m_face_to_triangle_map( &m_tm1, m_vpm1 );
@ -251,11 +249,14 @@ namespace CGAL {
h_upper = local_bounds.second; h_upper = local_bounds.second;
} }
std::cout << "Processed triangle: " << primitive.id()
<< ", found bounds (low., up.): (" << local_bounds.first
<< ", " << local_bounds.second << ")" << std::endl;
// 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_back(Candidate_triangle(candidate_triangle, local_bounds)); m_candidiate_triangles.push_back(Candidate_triangle(candidate_triangle, local_bounds));
/* TODO Store the triangle given here is primitive as candidate triangle
together with the local bounds it optained to send it to
subdivision later.
*/
} }
// Determine whether child nodes will still contribute to a larger // Determine whether child nodes will still contribute to a larger