mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-25 09:20:32 +05:00
adding python scripts to illustrate the way to mesh a shape giving different hypothesis on its sub-shapes.
This commit is contained in:
parent
d65fdaa969
commit
fe9985e3cf
@ -53,7 +53,12 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \
|
||||
SMESH_box2_tetra.py \
|
||||
SMESH_box3_tetra.py \
|
||||
SMESH_flight_skin.py \
|
||||
SMESH_Partition1_tetra.py
|
||||
SMESH_Partition1_tetra.py \
|
||||
SMESH_box_hexa.py \
|
||||
SMESH_demo_hexa2.py \
|
||||
SMESH_demo_hexa.py \
|
||||
SMESH_demo_tetra2.py \
|
||||
SMESH_demo_tetra.py
|
||||
|
||||
LIB_CLIENT_IDL = SALOMEDS.idl \
|
||||
SALOME_Exception.idl \
|
||||
|
215
src/SMESH_SWIG/SMESH_box_hexa.py
Normal file
215
src/SMESH_SWIG/SMESH_box_hexa.py
Normal file
@ -0,0 +1,215 @@
|
||||
#
|
||||
# Hexahedrization of a simple box. Hypothesis and algorithms for
|
||||
# the mesh generation are not global: the mesh of some edges is thinner
|
||||
#
|
||||
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
|
||||
import SMESH
|
||||
import smeshpy
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
geom = geompy.geom
|
||||
myBuilder = geompy.myBuilder
|
||||
|
||||
ShapeTypeShell = 3
|
||||
ShapeTypeFace = 4
|
||||
ShapeTypeEdge = 6
|
||||
|
||||
# ---- define a boxe
|
||||
|
||||
box = geompy.MakeBox(0., 0., 0., 1., 1., 1.)
|
||||
|
||||
idbox = geompy.addToStudy(box,"box")
|
||||
|
||||
print "Analysis of the geometry box :"
|
||||
subShellList=geompy.SubShapeAllSorted(box,ShapeTypeShell)
|
||||
subFaceList=geompy.SubShapeAllSorted(box,ShapeTypeFace)
|
||||
subEdgeList=geompy.SubShapeAllSorted(box,ShapeTypeEdge)
|
||||
|
||||
print "number of Shells in box : ",len(subShellList)
|
||||
print "number of Faces in box : ",len(subFaceList)
|
||||
print "number of Edges in box : ",len(subEdgeList)
|
||||
|
||||
idSubEdge = []
|
||||
for k in range(len(subEdgeList)):
|
||||
idSubEdge.append(geompy.addToStudyInFather(box,subEdgeList[k],"SubEdge"+str(k)))
|
||||
|
||||
edgeX = []
|
||||
edgeX.append(subEdgeList[4])
|
||||
edgeX.append(subEdgeList[5])
|
||||
edgeX.append(subEdgeList[6])
|
||||
edgeX.append(subEdgeList[7])
|
||||
|
||||
edgeY = []
|
||||
edgeY.append(subEdgeList[1])
|
||||
edgeY.append(subEdgeList[2])
|
||||
edgeY.append(subEdgeList[9])
|
||||
edgeY.append(subEdgeList[10])
|
||||
|
||||
edgeZ = []
|
||||
edgeZ.append(subEdgeList[0])
|
||||
edgeZ.append(subEdgeList[3])
|
||||
edgeZ.append(subEdgeList[8])
|
||||
edgeZ.append(subEdgeList[11])
|
||||
|
||||
idEdgeX = []
|
||||
idEdgeY = []
|
||||
idEdgeZ = []
|
||||
for i in range(4):
|
||||
idEdgeX.append(geompy.addToStudyInFather(box,edgeX[i],"EdgeX"+str(i+1)))
|
||||
idEdgeY.append(geompy.addToStudyInFather(box,edgeY[i],"EdgeY"+str(i+1)))
|
||||
idEdgeZ.append(geompy.addToStudyInFather(box,edgeZ[i],"EdgeZ"+str(i+1)))
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
gen=smeshpy.smeshpy()
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- NumberOfSegments in X, Y, Z direction"
|
||||
|
||||
numberOfSegmentsX = 10
|
||||
|
||||
hyp1=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegX=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegX.SetNumberOfSegments(numberOfSegmentsX)
|
||||
hypNbSegXID = hypNbSegX.GetId()
|
||||
print hypNbSegX.GetName()
|
||||
print hypNbSegXID
|
||||
print hypNbSegX.GetNumberOfSegments()
|
||||
|
||||
idsegX = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegX) )
|
||||
smeshgui.SetName(idsegX, "NumberOfSegmentsX")
|
||||
|
||||
print ""
|
||||
|
||||
numberOfSegmentsY = 20
|
||||
|
||||
hyp1=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegY=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegY.SetNumberOfSegments(numberOfSegmentsY)
|
||||
hypNbSegYID = hypNbSegY.GetId()
|
||||
print hypNbSegY.GetName()
|
||||
print hypNbSegYID
|
||||
print hypNbSegY.GetNumberOfSegments()
|
||||
|
||||
idsegY = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegY) )
|
||||
smeshgui.SetName(idsegY, "NumberOfSegmentsY")
|
||||
|
||||
print ""
|
||||
|
||||
numberOfSegmentsZ = 40
|
||||
|
||||
hyp1=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegZ=hyp1._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
|
||||
hypNbSegZID = hypNbSegZ.GetId()
|
||||
print hypNbSegZ.GetName()
|
||||
print hypNbSegZID
|
||||
print hypNbSegZ.GetNumberOfSegments()
|
||||
|
||||
idsegZ = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegZ) )
|
||||
smeshgui.SetName(idsegZ, "NumberOfSegmentsZ")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Regular_1D")
|
||||
regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
|
||||
regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
|
||||
smeshgui.SetName(regularID, "Wire Discretisation")
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Quadrangle_2D")
|
||||
quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
|
||||
quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
|
||||
smeshgui.SetName(quadID, "Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Hexa_3D")
|
||||
hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
|
||||
hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
|
||||
smeshgui.SetName(hexaID, "Hexa_3D")
|
||||
|
||||
# ---- init a Mesh with the boxe
|
||||
|
||||
mesh=gen.Init(idbox)
|
||||
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
|
||||
smeshgui.SetName(idmesh, "MeshBox")
|
||||
smeshgui.SetShape(idbox, idmesh)
|
||||
|
||||
# ---- add hypothesis to the boxe
|
||||
|
||||
print "-------------------------- add hypothesis to the boxe"
|
||||
print " the number of segments is globally set to"
|
||||
print " NumberOfSegmentsX = ", numberOfSegmentsX
|
||||
|
||||
ret=mesh.AddHypothesis(box,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(box,hypNbSegX)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(box,quad2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(box,hexa3D)
|
||||
print ret
|
||||
|
||||
print "-------------------------- set algoritms"
|
||||
|
||||
smeshgui.SetAlgorithms( idmesh, regularID)
|
||||
smeshgui.SetHypothesis( idmesh, idsegX )
|
||||
smeshgui.SetAlgorithms( idmesh, quadID )
|
||||
smeshgui.SetAlgorithms( idmesh, hexaID )
|
||||
|
||||
for i in range(4):
|
||||
print "-------------------------- add hypothesis to edge in the Y and Z directions", (i+1)
|
||||
|
||||
subMeshEdgeY = mesh.GetElementsOnShape(edgeY[i])
|
||||
subMeshEdgeZ = mesh.GetElementsOnShape(edgeZ[i])
|
||||
|
||||
retY = mesh.AddHypothesis(edgeY[i],hypNbSegY)
|
||||
retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
|
||||
print " add hyp Y ", retY, " Z ", retZ
|
||||
|
||||
idsmY = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idEdgeY[i],salome.orb.object_to_string(subMeshEdgeY),
|
||||
ShapeTypeEdge)
|
||||
idsmZ = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idEdgeZ[i],salome.orb.object_to_string(subMeshEdgeZ),
|
||||
ShapeTypeEdge)
|
||||
|
||||
smeshgui.SetName(idsmY, "SubMeshEdgeY_"+str(i+1))
|
||||
smeshgui.SetName(idsmZ, "SubMeshEdgeZ_"+str(i+1))
|
||||
|
||||
smeshgui.SetHypothesis(idsmY, idsegY)
|
||||
smeshgui.SetHypothesis(idsmZ, idsegZ)
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the boxe"
|
||||
ret=gen.Compute(mesh,idbox)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
else:
|
||||
print "problem when Computing the mesh"
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
|
175
src/SMESH_SWIG/SMESH_demo_hexa.py
Normal file
175
src/SMESH_SWIG/SMESH_demo_hexa.py
Normal file
@ -0,0 +1,175 @@
|
||||
#
|
||||
# Tetrahedrization of a geometry (box minus a inner cylinder).
|
||||
# Hypothesis and algorithms for the mesh generation are global
|
||||
#
|
||||
|
||||
import math
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
|
||||
import SMESH
|
||||
import smeshpy
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
geom = geompy.geom
|
||||
myBuilder = geompy.myBuilder
|
||||
|
||||
ShapeTypeShell = 3
|
||||
ShapeTypeFace = 4
|
||||
ShapeTypeEdge = 6
|
||||
|
||||
a = math.sqrt(2.)/4.
|
||||
ma = - a
|
||||
zero = 0.
|
||||
un = 1.
|
||||
mun= - un
|
||||
demi = 1./2.
|
||||
|
||||
Orig = geom.MakePointStruct(zero,zero,zero)
|
||||
P0 = geom.MakePointStruct(a,a,zero)
|
||||
P1 = geom.MakePointStruct(zero,demi,zero)
|
||||
P2 = geom.MakePointStruct(ma,a,zero)
|
||||
P3 = geom.MakePointStruct(mun,un,zero)
|
||||
P4 = geom.MakePointStruct(un,un,zero)
|
||||
P5 = geom.MakePointStruct(zero,zero,un)
|
||||
|
||||
arc = geompy.MakeArc(P0,P1,P2)
|
||||
e1 = geompy.MakeEdge(P2,P3)
|
||||
e2 = geompy.MakeEdge(P3,P4)
|
||||
e3 = geompy.MakeEdge(P4,P0)
|
||||
|
||||
list = []
|
||||
list.append(arc._get_Name())
|
||||
list.append(e1._get_Name())
|
||||
list.append(e2._get_Name())
|
||||
list.append(e3._get_Name())
|
||||
|
||||
wire = geompy.MakeWire(list)
|
||||
face = geompy.MakeFace(wire,1)
|
||||
|
||||
dir = geompy.MakeVector(Orig,P5)
|
||||
vol1 = geompy.MakePipe(dir,face)
|
||||
|
||||
angle = math.pi/2.
|
||||
dir = geom.MakeAxisStruct(zero,zero,zero,zero,zero,un)
|
||||
vol2 = geompy.MakeRotation(vol1,dir,angle)
|
||||
|
||||
vol3 = geompy.MakeRotation(vol2,dir,angle)
|
||||
|
||||
vol4 = geompy.MakeRotation(vol3,dir,angle)
|
||||
|
||||
list = []
|
||||
list.append(vol1._get_Name())
|
||||
list.append(vol2._get_Name())
|
||||
list.append(vol3._get_Name())
|
||||
list.append(vol4._get_Name())
|
||||
|
||||
volComp = geompy.MakeCompound(list)
|
||||
|
||||
tol3d = 1.e-3
|
||||
vol = geom.MakeGlueFaces(volComp,tol3d)
|
||||
idVol = geompy.addToStudy(vol,"volume")
|
||||
|
||||
print "Analysis of the final volume:"
|
||||
subShellList=geompy.SubShapeAll(vol,ShapeTypeShell)
|
||||
subFaceList=geompy.SubShapeAll(vol,ShapeTypeFace)
|
||||
subEdgeList=geompy.SubShapeAll(vol,ShapeTypeEdge)
|
||||
|
||||
print "number of Shells in the volume : ",len(subShellList)
|
||||
print "number of Faces in the volume : ",len(subFaceList)
|
||||
print "number of Edges in the volume : ",len(subEdgeList)
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
gen=smeshpy.smeshpy()
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
hypNbSegID = hypNbSeg.GetId()
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
|
||||
smeshgui.SetName(idseg, "NumberOfSegments")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Regular_1D")
|
||||
regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
|
||||
regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
|
||||
smeshgui.SetName(regularID, "Wire Discretisation")
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Quadrangle_2D")
|
||||
quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
|
||||
quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
|
||||
smeshgui.SetName(quadID, "Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Hexa_3D")
|
||||
hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
|
||||
hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
|
||||
smeshgui.SetName(hexaID, "Hexa_3D")
|
||||
|
||||
# ---- init a Mesh with the volume
|
||||
|
||||
mesh=gen.Init(idVol)
|
||||
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
|
||||
smeshgui.SetName(idmesh, "meshVolume")
|
||||
smeshgui.SetShape(idVol, idmesh)
|
||||
|
||||
# ---- add hypothesis to the volume
|
||||
|
||||
print "-------------------------- add hypothesis to the volume"
|
||||
|
||||
ret=mesh.AddHypothesis(vol,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hypNbSeg)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,quad2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hexa3D)
|
||||
print ret
|
||||
|
||||
print "-------------------------- set algoritms"
|
||||
|
||||
smeshgui.SetAlgorithms( idmesh, regularID)
|
||||
smeshgui.SetHypothesis( idmesh, idseg )
|
||||
smeshgui.SetAlgorithms( idmesh, quadID )
|
||||
smeshgui.SetAlgorithms( idmesh, hexaID )
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the volume"
|
||||
ret=gen.Compute(mesh,idVol)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
else:
|
||||
print "problem when Computing the mesh"
|
||||
|
||||
sg.updateObjBrowser(1)
|
225
src/SMESH_SWIG/SMESH_demo_hexa2.py
Normal file
225
src/SMESH_SWIG/SMESH_demo_hexa2.py
Normal file
@ -0,0 +1,225 @@
|
||||
#
|
||||
# Tetrahedrization of a geometry (box minus a inner cylinder).
|
||||
# Hypothesis and algorithms for the mesh generation are not global:
|
||||
# the mesh of some edges is thinner
|
||||
#
|
||||
|
||||
import math
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
|
||||
import SMESH
|
||||
import smeshpy
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
geom = geompy.geom
|
||||
myBuilder = geompy.myBuilder
|
||||
|
||||
ShapeTypeShell = 3
|
||||
ShapeTypeFace = 4
|
||||
ShapeTypeEdge = 6
|
||||
|
||||
a = math.sqrt(2.)/4.
|
||||
ma = - a
|
||||
zero = 0.
|
||||
un = 1.
|
||||
mun= - un
|
||||
demi = 1./2.
|
||||
|
||||
Orig = geom.MakePointStruct(zero,zero,zero)
|
||||
P0 = geom.MakePointStruct(a,a,zero)
|
||||
P1 = geom.MakePointStruct(zero,demi,zero)
|
||||
P2 = geom.MakePointStruct(ma,a,zero)
|
||||
P3 = geom.MakePointStruct(mun,un,zero)
|
||||
P4 = geom.MakePointStruct(un,un,zero)
|
||||
P5 = geom.MakePointStruct(zero,zero,un)
|
||||
|
||||
arc = geompy.MakeArc(P0,P1,P2)
|
||||
e1 = geompy.MakeEdge(P2,P3)
|
||||
e2 = geompy.MakeEdge(P3,P4)
|
||||
e3 = geompy.MakeEdge(P4,P0)
|
||||
|
||||
list = []
|
||||
list.append(arc._get_Name())
|
||||
list.append(e1._get_Name())
|
||||
list.append(e2._get_Name())
|
||||
list.append(e3._get_Name())
|
||||
|
||||
wire = geompy.MakeWire(list)
|
||||
face = geompy.MakeFace(wire,1)
|
||||
|
||||
dir = geompy.MakeVector(Orig,P5)
|
||||
vol1 = geompy.MakePipe(dir,face)
|
||||
|
||||
angle = math.pi/2.
|
||||
dir = geom.MakeAxisStruct(zero,zero,zero,zero,zero,un)
|
||||
vol2 = geompy.MakeRotation(vol1,dir,angle)
|
||||
|
||||
vol3 = geompy.MakeRotation(vol2,dir,angle)
|
||||
|
||||
vol4 = geompy.MakeRotation(vol3,dir,angle)
|
||||
|
||||
list = []
|
||||
list.append(vol1._get_Name())
|
||||
list.append(vol2._get_Name())
|
||||
list.append(vol3._get_Name())
|
||||
list.append(vol4._get_Name())
|
||||
|
||||
volComp = geompy.MakeCompound(list)
|
||||
|
||||
tol3d = 1.e-3
|
||||
vol = geom.MakeGlueFaces(volComp,tol3d)
|
||||
idVol = geompy.addToStudy(vol,"volume")
|
||||
|
||||
print "Analysis of the final volume:"
|
||||
subShellList=geompy.SubShapeAllSorted(vol,ShapeTypeShell)
|
||||
subFaceList=geompy.SubShapeAllSorted(vol,ShapeTypeFace)
|
||||
subEdgeList=geompy.SubShapeAllSorted(vol,ShapeTypeEdge)
|
||||
|
||||
print "number of Shells in the volume : ",len(subShellList)
|
||||
print "number of Faces in the volume : ",len(subFaceList)
|
||||
print "number of Edges in the volume : ",len(subEdgeList)
|
||||
|
||||
idSubEdge = []
|
||||
for k in range(len(subEdgeList)):
|
||||
idSubEdge.append(geompy.addToStudyInFather(vol,subEdgeList[k],"SubEdge"+str(k)))
|
||||
|
||||
edgeZ = []
|
||||
edgeZ.append(subEdgeList[0])
|
||||
edgeZ.append(subEdgeList[3])
|
||||
edgeZ.append(subEdgeList[10])
|
||||
edgeZ.append(subEdgeList[11])
|
||||
edgeZ.append(subEdgeList[20])
|
||||
edgeZ.append(subEdgeList[21])
|
||||
edgeZ.append(subEdgeList[28])
|
||||
edgeZ.append(subEdgeList[31])
|
||||
|
||||
idEdgeZ = []
|
||||
for i in range(8):
|
||||
idEdgeZ.append(geompy.addToStudyInFather(vol,edgeZ[i],"EdgeZ"+str(i+1)))
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
gen=smeshpy.smeshpy()
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- NumberOfSegments the global one"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
hypNbSegID = hypNbSeg.GetId()
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
|
||||
smeshgui.SetName(idseg, "NumberOfSegments")
|
||||
|
||||
print "-------------------------- NumberOfSegments in the Z direction"
|
||||
|
||||
numberOfSegmentsZ = 40
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegZ=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
|
||||
hypNbSegZID = hypNbSegZ.GetId()
|
||||
print hypNbSegZ.GetName()
|
||||
print hypNbSegZID
|
||||
print hypNbSegZ.GetNumberOfSegments()
|
||||
|
||||
idsegZ = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSegZ) )
|
||||
smeshgui.SetName(idsegZ, "NumberOfSegmentsZ")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Regular_1D")
|
||||
regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
|
||||
regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
|
||||
smeshgui.SetName(regularID, "Wire Discretisation")
|
||||
|
||||
print "-------------------------- Quadrangle_2D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Quadrangle_2D")
|
||||
quad2D = hypothesis._narrow(SMESH.SMESH_Quadrangle_2D)
|
||||
quadID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(quad2D) )
|
||||
smeshgui.SetName(quadID, "Quadrangle_2D")
|
||||
|
||||
print "-------------------------- Hexa_3D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Hexa_3D")
|
||||
hexa3D = hypothesis._narrow(SMESH.SMESH_Hexa_3D)
|
||||
hexaID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(hexa3D) )
|
||||
smeshgui.SetName(hexaID, "Hexa_3D")
|
||||
|
||||
# ---- init a Mesh with the volume
|
||||
|
||||
mesh=gen.Init(idVol)
|
||||
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
|
||||
smeshgui.SetName(idmesh, "meshVolume")
|
||||
smeshgui.SetShape(idVol, idmesh)
|
||||
|
||||
# ---- add hypothesis to the volume
|
||||
|
||||
print "-------------------------- add hypothesis to the volume"
|
||||
|
||||
ret=mesh.AddHypothesis(vol,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hypNbSeg)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,quad2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(vol,hexa3D)
|
||||
print ret
|
||||
|
||||
print "-------------------------- set algoritms"
|
||||
|
||||
smeshgui.SetAlgorithms( idmesh, regularID)
|
||||
smeshgui.SetHypothesis( idmesh, idseg )
|
||||
smeshgui.SetAlgorithms( idmesh, quadID )
|
||||
smeshgui.SetAlgorithms( idmesh, hexaID )
|
||||
|
||||
for i in range(8):
|
||||
print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
|
||||
|
||||
subMeshEdgeZ = mesh.GetElementsOnShape(edgeZ[i])
|
||||
|
||||
retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
|
||||
print " add hyp Z ", retZ
|
||||
|
||||
idsmZ = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idEdgeZ[i],salome.orb.object_to_string(subMeshEdgeZ),
|
||||
ShapeTypeEdge)
|
||||
|
||||
smeshgui.SetName(idsmZ, "SubMeshEdgeZ_"+str(i+1))
|
||||
|
||||
smeshgui.SetHypothesis(idsmZ, idsegZ)
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the volume"
|
||||
ret=gen.Compute(mesh,idVol)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
else:
|
||||
print "problem when Computing the mesh"
|
||||
|
||||
sg.updateObjBrowser(1)
|
176
src/SMESH_SWIG/SMESH_demo_tetra.py
Normal file
176
src/SMESH_SWIG/SMESH_demo_tetra.py
Normal file
@ -0,0 +1,176 @@
|
||||
#
|
||||
# Tetrahedrization of a geometry (box minus a inner cylinder).
|
||||
# Hypothesis and algorithms for the mesh generation are global
|
||||
#
|
||||
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
|
||||
import SMESH
|
||||
import smeshpy
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
geom = geompy.geom
|
||||
myBuilder = geompy.myBuilder
|
||||
|
||||
ShapeTypeShell = 3
|
||||
ShapeTypeFace = 4
|
||||
ShapeTypeEdge = 6
|
||||
|
||||
# ---- define a boxe and a cylinder
|
||||
x0 = -1.
|
||||
y0 = -1.
|
||||
z0 = -1.
|
||||
|
||||
x1 = 1.
|
||||
y1 = 1.
|
||||
z1 = 1.
|
||||
|
||||
P0 = geom.MakePointStruct(0.,-1.,0.)
|
||||
P1 = geom.MakePointStruct(0.,1.,0.)
|
||||
Vect = geom.MakeDirection(P1)
|
||||
radius = 0.5
|
||||
height = 2.
|
||||
|
||||
boxe = geompy.MakeBox(x0,y0,z0,x1,y1,z1)
|
||||
|
||||
cylinder = geompy.MakeCylinder(P0,Vect,radius,height)
|
||||
|
||||
shape = geompy.MakeBoolean(boxe,cylinder,2)
|
||||
idshape = geompy.addToStudy(shape,"shape")
|
||||
|
||||
print ""
|
||||
|
||||
print "Analysis of the shape :"
|
||||
subShellList=geompy.SubShapeAll(shape,ShapeTypeShell)
|
||||
subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace)
|
||||
subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge)
|
||||
|
||||
print "number of Shells in the shape : ",len(subShellList)
|
||||
print "number of Faces in the shape : ",len(subFaceList)
|
||||
print "number of Edges in the shape : ",len(subEdgeList)
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
gen=smeshpy.smeshpy()
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- NumberOfSegments"
|
||||
|
||||
numberOfSegments = 10
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSeg=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSeg.SetNumberOfSegments(numberOfSegments)
|
||||
hypNbSegID = hypNbSeg.GetId()
|
||||
print hypNbSeg.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSeg.GetNumberOfSegments()
|
||||
|
||||
idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg) )
|
||||
smeshgui.SetName(idseg, "NumberOfSegments")
|
||||
|
||||
print "-------------------------- LengthFromEdges"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("LengthFromEdges")
|
||||
hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
|
||||
hypLengthFromEdgeID = hypLengthFromEdge.GetId()
|
||||
print hypLengthFromEdge.GetName()
|
||||
print hypLengthFromEdgeID
|
||||
|
||||
idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
|
||||
smeshgui.SetName(idlenfromedge, "LengthFromEdge")
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 0.5
|
||||
|
||||
hypothesis=gen.CreateHypothesis("MaxElementVolume")
|
||||
hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
|
||||
idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
|
||||
smeshgui.SetName(idvolume, "MaxElementVolume")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Regular_1D")
|
||||
regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
|
||||
regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
|
||||
smeshgui.SetName(regularID, "Wire Discretisation")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("MEFISTO_2D")
|
||||
mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
|
||||
mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
|
||||
smeshgui.SetName(mefistoID, "MEFISTO_2D")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NETGEN_3D")
|
||||
netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
|
||||
netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
|
||||
smeshgui.SetName(netgenID, "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
mesh=gen.Init(idshape)
|
||||
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
|
||||
smeshgui.SetName(idmesh, "MeshShape")
|
||||
smeshgui.SetShape(idshape, idmesh)
|
||||
|
||||
# ---- add hypothesis to flight
|
||||
|
||||
print "-------------------------- add hypothesis to the shape"
|
||||
|
||||
ret=mesh.AddHypothesis(shape,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypNbSeg)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,mefisto2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,netgen3D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypVolume)
|
||||
print ret
|
||||
|
||||
smeshgui.SetAlgorithms( idmesh, regularID)
|
||||
smeshgui.SetHypothesis( idmesh, idseg )
|
||||
smeshgui.SetAlgorithms( idmesh, mefistoID )
|
||||
smeshgui.SetHypothesis( idmesh, idlenfromedge)
|
||||
smeshgui.SetAlgorithms( idmesh, netgenID )
|
||||
smeshgui.SetHypothesis( idmesh, idvolume )
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
|
||||
print "-------------------------- compute the mesh of the shape"
|
||||
ret=gen.Compute(mesh,idshape)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
else:
|
||||
print "probleme when computing the mesh"
|
||||
|
||||
sg.updateObjBrowser(1)
|
243
src/SMESH_SWIG/SMESH_demo_tetra2.py
Normal file
243
src/SMESH_SWIG/SMESH_demo_tetra2.py
Normal file
@ -0,0 +1,243 @@
|
||||
#
|
||||
# Tetrahedrization of a geometry (box minus a inner cylinder).
|
||||
# Hypothesis and algorithms for the mesh generation are not
|
||||
# global: the mesh of some edges is thinner.
|
||||
#
|
||||
|
||||
import salome
|
||||
from salome import sg
|
||||
|
||||
import geompy
|
||||
|
||||
import SMESH
|
||||
import smeshpy
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
geom = geompy.geom
|
||||
myBuilder = geompy.myBuilder
|
||||
|
||||
ShapeTypeShell = 3
|
||||
ShapeTypeFace = 4
|
||||
ShapeTypeEdge = 6
|
||||
|
||||
# ---- define a boxe and a cylinder
|
||||
x0 = -1.
|
||||
y0 = -1.
|
||||
z0 = -1.
|
||||
|
||||
x1 = 1.
|
||||
y1 = 1.
|
||||
z1 = 1.
|
||||
|
||||
P0 = geom.MakePointStruct(0.,-1.,0.)
|
||||
P1 = geom.MakePointStruct(0.,1.,0.)
|
||||
Vect = geom.MakeDirection(P1)
|
||||
radius = 0.5
|
||||
height = 2.
|
||||
|
||||
boxe = geompy.MakeBox(x0,y0,z0,x1,y1,z1)
|
||||
|
||||
cylinder = geompy.MakeCylinder(P0,Vect,radius,height)
|
||||
|
||||
shape = geompy.MakeBoolean(boxe,cylinder,2)
|
||||
idshape = geompy.addToStudy(shape,"shape")
|
||||
|
||||
print "Analysis of the shape :"
|
||||
subShellList=geompy.SubShapeAllSorted(shape,ShapeTypeShell)
|
||||
subFaceList=geompy.SubShapeAllSorted(shape,ShapeTypeFace)
|
||||
subEdgeList=geompy.SubShapeAllSorted(shape,ShapeTypeEdge)
|
||||
|
||||
print "number of Shells in the shape : ",len(subShellList)
|
||||
print "number of Faces in the shape : ",len(subFaceList)
|
||||
print "number of Edges in the shape : ",len(subEdgeList)
|
||||
|
||||
idSubEdge = []
|
||||
for k in range(len(subEdgeList)):
|
||||
idSubEdge.append(geompy.addToStudyInFather(shape,subEdgeList[k],"SubEdge"+str(k)))
|
||||
|
||||
circle1 = subEdgeList[5]
|
||||
idCircle1 = geompy.addToStudyInFather(shape,circle1,"circle1")
|
||||
|
||||
circle2 = subEdgeList[9]
|
||||
idCircle2 = geompy.addToStudyInFather(shape,circle2,"circle2")
|
||||
|
||||
height = subEdgeList[7]
|
||||
idHeight = geompy.addToStudyInFather(shape,height,"height")
|
||||
|
||||
# ---- launch SMESH
|
||||
|
||||
smeshgui = salome.ImportComponentGUI("SMESH")
|
||||
smeshgui.Init(salome.myStudyId)
|
||||
|
||||
gen=smeshpy.smeshpy()
|
||||
|
||||
# ---- create Hypothesis
|
||||
|
||||
print "-------------------------- create Hypothesis"
|
||||
|
||||
print "-------------------------- NumberOfSegments Edge of the boxe"
|
||||
|
||||
numberOfSegmentsBoxe = 10
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegBoxe=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegBoxe.SetNumberOfSegments(numberOfSegmentsBoxe)
|
||||
hypNbSegID = hypNbSegBoxe.GetId()
|
||||
print hypNbSegBoxe.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSegBoxe.GetNumberOfSegments()
|
||||
|
||||
idSegBoxe = smeshgui.AddNewHypothesis(salome.orb.object_to_string(hypNbSegBoxe))
|
||||
smeshgui.SetName(idSegBoxe, "NumberOfSegmentsBoxe")
|
||||
|
||||
print "-------------------------- NumberOfSegments Edge of the cylinder"
|
||||
|
||||
numberOfSegmentsCylinder = 40
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NumberOfSegments")
|
||||
hypNbSegCylinder=hypothesis._narrow(SMESH.SMESH_NumberOfSegments)
|
||||
hypNbSegCylinder.SetNumberOfSegments(numberOfSegmentsCylinder)
|
||||
hypNbSegID = hypNbSegCylinder.GetId()
|
||||
print hypNbSegCylinder.GetName()
|
||||
print hypNbSegID
|
||||
print hypNbSegCylinder.GetNumberOfSegments()
|
||||
|
||||
idSegCylinder = smeshgui.AddNewHypothesis(salome.orb.object_to_string(hypNbSegCylinder))
|
||||
smeshgui.SetName(idSegCylinder, "NumberOfSegmentsCylinder")
|
||||
|
||||
print "-------------------------- LengthFromEdges"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("LengthFromEdges")
|
||||
hypLengthFromEdge=hypothesis._narrow(SMESH.SMESH_LengthFromEdges)
|
||||
hypLengthFromEdgeID = hypLengthFromEdge.GetId()
|
||||
print hypLengthFromEdge.GetName()
|
||||
print hypLengthFromEdgeID
|
||||
|
||||
idlenfromedge = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLengthFromEdge) )
|
||||
smeshgui.SetName(idlenfromedge, "LengthFromEdge")
|
||||
|
||||
print "-------------------------- MaxElementVolume"
|
||||
|
||||
maxElementVolume = 0.5
|
||||
|
||||
hypothesis=gen.CreateHypothesis("MaxElementVolume")
|
||||
hypVolume=hypothesis._narrow(SMESH.SMESH_MaxElementVolume)
|
||||
hypVolume.SetMaxElementVolume(maxElementVolume)
|
||||
print hypVolume.GetName()
|
||||
print hypVolume.GetId()
|
||||
print hypVolume.GetMaxElementVolume()
|
||||
|
||||
idvolume = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypVolume) )
|
||||
smeshgui.SetName(idvolume, "MaxElementVolume")
|
||||
|
||||
# ---- create Algorithms
|
||||
|
||||
print "-------------------------- create Algorithms"
|
||||
|
||||
print "-------------------------- Regular_1D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("Regular_1D")
|
||||
regular1D = hypothesis._narrow(SMESH.SMESH_Regular_1D)
|
||||
regularID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(regular1D) )
|
||||
smeshgui.SetName(regularID, "Wire Discretisation")
|
||||
|
||||
print "-------------------------- MEFISTO_2D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("MEFISTO_2D")
|
||||
mefisto2D = hypothesis._narrow(SMESH.SMESH_MEFISTO_2D)
|
||||
mefistoID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(mefisto2D) )
|
||||
smeshgui.SetName(mefistoID, "MEFISTO_2D")
|
||||
|
||||
print "-------------------------- NETGEN_3D"
|
||||
|
||||
hypothesis=gen.CreateHypothesis("NETGEN_3D")
|
||||
netgen3D = hypothesis._narrow(SMESH.SMESH_NETGEN_3D)
|
||||
netgenID = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(netgen3D) )
|
||||
smeshgui.SetName(netgenID, "NETGEN_3D")
|
||||
|
||||
# ---- init a Mesh with the shell
|
||||
|
||||
mesh=gen.Init(idshape)
|
||||
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
|
||||
smeshgui.SetName(idmesh, "MeshShape")
|
||||
smeshgui.SetShape(idshape, idmesh)
|
||||
|
||||
# ---- add hypothesis to flight
|
||||
|
||||
print "-------------------------- add hypothesis to the shape"
|
||||
|
||||
ret=mesh.AddHypothesis(shape,regular1D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypNbSegBoxe)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,mefisto2D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypLengthFromEdge)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,netgen3D)
|
||||
print ret
|
||||
ret=mesh.AddHypothesis(shape,hypVolume)
|
||||
print ret
|
||||
|
||||
print "-------------------------- set algoritms"
|
||||
|
||||
smeshgui.SetAlgorithms( idmesh, regularID)
|
||||
smeshgui.SetHypothesis( idmesh, idSegBoxe )
|
||||
smeshgui.SetAlgorithms( idmesh, mefistoID )
|
||||
smeshgui.SetHypothesis( idmesh, idlenfromedge)
|
||||
smeshgui.SetAlgorithms( idmesh, netgenID )
|
||||
smeshgui.SetHypothesis( idmesh, idvolume )
|
||||
|
||||
print "-------------------------- add hypothesis to the first circle"
|
||||
|
||||
subMeshEdgeCircle1 = mesh.GetElementsOnShape(circle1)
|
||||
retCircle1 = mesh.AddHypothesis(circle1,hypNbSegCylinder)
|
||||
print " add hyp to C1 ", retCircle1
|
||||
|
||||
idsmCircle1 = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idCircle1,salome.orb.object_to_string(subMeshEdgeCircle1),
|
||||
ShapeTypeEdge)
|
||||
|
||||
smeshgui.SetName(idsmCircle1, "SubMeshEdgeCircle1")
|
||||
smeshgui.SetHypothesis(idsmCircle1, idSegCylinder)
|
||||
|
||||
print "-------------------------- add hypothesis to the second circle"
|
||||
|
||||
subMeshEdgeCircle2 = mesh.GetElementsOnShape(circle2)
|
||||
retCircle2 = mesh.AddHypothesis(circle2,hypNbSegCylinder)
|
||||
print " add hyp to C2 ", retCircle2
|
||||
|
||||
idsmCircle2 = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idCircle2,salome.orb.object_to_string(subMeshEdgeCircle2),
|
||||
ShapeTypeEdge)
|
||||
|
||||
smeshgui.SetName(idsmCircle2, "SubMeshEdgeCircle2")
|
||||
smeshgui.SetHypothesis(idsmCircle2, idSegCylinder)
|
||||
|
||||
print "-------------------------- add hypothesis to the height of the cylinder"
|
||||
|
||||
subMeshEdgeHeight = mesh.GetElementsOnShape(height)
|
||||
retHeight = mesh.AddHypothesis(height,hypNbSegCylinder)
|
||||
print " add hyp to H ", retHeight
|
||||
|
||||
idsmHeight = smeshgui.AddSubMeshOnShape(
|
||||
idmesh,idHeight,salome.orb.object_to_string(subMeshEdgeHeight),
|
||||
ShapeTypeEdge)
|
||||
|
||||
smeshgui.SetName(idsmHeight, "SubMeshEdgeHeight")
|
||||
smeshgui.SetHypothesis(idsmHeight, idSegCylinder)
|
||||
|
||||
sg.updateObjBrowser(1)
|
||||
|
||||
print "-------------------------- compute the mesh of the shape"
|
||||
ret=gen.Compute(mesh,idshape)
|
||||
print ret
|
||||
if ret != 0:
|
||||
log=mesh.GetLog(0) # no erase trace
|
||||
for linelog in log:
|
||||
print linelog
|
||||
else:
|
||||
print "probleme when computing the mesh"
|
||||
|
||||
sg.updateObjBrowser(1)
|
Loading…
Reference in New Issue
Block a user