diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index d2ababd2779..c1e827c33fc 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -1181,10 +1181,12 @@ bool can_be_collapsed(const typename C3T3::Edge& e, } } -template +template void collapse_short_edges(C3T3& c3t3, - const typename C3T3::Triangulation::Geom_traits::FT& low, - const typename C3T3::Triangulation::Geom_traits::FT& high, + const Sizing& sizing, const bool protect_boundaries, CellSelector cell_selector, Visitor& visitor) @@ -1206,13 +1208,17 @@ void collapse_short_edges(C3T3& c3t3, typename Gt::Compute_squared_length_3 sql = tr.geom_traits().compute_squared_length_3_object(); + const FT target_edge_length = sizing(CGAL::ORIGIN, 0, 0); + const FT low = FT(4) / FT(5) * target_edge_length; + const FT high = FT(4) / FT(3) * target_edge_length; + const FT sq_low = low*low; + const FT sq_high = high*high; + #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE std::cout << "Collapse short edges (" << low << ", " << high << ")..."; std::cout.flush(); std::size_t nb_collapses = 0; #endif - const FT sq_low = low*low; - const FT sq_high = high*high; //collect long edges Boost_bimap short_edges; diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h index 5106fb1835b..4467c713c8b 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h @@ -234,9 +234,12 @@ bool can_be_split(const typename C3T3::Edge& e, } } -template +template void split_long_edges(C3T3& c3t3, - const typename C3T3::Triangulation::Geom_traits::FT& high, + const Sizing& sizing, const bool protect_boundaries, CellSelector cell_selector, Visitor& visitor) @@ -254,6 +257,9 @@ void split_long_edges(C3T3& c3t3, boost::bimaps::multiset_of > > Boost_bimap; typedef typename Boost_bimap::value_type long_edge; + const FT target_edge_length = sizing(CGAL::ORIGIN, 0, 0); + const FT high = FT(4) / FT(3) * target_edge_length; + #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE std::cout << "Split long edges (" << high << ")..."; std::cout.flush(); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h index 0dcc8dfde6d..000f007f9fd 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h @@ -174,13 +174,40 @@ public: return m_c3t3_pbackup != NULL; } + bool is_too_long(const Edge& e) const + { + const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); + const FT emax = FT(4)/FT(3) * target_edge_length; + return tr().segment(e).squared_length() > CGAL::square(emax * emax); + } + + bool is_too_short(const Edge& e) const + { + const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); + const FT emin = FT(4)/FT(5) * target_edge_length; + return tr().segment(e).squared_length() < CGAL::square(emin * emin); + } + + bool is_too_long_or_too_short(const Edge& e) const + { + const FT sqlen = tr().segment(e).squared_length(); + + const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); + const FT sq_emax = CGAL::square(FT(4)/FT(3) * target_edge_length); + if(sqlen > sq_emax) + return true; + + const FT sq_emin = CGAL::square(FT(4)/FT(5) * target_edge_length); + if (sqlen < sq_emin) + return true; + + return false; + } + void split() { CGAL_assertion(check_vertex_dimensions()); - - const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); - const FT emax = FT(4)/FT(3) * target_edge_length; - split_long_edges(m_c3t3, emax, m_protect_boundaries, + split_long_edges(m_c3t3, m_sizing, m_protect_boundaries, m_cell_selector, m_visitor); #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG @@ -200,11 +227,7 @@ public: void collapse() { CGAL_assertion(check_vertex_dimensions()); - - const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); - FT emin = FT(4)/FT(5) * target_edge_length; - FT emax = FT(4)/FT(3) * target_edge_length; - collapse_short_edges(m_c3t3, emin, emax, m_protect_boundaries, + collapse_short_edges(m_c3t3, m_sizing, m_protect_boundaries, m_cell_selector, m_visitor); #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG @@ -254,14 +277,6 @@ public: bool resolution_reached() { - const FT target_edge_length = m_sizing(CGAL::ORIGIN, 0, 0); - - FT emax = FT(4) / FT(3) * target_edge_length; - FT emin = FT(4) / FT(5) * target_edge_length; - - FT sqmax = emax * emax; - FT sqmin = emin * emin; - for (const Edge& e : tr().finite_edges()) { // skip protected edges @@ -272,11 +287,13 @@ public: continue; } - FT sqlen = tr().segment(e).squared_length(); - if (sqlen < sqmin || sqlen > sqmax) + if(is_too_long_or_too_short(e)) return false; } + +#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE std::cout << "Resolution reached" << std::endl; +#endif return true; } diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index 8a8ebe925b3..cc321ca2208 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -168,10 +168,12 @@ void tetrahedral_isotropic_remeshing( const NamedParameters& np = parameters::default_values()) { typedef CGAL::Triangulation_3 Triangulation; + typedef typename TDS::Vertex::Index Index; tetrahedral_isotropic_remeshing( tr, - [target_edge_length](const typename Triangulation::Point& /* p */) - {return target_edge_length;}, + [target_edge_length] + (const typename Triangulation::Point& /* p */, const Index&, const int&) + {return target_edge_length; }, np); } @@ -183,10 +185,12 @@ void tetrahedral_isotropic_remeshing( const NamedParameters& np = parameters::default_values()) { typedef CGAL::Triangulation_3 Triangulation; + typedef typename TDS::Vertex::Index Index; tetrahedral_isotropic_remeshing( tr, - [target_edge_length](const typename Triangulation::Point& /* p */) - {return target_edge_length; }, + [target_edge_length] + (const typename Triangulation::Point& /* p */, const Index&, const int&) + {return target_edge_length;}, np); }