X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FblocFissure%2Fgmu%2FquadranglesToShape.py;h=989ceda85e727b75acab9a81844b3dbced552b78;hp=faa9478f7805053a9633c7a211b1b28ab81d9200;hb=a274ade365bd0f0e19d56c577acc4a13aa1972a7;hpb=5d68554076bbca0e1e95fb0db215a6c2b84b6c54 diff --git a/src/Tools/blocFissure/gmu/quadranglesToShape.py b/src/Tools/blocFissure/gmu/quadranglesToShape.py index faa9478f7..989ceda85 100644 --- a/src/Tools/blocFissure/gmu/quadranglesToShape.py +++ b/src/Tools/blocFissure/gmu/quadranglesToShape.py @@ -1,7 +1,28 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2014-2021 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# import logging -from geomsmesh import geompy +from .geomsmesh import geompy +from .geomsmesh import geomPublish +from .geomsmesh import geomPublishInFather +from . import initLog import GEOM import math import numpy as np @@ -26,7 +47,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): logging.info("start") isVecteurDefaut = False - if shapeFissureParams.has_key('vecteurDefaut'): + if 'vecteurDefaut' in shapeFissureParams: isVecteurDefaut = True vecteurDefaut = shapeFissureParams['vecteurDefaut'] @@ -150,7 +171,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): h = e/(np.sqrt(f*g)) # cosinus ruptureX = h < cosmin # True si angle > reference logging.debug("matrice de rupture X: \n%s",ruptureX) - rupX = filter(lambda x: np.prod(ruptureX[:,x]), range(len(nodeline)-2)) + rupX = [x for x in range(len(nodeline)-2) if np.prod(ruptureX[:,x])] logging.debug("colonnes de rupture: %s",rupX) # recherche d'angles supérieurs a un seuil sur une colonne : angle entre deux vecteurs successifs vecy = mat[ 1:, :, :] - mat[:-1, :, :] # vecteurs selon direction "y" @@ -162,7 +183,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): h = e/(np.sqrt(f*g)) # cosinus ruptureY = h < cosmin # True si angle > reference logging.debug("matrice de rupture Y: \n%s",ruptureY) - rupY = filter(lambda x: np.prod(ruptureY[x, :]), range(len(nodelines)-2)) + rupY = [x for x in range(len(nodelines)-2) if np.prod(ruptureY[x, :])] logging.debug("lignes de rupture: %s",rupY) if (len(rupX)*len(rupY)) > 0: logging.critical("""Cas non traité: présence d'angles vifs dans 2 directions, @@ -225,23 +246,23 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): if i == 0: noeudsBords[0].append(node) #name = "bord0_%d"%k - #geompy.addToStudy( node, name ) + #geomPublish(initLog.debug, node, name ) if i == (nbLignes -1): noeudsBords[2].append(node) #name = "bord2_%d"%k - #geompy.addToStudy( node, name ) + #geomPublish(initLog.debug, node, name ) if j == 0: noeudsBords[1].append(node) #name = "bord1_%d"%k - #geompy.addToStudy( node, name ) + #geomPublish(initLog.debug, node, name ) if j == (nbCols -1): noeudsBords[3].append(node) #name = "bord3_%d"%k - #geompy.addToStudy( node, name ) + #geomPublish(initLog.debug, node, name ) k += 1 curve = geompy.MakeInterpol(nodeList, False, False) #name = "curve_%d"%i - #geompy.addToStudy( curve, name ) + #geomPublish(initLog.debug, curve, name ) if len(curvconts) == 0 or len(curves) > 0: # éliminer les doublons de la surface sans découpe curvconts.append(nodeList) curves.append(curve) @@ -267,13 +288,13 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): pointIn_y = 0.0 pointIn_z = 0.0 pointExplicite = False - if shapeFissureParams.has_key('pointIn_x'): + if 'pointIn_x' in shapeFissureParams: pointExplicite = True pointIn_x = shapeFissureParams['pointIn_x'] - if shapeFissureParams.has_key('pointIn_y'): + if 'pointIn_y' in shapeFissureParams: pointExplicite = True pointIn_y = shapeFissureParams['pointIn_y'] - if shapeFissureParams.has_key('pointIn_z'): + if 'pointIn_z' in shapeFissureParams: pointExplicite = True pointIn_z = shapeFissureParams['pointIn_z'] if pointExplicite: @@ -281,7 +302,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): logging.debug("orientation filling par point intérieur %s", (pointIn_x, pointIn_y, pointIn_z)) vecteurDefaut = geompy.MakeVector(cdg, vertex) - if shapeFissureParams.has_key('convexe'): + if 'convexe' in shapeFissureParams: isConvexe = shapeFissureParams['convexe'] logging.debug("orientation filling par indication de convexité %s", isConvexe) cdg = geompy.MakeCDG(filling) @@ -291,11 +312,11 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): vecteurDefaut = geompy.MakeVector(vertex, cdg) if vecteurDefaut is not None: - geompy.addToStudy(normal, "normFillOrig%d"%iface) - geompy.addToStudy(vecteurDefaut, "fromInterieur%d"%iface) + geomPublish(initLog.debug, normal, "normFillOrig%d"%iface) + geomPublish(initLog.debug, vecteurDefaut, "fromInterieur%d"%iface) if geompy.GetAngleRadians(vecteurDefaut, normal) > math.pi/2.0: filling = geompy.ChangeOrientation(filling) - geompy.addToStudy( filling, "filling%d"%iface ) + geomPublish(initLog.debug, filling, "filling%d"%iface ) #geompy.ExportBREP(filling, "filling.brep") iface = iface+1 fillings.append(filling) @@ -315,7 +336,7 @@ def quadranglesToShape(meshQuad, shapeFissureParams, centreFondFiss): curve = geompy.MakeInterpol(nodes, False, False) curves.append(curve) fillcont = geompy.MakeFilling(geompy.MakeCompound(curves), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True) - geompy.addToStudy( fillcont, "filcont%d"%icont ) + geomPublish(initLog.debug, fillcont, "filcont%d"%icont ) fillconts.append(fillcont) icont = icont+1 pass # --- loop while there are remaining nodes