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