Salome HOME
1df7bd0b000cce1873acbb48cfe0e7fc17c8ee94
[modules/smesh.git] / src / Tools / blocFissure / gmu / restreintFaceFissure.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import logging
22 from .geomsmesh import geompy
23 from .geomsmesh import geomPublish
24 from .geomsmesh import geomPublishInFather
25 from . import initLog
26 from .sortFaces import sortFaces
27 import traceback
28 from .fissError import fissError
29
30 def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
31   """
32   restriction de la face de fissure au domaine solide
33   partition face fissure étendue par fillings
34   """
35   logging.info('start')
36   partShapeDefaut = geompy.MakePartition([shapeDefaut], facesDefaut, [], [], geompy.ShapeType["FACE"], 0, [], 0)
37   geomPublish(initLog.debug, partShapeDefaut, 'partShapeDefaut')
38   facesPartShapeDefaut = geompy.ExtractShapes(partShapeDefaut, geompy.ShapeType["FACE"], False)
39   if pointInterne is not None:
40     distfaces = [(geompy.MinDistance(face,pointInterne), i, face) for i, face in enumerate(facesPartShapeDefaut)]
41     distfaces.sort()
42     logging.debug("selection de la face la plus proche du point interne, distance=%s",distfaces[0][0])
43     facesPortFissure = distfaces[0][2]
44   else:
45     try:
46       facesPartShapeDefautSorted, minSurf, maxSurf = sortFaces(facesPartShapeDefaut) # la face de fissure dans le volume doit être la plus grande
47     except:
48       texte = "Restriction de la face de fissure au domaine solide impossible.<br>"
49       texte += "Causes possibles :<ul>"
50       texte += "<li>La face de fissure est tangente à la paroi solide."
51       texte += "Elle doit déboucher franchement, sans que la surface dehors ne devienne plus grande que la surface dans le solide.</li>"
52       texte += "<li>le prémaillage de la face de fissure est trop grossier, les mailles à enlever dans le maillage sain "
53       texte += "n'ont pas toutes été détectées.</li></ul>"
54       raise fissError(traceback.extract_stack(),texte)
55     logging.debug("surfaces faces fissure étendue, min %s, max %s", minSurf, maxSurf)
56     facesPortFissure = facesPartShapeDefautSorted[-1]
57   
58   geomPublish(initLog.debug, facesPortFissure, "facesPortFissure")
59   return facesPortFissure