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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Shape factory
Shape gallery
What's new
System requirements
Download Center
Public license
Getting started
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
Home / Developer Corner / Forums / Usage issues / Bezier Curve loses poles if created from TopoDS_Edge

Bezier Curve loses poles if created from TopoDS_Edge

Bezier Curve loses poles if created from TopoDS_Edge
Laszlo Kudela 2012/10/05 17:17
Hello everyone,

I have a class called ObjectBezierCurve, which has a member (along with some other data) called myTopoDS_Edge (of course of type TopoDS_Edge).

The constructor gets an AIS_Shape, and the TopoDS_Edge is created as follows:

myTopoDS_Edge = TopoDS::Edge(theAIS_Shape->Shape());

To access myTopoDS_Edge, there is a function called get_TopoDS_Edge, which is by the way inherited from the superclass ObjectEdge. Then, this ObjectBezierCurve class is stored in a TColStd_HSequenceOfTransient sequence. In a completely different part of the program, I want to reconstruct the Bézier curve using myTopoDS_Edge of the class. This part looks like the following:

for(int i=1;i<=myData->Length();i++)
          Handle(Object) curObject = Handle(Object)::DownCast(myData->Value(i));
          if(Object->GeometryType() == CurveObject)
               Handle(ObjectEdge) curEdge = Handle(ObjectEdge)::DownCast(curObject);
               TopoDS_Edge curTopoDS_Edge = curEdge->get_TopoDS_Edge();
               Standard_Real startParam, endParam;
               Handle(Geom_Curve) theGeom_Curve = BRep_Tool::Curve(curTopoDS_Edge,startParam,endParam);

The problem is now if I cast theGeom_Curve into a Geom_BezierCurve, the curve loses all its poles, and only the first two of them remain. The weird thing is that if I create a Geom_Curve from myTopoDS_Edge in the constructor of ObjectBezierCurve, and cast it to Geom_BezierCurve, it gives back the proper Bezier curve. However, in this other part of the program I do completely the same thing, and gives back a very different one. Is this a known bug or I am missing something?

Laszlo Kudela 2012/10/06 17:30
If someone is interested, I have found the answer to the question.

It turned out that the TopoDS_Shape returned by


contains a Handle to a memory space which is constantly modified in another part of the program. It turned out that the Geom_BezierCurve in this memory space is a Bezier Curve with 2 poles by default.

So in summary, I can say that if you crate an AIS_Shape based on a TopoDS_Shape be careful what Geom_***** entity you use. Make sure you do not modify this memory address somewhere else. If you do, and want your new shape to be a separate one, use the Copy() function that creates a completely new Geom_ entitiy in a different address.

So the solution was something like this:

Standard_Real a,b;
Handle(Geom_Curve) oldGeomCurve = Brep_Tool::Curve(myTopoDS_Edge,a,b);
Handle(Geom_Curve) newGeomCurve = Handle(Geom_Curve)::DownCast(oldGeomCurve->Copy());
BRepBuilderAPI_MakeEdge ME(newGeomCurve);
myTopoDS_Edge = ME.Edge();
Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

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