]> SALOME platform Git repositories - modules/smesh.git/blob - src/Tools/blocFissure/gmu/extractionOrientee.py
Salome HOME
Allow saving groups with non-ascii names.
[modules/smesh.git] / src / Tools / blocFissure / gmu / extractionOrientee.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 .whichSide import whichSide
10
11 # -----------------------------------------------------------------------------
12 # --- renvoie l'extraction des shapes d'un objet selon leur position par rapport à la face.
13
14 def extractionOrientee(face, obj, ref, shapeType, tol, prefix=""):
15   """
16   renvoie l'extraction des shapes d'un objet selon leur position
17   par rapport à la face.
18   shapeType in ["VERTEX", "EDGE", "FACE",...]
19   """
20   logging.info('start')
21   trace = True
22   sideRef = whichSide(face, ref)
23   logging.debug("ref side %s", sideRef)
24   shapesInside = []
25   shapesOutside = []
26   shapesOnside = []
27   shapes = geompy.ExtractShapes(obj, geompy.ShapeType[shapeType], False)
28   i=0
29   j=0
30   k=0
31   prefix = prefix + shapeType
32   for shape in shapes:
33     side = whichSide(face, shape, tol)
34     if side == sideRef:
35       shapesInside.append(shape)
36       if trace:
37         name = prefix + "_Inside%d"%i
38         geomPublishInFather(initLog.debug, obj, shape, name)
39       i+=1
40     elif side == -sideRef:
41       shapesOutside.append(shape)
42       if trace:
43         name = prefix + "_Outside%d"%j
44         geomPublishInFather(initLog.debug, obj, shape, name)
45       j+=1
46     elif side == 0:
47       shapesOnside.append(shape)
48       if trace:
49         name = prefix + "_Onside%d"%k
50         geomPublishInFather(initLog.debug, obj, shape, name)
51       k+=1
52     logging.debug("--- shape was %s", name)
53   return [shapesInside, shapesOutside, shapesOnside]
54