From 8dd9fa825994b0da063118f18b59dddcfc80228a Mon Sep 17 00:00:00 2001 From: salome <> Date: Tue, 1 Feb 2005 10:55:41 +0000 Subject: [PATCH] =?utf8?q?PN=20:=20int=C3=A9gration=20des=20CL=20dans=20Ef?= =?utf8?q?icas=20et=20non=20dans=20SMESH?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/EFICASGUI/ChoixMaillage.py | 53 +++++++++ src/EFICASGUI/ChoixMaillage.ui | 131 +++++++++++++++++++++ src/EFICASGUI/Makefile.in | 3 + src/EFICASGUI/MonChoixMaillage.py | 40 +++++++ src/EFICASGUI/SMESH_utils.py | 11 +- src/EFICASGUI/eficasCL.py | 188 ++++++++++++++++++++++++++++++ 6 files changed, 422 insertions(+), 4 deletions(-) create mode 100644 src/EFICASGUI/ChoixMaillage.py create mode 100644 src/EFICASGUI/ChoixMaillage.ui create mode 100644 src/EFICASGUI/MonChoixMaillage.py create mode 100644 src/EFICASGUI/eficasCL.py diff --git a/src/EFICASGUI/ChoixMaillage.py b/src/EFICASGUI/ChoixMaillage.py new file mode 100644 index 00000000..630e7856 --- /dev/null +++ b/src/EFICASGUI/ChoixMaillage.py @@ -0,0 +1,53 @@ +# Form implementation generated from reading ui file 'ChoixMaillage.ui' +# +# Created: Tue Jan 25 11:28:46 2005 +# by: The PyQt User Interface Compiler (pyuic) +# +# WARNING! All changes made in this file will be lost! + + +from qt import * +Extracting Python code from ChoixMaillage.ui.h + + +class ChoixMaillage(QDialog): + def __init__(self,parent = None,name = None,modal = 0,fl = 0): + QDialog.__init__(self,parent,name,modal,fl) + + if name == None: + self.setName("ChoixMaillage") + + self.resize(526,252) + self.setCaption(self.trUtf8("Choix du Maillage sur lequel s appliquent les condtions aux limites")) + + + self.TextLabel1 = QLabel(self,"TextLabel1") + self.TextLabel1.setGeometry(QRect(10,190,191,40)) + self.TextLabel1.setText(self.trUtf8("Nom du nouveau maillage")) + + self.TextLabel2 = QLabel(self,"TextLabel2") + self.TextLabel2.setGeometry(QRect(20,70,181,31)) + self.TextLabel2.setText(self.trUtf8("Maillage sélectionné")) + + self.Maillage = QListBox(self,"Maillage") + self.Maillage.setGeometry(QRect(210,70,281,90)) + + self.TextLabel1_2 = QLabel(self,"TextLabel1_2") + self.TextLabel1_2.setGeometry(QRect(20,10,120,20)) + self.TextLabel1_2.setText(self.trUtf8("Géométrie traitée :")) + + self.NomShape = QLabel(self,"NomShape") + self.NomShape.setGeometry(QRect(140,10,191,21)) + self.NomShape.setText(self.trUtf8("TextLabel2")) + + self.NouveauMesh = QLineEdit(self,"NouveauMesh") + self.NouveauMesh.setGeometry(QRect(210,200,280,24)) + + self.connect(self.Maillage,SIGNAL("clicked(QListBoxItem*)"),self.Maillage_clicked) + self.connect(self.NouveauMesh,SIGNAL("returnPressed()"),self.NouveauMesh_returnPressed) + + def Maillage_clicked(self,a0): + print "ChoixMaillage.Maillage_clicked(QListBoxItem*): Not implemented yet" + + def NouveauMesh_returnPressed(self): + print "ChoixMaillage.NouveauMesh_returnPressed(): Not implemented yet" diff --git a/src/EFICASGUI/ChoixMaillage.ui b/src/EFICASGUI/ChoixMaillage.ui new file mode 100644 index 00000000..ad2e6e46 --- /dev/null +++ b/src/EFICASGUI/ChoixMaillage.ui @@ -0,0 +1,131 @@ + +ChoixMaillage + + + ChoixMaillage + + + + 0 + 0 + 526 + 252 + + + + Choix du Maillage sur lequel s appliquent les condtions aux limites + + + + TextLabel1 + + + + 10 + 190 + 191 + 40 + + + + Nom du nouveau maillage + + + + + TextLabel2 + + + + 20 + 70 + 181 + 31 + + + + Maillage sélectionné + + + + + Maillage + + + + 210 + 70 + 281 + 90 + + + + + + TextLabel1_2 + + + + 20 + 10 + 120 + 20 + + + + Géométrie traitée : + + + + + NomShape + + + + 140 + 10 + 191 + 21 + + + + TextLabel2 + + + + + NouveauMesh + + + + 210 + 200 + 280 + 24 + + + + + + + Maillage + clicked(QListBoxItem*) + ChoixMaillage + Maillage_clicked(QListBoxItem*) + + + NouveauMesh + returnPressed() + ChoixMaillage + NouveauMesh_returnPressed() + + + + ChoixMaillage.ui.h + + + Maillage_clicked( QListBoxItem * ) + NouveauMesh_returnPressed() + + + diff --git a/src/EFICASGUI/Makefile.in b/src/EFICASGUI/Makefile.in index ad8e5e5a..6ac50505 100644 --- a/src/EFICASGUI/Makefile.in +++ b/src/EFICASGUI/Makefile.in @@ -37,6 +37,9 @@ eficasEtude.py \ EFICASGUI.py \ salomedsgui.py \ SMESH_utils.py \ +eficasCL.py \ +ChoixMaillage.py \ +MonChoixMaillage.py \ eficasSalome.py # _CS_gbo_151104 Ajout pour compatibilité ascendante entre versions de Eficas diff --git a/src/EFICASGUI/MonChoixMaillage.py b/src/EFICASGUI/MonChoixMaillage.py new file mode 100644 index 00000000..d332efa2 --- /dev/null +++ b/src/EFICASGUI/MonChoixMaillage.py @@ -0,0 +1,40 @@ + +import salome +import salomedsgui +aGuiDS=salomedsgui.guiDS() + +# ----------------------------------------------------------------------------- + +import ChoixMaillage + + +class MonChoixMaillage(ChoixMaillage.ChoixMaillage): + """ + adaptation de la classe generee par pyuic. + """ + def __init__(self,CL,monNum,parent = None,name = None,modal = 0,fl = 0,): + ChoixMaillage.ChoixMaillage.__init__(self,parent,name,modal,fl) + self._CL=CL + self._numero=monNum + self.recupere_info() + + self.NomShape.setText(self._nomShape) + for item in self._listeMesh: + self.Maillage.insertItem(item) + self.show() + + def recupere_info(self): + self._nomShape = self._CL.NomShape(self._numero) + self._listeMesh= self._CL.Possibles(self._numero) + + def Maillage_clicked(self,item) : + self._CL.traiteMaillage(self._numero,item.text()) + self._CL.traiteCL() + self.close() + + + def NouveauMesh_returnPressed(self): + self._CL.traiteNewMaillage(self._numero,str(self.NouveauMesh.text())) + self._CL.traiteCL() + self.close() + diff --git a/src/EFICASGUI/SMESH_utils.py b/src/EFICASGUI/SMESH_utils.py index 48cf007f..67a15325 100644 --- a/src/EFICASGUI/SMESH_utils.py +++ b/src/EFICASGUI/SMESH_utils.py @@ -4,7 +4,7 @@ # Author : Paul RASCLE, EDF # Project : SALOME # Copyright : EDF 2003 -# $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/SMESH_utils.py,v 1.2 2004/12/10 16:43:25 salome Exp $ +# $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/SMESH_utils.py,v 1.3 2004/12/10 18:55:02 salome Exp $ #============================================================================= from omniORB import CORBA @@ -12,6 +12,7 @@ import LifeCycleCORBA import SALOMEDS import GEOM import SMESH +from eficasCL import * # initialise the ORB orb = CORBA.ORB_init([''], CORBA.ORB_ID) @@ -142,16 +143,16 @@ def getSMESHSubShapeIndexes(myStudy, entryList, typenoeudorcell = 0): refList = [] subShapeIndexes = [] - print "################ len(entryList)=", len(entryList) if len(entryList) > 0: iorStringMain = getMainShapeName(myStudy, entryList[0]) if iorStringMain == None: raise RuntimeException("L'ior CORBA n'est pas défini") - print "################ iorStringMain=", iorStringMain - myCL=smesh.GetOrCreateCL(str(iorStringMain)) + #myCL=smesh.GetOrCreateCL(str(iorStringMain)) + myCLinit=CLinit() + myCL=myCLinit.GetOrCreateCL(iorStringMain) if len(entryList) > 0: for idShape in entryList: @@ -173,8 +174,10 @@ def getAsterGroupNo(myStudy,entryList): typenoeudorcell = 0 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell) labelGroupNo = [] + print "d" for val in subShapeIndexes: labelGroupNo.append(val) + print "e" return labelGroupNo #-------------------------------------------------------------------------- diff --git a/src/EFICASGUI/eficasCL.py b/src/EFICASGUI/eficasCL.py new file mode 100644 index 00000000..dfe51325 --- /dev/null +++ b/src/EFICASGUI/eficasCL.py @@ -0,0 +1,188 @@ +import salome +import SALOMEDS +import SMESH +import SalomePyQt +import MonChoixMaillage + +Tag_RefOnShape = 1 +dict_CL={} + +class CLinit: + def __init__(self): + self.smesh=None + self._d = SalomePyQt.SalomePyQt().getDesktop() + self.get_maillages() + self.listeDejaTraites= [] + self.Liste_Shape = {} + self.correspondanceNomIOR = {} + self.name="CL" + + def GetOrCreateCL(self,myShapeName): + if not (dict_CL.has_key(myShapeName)): + dict_CL[myShapeName] = CL() + return dict_CL[myShapeName] + + def chercheAtraiter(self): + atraiter=-1 + curseur=0 + print dict_CL.keys() + print self.listeDejaTraites + while curseur < len(dict_CL): + GEOMIor=self.Liste_Shape[curseur] + if GEOMIor not in self.listeDejaTraites: + atraiter=curseur + break + curseur=curseur+1 + return atraiter + + def traiteCL(self): + # Récupere tous les Mesh + if self.Liste_Shape == {}: + self.Liste_Shape = dict_CL.keys() + atraiter=self.chercheAtraiter() + if atraiter >= 0: + Choix=MonChoixMaillage.MonChoixMaillage(self,atraiter,self._d) + salome.sg.updateObjBrowser(0) + + def traiteMaillage(self,indiceIOR,NomMaillage): + MeshIOR = self.correspondanceNomIOR[str(NomMaillage)] + Mesh = salome.orb.string_to_object(MeshIOR) + GEOMIor =self.Liste_Shape[indiceIOR] + for monIOR in dict_CL[GEOMIor].CLOnNode.keys(): + GEOMShape = salome.orb.string_to_object(monIOR) + aShapeSO = salome.myStudy.FindObjectIOR(monIOR) + attrName = aShapeSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + Mesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape) + for monIOR in dict_CL[GEOMIor].CLOnCell.keys(): + GEOMShape = salome.orb.string_to_object(monIOR) + aShapeSO = salome.myStudy.FindObjectIOR(monIOR) + attrName = aShapeSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape) + self.listeDejaTraites.append(GEOMIor) + + + def traiteNewMaillage(self,indiceIOR,NomMaillage): + GEOMIor =self.Liste_Shape[indiceIOR] + print GEOMIor + print dict_CL[GEOMIor].CLOnNode.keys() + print dict_CL[GEOMIor].CLOnCell.keys() + shape = salome.orb.string_to_object(GEOMIor) + if self.smesh == None : + self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + self.smesh.SetCurrentStudy(salome.myStudy) + assert (self.smesh) + newMesh = self.smesh.CreateMesh(shape) + self.SetName(salome.ObjectToID(newMesh),NomMaillage) + for monIOR in dict_CL[GEOMIor].CLOnNode.keys(): + GEOMShape = salome.orb.string_to_object(monIOR) + aShapeSO = salome.myStudy.FindObjectIOR(monIOR) + attrName = aShapeSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + newMesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape) + for monIOR in dict_CL[GEOMIor].CLOnCell.keys(): + GEOMShape = salome.orb.string_to_object(monIOR) + aShapeSO = salome.myStudy.FindObjectIOR(monIOR) + attrName = aShapeSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape) + self.listeDejaTraites.append(GEOMIor) + + def NomShape(self,numero): + GEOMIor=self.Liste_Shape[numero] + aShapeSO = salome.myStudy.FindObjectIOR(GEOMIor) + attrName = aShapeSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + return Name + +# NodeorCell = 0 on traite des noeuds +# NodeorCell = 1 on traite des mailles + + def Possibles(self,numero): + GEOMIor=self.Liste_Shape[numero] + liste=[] + for MeshIor in self.Liste_maillages[GEOMIor]: + aMeshSO = salome.myStudy.FindObjectIOR(MeshIor) + attrName = aMeshSO.FindAttribute("AttributeName")[1] + anAttr = attrName._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + self.correspondanceNomIOR[Name] = MeshIor + liste.append(Name) + return liste + + def get_maillages(self): + self.Liste_maillages={} + if self.smesh == None : + self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + self.smesh.SetCurrentStudy(salome.myStudy) + stringIOR=salome.orb.object_to_string(self.smesh) + SO_smesh=salome.myStudy.FindObjectIOR(stringIOR) + if SO_smesh != None: + ChildIterator = salome.myStudy.NewChildIterator(SO_smesh) + while ChildIterator.More() : + aSObj = ChildIterator.Value() + ChildIterator.Next() + anAttr =aSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName) + Name = anAttr.Value() + if (Name != "Hypotheses" and Name != "Algorithms"): + res, Ref = aSObj.FindSubObject( Tag_RefOnShape ) + if res == 1 : + ok,MyShapeSO = Ref.ReferencedObject() + if ok : + IORAttr = MyShapeSO.FindAttribute("AttributeIOR")[1] + anAttr = IORAttr._narrow(SALOMEDS.AttributeIOR) + GEOMShapeIOR = anAttr.Value() + + IORAttr2 = aSObj.FindAttribute("AttributeIOR")[1] + anAttr2 = IORAttr2._narrow(SALOMEDS.AttributeIOR) + MeshIOR = anAttr2.Value() + + if GEOMShapeIOR in self.Liste_maillages.keys(): + self.Liste_maillages[GEOMShapeIOR].append(MeshIOR) + else : + self.Liste_maillages[GEOMShapeIOR]=[MeshIOR] + + def SetName(self,Entry, Name): + SO = salome.myStudy.FindObjectID( Entry ) + if SO != None : + myStudyBuilder = salome.myStudy.NewBuilder() + aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName") + aName.SetValue(Name) + +class CL: + + def __init__(self): + self.CLOnCell={} + self.CLOnNode={} + +# nodeOrCell = 0 on traite des noeuds +# nodeOrCell = 1 on traite des faces + + def SetIdAsCL(self,CLName,nodeOrCell): + if (nodeOrCell == 0) : + if self.CLOnNode.has_key(CLName): + self.CLOnNode[CLName] = self.CLOnNode[CLName] + 1 + else : + self.CLOnNode[CLName] = 1 + if (nodeOrCell == 1) : + if self.CLOnCell.has_key(CLName): + self.CLOnCell[CLName] = self.CLOnCell[CLName] + 1 + else : + self.CLOnCell[CLName] = 1 + + def UnSetIdAsCL(self,CLName,nodeOrCell): + if (nodeOrCell == 0) : + if self.CLOnNode.has_key(CLName): + self.CLOnNode[CLName] = self.CLOnNode[CLName] - 1 + if (nodeOrCell == 1) : + if self.CLOnCell.has_key(CLName): + self.CLOnCell[CLName] = self.CLOnCell[CLName] - 1 + + -- 2.39.2