2014-12-16 21:27:28 +05:00
|
|
|
# Fast intersection
|
|
|
|
|
|
|
|
import salome
|
2021-08-12 11:43:44 +05:00
|
|
|
salome.salome_init_without_session()
|
2014-12-16 21:27:28 +05:00
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
2017-06-13 14:57:14 +05:00
|
|
|
geompy = geomBuilder.New()
|
2014-12-16 21:27:28 +05:00
|
|
|
|
|
|
|
# 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!")
|
2014-12-16 21:27:28 +05:00
|
|
|
else:
|
2017-02-10 21:07:24 +05:00
|
|
|
print("\nTwo lists of indexes of sub-shapes localize the intersection:")
|
|
|
|
print(res1, res2)
|
2014-12-16 21:27:28 +05:00
|
|
|
|
|
|
|
# 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!")
|
2014-12-16 21:27:28 +05:00
|
|
|
else:
|
2017-02-10 21:07:24 +05:00
|
|
|
print("\nTwo lists of indexes of sub-shapes localize the gap:")
|
|
|
|
print(aRes1, aRes2)
|