Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / blocFissure / gmu / restreintFaceFissure.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2022  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 """Restriction de la face de fissure au domaine solide"""
21
22 import logging
23
24 import traceback
25
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublish
28
29 from . import initLog
30
31 from .sortFaces import sortFaces
32 from .fissError import fissError
33
34 def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne, \
35                          nro_cas=None):
36   """restriction de la face de fissure au domaine solide
37
38   partition face fissure étendue par fillings
39   """
40   logging.info('start')
41
42   partShapeDefaut = geompy.MakePartition([shapeDefaut], facesDefaut, [], [], geompy.ShapeType["FACE"], 0, [], 0)
43   geomPublish(initLog.debug, partShapeDefaut, 'partShapeDefaut', i_pref=nro_cas)
44   facesPartShapeDefaut = geompy.ExtractShapes(partShapeDefaut, geompy.ShapeType["FACE"], False)
45
46   if pointInterne is not None:
47     distfaces = [(geompy.MinDistance(face,pointInterne), i, face) for i, face in enumerate(facesPartShapeDefaut)]
48     distfaces.sort()
49     texte = "Sélection de la face la plus proche du point interne, distance={}".format(distfaces[0][0])
50     logging.debug(texte)
51     facesPortFissure = distfaces[0][2]
52   else:
53     try:
54       facesPartShapeDefautSorted, minSurf, maxSurf = sortFaces(facesPartShapeDefaut) # la face de fissure dans le volume doit être la plus grande
55     except:
56       texte = "Restriction de la face de fissure au domaine solide impossible.<br>"
57       texte += "Causes possibles :<ul>"
58       texte += "<li>La face de fissure est tangente à la paroi solide."
59       texte += "Elle doit déboucher franchement, sans que la surface dehors ne devienne plus grande que la surface dans le solide.</li>"
60       texte += "<li>le prémaillage de la face de fissure est trop grossier, les mailles à enlever dans le maillage sain "
61       texte += "n'ont pas toutes été détectées.</li></ul>"
62       raise fissError(traceback.extract_stack(),texte)
63     texte = "surfaces faces fissure étendue, min {}, max {}".format(minSurf, maxSurf)
64     logging.debug(texte)
65     facesPortFissure = facesPartShapeDefautSorted[-1]
66
67   geomPublish(initLog.debug, facesPortFissure, "facesPortFissure", i_pref=nro_cas)
68
69   return facesPortFissure