1 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 # File : SMESH_test1.py
32 def SetSObjName(theSObj,theName) :
33 ok, anAttr = theSObj.FindAttribute("AttributeName")
35 aName = anAttr._narrow(SALOMEDS.AttributeName)
37 aName.SetValue(theName)
39 def ConvertMED2UNV(thePath,theFile) :
40 anInitFileName = thePath + theFile
41 aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName)
42 print aResult, aMeshes
44 for iMesh in range(len(aMeshes)) :
45 aMesh = aMeshes[iMesh]
46 anSObj = salome.ObjectToSObject(aMesh)
47 print anSObj.GetName(),
48 aFileName = anInitFileName
49 aFileName = os.path.basename(aFileName)
50 SetSObjName(anSObj,aFileName)
51 print anSObj.GetName()
54 aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
55 aMesh.ExportUNV(aFileName)
56 aMesh = smesh.CreateMeshesFromUNV(aFileName)
57 anSObj = salome.ObjectToSObject(aMesh)
58 print anSObj.GetName(),
60 aFileName = os.path.basename(aFileName)
61 SetSObjName(anSObj,aFileName)
62 print anSObj.GetName()
64 smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
65 smesh.SetCurrentStudy(salome.myStudy)
67 aPath = os.getenv('DATA_DIR') + '/MedFiles/'
68 aListDir = os.listdir(aPath)
71 for iFile in range(len(aListDir)) :
72 aFileName = aListDir[iFile]
73 aName,anExt = os.path.splitext(aFileName)
75 aFileName = os.path.basename(aFileName)
77 ConvertMED2UNV(aPath,aFileName)
80 salome.sg.updateObjBrowser(1)