X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FTools%2FZCracksPlug%2FgenereCrack.py;h=6889d304bd678d7a0a8c4b11efbf0f8085ac6154;hb=HEAD;hp=372772b4311ba2f91f62aa4f3e97928c838976c5;hpb=1746a461949c030eb46ccb860e586ade2e5de5e3;p=modules%2Fsmesh.git diff --git a/src/Tools/ZCracksPlug/genereCrack.py b/src/Tools/ZCracksPlug/genereCrack.py index 372772b43..6bb2fb77b 100644 --- a/src/Tools/ZCracksPlug/genereCrack.py +++ b/src/Tools/ZCracksPlug/genereCrack.py @@ -1,7 +1,26 @@ +# Copyright (C) 2016-2024 CEA, EDF +# +# 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 os, shutil -import sphere, ellipse, rectangle -import utilityFunctions as uF -from output import message +from . import sphere, ellipse, rectangle +from . import utilityFunctions as uF +from .output import message def main(data, outFile): activeCrack=data['crack']['actif'] @@ -32,7 +51,7 @@ def generateEllipse(crack, outFile): res=False demiGrandAxe=crack['Rayon'][0] - if 'Rayon 2' not in crack.keys(): crack['Rayon 2']=[] + if 'Rayon 2' not in list(crack.keys()): crack['Rayon 2']=[] if len(crack['Rayon 2'])==0: demiPetitAxe=demiGrandAxe else: @@ -54,7 +73,7 @@ def generateEllipse(crack, outFile): res=False normale=crack['Normale'] - if 'Direction' not in crack.keys(): crack['Direction']=[] + if 'Direction' not in list(crack.keys()): crack['Direction']=[] if len(crack['Direction'])==0: if normale==[1.,0.,0.]: direction=[0.,1.,0.] @@ -71,7 +90,7 @@ def generateEllipse(crack, outFile): message('E','Normale and Direction are equals',goOn=True) res=False - if 'Angle' not in crack.keys(): crack['Angle']=[] + if 'Angle' not in list(crack.keys()): crack['Angle']=[] if len(crack['Angle'])==0: angle=0.0 else: @@ -81,7 +100,7 @@ def generateEllipse(crack, outFile): res=False angle=crack['Angle'][0] - if 'Rayon entaille' not in crack.keys(): crack['Rayon entaille']=[] + if 'Rayon entaille' not in list(crack.keys()): crack['Rayon entaille']=[] if len(crack['Rayon entaille'])==0: rayon_entaille=0.0 else: @@ -91,7 +110,7 @@ def generateEllipse(crack, outFile): res=False rayon_entaille=crack['Rayon entaille'][0] - if 'Extension' not in crack.keys(): crack['Extension']=[] + if 'Extension' not in list(crack.keys()): crack['Extension']=[] if len(crack['Extension'])==0: extension=0.0 else: @@ -117,7 +136,7 @@ def generateRectangle(crack, outFile): res=False longueur=crack['Longueur'][0] - if 'Largeur' not in crack.keys(): crack['Largeur']=[] + if 'Largeur' not in list(crack.keys()): crack['Largeur']=[] if len(crack['Largeur'])==0: largeur=longueur else: @@ -145,7 +164,7 @@ def generateRectangle(crack, outFile): res=False direction=crack['Direction'] - if 'Angle' not in crack.keys(): crack['Angle']=[] + if 'Angle' not in list(crack.keys()): crack['Angle']=[] if len(crack['Angle'])==0: angle=0.0 else: @@ -155,7 +174,7 @@ def generateRectangle(crack, outFile): res=False angle=crack['Angle'][0] - if 'Rayon' not in crack.keys(): crack['Rayon']=[] + if 'Rayon' not in list(crack.keys()): crack['Rayon']=[] if len(crack['Rayon'])==0: rayon=0.0 else: @@ -165,7 +184,7 @@ def generateRectangle(crack, outFile): res=False rayon=crack['Rayon'][0] - if 'Rayon entaille' not in crack.keys(): crack['Rayon entaille']=[] + if 'Rayon entaille' not in list(crack.keys()): crack['Rayon entaille']=[] if len(crack['Rayon entaille'])==0: rayon_entaille=0.0 else: @@ -212,13 +231,12 @@ def generateCustom(crack, outFile): import salome salome.salome_init() - theStudy = salome.myStudy import salome_notebook - notebook = salome_notebook.NoteBook(theStudy) + notebook = salome_notebook.NoteBook() import SMESH, SALOMEDS from salome.smesh import smeshBuilder - smesh = smeshBuilder.New(theStudy) + smesh = smeshBuilder.New() ([Maillage_1], status) = smesh.CreateMeshesFromMED(crack['med file']) isCrack=False for group in Maillage_1.GetGroups(): @@ -228,7 +246,7 @@ def generateCustom(crack, outFile): else: Group_1 = Maillage_1.CreateEmptyGroup( SMESH.NODE, 'crack' ) nbAdd = Group_1.AddFrom( Maillage_1.GetMesh() ) - Maillage_1.ExportMED( outFile, 0, SMESH.MED_V2_2, 1, None ,1) + Maillage_1.ExportMED(outFile) return(True)