geom/doc/salome/examples/repairing_operations_ex05.py

53 lines
1.4 KiB
Python
Raw Normal View History

2013-02-12 17:35:16 +06:00
# Suppress Holes
import salome
salome.salome_init_without_session()
2013-02-28 20:00:05 +06:00
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 a vertex and a vector
p1 = geompy.MakeVertex(35, 35, 0)
p2 = geompy.MakeVertex(35, 35, 50)
v = geompy.MakeVector(p1, p2)
# create a cylinder
height = 20
radius1 = 20
cylinder = geompy.MakeCylinder(p1, v, radius1, height)
# create a cone
cone = geompy.MakeCone(p1, v, 70, 0, 80)
# make a cut
cut = geompy.MakeCut(cone, cylinder)
# get faces as sub-shapes
faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"])
f_2 = geompy.GetSubShapeID(cut, faces[2])
# remove one face from the shape
cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
2013-02-28 20:00:05 +06:00
# get edges as sub-shapes
edges = geompy.SubShapeAllSortedCentres(faces[2], geompy.ShapeType["EDGE"])
edge = geompy.GetInPlace(cut_without_f_2, edges[0], True)
e_2 = geompy.GetSubShapeID(cut_without_f_2, edge)
2013-02-12 17:35:16 +06:00
2013-02-28 20:00:05 +06:00
# suppress a hole using the selected edge
result = geompy.SuppressHoles(cut_without_f_2, [e_2])
2013-02-12 17:35:16 +06:00
# add objects in the study
id_cut = geompy.addToStudy(cut, "Cut")
id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2")
id_result = geompy.addToStudy(result, "Result")
# display the results
gg.createAndDisplayGO(id_cut)
gg.setDisplayMode(id_cut,1)
gg.createAndDisplayGO(id_cut_without_f_2)
gg.setDisplayMode(id_cut_without_f_2,1)
gg.createAndDisplayGO(id_result)
gg.setDisplayMode(id_result,1)