Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

To Draw a CIRCLE

To Draw a CIRCLE
shmsh 2013/01/25 02:13
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
You have to be logged in to download the attached file
shmsh 2013/01/30 12:18
All Dear

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

Chamari 2013/02/05 14:48

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 2013/02/06 01:19
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????

Chamari 2013/02/06 07:51
"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 <AIS_InteractiveContext.hxx>
shmsh 2013/02/08 22:10
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(AIS_InteractiveContext) myAISContext;
     myAISContext = new AIS_InteractiveContext(myViewer);
myAISContext->Display(shape , 1);

and the includes header are :
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <gp_Circ.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <AIS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <GC_MakeSegment.hxx>
#include <Standard_Macro.hxx>
#include <AIS_InteractiveContext.hxx>
#include <V3d_Viewer.hxx>

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

shmsh 2013/02/08 22:16

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 ;

Chamari 2013/02/11 08:02
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 2013/02/12 04:52
Dear Chamari

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

Great dear

Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map