From 9cef351b45b5f180c5ff63218e3cee2ccd8bb69f Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Mon, 21 Aug 2017 15:34:02 +0800 Subject: [PATCH] partition candidate with constructor --- .../include/CGAL/VSA_approximation.h | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h index 32756e378ec..160a781898c 100644 --- a/Surface_mesh_approximation/include/CGAL/VSA_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/VSA_approximation.h @@ -59,24 +59,30 @@ class VSA_approximation { // The facet candidate to be queued. struct FacetToIntegrate { - face_descriptor f; // facet - std::size_t px; // proxy index - FT err; // fitting error + FacetToIntegrate(const face_descriptor &_f, const std::size_t &_px, const FT &_err) + : f(_f), px(_px), err(_err) {} + bool operator<(const FacetToIntegrate &rhs) const { return err > rhs.err; } + + face_descriptor f; // facet + std::size_t px; // proxy index + FT err; // fitting error }; - // proxy error with proxy index + // Proxy error with its index. struct ProxyError { - ProxyError(const std::size_t &_px, const FT &_error) - : px(_px), error(_error) {} + ProxyError(const std::size_t &_px, const FT &_err) + : px(_px), err(_err) {} + // in ascending order bool operator<(const ProxyError &rhs) const { - return error < rhs.error; + return err < rhs.err; } + std::size_t px; - FT error; + FT err; }; // The average positioned anchor attached to a vertex. @@ -357,11 +363,8 @@ public: BOOST_FOREACH(face_descriptor fadj, faces_around_face(halfedge(f, *m_pmesh), *m_pmesh)) { if (fadj != boost::graph_traits::null_face() && seg_pmap[fadj] == CGAL_NOT_TAGGED_ID) { - FacetToIntegrate cand; - cand.f = fadj; - cand.err = (*fit_error)(fadj, proxies[i]); - cand.px = i; - facet_pqueue.push(cand); + facet_pqueue.push(FacetToIntegrate( + fadj, i, (*fit_error)(fadj, proxies[i]))); } } } @@ -374,11 +377,8 @@ public: BOOST_FOREACH(face_descriptor fadj, faces_around_face(halfedge(c.f, *m_pmesh), *m_pmesh)) { if (fadj != boost::graph_traits::null_face() && seg_pmap[fadj] == CGAL_NOT_TAGGED_ID) { - FacetToIntegrate cand; - cand.f = fadj; - cand.err = (*fit_error)(fadj, proxies[c.px]); - cand.px = c.px; - facet_pqueue.push(cand); + facet_pqueue.push(FacetToIntegrate( + fadj, c.px, (*fit_error)(fadj, proxies[c.px]))); } } } @@ -876,7 +876,7 @@ private: BOOST_FOREACH(const ProxyError &pxe, px_error) { // add error residual from previous proxy // to_add maybe negative but greater than -0.5 - FT to_add = (residual + pxe.error) / avg_error; + FT to_add = (residual + pxe.err) / avg_error; // floor_to_add maybe negative but no less than -1 FT floor_to_add = FT(std::floor(CGAL::to_double(to_add))); const std::size_t q_to_add = static_cast(CGAL::to_double( @@ -886,7 +886,7 @@ private: } for (std::size_t i = 0; i < px_error.size(); ++i) std::cout << "#px " << px_error[i].px - << ", #error " << px_error[i].error + << ", #error " << px_error[i].err << ", #num_to_add " << num_to_add[px_error[i].px] << std::endl; std::size_t num_inserted = 0;