mirror of https://github.com/CGAL/cgal
removing AABB_filtered_traits_3.h and AABB_statically_filtered_traits_3.h
This commit is contained in:
parent
b5acb03946
commit
c68c64e727
|
|
@ -26,6 +26,9 @@
|
|||
#include <CGAL/AABB_tree/internal/Is_ray_intersection_geomtraits.h>
|
||||
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
|
||||
#include <CGAL/AABB_tree/internal/Remove_optional.h>
|
||||
#include <CGAL/Filtered_predicate.h>
|
||||
#include <CGAL/Filtered_kernel/internal/Static_filters/Static_filter_error.h>
|
||||
#include <CGAL/Filtered_kernel/internal/Static_filters/tools.h>
|
||||
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>
|
||||
#include <CGAL/Search_traits_3.h>
|
||||
|
||||
|
|
@ -124,6 +127,343 @@ public:
|
|||
Intersection_distance intersection_distance_object() const { return Intersection_distance(); }
|
||||
};
|
||||
|
||||
template<typename GeomTraits>
|
||||
class Compare_distance {
|
||||
typedef typename GeomTraits::Point_3 Point;
|
||||
typedef typename GeomTraits::FT FT;
|
||||
typedef typename GeomTraits::Boolean Boolean;
|
||||
|
||||
/// Bounding box type.
|
||||
typedef typename CGAL::Bbox_3 Bounding_box;
|
||||
public:
|
||||
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const
|
||||
{
|
||||
return do_intersect_sphere_iso_cuboid_3
|
||||
(GeomTraits().construct_sphere_3_object()
|
||||
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb) ?
|
||||
CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
|
||||
{
|
||||
return GeomTraits().do_intersect_3_object()
|
||||
(GeomTraits().construct_sphere_3_object()
|
||||
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr) ?
|
||||
CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
|
||||
{
|
||||
return GeomTraits().do_intersect_3_object()
|
||||
(GeomTraits().construct_sphere_3_object()(p, sq_distance),
|
||||
pr) ?
|
||||
CGAL::SMALLER :
|
||||
CGAL::LARGER;
|
||||
}
|
||||
|
||||
Boolean do_intersect_sphere_iso_cuboid_3(const typename GeomTraits::Sphere_3& sphere,
|
||||
const Bounding_box& box) const
|
||||
{
|
||||
typedef typename GeomTraits::FT FT;
|
||||
typedef typename GeomTraits::Point_3 Point;
|
||||
|
||||
const FT bxmin = box.xmin();
|
||||
const FT bymin = box.ymin();
|
||||
const FT bzmin = box.zmin();
|
||||
const FT bxmax = box.xmax();
|
||||
const FT bymax = box.ymax();
|
||||
const FT bzmax = box.zmax();
|
||||
|
||||
// Check that the minimum distance to the box is smaller than the radius, otherwise there is
|
||||
// no intersection. `distance` stays at 0 if the center is inside or on `rec`.
|
||||
|
||||
FT d = FT(0);
|
||||
FT distance = FT(0);
|
||||
const FT sr = typename GeomTraits::Compute_squared_radius_3()(sphere);
|
||||
|
||||
const Point center = typename GeomTraits::Construct_center_3()(sphere);
|
||||
typename GeomTraits::Cartesian_const_iterator_3 cci = typename GeomTraits::Construct_cartesian_const_iterator_3()(center);
|
||||
|
||||
if (*cci < bxmin)
|
||||
{
|
||||
d = bxmin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance = d;
|
||||
}
|
||||
else if (*cci > bxmax)
|
||||
{
|
||||
d = *cci - bxmax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance = d;
|
||||
}
|
||||
|
||||
cci++;
|
||||
if (*cci < bymin)
|
||||
{
|
||||
d = bymin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
else if (*cci > bymax)
|
||||
{
|
||||
d = *cci - bymax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
|
||||
cci++;
|
||||
if (*cci < bzmin)
|
||||
{
|
||||
d = bzmin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
else if (*cci > bzmax)
|
||||
{
|
||||
d = *cci - bzmax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
// Note that with the way the distance above is computed, the distance is '0' if the box strictly
|
||||
// contains the sphere. But since we use '>', we don't exit
|
||||
return (distance <= sr);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename GeomTraits, bool Has_filtered_predicates = internal::Has_filtered_predicates<GeomTraits>::value, bool Has_static_filters = internal::Has_static_filters<GeomTraits>::value>
|
||||
class Compare_distance_getter {};
|
||||
|
||||
template <typename GeomTraits>
|
||||
class Compare_distance_getter<GeomTraits, false, false> {
|
||||
// this class is in charge of checking what K provides (i.e., can we use filtered predicates, can we use statically filtered predicates, etc.)
|
||||
// depending on that it defines
|
||||
public:
|
||||
typedef Compare_distance<GeomTraits> type;
|
||||
static Compare_distance<GeomTraits> compare_distance_object() {
|
||||
return Compare_distance<GeomTraits>();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename GeomTraits>
|
||||
class Compare_distance_getter<GeomTraits, true, false> {
|
||||
// this class is in charge of checking what K provides (i.e., can we use filtered predicates, can we use statically filtered predicates, etc.)
|
||||
// depending on that it defines
|
||||
|
||||
typedef GeomTraits Kernel;
|
||||
|
||||
typedef typename Kernel::Exact_kernel EKernel;
|
||||
typedef typename Kernel::Approximate_kernel AKernel;
|
||||
typedef typename Kernel::C2E C2E;
|
||||
typedef typename Kernel::C2F C2F;
|
||||
|
||||
typedef Compare_distance<EKernel> Exact_functor;
|
||||
typedef Compare_distance<AKernel> Filtered_functor;
|
||||
|
||||
public:
|
||||
typedef Filtered_predicate<Exact_functor, Filtered_functor,
|
||||
C2E, C2F> Compare_distance_pred;
|
||||
typedef Compare_distance_pred type;
|
||||
|
||||
static Compare_distance_pred compare_distance_object() {
|
||||
return Compare_distance_pred(Exact_functor(), Filtered_functor());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename GeomTraits>
|
||||
class Compare_distance_getter<GeomTraits, true, true> {
|
||||
// this class is in charge of checking what K provides (i.e., can we use filtered predicates, can we use statically filtered predicates, etc.)
|
||||
// depending on that it defines
|
||||
class Statically_filtered_compare_distance {
|
||||
|
||||
typedef typename GeomTraits::Point_3 Point;
|
||||
typedef typename GeomTraits::FT FT;
|
||||
typedef typename GeomTraits::Boolean Boolean;
|
||||
|
||||
/// Bounding box type.
|
||||
typedef typename CGAL::Bbox_3 Bounding_box;
|
||||
public:
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const {
|
||||
return Compare_distance_getter<GeomTraits, true, false>::compare_distance_object()(p, pr, bound);
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const {
|
||||
return Compare_distance_getter<GeomTraits, true, false>::compare_distance_object()(p, pr, sq_distance);
|
||||
}
|
||||
|
||||
Comparison_result operator()(const Point& p, const Bounding_box& b, const Point& bound) const {
|
||||
Sphere_3 s = GeomTraits().construct_sphere_3_object()(p, GeomTraits().compute_squared_distance_3_object()(p, bound));
|
||||
CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") +
|
||||
std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
|
||||
internal::Static_filters_predicates::Get_approx<Point> get_approx; // Identity functor for all points
|
||||
const Point& c = s.center();
|
||||
|
||||
double scx, scy, scz, ssr;
|
||||
double bxmin = b.xmin(), bymin = b.ymin(), bzmin = b.zmin(),
|
||||
bxmax = b.xmax(), bymax = b.ymax(), bzmax = b.zmax();
|
||||
|
||||
if (internal::fit_in_double(get_approx(c).x(), scx) &&
|
||||
internal::fit_in_double(get_approx(c).y(), scy) &&
|
||||
internal::fit_in_double(get_approx(c).z(), scz) &&
|
||||
internal::fit_in_double(s.squared_radius(), ssr))
|
||||
{
|
||||
CGAL_BRANCH_PROFILER_BRANCH_1(tmp);
|
||||
|
||||
if ((ssr < 1.11261183279326254436e-293) || (ssr > 2.80889552322236673473e+306)) {
|
||||
CGAL_BRANCH_PROFILER_BRANCH_2(tmp);
|
||||
return Compare_distance_getter<GeomTraits, true, false>::compare_distance_object()(p, b, bound);
|
||||
}
|
||||
double distance = 0;
|
||||
double max1 = 0;
|
||||
double double_tmp_result = 0;
|
||||
double eps = 0;
|
||||
if (scx < bxmin)
|
||||
{
|
||||
double bxmin_scx = bxmin - scx;
|
||||
max1 = bxmin_scx;
|
||||
|
||||
distance = square(bxmin_scx);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scx > bxmax)
|
||||
{
|
||||
double scx_bxmax = scx - bxmax;
|
||||
max1 = scx_bxmax;
|
||||
|
||||
distance = square(scx_bxmax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
|
||||
if (scy < bymin)
|
||||
{
|
||||
double bymin_scy = bymin - scy;
|
||||
if (max1 < bymin_scy) {
|
||||
max1 = bymin_scy;
|
||||
}
|
||||
|
||||
distance += square(bymin_scy);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scy > bymax)
|
||||
{
|
||||
double scy_bymax = scy - bymax;
|
||||
if (max1 < scy_bymax) {
|
||||
max1 = scy_bymax;
|
||||
}
|
||||
distance += square(scy_bymax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
|
||||
if (scz < bzmin)
|
||||
{
|
||||
double bzmin_scz = bzmin - scz;
|
||||
if (max1 < bzmin_scz) {
|
||||
max1 = bzmin_scz;
|
||||
}
|
||||
distance += square(bzmin_scz);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scz > bzmax)
|
||||
{
|
||||
double scz_bzmax = scz - bzmax;
|
||||
if (max1 < scz_bzmax) {
|
||||
max1 = scz_bzmax;
|
||||
}
|
||||
|
||||
distance += square(scz_bzmax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
// double_tmp_result and eps were growing all the time
|
||||
// no need to test for > eps as done earlier in at least one case
|
||||
return CGAL::SMALLER;
|
||||
|
||||
CGAL_BRANCH_PROFILER_BRANCH_2(tmp);
|
||||
}
|
||||
return Compare_distance_getter<GeomTraits, true, false>::compare_distance_object()(p, b, bound);
|
||||
}
|
||||
};
|
||||
public:
|
||||
typedef Statically_filtered_compare_distance type;
|
||||
|
||||
static Statically_filtered_compare_distance compare_distance_object() {
|
||||
return Statically_filtered_compare_distance();
|
||||
}
|
||||
};
|
||||
|
||||
} } //end of namespace internal::AABB_tree
|
||||
|
||||
/// \addtogroup PkgAABBTreeRef
|
||||
|
|
@ -163,7 +503,7 @@ class AABB_tree;
|
|||
/// \sa `AABBPrimitiveWithSharedData`
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
|
||||
class AABB_traits_base_3
|
||||
class AABB_traits_3
|
||||
#ifndef DOXYGEN_RUNNING
|
||||
: public internal::AABB_tree::AABB_traits_base<AABBPrimitive>,
|
||||
public internal::AABB_tree::AABB_traits_intersection_base_3<GeomTraits>,
|
||||
|
|
@ -174,7 +514,7 @@ class AABB_traits_base_3
|
|||
public:
|
||||
typedef GeomTraits Geom_traits;
|
||||
|
||||
typedef AABB_traits_base_3<GeomTraits, AABBPrimitive, BboxMap> AT;
|
||||
typedef AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap> AT;
|
||||
// AABBTraits concept types
|
||||
typedef typename GeomTraits::FT FT;
|
||||
typedef AABBPrimitive Primitive;
|
||||
|
|
@ -228,9 +568,9 @@ public:
|
|||
BboxMap bbm;
|
||||
|
||||
/// Default constructor.
|
||||
AABB_traits_base_3() { }
|
||||
AABB_traits_3() { }
|
||||
|
||||
AABB_traits_base_3(BboxMap bbm)
|
||||
AABB_traits_3(BboxMap bbm)
|
||||
: bbm(bbm)
|
||||
{}
|
||||
|
||||
|
|
@ -253,10 +593,10 @@ public:
|
|||
*/
|
||||
class Split_primitives
|
||||
{
|
||||
typedef AABB_traits_base_3<GeomTraits,AABBPrimitive,BboxMap> Traits;
|
||||
typedef AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap> Traits;
|
||||
const Traits& m_traits;
|
||||
public:
|
||||
Split_primitives(const AABB_traits_base_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
|
||||
Split_primitives(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
|
||||
: m_traits(traits) {}
|
||||
|
||||
typedef void result_type;
|
||||
|
|
@ -293,9 +633,9 @@ public:
|
|||
* @return the bounding box of the primitives of the iterator range
|
||||
*/
|
||||
class Compute_bbox {
|
||||
const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
public:
|
||||
Compute_bbox(const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
Compute_bbox(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
:m_traits (traits) {}
|
||||
|
||||
template<typename ConstPrimitiveIterator>
|
||||
|
|
@ -317,9 +657,9 @@ public:
|
|||
/// In the case the query is a `CGAL::AABB_tree`, the `do_intersect()`
|
||||
/// function of this tree is used.
|
||||
class Do_intersect {
|
||||
const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
public:
|
||||
Do_intersect(const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
Do_intersect(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
:m_traits(traits) {}
|
||||
|
||||
template<typename Query>
|
||||
|
|
@ -352,9 +692,9 @@ public:
|
|||
|
||||
|
||||
class Intersection {
|
||||
const AABB_traits_base_3<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
|
||||
const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& m_traits;
|
||||
public:
|
||||
Intersection(const AABB_traits_base_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
|
||||
Intersection(const AABB_traits_3<GeomTraits,AABBPrimitive,BboxMap>& traits)
|
||||
:m_traits(traits) {}
|
||||
template<typename Query>
|
||||
std::optional< typename Intersection_and_primitive_id<Query>::Type >
|
||||
|
|
@ -373,9 +713,9 @@ public:
|
|||
class Closest_point {
|
||||
typedef typename AT::Point Point;
|
||||
typedef typename AT::Primitive Primitive;
|
||||
const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& m_traits;
|
||||
public:
|
||||
Closest_point(const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
Closest_point(const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
: m_traits(traits) {}
|
||||
|
||||
|
||||
|
|
@ -390,132 +730,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// This should go down to the GeomTraits, i.e. the kernel
|
||||
// and the internal implementation should change its name from
|
||||
// do_intersect to something like does_contain (this is what we compute,
|
||||
// this is not the same do_intersect as the spherical kernel)
|
||||
class Compare_distance {
|
||||
typedef typename AT::Point Point;
|
||||
typedef typename AT::FT FT;
|
||||
typedef typename AT::Primitive Primitive;
|
||||
typedef typename GeomTraits::Boolean Boolean;
|
||||
public:
|
||||
CGAL::Comparison_result operator()(const Point& p, const Bounding_box& bb, const Point& bound) const
|
||||
{
|
||||
return do_intersect_sphere_iso_cuboid_3
|
||||
(GeomTraits().construct_sphere_3_object()
|
||||
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), bb) ?
|
||||
CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
|
||||
{
|
||||
return GeomTraits().do_intersect_3_object()
|
||||
(GeomTraits().construct_sphere_3_object()
|
||||
(p, GeomTraits().compute_squared_distance_3_object()(p, bound)), pr)?
|
||||
CGAL::SMALLER : CGAL::LARGER;
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
|
||||
{
|
||||
return GeomTraits().do_intersect_3_object()
|
||||
(GeomTraits().construct_sphere_3_object()(p, sq_distance),
|
||||
pr) ?
|
||||
CGAL::SMALLER :
|
||||
CGAL::LARGER;
|
||||
}
|
||||
|
||||
Boolean do_intersect_sphere_iso_cuboid_3(const typename GeomTraits::Sphere_3& sphere,
|
||||
const Bounding_box& box) const
|
||||
{
|
||||
typedef typename GeomTraits::FT FT;
|
||||
typedef typename GeomTraits::Point_3 Point;
|
||||
|
||||
const FT bxmin = box.xmin();
|
||||
const FT bymin = box.ymin();
|
||||
const FT bzmin = box.zmin();
|
||||
const FT bxmax = box.xmax();
|
||||
const FT bymax = box.ymax();
|
||||
const FT bzmax = box.zmax();
|
||||
|
||||
// Check that the minimum distance to the box is smaller than the radius, otherwise there is
|
||||
// no intersection. `distance` stays at 0 if the center is inside or on `rec`.
|
||||
|
||||
FT d = FT(0);
|
||||
FT distance = FT(0);
|
||||
const FT sr = typename GeomTraits::Compute_squared_radius_3()(sphere);
|
||||
|
||||
const Point center = typename GeomTraits::Construct_center_3()(sphere);
|
||||
typename GeomTraits::Cartesian_const_iterator_3 cci = typename GeomTraits::Construct_cartesian_const_iterator_3()(center);
|
||||
|
||||
if (*cci < bxmin)
|
||||
{
|
||||
d = bxmin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance = d;
|
||||
}
|
||||
else if (*cci > bxmax)
|
||||
{
|
||||
d = *cci - bxmax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance = d;
|
||||
}
|
||||
|
||||
cci++;
|
||||
if (*cci < bymin)
|
||||
{
|
||||
d = bymin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
else if (*cci > bymax)
|
||||
{
|
||||
d = *cci - bymax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
|
||||
cci++;
|
||||
if (*cci < bzmin)
|
||||
{
|
||||
d = bzmin - *cci;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
else if (*cci > bzmax)
|
||||
{
|
||||
d = *cci - bzmax;
|
||||
d = square(d);
|
||||
if (d > sr)
|
||||
return false;
|
||||
|
||||
distance += d;
|
||||
}
|
||||
// Note that with the way the distance above is computed, the distance is '0' if the box strictly
|
||||
// contains the sphere. But since we use '>', we don't exit
|
||||
return (distance <= sr);
|
||||
}
|
||||
};
|
||||
typedef typename internal::AABB_tree::Compare_distance_getter<GeomTraits>::type Compare_distance;
|
||||
|
||||
Closest_point closest_point_object() const {return Closest_point(*this);}
|
||||
Compare_distance compare_distance_object() const {return Compare_distance();}
|
||||
Compare_distance compare_distance_object() const {return internal::AABB_tree::Compare_distance_getter<GeomTraits>::compare_distance_object();}
|
||||
|
||||
typedef enum { CGAL_AXIS_X = 0,
|
||||
CGAL_AXIS_Y = 1,
|
||||
|
|
@ -541,17 +759,17 @@ private:
|
|||
}
|
||||
|
||||
/// Comparison functions
|
||||
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
static bool less_x(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
{
|
||||
return GeomTraits().less_x_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
|
||||
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
|
||||
}
|
||||
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
static bool less_y(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
{
|
||||
return GeomTraits().less_y_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
|
||||
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
|
||||
}
|
||||
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits_base_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
static bool less_z(const Primitive& pr1, const Primitive& pr2,const AABB_traits_3<GeomTraits,AABBPrimitive, BboxMap>& traits)
|
||||
{
|
||||
return GeomTraits().less_z_3_object()( internal::Primitive_helper<AT>::get_reference_point(pr1,traits),
|
||||
internal::Primitive_helper<AT>::get_reference_point(pr2,traits) );
|
||||
|
|
@ -564,8 +782,8 @@ private:
|
|||
// Private methods
|
||||
//-------------------------------------------------------
|
||||
template<typename GT, typename P, typename B>
|
||||
typename AABB_traits_base_3<GT,P,B>::Axis
|
||||
AABB_traits_base_3<GT,P,B>::longest_axis(const Bounding_box& bbox)
|
||||
typename AABB_traits_3<GT,P,B>::Axis
|
||||
AABB_traits_3<GT,P,B>::longest_axis(const Bounding_box& bbox)
|
||||
{
|
||||
const double dx = bbox.xmax() - bbox.xmin();
|
||||
const double dy = bbox.ymax() - bbox.ymin();
|
||||
|
|
@ -599,36 +817,6 @@ private:
|
|||
|
||||
} // end namespace CGAL
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Filtered traits
|
||||
//-------------------------------------------------------
|
||||
|
||||
#include <CGAL/AABB_tree/internal/AABB_filtered_traits_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default, bool Has_filtered_predicates_ = internal::Has_filtered_predicates<GeomTraits>::value>
|
||||
class AABB_traits_3;
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap>
|
||||
class AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap, false> : public AABB_traits_base_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_traits_base_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
|
||||
public:
|
||||
AABB_traits_3() : Base() {}
|
||||
AABB_traits_3(BboxMap bbm) : Base(bbm) {}
|
||||
};
|
||||
|
||||
|
||||
template<class GeomTraits, typename AABBPrimitive, typename BboxMap>
|
||||
class AABB_traits_3<GeomTraits, AABBPrimitive, BboxMap, true> : public AABB_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
|
||||
public:
|
||||
AABB_traits_3() : Base() {}
|
||||
AABB_traits_3(BboxMap bbm) : Base(bbm) {}
|
||||
};
|
||||
}
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
||||
#endif // CGAL_AABB_TRAITS_3_H_
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
|
||||
//
|
||||
|
||||
#ifndef CGAL_AABB_FILTERED_TRAITS_3_H
|
||||
#define CGAL_AABB_FILTERED_TRAITS_3_H
|
||||
|
||||
#include <CGAL/license/AABB_tree.h>
|
||||
|
||||
#include <CGAL/AABB_traits_3.h>
|
||||
#include <CGAL/Filtered_predicate.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
|
||||
class AABB_filtered_traits_base_3 : public AABB_traits_base_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_traits_base_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
public:
|
||||
typedef GeomTraits Kernel;
|
||||
|
||||
typedef typename Kernel::Exact_kernel EKernel;
|
||||
typedef typename Kernel::Approximate_kernel AKernel;
|
||||
typedef typename Kernel::C2E C2E;
|
||||
typedef typename Kernel::C2F C2F;
|
||||
|
||||
// Exact traits is based on the exact kernel.
|
||||
typedef AABB_traits_base_3<EKernel, AABBPrimitive, BboxMap> Exact_traits;
|
||||
// Filtering traits is based on the filtering kernel.
|
||||
typedef AABB_traits_base_3<AKernel, AABBPrimitive, BboxMap> Filtering_traits;
|
||||
|
||||
typedef Filtered_predicate<
|
||||
typename Exact_traits::Compare_distance,
|
||||
typename Filtering_traits::Compare_distance,
|
||||
C2E, C2F> Compare_distance;
|
||||
|
||||
AABB_filtered_traits_base_3() : Base() {}
|
||||
AABB_filtered_traits_base_3(BboxMap bbm) : Base(bbm) {}
|
||||
|
||||
Compare_distance compare_distance_object() const
|
||||
{
|
||||
typename Exact_traits::Compare_distance pe = Exact_traits().compare_distance_object();
|
||||
typename Filtering_traits::Compare_distance pf = Filtering_traits().compare_distance_object();
|
||||
|
||||
return Compare_distance(pe, pf);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#include <CGAL/AABB_tree/internal/AABB_statically_filtered_traits_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default, bool Has_static_filters = internal::Has_static_filters<GeomTraits>::value>
|
||||
class AABB_filtered_traits_3;
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap>
|
||||
class AABB_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap, false> : public AABB_filtered_traits_base_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_filtered_traits_base_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
|
||||
public:
|
||||
AABB_filtered_traits_3() : Base() {}
|
||||
AABB_filtered_traits_3(BboxMap bbm) : Base(bbm) {}
|
||||
};
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap>
|
||||
class AABB_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap, true> : public AABB_statically_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_statically_filtered_traits_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
|
||||
public:
|
||||
AABB_filtered_traits_3() : Base() {}
|
||||
AABB_filtered_traits_3(BboxMap bbm) : Base(bbm) {}
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
// Copyright (c) 2024 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s) : Stéphane Tayeb, Pierre Alliez, Camille Wormser
|
||||
//
|
||||
|
||||
#ifndef CGAL_AABB_STATICALLY_FILTERED_TRAITS_3_H
|
||||
#define CGAL_AABB_STATICALLY_FILTERED_TRAITS_3_H
|
||||
|
||||
#include <CGAL/license/AABB_tree.h>
|
||||
|
||||
#include <CGAL/Filtered_kernel/internal/Static_filters/Static_filter_error.h>
|
||||
#include <CGAL/Filtered_kernel/internal/Static_filters/tools.h>
|
||||
#include <CGAL/AABB_tree/internal/AABB_filtered_traits_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template<typename GeomTraits, typename AABBPrimitive, typename BboxMap = Default>
|
||||
class AABB_statically_filtered_traits_3 : public AABB_filtered_traits_base_3<GeomTraits, AABBPrimitive, BboxMap> {
|
||||
using Base = AABB_filtered_traits_base_3<GeomTraits, AABBPrimitive, BboxMap>;
|
||||
|
||||
public:
|
||||
class Compare_distance : public Base::Compare_distance {
|
||||
public:
|
||||
using Point = typename GeomTraits::Point_3;
|
||||
using Bounding_box = Bbox_3;
|
||||
using Sphere_3 = typename GeomTraits::Sphere_3;
|
||||
using FT = typename GeomTraits::FT;
|
||||
|
||||
Comparison_result operator()(const Point& p, const Bounding_box& b, const Point& bound) const {
|
||||
Sphere_3 s = GeomTraits().construct_sphere_3_object()(p, GeomTraits().compute_squared_distance_3_object()(p, bound));
|
||||
CGAL_BRANCH_PROFILER_3(std::string("semi-static failures/attempts/calls to : ") +
|
||||
std::string(CGAL_PRETTY_FUNCTION), tmp);
|
||||
|
||||
internal::Static_filters_predicates::Get_approx<Point> get_approx; // Identity functor for all points
|
||||
const Point& c = s.center();
|
||||
|
||||
double scx, scy, scz, ssr;
|
||||
double bxmin = b.xmin(), bymin = b.ymin(), bzmin = b.zmin(),
|
||||
bxmax = b.xmax(), bymax = b.ymax(), bzmax = b.zmax();
|
||||
|
||||
if (internal::fit_in_double(get_approx(c).x(), scx) &&
|
||||
internal::fit_in_double(get_approx(c).y(), scy) &&
|
||||
internal::fit_in_double(get_approx(c).z(), scz) &&
|
||||
internal::fit_in_double(s.squared_radius(), ssr))
|
||||
{
|
||||
CGAL_BRANCH_PROFILER_BRANCH_1(tmp);
|
||||
|
||||
if ((ssr < 1.11261183279326254436e-293) || (ssr > 2.80889552322236673473e+306)) {
|
||||
CGAL_BRANCH_PROFILER_BRANCH_2(tmp);
|
||||
return Base::Compare_distance::operator()(p, b, bound);
|
||||
}
|
||||
double distance = 0;
|
||||
double max1 = 0;
|
||||
double double_tmp_result = 0;
|
||||
double eps = 0;
|
||||
if (scx < bxmin)
|
||||
{
|
||||
double bxmin_scx = bxmin - scx;
|
||||
max1 = bxmin_scx;
|
||||
|
||||
distance = square(bxmin_scx);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scx > bxmax)
|
||||
{
|
||||
double scx_bxmax = scx - bxmax;
|
||||
max1 = scx_bxmax;
|
||||
|
||||
distance = square(scx_bxmax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || (max1 > 1.67597599124282407923e+153))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
|
||||
if (scy < bymin)
|
||||
{
|
||||
double bymin_scy = bymin - scy;
|
||||
if (max1 < bymin_scy) {
|
||||
max1 = bymin_scy;
|
||||
}
|
||||
|
||||
distance += square(bymin_scy);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if ((max1 < 3.33558365626356687717e-147) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scy > bymax)
|
||||
{
|
||||
double scy_bymax = scy - bymax;
|
||||
if (max1 < scy_bymax) {
|
||||
max1 = scy_bymax;
|
||||
}
|
||||
distance += square(scy_bymax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
|
||||
if (scz < bzmin)
|
||||
{
|
||||
double bzmin_scz = bzmin - scz;
|
||||
if (max1 < bzmin_scz) {
|
||||
max1 = bzmin_scz;
|
||||
}
|
||||
distance += square(bzmin_scz);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
else if (scz > bzmax)
|
||||
{
|
||||
double scz_bzmax = scz - bzmax;
|
||||
if (max1 < scz_bzmax) {
|
||||
max1 = scz_bzmax;
|
||||
}
|
||||
|
||||
distance += square(scz_bzmax);
|
||||
double_tmp_result = (distance - ssr);
|
||||
|
||||
if (((max1 < 3.33558365626356687717e-147)) || ((max1 > 1.67597599124282407923e+153)))
|
||||
return CGAL::SMALLER;
|
||||
|
||||
eps = 1.99986535548615598560e-15 * (std::max)(ssr, square(max1));
|
||||
|
||||
if (double_tmp_result > eps)
|
||||
return CGAL::LARGER;
|
||||
}
|
||||
|
||||
// double_tmp_result and eps were growing all the time
|
||||
// no need to test for > eps as done earlier in at least one case
|
||||
return CGAL::SMALLER;
|
||||
|
||||
CGAL_BRANCH_PROFILER_BRANCH_2(tmp);
|
||||
}
|
||||
return Base::Compare_distance::operator()(p, b, bound);
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const Point& bound) const
|
||||
{
|
||||
return Base::Compare_distance::operator()(p, pr, bound);
|
||||
}
|
||||
|
||||
template <class Solid>
|
||||
CGAL::Comparison_result operator()(const Point& p, const Solid& pr, const FT& sq_distance) const
|
||||
{
|
||||
return Base::Compare_distance::operator()(p, pr, sq_distance);
|
||||
}
|
||||
};
|
||||
AABB_statically_filtered_traits_3() : Base() {}
|
||||
AABB_statically_filtered_traits_3(BboxMap bbm) : Base(bbm) {}
|
||||
|
||||
Compare_distance compare_distance_object() const { return Compare_distance(); }
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue