1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from .geomsmesh import geompy
23 from .geomsmesh import geomPublish
24 from .geomsmesh import geomPublishInFather
26 from .sortFaces import sortFaces
28 from .fissError import fissError
30 def restreintFaceFissure(shapeDefaut, facesDefaut, pointInterne):
32 restriction de la face de fissure au domaine solide
33 partition face fissure étendue par fillings
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)]
42 logging.debug("selection de la face la plus proche du point interne, distance=%s",distfaces[0][0])
43 facesPortFissure = distfaces[0][2]
46 facesPartShapeDefautSorted, minSurf, maxSurf = sortFaces(facesPartShapeDefaut) # la face de fissure dans le volume doit être la plus grande
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]
58 geomPublish(initLog.debug, facesPortFissure, "facesPortFissure")
59 return facesPortFissure