2014-12-16 21:27:28 +05:00
|
|
|
# Fast intersection
|
|
|
|
|
|
|
|
import salome
|
|
|
|
salome.salome_init()
|
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
|
|
|
geompy = geomBuilder.New(salome.myStudy)
|
|
|
|
|
|
|
|
# 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)
|