1 // Copyright (c) 2014 GeometryFactory Sarl (France). 2 // All rights reserved. 3 // 4 // This file is part of CGAL (www.cgal.org). 5 // 6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Surface_mesh_segmentation/include/CGAL/internal/Surface_mesh_segmentation/AABB_traits.h $ 7 // $Id: AABB_traits.h e893ac1 2020-08-18T10:06:51+02:00 Sébastien Loriot 8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial 9 // 10 // Author(s) : Ilker O. Yaz 11 12 13 #ifndef CGAL_INTERNAL_SURFACE_MESH_SEGMENTATION_AABB_TRAITS_H 14 #define CGAL_INTERNAL_SURFACE_MESH_SEGMENTATION_AABB_TRAITS_H 15 16 #include <CGAL/license/Surface_mesh_segmentation.h> 17 18 19 #include <CGAL/AABB_traits.h> 20 #include <boost/utility/enable_if.hpp> 21 #include <boost/type_traits.hpp> 22 23 namespace CGAL 24 { 25 26 /// @cond CGAL_DOCUMENT_INTERNAL 27 template<typename GeomTraits, typename AABB_primitive, bool fast_bbox_intersection> 28 class AABB_traits_SDF : 29 public AABB_traits<GeomTraits, AABB_primitive> 30 { 31 public: 32 typedef AABB_traits<GeomTraits, AABB_primitive> Base_traits; 33 typedef typename Base_traits::Bounding_box Bounding_box; 34 typedef typename Base_traits::Point_3 Point_3; 35 36 class Do_intersect 37 : public Base_traits::Do_intersect 38 { 39 public: Do_intersect(const AABB_traits<GeomTraits,AABB_primitive> & traits)40 Do_intersect(const AABB_traits<GeomTraits,AABB_primitive>& traits) 41 :Base_traits::Do_intersect(traits) {} 42 43 // not sure is it safe on templated funcs ? may be do not inherit and repeat functions... 44 using Base_traits::Do_intersect::operator (); 45 46 // activate functions below if K::FT is floating point and fast_bbox_intersection = true 47 template <class K> 48 typename boost::enable_if_c< 49 boost::is_floating_point<typename K::FT>::value && fast_bbox_intersection, 50 bool >::type operator()51 operator()(const CGAL::Segment_3<K>& segment, const Bounding_box& bbox) const { 52 const Point_3& p = segment.source(); 53 const Point_3& q = segment.target(); 54 55 return Intersections::internal::do_intersect_bbox_segment_aux 56 <double, 57 true, // bounded at t=0 58 true, // bounded at t=1 59 false> // do not use static filters 60 (p.x(), p.y(), p.z(), 61 q.x(), q.y(), q.z(), 62 bbox); 63 } 64 65 template <class K> 66 typename boost::enable_if_c< 67 boost::is_floating_point<typename K::FT>::value && fast_bbox_intersection, 68 bool >::type operator()69 operator()(const CGAL::Ray_3<K>& ray, const Bounding_box& bbox) const { 70 const Point_3& p = ray.source(); 71 const Point_3& q = ray.second_point(); 72 73 return Intersections::internal::do_intersect_bbox_segment_aux 74 <double, 75 true, // bounded at t=0 76 false,// not bounded at t=1 77 false> // do not use static filters 78 (p.x(), p.y(), p.z(), 79 q.x(), q.y(), q.z(), 80 bbox); 81 } 82 83 }; 84 do_intersect_object()85 Do_intersect do_intersect_object() const { 86 return Do_intersect(*this); 87 } 88 }; 89 /// @endcond 90 91 } //namespace CGAL 92 #endif //CGAL_INTERNAL_SURFACE_MESH_SEGMENTATION_AABB_TRAITS_H 93