To Draw a CIRCLE

Hello there
A beginner user of OCCT is here ..
I want to start a 3D modeling project but before that......
I want to create a small program on VC9 as an MDI application to draw a circle (from center and radius )in a 3D space when the user give the center point Coordinate in XYZ plane and the radius of the circle in certain Dialog Box as shown in attached file, can any body tell me kindly how to do that....
Any help would be greatly appreciated

and if any body have good knowledge of programming using MFC ,,, I have a request to post His Email.
for general knowledge :
I have installed and compiled OCCT libraries with Microsoft Visual Studio and every thing works fine

Thanks a lot for any kind of help

Regards To All

shmsh's picture

All Dear

Kindly reply .......
it is too urgent .......

Regards

Chamari's picture

Hi,

this is how to draw a circle.
x,y,z and radius should be given as input.

Standard_Real x;
Standard_Real y;
Standard_Real z;
Standard_Real radius;
gp_Dir dir(0,0,1); // you can change this

gp_Pnt point(x,y,z);
gp_Circ circle(gp_Ax2( point, dir),radius);
BRepBuilderAPI_MakeEdge makeEdge(circle);
Handle(AIS_Shape) shape = new AIS_Shape(TopoDS_Edge());
shape ->Set(makeEdge.Edge());
myAISContext->Display(shape , 1);

shmsh's picture

Dear Chamari

thanks for reply
but when i run the code i got these error
error c2065 : error"myAISContext" undeclared identifier
error c2228 left of "->" must point to class/struct/union

so what is wrong????

Regards

Chamari's picture

"myAISContext" is a handle to AIS_InteractiveContext.

Handle(AIS_InteractiveContext) myAISContext;
myAISContext = new AIS_InteractiveContext(myViewer);

where myViewer is a Handle(V3d_Viewer).

and you might need to include the header file as well.

#include

shmsh's picture

Dear Chamari

now my code is something like this (first I gave constant values to the coordinates and radius) :

gp_Dir dir(0,0,1);
gp_Pnt point(10,10,10);
gp_Circ circle(gp_Ax2( point, dir),50);
BRepBuilderAPI_MakeEdge makeEdge(circle);
Handle (AIS_Shape) shape = new AIS_Shape(TopoDS_Edge());
shape ->Set(makeEdge.Edge());
Handle(V3d_Viewer)myViewer;
Handle(AIS_InteractiveContext) myAISContext;
myAISContext = new AIS_InteractiveContext(myViewer);
myAISContext->Display(shape , 1);

and the includes header are :
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

and now when I build the solution it succeeded but on Debugging I got an error pointing toward last line of the code which is
myAISContext->Display(shape , 1);
and the error is :
" Unhandled exception at 0x0183ffe5 (TKV3d.dll) in CIRCLE.exe: 0xC0000005: Access violation reading location 0xfefd0020"
so what is the problem of that error???

and thanx for replying dear

Regards

shmsh's picture

Dear

sorry I forgot to mention that on "Break command" it points to V3d_Viewer.cxx file to line 354 :
Handle(Visual3d_ViewManager) V3d_Viewer::Viewer() const {
return MyViewer ;

thanks

Chamari's picture

I guess it's because u haven't instantiate myViewer.

myViewer= new V3d_Viewer(...)

Please look at the OCC samples. They include a lot of information and solve the problems encounter at the beginning

shmsh's picture

Dear Chamari

exactly.....yes I did not instantiate V3d_Viewer
Thanks for help

Great dear

Regards