2010/3/14 Dave Cowden <dave.cow...@gmail.com> > Hi, All: > > I'm running into a problem, wondering if someone can help. > > I am trying to get the underlying curve of an edge, and getting a swig > error message. > Heres' a simplified version of my code( which gets the endpoints of the > curve ) > > from OCC import BRepBuilderAPI,gp,GeomAdaptor > > brepTool = BRep.BRep_Tool(); > builder = > BRepBuilderAPI.BRepBuilderAPI_MakeEdge(gp.gp_Pnt(0,0,0),gp.gp_Pnt(1,1,1)); > builder.Build(); > edge = builder.Edge(); > hc = brepTool.Curve(edge); > c = GeomAdaptor.GeomAdaptor_Curve(hc[0]); > p1 = c.Value(hc[1]); > p2 = c.Value(hc[2]); > > it prints this message: > > "swig/python detected a memory leak of type 'Handle_Geom_Curve *', no > destructor > found." > > > I have been using the alternative code below that does not give this > message, but doesnt seem to perform as well: I was surprised after running > the code below that it does not seem as fast as the above: > > curve = BRepAdaptor.BRepAdaptor_Curve(edge); > pa1 = curve.FirstParameter(); > pa2 = curve.LastParameter(); > curveType = curve.GetType(); > #get first and last points. > p1 = gp.gp_Pnt(); > p2 = gp.gp_Pnt(); > BRepLProp_CurveTool.Value(curve,pa1,p1 ); > BRepLProp_CurveTool.Value(curve,pa2,p2 ); > > I am using pythonOCC version 0.4 on windows XP pro. Is either of the above > methods preferred? > Thanks in advance! > > Hi Dave,
The first one solution to be better. In your code, a function returns a swig object of type 'Handle_Geom_Curve', but the python proxy for this class is not loaded -> you don't have access to all methods for this object (and actually the __del__ method, causing a memory leak). The fix: add the following line at the top of your code: from OCC.Geom import * Cheers, Thomas
_______________________________________________ Pythonocc-users mailing list Pythonocc-users@gna.org https://mail.gna.org/listinfo/pythonocc-users