Merge pull request #3510 from sloriot/NefS2_fixes

Various Nef_S2 fixes
This commit is contained in:
Laurent Rineau 2018-12-19 15:45:59 +01:00
commit 12c8319a48
2 changed files with 25 additions and 4 deletions

View File

@ -71,6 +71,23 @@ VVector convert(const CGAL::Vector_3<R>& v)
CGAL::to_double(v.y()),
CGAL::to_double(v.z())); }
template <typename R>
VVector normalize_and_convert(const CGAL::Vector_3<R>& v)
{
typename R::FT xa = CGAL::abs(v.x());
typename R::FT ya = CGAL::abs(v.y());
typename R::FT za = CGAL::abs(v.z());
typename R::FT m = (std::max)((std::max)(xa,ya),za);
if (m==0) {
return VVector(0,0,0);
} else {
double xd = CGAL::to_double(v.x()/m);
double yd = CGAL::to_double(v.y()/m);
double zd = CGAL::to_double(v.z()/m);
VVector u(xd,yd,zd);
return u / CGAL_NTS sqrt(u*u) ; // normalize
}
}
const double refinement_angle = 0.1;
const double shrink_fac = 0.995;
@ -80,8 +97,7 @@ class Approximator {
public:
static VPoint approximate(const CGAL::Sphere_point<R>& p) {
VVector v = convert(p-CGAL::ORIGIN);
v = v / CGAL_NTS sqrt(v*v) ; // normalize
VVector v = normalize_and_convert(p-CGAL::ORIGIN);
return CGAL::ORIGIN+v;
}

View File

@ -350,6 +350,11 @@ public:
f->mark() == true);
}
bool is_sphere() const
{
return is_plane();
}
void extract_complement()
{ CGAL_NEF_TRACEN("extract complement");
if ( this->is_shared() ) clone_rep();
@ -375,7 +380,7 @@ public:
SHalfedge_iterator e;
CGAL_forall_svertices(v,D) v->mark() = false;
CGAL_forall_sedges(e,D) e->mark() = false;
if ( D.has_sloop() ) D.shalfloop()->mark() = false;
if ( D.has_shalfloop() ) D.shalfloop()->mark() = false;
D.simplify();
}
@ -390,7 +395,7 @@ public:
CGAL_forall_svertices(v,D) v->mark() = true;
CGAL_forall_sedges(e,D) e->mark() = true;
CGAL_forall_sfaces(f,D) f->mark() = false;
if ( D.has_sloop() ) D.shalfloop()->mark() = D.shalfoop()->twin() = true;
if ( D.has_shalfloop() ) D.shalfloop()->mark() = D.shalfoop()->twin()->mark() = true;
D.simplify();
}