Thomas Paviot a écrit : > Jelle Feringa a écrit : > > >> Hi, >> >> I'm trying to acces the triangulation of an object. >> That's ok, until the moment I need to deal with Handle_* >> I'm not aware of the concept of Handle_ ( related to smart_pointers, >> right? ) so go easy on me ;') >> >> What I'm trying write is similar to this C++ snippet found on OCC forum: >> >> TopoDS_Face F =TopoDS::Face(ex.Current()); >> TopLoc_Location L; >> Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L); >> TColgp_Array1OfPnt tab(1,(facing->NbNodes())); >> tab = facing->Nodes(); >> Poly_Array1OfTriangle tri(1,facing->NbTriangles()); >> tri = facing->Triangles(); >> >> >> myT = occ.BRep_Tool().Triangulation(f, f.Location()) >> >> So, when accessing myT, it only has Acces, DownCast and a couple of >> other methods, not the .NbNodes / .NbTriangles methods I need to acces >> the data on the triangle. >> What can I do to overcome this? >> >> Cheers & many thanks in advance, >> >> -jelle >> >> >> > Hi Jelle, > > The Triangulation method returns a Handle_Poly_Triangulation object and > not a Poly_Triangulation object. Under C++, you can access all members > fonctions of an object from its handle. It's not possible in pythonOCC: > then Handle_* inherits from Handle_Standard_Transient class and the > '->()' operator is not wrapped. You can just access methods of > Handle_Standard_Transient (ie DownCast, Access etc.). > > I do not know how to get the object pointed by a Handle_* object. > > The OpenCascade handler management system (smart pointers) is the major > issue I face in the development of pythonOCC (maybe because I do not > understand it very well). I think that a more pythonic way for the > wrapper would be to hide the handler mechanism to the end-users so they > users have just to work with objects and not their Handle. > > Best regards, > > Thomas > > >
I found this two posts related to smart pointers management with SWIG: http://osdir.com/ml/programming.swig/2002-08/msg00148.html http://www.nabble.com/smart-pointers-and-const-td16289841.html I think it's a good start. Thomas _______________________________________________ Minerva-pythonocc mailing list Minerva-pythonocc@gna.org https://mail.gna.org/listinfo/minerva-pythonocc