From 08d8e16d50305fc12f091c96ebe89bfca079cbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 17 Mar 2017 12:27:42 +0100 Subject: [PATCH] Modified Mesh_3 to work with P3M3 These are new changes compared to the previous commit (7b3314a). They are required because Mesh_3 has also evolved since it was forked. --- .../CGAL/Mesh_3/Mesh_surface_cell_base_3.h | 4 ++- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 17 +++++++++++ .../include/CGAL/Mesh_3/vertex_perturbation.h | 30 +++++++++++-------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h index 4cefe715e57..519d424acc8 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h @@ -312,7 +312,9 @@ operator<<(std::ostream &os, for(int i = 0; i < 4; ++i) { if(is_ascii(os)) - os << ' ' << c.surface_patch_index(i); + // + os << ' ' << c.surface_patch_index(i).first + << " " << c.surface_patch_index(i).second; else write(os, c.surface_patch_index(i)); } diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 14f0fc7888f..ac03b49a127 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -1731,11 +1731,28 @@ compute_facet_properties(const Facet& facet, } if (p1 == p2) { fp = Facet_properties(); return; } +#if 1 // + // segment here must be canonical for periodic. Dual_segment only calls + // the (robust) weighted circumcenter which does not return this canonical + // segment. The static cast is because we need to grab the dual function + // that is in P3RT3 and not at the level of periodic_mesh_triangulation_3 + // (due to inconsistencies with names). + assert(!force_exact); // code below is only meant to replace the call of dual_segment + Segment_3 segment = r_tr_.segment( + static_cast(&r_tr_)->dual(facet)); + if ( compare_xyz(segment.source(), segment.target()) == CGAL::LARGER ) + { + typename Gt::Construct_opposite_segment_3 opposite = + Gt().construct_opposite_segment_3_object(); + segment = opposite(segment); + } +#else // Trick to have canonical vector : thus, we compute always the same // intersection Segment_3 segment = ( compare_xyz(p1,p2)== CGAL::SMALLER ) ? Segment_3(p1, p2) : Segment_3(p2, p1); +#endif // If facet is on surface, compute intersection point and return true #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 diff --git a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h index 0731e669b81..bac3b546dea 100644 --- a/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h +++ b/Mesh_3/include/CGAL/Mesh_3/vertex_perturbation.h @@ -878,8 +878,8 @@ protected: bool *could_lock_zone = NULL) const { CGAL_precondition(!slivers.empty()); - - Vector_3 grad_vector = compute_gradient_vector(v,slivers); + + Vector_3 grad_vector = compute_gradient_vector(c3t3, v, slivers); // Exit if grad_vector is not relevant if ( CGAL::NULL_VECTOR == grad_vector ) @@ -903,18 +903,19 @@ private: * @brief compute the gradient vector */ Vector_3 - compute_gradient_vector(const Vertex_handle& v, + compute_gradient_vector(const C3T3& c3t3, + const Vertex_handle& v, const std::vector& slivers) const { switch (slivers.size()) { case 1: - return -1*compute_gradient_vector(slivers.front(),v); + return -1*compute_gradient_vector(c3t3, slivers.front(), v); break; case 2: { - Vector_3 v1 = compute_gradient_vector(slivers.front(), v); - Vector_3 v2 = compute_gradient_vector(slivers.back(), v); + Vector_3 v1 = compute_gradient_vector(c3t3, slivers.front(), v); + Vector_3 v2 = compute_gradient_vector(c3t3, slivers.back(), v); if( v1 * v2 > 0 ) // "-0.5" because angle has to go down return -0.5*(v1 + v2); @@ -932,7 +933,8 @@ private: * @brief compute the gradient vector */ Vector_3 - compute_gradient_vector(const Cell_handle& cell, + compute_gradient_vector(const C3T3& c3t3, + const Cell_handle& cell, const Vertex_handle& v) const { CGAL_assertion(cell->has_vertex(v)); @@ -968,10 +970,10 @@ private: FT a_02 = CGAL::abs(details::angle_in_radian(p1p0, p1p2)); FT a_03 = CGAL::abs(details::angle_in_radian(p1p0, p1p3)); - - Vector_3 n0 = normal_estimate(cell,k3); - Vector_3 n1 = normal_estimate(cell,k2); - + + Vector_3 n0 = normal_estimate(c3t3, cell, k3); + Vector_3 n1 = normal_estimate(c3t3, cell, k2); + typename Gt::Compute_squared_distance_3 sq_distance = Gt().compute_squared_distance_3_object(); @@ -1010,7 +1012,8 @@ private: * @brief returns the normal of facet (ch,i), oriented from inside to outside * of \c ch */ - Vector_3 normal_estimate(const Cell_handle& ch, const int i) const + Vector_3 normal_estimate(const C3T3& c3t3, + const Cell_handle& ch, const int i) const { int k1 = (i+1)&3; int k2 = (i+2)&3; @@ -1025,7 +1028,8 @@ private: const Point_3& p3 = ch->vertex(k3)->point(); // compute normal and return it - Construct_point_3 cp; + // (also all the passing of c3t3 by const ref& in the functions) + Construct_point_3 cp = c3t3.triangulation().geom_traits().construct_point_3_object(); return normal(cp(p1),cp(p2),cp(p3)); } };