Utilisation d'une CAO sous xao avec des groupes

This commit is contained in:
GERALD NICOLAS 2021-01-18 17:36:30 +01:00
parent 0f2942f29e
commit dc3c466f6b
2 changed files with 77 additions and 51 deletions

View File

@ -122,9 +122,22 @@ class casStandard(fissureGenerique):
lgInfluence = shapeFissureParams['lgInfluence'] lgInfluence = shapeFissureParams['lgInfluence']
shellFiss = geompy.ImportBREP( self.dicoParams['brepFaceFissure']) cao_file = self.dicoParams['brepFaceFissure']
suffix = os.path.basename(cao_file).split(".")[-1]
if ( suffix.upper() == "BREP" ):
shellFiss = geompy.ImportBREP(cao_file)
elif ( suffix.upper() == "XAO" ):
(_, shellFiss, _, l_groups, _) = geompy.ImportXAO(cao_file)
fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"]) fondFiss = geompy.CreateGroup(shellFiss, geompy.ShapeType["EDGE"])
if isinstance(self.dicoParams['edgeFissIds'][0],int):
geompy.UnionIDs(fondFiss, self.dicoParams['edgeFissIds'] ) geompy.UnionIDs(fondFiss, self.dicoParams['edgeFissIds'] )
else:
l_groups = geompy.GetGroups(shellFiss)
l_aux = list()
for group in l_groups:
if ( group.GetName() in self.dicoParams['edgeFissIds'] ):
l_aux.append(group)
geompy.UnionList(fondFiss, l_aux )
geomPublish(initLog.debug, shellFiss, 'shellFiss' ) geomPublish(initLog.debug, shellFiss, 'shellFiss' )
geomPublishInFather(initLog.debug, shellFiss, fondFiss, 'fondFiss' ) geomPublishInFather(initLog.debug, shellFiss, fondFiss, 'fondFiss' )
@ -153,8 +166,8 @@ class casStandard(fissureGenerique):
def genereMaillageFissure(self, geometriesSaines, maillagesSains, def genereMaillageFissure(self, geometriesSaines, maillagesSains,
shapesFissure, shapeFissureParams, shapesFissure, shapeFissureParams,
maillageFissureParams, elementsDefaut, step): maillageFissureParams, elementsDefaut, step):
maillageFissure = construitFissureGenerale(maillagesSains, maillageFissure = construitFissureGenerale(maillagesSains, \
shapesFissure, shapeFissureParams, shapesFissure, shapeFissureParams, \
maillageFissureParams, elementsDefaut, step) maillageFissureParams, elementsDefaut, step)
return maillageFissure return maillageFissure
@ -171,4 +184,3 @@ class casStandard(fissureGenerique):
Entity_Node = 0, Entity_Node = 0,
Entity_Quad_Tetra = 0, Entity_Quad_Tetra = 0,
Entity_Quad_Quadrangle = 0) Entity_Quad_Quadrangle = 0)

View File

@ -75,21 +75,21 @@ def fissureGeneraleDlg(context):
self.ui.bb_OkCancel.accepted.connect(self.execute) self.ui.bb_OkCancel.accepted.connect(self.execute)
def initDefaut(self): def initDefaut(self):
self.defaut = dict( self.defaut = dict( \
nomCas = 'angleCube', nomCas = 'angleCube', \
maillageSain = os.path.join(gmu.pathBloc, 'materielCasTests/CubeAngle.med'), maillageSain = os.path.join(gmu.pathBloc, 'materielCasTests/CubeAngle.med'), \
brepFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"), brepFaceFissure = os.path.join(gmu.pathBloc, "materielCasTests/CubeAngleFiss.brep"), \
edgeFissIds = [4], edgeFissIds = [4], \
lgInfluence = 20, lgInfluence = 20, \
meshBrep = (5,10), meshBrep = (5,10), \
rayonPipe = 5, rayonPipe = 5, \
lenSegPipe = 2.5, lenSegPipe = 2.5, \
nbSegRad = 5, nbSegRad = 5, \
nbSegCercle = 32, nbSegCercle = 32, \
areteFaceFissure = 10, areteFaceFissure = 10, \
areteVives = 0, areteVives = 0, \
reptrav = '.', reptrav = '.', \
nomres = 'maillage_avec_fissure', nomres = 'maillage_avec_fissure', \
verbosite = 0) verbosite = 0)
@ -122,22 +122,37 @@ def fissureGeneraleDlg(context):
incomplet = True incomplet = True
else: else:
self.ui.le_maillage.setPalette(self.blackPalette) self.ui.le_maillage.setPalette(self.blackPalette)
if not os.path.lexists(dico['brepFaceFissure']): cao_file = dico['brepFaceFissure']
if not os.path.lexists(cao_file):
self.ui.le_facefiss.setPalette(self.redPalette)
incomplet = True
else:
suffix = os.path.basename(cao_file).split(".")[-1]
if ( suffix.upper() not in ("BREP","XAO") ):
print ("Suffixe inconnu pour le fichier {}".format(cao_file))
self.ui.le_facefiss.setPalette(self.redPalette) self.ui.le_facefiss.setPalette(self.redPalette)
incomplet = True incomplet = True
else: else:
self.ui.le_facefiss.setPalette(self.blackPalette) self.ui.le_facefiss.setPalette(self.blackPalette)
if dico['edgeFissIds']:
edgeFissIdsOK=True edgeFissIdsOK=True
try: param_0 = dico['edgeFissIds'][0]
l = dico['edgeFissIds'] type_param_id = type(param_0)
for i in l: for param in dico['edgeFissIds'][1:]:
if not isinstance(i, int): if not isinstance(param,type_param_id):
print("not isinstance(i, int)") print ("La donnée {} n'est pas du même type que la première de la liste : {}.".format(param,type(param)))
incomplet = True incomplet = True
edgeFissIdsOK=False edgeFissIdsOK=False
break if edgeFissIdsOK:
except: if isinstance(param_0, int):
print("except eval") pass
elif isinstance(param_0, str):
pass
else:
print("Il faut une liste d'IDs d'arêtes ou une liste de noms de groupes d'arêtes.")
incomplet = True
edgeFissIdsOK=False
else:
incomplet = True incomplet = True
edgeFissIdsOK=False edgeFissIdsOK=False
if edgeFissIdsOK: if edgeFissIdsOK:
@ -306,21 +321,21 @@ def fissureGeneraleDlg(context):
self.ui.le_nomres.setText(nomres) self.ui.le_nomres.setText(nomres)
def creeDico(self): def creeDico(self):
dico = dict( dico = dict( \
maillageSain = str(self.ui.le_maillage.text()), maillageSain = str(self.ui.le_maillage.text()), \
brepFaceFissure = str(self.ui.le_facefiss.text()), brepFaceFissure = str(self.ui.le_facefiss.text()), \
edgeFissIds = eval(str(self.ui.le_fondfiss.text())), edgeFissIds = eval(str(self.ui.le_fondfiss.text())), \
lgInfluence = self.ui.dsb_influence.value(), lgInfluence = self.ui.dsb_influence.value(), \
meshBrep = [self.ui.dsb_meshBrepMin.value(),self.ui.dsb_meshBrepMax.value()], meshBrep = [self.ui.dsb_meshBrepMin.value(),self.ui.dsb_meshBrepMax.value()], \
rayonPipe = self.ui.dsb_rayonPipe.value(), rayonPipe = self.ui.dsb_rayonPipe.value(), \
lenSegPipe = self.ui.dsb_lenSegPipe.value(), lenSegPipe = self.ui.dsb_lenSegPipe.value(), \
nbSegRad = self.ui.sb_couronnes.value(), nbSegRad = self.ui.sb_couronnes.value(), \
nbSegCercle = self.ui.sb_secteurs.value(), nbSegCercle = self.ui.sb_secteurs.value(), \
areteFaceFissure = self.ui.dsb_areteFaceFissure.value(), areteFaceFissure = self.ui.dsb_areteFaceFissure.value(), \
aretesVives = self.ui.dsb_aretesVives.value(), aretesVives = self.ui.dsb_aretesVives.value(), \
reptrav = str(self.ui.le_reptrav.text()), reptrav = str(self.ui.le_reptrav.text()), \
nomres = str(self.ui.le_nomres.text()), nomres = str(self.ui.le_nomres.text()), \
verbosite = self.ui.cb_log.currentIndex() verbosite = self.ui.cb_log.currentIndex() \
) )
print(dico) print(dico)
return dico return dico
@ -384,4 +399,3 @@ def fissureGeneraleDlg(context):
else: else:
print("dialog rejected, exit") print("dialog rejected, exit")
pass pass