Documentation on connecting user data to kernel structures

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Documentation on connecting user data to kernel structures

Julien JPK
Hello,

I'm having a hard time figuring out how to do a seemingly simple thing
in CGAL: I would like to associate POD content to some kernel
structures, namely points and segments. I don't really mind if this
involves actually extending the structures or having a map of some sort,
but I would like to connect my points and segments to some additional
data such that it is quickly retrievable from its kernel object.

I gave a shot at the obvious "just extend it" approach on K::Point_2 for
a Cartesian kernel, to no avail: when I attempt to compile a call to
convex_hull_2 using iterators to my derived type, an assignment operator
from K::Point_2 is requested, which suggests inheritance isn't the right
tool here...

After some digging, I came across extensible kernels [1] but I cannot
shake the feeling that there must be a much simpler way when the kernel
extension is all about POD structures being added and no functionality
being altered or concept broken... In Boost.Geometry for example, this
is easily achieved using BOOST_GEOMETRY_REGISTER_POINT_2D, although in
this case the dependency with the original kernel structures is not
really present [2].

Could someone put me on the right track for this?

Thank you in advance,
Regards,
J.

[1]: https://doc.cgal.org/latest/Kernel_23/index.html
[2]:
https://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/reference/adapted/register/boost_geometry_register_point_2d.html


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Documentation on connecting user data to kernel structures

MaelRL
Hello,

As you say, an obvious but not ideal solution is to assign your
properties via (unordered) maps.

However, some algorithms can do much better: for example, in the 2D
convex hulls that you mention, you can pass a range of some type, e.g.
Point_with_info, and a property map to extract the geometric Point_2
from your Point_with_info; see the following example
https://cgal.geometryfactory.com/CGAL/doc/master/Convex_hull_2/Convex_hull_2_2convex_hull_indices_2_8cpp-example.html.

Which other algorithms would you need this type of mechanism with?

Best,
Mael

On 09/10/2019 17:58, Julien JPK wrote:

> Hello,
>
> I'm having a hard time figuring out how to do a seemingly simple thing
> in CGAL: I would like to associate POD content to some kernel
> structures, namely points and segments. I don't really mind if this
> involves actually extending the structures or having a map of some sort,
> but I would like to connect my points and segments to some additional
> data such that it is quickly retrievable from its kernel object.
>
> I gave a shot at the obvious "just extend it" approach on K::Point_2 for
> a Cartesian kernel, to no avail: when I attempt to compile a call to
> convex_hull_2 using iterators to my derived type, an assignment operator
> from K::Point_2 is requested, which suggests inheritance isn't the right
> tool here...
>
> After some digging, I came across extensible kernels [1] but I cannot
> shake the feeling that there must be a much simpler way when the kernel
> extension is all about POD structures being added and no functionality
> being altered or concept broken... In Boost.Geometry for example, this
> is easily achieved using BOOST_GEOMETRY_REGISTER_POINT_2D, although in
> this case the dependency with the original kernel structures is not
> really present [2].
>
> Could someone put me on the right track for this?
>
> Thank you in advance,
> Regards,
> J.
>
> [1]: https://doc.cgal.org/latest/Kernel_23/index.html
> [2]:
> https://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/reference/adapted/register/boost_geometry_register_point_2d.html
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss