Salome HOME
decoupage insereFissureGenerale, renommée construitFissureGenerale, premiere phase...
[modules/smesh.git] / src / Tools / blocFissure / gmu / restreintFaceFissure.py
1 # -*- coding: utf-8 -*-
2
3 import logging
4 from geomsmesh import geompy
5 from sortFaces import sortFaces
6
7 def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
8   """
9   restriction de la face de fissure au domaine solide
10   partition face fissure étendue par fillings
11   """
12   logging.info('start')
13   partShapeDefaut = geompy.MakePartition([shapeDefaut], facesDefaut, [], [], geompy.ShapeType["FACE"], 0, [], 0)
14   geompy.addToStudy(partShapeDefaut, 'partShapeDefaut')
15   facesPartShapeDefaut = geompy.ExtractShapes(partShapeDefaut, geompy.ShapeType["FACE"], False)
16   if pointInterne is not None:
17     distfaces = [(geompy.MinDistance(face,pointInterne), i, face) for i, face in enumerate(facesPartShapeDefaut)]
18     distfaces.sort()
19     logging.debug("selection de la face la plus proche du point interne, distance=%s",distfaces[0][0])
20     facesPortFissure = distfaces[0][2]
21   else:
22     facesPartShapeDefautSorted, minSurf, maxSurf = sortFaces(facesPartShapeDefaut) # la face de fissure dans le volume doit être la plus grande
23     logging.debug("surfaces faces fissure étendue, min %s, max %s", minSurf, maxSurf)
24     facesPortFissure = facesPartShapeDefautSorted[-1]
25   
26   geompy.addToStudy(facesPortFissure, "facesPortFissure")
27   return facesPortFissure