Hello!
Im a student and i`m trying to create Windows form application in c# which is using open cascade lib. but i can`t handle with that. Have anybody some example of similar application ? Please help me !
Pawel Tue, 06/23/2009 - 11:29
Hi Kamil,
there is a c# example shipped with the OCC distribution. Have you checked that?
i've managed to run c# sample, though it was not easy.. first i fused shell project into occ project, then copied all OCC dlls to debug directory and only then it worked... and dont forget to set path to tkopengl.dll
Kamil you can use narocadwrapper. When You are creating project in VS you just need to add dll to referencees of your project. Then you have most of functions of OCC
Hi! I'm a student and i'm trying to develop a C# application.
Can someone write a very very little tutorial for embed and use narocad wrapper? [in visual studio or in SharpDevelop]
If you installed OCC you have folder \OpenCascade\win32\samples\standard\c#\IE. In the folder you have sample project with 3d view written in c# and c++. It contains its own wrapper but narocadwrapper is better. You create new project of dll library with class viewer thats inherits after UserControl class, this is your 3d viewer control. After you finish you are adding your control to Tool Box of VS2005 ("Tool>>Choose Tool Box Items" in .NET Framework components you are clicking Browse then you are choosing location of your dll with control inside). Now last thing is to drag you control on window.
If you download the NaroCad project there are two simple projects in the trunk\wrappers\tests\. One of them is the MakeBottle sample ported to these wrappers.
Another complete and fully working visual project that you might use for start is located on branches\newtestproject\OpenCascadeResearch\.
ok, I have embed the view user control!
The MakeBottle example is very complex and I need only to draw lines, circles and write some text.
How I can do it? I have only to add simple entities to my draw. Could anyone help me?
About adding your shape to OCC context, the code may be the following:
OCTopoDS_Shape shape = makeSegment1.Shape();
OCAIS_Shape interactive = new OCAIS_Shape(shape);
context.Display(interactive, true);
So all you need is to obtain the TopoDS_Shape and to add it to OCC context.
The procedures are documented based on OpenCascade documentations and headers. The NaroCAD project only provide (fairly complete but still partial) wrappers. So if you have an OpenCascade code, you can convert the code mostly by writing: using OCNaroWrappers; and put OC before every OpenCascade class.
So if your code is like this:
gp_Pnt a (10, 20, 10);
the C# code will be:
OCgp_Pnt a = new OCgp_Pnt(10, 20, 10);
In rest the code follows the OpenCascade "look and feel".
Thanks! I added new shapes and I changed the colors!
I still need help for two things:
Add TEXT and
add a control for the user interaction such as Zoom and Pan: (at least for the Window Zoom).
hi, for Pan there is no problem
add to your project the events onMouseDown and onMouseMouve
for the event onMouseDown store the e.X and the e.Y in tow different variables (Lx and Ly)
{
Lx = e.X;
Lx = e.Y;
}
Tue, 06/23/2009 - 11:29
Hi Kamil,
there is a c# example shipped with the OCC distribution. Have you checked that?
Pawel
Fri, 06/26/2009 - 22:23
yes i did, but there is a lot of source code and it doesnt work`s correctly. It is compiling but return some exceptions. I`m using VS 2005 and 2008
Sat, 06/27/2009 - 02:22
i've managed to run c# sample, though it was not easy.. first i fused shell project into occ project, then copied all OCC dlls to debug directory and only then it worked... and dont forget to set path to tkopengl.dll
Sat, 02/20/2010 - 07:37
Hi,
I want to user OCC and shell projects that are available in C# sample ...how can I do that.
basically I want to use OCC and shell project in my current C# project, I tried lot but no luck to get it work..please help me...
Thanks
Sat, 06/27/2009 - 13:57
Hi Kamil,
I would suggest searching the forum. There have already been some posts dealing with running the sample.
Pawel
Tue, 07/21/2009 - 18:20
Kamil you can use narocadwrapper. When You are creating project in VS you just need to add dll to referencees of your project. Then you have most of functions of OCC
Sun, 07/26/2009 - 13:47
yes, i did it and everything works fine :)
Mon, 07/27/2009 - 18:21
Hi! I'm a student and i'm trying to develop a C# application.
Can someone write a very very little tutorial for embed and use narocad wrapper? [in visual studio or in SharpDevelop]
Tue, 07/28/2009 - 12:52
If you installed OCC you have folder \OpenCascade\win32\samples\standard\c#\IE. In the folder you have sample project with 3d view written in c# and c++. It contains its own wrapper but narocadwrapper is better. You create new project of dll library with class viewer thats inherits after UserControl class, this is your 3d viewer control. After you finish you are adding your control to Tool Box of VS2005 ("Tool>>Choose Tool Box Items" in .NET Framework components you are clicking Browse then you are choosing location of your dll with control inside). Now last thing is to drag you control on window.
Tue, 07/28/2009 - 20:16
Thanks!!
Tue, 07/28/2009 - 18:21
Hi,
If you download the NaroCad project there are two simple projects in the trunk\wrappers\tests\. One of them is the MakeBottle sample ported to these wrappers.
Another complete and fully working visual project that you might use for start is located on branches\newtestproject\OpenCascadeResearch\.
Mihai
Sat, 08/15/2009 - 17:13
ok, I have embed the view user control!
The MakeBottle example is very complex and I need only to draw lines, circles and write some text.
How I can do it? I have only to add simple entities to my draw. Could anyone help me?
Sun, 08/16/2009 - 12:57
For example:
using System;
using System.Windows.Forms;
using OCNaroWrappers;
namespace test
{
public partial class MainForm : Form
{
private ViewUserControl control;
public MainForm()
{
InitializeComponent();
control = new ViewUserControl();
control.Dock = DockStyle.Fill;
this.Controls.Add(control);
double x1 = 0; double x2 = 10; double y1 = 0; double y2 = 10;
OCgp_Pnt aPnt1 = new OCgp_Pnt(x1,y1,0);
OCgp_Pnt aPnt2 = new OCgp_Pnt(x2,y2,0);
OCGC_MakeSegment makeSegment1 = new OCGC_MakeSegment(aPnt1, aPnt2);
// What I have to write for add this segment??
control.ZoomAll();
}
}
}
Sun, 08/23/2009 - 03:51
Hi,
I think you have two problems here:
- create a window that embeds OCC view
- 2nd: add to context your shape
About the first one, the code that NaroCAD uses for this may be found here: http://narocad.svn.sourceforge.net/viewvc/narocad/trunk/narocad/Source/P...
About adding your shape to OCC context, the code may be the following:
OCTopoDS_Shape shape = makeSegment1.Shape();
OCAIS_Shape interactive = new OCAIS_Shape(shape);
context.Display(interactive, true);
So all you need is to obtain the TopoDS_Shape and to add it to OCC context.
Bests,
Ciprian
Tue, 08/25/2009 - 16:34
Thanks! I have done! But this command:
OCTopoDS_Shape shape = makeSegment1.Shape();
give to me this error:
'OCNaroWrappers.OCGC_MakeSegment' does not contain a definition for 'Shape' etc. etc...
What's happening?
Wed, 08/26/2009 - 17:04
OCGC_MakeSegment::Value() returns OCGeom_TrimmedCurve object type.
OCGeom_TrimmedCurve trimCurve = makeSegment1.Value();
OCBRepBuilderAPI_MakeEdge edgeMaker = new OCBRepBuilderAPI_MakeEdge(trimCurve);
OCTopoDS_Shape shape = edgeMaker.Shape();
OCAIS_Shape interactive = new OCAIS_Shape(shape);
context.Display(interactive, true);
Thu, 08/27/2009 - 16:10
Thanks! It's perfect!
But, where I can found more information about these procedures?
I wouldn't want to ask for every single entity that I have to draw!
Thanks a lot and sorry for my English!
Thu, 08/27/2009 - 17:30
The procedures are documented based on OpenCascade documentations and headers. The NaroCAD project only provide (fairly complete but still partial) wrappers. So if you have an OpenCascade code, you can convert the code mostly by writing: using OCNaroWrappers; and put OC before every OpenCascade class.
So if your code is like this:
gp_Pnt a (10, 20, 10);
the C# code will be:
OCgp_Pnt a = new OCgp_Pnt(10, 20, 10);
In rest the code follows the OpenCascade "look and feel".
Tue, 09/01/2009 - 23:37
Thanks! I added new shapes and I changed the colors!
I still need help for two things:
Add TEXT and
add a control for the user interaction such as Zoom and Pan: (at least for the Window Zoom).
If anyone can help me, I would be very grateful.
Wed, 09/02/2009 - 15:42
hi, for Pan there is no problem
add to your project the events onMouseDown and onMouseMouve
for the event onMouseDown store the e.X and the e.Y in tow different variables (Lx and Ly)
{
Lx = e.X;
Lx = e.Y;
}
now for the event onMouseMouve use this
{
view.Zoom(Lx,Lx, e.X, e.Y);
Lx = e.X;
Lx = e.Y;
}
It works perfectly, so i have also the problem of displaying text, so if you found the solution please contact me
Futate2001@yahoo.fr
Wed, 09/02/2009 - 15:48
sorry, i was talking of Zoom
For pan use the folowing function onMouseMouve
{
Lx = e.X;
Ly = e.Y;
View.Pan(e.X-Lx, Ly- e.Y,1)
}
sorry for the mistake, So the problem persists for displaying text
good luck