Hi Thomas,

I'm sorry for my storm of emails here ;')
I've spend today learning the pythonocc API, which is very interesting, but I've been experiencing *numerous* crashes that I cannot explain.
I hope you dont mind if I share some of 'em with you?

Is there a reason why the following code is crashing?
It sures does return a Face, but when accessing its methods, Boom...

shape = ms.Shape()
topo = Topo(shape)
shape.topology = topo


for f in shape.topology.faces():
    f # TopoDS_Face

    f.Checked() # Crashes


#------


Same thing when accessing the mesh of an object.
When accessing triangles, Kaboom...

sphere =occ.BRepPrimAPI_MakeSphere(12,12)
#myShape = sphere.Shape()

ms = occ.BRepBuilderAPI_MakeSolid()
ms.Add(sphere.Shell())
ms.Build()
myShape = ms.Solid()

bbox = get_bounding_box(ms.Shape())
myT = occ.BRepMesh_FastDiscret(0.1, ms.Shape(), bbox, 5.)

n_domains, n_tris, n_verts = myT.NbDomains(), myT.NbTriangles(), myT.NbVertices()

for i in xrange(100):
    tri = myT.Triangle(i)
    # Crashes here...


#------


Here's what I need to get: that is to get the UV value for a vertex of a mesh representing a surface.
It seems I would need the BrepAdaptor_HSurface class to do so...

bbox = get_bounding_box(ms.Shape())
myT = occ.BRepMesh_FastDiscret(0.1, ms.Shape(), bbox, 5.)
n_domains, n_tris, n_verts = myT.NbDomains(), myT.NbTriangles(), myT.NbVertices()

'''
Standard_EXPORT gp_XY FindUV (const TopoDS_Vertex &V, const gp_Pnt2d &XY, const Standard_Integer ip, const Handle(BRepAdaptor_HSurface)&S, const Standard_Real mindist)

Find the UV value of the Surface of a Vertex on the Mesh
We'll need to find the gaussian curvature of that UV value and map it to a Color

'''
# missing the BrepAdaptor_HSurface
myT.FindUV()

for i in xrange(100):
    tri = myT.Triangle(i)
    # Kaboom


Note that when getting the face using the this method, we *do* have access to its methods!

# interestingly, this works:

_f = myT.DomainFace(1)

# now we *can* use all methods, yeaah!
_f.Checked()


So, I'm really curious to know whether I've completely looked over some important OCC concepts. The other thing is that I'm completely lost on how one should deal with Handle_* objects.
That's something that should go onto the Wiki for sure.

Cheers,

-jelle












_______________________________________________
Minerva-pythonocc mailing list
Minerva-pythonocc@gna.org
https://mail.gna.org/listinfo/minerva-pythonocc

Reply via email to