From 0ff1aa98ba39598e9a31807dd816ebe4865fd1d4 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Thu, 26 Nov 2020 18:22:24 +0000 Subject: [PATCH 1/3] Fix passing big parameters by value in SNC_io_parser.h --- Nef_3/include/CGAL/Nef_3/SNC_io_parser.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h index 5eee7528ee7..dbd84e5849c 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h @@ -127,9 +127,9 @@ class moreLeft : public T { typedef typename T::RT RT; public: - moreLeft(T D) : T(D) {} + moreLeft(const T& D) : T(D) {} - int operator()(SHalfedge_handle se1, SHalfedge_handle se2) { + int operator()(SHalfedge_handle se1, SHalfedge_handle se2) const { CGAL_assertion(se1 != SHalfedge_handle()); if(se2 == SHalfedge_handle()) @@ -356,7 +356,7 @@ class sort_sface_cycle_entries : public SNC_decorator { typedef typename T::Vector_3 Vector_3; public: - sort_sface_cycle_entries(T D) : Base(D) {} + sort_sface_cycle_entries(T& D) : Base(D) {} bool operator() (Object_handle o1, Object_handle o2) const { CGAL_NEF_TRACEN("sort sface cycles "); @@ -442,11 +442,11 @@ class sort_sfaces : public SNC_decorator { if(sf1->center_vertex() != sf2->center_vertex()) return SORT(sf1->center_vertex(), sf2->center_vertex()); - // sort_sface_cycle_entries sort_cycles((Base) *this); + // sort_sface_cycle_entries sort_cycles(*this); // return sort_cycles(*sf1->sface_cycles_begin(), *sf2->sface_cycles_begin()); SM_decorator SD(&*sf1->center_vertex()); - moreLeft ml((Base) *this); + moreLeft ml(*this); Vector_3 plus(1,0,0); SFace_cycle_iterator fc; @@ -563,7 +563,7 @@ class sort_facet_cycle_entries : public T { typedef typename T::Vector_3 Vector_3; public: - sort_facet_cycle_entries(T D) : T(D) {} + sort_facet_cycle_entries(const T& D) : T(D) {} bool operator() (Object_handle o1, Object_handle o2) const { @@ -611,7 +611,7 @@ class sort_shell_entries : public T { typedef typename T::Point_3 Point_3; public: - sort_shell_entries(T D) : T(D) {} + sort_shell_entries(const T& D) : T(D) {} bool operator() (Object_handle o1, Object_handle o2) const { SFace_handle sf1, sf2; @@ -1076,7 +1076,7 @@ public: { Self O(os,W, sort); O.print(); } template - void output_sorted_indexes(Iter begin, Iter end, Index i) const { + void output_sorted_indexes(Iter begin, Iter end, const Index& i) const { int low = i[begin]; int high = low; for(Iter it=begin; it != end; it++) { @@ -1193,7 +1193,7 @@ SNC_io_parser::SNC_io_parser(std::ostream& os, SNC_structure& W, } } fi->plane() = normalized(fi->plane()); - fi->boundary_entry_objects().sort(sort_facet_cycle_entries((Base) *this)); + fi->boundary_entry_objects().sort(sort_facet_cycle_entries(*this)); } FL.push_back(fi); } @@ -1262,7 +1262,7 @@ SNC_io_parser::SNC_io_parser(std::ostream& os, SNC_structure& W, *fc = make_object(se); } } - sfi->boundary_entry_objects().sort(sort_sface_cycle_entries((Base) *this)); + sfi->boundary_entry_objects().sort(sort_sface_cycle_entries(*this)); } SFL.push_back(sfi); } @@ -1287,7 +1287,7 @@ SNC_io_parser::SNC_io_parser(std::ostream& os, SNC_structure& W, visit_shell_objects(SFace_handle(it),findMinSF); *it = make_object(findMinSF.minimal_sface()); } - ci->shell_entry_objects().sort(sort_shell_entries((Base)*this)); + ci->shell_entry_objects().sort(sort_shell_entries(*this)); } CL.push_back(ci); } From fe61108b3228e6061d299db6fbdd90592ea760ee Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Thu, 17 Dec 2020 22:43:47 +0000 Subject: [PATCH 2/3] Use SNC_const_decorators to allow const constructor references --- Nef_3/include/CGAL/Nef_3/SNC_io_parser.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h index dbd84e5849c..71c6a679986 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h @@ -181,15 +181,15 @@ class moreLeft : public T { }; template -class sort_vertices : public SNC_decorator { +class sort_vertices : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Point_3 Point_3; public: - sort_vertices(T& D) : Base(D) {} + sort_vertices(const T& D) : Base(D) {} bool operator() (Vertex_handle v1, Vertex_handle v2) const { return lexicographically_xyz_smaller(v1->point(), v2->point()); @@ -197,14 +197,14 @@ class sort_vertices : public SNC_decorator { }; template -class sort_edges : public SNC_decorator { +class sort_edges : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::Halfedge_handle Halfedge_handle; public: - sort_edges(T& D) : Base(D) {} + sort_edges(const T& D) : Base(D) {} bool operator() (Halfedge_handle e1, Halfedge_handle e2) const { sort_vertices SORT(*this->sncp()); @@ -259,17 +259,17 @@ class sort_facets : public SNC_decorator { }; template -class sort_sedges : public SNC_decorator { +class sort_sedges : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef CGAL::SM_decorator SM_decorator; typedef typename T::Vertex_handle Vertex_handle; typedef typename T::SHalfedge_handle SHalfedge_handle; typedef typename T::Sphere_circle Sphere_circle; public: - sort_sedges(T& D) : Base(D) {} + sort_sedges(const T& D) : Base(D) {} bool operator() (SHalfedge_handle se1, SHalfedge_handle se2) const { CGAL_NEF_TRACEN("sort sedges"); @@ -342,10 +342,10 @@ class sort_sloops : public SNC_decorator { }; template -class sort_sface_cycle_entries : public SNC_decorator { +class sort_sface_cycle_entries : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::SM_decorator SM_decorator; typedef typename T::Object_handle Object_handle; typedef typename T::SVertex_handle SVertex_handle; @@ -356,7 +356,7 @@ class sort_sface_cycle_entries : public SNC_decorator { typedef typename T::Vector_3 Vector_3; public: - sort_sface_cycle_entries(T& D) : Base(D) {} + sort_sface_cycle_entries(const T& D) : Base(D) {} bool operator() (Object_handle o1, Object_handle o2) const { CGAL_NEF_TRACEN("sort sface cycles "); From dd636afbc33762d6fd8eef4b45ec4e0a4ccb0f32 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Fri, 18 Dec 2020 08:18:00 +0000 Subject: [PATCH 3/3] Use SNC_const_decorator for additional sorts and finds --- Nef_3/include/CGAL/Nef_3/SNC_io_parser.h | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h index 71c6a679986..9220c696ee2 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_io_parser.h @@ -120,7 +120,6 @@ typename Type_converter::Vector_3 get_vector(const CGAL::Vector_3& v){ ret template class moreLeft : public T { - typedef typename T::SM_decorator SM_decorator; typedef typename T::SHalfedge_handle SHalfedge_handle; typedef typename T::Vector_3 Vector_3; typedef typename T::FT FT; @@ -135,7 +134,6 @@ class moreLeft : public T { if(se2 == SHalfedge_handle()) return -1; - SM_decorator SM(&*se1->source()->source()); Vector_3 vec1 = se1->circle().orthogonal_vector(); Vector_3 vec2 = se2->circle().orthogonal_vector(); @@ -215,17 +213,17 @@ class sort_edges : public SNC_const_decorator { }; template -class sort_facets : public SNC_decorator { +class sort_facets : public SNC_const_decorator { typedef T SNC_structure; - typedef SNC_decorator Base; + typedef SNC_const_decorator Base; typedef typename T::Halffacet_handle Halffacet_handle; typedef typename T::SHalfedge_handle SHalfedge_handle; typedef typename T::Vector_3 Vector_3; typedef typename T::Plane_3 Plane_3; public: - sort_facets(T& D) : Base(D) {} + sort_facets(const T& D) : Base(D) {} bool operator() (Halffacet_handle f1, Halffacet_handle f2) const { @@ -322,14 +320,14 @@ class sort_sedges : public SNC_const_decorator { template -class sort_sloops : public SNC_decorator { +class sort_sloops : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::SHalfloop_handle SHalfloop_handle; public: - sort_sloops(T& D) : Base(D) {} + sort_sloops(const T& D) : Base(D) {} bool operator() (SHalfloop_handle sl1, SHalfloop_handle sl2) const { if(sl1 == sl2) return false; @@ -414,10 +412,10 @@ class sort_sface_cycle_entries : public SNC_const_decorator { }; template -class sort_sfaces : public SNC_decorator { +class sort_sfaces : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::SM_decorator SM_decorator; typedef typename T::Point_3 Point_3; typedef typename T::Vector_3 Vector_3; @@ -430,7 +428,7 @@ class sort_sfaces : public SNC_decorator { SHalfedge_around_sface_circulator; public: - sort_sfaces(T& D) : Base(D) {} + sort_sfaces(const T& D) : Base(D) {} bool operator() (SFace_handle sf1, SFace_handle sf2) const { CGAL_NEF_TRACEN("sort sfaces"); @@ -530,15 +528,15 @@ class sort_sfaces : public SNC_decorator { }; template -class sort_volumes : public SNC_decorator { +class sort_volumes : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::Volume_handle Volume_handle; typedef typename T::SFace_handle SFace_handle; public: - sort_volumes(T& D) : Base(D) {} + sort_volumes(const T& D) : Base(D) {} bool operator() (Volume_handle c1, Volume_handle c2) const { CGAL_NEF_TRACEN("sort volumes"); @@ -627,10 +625,10 @@ class sort_shell_entries : public T { }; template -struct find_minimal_sface_of_shell : public SNC_decorator { +struct find_minimal_sface_of_shell : public SNC_const_decorator { typedef T SNC_structure; - typedef CGAL::SNC_decorator Base; + typedef CGAL::SNC_const_decorator Base; typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Halfedge_handle Halfedge_handle; typedef typename T::Halffacet_handle Halffacet_handle; @@ -643,7 +641,7 @@ struct find_minimal_sface_of_shell : public SNC_decorator { SFace_handle sf_min; sort_sfaces SORT; - find_minimal_sface_of_shell(T& D, SFace_visited_hash& Vi) + find_minimal_sface_of_shell(const T& D, SFace_visited_hash& Vi) : Base(D), Done(Vi), SORT(D) {} void visit(SFace_handle h) {