import salome
import SALOMEDS
import SMESH
+import GEOM
import SalomePyQt
import MonChoixMaillage
class CLinit:
def __init__(self):
+ geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+ self.GroupOp = geom.GetIGroupOperations(salome.myStudyId)
self.smesh=None
+ self.geomcompID=None
self._d = SalomePyQt.SalomePyQt().getDesktop()
- self.get_maillages()
self.correspondanceNomIOR = {}
+ self.correspondanceNomIORshape = {}
self.name="CL"
+ print "fin init"
def GetOrCreateCL(self,myShapeName):
if not (dict_CL.has_key(myShapeName)):
def traiteCL(self):
+ self.get_geoms()
+ self.get_maillages()
# Récupere tous les Mesh
if len(dict_CL) > 0:
Choix=MonChoixMaillage.MonChoixMaillage(self,0,self._d)
salome.sg.updateObjBrowser(0)
-
+
+
def traiteMaillage(self,indiceIOR,NomMaillage):
MeshIOR = self.correspondanceNomIOR[str(NomMaillage)]
Mesh = salome.orb.string_to_object(MeshIOR)
GEOMIor = dict_CL.keys()[indiceIOR]
for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
- GEOMShape = salome.orb.string_to_object(monIOR)
+ GEOMShape = salome.orb.string_to_object(monIOR)
aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
attrName = aShapeSO.FindAttribute("AttributeName")[1]
- anAttr = attrName._narrow(SALOMEDS.AttributeName)
+ 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)
+ GEOMShape = salome.orb.string_to_object(monIOR)
aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
attrName = aShapeSO.FindAttribute("AttributeName")[1]
- anAttr = attrName._narrow(SALOMEDS.AttributeName)
+ anAttr = attrName._narrow(SALOMEDS.AttributeName)
Name = anAttr.Value()
- #_CS_cbo: ajout de la determination de la dimension de la geometrie
- #Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
- ShapeType = GEOMShape.GetShapeType()
- print ShapeType
- if str(ShapeType) is "EDGE":
- print "--------------- EDGE existing Mesh"
- Mesh.CreateGroupFromGEOM(SMESH.EDGE,Name,GEOMShape)
- else:
- print "--------------- FACE existing Mesh"
- Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
+ #_CS_cbo: ajout de la determination de la dimension de la geometrie
+ type = self.getShapeType(GEOMShape)
+ Mesh.CreateGroupFromGEOM(type,Name,GEOMShape)
del dict_CL[GEOMIor]
- def traiteNewMaillage(self,indiceIOR,NomMaillage):
- GEOMIor = dict_CL.keys()[indiceIOR]
- shape = salome.orb.string_to_object(GEOMIor)
+ def traiteNewMaillage(self,numero,indiceIOR,NomMaillage):
+ GEOMIor=dict_CL.keys()[numero]
+ GEOMShapeIor=self.correspondanceNomIORshape[str(indiceIOR)]
+ shape = salome.orb.string_to_object(GEOMShapeIor)
if self.smesh == None :
- self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
- self.smesh.SetCurrentStudy(salome.myStudy)
+ 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)
+ 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)
+ GEOMShape = salome.orb.string_to_object(monIOR)
aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
attrName = aShapeSO.FindAttribute("AttributeName")[1]
- anAttr = attrName._narrow(SALOMEDS.AttributeName)
+ anAttr = attrName._narrow(SALOMEDS.AttributeName)
Name = anAttr.Value()
#_CS_cbo: ajout de la determination de la dimension de la geometrie
- #newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
- ShapeType = GEOMShape.GetShapeType()
- print ShapeType
- if str(ShapeType) is "EDGE":
- print "--------------- EDGE newMesh"
- newMesh.CreateGroupFromGEOM(SMESH.EDGE,Name,GEOMShape)
- else:
- print "--------------- FACE newMesh"
- newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
+ type = self.getShapeType(GEOMShape)
+ newMesh.CreateGroupFromGEOM(type,Name,GEOMShape)
del dict_CL[GEOMIor]
def NomShape(self,numero):
# NodeorCell = 0 on traite des noeuds
# NodeorCell = 1 on traite des mailles
- def Possibles(self,numero):
- GEOMIor = dict_CL.keys()[numero]
+ def Possibles(self,numero,GeomChoisie):
+ GEOMIor=self.correspondanceNomIORshape[str(GeomChoisie)]
liste=[]
if GEOMIor in self.Liste_maillages.keys():
for MeshIor in self.Liste_maillages[GEOMIor]:
liste.append(Name)
return liste
+
+ def MainShapes(self,numero):
+ GEOMIor = dict_CL.keys()[numero]
+ listeNoms=[]
+ for MainID in self.Liste_geoms[GEOMIor]:
+ aSO = salome.myStudy.FindObjectID(MainID)
+ if aSO==None:
+ print "pb dans MainShapes"
+ return listeNoms
+ attrName = aSO.FindAttribute("AttributeName")[1]
+ anAttr = attrName._narrow(SALOMEDS.AttributeName)
+ Name = anAttr.Value()
+ listeNoms.append(Name)
+ IORAttr = aSO.FindAttribute("AttributeIOR")[1]
+ anAttr = IORAttr._narrow(SALOMEDS.AttributeIOR)
+ GEOMShapeIOR = anAttr.Value()
+ self.correspondanceNomIORshape[Name]=GEOMShapeIOR
+ return listeNoms
+
+
+ def getShapeType(self,GEOMShape):
+ """
+ Determination du type de geometrie pour les conditions aux limites.
+
+ Le type de geometrie determine le type de mailles.
+ Voir le dictionnnaire ShapeType dans geompy.py pour les correspondances type - numero.
+ """
+ type = []
+ tgeo = str(GEOMShape.GetShapeType())
+ if tgeo == "VERTEX":
+ type = SMESH.NODE
+ elif tgeo == "EDGE":
+ type = SMESH.EDGE
+ elif tgeo == "FACE":
+ type = SMESH.FACE
+ elif tgeo == "SOLID":
+ type = SMESH.VOLUME
+ elif tgeo == "COMPOUND":
+ tgeo = self.GroupOp.GetType(GEOMShape)
+ if tgeo == 7:
+ type = SMESH.NODE
+ elif tgeo == 6:
+ type = SMESH.EDGE
+ elif tgeo == 4:
+ type = SMESH.FACE
+ elif tgeo == 2:
+ type = SMESH.VOLUME
+ return type
+
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)
+ print stringIOR
SO_smesh=salome.myStudy.FindObjectIOR(stringIOR)
if SO_smesh != None:
+ print salome.myStudy
ChildIterator = salome.myStudy.NewChildIterator(SO_smesh)
while ChildIterator.More() :
aSObj = ChildIterator.Value()
else :
self.Liste_maillages[GEOMShapeIOR]=[MeshIOR]
+ def get_geoms(self):
+ self.Liste_geoms={}
+ for GeomCLIOR in dict_CL.keys():
+ self.Liste_geoms[GeomCLIOR]=[]
+ self.chercheMain(GeomCLIOR,GeomCLIOR)
+
+ def chercheMain(self,GEOMIor,GeomCLIOR):
+
+
+ sobj = salome.myStudy.FindObjectIOR(GEOMIor)
+ if sobj == None :
+ print "objet nul dans chercheMain"
+ return
+
+ # On cherche les dépendances et
+ # on ajoute l objet lui-même à la liste
+ Listedep=salome.myStudy.FindDependances(sobj)
+ Listedep.append(sobj)
+
+ ListeAtraiter=[]
+ for sobj in Listedep :
+ # tant que l objet est une reference
+ # on cherche son pere
+ current=sobj
+ boo,iorso = sobj.FindAttribute("AttributeIOR")
+ while ( boo==0 ) :
+ current=current.GetFather()
+ boo,iorso = current.FindAttribute("AttributeIOR")
+ iorString = iorso.Value()
+ shapeobj=salome.orb.string_to_object(iorString)
+ Shape=shapeobj._narrow(GEOM.GEOM_Object)
+ if Shape != None :
+ if self.geomcompID == None:
+ self.geomcompID = current.GetFatherComponent().GetID()
+ ListeAtraiter.append(current)
+
+ for sobj in ListeAtraiter:
+ current=sobj
+ while ( current.GetFather().GetID() != self.geomcompID):
+ current=current.GetFather()
+ MainID=current.GetID()
+ if (MainID not in self.Liste_geoms[GeomCLIOR]):
+ self.Liste_geoms[GeomCLIOR].append(MainID)
+ Attr = current.FindAttribute("AttributeIOR")[1]
+ if (Attr != None):
+ MainIORAttr = Attr._narrow(SALOMEDS.AttributeIOR)
+ MainIor = MainIORAttr.Value()
+ self.chercheMain(MainIor,GeomCLIOR)
+
def SetName(self,Entry, Name):
SO = salome.myStudy.FindObjectID( Entry )
if SO != None :
else :
self.CLOnNode[CLName] = 1
if (nodeOrCell == 1) :
- print "FFFFFACCE"
+ print "MAILLE"
if self.CLOnCell.has_key(CLName):
self.CLOnCell[CLName] = self.CLOnCell[CLName] + 1
else :