Subject: CGAL users discussion list
List archive
- From: Hexley <>
- To:
- Subject: Re: [cgal-discuss] Use of Spherical Kernels in AABB Tree
- Date: Wed, 3 Jun 2015 07:18:49 -0700 (PDT)
Hi, I'm actually OP's colleague and responsible for the CGAL module of our
code, but I'm having some trouble implementing a custom traits to make use
of the spherical kernel intersect function, as you suggested.
I decided to make a model of AABBGeomTraits. Since I only need to redefine
the Intersect_3 functor and construction function, I figured I could make my
custom traits a subclass of a spherical kernel. I followed the procedure
descibed in the documentation, and also made my own Intersect_3 replacement
functor, as shown below.
/// Class used as substitute for Intersect_3
class SphericalIntersect {
typedef Spherical SK;
public:
typedef std::pair<SK::Circular_arc_point_3, UInt> pair_type;
typedef boost::variant<pair_type> variant_type;
typedef boost::optional<variant_type> result_type;
typedef CGAL::cpp11::result_of<SK::Intersect_3(SK::Line_arc_3,
SK::Sphere_3,
std::back_insert_iterator<std::list<variant_type> >)
>::type cpp11_type;
result_type
operator()(const CGAL::Line_arc_3<SK> & a, const CGAL::Sphere_3<SK> & b) {
std::list<variant_type> list;
CGAL::intersection(a, b, std::back_inserter(list));
return boost::make_optional(list.front());
}
};
/**
* @brief Class used as AABBGeomTraits in the CGAL AABB tree algorithm
*
* The inheritance from another kernel is described in CGAL documentation
*/
template<typename SK, typename K_base> // SK is new kernel, K_base is old
one
class SphericalTraits_base : public K_base::template Base<SK>::Type {
typedef typename K_base::template Base<SK>::Type OldK;
public:
typedef SphericalIntersect Intersect_3;
Intersect_3 intersect_3_object() {
return Intersect_3();
}
template<typename Kernel>
struct Base {
typedef SphericalTraits_base<Kernel, K_base> Type;
};
};
template<typename FT_>
struct SphericalTraits : public CGAL::Type_equality_wrapper<
SphericalTraits_base<SphericalTraits<FT_>,
CGAL::Spherical_kernel_3<CGAL::Simple_cartesian<FT_>,
CGAL::Algebraic_kernel_for_spheres_2_3<FT_> > >,
SphericalTraits<FT_> >
{};
I am then using SphericalTraits<double> in the CGAL::AABB_traits class.
Every type of point, sphere, line_arc, etc., used in the algorithm is
related to the kernel Spherical which refers to
CGAL::Spherical_kernel_3<CGAL::Simple_cartesian<double>,
CGAL::Algebraic_kernel_for_spheres_2_3<double> >. I am also using a custom
AABBPrimitive class which redefines :
Id = unsigned int
Point = Spherical::Circular_arc_point_3
Datum = Spherical::Line_arc_3
I have a small example which constrcuts the tree and asks a query, but it
doesn't compile, and I get this error :
/usr/local/include/CGAL/AABB_tree.h:1061:4: error: no matching function for
call to ‘std::pair<CGAL::Point_3<akantu::SphericalTraits<double> >,
unsigned
int>::pair(CGAL::internal::Primitive_helper<CGAL::AABB_traits<akantu::SphericalTraits<double>,
akantu::Line_arc_primitive>, false>::Reference_point_type, const Id&)’
points.push_back(
But at this point I would just like to know if I'm on the right track.
Thanks in advance !
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Use-of-Spherical-Kernels-in-AABB-Tree-tp4660886p4660896.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Use of Spherical Kernels in AABB Tree, Clement Roux-Langlois, 06/02/2015
- Re: [cgal-discuss] Use of Spherical Kernels in AABB Tree, Sebastien Loriot (GeometryFactory), 06/02/2015
- Re: [cgal-discuss] Use of Spherical Kernels in AABB Tree, Hexley, 06/03/2015
- Re: [cgal-discuss] Use of Spherical Kernels in AABB Tree, Sebastien Loriot (GeometryFactory), 06/02/2015
Archive powered by MHonArc 2.6.18.