charles-sharman / ccad

pythonocc wrapper
GNU Lesser General Public License v3.0
21 stars 11 forks source link

segfault on osx #5

Closed tpaviot closed 10 years ago

tpaviot commented 10 years ago

ccad's current implementation for topology traversing fails at returning list of subshapes.

Indeed, the use of TopExp_Explorer, currently

hashes = []
retval = []
while ex.More():
    s1 = ex.Current()
    s1_hash = s1.__hash__()
    if s1_hash not in hashes:
        hashes.append(s1_hash)
        retval.append(s1)
     ex.Next()
return retval

should be replaced with:

hashes = []
retval = []
occ_seq = TopTools_ListOfShape()
while ex.More():
    s1 = ex.Current()
    s1_hash = s1.__hash__()
    if s1_hash not in hashes:
        hashes.append(s1_hash)
        occ_seq.Append(s1)
     ex.Next()
# Convert occ_seq to python list
occ_iterator = TopTools_ListIteratorOfListOfShape(occ_seq)
while occ_iterator.More():
    topo_to_add = occ_iterator.Value()
    retval.append(topo_to_add)
    occ_iterator.Next()
return iter(retval)

This is the result of a long work, see https://github.com/tpaviot/pythonocc/blob/master/src/addons/Utils/Topology.py

tpaviot commented 10 years ago

Note : this is the case wherever you use TopExp_Explorer instances in the ccad code.

charles-sharman commented 10 years ago

The current code works fine under Linux and probably Windows. At least I haven't heard a complaint from the Windows users. If so, I presume this is a workaround for OSX only to avoid a pythonOCC issue with TopExp_Explorer. Is that right?

tpaviot commented 10 years ago

don't know. In previous pythonocc versions, this uses to work on all platforms. I'm currently testing your ccad with the ongoing pythonocc/oce-0.16. The issue may come from OSX, or oce-0.16 or both of them. Usually, pythonocc's behavior is the some on OSX and Linux, and my differ on Win32/64. Let me investigate this further.

tpaviot commented 10 years ago

Ok, I got it, it was a bug in the current work on pythonocc. I fixed it (see f9e2daf). The issue can be closed.