CGAL.jl
CGAL.jl copied to clipboard
Use libcgal_jll v0.18
@wrapmodule
seems to fail. @barche is that an issue from the C++ wrapper or do I need to add something on the Julia side ?
julia> using CGAL
[ Info: Precompiling CGAL [15fcbb24-5a00-427b-98c5-e32879a22884]
C++ exception while wrapping module CGAL: No appropriate factory for type N4CGAL15Triangulation_3INS_5EpickENS_30Triangulation_data_structure_3INS_27Triangulation_vertex_base_3IS1_NS_30Triangulation_ds_vertex_base_3IvEEEENS_34Delaunay_triangulation_cell_base_3IS1_NS_25Triangulation_cell_base_3IS1_NS_28Triangulation_ds_cell_base_3IvEEEEEENS_14Sequential_tagEEENS_7DefaultEEE
ERROR: LoadError: No appropriate factory for type N4CGAL15Triangulation_3INS_5EpickENS_30Triangulation_data_structure_3INS_27Triangulation_vertex_base_3IS1_NS_30Triangulation_ds_vertex_base_3IvEEEENS_34Delaunay_triangulation_cell_base_3IS1_NS_25Triangulation_cell_base_3IS1_NS_28Triangulation_ds_cell_base_3IvEEEEEENS_14Sequential_tagEEENS_7DefaultEEE
Stacktrace:
[1] register_julia_module
@ C:\Users\blegat\.julia\packages\CxxWrap\IdOJa\src\CxxWrap.jl:405 [inlined]
[2] readmodule(so_path::String, funcname::Symbol, m::Module, flags::Nothing)
@ CxxWrap.CxxWrapCore C:\Users\blegat\.julia\packages\CxxWrap\IdOJa\src\CxxWrap.jl:734
[3] wrapmodule(so_path::String, funcname::Symbol, m::Module, flags::Nothing)
@ CxxWrap.CxxWrapCore C:\Users\blegat\.julia\packages\CxxWrap\IdOJa\src\CxxWrap.jl:738
[4] include
@ .\Base.jl:419 [inlined]
[5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
@ Base .\loading.jl:1554
in expression starting at C:\Users\blegat\.julia\dev\CGAL\src\CGAL.jl:1
in expression starting at stdin:1
ERROR: Failed to precompile CGAL [15fcbb24-5a00-427b-98c5-e32879a22884] to C:\Users\blegat\.julia\compiled\v1.8\CGAL\jl_1B64.tmp.
Stacktrace:
l.jl:222
[12] (::VSCodeServer.var"#107#109"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
@ VSCodeServer c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\repl.jl:186
[13] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging .\logging.jl:511
[14] with_logger
@ .\logging.jl:623 [inlined]
[15] (::VSCodeServer.var"#106#108"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
@ VSCodeServer c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\repl.jl:187
[16] #invokelatest#2
@ .\essentials.jl:729 [inlined]
[17] invokelatest(::Any)
@ Base .\essentials.jl:726
[18] macro expansion
@ c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
[19] (::VSCodeServer.var"#61#62")()
@ VSCodeServer .\task.jl:484
julia> using CGAL
[ Info: Precompiling CGAL [15fcbb24-5a00-427b-98c5-e32879a22884]
CxxWrap.CxxWrapCore.wrapmodule(get(ENV, "JLCGAL_LIBPATH", libcgal_julia()), :define_julia_module, CGAL, nothing)
ERROR: LoadError: UndefVarError: AffTransformation2 not defined
Stacktrace:
[1] top-level scope
@ C:\Users\blegat\.julia\dev\CGAL\src\kernel.jl:78
[2] include(mod::Module, _path::String)
@ Base .\Base.jl:419
[3] include(x::String)
[11] repleval(m::Module, code::Expr, #unused#::String)
@ VSCodeServer c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\repl.jl:222
[12] (::VSCodeServer.var"#107#109"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
@ VSCodeServer c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\repl.jl:186 [13] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging .\logging.jl:511
[14] with_logger
@ .\logging.jl:623 [inlined]
[15] (::VSCodeServer.var"#106#108"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
@ VSCodeServer c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\repl.jl:187
[16] #invokelatest#2 @ .\essentials.jl:729 [inlined]
[17] invokelatest(::Any)
@ Base .\essentials.jl:726
[18] macro expansion @ c:\Users\blegat\.vscode\extensions\julialang.language-julia-1.7.12\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
[19] (::VSCodeServer.var"#61#62")() @ VSCodeServer .\task.jl:484
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 :\