Hi guys, have you had some time to look at this strange TopoDS_Iterator
issue yet? I'm not sure if I explained it very well, so here is another
attempt at explaining the weird behaviour:
1. I use TopoDS_Iterator to collect all faces of a shell into a Python
set, as well as collect the hash of each face into a set.
2. I then use TopoDS_Iterator again to iterate through the same shell's
faces.
2.1. While doing this 2nd iteration, I assert:
2.1.1. that hash(face) is in the set of hashes I collected
in (1) - this works (as expected)
2.2.2. that face is in the set of faces I collected in (1) -
this assertion FAILS (unexpected)
I don't really understand this at all, as the hash of an object should
supposedly be used to determine set membership.
Cheers,
Frank
Frank Conradie wrote:
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
_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users