Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Fast intersection
1 # Fast intersection
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # create a box
10 box = geompy.MakeBoxDXDYDZ(100,100,100)
11 # create a cylinder
12 cylinder = geompy.MakeCylinderRH(100, 300)
13 
14 isOk, res1, res2 = geompy.FastIntersect(box, cylinder)
15 if isOk == 0:
16  raise RuntimeError, "No intersection!"
17 else:
18  print "\nTwo lists of indexes of sub-shapes localize the intersection:"
19  print res1, res2
20 
21 # create two boxes with gap
22 Ver1 = geompy.MakeVertex(0, 0, 0)
23 Ver2 = geompy.MakeVertex(100, 100, 100)
24 Ver3 = geompy.MakeVertex(100.1, 0, 0)
25 Ver4 = geompy.MakeVertex(200, 200, 200)
26 box1 = geompy.MakeBoxTwoPnt(Ver1, Ver2)
27 box2 = geompy.MakeBoxTwoPnt(Ver3, Ver4)
28 
29 isOk1, aRes1, aRes2 = geompy.FastIntersect(box1, box2, 1.)
30 if isOk1 == 0:
31  raise RuntimeError, "No gaps!"
32 else:
33  print "\nTwo lists of indexes of sub-shapes localize the gap:"
34  print aRes1, aRes2

Download this script