geom/doc/salome/examples/repairing_operations_ex01.py

50 lines
1.4 KiB
Python
Raw Normal View History

2013-02-12 17:35:16 +06:00
# Shape Processing
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
2017-06-13 14:57:14 +05:00
geompy = geomBuilder.New()
2013-02-12 17:35:16 +06:00
gg = salome.ImportComponentGUI("GEOM")
# create vertices, an edge, an arc, a wire, a face and a prism
p1 = geompy.MakeVertex(0,0,0)
p2 = geompy.MakeVertex(200,0,0)
p3 = geompy.MakeVertex(100,150,0)
edge = geompy.MakeEdge(p1,p2)
arc = geompy.MakeArc(p1,p3,p2)
wire = geompy.MakeWire([edge,arc])
face = geompy.MakeFace(wire, 1)
theShape = geompy.MakePrismVecH(face, edge, 130)
# check the shape at the beginning
2017-02-10 21:07:24 +05:00
print("Before ProcessShape:")
2018-11-01 13:04:12 +05:00
isValid = geompy.CheckShape(theShape, True)
2013-02-12 17:35:16 +06:00
if isValid == 0:
2017-02-10 21:07:24 +05:00
print("The shape is not valid")
2013-02-12 17:35:16 +06:00
else:
2017-02-10 21:07:24 +05:00
print("The shape seems to be valid")
2013-02-12 17:35:16 +06:00
# process the Shape
Operators = ["FixShape"]
Parameters = ["FixShape.Tolerance3d"]
Values = ["1e-7"]
PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
# check the shape at the end
2017-02-10 21:07:24 +05:00
print("After ProcessShape:")
2018-11-01 13:04:12 +05:00
isValid = geompy.CheckShape(PS, True)
2013-02-12 17:35:16 +06:00
if isValid == 0:
2017-02-10 21:07:24 +05:00
print("The shape is not valid")
raise RuntimeError("It seems, that the ProcessShape() has failed")
2013-02-12 17:35:16 +06:00
else:
2017-02-10 21:07:24 +05:00
print("The shape seems to be valid")
2013-02-12 17:35:16 +06:00
# add in the study and display
Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
Id_PS = geompy.addToStudy(PS, "Processed Shape")
gg.createAndDisplayGO(Id_Shape)
gg.setDisplayMode(Id_Shape,1)
gg.createAndDisplayGO(Id_PS)
gg.setDisplayMode(Id_PS,1)