mirror of https://github.com/CGAL/cgal
clean up
This commit is contained in:
parent
77cc8cdb3c
commit
5aa38bc9eb
|
|
@ -27,19 +27,9 @@
|
||||||
#include <CGAL/functions_on_signs.h>
|
#include <CGAL/functions_on_signs.h>
|
||||||
#include <CGAL/Envelope_3/Envelope_base.h>
|
#include <CGAL/Envelope_3/Envelope_base.h>
|
||||||
|
|
||||||
//#define CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
//inline
|
|
||||||
//Sign
|
|
||||||
//operator*(const Sign &s1, const Sign &s2)
|
|
||||||
//{
|
|
||||||
// if ( s1 == ZERO || s2 == ZERO ) return ZERO;
|
|
||||||
// if ( s1 == s2 ) return POSITIVE;
|
|
||||||
// return NEGATIVE;
|
|
||||||
//}
|
|
||||||
|
|
||||||
template <class Kernel_> class Env_sphere_3;
|
template <class Kernel_> class Env_sphere_3;
|
||||||
|
|
||||||
template <class ConicTraits_2>
|
template <class ConicTraits_2>
|
||||||
|
|
@ -68,31 +58,14 @@ public:
|
||||||
typedef typename Alg_kernel::Point_2 Alg_point_2;
|
typedef typename Alg_kernel::Point_2 Alg_point_2;
|
||||||
typedef typename Alg_kernel::Circle_2 Alg_circle_2;
|
typedef typename Alg_kernel::Circle_2 Alg_circle_2;
|
||||||
|
|
||||||
// typedef typename Rat_kernel::Sphere_3 Surface_3;
|
|
||||||
typedef Env_sphere_3<Rat_kernel> Surface_3;
|
typedef Env_sphere_3<Rat_kernel> Surface_3;
|
||||||
|
|
||||||
// here we refer to the lower part of the sphere only
|
// here we refer to the lower part of the sphere only
|
||||||
typedef Surface_3 Xy_monotone_surface_3;
|
typedef Surface_3 Xy_monotone_surface_3;
|
||||||
typedef unsigned int Multiplicity;
|
typedef unsigned int Multiplicity;
|
||||||
protected:
|
protected:
|
||||||
typedef std::pair<X_monotone_curve_2, Intersection_type> Intersection_curve;
|
typedef std::pair<X_monotone_curve_2,
|
||||||
|
Multiplicity> Intersection_curve;
|
||||||
#ifdef CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
|
||||||
// caching the computation of a surface 3d point from a 2d point
|
|
||||||
typedef std::pair<Xy_monotone_surface_3, Point_2> Surface_point_pair;
|
|
||||||
struct Less_surface_point_pair
|
|
||||||
{
|
|
||||||
bool operator() (const Surface_point_pair& sp1,
|
|
||||||
const Surface_point_pair& sp2) const
|
|
||||||
{
|
|
||||||
// Compare the pairs of IDs lexicographically.
|
|
||||||
return (sp1.first < sp2.first ||
|
|
||||||
(sp1.first == sp2.first && Alg_kernel().less_xy_2_object()(sp1.second,sp2.second)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::map<Surface_point_pair, Algebraic,
|
|
||||||
Less_surface_point_pair> Surface_point_cache;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class Make_xy_monotone_3
|
class Make_xy_monotone_3
|
||||||
|
|
@ -854,23 +827,6 @@ public:
|
||||||
Algebraic(1),
|
Algebraic(1),
|
||||||
A1,
|
A1,
|
||||||
A2);
|
A2);
|
||||||
/*if (parent.get_envelope_type() == LOWER)
|
|
||||||
res = CGAL::sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(Algebraic(c_diff),
|
|
||||||
Algebraic(-1),
|
|
||||||
Algebraic(1),
|
|
||||||
A1,
|
|
||||||
A2);
|
|
||||||
else
|
|
||||||
res = CGAL::sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(Algebraic(c_diff),
|
|
||||||
Algebraic(1),
|
|
||||||
Algebraic(-1),
|
|
||||||
A1,
|
|
||||||
A2);*/
|
|
||||||
|
|
||||||
// if (parent.get_envelope_type() == LOWER)
|
|
||||||
// res = CGAL_NTS sign(c1 - CGAL::sqrt(A1) - c2 + CGAL::sqrt(A2));
|
|
||||||
// else
|
|
||||||
// res = CGAL_NTS sign(c1 + CGAL::sqrt(A1) - c2 - CGAL::sqrt(A2));
|
|
||||||
return Comparison_result(res);
|
return Comparison_result(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1112,20 +1068,6 @@ public:
|
||||||
const Xy_monotone_surface_3& s) const
|
const Xy_monotone_surface_3& s) const
|
||||||
{
|
{
|
||||||
Algebraic res;
|
Algebraic res;
|
||||||
#ifdef CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
|
||||||
// first try the cache:
|
|
||||||
typename Surface_point_cache::iterator cache_iter;
|
|
||||||
Surface_point_pair spair(const_cast<Xy_monotone_surface_3>(s), p);
|
|
||||||
|
|
||||||
std::cout << "before find" << std::endl;
|
|
||||||
cache_iter = point_on_cache.find(spair);
|
|
||||||
std::cout << "after find" << std::endl;
|
|
||||||
if (cache_iter != point_on_cache.end())
|
|
||||||
{
|
|
||||||
res = (*cache_iter).second;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// the point coordinates
|
// the point coordinates
|
||||||
const Algebraic x1 = p.x(), y1 = p.y();
|
const Algebraic x1 = p.x(), y1 = p.y();
|
||||||
|
|
@ -1166,11 +1108,6 @@ public:
|
||||||
else
|
else
|
||||||
res = ((comp == LARGER) ? zs[0] : zs[1]);
|
res = ((comp == LARGER) ? zs[0] : zs[1]);
|
||||||
|
|
||||||
#ifdef CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
|
||||||
// update the cache
|
|
||||||
point_on_cache[spair] = res;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1316,13 +1253,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_is_lower;
|
bool m_is_lower;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
#ifdef CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
|
||||||
mutable Surface_point_cache point_on_cache;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -1423,14 +1353,6 @@ InputStream& operator>> (InputStream& is, Env_sphere_3<Kernel>& s)
|
||||||
return (is);
|
return (is);
|
||||||
}
|
}
|
||||||
|
|
||||||
//template <class Kernel>
|
|
||||||
//bool
|
|
||||||
//operator<(const CGAL::Sphere_3<Kernel> &a,
|
|
||||||
// const CGAL::Sphere_3<Kernel> &b)
|
|
||||||
//{
|
|
||||||
// return (a.center() < b.center() ||
|
|
||||||
// (a.center() == b.center() && a.squared_radius() < b.squared_radius()));
|
|
||||||
//}
|
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#ifndef CGAL_ENV_TRIANGLE_TRAITS_3_H
|
#ifndef CGAL_ENV_TRIANGLE_TRAITS_3_H
|
||||||
#define CGAL_ENV_TRIANGLE_TRAITS_3_H
|
#define CGAL_ENV_TRIANGLE_TRAITS_3_H
|
||||||
|
|
||||||
#include <CGAL/Handle_for.h>
|
|
||||||
#include <CGAL/Object.h>
|
#include <CGAL/Object.h>
|
||||||
#include <CGAL/enum.h>
|
#include <CGAL/enum.h>
|
||||||
#include <CGAL/Bbox_3.h>
|
#include <CGAL/Bbox_3.h>
|
||||||
|
|
@ -35,13 +34,6 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// this cache doesn't help much
|
|
||||||
//#define CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
#include <map>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
CGAL_BEGIN_NAMESPACE
|
||||||
|
|
||||||
template <class Kernel_> class Env_triangle_3;
|
template <class Kernel_> class Env_triangle_3;
|
||||||
|
|
@ -64,7 +56,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* \class Representation of a 3d triangle with cached data.
|
* \class Representation of a 3d triangle with cached data.
|
||||||
*/
|
*/
|
||||||
class _Triangle_cached_3 //: public Ref_counted
|
class _Triangle_cached_3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -260,10 +252,7 @@ public:
|
||||||
*/
|
*/
|
||||||
const Point_3& vertex(unsigned int i) const
|
const Point_3& vertex(unsigned int i) const
|
||||||
{
|
{
|
||||||
if (i > 2)
|
return vertices[i%3];
|
||||||
i = i % 3;
|
|
||||||
CGAL_assertion(i>=0 && i<=2);
|
|
||||||
return vertices[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -336,25 +325,8 @@ protected:
|
||||||
typedef typename Kernel::Line_3 Line_3;
|
typedef typename Kernel::Line_3 Line_3;
|
||||||
typedef typename Kernel::Direction_3 Direction_3;
|
typedef typename Kernel::Direction_3 Direction_3;
|
||||||
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
typedef std::pair<X_monotone_curve_2,
|
||||||
// caching the computation of a surface 3d point from a 2d point
|
Multiplicity> Intersection_curve;
|
||||||
typedef std::pair<Xy_monotone_surface_3, Point_2> Surface_point_pair;
|
|
||||||
struct Less_surface_point_pair
|
|
||||||
{
|
|
||||||
bool operator() (const Surface_point_pair& sp1,
|
|
||||||
const Surface_point_pair& sp2) const
|
|
||||||
{
|
|
||||||
// Compare the pairs of IDs lexicographically.
|
|
||||||
return (sp1.first < sp2.first ||
|
|
||||||
(sp1.first == sp2.first &&
|
|
||||||
Kernel().less_xy_2_object()(sp1.second,sp2.second)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::map<Surface_point_pair, Point_3,
|
|
||||||
Less_surface_point_pair> Surface_point_cache;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef std::pair<X_monotone_curve_2, Multiplicity> Intersection_curve;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
|
@ -719,65 +691,14 @@ public:
|
||||||
return EQUAL;
|
return EQUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// these should contain the points on the surfaces that we need to
|
|
||||||
// compare for the envelope
|
|
||||||
Point_3 ip1, ip2;
|
|
||||||
bool ip1_found = false, ip2_found = false;
|
|
||||||
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
// first try the cache:
|
|
||||||
|
|
||||||
typename Surface_point_cache::iterator cache_iter;
|
|
||||||
Surface_point_pair spair1(surf1, p);
|
|
||||||
Surface_point_pair spair2(surf2, p);
|
|
||||||
|
|
||||||
cache_iter = parent->point_on_cache.find(spair1);
|
|
||||||
if (cache_iter != (parent->point_on_cache).end())
|
|
||||||
{
|
|
||||||
ip1 = (*cache_iter).second;
|
|
||||||
ip1_found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
cache_iter = parent->point_on_cache.find(spair2);
|
|
||||||
if (cache_iter != (parent->point_on_cache).end())
|
|
||||||
{
|
|
||||||
ip2 = (*cache_iter).second;
|
|
||||||
ip2_found = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Kernel k;
|
Kernel k;
|
||||||
if (!ip1_found || !ip2_found)
|
|
||||||
{
|
|
||||||
// should calculate at least one point
|
|
||||||
|
|
||||||
// Compute the intersetion between the vertical line and the given
|
// Compute the intersetion between the vertical line and the given
|
||||||
// surfaces
|
// surfaces
|
||||||
if (!ip1_found)
|
Point_3 ip1 = parent->envelope_point_of_surface(p, surf1);
|
||||||
{
|
Point_3 ip2 = parent->envelope_point_of_surface(p, surf2);
|
||||||
ip1 = parent->envelope_point_of_surface(p, surf1);
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
// update the cache
|
|
||||||
(parent->point_on_cache)[spair1] = ip1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ip2_found)
|
|
||||||
{
|
|
||||||
ip2 = parent->envelope_point_of_surface(p, surf2);
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
// update the cache
|
|
||||||
(parent->point_on_cache)[spair2] = ip2;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return k.compare_z_3_object()(ip1, ip2);
|
return k.compare_z_3_object()(ip1, ip2);
|
||||||
//// the answer changes when we compute lower/upper envelope
|
|
||||||
//if (parent->get_envelope_type() == LOWER)
|
|
||||||
// return k.compare_z_3_object()(ip1, ip2);
|
|
||||||
//else
|
|
||||||
// return k.compare_z_3_object()(ip2, ip1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check which of the surfaces is closer to the envelope at the xy
|
// check which of the surfaces is closer to the envelope at the xy
|
||||||
|
|
@ -921,12 +842,6 @@ public:
|
||||||
|
|
||||||
Sign s2 = CGAL_NTS sign(-b3*x1+a3*y1-(-b3*x2+a3*y2));
|
Sign s2 = CGAL_NTS sign(-b3*x1+a3*y1-(-b3*x2+a3*y2));
|
||||||
return (Comparison_result(s1 * s2));
|
return (Comparison_result(s1 * s2));
|
||||||
// the answer is reversed when computing upper envelope vs. lower
|
|
||||||
// envelope
|
|
||||||
/*if (parent->get_envelope_type() == LOWER)
|
|
||||||
return Comparison_result(s1 * s2);
|
|
||||||
else
|
|
||||||
return Comparison_result(s1 * s2 * -1); */
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1586,14 +1501,6 @@ public:
|
||||||
|
|
||||||
return (ip);
|
return (ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
|
||||||
mutable Surface_point_cache point_on_cache;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue