As a follow-up, here is how I work around this TopoDS_Iterator issue:
* I temporarily append the shape returned by it.Value() to a
TopTools_SequenceOfShape
* Then I retrieve it from there again, and use this shape from then on -
it works perfectly then and delivers a unique Python object for the shape
Here is the code with the work-around:
from OCC import TopExp, BRepPrimAPI, TopAbs, TopoDS, TopTools
box = BRepPrimAPI.BRepPrimAPI_MakeBox(10., 20., 30.)
sh = box.Shell()
*seq = TopTools.TopTools_SequenceOfShape()*
results = set()
hashes = set()
it = TopoDS.TopoDS_Iterator(sh)
while it.More():
s = it.Value()
* seq.Append(s)
s = seq.Value(seq.Length())*
results.add(s)
hashes.add(hash(s))
it.Next()
it = TopoDS.TopoDS_Iterator(sh)
while it.More():
s = it.Value()
* seq.Append(s)
s = seq.Value(seq.Length())*
assert hash(s) in hashes # this works as expected
assert s in results # this also now works as expected
it.Next()
- Frank
Frank Conradie wrote:
Here is my test case using TopoDS_Iterator - I was wrong about IsNull,
as it does work correctly, but the iterator does not return a Python
object that uniquely represent the shape:
from OCC import TopExp, BRepPrimAPI, TopAbs, TopoDS
box = BRepPrimAPI.BRepPrimAPI_MakeBox(10., 20., 30.)
sh = box.Shell()
results = set()
hashes = set()
it = TopoDS.TopoDS_Iterator(sh)
while it.More():
s = it.Value()
results.add(s)
hashes.add(hash(s))
it.Next()
it = TopoDS.TopoDS_Iterator(sh)
while it.More():
s = it.Value()
assert hash(s) in hashes # this works as expected
assert s in results # this does NOT work as expected (fails)
it.Next()
- Frank
jelle feringa wrote:
No, it has the same problem as the explorer - I used
TopTools_SequenceOfShape to work around the issue. I will try and find some
time tonight to send an example.
Ah, now I remember ;')
Many thanks Frank, I look fwd integrating your feedback!
Cheers,
-jelle
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users
------------------------------------------------------------------------
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users