From 8fde0dfff8463a14b5da8a128d24d83a0e06f84d Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Thu, 28 Jan 2021 15:06:48 +0100 Subject: [PATCH] =?utf8?q?cosm=C3=A9tique?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/Tools/blocFissure/gmu/mailleFacesPeau.py | 6 +- .../blocFissure/gmu/regroupeSainEtDefaut.py | 79 +++++++++++-------- .../materielCasTests/genereMateriel.py | 12 +-- .../blocFissure/materielCasTests/tube.py | 31 ++++---- 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/src/Tools/blocFissure/gmu/mailleFacesPeau.py b/src/Tools/blocFissure/gmu/mailleFacesPeau.py index 6bbf3e10b..4ecaf3146 100644 --- a/src/Tools/blocFissure/gmu/mailleFacesPeau.py +++ b/src/Tools/blocFissure/gmu/mailleFacesPeau.py @@ -18,6 +18,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +"""maillage faces de peau""" + import logging from .geomsmesh import geompy @@ -34,9 +36,7 @@ def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad): - """ - maillage faces de peau - """ + """maillage faces de peau""" logging.info('start') nbFacesFilling = len(partitionsPeauFissFond) boutFromIfil = [None for i in range(nbFacesFilling)] diff --git a/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py b/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py index 626d9f931..2e71253c0 100644 --- a/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py +++ b/src/Tools/blocFissure/gmu/regroupeSainEtDefaut.py @@ -18,17 +18,17 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +"""Maillage sain sans la zone de defaut""" + import logging + +from .geomsmesh import geompy from .geomsmesh import smesh import SMESH -from .geomsmesh import geompy - -# ----------------------------------------------------------------------------- -# --- maillage complet et fissure def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGeomFissure, nomVolume, normal = None): - """ - Maillage sain sans la zone de defaut + """Maillage sain sans la zone de defaut + TODO: a completer """ logging.info('Concatenation') @@ -36,22 +36,26 @@ def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGe maillageComplet = smesh.Concatenate([maillageSain.GetMesh(), blocComplet.GetMesh()], 1, 1, 1e-05,False) groups = maillageComplet.GetGroups() - grps = [ grp for grp in groups if grp.GetName() == 'FACE1'] - faceFissure = grps[0] - grps = [ grp for grp in groups if grp.GetName() == 'nfondfis'] - noeudsFondFissure = grps[0] - grps = [ grp for grp in groups if grp.GetName() == 'fisInPi'] - fisInPi = grps[0] - grps = [ grp for grp in groups if grp.GetName() == 'fisOutPi'] - fisOutPi = grps[0] + for grp in groups: + grp_nom = grp.GetName() + if ( grp_nom == "FACE1" ): + faceFissure = grp + elif ( grp_nom == "nfondfis" ): + noeudsFondFissure = grp + elif ( grp_nom == "fisInPi" ): + fisInPi = grp + elif ( grp_nom == "fisOutPi" ): + fisOutPi = grp # --- TODO: fiabiliser l'orientation dans le cas general if normal is None: normal = smesh.MakeDirStruct( 0, 0, 1 ) + logging.debug('après normal = {}'.format(normal)) maillageComplet.Reorient2D( fisInPi, normal, [0,0,0]) + logging.debug('après Reorient2D In') maillageComplet.Reorient2D( fisOutPi, normal, [0,0,0]) - - shapes = [] + + shapes = list() if extrusionFaceFissure is not None: subIds = geompy.SubShapeAllIDs(extrusionFaceFissure, geompy.ShapeType["SOLID"]) if len(subIds) > 1: @@ -64,40 +68,47 @@ def RegroupeSainEtDefaut(maillageSain, blocComplet, extrusionFaceFissure, faceGe # shapes = geompy.ExtractShapes(faceGeomFissure, geompy.ShapeType["FACE"], False) # else: # shapes = [faceGeomFissure] - - grpEdges = [] - grpFaces = [] - grpVolumes = [] + + grpEdges = list() + grpFaces = list() + grpVolumes = list() if len(shapes) == 0: shapes = [None] # calcul uniquement avec les normales des faces mailles de la fissure for i, aShape in enumerate(shapes): - logging.info('Detection elements affectes par le dedoublement de la face %d'%i) + texte = "Detection elements affectes par le dedoublement de la face n° {}".format(i) + logging.debug(texte) affectedGroups = maillageComplet.AffectedElemGroupsInRegion([faceFissure], [noeudsFondFissure], aShape) - grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedEdges'] - affectedEdges = grps[0] + for grp in affectedGroups: + grp_nom = grp.GetName() + if ( grp_nom == "affectedEdges" ): + affectedEdges = grp + elif ( grp_nom == "affectedFaces" ): + affectedFaces = grp + elif ( grp_nom == "affectedVolumes" ): + affectedVolumes = grp + #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedEdges'] + #affectedEdges = grps[0] affectedEdges.SetName('affEd%d'%i) grpEdges.append(affectedEdges) - grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedFaces'] - affectedFaces = grps[0] + #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedFaces'] + #affectedFaces = grps[0] affectedFaces.SetName('affFa%d'%i) grpFaces.append(affectedFaces) - grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedVolumes'] - affectedVolumes = grps[0] + #grps = [ grp for grp in affectedGroups if grp.GetName() == 'affectedVolumes'] + #affectedVolumes = grps[0] affectedVolumes.SetName('affVo%d'%i) grpVolumes.append(affectedVolumes) - logging.info("union des groupes d'edges") affectedEdges = maillageComplet.UnionListOfGroups(grpEdges, 'affEdges') - logging.info("union des groupes de faces") affectedFaces = maillageComplet.UnionListOfGroups(grpFaces, 'affFaces') - logging.info("union des groupes de volumes") affectedVolumes = maillageComplet.UnionListOfGroups(grpVolumes, 'affVols') for grp in affectedGroups: - logging.debug("nom groupe %s",grp.GetName()) - [ FACE2, FACE2_nodes ] = maillageComplet.DoubleNodeElemGroups([faceFissure], [noeudsFondFissure], affectedGroups, True, True) + texte = "Traitement du groupe '{}'".format(grp.GetName()) + logging.debug(texte) + [ FACE2, _ ] = maillageComplet.DoubleNodeElemGroups([faceFissure], [noeudsFondFissure], affectedGroups, True, True) FACE2.SetName( 'FACE2' ) + # Groupe de toutes les mailles volumiques GroupVol = maillageComplet.CreateEmptyGroup( SMESH.VOLUME, nomVolume ) - nbAdd = GroupVol.AddFrom( maillageComplet.GetMesh() ) + _ = GroupVol.AddFrom( maillageComplet.GetMesh() ) return maillageComplet - diff --git a/src/Tools/blocFissure/materielCasTests/genereMateriel.py b/src/Tools/blocFissure/materielCasTests/genereMateriel.py index cc207bf5f..ab915c089 100644 --- a/src/Tools/blocFissure/materielCasTests/genereMateriel.py +++ b/src/Tools/blocFissure/materielCasTests/genereMateriel.py @@ -19,15 +19,15 @@ # from blocFissure.materielCasTests import cubeAngle -from blocFissure.materielCasTests import cubeFin from blocFissure.materielCasTests import decoupeCylindre -from blocFissure.materielCasTests import disque_perce -from blocFissure.materielCasTests import ellipse -from blocFissure.materielCasTests import ellipse_disque -from blocFissure.materielCasTests import ellipse_probleme from blocFissure.materielCasTests import eprouvetteCourbe from blocFissure.materielCasTests import eprouvetteDroite from blocFissure.materielCasTests import fissureGauche from blocFissure.materielCasTests import fissureGauche2 -from blocFissure.materielCasTests import tube +from blocFissure.materielCasTests import ellipse +from blocFissure.materielCasTests import ellipse_probleme +from blocFissure.materielCasTests import disque_perce +from blocFissure.materielCasTests import ellipse_disque from blocFissure.materielCasTests import vis +from blocFissure.materielCasTests import cubeFin +#from blocFissure.materielCasTests import tube diff --git a/src/Tools/blocFissure/materielCasTests/tube.py b/src/Tools/blocFissure/materielCasTests/tube.py index d0167b601..60053554e 100755 --- a/src/Tools/blocFissure/materielCasTests/tube.py +++ b/src/Tools/blocFissure/materielCasTests/tube.py @@ -19,18 +19,20 @@ # """Cas-test de blocFissure sur un tube""" -__revision__ = "V02.04" +__revision__ = "V02.05" import logging - -import sys -import salome - -salome.salome_init() - import os + from blocFissure import gmu +import salome +from SketchAPI import * +from salome.shaper import model +import SHAPERSTUDY +import SMESH +from salome.smesh import smeshBuilder + #=============== Options ==================== # 1. NOM_OBJET = nom de l'objet NOM_OBJET = "Tube" @@ -51,14 +53,12 @@ NB_S_H = 60 NB_S_P = 30 #============================================ +salome.salome_init() + ### ### SHAPER component ### -from SketchAPI import * - -from salome.shaper import model - model.begin() partSet = model.moduleDocument() @@ -152,7 +152,8 @@ SketchPoint_5 = SketchProjection_5.createdFeature() ### Create SketchEllipticArc SketchEllipticArc_1 = Sketch_2.addEllipticArc(-20, 8.956370781951521e-27, -10.21629725685072, 9.783702743149284, 10.10993798723031, 4.722461741243296, 9.440921421952831, 9.565935245237778, False) -[SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12, SketchLine_7, SketchLine_8] = SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux") +[SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12, SketchLine_7, SketchLine_8] = \ + SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux") Sketch_2.setCoincident(SketchEllipticArc_1.startPoint(), SketchLine_6.endPoint()) Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_6).coordinates(), SketchLine_5.result()) Sketch_2.setTangent(SketchEllipticArc_1.result(), SketchArc_1.results()[1]) @@ -228,7 +229,7 @@ model.end() ### model.publishToShaperStudy() -import SHAPERSTUDY + l_aux = SHAPERSTUDY.shape(model.featureStringId(Revolution_1)) objet = l_aux[0] l_groups = l_aux[1:] @@ -237,11 +238,7 @@ l_groups = l_aux[1:] ### SMESH component ### -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - smesh = smeshBuilder.New() -from salome.StdMeshers import StdMeshersBuilder Maillage_tube = smesh.Mesh(objet) smesh.SetName(Maillage_tube, NOM_OBJET) -- 2.39.2