geom/doc/salome/examples/fast_intersection.py

35 lines
953 B
Python
Raw Permalink Normal View History

# Fast intersection
import salome
salome.salome_init_without_session()
import GEOM
from salome.geom import geomBuilder
2017-06-13 14:57:14 +05:00
geompy = geomBuilder.New()
# create a box
box = geompy.MakeBoxDXDYDZ(100,100,100)
# create a cylinder
cylinder = geompy.MakeCylinderRH(100, 300)
isOk, res1, res2 = geompy.FastIntersect(box, cylinder)
if isOk == 0:
2017-02-10 21:07:24 +05:00
raise RuntimeError("No intersection!")
else:
2017-02-10 21:07:24 +05:00
print("\nTwo lists of indexes of sub-shapes localize the intersection:")
print(res1, res2)
# create two boxes with gap
Ver1 = geompy.MakeVertex(0, 0, 0)
Ver2 = geompy.MakeVertex(100, 100, 100)
Ver3 = geompy.MakeVertex(100.1, 0, 0)
Ver4 = geompy.MakeVertex(200, 200, 200)
box1 = geompy.MakeBoxTwoPnt(Ver1, Ver2)
box2 = geompy.MakeBoxTwoPnt(Ver3, Ver4)
isOk1, aRes1, aRes2 = geompy.FastIntersect(box1, box2, 1.)
if isOk1 == 0:
2017-02-10 21:07:24 +05:00
raise RuntimeError("No gaps!")
else:
2017-02-10 21:07:24 +05:00
print("\nTwo lists of indexes of sub-shapes localize the gap:")
print(aRes1, aRes2)