Salome HOME
Merge branch V7_3_1_BR
[modules/smesh.git] / src / Tools / blocFissure / gmu / extractionOrientee.py
1 # -*- coding: utf-8 -*-
2
3 import logging
4 from geomsmesh import geompy
5
6 from whichSide import whichSide
7
8 # -----------------------------------------------------------------------------
9 # --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
10
11 def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
12   """
13   renvoie l'extraction des shapes d'un objet selon leur position
14   par rapport à la face.
15   shapeType in ["VERTEX", "EDGE", "FACE",...]
16   """
17   logging.info('start')
18   trace = True
19   sideRef = whichSide(face, ref)
20   logging.debug("ref side %s", sideRef)
21   shapesInside = []
22   shapesOutside = []
23   shapesOnside = []
24   shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
25   i=0
26   j=0
27   k=0
28   prefix = prefix + shapeType
29   for shape in shapes:
30     side = whichSide(face, shape, tol)
31     if side == sideRef:
32       shapesInside.append(shape)
33       if trace:
34         name = prefix + "_Inside%d"%i
35         geompy.addToStudyInFather(obj, shape, name)
36       i+=1
37     elif side == -sideRef:
38       shapesOutside.append(shape)
39       if trace:
40         name = prefix + "_Outside%d"%j
41         geompy.addToStudyInFather(obj, shape, name)
42       j+=1
43     elif side == 0:
44       shapesOnside.append(shape)
45       if trace:
46         name = prefix + "_Onside%d"%k
47         geompy.addToStudyInFather(obj, shape, name)
48       k+=1
49     logging.debug("--- shape was %s", name)
50   return [shapesInside, shapesOutside, shapesOnside]
51