PR: examples adaptation to geomBuilder

This commit is contained in:
prascle 2013-03-15 10:57:18 +00:00
parent 96551e154e
commit f9343acc3c
18 changed files with 161 additions and 1440 deletions

View File

@ -22,8 +22,14 @@
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
#-----------------------------GEOM----------------------------------------
@ -55,7 +61,6 @@ Id_face1 = geompy.addToStudy(face1,"Face1")
#-----------------------------SMESH-------------------------------------------
smesh.SetCurrentStudy(salome.myStudy)
# -- Init mesh --
plane_mesh = salome.IDToObject( Id_face1)

View File

@ -26,8 +26,14 @@
# Description : Create meshes to test extrusion of mesh elements along path
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
#----------------------------------GEOM
@ -53,7 +59,6 @@ id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2")
#---------------------------------SMESH
smesh.SetCurrentStudy(salome.myStudy)
# create the path mesh
mesh1 = smesh.Mesh(ellipse1, "Path Mesh")

View File

@ -26,8 +26,14 @@
# Description : Create meshes to test extrusion of mesh elements along path
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# create points to build two circles
@ -51,8 +57,6 @@ idcircle = geompy.addToStudy(circle, "Circle")
idface = geompy.addToStudy(face, "Circular face")
smesh.SetCurrentStudy(salome.myStudy)
# init a Mesh with the circular face
mesh1 = smesh.Mesh(face, "Mesh on circular face")

View File

@ -22,10 +22,16 @@
#
import salome
import smesh
import math
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
def GetNewNodes(mesh,Elems,OldNodes):
"""
@ -55,7 +61,6 @@ def GetNewNodes(mesh,Elems,OldNodes):
pass
return newnodes
smesh.SetCurrentStudy(salome.myStudy)
# create empty mesh
mesh = smesh.Mesh()
@ -67,13 +72,13 @@ tol = 0.001
n1 = mesh.AddNode(55,-5,0)
n2 = mesh.AddNode(55,5,0)
e1 = mesh.AddEdge([n1,n2])
dir1 = smesh.DirStruct(smesh.PointStruct(-10,0,0))
dir1 = SMESH.DirStruct(SMESH.PointStruct(-10,0,0))
mesh.ExtrusionSweep([e1],dir1,11)
# 2. create second edge and make extrusion along 0y
n3 = mesh.AddNode(-5,-55,0)
n4 = mesh.AddNode(5,-55,0)
e2 = mesh.AddEdge([n3,n4])
dir2 = smesh.DirStruct(smesh.PointStruct(0,10,0))
dir2 = SMESH.DirStruct(SMESH.PointStruct(0,10,0))
mesh.ExtrusionSweep([e2],dir2,11)
# since result has coincident nodes and faces
@ -83,12 +88,12 @@ mesh.MergeNodes(nodes)
mesh.MergeEqualElements()
# make extrusion faces along 0z
faces = mesh.GetElementsByType(smesh.FACE)
faces = mesh.GetElementsByType(SMESH.FACE)
nbf = len(faces)
maxang = 2.0
zstep = 5
nbzsteps = 50
dir3 = smesh.DirStruct(smesh.PointStruct(0,0,zstep))
dir3 = SMESH.DirStruct(SMESH.PointStruct(0,0,zstep))
newfaces = [] # list for keeping created top faces
# during extrusion
@ -121,7 +126,7 @@ for i in range(0,nbzsteps):
pass
# rotate faces from newfaces
axisr1 = smesh.AxisStruct(0,0,0,0,0,1)
axisr1 = SMESH.AxisStruct(0,0,0,0,0,1)
for i in range(0,nbzsteps):
ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps))
mesh.Rotate(newfaces[i],axisr1,ang,0)
@ -135,7 +140,7 @@ n6 = mesh.AddNode(67.5,0,0)
n7 = mesh.AddNode(70,0,0)
e56 = mesh.AddEdge([n5,n6])
e67 = mesh.AddEdge([n6,n7])
axisr2 = smesh.AxisStruct(65,0,0,0,1,0)
axisr2 = SMESH.AxisStruct(65,0,0,0,1,0)
mesh.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
res = mesh.GetLastCreatedElems()
faces1 = []
@ -152,7 +157,7 @@ n9 = mesh.AddNode(-67.5,0,0)
n10 = mesh.AddNode(-70,0,0)
e8 = mesh.AddEdge([n8,n9])
e9 = mesh.AddEdge([n9,n10])
axisr3 = smesh.AxisStruct(-65,0,0,0,-1,0)
axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0)
mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
res = mesh.GetLastCreatedElems()
faces2 = []
@ -212,4 +217,4 @@ for i in range(0,nbrs):
oldnodes = newnodes
pass
smesh.salome.sg.updateObjBrowser(1)
salome.sg.updateObjBrowser(1)

View File

@ -25,7 +25,6 @@ from SMESH_test1 import *
## Old style
def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType):
import geompy
if theShape != theSubShape:
aName = str(theSubShape)
geompy.addToStudyInFather(theShape,theSubShape,aName)
@ -45,25 +44,23 @@ def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theEl
## Current style
def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType):
import geompy
import smesh
if theShape != theSubShape:
aName = str(theSubShape)
geompy.addToStudyInFather(theShape,theSubShape,aName)
theMesh.Compute()
aFilter = smesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape)
aFilter = smesh.GetFilter(theElemType, SMESH.FT_BelongToGeom, theSubShape)
return aFilter.GetElementsId(theMesh.GetMesh())
anElemType = smesh.FACE;
anElemType = SMESH.FACE;
print "anElemType =", anElemType
#anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType)
anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType)
print "Number of ids = ", len(anIds)
print "anIds = ", anIds
## Check old version
#anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType)
#anIds = CheckBelongToGeomFilterOld(smesh,mesh.GetMesh(),box,box,anElemType)
#print "anIds = ", anIds
salome.sg.updateObjBrowser(1);

View File

@ -28,8 +28,14 @@
# ! documentation generation to identify certain places of this file
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
## create a bottom box
Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
@ -60,7 +66,6 @@ geompy.addToStudy(Box_sup, "Box_sup")
geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
smesh.SetCurrentStudy(salome.myStudy)
## create a bottom mesh
Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
@ -91,10 +96,10 @@ Ginf2=Mesh_sup.Group(Finf2, "Inf")
## create compounds
# create a compound of two meshes with renaming groups with the same names and
# merging of elements with the given tolerance
Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
# create a compound of two meshes with uniting groups with the same names and
# creating groups of all elements
Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')
#end

View File

@ -50,11 +50,11 @@ geompy.AddObject(aGeomGroup2, 10)
geompy.addToStudy(aGeomGroup1, "Group on Faces")
geompy.addToStudy(aGeomGroup2, "Group on Edges")
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE)
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE)
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE)
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE)
print "Create aGroupOnShell - a group linked to a shell"
aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", smesh.EDGE)
aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", SMESH.EDGE)
print "aGroupOnShell type =", aGroupOnShell.GetType()
print "aGroupOnShell size =", aGroupOnShell.Size()
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()

View File

@ -21,13 +21,8 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
import salome
import smesh
smesh.SetCurrentStudy(salome.myStudy)
def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
aFilterMgr = smesh.smesh.CreateFilterManager()
aFilterMgr = smesh.CreateFilterManager()
aFilter = aFilterMgr.CreateFilter()
aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
@ -47,9 +42,9 @@ from SMESH_test1 import *
mesh.Compute()
# First way
BuildGroupLyingOn(mesh.GetMesh(), smesh.FACE, "Group of faces lying on edge #1", edge )
BuildGroupLyingOn(mesh.GetMesh(), SMESH.FACE, "Group of faces lying on edge #1", edge )
# Second way
mesh.MakeGroup("Group of faces lying on edge #2", smesh.FACE, smesh.FT_LyingOnGeom, edge)
mesh.MakeGroup("Group of faces lying on edge #2", SMESH.FACE, SMESH.FT_LyingOnGeom, edge)
salome.sg.updateObjBrowser(1);

View File

@ -26,9 +26,16 @@
#Auhtor :MASLOV Eugeny, KOVALTCHUK Alexey
#####################################################################
#
import geompy
import salome
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import os
import math
@ -98,8 +105,6 @@ Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
#Mesh creation
smesh.SetCurrentStudy(salome.myStudy)
# -- Init --
shape_mesh = salome.IDToObject( Cut_1_ID )
@ -117,7 +122,7 @@ smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength))
print "-------------------------- MaxElementArea"
theMaxElementArea = 20
algoMef = mesh.Triangle(smesh.MEFISTO)
algoMef = mesh.Triangle(smeshBuilder.MEFISTO)
hArea = algoMef.MaxElementArea( theMaxElementArea )
print hArea.GetName()
print hArea.GetId()
@ -126,7 +131,7 @@ smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea))
print "-------------------------- MaxElementVolume"
theMaxElementVolume = 150
algoNg = mesh.Tetrahedron(smesh.NETGEN)
algoNg = mesh.Tetrahedron(smeshBuilder.NETGEN)
hVolume = algoNg.MaxElementVolume( theMaxElementVolume )
print hVolume.GetName()
print hVolume.GetId()

View File

@ -26,8 +26,15 @@
# -- Rayon de la bariere
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
from math import sqrt
@ -119,8 +126,6 @@ print "number of Edges in alveole : ", len(subEdgeList)
status = geompy.CheckShape(alveole)
print " check status ", status
# ---- launch SMESH
smesh.SetCurrentStudy(salome.myStudy)
# ---- init a Mesh with the alveole
shape_mesh = salome.IDToObject( idalveole )
@ -155,7 +160,7 @@ print "-------------------------- MaxElementVolume"
maxElementVolume = 0.5
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
print hypVolume.GetName()
print hypVolume.GetId()

View File

@ -27,10 +27,17 @@
# Module : GEOM
# $Header:
#
from geompy import *
from math import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
# It is an example of creating a hexahedrical mesh on a sphere.
#
@ -42,20 +49,20 @@ import smesh
Radius = 100.
Dist = Radius / 2.
Factor = 2.5
Angle90 = pi / 2.
Angle90 = math.pi / 2.
NbSeg = 10
PointsList = []
ShapesList = []
#Basic Elements
P0 = MakeVertex(0., 0., 0.)
P1 = MakeVertex(-Dist, -Dist, -Dist)
P2 = MakeVertex(-Dist, -Dist, Dist)
P3 = MakeVertex(-Dist, Dist, Dist)
P4 = MakeVertex(-Dist, Dist, -Dist)
P0 = geompy.MakeVertex(0., 0., 0.)
P1 = geompy.MakeVertex(-Dist, -Dist, -Dist)
P2 = geompy.MakeVertex(-Dist, -Dist, Dist)
P3 = geompy.MakeVertex(-Dist, Dist, Dist)
P4 = geompy.MakeVertex(-Dist, Dist, -Dist)
VZ = MakeVectorDXDYDZ(0., 0., 1.)
VZ = geompy.MakeVectorDXDYDZ(0., 0., 1.)
#Construction Elements
PointsList.append(P1)
@ -64,47 +71,46 @@ PointsList.append(P3)
PointsList.append(P4)
PointsList.append(P1)
PolyLine = MakePolyline(PointsList)
PolyLine = geompy.MakePolyline(PointsList)
Face1 = MakeFace(PolyLine, 1)
Face2 = MakeScaleTransform(Face1, P0, Factor)
Face3 = MakeScaleTransform(Face1, P0, -1.)
Face1 = geompy.MakeFace(PolyLine, 1)
Face2 = geompy.MakeScaleTransform(Face1, P0, Factor)
Face3 = geompy.MakeScaleTransform(Face1, P0, -1.)
#Models
Sphere = MakeSphereR(Radius)
Sphere = geompy.MakeSphereR(Radius)
Block = MakeHexa2Faces(Face1, Face2)
Cube = MakeHexa2Faces(Face1, Face3)
Block = geompy.MakeHexa2Faces(Face1, Face2)
Cube = geompy.MakeHexa2Faces(Face1, Face3)
Common1 = MakeBoolean(Sphere, Block, 1)
Common2 = MakeRotation(Common1, VZ, Angle90)
Common1 = geompy.MakeBoolean(Sphere, Block, 1)
Common2 = geompy.MakeRotation(Common1, VZ, Angle90)
MultiBlock1 = MakeMultiTransformation1D(Common1, 20, -1, 3)
MultiBlock2 = MakeMultiTransformation1D(Common2, 30, -1, 3)
MultiBlock1 = geompy.MakeMultiTransformation1D(Common1, 20, -1, 3)
MultiBlock2 = geompy.MakeMultiTransformation1D(Common2, 30, -1, 3)
#Reconstruct sphere from several blocks
ShapesList.append(Cube)
ShapesList.append(MultiBlock1)
ShapesList.append(MultiBlock2)
Compound = MakeCompound(ShapesList)
Compound = geompy.MakeCompound(ShapesList)
Result = MakeGlueFaces(Compound, 0.1)
Result = geompy.MakeGlueFaces(Compound, 0.1)
#addToStudy
Id_Sphere = addToStudy(Sphere, "Sphere")
Id_Cube = addToStudy(Cube, "Cube")
Id_Sphere = geompy.addToStudy(Sphere, "Sphere")
Id_Cube = geompy.addToStudy(Cube, "Cube")
Id_Common1 = addToStudy(Common1, "Common1")
Id_Common2 = addToStudy(Common2, "Common2")
Id_Common1 = geompy.addToStudy(Common1, "Common1")
Id_Common2 = geompy.addToStudy(Common2, "Common2")
Id_MultiBlock1 = addToStudy(MultiBlock1, "MultiBlock1")
Id_MultiBlock2 = addToStudy(MultiBlock2, "MultiBlock2")
Id_MultiBlock1 = geompy.addToStudy(MultiBlock1, "MultiBlock1")
Id_MultiBlock2 = geompy.addToStudy(MultiBlock2, "MultiBlock2")
Id_Result = addToStudy(Result, "Result")
Id_Result = geompy.addToStudy(Result, "Result")
#-----------------------------------------------------------------------
#Meshing
smesh.SetCurrentStudy(salome.myStudy)
my_hexa = smesh.Mesh(Result, "Sphere_Mesh")
algo = my_hexa.Segment()
algo.NumberOfSegments(NbSeg)

View File

@ -28,17 +28,22 @@
# $Header$
#
import salome
import geompy
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
import smesh
import GEOM_Spanner
isBlocksTest = 0 # False
isMeshTest = 1 # True
smesh.SetCurrentStudy(salome.myStudy)
GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh)
salome.sg.updateObjBrowser(1);

View File

@ -31,16 +31,16 @@
# Salome geometry and meshing for a box
#
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
from salome import sg
import geompy
import smesh
# ---- launch GEOM
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
###geom.GetCurrentStudy(salome.myStudy._get_StudyId())
# Plate
@ -48,7 +48,6 @@ box = geompy.MakeBox(0.,0.,0.,1.,1.,1.)
boxId = geompy.addToStudy(box,"box")
# ---- SMESH
smesh.SetCurrentStudy(salome.myStudy)
# ---- init a Mesh

View File

@ -25,8 +25,14 @@
# Hypothesis and algorithms for the mesh generation are global
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# ---- define 2 boxes box1 and box2
@ -74,7 +80,6 @@ print "number of Edges in shell : ", len(subEdgeList)
### ---------------------------- SMESH --------------------------------------
smesh.SetCurrentStudy(salome.myStudy)
# ---- init a Mesh with the shell
@ -109,7 +114,7 @@ print "-------------------------- MaxElementVolume"
maxElementVolume = 500
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
print hypVolume.GetName()
print hypVolume.GetId()

View File

@ -26,9 +26,14 @@
# Hypothesis and algorithms for the mesh generation are global
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# ---- define 3 boxes box1, box2 and box3
@ -85,7 +90,6 @@ print "number of Edges in shell : ", len(subEdgeList)
### ---------------------------- SMESH --------------------------------------
smesh.SetCurrentStudy(salome.myStudy)
# ---- init a Mesh with the shell
@ -120,7 +124,7 @@ print "-------------------------- MaxElementVolume"
maxElementVolume = 500
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
print hypVolume.GetName()
print hypVolume.GetId()

View File

@ -25,9 +25,14 @@
# the mesh generation are global
#
import salome
import geompy
import smesh
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# ---- define a boxe
@ -46,7 +51,6 @@ print "number of Edges in box : ", len(subEdgeList)
### ---------------------------- SMESH --------------------------------------
smesh.SetCurrentStudy(salome.myStudy)
# ---- init a Mesh with the boxe
@ -79,7 +83,7 @@ print "-------------------------- MaxElementVolume"
maxElementVolume = 500
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN)
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
print hypVolume.GetName()
print hypVolume.GetId()

View File

@ -66,8 +66,6 @@ idedge = geompy.addToStudyInFather(face, edge, name)
# ---- SMESH
smesh.SetCurrentStudy(salome.myStudy)
# ---- Init a Mesh with the box
mesh = smesh.Mesh(box, "Meshbox")

File diff suppressed because it is too large Load Diff