rgcv / libcgal-julia

CGAL bindings for Julia
MIT License
7 stars 5 forks source link

Question on voronoi diagram code #1

Closed mathieu17g closed 2 years ago

mathieu17g commented 2 years ago

Hi @rgcv, looking at the code of src/voronoi_diagram_2.cpp, following my comment https://github.com/rgcv/CGAL.jl/issues/4#issuecomment-1086646407, I stumbled on the mapping you implemented. If you happen to recall your code, I would greatly appreciate some hints.

I could not spot in CGAL's code, the differences between Face, Halfedge, and Vertex templates' instantiations that led to the split in the mapping

https://github.com/rgcv/libcgal-julia/blob/8d5bc5f13d3c9c6160cfff795d2a0bbe1e473d94/src/voronoi_diagram_2.cpp#L57-L118

rgcv commented 2 years ago

Hey @mathieu17g,

Why did you separate (...) mapping[s]

The answer, I hope, is relatively simple. Those separations occur because the methods have type dependencies, and type/method registration order matters. If you attempt to register a method that depends on a type that wasn't yet registered, the wrapper will not compile. That's why I split them up.

mapping of other (...) methods (done without any call to apply)

That's an interesting little detail I myself am now unsure of looking back at the code, but there is no actual need for using apply in these scenarios since the various types are intertwined (e.g., VD::Face and Vertex::Face are the same, so they can be reused, really). Still happened to use it for.. some reason, not sure if there was a good one for it though :stuck_out_tongue: