@@ -27,3 +27,37 @@ along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
27
27
%include <python/std_list.i>
28
28
%include <python/std_string.i>
29
29
%include <python/std_basic_string.i>
30
+
31
+ %pythoncode %{
32
+ def _dumps_object (klass):
33
+ " " " Improve string output for any oce object.
34
+ By default, __repr__ method returns something like:
35
+ <OCC.TopoDS.TopoDS_Shape; proxy of <Swig Object of type 'TopoDS_Shape *' at 0x02BB0758> >
36
+ This is too much verbose.
37
+ We prefer :
38
+ class<'gp_Pnt'>
39
+ or
40
+ class<'TopoDS_Shape'; Type:Solid; Id:59391729>
41
+ " " "
42
+ klass_name = str (klass.__class__ ).split (" ." )[2 ].split (" '" )[0 ]
43
+ repr_string = " class<'" + klass_name + " '"
44
+ # for TopoDS_Shape, we also look for the base type
45
+ if klass_name == " TopoDS_Shape" :
46
+ st = klass.ShapeType ()
47
+ types = {OCC.TopAbs .TopAbs_VERTEX :" Vertex" ,
48
+ OCC.TopAbs .TopAbs_SOLID :" Solid" ,
49
+ OCC.TopAbs .TopAbs_EDGE :" Edge" ,
50
+ OCC.TopAbs .TopAbs_FACE :" Face" ,
51
+ OCC.TopAbs .TopAbs_SHELL :" Shell" ,
52
+ OCC.TopAbs .TopAbs_WIRE :" Wire" ,
53
+ OCC.TopAbs .TopAbs_COMPOUND :" Compound" ,
54
+ OCC.TopAbs .TopAbs_COMPSOLID :" Compsolid." }
55
+ repr_string += " ; Type:%s" % types[st]
56
+ # for each class that has an HashCode method define,
57
+ # print the id
58
+ if hasattr (klass, " HashCode" ):
59
+ klass_id = hash(klass)
60
+ repr_string += "; id:%s" % klass_id
61
+ repr_string += " >"
62
+ return repr_string
63
+ %}
0 commit comments