9and3 / Cockroach

A plug-in for Rhino point cloud post-processing and meshing
GNU Lesser General Public License v3.0
66 stars 10 forks source link

Add Alpha Wrapping from CGAL 5.5 #4

Closed mariuszhermansdorfer closed 1 year ago

mariuszhermansdorfer commented 1 year ago

Hey Developers,

as mentioned on the Rhino forum, Alpha Wrapping is not part of Cockroach yet. If you were interested in adding this functionality, I'd be happy to contribute to the code base.

Would need some guidance with marshalling into unmanaged code, but am eager to learn.

petrasvestartas commented 1 year ago

There are several steps if you want to do it yourself:

Step 1: Install CMake. Install cockroach libraries, when running CMakeLists.txt

Step 2: Write simple Console Application in C++ to test a data set of this function.

Step 3: Create C++ rhino plugin and run the function. Here you will need to write rhino mesh conversions. Test various inputs in Rhino.

Step 4: If you want to bind it use PInvoke for C# or pybind11 for Python.

That is a typical process I use.

mariuszhermansdorfer commented 1 year ago

Thanks for your quick response @petrasvestartas!

will dive into it and get back to you.

mariuszhermansdorfer commented 1 year ago

Hey @petrasvestartas, I've managed to compile Cockroach following the steps provided in the readme. It does open the my_exe.exe file and I can see the test point cloud. However, there is no *.DLL file generated for CGAL. Do you know how to modify the cmakelists file to create one?

petrasvestartas commented 1 year ago

The minimal example is under the libraries section: https://github.com/petrasvestartas/CMAKE#libraries

in short you need to replace the executable: add_executable(my_exe main_cilantro.cpp) to the static library: add_library(LIBRARY_NAME STATIC/SHARED/OBJECT source1.cpp source2.cpp)

mariuszhermansdorfer commented 1 year ago

thanks @petrasvestartas, I'll give it a go and report back!

mariuszhermansdorfer commented 1 year ago

Hmm, I just realized that CGAL is a header-only library hence it doesn't come with any .cpp files. I'd probably have to create these first to be able to compile a DLL. Having no experience with c++, I'd need some guidance to get there.

Do you have any good examples in cockroach where you call CGAL methods from a .cpp file?

petrasvestartas commented 1 year ago

CPP files are just implementations of function declaration in header files. They are c++ files just with different endings.

STEP1 I suggest to start from PInvoke of simple addition function (ignore the rest of the code for now): https://github.com/9and3/Cockroach/blob/Cockroach/PInvokeCGAL/baseCGAL.cpp https://github.com/9and3/Cockroach/blob/Cockroach/PInvokeCGAL/baseCGAL.h

STEP2 The reason why you need function declarations, is that on C# you would call these declarations, without and you do not need to care about the actual code of the function: https://github.com/9and3/Cockroach/blob/Cockroach/PInvokeCSharp/UnsafeCGAL.cs

STEP3 And then you can actually test these functions: https://github.com/9and3/Cockroach/blob/Cockroach/PInvokeCSharp/TestCGAL.cs

I would like to ask you to open issues in the official IBOIS Cockroach repository. This repo was only a temporary one. Issues can be created here: https://github.com/ibois-epfl/Cockroach/issues

petrasvestartas commented 1 year ago

If no further development is done in this question I close it. If yes feel free to open the issue again.