Open blegat opened 1 year ago
This is a problem in the wrapper, the type:
CGAL::Triangulation_3<CGAL::Epick, CGAL::Triangulation_data_structure_3<CGAL::Triangulation_vertex_base_3<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_3<void> >, CGAL::Delaunay_triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_cell_base_3<CGAL::Epick, CGAL::Triangulation_ds_cell_base_3<void> > >, CGAL::Sequential_tag>, CGAL::Default>
probably hasn't been added using add_type
. (note: you can demangle the type using the c++filt -t <type>
command)
It's ugly, but unfortunately one must add the types manually and resort to the WRAP_TRIANGULATION
macro for mapping the 3D delaunay triangulation. I did some testing and got it to mostly work, but ran into a couple issues when attempting use already defined methods for Edge/Facet/Vertex supertypes. Despite having defined SuperType
s for said 3D Delaunay Triangulation's components, upcasting wasn't cooperating. I might look into this further if I have time.
Thanks! Did you push it on a branch that I can take a look at?
I tried to apply the same principle as done with Regular_triangulation_3
, but I couldn't get that working at the time, I might've been missing something. Here's a few local changes I tried on the lib side of things
diff --git a/src/triangulation_3.cpp b/src/triangulation_3.cpp
index fbb0a5e..73a7745 100644
--- a/src/triangulation_3.cpp
+++ b/src/triangulation_3.cpp
@@ -59,7 +59,9 @@
namespace jlcxx {
using namespace jlcgal;
- template<> struct SuperType<DTr_3> { typedef CGAL::Triangulation_3<Kernel, typename DTr_3::Triangulation_data_structure> type; };
+ template<> struct SuperType<DTr_3::Edge> { typedef DTr_3::Tr_Base::Edge type; };
+ template<> struct SuperType<DTr_3::Facet> { typedef DTr_3::Tr_Base::Facet type; };
+ template<> struct SuperType<DTr_3::Vertex> { typedef DTr_3::Tr_Base::Vertex type; };
template<> struct SuperType<RTr_3::Edge> { typedef RTr_3::Tr_Base::Edge type; };
template<> struct SuperType<RTr_3::Facet> { typedef RTr_3::Tr_Base::Facet type; };
@@ -76,13 +78,17 @@ void wrap_triangulation_3(jlcxx::Module& cgal) {
auto tvertex = cgal.add_type<Tr_3::Vertex>(tr_name + "Vertex");
const std::string dtr_name = "Delaunay" + tr_name;
- auto dtr = cgal.add_type<DTr_3>(dtr_name, tr.dt());
+ cgal.add_type<DTr_3::Tr_Base>(dtr_name + "Base");
+ auto dtr = cgal.add_type<DTr_3>(dtr_name);
+ auto dtredge = cgal.add_type<DTr_3::Edge>(dtr_name + "Edge", tedge.dt());
+ auto dtrface = cgal.add_type<DTr_3::Facet>(dtr_name + "Facet", tface.dt());
+ auto dtrvertex = cgal.add_type<DTr_3::Vertex>(dtr_name + "Vertex", tvertex.dt());
const std::string rtr_name = "Regular" + tr_name;
cgal.add_type<RTr_3::Tr_Base>(rtr_name + "Base");
auto rtr = cgal.add_type<RTr_3> (rtr_name);
auto rtedge = cgal.add_type<RTr_3::Edge> (rtr_name + "Edge", tedge.dt());
- auto rtface = cgal.add_type<RTr_3::Facet> (rtr_name + "Facet", tface.dt());
+ auto rtface = cgal.add_type<RTr_3::Facet> (rtr_name + "Facet", tface.dt());
auto rtvertex = cgal.add_type<RTr_3::Vertex>(rtr_name + "Vertex", tvertex.dt());
tvertex
@@ -100,21 +106,10 @@ void wrap_triangulation_3(jlcxx::Module& cgal) {
dtr
// Creation
- .constructor<const DTr_3&>()
+ .WRAP_TRIANGULATION(DTr_3, dtr)
.method(dtr_name, [](jlcxx::ArrayRef<DTr_3::Point> ps) {
return jlcxx::create<DTr_3>(ps.begin(), ps.end());
})
- ;
- cgal.set_override_module(jl_base_module);
- dtr
- // Insertion and Removal
- .method("insert!", [](DTr_3& dt, jlcxx::ArrayRef<DTr_3::Point> ps) -> DTr_3& {
- dt.insert(ps.begin(), ps.end());
- return dt;
- })
- ;
- cgal.unset_override_module();
- dtr
// Queries
.method("nearest_vertex", [](const DTr_3& dt, const DTr_3::Point& p) {
return *dt.nearest_vertex(p);
I removed the SuperType
def for Delaunay_triangulation_3
since we can't really go about this with inheritance. I remember having similar issues when mapping the 2D Triangulation classes, hence the existence of macros such as WRAP_TRIANGULATION
.
Ideally, this would be properly mapped out, but there are a lot of things being masked when mapping to Julia. Makes it relatively easier, but has its shortcomings :\
@wrapmodule
seems to fail. @barche is that an issue from the C++ wrapper or do I need to add something on the Julia side ?