X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH_I%2FSMESH_test.py;h=0cc3a94bf8c00d14a3ba265247019d9a7f276bed;hb=61f149c6811e7e3a1e03441cbbdefbe793373c72;hp=4129057670caab6b9fcc150dee27125eba082445;hpb=bef9beee88cac57394b8dc3bc914381c1a2fff83;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_test.py b/src/SMESH_I/SMESH_test.py index 412905767..0cc3a94bf 100644 --- a/src/SMESH_I/SMESH_test.py +++ b/src/SMESH_I/SMESH_test.py @@ -1,125 +1,127 @@ -# creer des geometries, en selectionner une +# SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_test.py +# Module : SMESH -import SMESH -import smeshpy import salome -from salome import sg -import math -#import SMESH_BasicHypothesis_idl - import geompy +import smeshpy -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") -myBuilder = salome.myStudy.NewBuilder() -from geompy import gg - -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 +import SMESH +import StdMeshers # ---- define a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idb = geompy.addToStudy(box,"box") +idb = geompy.addToStudy(box, "box") # ---- add first face of box in study -subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) -face=subShapeList[0] -name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) -print name -idf=geompy.addToStudyInFather(box,face,name) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +idf = geompy.addToStudyInFather(box, face, name) # ---- add shell from box in study -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) shell = subShellList[0] -name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) -print name -ids=geompy.addToStudyInFather(box,shell,name) +name = geompy.SubShapeName(shell, box) +ids = geompy.addToStudyInFather(box, shell, name) # ---- add first edge of face in study -edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) -edge=edgeList[0]; -name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) -print name -ide=geompy.addToStudyInFather(face,edge,name) +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0]; +name = geompy.SubShapeName(edge, face) +ide = geompy.addToStudyInFather(face, edge, name) # ---- launch SMESH, init a Mesh with the box -gen=smeshpy.smeshpy() -mesh=gen.Init(idb) -# ---- create Hypothesis +gen = smeshpy.smeshpy() +mesh = gen.CreateMesh(idb) print "-------------------------- create Hypothesis" + print "-------------------------- LocalLength" -hyp1=gen.CreateHypothesis("LocalLength") -print hyp1.GetName() -print hyp1.GetId() -hypo1 = hyp1._narrow(SMESH.SMESH_LocalLength) + +hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") +print hypo1.GetName() +print hypo1.GetId() print hypo1.GetLength() hypo1.SetLength(100) print hypo1.GetLength() print "-------------------------- bidon" -hyp3=gen.CreateHypothesis("bidon") + +hyp3 = gen.CreateHypothesis("bidon", "") print "-------------------------- NumberOfSegments" -hyp3=gen.CreateHypothesis("NumberOfSegments") -hypo3=hyp3._narrow(SMESH.SMESH_NumberOfSegments) + +hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypo3.SetNumberOfSegments(7) print hypo3.GetName() print hypo3.GetNumberOfSegments() print hypo3.GetId() print "-------------------------- MaxElementArea" -hyp4=gen.CreateHypothesis("MaxElementArea") -hypo4=hyp4._narrow(SMESH.SMESH_MaxElementArea) + +hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypo4.SetMaxElementArea(5000) print hypo4.GetName() print hypo4.GetMaxElementArea() print hypo4.GetId() print "-------------------------- Regular_1D" -alg1=gen.CreateHypothesis("Regular_1D") -print alg1.GetName() -print alg1.GetId() -algo1=alg1._narrow(SMESH.SMESH_Algo) -listHyp=algo1.GetCompatibleHypothesis() + +algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +print algo_1.GetName() +print algo_1.GetId() +listHyp = algo_1.GetCompatibleHypothesis() for hyp in listHyp: print hyp - -algo_1=alg1._narrow(SMESH.SMESH_Regular_1D) print algo_1.GetId() print "-------------------------- MEFISTO_2D" -alg2=gen.CreateHypothesis("MEFISTO_2D") -print alg2.GetName() -print alg2.GetId() -algo2=alg2._narrow(SMESH.SMESH_Algo) -listHyp=algo2.GetCompatibleHypothesis() + +algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +print algo_2.GetName() +print algo_2.GetId() +listHyp = algo_2.GetCompatibleHypothesis() for hyp in listHyp: print hyp -algo_2=alg2._narrow(SMESH.SMESH_MEFISTO_2D) print algo_2.GetId() -# ---- add hypothesis to edge - print "-------------------------- add hypothesis to edge" -edge=salome.IDToObject(ide) -submesh=mesh.GetElementsOnShape(edge) -ret=mesh.AddHypothesis(edge,algo_1) + +edge = salome.IDToObject(ide) +submesh = mesh.GetSubMesh(edge, "SubMeshEdge") +ret = mesh.AddHypothesis(edge,algo_1) print ret -ret=mesh.AddHypothesis(edge,hypo1) +ret = mesh.AddHypothesis(edge,hypo1) print ret -# ---- compute edge - ##print "-------------------------- compute edge" ##ret=gen.Compute(mesh,ide) ##print ret @@ -127,26 +129,24 @@ print ret ##for a in log: ## print a -# ---- add hypothesis to box - print "-------------------------- add hypothesis to box" -box=salome.IDToObject(idb) -submesh=mesh.GetElementsOnShape(box) -ret=mesh.AddHypothesis(box,algo_1) + +box = salome.IDToObject(idb) +submesh = mesh.GetSubMesh(box, "SubMeshBox") +ret = mesh.AddHypothesis(box,algo_1) print ret -ret=mesh.AddHypothesis(box,hypo1) +ret = mesh.AddHypothesis(box,hypo1) print ret -ret=mesh.AddHypothesis(box,algo_2) +ret = mesh.AddHypothesis(box,algo_2) print ret -ret=mesh.AddHypothesis(box,hypo4) +ret = mesh.AddHypothesis(box,hypo4) print ret -# ---- compute face +print "-------------------------- compute" -print "-------------------------- compute face" -ret=gen.Compute(mesh,idf) +ret = gen.Compute(mesh,idf) print ret -log=mesh.GetLog(1); +log = mesh.GetLog(1); for a in log: print "-------" ii = 0 @@ -184,8 +184,6 @@ for a in log: ii = ii+1 print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3) -# ---- compute box - ##print "-------------------------- compute box" ##ret=gen.Compute(mesh,idb) ##print ret @@ -200,4 +198,3 @@ for a in log: ##print ret ##ret=gen.Compute(mesh,ids) ##print ret -