Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How to use Kernel_traits?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How to use Kernel_traits?


Chronological Thread 
  • From: Ben Laurie <>
  • To:
  • Subject: Re: [cgal-discuss] How to use Kernel_traits?
  • Date: Thu, 13 Aug 2020 05:35:44 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:mardihRPT2Mj9RkkRtyr943qW9psv+yvbD5Q0YIujvd0So/mwa6zbRyN2/xhgRfzUJnB7Loc0qyK6v6mCDdLscnJmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRS7oR/Vu8QYjodvKaQ8wQbVr3VVfOhb2XlmLk+JkRbm4cew8p9j8yBOtP8k6sVNT6b0cbkmQLJBFDgpPHw768PttRnYUAuA/WAcXXkMkhpJGAfK8hf3VYrsvyTgt+p93C6aPdDqTb0xRD+v4btnRAPuhSwaMTMy7WPZhdFqjK9Drx2hqR5wzY7abo+WKfRwYL/ScMgASmZdRMtcTTBNDp++YoYJEuEPPfxYr474p1YWsBaxGw+sD/7pxDBSm3/2x6w63Po8GgzBxwMvAdQOvW/QrNX0MqcSUvu1wLPPzTXZYPNbwDHw45XHfR49u/+DR65wcdbPxkk1EQPIlkudpJH4Mj2b1ekArXSW4vRhWOyvhWMqqgB8rzmty8sxloTEhYwYx1TZ+Ch7wYs4IcC1RVJ7b9OmH5ZetyOXOpdwT8g/TW9ovyM6xacHuZ69ZCUF1JsnyATba/CddIiI+B3jWP6QITd+nnJleaiwiwy88Ui6zOD3S8q60E5SoyZbjtXBsmoB2h/T58SdV/dw/0as1SyS2w3X5exJJ10/m7DBJJ472LEwk4IesUTdES/yn0X7lKqWeV8l+uis8ujnY7HmqoKFO496lw3zNqsjltawAeQ/NQgOUGyb9vqm2LL/+k35Ra1GjvwwkqbHrJDXPdoXqrK9DgNP0Ysu6wyzAyqn3dkZh3ULMVZIdR2fg4jsIV7OIfT4Dfmlg1SrlTdm3+vJMaPnApXJNHfDja3hfbdj5ENHxwozyMpQ55NQCr0bPP3zXUrxuMTCDhAlKwy03/rnCNJl24wCVmKAGKuZPLrPvl+J/eIgP/SMZJQOuDvmMPgk5/vujWcjllMHfKmp24EXaHGiEfh8LUWZeymkv9EaDG1fvhYiVPe4zxqZQDtLbjCzWbg973c1EsW9HILbT8eshrKGmyy0F5kTamFdAU2XCiTVcZ6ZUdcQbSbHItN9iidWEv+6Woo53FevshX7wvxpNK3P6ygAvNXi0tZyoObcnBV3+T1vBNmGyDKwSXpplF8FVyNj3LxjuVcvjRCYwK1girpZE8ZS7rVHSEAhJJvExqt7Dd71HQnOd9PMRFe9Sci9GmINSYc6zNYKJkp8AN6/lQvr3iywArZTmabYKoYz9/f20n65A89g0XfLnP0rgl8ORspJNnbggbRwoVuAT7XVmlmUwv75PZ8X2zTAoT/anDi++XpAWQs1ap3rGHUWZ0/Yt9P8vxqQQLqnCLBhOQxEm5fbdvl6L+bxhFADf8/NfczEajvoyWOxAxWTgLSWY9iyIjhP7GDmEEEB1jsr0zOGOAw5XHnzpmvfCHlvEQuqbRq9ra9xr3S0SkJyxAaPPRVs

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'

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




Archive powered by MHonArc 2.6.19+.

Top of Page