Salome HOME
PR: synchro V7_main tag mergefrom_V6_main_28Feb13
[modules/geom.git] / doc / salome / examples / repairing_operations_ex09.py
1 # Limit Tolerance
2
3 import geompy
4 import salome
5 gg = salome.ImportComponentGUI("GEOM")
6
7 # import initial topology with bad tolerances (more than 1e-07)
8 shape1 = geompy.ImportBREP("my_shape_1.brep")
9 shape2 = geompy.ImportBREP("my_shape_2.brep")
10
11 geompy.addToStudy(shape1, "Shape 1")
12 geompy.addToStudy(shape2, "Shape 2")
13
14 # perform partition
15 try:
16     part = geompy.MakePartition([shape1, shape2])
17 except:
18     # limit tolerance
19     tolerance = 1e-07
20     shape1_lt = geompy.LimitTolerance(shape1, tolerance)
21     shape2_lt = geompy.LimitTolerance(shape2, tolerance)
22
23     # process shape
24     good_shape1 = geompy.ProcessShape(shape1_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
25     good_shape2 = geompy.ProcessShape(shape2_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"])
26
27     geompy.addToStudy(good_shape1, "Shape 1 corrected")
28     geompy.addToStudy(good_shape2, "Shape 2 corrected")
29
30     # perform partition on corrected shapes
31     part = geompy.MakePartition([good_shape1, good_shape2])
32     pass
33
34 geompy.addToStudy(part, "Partition")