diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h index 2934d17f189a..2bc19cf65c70 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h @@ -7,9 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman -// Efi Fogel +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H #define CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H @@ -82,71 +82,48 @@ namespace CGAL { // of the arrangement // 4. Overlay_2 - overlay of 2 MinimizationDiagram_2 -template , - class Overlay_2 = Envelope_overlay_2 > -class Envelope_divide_and_conquer_3 -{ + typename Overlay_2 = Envelope_overlay_2 > +class Envelope_divide_and_conquer_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Traits::Point_2 Point_2; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; + using Point_2 = typename Traits::Point_2; + using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; - typedef EnvelopeResolver_3 Envelope_resolver; + using Envelope_resolver = EnvelopeResolver_3; - typedef Envelope_divide_and_conquer_3 Self; + using Self = Envelope_divide_and_conquer_3; protected: - - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Face_handle - Face_handle; - typedef typename Minimization_diagram_2::Edge_iterator - Edge_iterator; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Halfedge_around_vertex_circulator - Halfedge_around_vertex_circulator; - typedef typename Minimization_diagram_2::Outer_ccb_iterator - Outer_ccb_iterator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Inner_ccb_iterator; - - typedef typename Minimization_diagram_2::Observer - Md_observer; - typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator - Envelope_data_iterator; + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Face_handle = typename Minimization_diagram_2::Face_handle; + using Ccb_halfedge_circulator = + typename Minimization_diagram_2::Ccb_halfedge_circulator; + using Halfedge_around_vertex_circulator = + typename Minimization_diagram_2::Halfedge_around_vertex_circulator; + + using Md_observer = typename Minimization_diagram_2::Observer; + using Face = typename Minimization_diagram_2::Face; + using Envelope_data_iterator = typename Face::Data_iterator; #ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER - typedef CGAL::Dual - Dual_Minimization_diagram_2; + using Dual_Minimization_diagram_2 = CGAL::Dual; #endif public: // c'tor - Envelope_divide_and_conquer_3(Envelope_type type = ENVELOPE_LOWER) - { + Envelope_divide_and_conquer_3(Envelope_type type = ENVELOPE_LOWER) { // Allocate the traits. m_geom_traits = new Traits; m_own_traits = true; @@ -158,8 +135,7 @@ class Envelope_divide_and_conquer_3 } Envelope_divide_and_conquer_3(const Traits* geom_traits, - Envelope_type type = ENVELOPE_LOWER) - { + Envelope_type type = ENVELOPE_LOWER) { // Set the traits. m_geom_traits = geom_traits; m_own_traits = false; @@ -171,11 +147,9 @@ class Envelope_divide_and_conquer_3 } // virtual destructor. - virtual ~Envelope_divide_and_conquer_3() - { + virtual ~Envelope_divide_and_conquer_3() { // Free the traits object, if necessary. - if (m_own_traits) - delete m_geom_traits; + if (m_own_traits) delete m_geom_traits; // Free the resolver delete resolver; @@ -183,25 +157,20 @@ class Envelope_divide_and_conquer_3 // compute the envelope of surfaces in 3D, using the default arbitrary // divider - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { Envelope_3::Arbitrary_dividor dividor; construct_lu_envelope(begin, end, result, dividor); } // compute the envelope of surfaces in 3D using the given set divider - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - { - return; // result is empty - } + SetDividor& dividor) { + if (begin == end) return; // result is empty // make the general surfaces xy-monotone std::list xy_monotones; @@ -219,25 +188,22 @@ class Envelope_divide_and_conquer_3 // compute the envelope of xy-monotone surfaces in 3D, // using the default arbitrary divider - template + template void construct_envelope_xy_monotone(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { Envelope_3::Arbitrary_dividor dividor; construct_envelope_xy_monotone(begin, end, result, dividor); } // compute the envelope of xy-monotone surfaces in 3D using the given // set divider - template + template void construct_envelope_xy_monotone(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - return; // result is empty + SetDividor& dividor) { + if (begin == end) return; // result is empty // recursively construct the envelope of the xy-monotone parts construct_lu_envelope_xy_monotones(begin, end, result, dividor); @@ -245,36 +211,25 @@ class Envelope_divide_and_conquer_3 } /*! Access the traits object. */ - const Traits* get_traits() const - { - return m_geom_traits; - } + const Traits* get_traits() const { return m_geom_traits; } - void reset() - { - resolver->reset(); - } + void reset() { resolver->reset(); } protected: // compute the envelope of xy-monotone surfaces in 3D - template + template void construct_lu_envelope_xy_monotones(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - { - return; // result is empty - } + SetDividor& dividor) { + if (begin == end) return; // result is empty SurfaceIterator first = begin++; - if (begin == end) - { + if (begin == end) { // only one surface is in the collection. insert it the result - Xy_monotone_surface_3& surf = *first; + const Xy_monotone_surface_3& surf = *first; deal_with_one_surface(surf, result); return; @@ -303,38 +258,34 @@ class Envelope_divide_and_conquer_3 CGAL_assertion(is_envelope_valid(result)); } - void deal_with_one_surface(Xy_monotone_surface_3& surf, - Minimization_diagram_2& result) - { - typedef std::pair Boundary_xcurve; - typedef std::list> Boundary_list; + void deal_with_one_surface(const Xy_monotone_surface_3& surf, + Minimization_diagram_2& result) { + using Boundary_xcurve = std::pair; + using Boundary_list = std::list>; - Boundary_list boundary; + Boundary_list boundary; m_geom_traits-> construct_projected_boundary_2_object()(surf, std::back_inserter(boundary)); - if (boundary.empty()) - { + if (boundary.empty()) { //one infinite surface CGAL_assertion_msg(result.number_of_faces() == 1, "In the beginning there should be only one face"); - result.faces_begin()->set_data(surf); + result.faces_begin()->set_env_data(surf); return; } for (auto boundary_it = boundary.begin(); boundary_it != boundary.end(); - ++boundary_it) - { - if (const Boundary_xcurve* boundary_cv = std::get_if(&(*boundary_it))) - { + ++boundary_it) { + if (const Boundary_xcurve* boundary_cv = + std::get_if(&(*boundary_it))) { Oriented_side side = boundary_cv->second; Halfedge_handle he = insert_non_intersecting_curve(result, boundary_cv->first); - if (side == ON_ORIENTED_BOUNDARY) - { + if (side == ON_ORIENTED_BOUNDARY) { // vertical xy-surface he->face()->set_no_data(); he->twin()->face()->set_no_data(); @@ -342,33 +293,29 @@ class Envelope_divide_and_conquer_3 continue; } - if (he->face() != he->twin()->face()) - { + if (he->face() != he->twin()->face()) { // new face created. // 'he' is directed from left to right, so the face to the left // of 'he' is above 'cv. Face_handle f; - if (side == ON_NEGATIVE_SIDE) // the surface is below cv. - { + if (side == ON_NEGATIVE_SIDE) { // the surface is below cv. f = he->twin()->face(); - f->set_data(surf); + f->set_env_data(surf); he->face()->set_no_data(); } - else - { + else { CGAL_assertion(side == ON_POSITIVE_SIDE); f = he->face(); - f->set_data(surf); + f->set_env_data(surf); he->twin()->face()->set_no_data(); } // init auxiliary data for f and its boundaries. - for(Outer_ccb_iterator ocit = f->outer_ccbs_begin(); - ocit != f->outer_ccbs_end(); ocit++){ + for (auto ocit = f->outer_ccbs_begin(); ocit != f->outer_ccbs_end(); + ocit++) { Ccb_halfedge_circulator face_hec = *ocit; Ccb_halfedge_circulator face_hec_begin = face_hec; - do - { + do { face_hec->set_is_equal_data_in_face(true); face_hec->set_has_equal_data_in_face(true); face_hec->set_has_equal_data_in_target_and_face(true); @@ -381,12 +328,11 @@ class Envelope_divide_and_conquer_3 } while(face_hec != face_hec_begin); } - for(Outer_ccb_iterator icit = f->inner_ccbs_begin(); - icit != f->inner_ccbs_end(); icit++){ + for (auto icit = f->inner_ccbs_begin(); icit != f->inner_ccbs_end(); + icit++) { Ccb_halfedge_circulator face_hec = *icit; Ccb_halfedge_circulator face_hec_begin = face_hec; - do - { + do { face_hec->set_is_equal_data_in_face(true); face_hec->set_has_equal_data_in_face(true); face_hec->set_has_equal_data_in_target_and_face(true); @@ -401,8 +347,7 @@ class Envelope_divide_and_conquer_3 } } } - else - { + else { // the xy-surface is an isolated point const Point_2* p = std::get_if(&(*boundary_it)); CGAL_assertion(p!=nullptr); @@ -412,10 +357,9 @@ class Envelope_divide_and_conquer_3 // update information in all the edges & vertices to indicate that // this surface is the envelope - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { - hi->set_data(surf); + hi->set_env_data(surf); // since all the edges & vertices have their envelope data equal to the // current surface, we can set is/has equal_data_in_target of all // halfedges to true @@ -423,12 +367,9 @@ class Envelope_divide_and_conquer_3 hi->set_has_equal_data_in_target(true); } - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { - vi->set_data(surf); - if (vi->is_isolated()) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { + vi->set_env_data(surf); + if (vi->is_isolated()) { // update the is/has equal_data_in_face flags according to the face data bool equal_data = !vi->face()->has_no_data(); vi->set_is_equal_data_in_face(equal_data); @@ -441,8 +382,7 @@ class Envelope_divide_and_conquer_3 public: void merge_envelopes(Minimization_diagram_2& result1, Minimization_diagram_2& result2, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { // overlay the 2 arrangements Overlay_2 overlay; @@ -465,25 +405,20 @@ class Envelope_divide_and_conquer_3 // compute the surface on the envelope for each edge // edge can be split as surfaces can intersect (or touch) over it std::list edges_to_resolve; - Edge_iterator ei = result.edges_begin(); - for (; ei != result.edges_end(); ++ei) - { + for (auto ei = result.edges_begin(); ei != result.edges_end(); ++ei) { Halfedge_handle hh = ei; // there must be data from at least one map, because all the surfaces // are continuous - if (!get_aux_is_set(hh, 0) || !get_aux_is_set(hh, 1)) - continue; + if (!get_aux_is_set(hh, 0) || !get_aux_is_set(hh, 1)) continue; CGAL_assertion(get_aux_is_set(hh, 0)); CGAL_assertion(get_aux_is_set(hh, 1)); CGAL_assertion(!aux_has_no_data(hh, 1) || !aux_has_no_data(hh, 0)); - if (aux_has_no_data(hh, 0) && !aux_has_no_data(hh, 1)) - { + if (aux_has_no_data(hh, 0) && !aux_has_no_data(hh, 1)) { hh->set_decision(DAC_DECISION_SECOND); hh->twin()->set_decision(DAC_DECISION_SECOND); continue; } - else if (!aux_has_no_data(hh, 0) && aux_has_no_data(hh, 1)) - { + else if (!aux_has_no_data(hh, 0) && aux_has_no_data(hh, 1)) { hh->set_decision(DAC_DECISION_FIRST); hh->twin()->set_decision(DAC_DECISION_FIRST); continue; @@ -506,12 +441,8 @@ class Envelope_divide_and_conquer_3 edges_to_resolve.push_back(hh); } // now deal with the edges - typename std::list::iterator li; - for (li = edges_to_resolve.begin(); li != edges_to_resolve.end(); ++li) - { + for (auto li = edges_to_resolve.begin(); li != edges_to_resolve.end(); ++li) resolver->resolve(*li, result); - - } edges_to_resolve.clear(); // decompose the result, to have faces without holes @@ -547,25 +478,20 @@ class Envelope_divide_and_conquer_3 index_map.detach(); #else // traverse the faces in arbitrary order - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; // if a surface of one map doesn't exist, then we set the second surface - if (aux_has_no_data(fh, 0) && !aux_has_no_data(fh, 1)) - { + if (aux_has_no_data(fh, 0) && !aux_has_no_data(fh, 1)) { fh->set_decision(DAC_DECISION_SECOND); continue; } - else if (aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) - { + else if (aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) { fh->set_decision(EQUAL); fh->set_no_data(); continue; } - else if (!aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) - { + else if (!aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) { fh->set_decision(DAC_DECISION_FIRST); continue; } @@ -592,9 +518,7 @@ class Envelope_divide_and_conquer_3 edge_observer.detach(); // compute the surface on the envelope for each vertex - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; if (vh->is_decision_set()) continue; @@ -603,13 +527,11 @@ class Envelope_divide_and_conquer_3 CGAL_assertion(get_aux_is_set(vh, 0)); CGAL_assertion(get_aux_is_set(vh, 1)); CGAL_assertion(!aux_has_no_data(vh, 1) || !aux_has_no_data(vh, 0)); - if (aux_has_no_data(vh, 0) && !aux_has_no_data(vh, 1)) - { + if (aux_has_no_data(vh, 0) && !aux_has_no_data(vh, 1)) { vh->set_decision(DAC_DECISION_SECOND); continue; } - else if (!aux_has_no_data(vh, 0) && aux_has_no_data(vh, 1)) - { + else if (!aux_has_no_data(vh, 0) && aux_has_no_data(vh, 1)) { vh->set_decision(DAC_DECISION_FIRST); continue; } @@ -659,39 +581,32 @@ class Envelope_divide_and_conquer_3 protected: void deal_with_faces_to_split(std::list& faces_to_split, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { // for each face in faces_to_split, find the intersection over the face, // and split the face - typename std::list::iterator li; - for (li = faces_to_split.begin(); li != faces_to_split.end(); ++li) + for (auto li = faces_to_split.begin(); li != faces_to_split.end(); ++li) resolver->resolve(*li, result); faces_to_split.clear(); } - template - bool is_equal_data(const InputIterator& begin1, - const InputIterator& end1, - const InputIterator& begin2, - const InputIterator& end2) - { + template + bool is_equal_data(const InputIterator& begin1, const InputIterator& end1, + const InputIterator& begin2, const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); - if (first.size() != second.size()) - return false; + if (first.size() != second.size()) return false; return (first == second); } // todo: should remove the uses of this method from this class - template + template bool has_equal_data(const InputIterator& begin1, const InputIterator& end1, const InputIterator& begin2, - const InputIterator& end2) - { + const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); @@ -702,11 +617,11 @@ class Envelope_divide_and_conquer_3 return (intersection.size() > 0); return true; } + // todo: should remove the uses of this method from this class - template + template bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1, - FeatureHandle2 fh2) - { + FeatureHandle2 fh2) { Envelope_data_iterator begin1, end1, begin2, end2; get_aux_data_iterators(id, fh1, begin1, end1); get_aux_data_iterators(id, fh2, begin2, end2); @@ -716,22 +631,17 @@ class Envelope_divide_and_conquer_3 // Remove unnecessary edges, between faces with the same surface // (and which are not degenerate) - void remove_unnecessary_edges(Minimization_diagram_2& result) - { + void remove_unnecessary_edges(Minimization_diagram_2& result) { // collect all those edges in this list, and remove them all at the end // (thus, not destroying the iterator) std::list edges; - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi, ++hi) - { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; - if (can_remove_edge(hh)) - edges.push_back(hh); + if (can_remove_edge(hh)) edges.push_back(hh); } - for (typename std::list::iterator ci = edges.begin(); - ci != edges.end(); ++ci) - { + for (auto ci = edges.begin(); ci != edges.end(); ++ci) { // if the endpoints become isolated after the removal we need to remove // them if they have the same data as the edge Halfedge_handle h = *ci; @@ -796,11 +706,10 @@ class Envelope_divide_and_conquer_3 } } - template + template void get_aux_data_iterators(unsigned int id, FeatureHandle fh, Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + Envelope_data_iterator& end) { Halfedge_handle h; Vertex_handle v; Face_handle f; @@ -815,18 +724,15 @@ class Envelope_divide_and_conquer_3 // this is why we start with a check for a face, then halfedge // and last vertex - if (assign(f, o)) - { + if (assign(f, o)) { begin = f->begin_data(); end = f->end_data(); } - else if (assign(h, o)) - { + else if (assign(h, o)) { begin = h->begin_data(); end = h->end_data(); } - else - { + else { CGAL_assertion_code(bool b = ) assign(v, o); CGAL_assertion(b); @@ -839,8 +745,7 @@ class Envelope_divide_and_conquer_3 // this can be done if the envelope surfaces on the edge are the same as // the envelope surfaces on both sides of the edge // (or if the edge is fake, i.e. created in the vd process) - bool can_remove_edge(Halfedge_handle hh) - { + bool can_remove_edge(Halfedge_handle hh) { Face_handle f1 = hh->face(), f2 = hh->twin()->face(); // we check if the decision done on the edge is equal to the decision @@ -860,20 +765,16 @@ class Envelope_divide_and_conquer_3 bool equal_second = (hh->get_is_equal_aux_data_in_face(1) && hh->twin()->get_is_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } - // check if can remove the edge's target if we remove the edge // this means that the target has the same envelope information as the edge - bool can_remove_edge_target(Halfedge_handle h) - { + bool can_remove_edge_target(Halfedge_handle h) { // \todo Use new design /* The code below uses the is_at_open_boundary. The comment from the calling function says: @@ -886,29 +787,23 @@ class Envelope_divide_and_conquer_3 if ((v->parameter_space_in_x() != ARR_INTERIOR) || (v->parameter_space_in_y() != ARR_INTERIOR)) return false; - */ - Vertex_handle v = h->target(); - if (v->is_at_open_boundary()) - return false; - - - /*if (v->get_is_fake() && !v->is_decision_set()) - return true; + Vertex_handle v = h->target(); + if (v->is_at_open_boundary()) return false; - if (h->get_is_fake() && !h->is_decision_set()) - { - h->set_decision(h->face()->get_decision()); - h->twin()->set_decision(h->get_decision()); - }*/ + /* if (v->get_is_fake() && !v->is_decision_set()) return true; + * if (h->get_is_fake() && !h->is_decision_set()) { + * h->set_decision(h->face()->get_decision()); + * h->twin()->set_decision(h->get_decision()); + * } + */ CGAL_assertion(v->is_decision_set()); CGAL_assertion(h->is_decision_set()); // if the decision done on the vertex and edge are different, // the envelope differs too. - if (h->get_decision() != v->get_decision()) - return false; + if (h->get_decision() != v->get_decision()) return false; // now, check the equality of the surfaces list according to the decision @@ -916,11 +811,9 @@ class Envelope_divide_and_conquer_3 bool equal_first = (h->get_is_equal_aux_data_in_target(0)); bool equal_second = (h->get_is_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -928,14 +821,12 @@ class Envelope_divide_and_conquer_3 // check if we can remove an isolated vertex from the envelope // this can be done if the envelope surfaces on the vertex are the same as // the envelope surfaces on its incident face - bool can_remove_isolated_vertex(Vertex_handle vh) - { + bool can_remove_isolated_vertex(Vertex_handle vh) { Face_handle f = vh->face(); CGAL_assertion(vh->is_decision_set() && f->is_decision_set()); // if the decision done on the vertex and face are different, // the envelope differs too. - if (vh->get_decision() != f->get_decision()) - return false; + if (vh->get_decision() != f->get_decision()) return false; // now, check the equality of the surfaces list according to the decision CGAL::Dac_decision decision = vh->get_decision(); @@ -943,11 +834,9 @@ class Envelope_divide_and_conquer_3 bool equal_first = (vh->get_is_equal_aux_data_in_face(0)); bool equal_second = (vh->get_is_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -957,8 +846,7 @@ class Envelope_divide_and_conquer_3 // the geometric point of view (i.e. if the curves can merge) // this can be done if the envelope surfaces on the vertex are the same as // the envelope surfaces on its 2 incident halfedges - bool combinatorically_can_remove_vertex(Vertex_handle vh) - { + bool combinatorically_can_remove_vertex(Vertex_handle vh) { Halfedge_around_vertex_circulator hec1 = vh->incident_halfedges(); Halfedge_around_vertex_circulator hec2 = hec1++; Halfedge_handle he1 = hec1, he2 = hec2; @@ -986,11 +874,9 @@ class Envelope_divide_and_conquer_3 bool equal_second = (he1->get_is_equal_aux_data_in_target(1) && he2->get_is_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -998,8 +884,7 @@ class Envelope_divide_and_conquer_3 // Remove unnecessary vertices, which have degree 2, and the 2 curves // can be merged // (and which are not degenerate) - void remove_unnecessary_vertices(Minimization_diagram_2& result) - { + void remove_unnecessary_vertices(Minimization_diagram_2& result) { // we have 2 types of unnecessary vertices: those with degree 2 (that // satisfy all the conditions below), and isolated vertices that have the // same envelope information as the face they're contained in. @@ -1017,9 +902,7 @@ class Envelope_divide_and_conquer_3 std::list candidates_to_remove; std::list isolated_to_remove; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; if (!vh->is_decision_set() || vh->degree() == 2) candidates_to_remove.push_back(vh); @@ -1027,22 +910,19 @@ class Envelope_divide_and_conquer_3 isolated_to_remove.push_back(vh); } - typename Traits::Merge_2 curves_merge = m_geom_traits->merge_2_object(); - typename Traits::Are_mergeable_2 curves_can_merge = - m_geom_traits->are_mergeable_2_object(); + auto curves_merge = m_geom_traits->merge_2_object(); + auto curves_can_merge = m_geom_traits->are_mergeable_2_object(); // check the candidates and remove if necessary - typename std::list::iterator ci; - for (ci = candidates_to_remove.begin(); - ci != candidates_to_remove.end(); ++ci) + for (auto ci = candidates_to_remove.begin(); + ci != candidates_to_remove.end(); ++ci) { Vertex_handle vh = *ci; CGAL_assertion(vh->degree() == 2); // we can remove this vertex only if the data on its halfedges is the // same - if (!combinatorically_can_remove_vertex(vh)) - continue; + if (!combinatorically_can_remove_vertex(vh)) continue; // merge the edges, if geometrically possible (if data on vertex is not // set, then it must be geometrically possible) @@ -1053,8 +933,7 @@ class Envelope_divide_and_conquer_3 const X_monotone_curve_2& a = he1->curve(), b = he2->curve(); CGAL_assertion(vh->is_decision_set() || curves_can_merge(a,b)); - if (vh->is_decision_set() && !curves_can_merge(a,b)) - continue; + if (vh->is_decision_set() && !curves_can_merge(a,b)) continue; X_monotone_curve_2 c; curves_merge(a,b,c); @@ -1108,8 +987,8 @@ class Envelope_divide_and_conquer_3 // remove isolated vertices - typename std::list::iterator li; - for (li = isolated_to_remove.begin(); li != isolated_to_remove.end(); ++li) + for (auto li = isolated_to_remove.begin(); li != isolated_to_remove.end(); + ++li) { Vertex_handle vh = *li; CGAL_assertion(vh->is_isolated()); @@ -1119,57 +998,47 @@ class Envelope_divide_and_conquer_3 } } - template - void update_envelope_surfaces_by_decision(FeatureHandle fh) - { + template + void update_envelope_surfaces_by_decision(FeatureHandle fh) { CGAL::Dac_decision decision = fh->get_decision(); Halfedge_handle h; Vertex_handle v; Face_handle f; - if (decision == DAC_DECISION_FIRST || decision == DAC_DECISION_BOTH) - { + if (decision == DAC_DECISION_FIRST || decision == DAC_DECISION_BOTH) { Envelope_data_iterator begin, end; get_aux_data_iterators(0, fh, begin, end); - fh->set_data(begin, end); + fh->set_env_data(begin, end); } - if (decision == DAC_DECISION_SECOND || decision == DAC_DECISION_BOTH) - { + if (decision == DAC_DECISION_SECOND || decision == DAC_DECISION_BOTH) { // copy data from second envelope Envelope_data_iterator begin, end; get_aux_data_iterators(1, fh, begin, end); - if (decision == DAC_DECISION_SECOND) - fh->set_data(begin, end); - else - fh->add_data(begin, end); + if (decision == DAC_DECISION_SECOND) fh->set_env_data(begin, end); + else fh->add_data(begin, end); } } // foreach feature of result, update the envelope surfaces, according // to the decision done over this feature, and its aux sources - void update_envelope_surfaces_by_decision(Minimization_diagram_2& result) - { + void update_envelope_surfaces_by_decision(Minimization_diagram_2& result) { // vertices - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) update_envelope_surfaces_by_decision(vi); // edges - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) update_envelope_surfaces_by_decision(hi); // faces - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) update_envelope_surfaces_by_decision(fi); } // update the is_equal/has_equal flags of the result envelope - void update_edge_face_flags(Halfedge_handle h) - { + void update_edge_face_flags(Halfedge_handle h) { bool is_equal, has_equal; is_equal = (h->get_decision() == h->face()->get_decision()); // has equal can be true even if the decision is not the same, @@ -1184,36 +1053,30 @@ class Envelope_divide_and_conquer_3 bool has_equal_first = (h->get_has_equal_aux_data_in_face(0)); bool is_equal_second = (h->get_is_equal_aux_data_in_face(1)); bool has_equal_second = (h->get_has_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - { + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the halfedge has a different decision, and if so, // we update the flag according to the halfedge decision decision = h->get_decision(); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - else - has_equal &= (has_equal_first & has_equal_second); + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else has_equal &= (has_equal_first & has_equal_second); } h->set_is_equal_data_in_face(is_equal); h->set_has_equal_data_in_face(has_equal); } - void update_edge_target_flags(Halfedge_handle h) - { + + void update_edge_target_flags(Halfedge_handle h) { bool is_equal, has_equal; is_equal = (h->get_decision() == h->target()->get_decision()); @@ -1229,19 +1092,15 @@ class Envelope_divide_and_conquer_3 bool has_equal_first = (h->get_has_equal_aux_data_in_target(0)); bool is_equal_second = (h->get_is_equal_aux_data_in_target(1)); bool has_equal_second = (h->get_has_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - { + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the vertex has a different decision, and if so, // we update the flag according to the vertex decision @@ -1257,8 +1116,8 @@ class Envelope_divide_and_conquer_3 h->set_is_equal_data_in_target(is_equal); h->set_has_equal_data_in_target(has_equal); } - void update_target_face_flags(Halfedge_handle h) - { + + void update_target_face_flags(Halfedge_handle h) { bool has_equal; // has equal can be true even if the decision is not the same, // but has same surfaces, i.e. one of the features got DAC_DECISION_BOTH @@ -1270,28 +1129,20 @@ class Envelope_divide_and_conquer_3 CGAL::Dac_decision decision = h->face()->get_decision(); bool has_equal_first = (h->get_has_equal_aux_data_in_target_and_face(0)); bool has_equal_second = (h->get_has_equal_aux_data_in_target_and_face(1)); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - else - { + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else { // we check if the vertex has a different decision, and if so, // we update the flag according to the vertex decision decision = h->target()->get_decision(); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - - else - has_equal &= (has_equal_first & has_equal_second); + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else has_equal &= (has_equal_first & has_equal_second); } h->set_has_equal_data_in_target_and_face(has_equal); } - void update_vertex_face_flags(Vertex_handle v, Face_handle f) - { + void update_vertex_face_flags(Vertex_handle v, Face_handle f) { bool is_equal, has_equal; is_equal = (v->get_decision() == f->get_decision()); // has equal can be true even if the decision is not the same, @@ -1307,18 +1158,15 @@ class Envelope_divide_and_conquer_3 bool has_equal_first = (v->get_has_equal_aux_data_in_face(0)); bool is_equal_second = (v->get_is_equal_aux_data_in_face(1)); bool has_equal_second = (v->get_has_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - { + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the face has a different decision, and if so, // we update the flag according to the face decision @@ -1334,11 +1182,9 @@ class Envelope_divide_and_conquer_3 v->set_has_equal_data_in_face(has_equal); } - void update_flags(Minimization_diagram_2& result) - { + void update_flags(Minimization_diagram_2& result) { // edges - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { update_edge_face_flags(hi); update_edge_target_flags(hi); @@ -1346,22 +1192,16 @@ class Envelope_divide_and_conquer_3 } // vertices - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - if (vi->is_isolated()) - update_vertex_face_flags(vi, vi->face()); - + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) + if (vi->is_isolated()) update_vertex_face_flags(vi, vi->face()); } - template + template bool get_aux_is_set(FeatureHandle fh, unsigned int id) - { - return fh->get_aux_is_set(id); - } + { return fh->get_aux_is_set(id); } - template - bool aux_has_no_data(FeatureHandle fh, unsigned int id) - { + template + bool aux_has_no_data(FeatureHandle fh, unsigned int id) { const Object& o = fh->get_aux_source(id); Halfedge_handle h; Vertex_handle v; @@ -1372,12 +1212,9 @@ class Envelope_divide_and_conquer_3 // aux source of a vertex can be face, halfedge or vertex // this is why we start with a check for a face, then halfedge // and last vertex - if (assign(f, o)) - return f->has_no_data(); - else if (assign(h, o)) - return h->has_no_data(); - else - { + if (assign(f, o)) return f->has_no_data(); + else if (assign(h, o)) return h->has_no_data(); + else { CGAL_assertion_code(bool b =) assign(v, o); CGAL_assertion(b); @@ -1393,25 +1230,21 @@ class Envelope_divide_and_conquer_3 void get_data_iterators(Object aux_src, Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + Envelope_data_iterator& end) { CGAL_assertion(!aux_src.is_empty()); Vertex_handle v; Halfedge_handle h; Face_handle f; - if (assign(v, aux_src)) - { + if (assign(v, aux_src)) { begin = v->begin_data(); end = v->end_data(); } - else if (assign(h, aux_src)) - { + else if (assign(h, aux_src)) { begin = h->begin_data(); end = h->end_data(); } - else - { + else { CGAL_assertion(assign(f, aux_src)); assign(f, aux_src); begin = f->begin_data(); @@ -1419,20 +1252,15 @@ class Envelope_divide_and_conquer_3 } } bool is_equal_data(Object o, - Envelope_data_iterator begin, - Envelope_data_iterator end) - { + Envelope_data_iterator begin, Envelope_data_iterator end) { CGAL_assertion(!o.is_empty()); Vertex_handle v; Halfedge_handle h; Face_handle f; - if (assign(v, o)) - return v->is_equal_data(begin, end); - else if (assign(h, o)) - return h->is_equal_data(begin, end); - else - { + if (assign(v, o)) return v->is_equal_data(begin, end); + else if (assign(h, o)) return h->is_equal_data(begin, end); + else { CGAL_assertion(assign(f, o)); assign(f, o); return f->is_equal_data(begin, end); @@ -1440,43 +1268,32 @@ class Envelope_divide_and_conquer_3 } bool has_equal_data(Object o, Envelope_data_iterator begin, - Envelope_data_iterator end) - { + Envelope_data_iterator end) { CGAL_assertion(!o.is_empty()); Vertex_handle v; Halfedge_handle h; Face_handle f; - if (assign(v, o)) - return v->has_equal_data(begin, end); - else if (assign(h, o)) - return h->has_equal_data(begin, end); - else - { + if (assign(v, o)) return v->has_equal_data(begin, end); + else if (assign(h, o)) return h->has_equal_data(begin, end); + else { CGAL_assertion(assign(f, o)); assign(f, o); return f->has_equal_data(begin, end); } } - void print_decisions(Minimization_diagram_2& result) - { - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { - if (fi->is_unbounded()) - continue; + void print_decisions(Minimization_diagram_2& result) { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + if (fi->is_unbounded()) continue; Face_handle fh = fi; Ccb_halfedge_circulator face_hec = fh->outer_ccb(); Ccb_halfedge_circulator face_hec_begin = face_hec; - do { - ++face_hec; - } while(face_hec != face_hec_begin); - - Inner_ccb_iterator inner_iter = fh->holes_begin(); - for (; inner_iter != fh->holes_end(); ++inner_iter) + do ++face_hec; + while (face_hec != face_hec_begin); - { + for (auto inner_iter = fh->holes_begin(); inner_iter != fh->holes_end(); + ++inner_iter) { face_hec = face_hec_begin = (*inner_iter); do { ++face_hec; @@ -1488,17 +1305,11 @@ class Envelope_divide_and_conquer_3 // confirm that aux source and decision are set over all minimization // diagram features - bool check_resolve_was_ok(Minimization_diagram_2& result) - { + bool check_resolve_was_ok(Minimization_diagram_2& result) { bool all_ok = true; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; - /* if (vh->get_is_fake()) - * continue; - */ - + // if (vh->get_is_fake()) continue; all_ok &= (vh->get_aux_is_set(0)); CGAL_assertion_msg(all_ok, "aux source (0) not set over vertex"); all_ok &= (vh->get_aux_is_set(1)); @@ -1507,8 +1318,7 @@ class Envelope_divide_and_conquer_3 CGAL_assertion_msg(all_ok, "decision was not set over vertex"); } - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { Halfedge_handle hh = hi; /* if (hh->get_is_fake()) @@ -1522,11 +1332,9 @@ class Envelope_divide_and_conquer_3 all_ok &= (hh->is_decision_set()); CGAL_assertion_msg(all_ok, "decision was not set over edge"); } - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { - Face_handle fh = fi; + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + Face_handle fh = fi; all_ok &= (fh->get_aux_is_set(0)); CGAL_assertion_msg(all_ok, "aux source (0) not set over face"); all_ok &= (fh->get_aux_is_set(1)); @@ -1539,12 +1347,9 @@ class Envelope_divide_and_conquer_3 // confirm that envelope data is set over all minimization diagram features // and that no fake feature are left - bool is_envelope_valid(Minimization_diagram_2& result) - { + bool is_envelope_valid(Minimization_diagram_2& result) { bool all_ok = true; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; all_ok &= (vh->get_is_set()); @@ -1555,26 +1360,23 @@ class Envelope_divide_and_conquer_3 /* all_ok &= (!vh->get_is_fake());*/ CGAL_assertion_msg(all_ok, "fake vertex in envelope"); } - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { Halfedge_handle hh = hi; all_ok &= (hh->get_is_set()); - if (!all_ok) - std::cerr << "edge: " << hh->curve() << std::endl; + if (!all_ok) std::cerr << "edge: " << hh->curve() << std::endl; CGAL_assertion_msg(all_ok, "data not set over edge"); all_ok &= (!hh->has_no_data()); - if (!all_ok) - std::cerr << "edge: " << hh->curve() << std::endl; + if (!all_ok) std::cerr << "edge: " << hh->curve() << std::endl; CGAL_assertion_msg(all_ok, "data empty over edge"); /*all_ok &= (!hh->get_is_fake());*/ CGAL_assertion_msg(all_ok, "fake edge in envelope"); } - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { + + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; all_ok &= (fh->get_is_set()); CGAL_assertion_msg(all_ok, "data not set over face"); @@ -1738,14 +1540,13 @@ class Envelope_divide_and_conquer_3 // A BFS visitor class which collects the faces that need resolving // in a list according to the discover time // In our case graph vertices represent minimization diagram faces - template - class Faces_order_bfs_visitor : public boost::default_bfs_visitor - { + template + class Faces_order_bfs_visitor : public boost::default_bfs_visitor { public: - typedef typename Envelope_divide_and_conquer_3::Self Self; + using Self = typename Envelope_divide_and_conquer_3::Self; protected: const IndexMap* index_map; // Mapping vertices to indices @@ -1753,28 +1554,23 @@ class Envelope_divide_and_conquer_3 Self* base; public: - // Constructor. Faces_order_bfs_visitor(const IndexMap& imap, std::list& f, Self* b) : index_map(&imap), faces(f), base(b) - { - CGAL_assertion(base != nullptr); - } + { CGAL_assertion(base != nullptr); } // Write the discover time for a given vertex. template - void discover_vertex(Vertex fh, const Graph&) - { + void discover_vertex(Vertex fh, const Graph&) { // first we check if we can set the decision immediately // if a surface of one map doesn't exist, then we set the second surface if (base->aux_has_no_data(fh, 0) && !base->aux_has_no_data(fh, 1)) fh->set_decision(DAC_DECISION_SECOND); - else if (base->aux_has_no_data(fh, 0) && base->aux_has_no_data(fh, 1)) - { + else if (base->aux_has_no_data(fh, 0) && base->aux_has_no_data(fh, 1)) { fh->set_decision(EQUAL); fh->set_no_data(); diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h index 5a20790628ef..8d50d5bcd1a0 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h @@ -7,8 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_ELEMENT_VISITOR_3_H #define CGAL_ENVELOPE_ELEMENT_VISITOR_3_H @@ -16,6 +17,11 @@ #include +#include +#include +#include +#include + #include #include #include @@ -26,11 +32,6 @@ #include #include -#include -#include -#include -#include - namespace CGAL { // Return the comparison result of the halfedge's source and target vertices. @@ -41,102 +42,90 @@ namespace CGAL { // this class does the resolving of edge and face in the divide & conquer // algorithm it should handle all faces (it supports holes in the face) -template -class Envelope_element_visitor_3 -{ +template +class Envelope_element_visitor_3 { +public: + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; + +private: + using Md2 = Minimization_diagram_2; + public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Multiplicity Multiplicity; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; - typedef typename Traits::Equal_2 Equal_2; - - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Traits::Point_2 Point_2; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Minimization_diagram_2::Are_all_sides_oblivious_category - Are_all_sides_oblivious_category; + using Multiplicity = typename Traits::Multiplicity; + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; + using Equal_2 = typename Traits::Equal_2; + + using Point_2 = typename Traits::Point_2; + using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; + using Are_all_sides_oblivious_category = + typename Md2::Are_all_sides_oblivious_category; protected: class Copied_face_zone_visitor; - typedef Envelope_element_visitor_3 Self; - typedef typename Minimization_diagram_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Face_const_handle - Face_const_handle; - typedef typename Minimization_diagram_2::Face_handle - Face_handle; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle - Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Inner_ccb_iterator; - typedef typename Minimization_diagram_2::Outer_ccb_iterator - Outer_ccb_iterator; - typedef typename Minimization_diagram_2::Isolated_vertex_iterator - Isolated_vertex_iterator; - typedef typename Minimization_diagram_2::Topology_traits - Topology_traits; - typedef typename Minimization_diagram_2::Dcel Dcel; - typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator - Envelope_data_iterator; - - typedef typename Minimization_diagram_2::Observer Md_observer; - typedef Arr_accessor Md_accessor; - - typedef typename Topology_traits::Default_point_location_strategy - Md_point_location; - typedef typename Topology_traits::Zone_insertion_visitor - Md_insert_zone_visitor; - - typedef std::list Halfedges_list; - typedef typename std::list::iterator Halfedges_list_iterator; - - typedef std::pair Halfedge_w_type; - typedef std::list Halfedges_w_type_list; - - typedef std::list Vertices_list; - typedef typename std::list::iterator Vertices_list_iterator; - - typedef std::list Faces_list; - typedef typename std::list::iterator Faces_list_iterator; - - typedef Unique_hash_map Vertices_hash; - typedef Unique_hash_map Halfedges_hash; - typedef Unique_hash_map - Halfedges_hash_w_type; - typedef Unique_hash_map Faces_hash; - - typedef Unique_hash_map Vertices_map; - typedef Unique_hash_map - Halfedges_map; - typedef Unique_hash_map Faces_map; - - typedef Unique_hash_map - Vertices_to_edges_map; - - typedef std::pair Intersection_curve; - typedef std::list> Intersections_list; + using Self = Envelope_element_visitor_3; + + using Vertex_handle = typename Md2::Vertex_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Face_handle = typename Md2::Face_handle; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Face_const_handle = typename Md2::Face_const_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Face_iterator = typename Md2::Face_iterator; + + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Inner_ccb_iterator = typename Md2::Inner_ccb_iterator; + using Outer_ccb_iterator = typename Md2::Outer_ccb_iterator; + using Isolated_vertex_iterator = typename Md2::Isolated_vertex_iterator; + using Topology_traits = typename Md2::Topology_traits; + using Dcel = typename Md2::Dcel; + using Face = typename Dcel::Face; + using Envelope_data_iterator = typename Face::Data_iterator; + + using Md_observer = typename Md2::Observer; + using Md_accessor = Arr_accessor; + + using Md_point_location = + typename Topology_traits::Default_point_location_strategy; + using Md_insert_zone_visitor = + typename Topology_traits::Zone_insertion_visitor; + + using Halfedges_list = std::list; + using Halfedges_list_iterator = typename std::list::iterator; + + using Halfedge_w_type = std::pair; + using Halfedges_w_type_list = std::list; + + using Vertices_list = std::list; + using Vertices_list_iterator = typename std::list::iterator; + + using Faces_list = std::list; + using Faces_list_iterator = typename std::list::iterator; + + using Vertices_hash = Unique_hash_map; + using Halfedges_hash = Unique_hash_map; + using Halfedges_hash_w_type = Unique_hash_map; + using Faces_hash = Unique_hash_map; + + using Vertices_map = Unique_hash_map; + using Halfedges_map = Unique_hash_map; + using Faces_map = Unique_hash_map; + + using Vertices_to_edges_map = Unique_hash_map; + + using Intersection_curve = std::pair; + using Intersections_list = + std::list>; // this is used in the resolve edge process - typedef Triple Point_2_with_info; - struct Points_compare - { + using Point_2_with_info = Triple; + + struct Points_compare { protected: const Traits* p_traits; @@ -144,22 +133,19 @@ class Envelope_element_visitor_3 // Constructor Points_compare(const Traits& geom_traits) : p_traits(&geom_traits) {} - bool operator()(const Point_2_with_info& p1, - const Point_2_with_info& p2) const - { + bool operator()(const Point_2_with_info& p1, const Point_2_with_info& p2) + const { // The original code seemed to presume that two Points are never equal // This is not true, there are various counter examples. // e.g the intersection of surf1 and surf2 may have ending edge and // a starting edge on the to be resolved edge - return - p_traits->compare_xy_2_object()(p1.first, p2.first) == SMALLER; + return p_traits->compare_xy_2_object()(p1.first, p2.first) == SMALLER; } }; public: // c'tor - Envelope_element_visitor_3(Envelope_type t = ENVELOPE_LOWER) - { + Envelope_element_visitor_3(Envelope_type t = ENVELOPE_LOWER) { // Allocate the traits. m_traits = new Traits; own_traits = true; @@ -167,8 +153,7 @@ class Envelope_element_visitor_3 } Envelope_element_visitor_3(const Traits* tr, - Envelope_type t = ENVELOPE_LOWER) - { + Envelope_type t = ENVELOPE_LOWER) { // Set the traits. m_traits = tr; own_traits = false; @@ -176,17 +161,11 @@ class Envelope_element_visitor_3 } // virtual destructor. - virtual ~Envelope_element_visitor_3() - { - // Free the traits object, if necessary. - if (own_traits) - delete m_traits; - } + virtual ~Envelope_element_visitor_3() { if (own_traits) delete m_traits; } // get a face with 2 surfaces defined over it, and compute the arrangement // of the/ envelope of these surfaces over the face - void resolve(Face_handle face, Minimization_diagram_2& result) - { + void resolve(Face_handle face, Minimization_diagram_2& result) { CGAL_assertion(face->get_aux_is_set(0)); CGAL_assertion(face->get_aux_is_set(1)); @@ -203,8 +182,7 @@ class Envelope_element_visitor_3 get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); - if (inter_objs.size() == 0) - { + if (inter_objs.size() == 0) { // here for resolve we can compare the surfaces over the edges only // (no need for left/right versions) Comparison_result cur_res = resolve_minimal_face(face); @@ -229,7 +207,7 @@ class Envelope_element_visitor_3 Vertices_map map_copied_to_orig_vertices; // here we maintain a mapping between faces in the copied arrangement and // their corresponding face from result - Faces_map map_copied_to_orig_faces; + Faces_map map_copied_to_orig_faces; // now, insert the face's boundary into the temporary minimization diagram // the face is assumed to have outer boundary, and may also have holes, @@ -243,7 +221,6 @@ class Envelope_element_visitor_3 CGAL_assertion(copied_face_arr.is_valid()); map_copied_to_orig_faces[copied_face] = face; - // we use our zone visitor, which only inserts into the arrangement the // points and curves which are inside the copied face // it updates the result arrangement at the same time (action after action @@ -284,10 +261,8 @@ class Envelope_element_visitor_3 Md_point_location pl(copied_face_arr); for (auto inter_objs_it = inter_objs.begin(); - inter_objs_it != inter_objs.end(); ++inter_objs_it) - { - if (const Point_2* point = std::get_if(&(*inter_objs_it))) - { + inter_objs_it != inter_objs.end(); ++inter_objs_it) { + if (const Point_2* point = std::get_if(&(*inter_objs_it))) { // intersection can be a point when the surfaces only touch each other. // we are only interested in the points that are inside the face or // on its boundary. @@ -298,15 +273,14 @@ class Envelope_element_visitor_3 // the above information is available in zone_visitor insert_point(copied_face_arr, *point, pl, zone_visitor); } - else if (const Intersection_curve* curve = std::get_if(&(*inter_objs_it))) - { + else if (const auto* curve = + std::get_if(&(*inter_objs_it))) { zone_visitor.set_current_intersection_type(curve->second); insert(copied_face_arr, curve->first, pl, zone_visitor); CGAL_assertion(copied_face_arr.is_valid()); CGAL_assertion(result.is_valid()); } - else - CGAL_error_msg( "wrong projected intersection type"); + else CGAL_error_msg( "wrong projected intersection type"); } zone_visitor.finish(); @@ -317,8 +291,7 @@ class Envelope_element_visitor_3 // go over the new edges, and set data over their faces typename Halfedges_w_type_list::iterator new_edge_it; for (new_edge_it = result_new_edges.begin(); - new_edge_it != result_new_edges.end(); ++new_edge_it) - { + new_edge_it != result_new_edges.end(); ++new_edge_it) { Halfedge_handle new_he = (*new_edge_it).first; Halfedge_handle new_he_twin = new_he->twin(); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS @@ -339,8 +312,7 @@ class Envelope_element_visitor_3 // to f1, not only the opposite Face_handle f1 = new_he->face(), f2 = new_he_twin->face(); Comparison_result res; - if (!f1->is_decision_set() && !f2->is_decision_set()) - { + if (! f1->is_decision_set() && !f2->is_decision_set()) { res = resolve_minimal_face(f1, &new_he); copy_data_by_comparison_result(face, f1, res); } @@ -349,11 +321,9 @@ class Envelope_element_visitor_3 // if the other face doesn't have its data, we resolve it using // the former result and the intersection type (if exists) - if (!f2->is_decision_set()) - { + if (! f2->is_decision_set()) { #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - if (itype != 0) - { + if (itype != 0) { res = convert_decision_to_comparison_result(f1->get_decision()); res = resolve_by_intersection_type(res, itype); CGAL_expensive_assertion_code @@ -361,26 +331,22 @@ class Envelope_element_visitor_3 resolve_minimal_face(f2, &new_he_twin);); CGAL_expensive_assertion(tmp_res == res); } - else - res = resolve_minimal_face(f2, &new_he_twin); + else res = resolve_minimal_face(f2, &new_he_twin); #else res = resolve_minimal_face(f2, &new_he_twin); #endif copy_data_by_comparison_result(face, f2, res); } - if (!f1->is_decision_set()) - { + if (! f1->is_decision_set()) { #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - if (itype != 0) - { + if (itype != 0) { res = convert_decision_to_comparison_result(f2->get_decision()); res = resolve_by_intersection_type(res, itype); CGAL_expensive_assertion_code (Comparison_result tmp_res = resolve_minimal_face(f1, &new_he)); CGAL_expensive_assertion(tmp_res == res); } - else - res = resolve_minimal_face(f1, &new_he); + else res = resolve_minimal_face(f1, &new_he); #else res = resolve_minimal_face(f1, &new_he); #endif @@ -393,22 +359,19 @@ class Envelope_element_visitor_3 // using compare_left/right versions Halfedges_list_iterator special_edge_it; for (special_edge_it = result_special_edges.begin(); - special_edge_it != result_special_edges.end(); ++special_edge_it) - { + special_edge_it != result_special_edges.end(); ++special_edge_it) { // we assume that the halfedge given points to the correct face // (which is inside the original face) Halfedge_handle special_he = *special_edge_it; Face_handle f = special_he->face(); - if (!f->is_decision_set()) - { + if (! f->is_decision_set()) { Comparison_result res = resolve_minimal_face(f, &special_he); copy_data_by_comparison_result(face, f, res); } // take care for the edge, if necessary - if (!special_he->is_decision_set() && - can_copy_decision_from_face_to_edge(special_he)) - { + if (! special_he->is_decision_set() && + can_copy_decision_from_face_to_edge(special_he)) { // if (!special_he->get_aux_is_set(0) || !special_he->get_aux_is_set(1)) // { // // this can only happen when the edge is fake, since the edge is on @@ -432,21 +395,19 @@ class Envelope_element_visitor_3 } // update data on special vertices - Vertices_list_iterator special_vertex_it; - for (special_vertex_it = result_special_vertices.begin(); - special_vertex_it != result_special_vertices.end(); ++special_vertex_it) - { + for (auto special_vertex_it = result_special_vertices.begin(); + special_vertex_it != result_special_vertices.end(); + ++special_vertex_it) { Vertex_handle special_v = *special_vertex_it; - if (!special_v->is_decision_set()) - { - + if (! special_v->is_decision_set()) { if (special_v->get_aux_is_set(0) && special_v->get_aux_is_set(1)) set_data_by_comparison_result(special_v, EQUAL); else // this is a new vertex inside the face, so we need to update its // aux source information from face also (done in method) copy_all_data_to_vertex(face, special_v); - } else + } + else CGAL_assertion(special_v->get_aux_is_set(0) && \ special_v->get_aux_is_set(1)); } @@ -455,11 +416,9 @@ class Envelope_element_visitor_3 // the face, and should use regular resolve_minimal_face typename std::list::iterator new_face_it; for (new_face_it = result_face_parts.begin(); - new_face_it != result_face_parts.end(); ++new_face_it) - { + new_face_it != result_face_parts.end(); ++new_face_it) { Face_handle new_face = *new_face_it; - if (!new_face->is_decision_set()) - { + if (! new_face->is_decision_set()) { Comparison_result res = resolve_minimal_face(new_face); copy_data_by_comparison_result(face, new_face, res); } @@ -473,8 +432,7 @@ class Envelope_element_visitor_3 // get an edge with 2 surfaces defined over it, and split it to get the shape // of the envelope of these surfaces over the edge - void resolve(Halfedge_handle edge, Minimization_diagram_2& result) - { + void resolve(Halfedge_handle edge, Minimization_diagram_2& result) { const Xy_monotone_surface_3& surf1 = get_aux_surface(edge, 0); const Xy_monotone_surface_3& surf2 = get_aux_surface(edge, 1); @@ -482,8 +440,7 @@ class Envelope_element_visitor_3 std::list> inter_objs; get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); - if (inter_objs.size() == 0) - { + if (inter_objs.size() == 0) { resolve_minimal_edge(edge, edge); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS copy_data_to_edge_endpoints(edge); @@ -496,8 +453,7 @@ class Envelope_element_visitor_3 // we want to work on the halfedge going from left to right // we use HE_COMP_RES so this code can compile both with Arr_2 // and with Aos_2. - if (HE_COMP_RES(edge) != SMALLER) - edge = edge->twin(); + if (HE_COMP_RES(edge) != SMALLER) edge = edge->twin(); Vertex_handle original_src = edge->source(); Vertex_handle original_trg = edge->target(); @@ -511,43 +467,39 @@ class Envelope_element_visitor_3 // we associate with every point 2 flags: // 1. is the point a left endpoint of an overlapping segment // 2. is the point a right endpoint of an overlapping segment - typedef std::vector Points_vec; - Points_vec split_points; + typedef std::vector Points_vec; + Points_vec split_points; bool is_min_end_at_inf = false; bool is_max_end_at_inf = false; for (auto inter_objs_it = inter_objs.begin(); - inter_objs_it != inter_objs.end(); ++inter_objs_it) - { - if (const Point_2* point = std::get_if(&(*inter_objs_it))) - { + inter_objs_it != inter_objs.end(); ++inter_objs_it) { + if (const Point_2* point = std::get_if(&(*inter_objs_it))) { // if the point is on the curve, should add it the split points // list, otherwise, it is irrelevant and should be ignored if (is_point_on_curve(*point, original_cv)) split_points.push_back(Point_2_with_info(*point, false, false)); } - else if (const Intersection_curve* icurve = std::get_if(&(*inter_objs_it))) - { + else if (const auto* icurve = + std::get_if(&(*inter_objs_it))) { const X_monotone_curve_2& x_curve = icurve->first; // find the intersection points and overlapping segments with the // original curve and insert them to the list of split points // intersect the x-monotone curve with the edge's curve typedef std::pair Intersect_point_2; - std::list> intersections_list; + std::list> + intersections_list; m_traits->intersect_2_object()(x_curve, original_cv, std::back_inserter(intersections_list)); - for (auto inter_it = intersections_list.begin(); inter_it != intersections_list.end(); ++inter_it) - { - if (const Intersect_point_2* ip = std::get_if(&(*inter_it))) - { + for (auto inter_it = intersections_list.begin(); + inter_it != intersections_list.end(); ++inter_it) { + if (const auto* ip = std::get_if(&(*inter_it))) split_points.push_back(Point_2_with_info(ip->first, false, false)); - } - else - { - const X_monotone_curve_2* icv = std::get_if(&(*inter_it)); + else { + const auto* icv = std::get_if(&(*inter_it)); CGAL_assertion(icv != nullptr); // we will add the *icv end points to the split_points, unless @@ -570,21 +522,18 @@ class Envelope_element_visitor_3 (*icv, ARR_MAX_END) == ARR_INTERIOR) split_points.push_back (Point_2_with_info(m_traits->construct_max_vertex_2_object() - (*icv), - false, true)); + (*icv), false, true)); else is_max_end_at_inf = true; } } } - else - CGAL_error_msg( "wrong projected intersection type"); + else CGAL_error_msg( "wrong projected intersection type"); } // if there aren't any split points, we can finish - if (split_points.empty()) - { + if (split_points.empty()) { resolve_minimal_edge(edge, edge); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS copy_data_to_edge_endpoints(edge); @@ -605,7 +554,7 @@ class Envelope_element_visitor_3 // by checking the first point in the list bool source_is_special = false; CGAL_assertion(split_points.size() >= 1); - if ((!original_src->is_at_open_boundary() && + if ((! original_src->is_at_open_boundary() && m_traits->equal_2_object()(split_points[0].first, original_src->point())) || (original_src->is_at_open_boundary() && is_min_end_at_inf)) @@ -618,7 +567,7 @@ class Envelope_element_visitor_3 // check if target is a special vertex, by checking the last point in // the list bool target_is_special = false; - if ((!original_trg->is_at_open_boundary() && + if ((! original_trg->is_at_open_boundary() && m_traits->equal_2_object()(split_points[split_points.size()-1].first, original_trg->point())) || (original_trg->is_at_open_boundary() && is_max_end_at_inf)) @@ -636,8 +585,7 @@ class Envelope_element_visitor_3 // cur_part is the part of the original edge that might be split Halfedge_handle cur_part = edge; - for (unsigned int i = 0; i < split_points.size(); ++i) - { + for (unsigned int i = 0; i < split_points.size(); ++i) { Point_2_with_info cur_p = split_points[i]; // if we get to the target vertex, we end the loop, since no more splits @@ -649,11 +597,9 @@ class Envelope_element_visitor_3 Vertex_handle cur_src_vertex = cur_part->source(); // check that the current split point is not already a vertex - if ((!cur_src_vertex->is_at_open_boundary() && - !m_traits->equal_2_object()(cur_p.first, cur_src_vertex->point())) || - cur_src_vertex->is_at_open_boundary()) - - { + if ((! cur_src_vertex->is_at_open_boundary() && + ! m_traits->equal_2_object()(cur_p.first, cur_src_vertex->point())) || + cur_src_vertex->is_at_open_boundary()) { // split the edge in this point X_monotone_curve_2 a,b; @@ -677,24 +623,20 @@ class Envelope_element_visitor_3 // involved we can set both aux data on it. otherwise we should use // the traits compare method. Comparison_result finished_part_res; - if (overlaps > 0) - finished_part_res = EQUAL; - else - finished_part_res = resolve_minimal_edge(edge, finished_part); + if (overlaps > 0) finished_part_res = EQUAL; + else finished_part_res = resolve_minimal_edge(edge, finished_part); finished_part->set_decision(finished_part_res); finished_part->twin()->set_decision(finished_part_res); - if (finished_part == edge) - first_part_res = finished_part_res; + if (finished_part == edge) first_part_res = finished_part_res; } // check the overlaps indications - if (cur_p.second == true) - ++overlaps; // we start a new overlapping segment at this point - if (cur_p.third == true) - --overlaps; // we end an overlapping segment at this point - + // we start a new overlapping segment at this point + if (cur_p.second == true) ++overlaps; + // we end an overlapping segment at this point + if (cur_p.third == true) --overlaps; } // set envelope data on the last part (cur_part) @@ -708,8 +650,7 @@ class Envelope_element_visitor_3 cur_part->set_decision(cur_part_res); cur_part->twin()->set_decision(cur_part_res); - if (cur_part == edge) - first_part_res = cur_part_res; + if (cur_part == edge) first_part_res = cur_part_res; // if the original source and target have same aux data as the edge // we can set envelope data over them also @@ -719,9 +660,8 @@ class Envelope_element_visitor_3 // the incident edge part to source should be edge (the first part) CGAL_assertion(original_src == edge->source()); - if (!original_src->is_decision_set() && - can_copy_decision_from_edge_to_vertex(edge->twin())) - { + if (! original_src->is_decision_set() && + can_copy_decision_from_edge_to_vertex(edge->twin())) { if (source_is_special) set_data_by_comparison_result(original_src, EQUAL); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS @@ -732,23 +672,19 @@ class Envelope_element_visitor_3 } // the incident edge part to target should be cur_part (the last part) CGAL_assertion(original_trg == cur_part->target()); - if (!original_trg->is_decision_set() && - can_copy_decision_from_edge_to_vertex(cur_part)) - { + if (! original_trg->is_decision_set() && + can_copy_decision_from_edge_to_vertex(cur_part)) { if (target_is_special) set_data_by_comparison_result(original_trg, EQUAL); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - else - set_data_by_comparison_result(original_trg, cur_part_res); + else set_data_by_comparison_result(original_trg, cur_part_res); #endif } - } // get a vertex with 2 surfaces defined over it and decide the envelope data // on it between them - void resolve(Vertex_handle vertex) - { + void resolve(Vertex_handle vertex) { // it is enough to compare only one surface from each group (because they // all overlap over the vertex), but set all the group const Xy_monotone_surface_3& surf1 = get_aux_surface(vertex, 0); @@ -768,8 +704,7 @@ class Envelope_element_visitor_3 // visitor. Vertex_handle insert_point(Minimization_diagram_2& arr, const Point_2& p, const Md_point_location& pl, - Copied_face_zone_visitor& visitor) - { + Copied_face_zone_visitor& visitor) { const Face_const_handle* fh; const Halfedge_const_handle* hh; const Vertex_const_handle* vh; @@ -778,17 +713,13 @@ class Envelope_element_visitor_3 auto obj = pl.locate(p); visitor.init(&arr); - if ((fh = std::get_if(&obj)) - != nullptr) - { + if ((fh = std::get_if(&obj)) != nullptr) { vh_for_p = visitor.found_point_in_face(p, arr.non_const_handle(*fh)); } - else if ((hh = std::get_if(&obj))) - { + else if ((hh = std::get_if(&obj))) { vh_for_p = visitor.found_point_on_edge(p , arr.non_const_handle(*hh)); } - else - { + else { // In this case p lies on an existing vertex, so we just update this // vertex. vh = std::get_if(&obj); @@ -797,11 +728,10 @@ class Envelope_element_visitor_3 } // Return a handle for the vertex associated with p. - return (vh_for_p); + return vh_for_p; } - // compute Comparison_result of surfaces over the face, assuming they get // the same answer for all points in face // if we get a halfedge, it is assumed to be on the outer boundary of the @@ -813,8 +743,7 @@ class Envelope_element_visitor_3 // In either case, we try to copy decision from an incident face, is possible // before asking the geometric question Comparison_result resolve_minimal_face(Face_handle face, - Halfedge_handle* he = nullptr) - { + Halfedge_handle* he = nullptr) { CGAL_precondition(he == nullptr || (*he)->face() == face); Comparison_result res = EQUAL; @@ -823,53 +752,43 @@ class Envelope_element_visitor_3 success = can_copy_decision_from_boundary_edge(face, res); #endif - if (success) - return res; + if (success) return res; const Xy_monotone_surface_3& surf1 = get_aux_surface(face, 0); const Xy_monotone_surface_3& surf2 = get_aux_surface(face, 1); Ccb_halfedge_circulator hec; - if (he == nullptr) - { + if (he == nullptr) { // compare the surfaces over arbitrary edge bool found_edge = false; Outer_ccb_iterator outer_ccb = face->outer_ccbs_begin(); - for (; outer_ccb != face->outer_ccbs_end() && !found_edge; ++outer_ccb) - { + for (; outer_ccb != face->outer_ccbs_end() && !found_edge; ++outer_ccb) { hec = *outer_ccb; Ccb_halfedge_circulator curr = hec; - do - { + do { Halfedge_handle he = hec; - if(he->is_fictitious()) - ++hec; - else - { + if(he->is_fictitious()) ++hec; + else { found_edge = true; const X_monotone_curve_2& cv = hec->curve(); res = compare_distance_to_envelope(cv,surf1,surf2); - break; } } while(curr != hec); } - if(!found_edge) - { + if (! found_edge) { // all edges are fictitous, we have two infinite surfaces. // but still, there can be holes. - if(face->inner_ccbs_begin() != face->inner_ccbs_end()) - { + if (face->inner_ccbs_begin() != face->inner_ccbs_end()) { Inner_ccb_iterator hit = face->inner_ccbs_begin(); hec = *hit; CGAL_assertion(!hec->is_fictitious()); const X_monotone_curve_2& cv = hec->curve(); res = compare_distance_to_envelope(cv, surf1, surf2); } - else - { + else { //two infinite surfaces, no outer boundary or holes. res = compare_distance_to_envelope(surf1, surf2, @@ -898,25 +817,20 @@ class Envelope_element_visitor_3 //assertion code end return res; } - else - { + else { // compare the surfaces over the halfedge's curve const X_monotone_curve_2& cv = (*he)->curve(); // a face is always to the left of its halfedge // we use HE_COMP_RES so this code can compile both with Arr_2 // and with Aos_2. - if (HE_COMP_RES(*he) == SMALLER) - { + if (HE_COMP_RES(*he) == SMALLER) { res = m_traits->compare_z_at_xy_above_3_object()(cv,surf1,surf2); - if(type == ENVELOPE_UPPER) - res = CGAL::opposite(res); + if (type == ENVELOPE_UPPER) res = CGAL::opposite(res); } - else - { + else { res = m_traits->compare_z_at_xy_below_3_object()(cv,surf1,surf2); - if(type == ENVELOPE_UPPER) - res = CGAL::opposite(res); + if (type == ENVELOPE_UPPER) res = CGAL::opposite(res); } } @@ -927,24 +841,17 @@ class Envelope_element_visitor_3 // comparison result of the other side of the intersection curve, // if the first side has result "res" Comparison_result resolve_by_intersection_type(Comparison_result res, - Multiplicity itype) - { + Multiplicity itype) { itype %= 2; - if (itype == 1) - { - if (res == LARGER) - return SMALLER; - else if (res == SMALLER) - return LARGER; - else - return res; + if (itype == 1) { + if (res == LARGER) return SMALLER; + else if (res == SMALLER) return LARGER; + else return res; } - else - { + else { CGAL_assertion(itype == 0); return res; } - } // find intersections between 2 xy-monotone surfaces @@ -952,8 +859,7 @@ class Envelope_element_visitor_3 template OutputIterator get_projected_intersections(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - OutputIterator o) - { + OutputIterator o) { return m_traits->construct_projected_intersections_2_object()(s1, s2, o); } @@ -962,8 +868,7 @@ class Envelope_element_visitor_3 Comparison_result compare_distance_to_envelope(Geometry& g, const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) - { + const Xy_monotone_surface_3& s2) { Comparison_result res = m_traits->compare_z_at_xy_3_object()(g, s1, s2); return ((type == ENVELOPE_LOWER) ? res : CGAL::opposite(res)); } @@ -973,8 +878,7 @@ class Envelope_element_visitor_3 Comparison_result compare_distance_to_envelope(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - Arr_not_all_sides_oblivious_tag) - { + Arr_not_all_sides_oblivious_tag) { Comparison_result res = m_traits->compare_z_at_xy_3_object()(s1, s2); return ((type == ENVELOPE_LOWER) ? res : CGAL::opposite(res)); } @@ -982,8 +886,7 @@ class Envelope_element_visitor_3 // compare two infinite surfaces with no boundary or holes Comparison_result compare_distance_to_envelope(const Xy_monotone_surface_3&, const Xy_monotone_surface_3&, - Arr_all_sides_oblivious_tag) - { + Arr_all_sides_oblivious_tag) { CGAL_error(); // doesn't suppose to reach here at all!!! return SMALLER; } @@ -991,8 +894,7 @@ class Envelope_element_visitor_3 // helper method to get the surfaces we need to work on template const Xy_monotone_surface_3& get_aux_surface(FeatureHandle fh, - unsigned int id) - { + unsigned int id) { const Object& o = fh->get_aux_source(id); CGAL_assertion(!o.is_empty()); @@ -1002,30 +904,26 @@ class Envelope_element_visitor_3 // this is why we start with a check for a face, then halfedge // and last vertex Face_handle f; - if (assign(f, o)) - return f->get_data(); + if (assign(f, o)) return f->get_env_data(); Halfedge_handle h; - if (assign(h, o)) - return h->get_data(); + if (assign(h, o)) return h->get_env_data(); Vertex_handle v; CGAL_assertion_code(bool b =) - assign(v, o); + assign(v, o); CGAL_assertion(b); - return v->get_data(); + return v->get_env_data(); } - bool can_copy_decision_from_face_to_edge(Halfedge_handle h) - { + bool can_copy_decision_from_face_to_edge(Halfedge_handle h) { // can copy decision from face to its incident edge if the aux // envelopes are continuous over the face and edge return (h->get_has_equal_aux_data_in_face(0) && h->get_has_equal_aux_data_in_face(1)); } - bool can_copy_decision_from_edge_to_vertex(Halfedge_handle h) - { + bool can_copy_decision_from_edge_to_vertex(Halfedge_handle h) { // can copy decision from face to its incident edge if the aux // envelopes are continuous over the face and edge return (h->get_has_equal_aux_data_in_target(0) && @@ -1038,29 +936,25 @@ class Envelope_element_visitor_3 // these features later // also consider isolated vertices // "res" is the decision made on the face - void copy_data_to_face_boundary(Face_handle face) - { + void copy_data_to_face_boundary(Face_handle face) { Ccb_halfedge_circulator ccb; - Outer_ccb_iterator outer_iter = face->outer_ccbs_begin(); - for (; outer_iter != face->outer_ccbs_end(); ++outer_iter) - { + for (auto outer_iter = face->outer_ccbs_begin(); + outer_iter != face->outer_ccbs_end(); ++outer_iter) { ccb = *outer_iter; copy_data_to_face_boundary(face, ccb); } - Inner_ccb_iterator inner_iter = face->inner_ccbs_begin(); - for (; inner_iter != face->inner_ccbs_end(); ++inner_iter) - { + for (auto inner_iter = face->inner_ccbs_begin(); + inner_iter != face->inner_ccbs_end(); ++inner_iter) { ccb = (*inner_iter); copy_data_to_face_boundary(face, ccb); } - Isolated_vertex_iterator iso_iter = face->isolated_vertices_begin(); - for (; iso_iter != face->isolated_vertices_end(); ++iso_iter) - { + for (auto iso_iter = face->isolated_vertices_begin(); + iso_iter != face->isolated_vertices_end(); ++iso_iter) { Vertex_handle vh = iso_iter; - if (!vh->is_decision_set() && has_equal_aux_data_with_face(vh)) + if (! vh->is_decision_set() && has_equal_aux_data_with_face(vh)) // can copy the data from the face, since we already took care of // the vertices of projected intersections vh->set_decision(face->get_decision()); @@ -1068,13 +962,11 @@ class Envelope_element_visitor_3 } void copy_data_to_face_boundary(Face_handle face, - Ccb_halfedge_circulator hec) - { + Ccb_halfedge_circulator hec) { Ccb_halfedge_circulator hec_begin = hec; do { Halfedge_handle hh = hec; - if(hh->is_fictitious()) - { + if (hh->is_fictitious()) { ++hec; continue; } @@ -1085,8 +977,7 @@ class Envelope_element_visitor_3 hh->set_decision(face->get_decision()); hh->twin()->set_decision(face->get_decision()); }*/ - if (!hh->is_decision_set() && can_copy_decision_from_face_to_edge(hh)) - { + if (! hh->is_decision_set() && can_copy_decision_from_face_to_edge(hh)) { // copy the decision from face to the edge hh->set_decision(face->get_decision()); hh->twin()->set_decision(hh->get_decision()); @@ -1100,22 +991,20 @@ class Envelope_element_visitor_3 // if the first map is continuous, but the second isn't (i.e. when we move // from the face to the edge, the envelope goes closer), then if the // second map wins on the face, it wins on the edge also - else if (!hh->is_decision_set() && + else if (! hh->is_decision_set() && face->get_decision() == DAC_DECISION_SECOND && hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + ! hh->get_has_equal_aux_data_in_face(1)) { hh->set_decision(DAC_DECISION_SECOND); hh->twin()->set_decision(DAC_DECISION_SECOND); } // if the second map is continuous, but the first isn't, then if the // first map wins on the face, it wins on the edge also - else if (!hh->is_decision_set() && + else if (! hh->is_decision_set() && face->get_decision() == DAC_DECISION_FIRST && - !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + ! hh->get_has_equal_aux_data_in_face(0) && + hh->get_has_equal_aux_data_in_face(1)) { hh->set_decision(DAC_DECISION_FIRST); hh->twin()->set_decision(DAC_DECISION_FIRST); } @@ -1136,45 +1025,35 @@ class Envelope_element_visitor_3 // the last bool indicates whether to check if possible to conclude from // face to vertex. it is only possible when hh->face == fh void conclude_decision_to_vertex(Vertex_handle vh, Halfedge_handle hh, - Face_handle fh, bool try_vertex_face) - { - if (vh->is_decision_set()) - return; + Face_handle fh, bool try_vertex_face) { + if (vh->is_decision_set()) return; - - // first, we try to copy decision from edge, then from face - if (hh->is_decision_set() && - can_copy_decision_from_edge_to_vertex(hh)) - { +// first, we try to copy decision from edge, then from face + if (hh->is_decision_set() && can_copy_decision_from_edge_to_vertex(hh)) vh->set_decision(hh->get_decision()); - } + // if the first map is continuous, but the second isn't (i.e. when we move // from the edge to the vertex, the envelope goes closer), then if the // second map wins on the edge, it wins on the vertex also else if (hh->get_decision() == DAC_DECISION_SECOND && hh->get_has_equal_aux_data_in_target(0) && - !hh->get_has_equal_aux_data_in_target(1)) - { + ! hh->get_has_equal_aux_data_in_target(1)) vh->set_decision(DAC_DECISION_SECOND); - } + // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also else if (hh->get_decision() == DAC_DECISION_FIRST && - !hh->get_has_equal_aux_data_in_target(0) && + ! hh->get_has_equal_aux_data_in_target(0) && hh->get_has_equal_aux_data_in_target(1)) - { vh->set_decision(DAC_DECISION_FIRST); - } + // check if we can copy from the face // todo: what if has_equal has 3 possible values? (and projected // ersection vertices have unknown flags) - else if (try_vertex_face) - { + else if (try_vertex_face) { /*CGAL_assertion(has_equal_aux_data_in_target_and_face(hh) == has_equal_aux_data(vh, fh));*/ - if (has_equal_aux_data_in_target_and_face(hh)) - { - + if (has_equal_aux_data_in_target_and_face(hh)) { // can copy the data from the face, since we already took care of // the vertices of projected intersections vh->set_decision(fh->get_decision()); @@ -1184,11 +1063,8 @@ class Envelope_element_visitor_3 // todo: this is for checking template - bool has_equal_data(const InputIterator& begin1, - const InputIterator& end1, - const InputIterator& begin2, - const InputIterator& end2) - { + bool has_equal_data(const InputIterator& begin1, const InputIterator& end1, + const InputIterator& begin2, const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); @@ -1199,12 +1075,12 @@ class Envelope_element_visitor_3 return (intersection.size() > 0); } + // todo: this is for checking template void get_aux_data_iterators(unsigned int id, FeatureHandle fh, Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + Envelope_data_iterator& end) { Halfedge_handle h; Vertex_handle v; Face_handle f; @@ -1212,18 +1088,15 @@ class Envelope_element_visitor_3 const Object& o = fh->get_aux_source(id); CGAL_assertion(!o.is_empty()); - if (assign(v, o)) - { + if (assign(v, o)) { begin = v->begin_data(); end = v->end_data(); } - else if (assign(h, o)) - { + else if (assign(h, o)) { begin = h->begin_data(); end = h->end_data(); } - else - { + else { CGAL_assertion(assign(f, o)); assign(f, o); begin = f->begin_data(); @@ -1234,8 +1107,7 @@ class Envelope_element_visitor_3 // todo: this is for checking template bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1, - FeatureHandle2 fh2) - { + FeatureHandle2 fh2) { Envelope_data_iterator begin1, end1, begin2, end2; get_aux_data_iterators(id, fh1, begin1, end1); get_aux_data_iterators(id, fh2, begin2, end2); @@ -1245,8 +1117,7 @@ class Envelope_element_visitor_3 // todo: this is for checking template - bool has_equal_aux_data(FeatureHandle1 fh1, FeatureHandle2 fh2) - { + bool has_equal_aux_data(FeatureHandle1 fh1, FeatureHandle2 fh2) { return (has_equal_aux_data(0, fh1, fh2) && has_equal_aux_data(1, fh1, fh2)); } @@ -1255,31 +1126,25 @@ class Envelope_element_visitor_3 // check if we can copy the decision made on a boundary edge to the face // if so, res will contain this decision's comparison result bool can_copy_decision_from_boundary_edge(Face_handle face, - Comparison_result& res) - { + Comparison_result& res) { bool result = false; // check outer boundary Ccb_halfedge_circulator hec, hec_begin; // check outer boundary Outer_ccb_iterator outer_ccb = face->outer_ccbs_begin(); - for (; outer_ccb != face->outer_ccbs_end(); ++outer_ccb) - { + for (; outer_ccb != face->outer_ccbs_end(); ++outer_ccb) { hec = *outer_ccb; hec_begin = hec; - do - { + do { Halfedge_handle hh = hec; - if(hh->is_fictitious()) - { + if(hh->is_fictitious()) { ++hec; continue; } if (can_copy_decision_from_face_to_edge(hh) && - hh->is_decision_set() && - hh->get_decision() != DAC_DECISION_BOTH) - { + hh->get_decision() != DAC_DECISION_BOTH) { res = convert_decision_to_comparison_result(hh->get_decision()); result = true; } @@ -1289,8 +1154,7 @@ class Envelope_element_visitor_3 else if (hh->is_decision_set() && hh->get_decision() == DAC_DECISION_FIRST && hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + ! hh->get_has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_FIRST); result = true; } @@ -1299,21 +1163,18 @@ class Envelope_element_visitor_3 else if (hh->is_decision_set() && hh->get_decision() == DAC_DECISION_SECOND && !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + hh->get_has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_SECOND); result = true; } hec++; } while(hec != hec_begin && !result); - if (result) - return true; + if (result) return true; } // check inner boundaries - Inner_ccb_iterator hole_iter = face->inner_ccbs_begin(); - for (; hole_iter != face->inner_ccbs_end(); ++hole_iter) - { + for (auto hole_iter = face->inner_ccbs_begin(); + hole_iter != face->inner_ccbs_end(); ++hole_iter) { hec = (*hole_iter); hec_begin = hec; @@ -1321,8 +1182,7 @@ class Envelope_element_visitor_3 Halfedge_handle hh = hec; if (can_copy_decision_from_face_to_edge(hh) && hh->is_decision_set() && - hh->get_decision() != DAC_DECISION_BOTH) - { + hh->get_decision() != DAC_DECISION_BOTH) { res = convert_decision_to_comparison_result(hh->get_decision()); result = true; } @@ -1332,8 +1192,7 @@ class Envelope_element_visitor_3 else if (hh->is_decision_set() && hh->get_decision() == DAC_DECISION_FIRST && hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + ! hh->get_has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_FIRST); result = true; @@ -1342,9 +1201,8 @@ class Envelope_element_visitor_3 // second map wins on the edge, it wins on the face also else if (hh->is_decision_set() && hh->get_decision() == DAC_DECISION_SECOND && - !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + ! hh->get_has_equal_aux_data_in_face(0) && + hh->get_has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_SECOND); result = true; } @@ -1368,15 +1226,13 @@ class Envelope_element_visitor_3 return EQUAL;*/ } - bool has_equal_aux_data_with_face(Vertex_handle v) - { + bool has_equal_aux_data_with_face(Vertex_handle v) { CGAL_assertion(v->is_isolated()); return (v->get_has_equal_aux_data_in_face(0) && v->get_has_equal_aux_data_in_face(1)); } - bool has_equal_aux_data_in_target_and_face(Halfedge_handle h) - { + bool has_equal_aux_data_in_target_and_face(Halfedge_handle h) { return (h->get_has_equal_aux_data_in_target_and_face(0) && h->get_has_equal_aux_data_in_target_and_face(1)); } @@ -1384,10 +1240,9 @@ class Envelope_element_visitor_3 // check the aux data on the endpoint vertices of the edge // and if it equals the aux data on the edge, copy it, to save calculations // for these features later - void copy_data_to_edge_endpoints(Halfedge_handle edge) - { + void copy_data_to_edge_endpoints(Halfedge_handle edge) { // take care for source - if (!edge->source()->is_decision_set() && + if (! edge->source()->is_decision_set() && can_copy_decision_from_edge_to_vertex(edge->twin())) // can copy the data from the edge, since we already took care of // the vertices of projected intersections @@ -1397,16 +1252,14 @@ class Envelope_element_visitor_3 // second map wins on the edge, it wins on the vertex also else if (edge->get_decision() == DAC_DECISION_SECOND && edge->twin()->get_has_equal_aux_data_in_target(0) && - !edge->twin()->get_has_equal_aux_data_in_target(1)) - { + !edge->twin()->get_has_equal_aux_data_in_target(1)) { edge->source()->set_decision(DAC_DECISION_SECOND); } // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also else if (edge->get_decision() == DAC_DECISION_FIRST && !edge->twin()->get_has_equal_aux_data_in_target(0) && - edge->twin()->get_has_equal_aux_data_in_target(1)) - { + edge->twin()->get_has_equal_aux_data_in_target(1)) { edge->source()->set_decision(DAC_DECISION_FIRST); } @@ -1421,16 +1274,14 @@ class Envelope_element_visitor_3 // second map wins on the edge, it wins on the vertex also else if (edge->get_decision() == DAC_DECISION_SECOND && edge->get_has_equal_aux_data_in_target(0) && - !edge->get_has_equal_aux_data_in_target(1)) - { + !edge->get_has_equal_aux_data_in_target(1)) { edge->target()->set_decision(DAC_DECISION_SECOND); } // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also else if (edge->get_decision() == DAC_DECISION_FIRST && !edge->get_has_equal_aux_data_in_target(0) && - edge->get_has_equal_aux_data_in_target(1)) - { + edge->get_has_equal_aux_data_in_target(1)) { edge->target()->set_decision(DAC_DECISION_FIRST); } } @@ -1439,10 +1290,9 @@ class Envelope_element_visitor_3 // bounded traits. template Vertex_handle create_copied_vertex(Halfedge_handle hh, - Md_accessor &to_accessor, + Md_accessor& to_accessor, bool source, - Arr_all_sides_oblivious_tag) - { + Arr_all_sides_oblivious_tag) { // create the 2 vertices and connect them with the edge // copied_prev_he should be directed from copied_source to copied_target Point_2* p_p = @@ -1458,12 +1308,9 @@ class Envelope_element_visitor_3 Vertex_handle create_copied_vertex(Halfedge_handle hh, Md_accessor& to_accessor, bool source, - Arr_not_all_sides_oblivious_tag) - { - typename Traits::Parameter_space_in_x_2 ps_x_op = - this->m_traits->parameter_space_in_x_2_object (); - typename Traits::Parameter_space_in_y_2 ps_y_op = - this->m_traits->parameter_space_in_y_2_object (); + Arr_not_all_sides_oblivious_tag) { + auto ps_x_op = this->m_traits->parameter_space_in_x_2_object (); + auto ps_y_op = this->m_traits->parameter_space_in_y_2_object (); bool is_directed_right = hh->direction() == ARR_LEFT_TO_RIGHT; @@ -1477,8 +1324,7 @@ class Envelope_element_visitor_3 if (ps_x != ARR_INTERIOR || ps_y != ARR_INTERIOR) return to_accessor.create_boundary_vertex(hh->curve(), ind, ps_x, ps_y, true); - else - { + else { // create the 2 vertices and connect them with the edge // copied_prev_he should be directed from copied_source to copied_target Point_2* p_p = @@ -1500,7 +1346,6 @@ class Envelope_element_visitor_3 Halfedges_map& map_orig_to_copied_halfedges, Vertices_map& map_orig_to_copied_vertices, bool is_outer_ccb) // do we copy an outer (or inner) ccb - { Md_accessor to_accessor(to); // count the number of faces that are closed by this ccb @@ -1511,22 +1356,18 @@ class Envelope_element_visitor_3 Ccb_halfedge_circulator hec_begin = hec; bool first_he = true; Halfedge_handle copied_prev_he; - do - { + do { Halfedge_handle hh = hec; if (hh->twin()->face() == hh->face() && - map_orig_to_copied_halfedges.is_defined(hh)) - { + map_orig_to_copied_halfedges.is_defined(hh)) { // this can happen in the case of antennas, when we get to the same // antena halfedge from the other side copied_prev_he = map_orig_to_copied_halfedges[hh]; } - else - { + else { const X_monotone_curve_2& current_cv = hh->curve(); - if (first_he) - { + if (first_he) { first_he = false; // create the 2 vertices and connect them with the edge @@ -1556,8 +1397,7 @@ class Envelope_element_visitor_3 map_copied_to_orig_vertices[copied_prev_he->target()] = hh->target(); map_orig_to_copied_vertices[hh->target()] = copied_prev_he->target(); } - else - { + else { CGAL_assertion(map_copied_to_orig_halfedges[copied_prev_he]->target() == hh->source()); @@ -1566,15 +1406,13 @@ class Envelope_element_visitor_3 // in which case we should use insert at vertices bool use_2_vertices = false; Vertex_handle copied_v2; - if (map_orig_to_copied_vertices.is_defined(hh->target())) - { + if (map_orig_to_copied_vertices.is_defined(hh->target())) { use_2_vertices = true; copied_v2 = map_orig_to_copied_vertices[hh->target()]; } Halfedge_handle copied_new_he; - if (!use_2_vertices) - { + if (! use_2_vertices) { // create vertex for the new target, and insert the new edge Vertex_handle copied_target = create_copied_vertex(hh, to_accessor, false, @@ -1595,8 +1433,7 @@ class Envelope_element_visitor_3 map_copied_to_orig_vertices[copied_new_he->target()] = hh->target(); map_orig_to_copied_vertices[hh->target()] = copied_new_he->target(); } - else - { + else { ++n_faces_closed; // in order to insert the new edge we should determine the prev @@ -1624,8 +1461,7 @@ class Envelope_element_visitor_3 // degeneracies (around the current vertices, at least) // so we can use the accessor method if (n_faces_closed == 1 && - map_orig_to_copied_halfedges.is_defined(hh->next())) - { + map_orig_to_copied_halfedges.is_defined(hh->next())) { bool dummy_swapped_predecessors = false; copied_new_he = to_accessor.insert_at_vertices_ex (copied_prev_he, @@ -1638,8 +1474,7 @@ class Envelope_element_visitor_3 CGAL_assertion(new_face); } - else - { + else { // TODO:can we use accessor method? copied_new_he = to.insert_at_vertices(current_cv, copied_prev_he, @@ -1650,8 +1485,8 @@ class Envelope_element_visitor_3 // (we should be careful in cases where more than one face is // created by the outer ccb } - else // copy inner boundary - { + else { + // copy inner boundary // should always flip the side of the edge, because the face // that we close is never the copied face, even in strane // situations like this: (two faces touch in a vertex) @@ -1698,16 +1533,13 @@ class Envelope_element_visitor_3 Halfedges_map& map_copied_to_orig_halfedges, Vertices_map& map_copied_to_orig_vertices, Halfedges_map& map_orig_to_copied_halfedges, - Vertices_map& map_orig_to_copied_vertices) - { + Vertices_map& map_orig_to_copied_vertices) { // Find a non-fictitous edge (if there is such one) on the CCB. - Ccb_halfedge_circulator hec_end = hec; - Halfedge_handle non_fict; + Ccb_halfedge_circulator hec_end = hec; + Halfedge_handle non_fict; - do - { - if(!hec->is_fictitious()) - { + do { + if (! hec->is_fictitious()) { non_fict = hec; break; } @@ -1716,13 +1548,12 @@ class Envelope_element_visitor_3 // Find an anchor halfedge he_from along the original CCB and locate // its image he_to in the target CCB. - Md_accessor from_accessor (from); - Md_accessor to_accessor (to); - Halfedge_handle he_from; - Halfedge_handle he_to; + Md_accessor from_accessor (from); + Md_accessor to_accessor (to); + Halfedge_handle he_from; + Halfedge_handle he_to; - if (non_fict == Halfedge_handle()) - { + if (non_fict == Halfedge_handle()) { // In case all edges along the CCB are fictitious, this outer CCB // belongs to the single unbounded face in the arrangement (as it // contains no unbounded curves at current). In this case, we go @@ -1732,21 +1563,19 @@ class Envelope_element_visitor_3 CGAL_assertion_msg ((to.number_of_faces() != 0), "if all halfedges are fictitious then there should be only one face"); - Face_handle to_uf = to.faces_begin(); - Ccb_halfedge_circulator to_uf_hec = to_uf->outer_ccb(); + Face_handle to_uf = to.faces_begin(); + Ccb_halfedge_circulator to_uf_hec = to_uf->outer_ccb(); he_from = hec; he_to = to_uf_hec; while (he_to->direction() != he_from->direction() || - he_to->next()->direction() != he_from->next()->direction()) - { + he_to->next()->direction() != he_from->next()->direction()) { he_to = he_to->next(); CGAL_assertion (he_to != to_uf_hec); } } - else - { + else { // Use the non-fictitious halfedge as an "anchor": Insert its associated // curve into the target arrangement, and keep track of the halfedge we // obtained. @@ -1758,11 +1587,10 @@ class Envelope_element_visitor_3 // Go over all other halfedges along the copied CCB, and store all // curves associated with non-fictitious halfedges. - Halfedge_handle he; - std::list xcvs; + Halfedge_handle he; + std::list xcvs; - for (he = he_from->next(); he != he_from; he = he->next()) - { + for (he = he_from->next(); he != he_from; he = he->next()) { if (! he->is_fictitious()) xcvs.push_back (he->curve()); } @@ -1776,10 +1604,9 @@ class Envelope_element_visitor_3 // Map the halfedges and vertices along the two CCBs. // Note that we make sure that the two CCBs are of the same size. const Halfedge_handle he_from_end = he_from; - CGAL_assertion_code(const Halfedge_handle he_to_end = he_to;); + CGAL_assertion_code(const Halfedge_handle he_to_end = he_to;); - do - { + do { map_copied_to_orig_vertices[he_to->source()] = he_from->source(); map_orig_to_copied_vertices[he_from->source()] = he_to->source(); @@ -1802,8 +1629,7 @@ class Envelope_element_visitor_3 Face_handle copy_face(Face_handle face, Minimization_diagram_2& from, Minimization_diagram_2& to, Halfedges_map& map_copied_to_orig_halfedges, - Vertices_map& map_copied_to_orig_vertices) - { + Vertices_map& map_copied_to_orig_vertices) { CGAL_precondition(from.is_valid()); CGAL_precondition(to.is_empty()); CGAL_assertion_msg(to.number_of_faces() == 1, @@ -1813,27 +1639,24 @@ class Envelope_element_visitor_3 // ones in the copied arrangement. Also keep track of the unbounded face // of the copied arrangement: Note that if the face we copy is bounded, // then it forms a hole in the unbounded face. - Vertices_map map_orig_to_copied_vertices; + Vertices_map map_orig_to_copied_vertices; Halfedges_map map_orig_to_copied_halfedges; - Face_handle to_uf = to.faces_begin(); + Face_handle to_uf = to.faces_begin(); // Copy outer CCB of the face, if it has one. - Face_handle copied_face; + Face_handle copied_face; - if (face->number_of_outer_ccbs() > 0) - { + if (face->number_of_outer_ccbs() > 0) { Ccb_halfedge_circulator hec = face->outer_ccb(); - if (face->is_unbounded()) - { + if (face->is_unbounded()) { copy_ccb_unbounded(hec, from, to, map_copied_to_orig_halfedges, map_copied_to_orig_vertices, map_orig_to_copied_halfedges, map_orig_to_copied_vertices); } - else - { + else { copy_ccb(hec, from, to_uf, to, map_copied_to_orig_halfedges, map_copied_to_orig_vertices, @@ -1850,17 +1673,15 @@ class Envelope_element_visitor_3 copied_face = hec_to->face(); } - else - { + else { // In case the copied face has no outer CCB, then it must be the // single unbounded face of the arrangement. copied_face = to_uf; } // Copy the inner CCB (the holes inside the face). - Inner_ccb_iterator iccb_it = face->inner_ccbs_begin(); - for (; iccb_it != face->inner_ccbs_end(); ++iccb_it) - { + for (auto iccb_it = face->inner_ccbs_begin(); + iccb_it != face->inner_ccbs_end(); ++iccb_it) { Ccb_halfedge_circulator he = *iccb_it; copy_ccb(he, from, copied_face, to, @@ -1873,11 +1694,10 @@ class Envelope_element_visitor_3 } // Copy the isolated vertices inside the given face. - Isolated_vertex_iterator iv_it = face->isolated_vertices_begin(); - for (; iv_it != face->isolated_vertices_end(); ++iv_it) - { - Vertex_handle iso_v = iv_it; - Vertex_handle copied_iso = + for (auto iv_it = face->isolated_vertices_begin(); + iv_it != face->isolated_vertices_end(); ++iv_it) { + Vertex_handle iso_v = iv_it; + Vertex_handle copied_iso = to.insert_in_face_interior (iso_v->point(), copied_face); map_copied_to_orig_vertices[copied_iso] = iso_v; @@ -1891,8 +1711,7 @@ class Envelope_element_visitor_3 // set envelope data in face "to" according to the comparison result of the // aux data of face "from" void copy_data_by_comparison_result(Face_handle from, Face_handle to, - Comparison_result res) - { + Comparison_result res) { CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set"); CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set"); to->set_aux_source(0, from->get_aux_source(0)); @@ -1902,8 +1721,7 @@ class Envelope_element_visitor_3 // set envelope data in vertex "v" according to the comparison result of the // aux data of "v" - void set_data_by_comparison_result(Vertex_handle v, Comparison_result res) - { + void set_data_by_comparison_result(Vertex_handle v, Comparison_result res) { CGAL_assertion_msg(v->get_aux_is_set(0), "aux_data(0) is not set"); CGAL_assertion_msg(v->get_aux_is_set(1), "aux_data(1) is not set"); v->set_decision(res); @@ -1911,8 +1729,7 @@ class Envelope_element_visitor_3 // set envelope data in halfedge "h" according to the comparison result of // the aux data of "h" - void set_data_by_comparison_result(Halfedge_handle h, Comparison_result res) - { + void set_data_by_comparison_result(Halfedge_handle h, Comparison_result res) { CGAL_assertion_msg(h->get_aux_is_set(0), "aux_data(0) is not set"); CGAL_assertion_msg(h->get_aux_is_set(1), "aux_data(1) is not set"); h->set_decision(res); @@ -1923,8 +1740,7 @@ class Envelope_element_visitor_3 // FeatureHabdle should be a Face_handle, Halfedge_handle or // Vertex_handle template - void copy_all_data_to_vertex(FeatureHabdle from, Vertex_handle to) - { + void copy_all_data_to_vertex(FeatureHabdle from, Vertex_handle to) { CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set"); CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set"); CGAL_assertion_msg(!to->is_decision_set(), "data is set in new vertex"); @@ -1946,8 +1762,7 @@ class Envelope_element_visitor_3 // } Comparison_result resolve_minimal_edge(Halfedge_handle orig_he, - Halfedge_handle new_he) - { + Halfedge_handle new_he) { // find and set the envelope data on the new edge const Xy_monotone_surface_3& surf1 = get_aux_surface(orig_he, 0); const Xy_monotone_surface_3& surf2 = get_aux_surface(orig_he, 1); @@ -1966,8 +1781,7 @@ class Envelope_element_visitor_3 // check if the point is on the curve. // we use the traits adaptor since cv can be an infinite curve - bool is_point_on_curve(const Point_2& p, const X_monotone_curve_2& cv) - { + bool is_point_on_curve(const Point_2& p, const X_monotone_curve_2& cv) { Arr_traits_adaptor_2 tr_adaptor(*m_traits); return (tr_adaptor.is_in_x_range_2_object()(cv, p) && m_traits->compare_y_at_x_2_object()(p, cv) == EQUAL); @@ -2179,8 +1993,7 @@ class Envelope_element_visitor_3 ps_x, ps_y, true); // add indication of a new vertex (that is not connected to anything, // and is also not isolated) - if (is_bounded()) - new_vertices.push_back(v); + if (is_bounded()) new_vertices.push_back(v); map_vertices[v] = new_v; } @@ -2294,7 +2107,7 @@ class Envelope_element_visitor_3 map_halfedges[he] = new_he; map_halfedges[he->twin()] = new_he->twin(); } - else if (! v1_is_new && !v2_is_new) { + else if (! v1_is_new && ! v2_is_new) { // if both vertices are old - use _insert_at_vertices // this is a linear action by the size of the faces involved // we can get relevant prev halfedges from he @@ -2352,7 +2165,7 @@ class Envelope_element_visitor_3 CGAL_assertion(map_halfedges.is_defined(prev)); Halfedge_handle big_prev = map_halfedges[prev]; Halfedge_handle new_he; - if (!v1_is_new) { + if (! v1_is_new) { new_he = big_arr_accessor.insert_from_vertex_ex(big_prev, he->curve(), (HE_COMP_RES(he) == SMALLER ? ARR_LEFT_TO_RIGHT : ARR_RIGHT_TO_LEFT), big_v2); @@ -2420,11 +2233,9 @@ class Envelope_element_visitor_3 Vertex_handle /* v */) override { saved_face = f; } - virtual void after_add_isolated_vertex(Vertex_handle v) override - { + virtual void after_add_isolated_vertex(Vertex_handle v) override { // make sure it is the only new vertex right now - CGAL_assertion(new_vertices.size() == 1 && - new_vertices.back() == v); + CGAL_assertion(new_vertices.size() == 1 && new_vertices.back() == v); new_vertices.pop_back(); @@ -2434,8 +2245,7 @@ class Envelope_element_visitor_3 // find features in big_arr Vertex_handle big_v = map_vertices[v]; - Face_handle big_face = map_faces[saved_face]; - + Face_handle big_face = map_faces[saved_face]; // can use O(1) operation _insert_isolated_vertex big_arr_accessor.insert_isolated_vertex(big_face, big_v); @@ -2520,15 +2330,15 @@ class Envelope_element_visitor_3 // face class Copied_face_zone_visitor { public: - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Face_handle Face_handle; + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Face_handle = typename Minimization_diagram_2::Face_handle; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; + using Point_2 = typename Minimization_diagram_2::Point_2; + using X_monotone_curve_2 = + typename Minimization_diagram_2::X_monotone_curve_2; - typedef std::pair Result; + using Result = std::pair; Copied_face_zone_visitor(Minimization_diagram_2& result, Minimization_diagram_2& copied, @@ -2541,27 +2351,26 @@ class Envelope_element_visitor_3 Halfedges_w_type_list& new_edges, Faces_list& face_parts, Vertices_list& sv, // special vertices - Self* p) - : copied_arr(copied), - result_arr(result), - result_original_face(orig_face), - map_halfedges(map_h), - map_vertices(map_v), - map_faces(map_f), - result_special_edges(se), - result_new_edges(new_edges), - result_face_parts(face_parts), - result_special_vertices(sv), - md_copy_observer(copied, result, map_h, map_v, map_f), - md_observer(map_h), - parent(p) + Self* p) : + copied_arr(copied), + result_arr(result), + result_original_face(orig_face), + map_halfedges(map_h), + map_vertices(map_v), + map_faces(map_f), + result_special_edges(se), + result_new_edges(new_edges), + result_face_parts(face_parts), + result_special_vertices(sv), + md_copy_observer(copied, result, map_h, map_v, map_f), + md_observer(map_h), + parent(p) { // init maps copied_face_parts[copied_face] = copied_face_parts.default_value(); - Halfedge_iterator hi = copied_arr.halfedges_begin(); - for (; hi != copied_arr.halfedges_end(); ++hi) - { + for (auto hi = copied_arr.halfedges_begin(); + hi != copied_arr.halfedges_end(); ++hi) { copied_arr_boundary_halfedges[hi] = copied_arr_boundary_halfedges.default_value(); if (hi->face() == copied_face && @@ -2569,14 +2378,12 @@ class Envelope_element_visitor_3 copied_vertices_to_halfedges[hi->target()] = hi; } - Vertex_iterator vi = copied_arr.vertices_begin(); - for (; vi != copied_arr.vertices_end(); ++vi) - { + for (auto vi = copied_arr.vertices_begin(); + vi != copied_arr.vertices_end(); ++vi) { copied_arr_orig_vertices[vi] = copied_arr_orig_vertices.default_value(); - if (vi->is_isolated()) - { + if (vi->is_isolated()) { CGAL_assertion(vi->face() == copied_face); copied_vertices_to_halfedges[vi] = Halfedge_handle(nullptr); } @@ -2602,14 +2409,12 @@ class Envelope_element_visitor_3 // the zone visitor functions /*! Initialize the visitor with an arrangement object. */ - void init(Minimization_diagram_2* arr) - { + void init(Minimization_diagram_2* arr) { CGAL_assertion(&copied_arr == arr); insert_visitor.init(arr); } - /*! - * Handle the a subcurve located in the interior of a given face. + /*! Handle the a subcurve located in the interior of a given face. * \param cv The subcurve. * \param face The face containing cv's interior. * \param left_v The vertex that corresponds to the left endpoint of cv @@ -2628,8 +2433,7 @@ class Envelope_element_visitor_3 Result found_subcurve(const X_monotone_curve_2& cv, Face_handle face, Vertex_handle left_v, Halfedge_handle left_he, - Vertex_handle right_v, Halfedge_handle right_he) - { + Vertex_handle right_v, Halfedge_handle right_he) { // insert the curve only if the face is ok if (is_face_ok(face)) { @@ -2673,13 +2477,11 @@ class Envelope_element_visitor_3 // and the vertex (or the vertex info if it was isolated) // otherwise, we set flags to true since it is a new vertex inside the // original face, and have same aux data as all face parts - if (is_boundary_vertex(new_he->target())) - { + if (is_boundary_vertex(new_he->target())) { Vertex_handle cur_t = new_he->target(); CGAL_assertion(copied_vertices_to_halfedges.is_defined(cur_t)); Halfedge_handle copied_b_he = copied_vertices_to_halfedges[cur_t]; - if (copied_b_he == Halfedge_handle(nullptr)) - { + if (copied_b_he == Halfedge_handle(nullptr)) { // this was an isolated vertex, which we touch // since we have in the new edge aux sources as in the face, // we can copy the vertex-face flags from the vertex @@ -2696,8 +2498,7 @@ class Envelope_element_visitor_3 result_new_he->set_has_equal_aux_data_in_target_and_face (1, cur_t->get_has_equal_aux_data_in_face(1)); } - else - { + else { CGAL_assertion(copied_b_he->target() == cur_t); CGAL_assertion(is_boundary_edge(copied_b_he)); Halfedge_handle b_he = map_halfedges[copied_b_he]; @@ -2724,8 +2525,7 @@ class Envelope_element_visitor_3 } } - else // not a boundary vertex - { + else { // not a boundary vertex result_new_he->set_is_equal_aux_data_in_target(0, true); result_new_he->set_is_equal_aux_data_in_target(1, true); // the face's data is not empty - so it is ok to set "true" here @@ -2735,13 +2535,11 @@ class Envelope_element_visitor_3 result_new_he->set_has_equal_aux_data_in_target_and_face(1, true); } - if (is_boundary_vertex(new_he->source())) - { + if (is_boundary_vertex(new_he->source())) { Vertex_handle cur_t = new_he->source(); CGAL_assertion(copied_vertices_to_halfedges.is_defined(cur_t)); Halfedge_handle copied_b_he = copied_vertices_to_halfedges[cur_t]; - if (copied_b_he == Halfedge_handle(nullptr)) - { + if (copied_b_he == Halfedge_handle(nullptr)) { // this was an isolated vertex, which we touch // since we have in the new edge aux sources as in the face, // we can copy the vertex-face flags from the vertex @@ -2758,8 +2556,7 @@ class Envelope_element_visitor_3 result_new_he->twin()->set_has_equal_aux_data_in_target_and_face (1, cur_t->get_has_equal_aux_data_in_face(1)); } - else - { + else { CGAL_assertion(copied_b_he->target() == cur_t); CGAL_assertion(is_boundary_edge(copied_b_he)); Halfedge_handle b_he = map_halfedges[copied_b_he]; @@ -2827,8 +2624,7 @@ class Envelope_element_visitor_3 */ Result found_overlap(const X_monotone_curve_2& cv, Halfedge_handle he, - Vertex_handle left_v, Vertex_handle right_v) - { + Vertex_handle left_v, Vertex_handle right_v) { // check if the halfedge is the boundary of the original face // (here we assume that this indication is dealt with in an observer // attached to the md, and implements split_edge) @@ -2851,12 +2647,10 @@ class Envelope_element_visitor_3 copied_arr_special_vertices[overlap_he->target()] = copied_arr_special_vertices.default_value(); - if (!is_boundary) - return base_res; + if (! is_boundary) return base_res; // if he is a boundary edge, it is a special edge - if (is_boundary) - { + if (is_boundary) { copied_arr_special_edges[overlap_he] = copied_arr_special_edges.default_value(); copied_arr_special_edges[overlap_he->twin()] = @@ -2865,51 +2659,46 @@ class Envelope_element_visitor_3 return base_res; } - /*! - * Handle point that lies inside a given face. + /*! Handle point that lies inside a given face. * \param p The point. * \param face The face inside which the point lies. * \return A handle to the new vertex obtained from the insertion of the * point into the face, or invalid handle if the point wasn't * inserted to the arrangement. */ - Vertex_handle found_point_in_face(const Point_2& p, Face_handle face) - { + Vertex_handle found_point_in_face(const Point_2& p, Face_handle face) { // p lies inside a face: Insert it as an isolated vertex it the interior // of this face. Vertex_handle vh_for_p; - if (is_face_ok(face)) - { + if (is_face_ok(face)) { Arr_accessor arr_access (copied_arr); arr_access.notify_before_global_change(); vh_for_p = copied_arr.insert_in_face_interior(p, face); arr_access.notify_after_global_change(); - // now should set the is_equal and has_equal flags - CGAL_assertion(map_vertices.is_defined(vh_for_p)); - Vertex_handle result_new_v = map_vertices[vh_for_p]; - result_new_v->set_is_equal_aux_data_in_face(0, true); - result_new_v->set_is_equal_aux_data_in_face(1, true); + // now should set the is_equal and has_equal flags + CGAL_assertion(map_vertices.is_defined(vh_for_p)); + Vertex_handle result_new_v = map_vertices[vh_for_p]; + result_new_v->set_is_equal_aux_data_in_face(0, true); + result_new_v->set_is_equal_aux_data_in_face(1, true); result_new_v->set_has_equal_aux_data_in_face(0, true); - result_new_v->set_has_equal_aux_data_in_face(1, true); + result_new_v->set_has_equal_aux_data_in_face(1, true); } return vh_for_p; } - /*! - * Handle point that lies on a given edge. + /*! Handle point that lies on a given edge. * \param p The point. * \param he The edge on which the point lies. * \return A handle to the new vertex obtained from the insertion of the * point into the edge, or invalid handle if the point wasn't * inserted to the arrangement. */ - Vertex_handle found_point_on_edge(const Point_2& p, Halfedge_handle he) - { + Vertex_handle found_point_on_edge(const Point_2& p, Halfedge_handle he) { // p lies in the interior of an edge: Split this edge to create a new // vertex associated with p. - X_monotone_curve_2 sub_cv1, sub_cv2; - Halfedge_handle split_he; + X_monotone_curve_2 sub_cv1, sub_cv2; + Halfedge_handle split_he; copied_arr.geometry_traits()-> split_2_object() (he->curve(), p, sub_cv1, sub_cv2); @@ -2929,15 +2718,13 @@ class Envelope_element_visitor_3 return split_he->target(); } - /*! - * Handle point that lies on a given vertex. + /*! Handle point that lies on a given vertex. * \param p The point. * \param v The vertex on which the point lies. * \return A handle to the new vertex obtained from the modifying * the existing vertex. */ - Vertex_handle found_point_on_vertex(const Point_2& p, Vertex_handle v) - { + Vertex_handle found_point_on_vertex(const Point_2& p, Vertex_handle v) { // if the vertex is a boundary vertex, then it is a special vertex // if it was created by split of a boundary edge, then it is already // marked as special. we need to mark it as special if it is an original @@ -2949,37 +2736,31 @@ class Envelope_element_visitor_3 return copied_arr.modify_vertex (v, p); } - /*! - * Update all the output collections using the internal data saved during + /*! Update all the output collections using the internal data saved during * the previous inserts. * Should be called after all inserts have finished. */ - void finish() - { + void finish() { // result_special_edges // result_new_edges - Halfedge_iterator hi = copied_arr.halfedges_begin(); - for (; hi != copied_arr.halfedges_end(); ++hi, ++hi) - { + for (auto hi = copied_arr.halfedges_begin(); + hi != copied_arr.halfedges_end(); ++hi, ++hi) { Halfedge_handle h = hi; CGAL_assertion(map_halfedges.is_defined(h) && map_halfedges.is_defined(h->twin())); - // we need only one of the twin halfedges to represent the new edge if (copied_arr_new_edges.is_defined(h)) result_new_edges.push_back(std::make_pair(map_halfedges[h], copied_arr_new_edges[h])); - if (copied_arr_special_edges.is_defined(h)) - { + if (copied_arr_special_edges.is_defined(h)) { // we need the halfedge that its incident face is inside the original // face Face_handle f1 = h->face(); if (copied_face_parts.is_defined(f1)) result_special_edges.push_back(map_halfedges[h]); - else - { + else { CGAL_assertion_code(Face_handle f2 = h->twin()->face()); CGAL_assertion(copied_face_parts.is_defined(f2)); result_special_edges.push_back(map_halfedges[h->twin()]); @@ -2988,28 +2769,23 @@ class Envelope_element_visitor_3 } // result_face_parts - Face_iterator fi = copied_arr.faces_begin(); - for (; fi != copied_arr.faces_end(); ++fi) - { + for (auto fi = copied_arr.faces_begin(); fi != copied_arr.faces_end(); + ++fi) { Face_handle f = fi; - if (copied_face_parts.is_defined(f)) - { + if (copied_face_parts.is_defined(f)) { CGAL_assertion(map_faces.is_defined(f)); result_face_parts.push_back(map_faces[f]); } } // result_special_vertices - Vertex_iterator vi = copied_arr.vertices_begin(); - for (; vi != copied_arr.vertices_end(); ++vi) - - { + for (auto vi = copied_arr.vertices_begin(); + vi != copied_arr.vertices_end(); ++vi) { Vertex_handle v = vi; CGAL_assertion(map_vertices.is_defined(v)); Vertex_handle result_v = map_vertices[v]; - if (copied_arr_orig_vertices.is_defined(v)) - { + if (copied_arr_orig_vertices.is_defined(v)) { // original vertex should be mapped to a boundary halfedge whose // target is the vertex CGAL_assertion(copied_vertices_to_halfedges.is_defined(v)); @@ -3032,9 +2808,8 @@ class Envelope_element_visitor_3 result_special_vertices.push_back(result_v); } } - else - { - if (!copied_arr_new_boundary_vertices.is_defined(v)) + else { + if (! copied_arr_new_boundary_vertices.is_defined(v)) // new vertex inside the face result_special_vertices.push_back(result_v); else if (copied_arr_special_vertices.is_defined(v)) @@ -3043,30 +2818,22 @@ class Envelope_element_visitor_3 } } - void set_current_intersection_type(Multiplicity t) - { - itype = t; - } + void set_current_intersection_type(Multiplicity t) { itype = t; } protected: - bool is_face_ok(Face_handle face) - { + bool is_face_ok(Face_handle face) { // is this face a part of the original face? // check in the copied_face_parts map return (copied_face_parts.is_defined(face)); } bool is_boundary_edge(Halfedge_handle he) - { - return (copied_arr_boundary_halfedges.is_defined(he)); - } + { return (copied_arr_boundary_halfedges.is_defined(he)); } bool is_original_boundary_vertex(Vertex_handle v) - { - return (copied_arr_orig_vertices.is_defined(v)); - } - bool is_boundary_vertex(Vertex_handle v) - { + { return (copied_arr_orig_vertices.is_defined(v)); } + + bool is_boundary_vertex(Vertex_handle v) { return (copied_arr_orig_vertices.is_defined(v) || copied_arr_new_boundary_vertices.is_defined(v)); } diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h index 6951875249ef..118d9825c03f 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h @@ -8,8 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_OVERLAY_2_H #define CGAL_ENVELOPE_OVERLAY_2_H @@ -17,40 +18,38 @@ #include +#include + #include #include -#include - namespace CGAL { -template > -class Envelope_overlay_2 -{ +template > +class Envelope_overlay_2 { public: - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; + + using Face_handle = typename Minimization_diagram_2::Face_handle; + using Face_iterator = typename Minimization_diagram_2::Face_iterator; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_iterator Face_iterator; + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Vertex_iterator = typename Minimization_diagram_2::Vertex_iterator; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator Vertex_iterator; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Halfedge_iterator = typename Minimization_diagram_2::Halfedge_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator Halfedge_iterator; + using Overlay_functor = OverlayFunctor; - typedef OverlayFunctor Overlay_functor; protected: - typedef typename Minimization_diagram_2::Geometry_traits_2 Traits; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = typename Minimization_diagram_2::Geometry_traits_2; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; public: - - void operator()(Minimization_diagram_2& md1, - Minimization_diagram_2& md2, - Minimization_diagram_2& result) - { + void operator()(Minimization_diagram_2& md1, Minimization_diagram_2& md2, + Minimization_diagram_2& result) { CGAL_assertion(md1.is_valid()); CGAL_assertion(md2.is_valid()); @@ -60,9 +59,7 @@ class Envelope_overlay_2 CGAL_assertion_code(post_test_assertions(result)); } - public: - /* void print_face(Face_handle fh) { @@ -72,7 +69,7 @@ class Envelope_overlay_2 { std::cout << " #data= " << fh->number_of_data_objects(); if (fh->number_of_data_objects() > 0) - std::cout << " data= " << fh->get_data(); + std::cout << " data= " << fh->get_env_data(); } if (fh->get_aux_is_set(0)) @@ -114,7 +111,7 @@ class Envelope_overlay_2 { std::cout << " #data= " << vh->number_of_data_objects(); if (vh->number_of_data_objects() > 0) - std::cout << " data= " << vh->get_data(); + std::cout << " data= " << vh->get_env_data(); } if (vh->get_aux_is_set(0)) @@ -146,7 +143,7 @@ class Envelope_overlay_2 { std::cout << " #data= " << hh->number_of_data_objects(); if (hh->number_of_data_objects() > 0) - std::cout << " data= " << hh->get_data(); + std::cout << " data= " << hh->get_env_data(); } @@ -169,75 +166,68 @@ class Envelope_overlay_2 } */ - void post_test_assertions(Minimization_diagram_2& md) - { + void post_test_assertions(Minimization_diagram_2& md) { // check that all data is filled in result - Face_iterator fi = md.faces_begin(); - for(; fi != md.faces_end(); ++fi) - { + for (auto fi = md.faces_begin(); fi != md.faces_end(); ++fi) { Face_handle fh = fi; - CGAL_assertion_msg(fh->get_aux_is_set(0), "data from md1 on face is not set"); - CGAL_assertion_msg(fh->get_aux_is_set(1), "data from md2 on face is not set"); + CGAL_assertion_msg(fh->get_aux_is_set(0), + "data from md1 on face is not set"); + CGAL_assertion_msg(fh->get_aux_is_set(1), + "data from md2 on face is not set"); } - Halfedge_iterator hi = md.halfedges_begin(); - for(; hi != md.halfedges_end(); ++hi) - { + for (auto hi = md.halfedges_begin(); hi != md.halfedges_end(); ++hi) { Halfedge_handle hh = hi; - CGAL_assertion_msg(hh->get_aux_is_set(0), "data from md1 on halfedge is not set"); - CGAL_assertion_msg(hh->get_aux_is_set(1), "data from md2 on halfedge is not set"); + CGAL_assertion_msg(hh->get_aux_is_set(0), + "data from md1 on halfedge is not set"); + CGAL_assertion_msg(hh->get_aux_is_set(1), + "data from md2 on halfedge is not set"); } - Vertex_iterator vi = md.vertices_begin(); - for(; vi != md.vertices_end(); ++vi) - { + for (auto vi = md.vertices_begin(); vi != md.vertices_end(); ++vi) { Vertex_handle vh = vi; - CGAL_assertion_msg(vh->get_aux_is_set(0), "data from md1 on vertex is not set"); - CGAL_assertion_msg(vh->get_aux_is_set(1), "data from md2 on vertex is not set"); + CGAL_assertion_msg(vh->get_aux_is_set(0), + "data from md1 on vertex is not set"); + CGAL_assertion_msg(vh->get_aux_is_set(1), + "data from md2 on vertex is not set"); } } + protected: // helper methods - template - Xy_monotone_surface_3 get_aux_data(FeatureHandle fh, unsigned int id) - { + template + Xy_monotone_surface_3 get_aux_data(FeatureHandle fh, unsigned int id) { const Object& o = fh->get_aux_source(id); Xy_monotone_surface_3 data; Halfedge_handle h; Vertex_handle v; - Face_handle f; - if (assign(v, o)) - data = v->get_data(); - else if (assign(h, o)) - data = h->get_data(); - else - { - CGAL_assertion(assign(f, o)); + Face_handle f; + if (assign(v, o)) data = v->get_env_data(); + else if (assign(h, o)) data = h->get_env_data(); + else { + CGAL_assertion(assign(f, o)); assign(f, o); - data = f->get_data(); - } + data = f->get_env_data(); + } return data; } - template - int get_number_of_aux_data_objects(FeatureHandle fh, unsigned int id) - { + + template + int get_number_of_aux_data_objects(FeatureHandle fh, unsigned int id) { const Object& o = fh->get_aux_source(id); int data; Halfedge_handle h; Vertex_handle v; - Face_handle f; - if (assign(v, o)) - data = v->number_of_data_objects(); - else if (assign(h, o)) - data = h->number_of_data_objects(); - else - { - CGAL_assertion(assign(f, o)); + Face_handle f; + if (assign(v, o)) data = v->number_of_data_objects(); + else if (assign(h, o)) data = h->number_of_data_objects(); + else { + CGAL_assertion(assign(f, o)); assign(f, o); - data = f->number_of_data_objects(); - } + data = f->number_of_data_objects(); + } return data; } diff --git a/Envelope_3/test/Envelope_3/Envelope_test_3.h b/Envelope_3/test/Envelope_3/Envelope_test_3.h index 80656676ca7d..37c70646365d 100644 --- a/Envelope_3/test/Envelope_3/Envelope_test_3.h +++ b/Envelope_3/test/Envelope_3/Envelope_test_3.h @@ -8,18 +8,12 @@ // $Name: $ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef CGAL_ENVELOPE_TEST_3_H #define CGAL_ENVELOPE_TEST_3_H -#include -#include "Envelope_test_overlay_functor.h" -#include - -#include -#include - #include #include #include @@ -27,128 +21,123 @@ #include #include +#include +#include "Envelope_test_overlay_functor.h" +#include + +#include +#include + //#define CGAL_DEBUG_ENVELOPE_TEST_3 -// this is a very trivial and not efficient algorithm for computing the lower envelope -// of general surfaces in 3d, used for testing. -// The algorithm projects the surfaces on the plane, and projects all the intersections -// between surfaces, to get an arrangement that is a partition of the real envelope. -// Then it computes for each part in the arrangement the surfaces on the envelope over it -// by comparing them all. +// this is a very trivial and not efficient algorithm for computing the lower +// envelope of general surfaces in 3d, used for testing. +// The algorithm projects the surfaces on the plane, and projects all the +// intersections between surfaces, to get an arrangement that is a partition of +// the real envelope. +// Then it computes for each part in the arrangement the surfaces on the +// envelope over it by comparing them all. namespace CGAL { -template -class Envelope_test_3 -{ +template +class Envelope_test_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; +private: + using Md2 = Minimization_diagram_2; -protected: +public: + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; - typedef Envelope_test_overlay_functor Overlay_functor; - typedef Envelope_overlay_2 Overlay_2; - - typedef Arr_walk_along_line_point_location Md_point_location; - - typedef typename Minimization_diagram_2::Halfedge_const_iterator Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator Halfedge_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator Vertex_iterator; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_const_iterator Face_const_iterator; - typedef typename Minimization_diagram_2::Face_const_handle Face_const_handle; - typedef typename Minimization_diagram_2::Face_iterator Face_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator Hole_iterator; - typedef typename Minimization_diagram_2::Dcel::Face_data_iterator Face_data_iterator; - - typedef std::pair Intersection_curve; + using Point_2 = typename Md2::Point_2; + using X_monotone_curve_2 = typename Md2::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; + +protected: + using Overlay_functor = Envelope_test_overlay_functor; + using Overlay_2 = Envelope_overlay_2; + + using Md_point_location = Arr_walk_along_line_point_location; + + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Vertex_handle = typename Md2::Vertex_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Face_handle = typename Md2::Face_handle; + using Face_const_iterator = typename Md2::Face_const_iterator; + using Face_const_handle = typename Md2::Face_const_handle; + using Face_iterator = typename Md2::Face_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Hole_iterator = typename Md2::Inner_ccb_iterator; + using Face_data_iterator = typename Md2::Dcel::Face_data_iterator; + + using Multiplicity = typename EnvelopeTraits_3::Multiplicity; + using Intersection_curve = std::pair; public: // c'tor - Envelope_test_3() - { - } + Envelope_test_3() {} // virtual destructor. virtual ~Envelope_test_3(){} template - void construct_lu_envelope(SurfaceIterator begin, - SurfaceIterator end, - Minimization_diagram_2 &result) - { - if (begin == end) - { - return; // result is empty - } + void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, + Minimization_diagram_2& result) { + if (begin == end) return; // result is empty std::vector surfaces; - SurfaceIterator si = begin; - for(; si != end; ++si) - { - surfaces.push_back(*si); - } + for (auto si = begin; si != end; ++si) surfaces.push_back(*si); Md_point_location pl(result); std::size_t number_of_surfaces = surfaces.size(); - std::size_t j; std::list curves_col; std::list points_col; typename std::list::iterator boundary_it; - for(std::size_t i=0; i Boundary_xcurve; std::list> boundary_list; - traits.construct_projected_boundary_2_object()(cur_surface, std::back_inserter(boundary_list)); - for(auto boundary_it = boundary_list.begin(); - boundary_it != boundary_list.end(); - ++boundary_it) - { - const Boundary_xcurve* boundary_cv = std::get_if(&(*boundary_it)); + auto ctr_proj_bnd = traits.construct_projected_boundary_2_object(); + ctr_proj_bnd(cur_surface, std::back_inserter(boundary_list)); + for (auto boundary_it = boundary_list.begin(); + boundary_it != boundary_list.end(); ++boundary_it) { + const auto* boundary_cv = std::get_if(&(*boundary_it)); assert(boundary_cv!=nullptr); curves_col.push_back(boundary_cv->first); } // second, intersect it with all surfaces before it - for(j=0; j> inter_objs; traits.construct_projected_intersections_2_object()(cur_surface, prev_surface, std::back_inserter(inter_objs)); // we collect all intersections and use sweep to insert them - for(std::size_t k=0; k(&inter_objs[k])) - { + for (std::size_t k = 0; k < inter_objs.size(); ++k) { + if (const Point_2* point = std::get_if(&inter_objs[k])) { #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "intersection between surfaces is a point: " << point << std::endl; + std::cout << "intersection between surfaces is a point: " + << point << std::endl; #endif //insert_vertex(result, point, pl); points_col.push_back(*point); } - else if (const Intersection_curve* curve = std::get_if(&inter_objs[k])) - { + else if (const auto* curve = + std::get_if(&inter_objs[k])) { curves_col.push_back(curve->first); /*#ifdef CGAL_DEBUG_ENVELOPE_TEST_3 std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl; @@ -165,10 +154,7 @@ class Envelope_test_3 }*/ //insert(result, curve.first, pl); } - else - { - assert_msg(false, "wrong intersection type"); - } + else assert_msg(false, "wrong intersection type"); } } } @@ -176,8 +162,7 @@ class Envelope_test_3 // insert the curves insert(result, curves_col.begin(), curves_col.end()); // insert the points - typename std::list::iterator pit = points_col.begin(); - for(; pit != points_col.end(); ++pit) + for (auto pit = points_col.begin(); pit != points_col.end(); ++pit) insert_point(result, *pit, pl); m_result = &result; @@ -185,52 +170,48 @@ class Envelope_test_3 // now, foreach vertex, edge and face, we should determine which surfaces are minimal over it. // update vertices' data - Vertex_iterator vi = result.vertices_begin(); - for(; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; // first we find the surfaces that are defined over the vertex std::list defined_surfaces; - typename Traits::Is_defined_over is_defined_over = traits.is_defined_over_object(); - for(std::size_t i=0; ipoint(), surfaces[i])) defined_surfaces.push_back(surfaces[i]); // now compare them over the vertex - set_minimum_over_vertex(vh, defined_surfaces.begin(), defined_surfaces.end()); + set_minimum_over_vertex(vh, defined_surfaces.begin(), + defined_surfaces.end()); } // update edges' data - Halfedge_iterator hi = result.halfedges_begin(); - for(; hi != result.halfedges_end(); ++hi, ++hi) - { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; // first we find the surfaces that are defined over the edge std::list defined_surfaces; - for(std::size_t i=0; i defined_surfaces; - for (std::size_t i=0; i + template void set_minimum_over_vertex(const Vertex_handle& v, - SurfaceIterator begin, SurfaceIterator end) - { - if (begin == end) - v->set_no_data(); - else - { - SurfaceIterator si = begin; + SurfaceIterator begin, SurfaceIterator end) { + if (begin == end) v->set_no_data(); + else { + auto si = begin; // we set the first surface as the minimum, and then compare all the others - v->set_data(*si); + v->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = traits.compare_z_at_xy_3_object()(v->point(), v->get_data(), *si); - if (cr == EQUAL) - v->add_data(*si); - else if (cr == LARGER) - v->set_data(*si); // this erases all surfaces from vertex's list + for (; si != end; ++si) { + Comparison_result cr = + traits.compare_z_at_xy_3_object()(v->point(), v->get_env_data(), *si); + if (cr == EQUAL) v->add_data(*si); + // this erases all surfaces from vertex's list + else if (cr == LARGER) v->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -287,58 +261,53 @@ class Envelope_test_3 // fill the edge with the surface on the envelope // all the surfaces are known to be defined over the edge's curve - template - void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, SurfaceIterator end) - { - if (begin == end) - h->set_no_data(); - else - { - if (h != current_edge) - compute_point_in_current_edge(h); - - SurfaceIterator si = begin; + template + void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, + SurfaceIterator end) { + if (begin == end) h->set_no_data(); + else { + if (h != current_edge) compute_point_in_current_edge(h); + + auto si = begin; // we set the first surface as the minimum, and then compare all the others - h->set_data(*si); + h->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge, - h->get_data(), *si); - if (cr == EQUAL) - h->add_data(*si); - else if (cr == LARGER) - h->set_data(*si); // this erases all surfaces from halfedge's list + for (; si != end; ++si) { + Comparison_result cr = + traits.compare_z_at_xy_3_object()(current_point_inside_edge, + h->get_env_data(), *si); + if (cr == EQUAL) h->add_data(*si); + // this erases all surfaces from halfedge's list + else if (cr == LARGER) h->set_env_data(*si); // else - new surface has no affect on the envelope } // set twin's data - h->twin()->set_data(h->begin_data(), h->end_data()); + h->twin()->set_env_data(h->begin_data(), h->end_data()); } } + // fill the face with the surface on the envelope // the surfaces are known to not intersect inside the face // (but might intersect on its edges) - template - void set_minimum_over_face(const Face_handle& face, SurfaceIterator begin, SurfaceIterator end) - { - if (face->is_unbounded() || begin == end) - { - // a special case - no surface over the unbounded face, and when there are no surfaces at all + template + void set_minimum_over_face(const Face_handle& face, SurfaceIterator begin, + SurfaceIterator end) { + if (face->is_unbounded() || begin == end) { + // a special case - no surface over the unbounded face, and when there + // are no surfaces at all face->set_no_data(); } - else - { - SurfaceIterator si = begin; + else { + auto si = begin; // we set the first surface as the minimum, and then compare all the others - face->set_data(*si); + face->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = compare_surfaces_over_face(face, face->get_data(), *si); - if (cr == EQUAL) - face->add_data(*si); - else if (cr == LARGER) - face->set_data(*si); // this erases all surfaces from face's list + for (; si != end; ++si) { + Comparison_result cr = + compare_surfaces_over_face(face, face->get_env_data(), *si); + if (cr == EQUAL) face->add_data(*si); + // this erases all surfaces from face's list + else if (cr == LARGER) face->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -349,14 +318,13 @@ class Envelope_test_3 // LARGER if the second surface is closer to the envelope // EQUAL otherwise // this is version 2 which uses a calculated point inside the face - Comparison_result compare_surfaces_over_face(const Face_handle& face, - const Xy_monotone_surface_3 &surf1, - const Xy_monotone_surface_3& surf2) - { + Comparison_result + compare_surfaces_over_face(const Face_handle& face, + const Xy_monotone_surface_3& surf1, + const Xy_monotone_surface_3& surf2) { assert(!face->is_unbounded()); Comparison_result cur_res; - if (face != current_face) - compute_point_in_current_face(face); + if (face != current_face) compute_point_in_current_face(face); cur_res = traits.compare_z_at_xy_3_object()(current_point,surf1,surf2); @@ -368,27 +336,24 @@ class Envelope_test_3 } // check if the surface is defines over the edge - bool is_surface_defined_over_edge(const Halfedge_handle& h, Xy_monotone_surface_3 &surf) - { + bool is_surface_defined_over_edge(const Halfedge_handle& h, + Xy_monotone_surface_3& surf) { // check it over a point inside the edge's curve - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); - bool result = traits.is_defined_over_object()(current_point_inside_edge, surf); + auto def_over_obj = traits.is_defined_over_object(); + bool result = def_over_obj(current_point_inside_edge, surf); return result; } // check if the surface is defines over the face // this is version checks the point inside the face bool is_surface_defined_over_face(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // we always have bounded surfaces - if (face->is_unbounded()) - return false; + if (face->is_unbounded()) return false; - if (face != current_face) - compute_point_in_current_face(face); + if (face != current_face) compute_point_in_current_face(face); bool result = traits.is_defined_over_object()(current_point,surf); @@ -396,9 +361,9 @@ class Envelope_test_3 } // compute a point inside the face of the arranegement - Point_2 compute_point_inside_face(Minimization_diagram_2 &env, Face_handle face) - { - assert(!face->is_unbounded()); + Point_2 compute_point_inside_face(Minimization_diagram_2& env, + Face_handle face) { + assert(! face->is_unbounded()); #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 std::cout << "in compute point inside face" << std::endl; @@ -409,8 +374,7 @@ class Envelope_test_3 Ccb_halfedge_circulator hec_begin = hec; bool found = false; do { - if (!traits.is_vertical_2_object()(hec->curve())) - { + if (!traits.is_vertical_2_object()(hec->curve())) { found = true; continue; } @@ -433,7 +397,7 @@ class Envelope_test_3 // if (traits.compare_x(found_hh->source()->point(), found_hh->target()->point()) == LARGER) // shoot_up = false; if (traits.equal_2_object()(found_hh->source()->point(), - traits.construct_max_vertex_2_object()(found_hh->curve()))) + traits.construct_max_vertex_2_object()(found_hh->curve()))) shoot_up = false; Md_point_location pl(env); @@ -443,21 +407,14 @@ class Envelope_test_3 Point_2 shoot_target; - if (shoot_up) - shoot_obj = pl.ray_shoot_up(shoot_source); - else - shoot_obj = pl.ray_shoot_down(shoot_source); + if (shoot_up) shoot_obj = pl.ray_shoot_up(shoot_source); + else shoot_obj = pl.ray_shoot_down(shoot_source); if (assign(shoot_hh, shoot_obj)) - { shoot_target = traits.vertical_ray_shoot_2(shoot_source, shoot_hh->curve()); - } else if (assign(shoot_vh, shoot_obj)) - { shoot_target = (env.non_const_handle(shoot_vh))->point(); - } - else - CGAL_error(); // it cannot be the unbounded face + else CGAL_error(); // it cannot be the unbounded face Point_2 res_point = traits.construct_middle_point(shoot_source, shoot_target); @@ -471,37 +428,34 @@ class Envelope_test_3 assert(test_fh == face); #endif - return res_point; } // compute a point inside the face saved in current_face // and put the result into current_point - void compute_point_in_current_face(Face_handle face) - { + void compute_point_in_current_face(Face_handle face) { current_face = face; current_point = compute_point_inside_face(*m_result, current_face); } // compute a point inside the edge saved in current_edge // and put the result into current_point_inside_edge - void compute_point_in_current_edge(Halfedge_handle h) - { + void compute_point_in_current_edge(Halfedge_handle h) { current_edge = h; current_point_inside_edge = traits.construct_middle_point(h->curve()); } protected: - Overlay_2 overlay; - Traits traits; - Minimization_diagram_2 *m_result; + Overlay_2 overlay; + Traits traits; + Minimization_diagram_2* m_result; - Face_handle current_face; - Point_2 current_point; + Face_handle current_face; + Point_2 current_point; - Halfedge_handle current_edge; - Point_2 current_point_inside_edge; + Halfedge_handle current_edge; + Point_2 current_point_inside_edge; }; } //namespace CGAL diff --git a/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h b/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h index c3388bed44ac..20cbfbcafb59 100644 --- a/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h +++ b/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h @@ -8,7 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef ENVELOPE_TEST_OVERLAY_FUNCTOR_H #define ENVELOPE_TEST_OVERLAY_FUNCTOR_H @@ -28,104 +29,87 @@ namespace CGAL { // this overlay functor compares the data over the 2 features that create new // features in the new map -template -class Envelope_test_overlay_functor -{ +template +class Envelope_test_overlay_functor { public: - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Minimization_diagram_2::Face_const_handle Face_handle1; - typedef typename Minimization_diagram_2::Face_const_handle Face_handle2; +private: + using Md2 = Minimization_diagram_2; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_handle1; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_handle2; +public: + using Face_handle1 = typename Md2::Face_const_handle; + using Face_handle2 = typename Md2::Face_const_handle; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_handle1; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_handle2; + using Vertex_handle1 = typename Md2::Vertex_const_handle; + using Vertex_handle2 = typename Md2::Vertex_const_handle; - typedef typename Minimization_diagram_2::Face_handle Res_face_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Res_halfedge_handle; - typedef typename Minimization_diagram_2::Vertex_handle Res_vertex_handle; + using Halfedge_handle1 = typename Md2::Halfedge_const_handle; + using Halfedge_handle2 = typename Md2::Halfedge_const_handle; + using Res_face_handle = typename Md2::Face_handle; + using Res_halfedge_handle = typename Md2::Halfedge_handle; + using Res_vertex_handle = typename Md2::Vertex_handle; - Envelope_test_overlay_functor(Minimization_diagram_2& , - Minimization_diagram_2& , - Minimization_diagram_2& ) - {} + Envelope_test_overlay_functor(Md2&, Md2&, Md2&) {} - void create_face (Face_handle1 f1, Face_handle2 f2, Res_face_handle res_f) - { + void create_face (Face_handle1 f1, Face_handle2 f2, Res_face_handle res_f) { res_f->set_aux_source(0, f1); res_f->set_aux_source(1, f2); assert_msg(f1->is_equal_data(f2->begin_data(), f2->end_data()), - "data different over face"); + "data different over face"); } - void create_vertex(Halfedge_handle1 h1, - Halfedge_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_handle1 h1, Halfedge_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, h1); res_v->set_aux_source(1, h2); assert_msg(h1->is_equal_data(h2->begin_data(), h2->end_data()), - "data different over vertex"); - + "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, v2); assert_msg(v1->is_equal_data(v2->begin_data(), v2->end_data()), "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Halfedge_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Halfedge_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, h2); assert_msg(v1->is_equal_data(h2->begin_data(), h2->end_data()), "data different over vertex"); } - void create_vertex(Halfedge_handle1 h1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_handle1 h1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, h1); res_v->set_aux_source(1, v2); assert_msg(h1->is_equal_data(v2->begin_data(), v2->end_data()), "data different over vertex"); } - void create_vertex(Face_handle1 f1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Face_handle1 f1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, f1); res_v->set_aux_source(1, v2); assert_msg(f1->is_equal_data(v2->begin_data(), v2->end_data()), "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Face_handle2 f2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Face_handle2 f2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, f2); assert_msg(v1->is_equal_data(f2->begin_data(), f2->end_data()), "data different over vertex"); } - void create_edge(Halfedge_handle1 h1, - Halfedge_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_handle1 h1, Halfedge_handle2 h2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, h1); res_h->set_aux_source(1, h2); @@ -136,10 +120,8 @@ class Envelope_test_overlay_functor "data different over edge"); } - void create_edge(Halfedge_handle1 h1, - Face_handle2 f2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_handle1 h1, Face_handle2 f2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, h1); res_h->set_aux_source(1, f2); @@ -150,10 +132,8 @@ class Envelope_test_overlay_functor "data different over edge"); } - void create_edge(Face_handle1 f1, - Halfedge_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Face_handle1 f1, Halfedge_handle2 h2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, f1); res_h->set_aux_source(1, h2); @@ -169,5 +149,3 @@ class Envelope_test_overlay_functor } //namespace CGAL #endif - - diff --git a/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h b/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h index 194b9fb7a120..84a83a62d8ad 100644 --- a/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h +++ b/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h @@ -8,17 +8,12 @@ // $Name: $ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef CGAL_ENVELOPE_TRIANGLES_TEST_3_H #define CGAL_ENVELOPE_TRIANGLES_TEST_3_H -#include "Envelope_test_overlay_functor.h" -#include - -#include -#include - #include #include #include @@ -26,6 +21,11 @@ #include #include +#include "Envelope_test_overlay_functor.h" +#include +#include +#include + //#define CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 // this is a very trivial and not efficient algorithm for computing the lower @@ -38,59 +38,47 @@ namespace CGAL { -template +template class Envelope_triangles_test_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; + +private: + using Md2 = Minimization_diagram_2; + +public: + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; + using Point_2 = typename Md2::Point_2; + using X_monotone_curve_2 = typename Md2::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; protected: - typedef Envelope_test_overlay_functor - Overlay_functor; - typedef Envelope_overlay_2 - Overlay_2; - - typedef Arr_walk_along_line_point_location - Md_point_location; - - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle - Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_const_iterator - Face_const_iterator; - typedef typename Minimization_diagram_2::Face_const_handle - Face_const_handle; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Hole_iterator; - - typedef typename Minimization_diagram_2::Dcel::Face_data_iterator - Face_data_iterator; - - typedef std::pair - Intersection_curve; + using Overlay_functor = Envelope_test_overlay_functor; + using Overlay_2 = Envelope_overlay_2; + + using Md2_point_location = Arr_walk_along_line_point_location; + + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Vertex_handle = typename Md2::Vertex_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Face_handle = typename Md2::Face_handle; + using Face_const_iterator = typename Md2::Face_const_iterator; + using Face_const_handle = typename Md2::Face_const_handle; + using Face_iterator = typename Md2::Face_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Hole_iterator = typename Md2::Inner_ccb_iterator; + + using Face_data_iterator = typename Md2::Dcel::Face_data_iterator; + + using Multiplicity = typename EnvelopeTraits_3::Multiplicity; + using Intersection_curve = std::pair; public: // c'tor @@ -99,27 +87,22 @@ class Envelope_triangles_test_3 { // virtual destructor. virtual ~Envelope_triangles_test_3() { } - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2 &result) - { - if (begin == end) - return; // result is empty + Minimization_diagram_2& result) { + if (begin == end) return; // result is empty std::vector surfaces; - SurfaceIterator si = begin; - for (; si != end; ++si) - surfaces.push_back(*si); + for (auto si = begin; si != end; ++si) surfaces.push_back(*si); - Md_point_location pl(result); + Md2_point_location pl(result); std::size_t number_of_surfaces = surfaces.size(); std::list curves_col; std::list points_col; - for(std::size_t i=0; i(&(*bit)); + const auto* boundary_cv = std::get_if(&(*bit)); assert(boundary_cv!=nullptr); curves_col.push_back(boundary_cv->first); } @@ -147,8 +130,7 @@ class Envelope_triangles_test_3 { (cur_surface, prev_surface, std::back_inserter(inter_objs)); // we collect all intersections and use sweep to insert them - for(std::size_t k=0; k(&inter_objs[k])) { #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "intersection between surfaces is a point: " @@ -157,7 +139,8 @@ class Envelope_triangles_test_3 { //insert_vertex(result, point, pl); points_col.push_back(*point); } - else if (const Intersection_curve* curve = std::get_if(&inter_objs[k])) { + else if (const auto* curve = + std::get_if(&inter_objs[k])) { #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl; @@ -165,26 +148,22 @@ class Envelope_triangles_test_3 { curves_col.push_back(curve->first); //insert(result, curve.first, pl); } - else - { - assert_msg(false, "wrong intersection type"); - } + else assert_msg(false, "wrong intersection type"); } } } #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "inserting the curves: " << std::endl; - typename std::list::iterator curves_it = curves_col.begin(); - for(; curves_it != curves_col.end(); ++curves_it) + for(auto curves_it = curves_col.begin(); curves_it != curves_col.end(); + ++curves_it) std::cout << *curves_it << std::endl; #endif // insert the curves insert(result, curves_col.begin(), curves_col.end()); // insert the points - typename std::list::iterator pit = points_col.begin(); - for (; pit != points_col.end(); ++pit) + for (auto pit = points_col.begin(); pit != points_col.end(); ++pit) insert_point(result, *pit, pl); m_result = &result; @@ -193,8 +172,7 @@ class Envelope_triangles_test_3 { // are minimal over it. // update vertices' data - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; // first we find the surfaces that are defined over the vertex std::list defined_surfaces; @@ -210,8 +188,8 @@ class Envelope_triangles_test_3 { } // update edges' data - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi, ++hi) { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; // first we find the surfaces that are defined over the edge std::list defined_surfaces; @@ -229,12 +207,11 @@ class Envelope_triangles_test_3 { // init current face for caching of computation current_face = Face_handle(); - Face_iterator fi; - for (fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; // first we find the surfaces that are defined over the face std::list defined_surfaces; - for(std::size_t i=0; iis_unbounded()) { + if (! fh->is_unbounded()) { Point_2 inside_test = compute_point_inside_face(test_env, fh); auto pl_obj = pl.locate(inside_test); // faces of env must contain the faces of test @@ -275,10 +250,9 @@ class Envelope_triangles_test_3 { // compare the 2 envelopes by overlaying them, and then comparing the // surfaces over the faces of the result map // if faces_only = false we also compare the data over the edges & vertices - bool compare_lu_envelopes_test2(Minimization_diagram_2 &test_env, - Minimization_diagram_2 &env, - bool /* faces_only */ = true) - { + bool compare_lu_envelopes_test2(Minimization_diagram_2& test_env, + Minimization_diagram_2& env, + bool /* faces_only */ = true) { Minimization_diagram_2 overlay_map; // overlay the 2 maps, the overlay test functor does all the comparisons overlay(test_env, env, overlay_map); @@ -286,27 +260,23 @@ class Envelope_triangles_test_3 { } protected: - // fill the vertex with the surface on the envelope // all the surfaces are known to be defined over the vertex' point - template + template void set_minimum_over_vertex(Vertex_handle v, SurfaceIterator begin, - SurfaceIterator end) - { - if (begin == end) - v->set_no_data(); + SurfaceIterator end) { + if (begin == end) v->set_no_data(); else { - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the others - v->set_data(*si); + v->set_env_data(*si); ++si; for (; si != end; ++si) { Comparison_result cr = - traits.compare_z_at_xy_3_object()(v->point(), v->get_data(), *si); - if (cr == EQUAL) - v->add_data(*si); - else if (cr == LARGER) - v->set_data(*si); // this erases all surfaces from vertex's list + traits.compare_z_at_xy_3_object()(v->point(), v->get_env_data(), *si); + if (cr == EQUAL) v->add_data(*si); + // this erases all surfaces from vertex's list + else if (cr == LARGER) v->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -314,59 +284,53 @@ class Envelope_triangles_test_3 { // fill the edge with the surface on the envelope // all the surfaces are known to be defined over the edge's curve - template + template void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, - SurfaceIterator end) - { - if (begin == end) - h->set_no_data(); + SurfaceIterator end) { + if (begin == end) h->set_no_data(); else { - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the others - h->set_data(*si); + h->set_env_data(*si); ++si; for (; si != end; ++si) { Comparison_result cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge, - h->get_data(), *si); - if (cr == EQUAL) - h->add_data(*si); - else if (cr == LARGER) - h->set_data(*si); // this erases all surfaces from halfedge's list + h->get_env_data(), *si); + if (cr == EQUAL) h->add_data(*si); + // this erases all surfaces from halfedge's list + else if (cr == LARGER) h->set_env_data(*si); // else - new surface has no affect on the envelope } // set twin's data - h->twin()->set_data(h->begin_data(), h->end_data()); + h->twin()->set_env_data(h->begin_data(), h->end_data()); } } // fill the face with the surface on the envelope // the surfaces are known to not intersect inside the face // (but might intersect on its edges) - template + template void set_minimum_over_face(Face_handle face, SurfaceIterator begin, - SurfaceIterator end) - { + SurfaceIterator end) { if (face->is_unbounded() || begin == end) { // a special case - no surface over the unbounded face, and when there // are no surfaces at all face->set_no_data(); } else { - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the // others - face->set_data(*si); + face->set_env_data(*si); ++si; for (; si != end; ++si) { Comparison_result cr = - compare_surfaces_over_face(face, face->get_data(), *si); - if (cr == EQUAL) - face->add_data(*si); - else if (cr == LARGER) - face->set_data(*si); // this erases all surfaces from face's list + compare_surfaces_over_face(face, face->get_env_data(), *si); + if (cr == EQUAL) face->add_data(*si); + // this erases all surfaces from face's list + else if (cr == LARGER) face->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -379,8 +343,7 @@ class Envelope_triangles_test_3 { Comparison_result compare_surfaces_over_face(Face_handle face, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) - { + const Xy_monotone_surface_3& surf2) { Comparison_result result2 = compare_surfaces_over_face_v2(face, surf1, surf2); @@ -407,8 +370,7 @@ class Envelope_triangles_test_3 { Comparison_result compare_surfaces_over_face_v1(const Face_handle& face, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) - { + const Xy_monotone_surface_3& surf2) { // TODO: this works for triangles, but not for general surfaces // in the general case, should use surface_compare_on_right and @@ -416,7 +378,7 @@ class Envelope_triangles_test_3 { // we iterate over the vertices of the face, and look for one that the // surfaces are not equal above it. (if doesn't exist, then the surfaces // overlap) - assert(!face->is_unbounded()); + assert(! face->is_unbounded()); Comparison_result cur_res; Ccb_halfedge_circulator hec = face->outer_ccb(); Ccb_halfedge_circulator hec_begin = hec; @@ -448,10 +410,9 @@ class Envelope_triangles_test_3 { // this version also works only for linear surfaces Comparison_result compare_surfaces_over_face_v2(const Face_handle& face, - const Xy_monotone_surface_3 &surf1, - const Xy_monotone_surface_3& surf2) - { - assert(!face->is_unbounded()); + const Xy_monotone_surface_3& surf1, + const Xy_monotone_surface_3& surf2) { + assert(! face->is_unbounded()); Comparison_result cur_res; if (face != current_face) compute_point_in_current_face(face); @@ -468,11 +429,9 @@ class Envelope_triangles_test_3 { // check if the surface is defines over the edge bool is_surface_defined_over_edge(const Halfedge_handle& h, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // check it over a point inside the edge's curve - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); bool result = traits.is_defined_over_object()(current_point_inside_edge, surf); @@ -481,11 +440,10 @@ class Envelope_triangles_test_3 { // check if the surface is defines over the face bool is_surface_defined_over_face(const Face_handle& face, - Xy_monotone_surface_3 &surf) + Xy_monotone_surface_3& surf) { // we always have bounded surfaces - if (face->is_unbounded()) - return false; + if (face->is_unbounded()) return false; bool result2 = is_surface_defined_over_face_v2(face, surf); @@ -505,16 +463,14 @@ class Envelope_triangles_test_3 { // check if the surface is defines over the face // this is version 1 which check all the vertices of the face bool is_surface_defined_over_face_v1(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // for now, we go over all the vertices of the face - typename Traits::Is_defined_over is_defined_over = - traits.is_defined_over_object(); + auto is_defined_over = traits.is_defined_over_object(); // check vertices on the outer ccb bool result = true; - if (!face->is_unbounded()) { + if (! face->is_unbounded()) { Ccb_halfedge_circulator hec = face->outer_ccb(); Ccb_halfedge_circulator hec_begin = hec; do { @@ -522,7 +478,7 @@ class Envelope_triangles_test_3 { bool tmp_result = is_defined_over(target_2,surf); #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 - std::cout << "is define over returned " << tmp_result << std::endl; + std::cout << "is define over returned " << tmp_result << std::endl; #endif result &= tmp_result; @@ -530,8 +486,7 @@ class Envelope_triangles_test_3 { } while(hec != hec_begin && result); } - if (result == false) - return result; + if (result == false) return result; // check vertices on holes boundary Hole_iterator hi; @@ -549,8 +504,7 @@ class Envelope_triangles_test_3 { result &= tmp_result; hec++; } while(hec != hec_begin && result); - if (result == false) - return result; + if (result == false) return result; } return result; @@ -559,8 +513,7 @@ class Envelope_triangles_test_3 { // check if the surface is defines over the face // this is version 2 which check the point inside the face bool is_surface_defined_over_face_v2(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { if (face != current_face) compute_point_in_current_face(face); @@ -570,10 +523,9 @@ class Envelope_triangles_test_3 { } // compute a point inside the face of the arranegement - Point_2 compute_point_inside_face(Minimization_diagram_2 &env, - Face_handle face) - { - assert(!face->is_unbounded()); + Point_2 compute_point_inside_face(Minimization_diagram_2& env, + Face_handle face) { + assert(! face->is_unbounded()); #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "in compute point inside face" << std::endl; @@ -584,7 +536,7 @@ class Envelope_triangles_test_3 { Ccb_halfedge_circulator hec_begin = hec; bool found = false; do { - if (!traits.is_vertical_2_object()(hec->curve())) { + if (! traits.is_vertical_2_object()(hec->curve())) { found = true; continue; } @@ -611,17 +563,15 @@ class Envelope_triangles_test_3 { (found_hh->curve()))) shoot_up = false; - Md_point_location pl(env); + Md2_point_location pl(env); Object shoot_obj; Halfedge_const_handle shoot_hh; Vertex_const_handle shoot_vh; Point_2 shoot_target; - if (shoot_up) - shoot_obj = pl.ray_shoot_up(shoot_source); - else - shoot_obj = pl.ray_shoot_down(shoot_source); + if (shoot_up) shoot_obj = pl.ray_shoot_up(shoot_source); + else shoot_obj = pl.ray_shoot_down(shoot_source); if (assign(shoot_hh, shoot_obj)) { shoot_target = @@ -630,8 +580,7 @@ class Envelope_triangles_test_3 { else if (assign(shoot_vh, shoot_obj)) { shoot_target = (env.non_const_handle(shoot_vh))->point(); } - else - CGAL_error(); // it cannot be the unbounded face + else CGAL_error(); // it cannot be the unbounded face Point_2 res_point = traits.construct_middle_point(shoot_source, shoot_target); @@ -652,16 +601,14 @@ class Envelope_triangles_test_3 { // compute a point inside the face saved in current_face // and put the result into current_point - void compute_point_in_current_face(Face_handle face) - { + void compute_point_in_current_face(Face_handle face) { current_face = face; current_point = compute_point_inside_face(*m_result, current_face); } // compute a point inside the edge saved in current_edge // and put the result into current_point_inside_edge - void compute_point_in_current_edge(Halfedge_handle h) - { + void compute_point_in_current_edge(Halfedge_handle h) { current_edge = h; current_point_inside_edge = traits.construct_middle_point(h->curve()); }