From 27965c56e8362da9ee1d2317cc4ec86059c73909 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 11 Nov 2020 18:47:09 +0000 Subject: [PATCH 1/2] Move code closer to useage and convert to if --- .../include/CGAL/Nef_S2/sphere_predicates.h | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h b/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h index b5655144033..996b47bce23 100644 --- a/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h +++ b/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h @@ -84,30 +84,15 @@ int spherical_compare(const Sphere_point& p1, const Sphere_point& p2, int axis, int pos) { - Sphere_point pS, pN; - CGAL_assertion(axis>=0 && axis<=2); - switch(axis) { - case 0: - pS=Sphere_point(0,-1,0); - // pN=Sphere_point(0,1,0); - break; - case 1: - pS=Sphere_point(0,0,1); - // pN=Sphere_point(0,0,-1); - break; - case 2: - pS=Sphere_point(0,-1,0); - // pN=Sphere_point(0,1,0); - break; - } typename R::Direction_3 d1(p1-CGAL::ORIGIN), d2(p2-CGAL::ORIGIN); if (d1 == d2) return 0; + + CGAL_assertion(axis>=0 && axis<=2); if(is_south(p1,axis) || is_north(p2,axis)) return -1; if(is_south(p2,axis) || is_north(p1,axis)) return 1; - // if (d1 == dS || d2 == dN) return -1; - // if (d1 == dN || d2 == dS) return 1; + // now no more special cases if (axis==0 && (p1.hx()==static_cast(0) && p2.hx()==static_cast(0))) { @@ -133,7 +118,11 @@ int spherical_compare(const Sphere_point& p1, // now s1 == s2 return s1 * CGAL::spherical_orientation(p1,Sphere_point(0,0,1),p2); } - int sor = CGAL::spherical_orientation(pS,p1,p2); + int sor; + if(axis==1) + sor = CGAL::spherical_orientation(Sphere_point(0, 0, 1),p1,p2); + else + sor = CGAL::spherical_orientation(Sphere_point(0,-1, 0),p1,p2); if ( sor ) return sor; if(axis==0) return CGAL::spherical_orientation(Sphere_point(0,0,pos),p2,p1); From 31e46384ca60408edc32fc0cf9283d61e26738e0 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 11 Nov 2020 18:47:25 +0000 Subject: [PATCH 2/2] Remove commented-out code --- .../include/CGAL/Nef_S2/sphere_predicates.h | 92 ------------------- 1 file changed, 92 deletions(-) diff --git a/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h b/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h index 996b47bce23..01316e8951f 100644 --- a/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h +++ b/Nef_S2/include/CGAL/Nef_S2/sphere_predicates.h @@ -197,98 +197,6 @@ $h^{0+}$ then we return a trivial segment. */ -/* -template -int Sphere_segment:: -intersection(const CGAL::Sphere_circle& c, std::vector >& s) const { - - CGAL_NEF_TRACEN(" intersection "<<*this<<" "< i1 = CGAL::intersection(ptr()->c_,c); - if ( !has_on(i1) ) - i1 = i1.antipode(); - s.push_back(Sphere_segment(source(),i1,sphere_circle())); - s.push_back(Sphere_segment(i1,target(),sphere_circle())); - return 2; - } - else if ( or1 == CGAL::ON_ORIENTED_BOUNDARY && - or2 == CGAL::ON_ORIENTED_BOUNDARY ) { - // if both ends of $s$ are part of $h$ then $s$ is a halfcircle or - // $s$ is fully part of $h$. In this case we have to check if the - // halfcircle is not part of $h^-$. This can be formulated by an - // orientation test of the point $p$ at the tip of the normal of - // |s.sphere_circle()| with respect to the plane through the - // endpoints of $s$ and the tip of the normal of $h$. - CGAL_NEF_TRACEN(" both in plane"); - s.push_back(*this); - return 1; - } - else if ( or1 != CGAL::ON_NEGATIVE_SIDE && - or2 != CGAL::ON_NEGATIVE_SIDE ) { - // this case covers the endpoints of $s$ as part of the closed - // oriented halfspace $h^{0+}$. At least one is part of - // $h^{+}$. If $s$ is not long then the segment must be fully part - // of $h^{0+}$. Otherwise if $s$ is long, then we at both ends - // there are subsegments as part of $h^{0+}$ (one might be - // degenerate). - if ( is_long() ) { - Sphere_point i1 = CGAL::intersection(ptr()->c_,c); - Sphere_point i2 = i1.antipode(); - Sphere_segment so(i1,i2,sphere_circle()); - if ( so.has_on(source()) && so.has_on(target()) ) - std::swap(i1,i2); - // now source(),i1,i2,target() are circularly ordered - s.push_back(Sphere_segment(source(),i1,sphere_circle())); - s.push_back(Sphere_segment(i1,i2,sphere_circle())); - s.push_back(Sphere_segment(i2,target(),sphere_circle())); - // CGAL_NEF_TRACEN(" both >= plane, long "<= plane, short "); - s.push_back(*this); - return 1; - } - else if ( or1 != CGAL::ON_POSITIVE_SIDE && - or2 != CGAL::ON_POSITIVE_SIDE ) { - // either both endpoints of $s$ are in $h^-$ or one is in $h^-$ - // and one on $h^0$. - if ( is_long() ) { - Sphere_point i1 = CGAL::intersection(ptr()->c_,c); - Sphere_point i2 = i1.antipode(); - Sphere_segment so(i1,i2,sphere_circle()); - // CGAL_NEF_TRACEN(" both <= plane, long"< int Sphere_segment:: intersection(const CGAL::Sphere_circle& c,