Re: [Pythonocc-users] hash of pythonocc objects

2009-03-31 Thread Thomas Paviot
Hi, The __hash__ overload feature for *all* pythonOCC objects is in the svn repository (rev.203) and has been successfully tested on both Windows and Linux platforms. Thanks to Frank's precious advice, pythonOCC made a huge step beyond since, from now, it becomes possible to handle OCC objects

Re: [Pythonocc-users] hash of pythonocc objects

2009-03-31 Thread Thomas Paviot
Hi Frank, The __hash__ overload feature is available on the subversion repository (rev.202). Just svn update and rebuild the solution. You can notice now that the __hash__() and id() methods return different results. This point is important: whenever you create a pythonOCC object (for instance

Re: [Pythonocc-users] hash of pythonocc objects

2009-03-30 Thread Frank Conradie
By the way, I have a related question, which may be more appropriate for the OCC forums, since I know it is an OCC issue and not specific to pythonocc. But maybe you OCC-gurus can help me out ;-) Why is it that TopExp_Explorer sometimes returns the same shapes multiple times, e.g. in my code I'

Re: [Pythonocc-users] hash of pythonocc objects

2009-03-30 Thread Frank Conradie
Hi Thomas But this is exactly my problem, since for TopoDS_Shape objects, the id is different for the same underlying occ object every time the shape is retrieved (e.g. through TopExp explorer). Is this because id() returns the address of the swig wrapper object, which is different every time i

Re: [Pythonocc-users] hash of pythonocc objects

2009-03-30 Thread Thomas Paviot
Hello Franck, It's really a good idea to map the Hash() OpenCascade method and the python __hash__(). I read a few posts on the __hash__() topic. A good one is, for instance: http://mail.python.org/pipermail/python-dev/2003-September/037923.html . It's said that 'object.__hash__() returns id(o

Re: [Pythonocc-users] hash of pythonocc objects

2009-03-30 Thread Frank Conradie
Hi Jelle My particular need was to hash TopoDS_Shape objects properly. I'm not sure if this is a good permanent solution, but this works for me, for shapes at least: def shape_hash(self): return self.HashCode(sys.maxint) TopoDS.TopoDS_Shape.__hash__ = shape_hash Now I can use shapes in a

[Pythonocc-users] hash of pythonocc objects

2009-03-30 Thread Frank Conradie
Life with pythonocc has become much better now that the == operator works properly for pythonocc objects, but it would be so much easier if objects would also "hash" based on the underlying OCC object. E.g. if o1==o2, then hash(o1) == hash(o2) This would make it possible to use pythonocc object