Skip to content

Commit

Permalink
Kernel_23 Add a functor for offsetting (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Jan 30, 2025
1 parent b19515e commit 434384a
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 3 deletions.
26 changes: 26 additions & 0 deletions Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -4525,6 +4525,32 @@ namespace CartesianKernelFunctors {
};


template <typename K>
class Intersect_offset_planes_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Plane_3 Plane_3;
public:
// typedef std::pair<Point_3,FT> result_type;
typedef FT result_type;

result_type operator()(const Plane_3& p0, const FT& t0,
const Plane_3& p1, const FT& t1,
const Plane_3& p2, const FT& t2,
const Plane_3& p3, const FT& t3) const
{
FT x, y, z, t;
intersect_offset_planesC3(p0.a(), p0.b(), p0.c(), p0.d(), t0,
p1.a(), p1.b(), p1.c(), p1.d(), t1,
p2.a(), p2.b(), p2.c(), p2.d(), t2,
p3.a(), p3.b(), p3.c(), p3.d(), t3,
x, y, z, t);
// return std::make_pair(Point_3(x, y, z),t);
return t;
}
};

} // namespace CartesianKernelFunctors

} //namespace CGAL
Expand Down
11 changes: 11 additions & 0 deletions Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,17 @@ power_distance_to_power_sphereC3(const FT &px, const FT &py, const FT &pz, const
return -ff0/(ff1 - ff0);
}


template < class FT >
void
intersect_offset_planesC3(const FT &p1a, const FT &p1b, const FT &p1c, const FT &p1d, const FT &t1,
const FT &p2a, const FT &p2b, const FT &p2c, const FT &p2d, const FT &t2,
const FT &p3a, const FT &p3b, const FT &p3c, const FT &p3d, const FT &t3,
const FT &p4a, const FT &p4b, const FT &p4c, const FT &p4d, const FT &t4 ,
FT&px, FT &py, FT &pz, FT& t)
{
}

// I will use this to test if the radial axis of three spheres
// intersect the triangle formed by the centers.
// // resolution of the system (where we note c the center)
Expand Down
3 changes: 2 additions & 1 deletion Filtered_kernel/include/CGAL/Lazy_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct Lazy_result_type

class Enum_holder {
protected:
enum { NONE, NT, VARIANT, OBJECT, BBOX, OPTIONAL_ };
enum { NONE, NT, VARIANT, OBJECT, BBOX, OPTIONAL_ , PAIR};
};

} // internal
Expand Down Expand Up @@ -213,6 +213,7 @@ class Lazy_kernel_generic_base : protected internal::Enum_holder
CGAL_WRAPPER_TRAIT(Intersect_2, VARIANT)
CGAL_WRAPPER_TRAIT(Intersect_3, VARIANT)
CGAL_WRAPPER_TRAIT(Intersect_point_3_for_polyhedral_envelope, OPTIONAL_)
CGAL_WRAPPER_TRAIT(Intersect_offset_planes_3, NT)
CGAL_WRAPPER_TRAIT(Compute_squared_radius_2, NT)
CGAL_WRAPPER_TRAIT(Compute_x_3, NT)
CGAL_WRAPPER_TRAIT(Compute_y_3, NT)
Expand Down
30 changes: 30 additions & 0 deletions Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,36 @@ namespace HomogeneousKernelFunctors {
using CartesianKernelFunctors::Compute_area_divided_by_pi_3;
using CartesianKernelFunctors::Compute_squared_length_divided_by_pi_square_3;



template <typename K>
class Intersect_offset_planes_3
{
typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
typedef typename K::Plane_3 Plane_3;
public:
// typedef std::pair<Point_3,T> result_type;
typedef FT result_type;

result_type operator()(const Plane_3& p0, const FT& t0,
const Plane_3& p1, const FT& t1,
const Plane_3& p2, const FT& t2,
const Plane_3& p3, const FT& t3) const
{
FT x, y, z, t;
/*
intersect_offset_planesC3(p0.a(), p0.b(), p0.c(), p0.d(), t0,
p1.a(), p1.b(), p1.c(), p1.d(), t1,
p2.a(), p2.b(), p2.c(), p2.d(), t2,
p3.a(), p3.b(), p3.c(), p3.d(), t3,
x, y, z, t);
*/
// return std::make_pair(Point_3(x, y, z),t);
assert(false);
return t;
}
};
template <typename K>
class Angle_2
{
Expand Down
2 changes: 0 additions & 2 deletions Kernel_23/include/CGAL/Kernel/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ namespace CGAL {

namespace CommonKernelFunctors {



template <typename K>
class Non_zero_coordinate_index_3
{
Expand Down
16 changes: 16 additions & 0 deletions Kernel_23/include/CGAL/Kernel/global_functions_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,22 @@ has_smaller_signed_distance_to_plane(const Plane_3<K> &h,
return internal::has_smaller_signed_distance_to_plane(h, p, q, K());
}

template < class K >
inline
// std::pair<typename K::Point_3, typename K::FT>
typename K::FT
intersect_offset_planes(const Plane_3<K> &p0,
const Plane_3<K> &p1,
const Plane_3<K> &p2,
const Plane_3<K> &p3,
const typename K::FT& t0,
const typename K::FT& t1,
const typename K::FT& t2,
const typename K::FT& t3)
{
return internal::intersect_offset_planes(p0, p1, p2, p3, t0, t1, t2, t3, K());
}

template < class K >
inline
typename K::Boolean
Expand Down
18 changes: 18 additions & 0 deletions Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,24 @@ has_smaller_signed_distance_to_plane(const typename K::Point_3 &hp,
return k.less_signed_distance_to_plane_3_object()(hp, hq, hr, p, q);
}

template < class K >
inline
// std::pair<typename K::Point_3, typename K::FT>
typename K::FT
intersect_offset_planes(const typename K::Plane_3 &p0,
const typename K::Plane_3 &p1,
const typename K::Plane_3 &p2,
const typename K::Plane_3 &p3,
const typename K::FT &t0,
const typename K::FT &t1,
const typename K::FT &t2,
const typename K::FT &t3,
const K &k)
{
return k.intersect_offset_planes_3_object()(p0, t0, p1, t1, p2, t2, p3, t3);
}


template < class K >
inline
typename K::Boolean
Expand Down
2 changes: 2 additions & 0 deletions Kernel_23/include/CGAL/Kernel/interface_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ CGAL_Kernel_cons(Intersect_2,
intersect_2_object)
CGAL_Kernel_cons(Intersect_3,
intersect_3_object)
CGAL_Kernel_cons(Intersect_offset_planes_3,
intersect_offset_planes_3_object)
CGAL_Kernel_cons(Intersect_point_3_for_polyhedral_envelope,
intersect_point_3_for_polyhedral_envelope_object)
CGAL_Kernel_pred(Is_degenerate_2,
Expand Down
6 changes: 6 additions & 0 deletions Kernel_23/test/Kernel_23/include/CGAL/_test_fct_plane_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _test_fct_plane_sqrt_3(const R&)
{
typedef typename R::Point_3 Point_3;
typedef typename R::Plane_3 Plane_3;
typedef typename R::FT FT;

// bisector of 2 planes
Point_3 q0(0, 0, 0, 1);
Expand All @@ -43,6 +44,11 @@ _test_fct_plane_sqrt_3(const R&)
assert( CGAL::bisector(ql4, ql2) == ql3 );
assert( CGAL::bisector(ql1, ql5) == ql1 );

FT one(1);

// std::pair<Point_3, FT> res =
FT res = CGAL::intersect_offset_planes(ql1, ql2, ql3, ql4, one, one, one, one);

return true;
}

Expand Down

0 comments on commit 434384a

Please sign in to comment.