Hello,
I think that there's a relatively quick way to port OpenCascade to .NET without using the SLOW PInvoke (or IJW), using Visual C++ 2005. Imagine having OpenCascade just compiled to CLR. Anyway it would be well usable only using C++/CLI (exactly like the native one), but usable at a decent level using C# and VB. The problem is that C# is unable to use Value classes (which OCC uses).
I saw the good "Wrapper" to C# , and the Syntax looks nice. Anyway:
- It requires 3 levels of indirection, plus additional memory for each used object.
- It is slow (anyway it won't be really noticeable 'cause OCC functions are more relevant)
- You could not port existing C++ code.
I just did some preliminar investigations:
- Handle classes and functions could be converted/used without problems in C# too. Handles could map exactly CLI Handles (^)
- In c++ you could use Exactly the same code( unless you use direct pointers)
- In C# you would use the same code with Handles , but non-handles functions require a different syntax. For example
C++
TopoDS_Shape A = GetMyTopoDsShape(10);
--
C#
TopoDS_Shape A = new TopoDS_Shape();
GetMyTopoDsShape(ref A,10);
(is really annoying!)
- You won't be able to use namespaces since you don't modify (almost) the source code.
---------
The steps should be the following:
- Port the System classes to .NET (not too Hard), just Wrap to NET types. Note: C++ types and CRT are automatically wrapped!
- substitute each "class" with "ref class" with the help of a preprocessor
- Make sure that each Class has a default constructor (even empty)and a copyconstructor (otherwise you won't compile). Maybe that's be biggest problem.
- Recompile the whole thing with the /clr option
- Tune some native high-performance requirements (like OpenGl).
At least for non visual classes it should work! Native things (OpenGL) will suffer of the native/wrapped transition. Anyway, they ported DirectX...
You can the use OCC functions natively without a wrapper from VB.NET , C#, C++/CLI
What about that?
Thomas