Could you give an example how to pass an object like a NurbsCurve from C# to C++.
I underdtand it should somewhere use the NonConstPointer but how?
In RhinoCommon, a NurbsCurve
holds on to an private IntPtr which a points to a ON_NurbsCurve objects. NonConstPointer
returns this IntPtr value.
Does this help?
– Dale
The functions for accessing these pointers are in the Rhino.Runtime.Interop class in RhinoCommon
Dale and @stevebaer , I am revisiting this topic from a while ago. Dale, your project Moose demonstrates exactly what your comment states.
Correct me if I am wrong, but RhinoCommon acts as a c# wrapper class of the c++ Rhino DLL. Does this mean every single Rhino class has a wrapper class in RhinoCommon that contains an IntPtr
that points to in an instance of its c++ Rhino Object, as well as public static “helper” methods that expose the public methods of the object instance it contains? And all this is accessed on the c# side through p/invoke? I knot p/invoke is popular for pure C style APIs, and something like COM Interop or c++/CLI is used when you’re dealing with object oriented c++. So, why p/invoke?
Do I have the general design of the Rhino / RhinoCommon correct? Could you help give some insight into your design choices in regards to the p/invoke as opposed to other options?
Thank you.
For the most part, yes.
This is true for RhinoCommon class that inherit from IDisposible.
Yes
P/Invoke is easy to implement, and it is fast and efficient. Also, the other technologies you mention (e…g COM, C++/CLI) are not cross platform.
– Dale