Subject: CGAL users discussion list
List archive
- From: Maxime Gimeno <>
- To:
- Subject: Re: [cgal-discuss] How to use Kernel_traits?
- Date: Tue, 18 Aug 2020 09:37:06 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:UfKvmxyK9gbSK9HXCy+O+j09IxM/srCxBDY+r6Qd0uoSL/ad9pjvdHbS+e9qxAeQG9mCtbQd07ed6vm9EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe8bL9oMRm6sQXcusYLjYd/Kqs61wfErGZPd+lK321jOEidnwz75se+/Z5j9zpftvc8/MNeUqv0Yro1Q6VAADspL2466svrtQLeTQSU/XsTTn8WkhtTDAfb6hzxQ4r8vTH7tup53ymaINH2QLUpUjms86tnVBnlgzoBOjUk8m/Yl9ZwgbpUrxKvpRNxw4DaboKIOvRgYqzQZskVSXZbU8tLSyBNHoGxYo0SBOQBJ+ZYqIz9qkMJoxSkCgisBebvxSFVjXH33K061vouEQfB3Ac9GN8OtW7brdr0NKcXT++51qbIzTTGb/xI3zf975PFch8kof6WXLJwddDdxlUoFwPAl1idr5HuMDyJ2OoXqWeb8/ZgWvy1i24hswx8rDeiy8gxhofJiYwYxE7J+Dl4zYs6O9G2R092bcO4HZZfqi2XOJd7T8A+T2x0pCo3xaELt5C7cSYF1Jgr2gLTZvqaeIaG5RLjUfyeITZ+hH99ZL2/iAy98Uy6xu37TMm0305GritDktnWt3ACzQbf6sadSvZ740yv2i6P2hjN5u1YJU04j6nWJp47zrIui5YfrV7PEy/olEjwkaSYbF8r+vKy5OTierjmpoGTN4tzigzmN6QhgM2/AeAhPggJQ2iX5P2w1LPj8EHnWrlKgfo2kq7WsJDeO8sXvLK2AwhQ0oo76ha/CSmp0MgAkHUZMF5IfAiLgovpNl3UPvz0EOuzj06snTt13/zGO6fuApTJLnjNirfherN95lZZyAUpwtFf5pdUBa8bLPL8W0/xscLXDhk+MwGvzObnDc9y1oIaWW6VHqCZN6bSvUeS5u0zO+mMeJMVuDHlJvc56P7hl3s5lUYAcqmoxpsYdG24Hu99I0iCenrtgtIBEX8QsQYkTezqjkeCUT9JaHqoUaI8/GJzNYS9EI2WRpyxmKfTm2CgD5hObyZHDEqNGDHmbcKfSvIUYWWTJMFm1TcLXLzkR4463gy1r1zHzaF6JMrI/ylNtY7/zMMnoKrIhBQq/Hp1Cd6c2ieDVSZvj2YQTng32q545kdyw1PG3aljiOFDDo9u4ehUWDs3JYKJz/BmE8ugHUXab9KRQRCnRM+nCHc/VJUq0toWagF8HdulyRvM1i7vD74OnKGQH88I9ffX0HH1Ysp80H3bz7IJjl88Q8IJO3f1qLR48l32Dp7IlkjRuKeveKIblHrI/XeCyGfIs0BdXQh3earAVHEbIEDRqIKqtQv5U7ayBOF/YUN6wsmYJ/4SM4C7vRB9XP7mfe/mTSexlmO3X0vaw7qNaM/tZzxY0niHTkcDlA8X8DCNMg1sXn798VKbNyRnEBfUW22p6fN38SrpQUo9zgXMZEpkheLsq0wlwMeEQvZW5Yoq/SIoqjF6BlG4houEBN+Jpg4nd6JZM4ow
It turns out, BTW, that you can do this:typedef typename Mesh::Point Point;
typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
On Thu, 13 Aug 2020 at 05:23, Ben Laurie <> wrote:On Sun, 9 Aug 2020 at 22:07, Mael <> wrote:Hi,
If you look at the documentation of Kernel_traits (https://doc.cgal.org/latest/Kernel_23/structCGAL_1_1Kernel__traits.html), you'll see that this traits class searches for a `R` typedef, which is the kernel. This `R` typedef exists for CGAL kernel objects (e.g. CGAL::Point_2, Point_3, etc.) but not for mesh types such as `Surface_mesh`.
Any particular reason why not?
What you would usually do here is to extract the point type from the mesh vertex->point property map of your mesh and call `Kernel_traits` on that point type, so something like:
typedef typename property_map_value<Mesh, CGAL::vertex_point_t>::type Point;
If I try that, I get:error: expected a qualified name after 'typename'
typedef boost::property_traits< boost::property_map< Mesh, vertex_point_t>::type >::value_type Point;
But again, with a Surface_mesh, you can just use the typename Surface_mesh<K>::Point.
If I take out the typename, I get:error: no template named 'property_map_value'Not sure what header defines it, but if I include this header, which also uses property_map_value, I get the same error...#include <CGAL/Polygon_mesh_processing/measure.h>typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
Note that this still assumes that your mesh is compatible with the BGL interface, which is valid for all meshes in CGAL and so more from other libraries, see https://doc.cgal.org/latest/BGL/index.html#title0. Furthermore, your `Point` type must be compatible with `Kernel_traits` (i.e. it defines a `R` typedef), otherwise you will need a partial specialization of `Kernel_traits`.
I am using CGAL::Surface_mesh.
Best,
Mael
On 2020-08-09 14:00, Ben Laurie wrote:
I want to write a template function that does something to a mesh, but without assuming anything about how the mesh is defined (i.e. I don't know what the kernel is).
I thought I could do something like this:
template<class Mesh>
void someFn(const Mesh &m)
{
typedef typename CGAL::Kernel_traits<Mesh>::Kernel Kernel;
typedef typename Kernel::Point_3 Point;
...
but this gives me errors like:
'CGAL::internal_kernel_traits::Dummy_kernel<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>
> >'
typedef typename CGAL::Kernel_traits<Mesh>::Kernel::Point_3 Point;
What am I doing wrong?
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
- [cgal-discuss] How to use Kernel_traits?, Ben Laurie, 08/09/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Mael, 08/09/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Ben Laurie, 08/13/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Ben Laurie, 08/13/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Maxime Gimeno, 08/18/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Ben Laurie, 08/13/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Ben Laurie, 08/13/2020
- Re: [cgal-discuss] How to use Kernel_traits?, Mael, 08/09/2020
Archive powered by MHonArc 2.6.19+.