Salome HOME
Update of CheckDone
[modules/smesh.git] / src / Tools / blocFissure / gmu / mailleAretesEtJonction.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 """edges de bord, faces défaut à respecter"""
21
22 import logging
23
24 import SMESH
25
26 from .geomsmesh import geompy
27 from .geomsmesh import smesh
28 from .geomsmesh import geomPublish
29
30 from . import initLog
31 from .putName import putName
32
33 def mailleAretesEtJonction (internalBoundary, aretesVivesCoupees, lgAretesVives, \
34                             nro_cas=None):
35   """edges de bord, faces défaut à respecter"""
36   logging.info('start')
37   logging.info("Pour le cas n°%s", nro_cas)
38
39   _ = smesh.CreateFilterManager()
40   _, internalBoundary, _NoneGroup = internalBoundary.MakeBoundaryElements( SMESH.BND_1DFROM2D, '', '', 0, [  ])
41   criteres = list()
42   unCritere = smesh.GetCriterion(SMESH.EDGE,SMESH.FT_FreeBorders,SMESH.FT_Undefined,0)
43   criteres.append(unCritere)
44   filtre = smesh.GetFilterFromCriteria(criteres)
45   bordsLibres = internalBoundary.MakeGroupByFilter( 'bords', filtre )
46   putName(bordsLibres, 'bordsLibres', i_pref=nro_cas)
47
48   # --- pour aider l'algo hexa-tetra à ne pas mettre de pyramides à l'extérieur des volumes repliés sur eux-mêmes
49   #     on désigne les faces de peau en quadrangles par le groupe "skinFaces"
50
51   skinFaces = internalBoundary.CreateEmptyGroup( SMESH.FACE, 'skinFaces' )
52   _ = skinFaces.AddFrom( internalBoundary.GetMesh() )
53
54   # --- maillage des éventuelles arêtes vives entre faces reconstruites
55
56   grpAretesVives = None
57   if aretesVivesCoupees:
58
59     aretesVivesC = geompy.MakeCompound(aretesVivesCoupees)
60     geomPublish(initLog.always, aretesVivesC, "aretesVives", nro_cas)
61     meshAretesVives = smesh.Mesh(aretesVivesC)
62     algo1d = meshAretesVives.Segment()
63     putName(algo1d.GetSubMesh(), "aretesVives", i_pref=nro_cas)
64     hypo1d = algo1d.LocalLength(lgAretesVives,[],1e-07)
65     putName(hypo1d, "aretesVives={}".format(lgAretesVives), i_pref=nro_cas)
66
67     is_done = meshAretesVives.Compute()
68     text = "meshAretesVives.Compute"
69     if is_done:
70       logging.info(text+" OK")
71     else:
72       text = "Erreur au calcul du maillage.\n" + text
73       logging.info(text)
74       raise Exception(text)
75
76     grpAretesVives = meshAretesVives.CreateEmptyGroup( SMESH.EDGE, 'grpAretesVives' )
77     _ = grpAretesVives.AddFrom( meshAretesVives.GetMesh() )
78
79   return (internalBoundary, bordsLibres, grpAretesVives)