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/Envelope_3/Envelope_base.h>
|
||||
|
||||
//#define CGAL_ENV_SPHERES_TRAITS_CACHE_POINT_ON
|
||||
|
||||
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 ConicTraits_2>
|
||||
|
|
@ -68,31 +58,14 @@ public:
|
|||
typedef typename Alg_kernel::Point_2 Alg_point_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
|
||||
typedef Surface_3 Xy_monotone_surface_3;
|
||||
typedef unsigned int Multiplicity;
|
||||
protected:
|
||||
typedef std::pair<X_monotone_curve_2, Intersection_type> 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
|
||||
typedef std::pair<X_monotone_curve_2,
|
||||
Multiplicity> Intersection_curve;
|
||||
|
||||
public:
|
||||
class Make_xy_monotone_3
|
||||
|
|
@ -854,23 +827,6 @@ public:
|
|||
Algebraic(1),
|
||||
A1,
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
@ -1112,21 +1068,7 @@ public:
|
|||
const Xy_monotone_surface_3& s) const
|
||||
{
|
||||
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
|
||||
const Algebraic x1 = p.x(), y1 = p.y();
|
||||
|
||||
|
|
@ -1166,11 +1108,6 @@ public:
|
|||
else
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -1316,13 +1253,6 @@ public:
|
|||
|
||||
protected:
|
||||
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);
|
||||
}
|
||||
|
||||
//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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#ifndef CGAL_ENV_TRIANGLE_TRAITS_3_H
|
||||
#define CGAL_ENV_TRIANGLE_TRAITS_3_H
|
||||
|
||||
#include <CGAL/Handle_for.h>
|
||||
#include <CGAL/Object.h>
|
||||
#include <CGAL/enum.h>
|
||||
#include <CGAL/Bbox_3.h>
|
||||
|
|
@ -35,13 +34,6 @@
|
|||
|
||||
#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
|
||||
|
||||
template <class Kernel_> class Env_triangle_3;
|
||||
|
|
@ -64,7 +56,7 @@ public:
|
|||
/*!
|
||||
* \class Representation of a 3d triangle with cached data.
|
||||
*/
|
||||
class _Triangle_cached_3 //: public Ref_counted
|
||||
class _Triangle_cached_3
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -260,10 +252,7 @@ public:
|
|||
*/
|
||||
const Point_3& vertex(unsigned int i) const
|
||||
{
|
||||
if (i > 2)
|
||||
i = i % 3;
|
||||
CGAL_assertion(i>=0 && i<=2);
|
||||
return vertices[i];
|
||||
return vertices[i%3];
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -336,25 +325,8 @@ protected:
|
|||
typedef typename Kernel::Line_3 Line_3;
|
||||
typedef typename Kernel::Direction_3 Direction_3;
|
||||
|
||||
#ifdef CGAL_ENV_TRIANGLES_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 &&
|
||||
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;
|
||||
typedef std::pair<X_monotone_curve_2,
|
||||
Multiplicity> Intersection_curve;
|
||||
public:
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
@ -719,65 +691,14 @@ public:
|
|||
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;
|
||||
if (!ip1_found || !ip2_found)
|
||||
{
|
||||
// should calculate at least one point
|
||||
|
||||
// Compute the intersetion between the vertical line and the given
|
||||
// surfaces
|
||||
if (!ip1_found)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
// Compute the intersetion between the vertical line and the given
|
||||
// surfaces
|
||||
Point_3 ip1 = parent->envelope_point_of_surface(p, surf1);
|
||||
Point_3 ip2 = parent->envelope_point_of_surface(p, surf2);
|
||||
|
||||
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
|
||||
|
|
@ -921,12 +842,6 @@ public:
|
|||
|
||||
Sign s2 = CGAL_NTS sign(-b3*x1+a3*y1-(-b3*x2+a3*y2));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
#ifdef CGAL_ENV_TRIANGLES_TRAITS_CACHE_POINT_ON
|
||||
mutable Surface_point_cache point_on_cache;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue