How to transfer Handle_AIS_InteractiveObject to C# ?


I want to use C# to make a shape and get the handle of the shape.

I try to modify the shell of C# sample, but have no idea how to return Handle_AIS_InteractiveObject to C#?

Anyone can help me?



In OCCViewer:
Handle_AIS_InteractiveObject OCCViewer::MakeCircle(float x, float y, float z, float i, float j, float k, float d)
gp_Ax2 Ax(gp_Pnt(x, y, z), gp_Dir(i, j, k));
gp_Circ Cir(Ax, d);
TopoDS_Edge c = BRepBuilderAPI_MakeEdge(Cir);
Handle(AIS_Shape) myCircle = new AIS_Shape(c);
myAISContext->SetDisplayMode(myCircle, 1);
return myCircle;

In shell:
void MakeCircle(float x, float y, float z, float i, float j, float k, float d)
if (myOCCViewer != NULL)
Handle(AIS_InteractiveObject) h_Object = myOCCViewer->MakeCircle(x, y, z, i, j, k, d);

//??????????? how to return h_Object;

Pawel's picture

I think the point is to use shell instead of transferring objects to C#. That's what the wrapper is for.

At least this is the way I do it. I'm not saying this impossible but I guess you would need a C# wrapper for the OC class otherwise.


Jonathan Hill's picture

Hi Jack,

You can download an example Visual Studio 2005 (.NET Framework v2.0) project I have created from: -

(the path is case sensitive and it contains about 20Mb of files)

Its a simple Windows form hosting a OpenCASCADE window with a rotating sphere created on a thread.
(The debug folder also contains all the runtime .dll files, including the OpenCASCADE v5.2 runtime files)

I am currently working on support for the new OpenCASCADE v6.1.0 release.

Let me know if you have any comments or queries.


Gerhard Hofmann's picture

I generated C# wrapper from CDL files. To be platform independant I use PInvoke. Some of it is discussed here:
You can also download a trial version of CADability from which includes this wrapper machanism. You only need these two dlls: "OpenCascade.dll", which is a C# class library that you can browse and "OCasToCSharp.dll" which is a plain C++ dll that is accessed from opaencascade.dll.
There is only a subset of the CDL files converted, just those parts we need ourselves, but since conversion is done automatically, we could wrap any classes.
I would be glad to get some feedback.