Salome HOME
Update copyrights
[modules/geom.git] / doc / salome / examples / repairing_operations_ex01.py
1 # Shape Processing
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
8 gg = salome.ImportComponentGUI("GEOM")
9
10 # create vertices, an edge, an arc, a wire, a face and a prism
11 p1 = geompy.MakeVertex(0,0,0)
12 p2 = geompy.MakeVertex(200,0,0)
13 p3 = geompy.MakeVertex(100,150,0)
14 edge = geompy.MakeEdge(p1,p2)
15 arc  = geompy.MakeArc(p1,p3,p2)
16 wire = geompy.MakeWire([edge,arc])
17 face = geompy.MakeFace(wire, 1)
18 theShape = geompy.MakePrismVecH(face, edge, 130)
19
20 # check the shape at the beginning
21 print("Before ProcessShape:")
22 isValid = geompy.CheckShape(theShape, True)
23 if isValid == 0:
24     print("The shape is not valid")
25 else:
26     print("The shape seems to be valid")
27
28 # process the Shape
29 Operators = ["FixShape"]
30 Parameters = ["FixShape.Tolerance3d"]
31 Values = ["1e-7"]
32 PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
33
34 # check the shape at the end
35 print("After ProcessShape:")
36 isValid = geompy.CheckShape(PS, True)
37 if isValid == 0:
38     print("The shape is not valid")
39     raise RuntimeError("It seems, that the ProcessShape() has failed")
40 else:
41     print("The shape seems to be valid")
42
43 # add in the study and display
44 Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
45 Id_PS    = geompy.addToStudy(PS, "Processed Shape")
46 gg.createAndDisplayGO(Id_Shape)
47 gg.setDisplayMode(Id_Shape,1)
48 gg.createAndDisplayGO(Id_PS)
49 gg.setDisplayMode(Id_PS,1)