Merge pull request #5157 from GilesBathgate/sphere-predicates-tidy

Possible technical debt in sphere_predicates.h
This commit is contained in:
Laurent Rineau 2021-02-18 21:02:40 +01:00
commit 85ca8bf2d7
1 changed files with 8 additions and 111 deletions

View File

@ -84,30 +84,15 @@ int spherical_compare(const Sphere_point<R>& p1,
const Sphere_point<R>& p2,
int axis, int pos) {
Sphere_point<R> pS, pN;
CGAL_assertion(axis>=0 && axis<=2);
switch(axis) {
case 0:
pS=Sphere_point<R>(0,-1,0);
// pN=Sphere_point<R>(0,1,0);
break;
case 1:
pS=Sphere_point<R>(0,0,1);
// pN=Sphere_point<R>(0,0,-1);
break;
case 2:
pS=Sphere_point<R>(0,-1,0);
// pN=Sphere_point<R>(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<typename R::RT>(0) &&
p2.hx()==static_cast<typename R::RT>(0))) {
@ -133,7 +118,11 @@ int spherical_compare(const Sphere_point<R>& p1,
// now s1 == s2
return s1 * CGAL::spherical_orientation(p1,Sphere_point<R>(0,0,1),p2);
}
int sor = CGAL::spherical_orientation(pS,p1,p2);
int sor;
if(axis==1)
sor = CGAL::spherical_orientation(Sphere_point<R>(0, 0, 1),p1,p2);
else
sor = CGAL::spherical_orientation(Sphere_point<R>(0,-1, 0),p1,p2);
if ( sor ) return sor;
if(axis==0)
return CGAL::spherical_orientation(Sphere_point<R>(0,0,pos),p2,p1);
@ -208,98 +197,6 @@ $h^{0+}$ then we return a trivial segment.
*/
/*
template <typename R>
int Sphere_segment<R>::
intersection(const CGAL::Sphere_circle<R>& c, std::vector<Sphere_segment<R> >& s) const {
CGAL_NEF_TRACEN(" intersection "<<*this<<" "<<c);
if ( is_degenerate() ) {
CGAL_NEF_TRACEN(" degenerate");
s.push_back(*this);
return 1;
}
CGAL::Oriented_side or1 = c.oriented_side(source());
CGAL::Oriented_side or2 = c.oriented_side(target());
CGAL_NEF_TRACEN(" Orientation " << or1 << " " << or2);
if ( or1 == CGAL::opposite(or2) && or1 != or2 ) {
// it is sure that $s$ intersects $h$ in its interior. the
// question is which part is in the halfspace $h^+$.
CGAL_NEF_TRACEN(" opposite");
Sphere_point<R> i1 = CGAL::intersection(ptr()->c_,c);
if ( !has_on(i1) )
i1 = i1.antipode();
s.push_back(Sphere_segment<R>(source(),i1,sphere_circle()));
s.push_back(Sphere_segment<R>(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<R> i1 = CGAL::intersection(ptr()->c_,c);
Sphere_point<R> i2 = i1.antipode();
Sphere_segment<R> 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 "<<s1<<s2);
return 3;
} // now short:
CGAL_NEF_TRACEN(" both >= 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<R> i1 = CGAL::intersection(ptr()->c_,c);
Sphere_point<R> i2 = i1.antipode();
Sphere_segment so(i1,i2,sphere_circle());
// CGAL_NEF_TRACEN(" both <= plane, long"<<so);
if ( so.has_on(source()) && so.has_on(target()) )
{ so = so.complement(); }
// CGAL_NEF_TRACEN(" both <= plane, long"<<so);
s.push_back(Sphere_segment(source(),so.source(),sphere_circle()));
s.push_back(so);
s.push_back(Sphere_segment(so.target(),target(),sphere_circle()));
return 3;
} // now short
CGAL_NEF_TRACEN(" both <= plane, short");
s.push_back(*this);
return 1;
}
CGAL_error_msg("Oops, forgot some case.");
return -1;
}
*/
template <typename R>
int Sphere_segment<R>::
intersection(const CGAL::Sphere_circle<R>& c,