diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field.h index 3df70524feca..fc6b14a984f5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Sizing_field.h @@ -10,12 +10,13 @@ // // Author(s) : Jane Tournois -#ifndef CGAL_SIZING_FIELD_H -#define CGAL_SIZING_FIELD_H +#ifndef CGAL_PMP_REMESHING_SIZING_FIELD_H +#define CGAL_PMP_REMESHING_SIZING_FIELD_H #include #include +#include namespace CGAL { @@ -38,13 +39,14 @@ class Sizing_field typedef typename K::FT FT; public: - virtual bool is_too_long(const halfedge_descriptor& h, FT& sql) const = 0; - virtual bool is_too_long(const vertex_descriptor& va, const vertex_descriptor& vb) const = 0; - virtual bool is_too_short(const halfedge_descriptor& h, FT& sqlen) const = 0; + virtual boost::optional is_too_long(const halfedge_descriptor& h) const = 0; + virtual boost::optional is_too_long(const vertex_descriptor& va, + const vertex_descriptor& vb) const = 0; + virtual boost::optional is_too_short(const halfedge_descriptor& h) const = 0; virtual Point_3 split_placement(const halfedge_descriptor& h) const = 0; }; }//end namespace CGAL -#endif //CGAL_SIZING_FIELD_H +#endif //CGAL_PMP_REMESHING_SIZING_FIELD_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Uniform_sizing_field.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Uniform_sizing_field.h index 7b00635ff543..8704c84ef117 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Uniform_sizing_field.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/Uniform_sizing_field.h @@ -10,8 +10,8 @@ // // Author(s) : Jane Tournois -#ifndef CGAL_UNIFORM_SIZING_FIELD_H -#define CGAL_UNIFORM_SIZING_FIELD_H +#ifndef CGAL_PMP_REMESHING_UNIFORM_SIZING_FIELD_H +#define CGAL_PMP_REMESHING_UNIFORM_SIZING_FIELD_H #include @@ -54,23 +54,32 @@ class Uniform_sizing_field : public CGAL::Sizing_field } public: - bool is_too_long(const halfedge_descriptor& h, FT& sqlen) const + boost::optional is_too_long(const halfedge_descriptor& h) const { - sqlen = sqlength(h); - return sqlen > m_sq_long; + const FT sqlen = sqlength(h); + if(sqlen > m_sq_long) + return sqlen; + else + return boost::none; } - bool is_too_long(const vertex_descriptor& va, - const vertex_descriptor& vb) const + boost::optional is_too_long(const vertex_descriptor& va, + const vertex_descriptor& vb) const { - FT sqlen = sqlength(va, vb); - return sqlen > m_sq_long; + const FT sqlen = sqlength(va, vb); + if (sqlen > m_sq_long) + return sqlen; + else + return boost::none; } - bool is_too_short(const halfedge_descriptor& h, FT& sqlen) const + boost::optional is_too_short(const halfedge_descriptor& h) const { - sqlen = sqlength(h); - return sqlen < m_sq_short; + const FT sqlen = sqlength(h); + if (sqlen < m_sq_long) + return sqlen; + else + return boost::none; } virtual Point_3 split_placement(const halfedge_descriptor& h) const @@ -89,4 +98,4 @@ class Uniform_sizing_field : public CGAL::Sizing_field }//end namespace CGAL -#endif //CGAL_UNIFORM_SIZING_FIELD_H +#endif //CGAL_PMP_REMESHING_UNIFORM_SIZING_FIELD_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h index b8c4abd7dc56..29890d0c55b4 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h @@ -488,9 +488,9 @@ namespace internal { { if (!is_split_allowed(e)) continue; - double sqlen; - if(sizing.is_too_long(halfedge(e, mesh_), sqlen)) - long_edges.insert(long_edge(halfedge(e, mesh_), sqlen)); + boost::optional sqlen = sizing.is_too_long(halfedge(e, mesh_)); + if(sqlen != boost::none) + long_edges.insert(long_edge(halfedge(e, mesh_), sqlen.get())); } //split long edges @@ -537,11 +537,13 @@ namespace internal { //check sub-edges //if it was more than twice the "long" threshold, insert them - double sqlen_new; - if(sizing.is_too_long(hnew, sqlen_new)) - long_edges.insert(long_edge(hnew, sqlen_new)); - if(sizing.is_too_long(next(hnew, mesh_), sqlen_new)) - long_edges.insert(long_edge(next(hnew, mesh_), sqlen_new)); + boost::optional sqlen_new = sizing.is_too_long(hnew); + if(sqlen_new != boost::none) + long_edges.insert(long_edge(hnew, sqlen_new.get())); + + sqlen_new = sizing.is_too_long(next(hnew, mesh_)); + if (sqlen_new != boost::none) + long_edges.insert(long_edge(next(hnew, mesh_), sqlen_new.get())); //insert new edges to keep triangular faces, and update long_edges if (!is_on_border(hnew)) @@ -560,9 +562,9 @@ namespace internal { if (snew == PATCH) { - double sql; - if(sizing.is_too_long(hnew2, sql)) - long_edges.insert(long_edge(hnew2, sql)); + boost::optional sql = sizing.is_too_long(hnew2); + if(sql != boost::none) + long_edges.insert(long_edge(hnew2, sql.get())); } } @@ -583,9 +585,9 @@ namespace internal { if (snew == PATCH) { - double sql; - if (sizing.is_too_long(hnew2, sql)) - long_edges.insert(long_edge(hnew2, sql)); + boost::optional sql = sizing.is_too_long(hnew2); + if (sql != boost::none) + long_edges.insert(long_edge(hnew2, sql.get())); } } } @@ -628,10 +630,10 @@ namespace internal { Boost_bimap short_edges; for(edge_descriptor e : edges(mesh_)) { - double sqlen; - if( sizing.is_too_short(halfedge(e, mesh_), sqlen) + boost::optional sqlen = sizing.is_too_short(halfedge(e, mesh_)); + if(sqlen != boost::none && is_collapse_allowed(e, collapse_constraints)) - short_edges.insert(short_edge(halfedge(e, mesh_), sqlen)); + short_edges.insert(short_edge(halfedge(e, mesh_), sqlen.get())); } #ifdef CGAL_PMP_REMESHING_VERBOSE_PROGRESS std::cout << "done." << std::endl; @@ -725,7 +727,8 @@ namespace internal { for(halfedge_descriptor ha : halfedges_around_target(va, mesh_)) { vertex_descriptor va_i = source(ha, mesh_); - if (sizing.is_too_long(vb, va_i)) + boost::optional sqha = sizing.is_too_long(vb, va_i); + if (sqha != boost::none) { collapse_ok = false; break; @@ -789,10 +792,10 @@ namespace internal { //insert new/remaining short edges for (halfedge_descriptor ht : halfedges_around_target(vkept, mesh_)) { - double sqlen; - if (sizing.is_too_short(ht, sqlen) + boost::optional sqlen = sizing.is_too_short(ht); + if (sqlen != boost::none && is_collapse_allowed(edge(ht, mesh_), collapse_constraints)) - short_edges.insert(short_edge(ht, sqlen)); + short_edges.insert(short_edge(ht, sqlen.get())); } } }//end if(collapse_ok) @@ -1703,9 +1706,9 @@ namespace internal { //insert new edges in 'short_edges' if (is_collapse_allowed(edge(hf, mesh_), collapse_constraints)) { - double sqlen; - if (sizing.is_too_short(hf, sqlen)) - short_edges.insert(typename Bimap::value_type(hf, sqlen)); + boost::optional sqlen = sizing.is_too_short(hf); + if (sqlen != boost::none) + short_edges.insert(typename Bimap::value_type(hf, sqlen.get())); } if(!is_border(hf, mesh_) &&