X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Fsalome%2Fgui%2FSMESH%2Fmodifying_meshes.htm;h=7338481cc7988230bddd341e78141dcff8d21d44;hb=529a4c0bfc7d5f67647141ed1ed03fe493f51802;hp=2bf6951c3cb4017f851c5744dad41af22fb91cdb;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258;p=modules%2Fsmesh.git diff --git a/doc/salome/gui/SMESH/modifying_meshes.htm b/doc/salome/gui/SMESH/modifying_meshes.htm index 2bf6951c3..7338481cc 100755 --- a/doc/salome/gui/SMESH/modifying_meshes.htm +++ b/doc/salome/gui/SMESH/modifying_meshes.htm @@ -12,15 +12,20 @@ LI.kadov-P { } --> - - + +

Modifying Meshes

Adding Nodes and Elements

+

# Attention! The scripts for Adding nodes + and Elements  have + been written using the old approach basing on direct usage of SMESH idl + interface.

+ +

# For the moment smesh package doesn't provide + methods to add nodes and elements.

+ +

# + In the next SALOME version the scripts will be updated to use only the + commands from smesh package.

+

Add Node

-

import SMESH

+

import + SMESH

-

import SMESH_mechanic

+

import SMESH_mechanic

-

 

+

 

-

smesh  = - SMESH_mechanic.smesh

+

mesh = SMESH_mechanic.mesh

-

mesh   = - SMESH_mechanic.mesh

+

aMeshEditor = mesh.GetMeshEditor()

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# add node

-

# add node

+

new_id = aMeshEditor.AddNode(50, + 10, 0)

+ +

print ""

+ +

if new_id == 0: + print "KO node addition."

+ +

else:           print + "New Node has been added with ID ", new_id

+ +

 

+ +

Add Edge

+ +

import + SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

mesh = SMESH_mechanic.mesh

-

aMeshEditor = mesh.GetMeshEditor()

+

aMeshEditor = mesh.GetMeshEditor()

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

print ""

-

    print - "Node addition is OK!"

+

 

+ +

# add node

-

else:

+

n1 = aMeshEditor.AddNode(50, + 10, 0)

-

    print +

if n1 == 0: print "KO node addition."

-

    

+

 

-

salome.sg.updateObjBrowser(1) -

+

# add edge

-

 

+

e1 = aMeshEditor.AddEdge([n1, + 38])

-

Add Edge

+

if e1 == 0: print + "KO edge addition."

+ +

else:       print + "New Edge has been added with ID ", e1

-

import SMESH

+

 

-

import SMESH_mechanic

+

Add Triangle

-

 

+

import + SMESH

-

smesh  = - SMESH_mechanic.smesh

+

import SMESH_mechanic

-

mesh   = - SMESH_mechanic.mesh

+

 

+ +

mesh = SMESH_mechanic.mesh

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

print ""

+ +

 

+ +

# add node

+ +

n1 = aMeshEditor.AddNode(50, + 10, 0)

+ +

if n1 == 0: print + "KO node addition."

+ +

 

+ +

# add triangle

+ +

t1 = aMeshEditor.AddFace([n1, + 38, 39])

+ +

if t1 == 0: print + "KO triangle addition."

+ +

else:       print + "New Triangle has been added with ID ", t1

+ +

Add Quadrangle

+ +

import SMESH

-

salome = SMESH_mechanic.salome

+

import SMESH_mechanic

+ +

 

+ +

mesh = SMESH_mechanic.mesh

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

print ""

 

# add node

-

aMeshEditor = mesh.GetMeshEditor()

+

n1 = aMeshEditor.AddNode(50, + 10, 0)

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

if n1 == 0: print + "KO node addition."

-

    print - "Node addition is OK!"

+

 

-

else:

+

n2 = aMeshEditor.AddNode(40, + 20, 0)

-

    print +

if n2 == 0: print "KO node addition."

-

 

+

 

-

# add edge

+

# add quadrangle

-

LastNodeId = mesh.NbNodes()

+

q1 = aMeshEditor.AddFace([n2, + n1, 38, 39])

-

if aMeshEditor.AddEdge([LastNodeId, - 38]) == 1:

+

if q1 == 0: print + "KO quadrangle addition."

-

    print - "Edge addition is OK!"

+

else: +       print + "New Quadrangle has been added with ID ", q1

-

else:

+

Add Tetrahedron

-

    print - "KO edge addition."

+

import SMESH

-

 

+

import SMESH_mechanic

-

salome.sg.updateObjBrowser(1) -

+

 

-

 

+

mesh = SMESH_mechanic.mesh

-

Add Triangle

+

aMeshEditor = mesh.GetMeshEditor()

-

import SMESH

+

print ""

-

import SMESH_mechanic

+

 

-

 

+

# add node

-

smesh  = - SMESH_mechanic.smesh

+

n1 = aMeshEditor.AddNode(50, + 10, 0)

-

mesh   = - SMESH_mechanic.mesh

+

if n1 == 0: print + "KO node addition."

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# add tetrahedron

-

# add node

+

t1 = aMeshEditor.AddVolume([n1, + 38, 39, 246])

-

aMeshEditor = mesh.GetMeshEditor()

+

if t1 == 0: print + "KO tetrahedron addition."

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

else: +       print + "New Tetrahedron has been added with ID ", t1

-

    print - "Node addition is OK!"

+

Add Hexahedron

-

else:

+

import + SMESH

-

    print - "KO node addition."

+

import SMESH_mechanic

-

 

+

 

-

LastNodeId = mesh.NbNodes()

+

mesh = SMESH_mechanic.mesh

-

 

+

aMeshEditor = mesh.GetMeshEditor()

+ +

print ""

-

# add triangle

+

 

-

if aMeshEditor.AddFace([LastNodeId, - 38, 39]) == 1:

+

# add nodes

-

    print - "Triangle addition is OK!"

+

nId1 = aMeshEditor.AddNode(50, + 10, 0)

-

else:

+

nId2 = aMeshEditor.AddNode(47, + 12, 0)

-

    print - "KO triangle addition."

+

nId3 = aMeshEditor.AddNode(50, + 10, 10)

+ +

nId4 = aMeshEditor.AddNode(47, + 12, 10)

+ +

 

+ +

if nId1 == 0 or + nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition."

+ +

 

+ +

# add hexahedron

+ +

vId = aMeshEditor.AddVolume([nId2, + nId1, 38, 39, nId4, nId3, 245, 246])

+ +

if vId == 0: print + "KO Hexahedron addition."

+ +

else:        print + "New Hexahedron has been added with ID ", vId

+ +

 

+ +

Add Polygon

+ +

import + math

+ +

import salome

+ +

import smesh

+ +

 

+ +

# create an empty mesh + structure

+ +

gen = smesh.smesh

+ +

mesh = gen.CreateEmptyMesh()

+ +

MeshEditor = mesh.GetMeshEditor()

+ +

 

+ +

# a method to build + a polygonal mesh element with <nb_vert> angles:

+ +

def MakePolygon + (a_mesh, x0, y0, z0, radius, nb_vert):

+ +

    al + = 2.0 * math.pi / nb_vert

+ +

    node_ids + = []

+ +

 

+ +

          # + Create nodes for a polygon

+ +

    for + ii in range(nb_vert):

+ +

        nid + = MeshEditor.AddNode(x0 + radius * math.cos(ii*al),

+ +

                                 y0 + + radius * math.sin(ii*al),

+ +

                                 z0)

+ +

        node_ids.append(nid)

+ +

        pass

+ +

 

-

    

+

          # + Create a polygon

-

salome.sg.updateObjBrowser(1) +

    return + MeshEditor.AddPolygonalFace(node_ids)

+ +

 

+ +

# Create three polygons

+ +

f1 = MakePolygon(mesh, + 0, 0,  0, + 30, 13)

+ +

f2 = MakePolygon(mesh, + 0, 0, 10, 21,  9)

+ +

f3 = MakePolygon(mesh, + 0, 0, 20, 13,  6)

+ +

 

+ +

salome.sg.updateObjBrowser(1)

-

 

+

Add Polyhedron

-

Add Quadrangle

+

import + salome

-

import SMESH

+

import math

-

import SMESH_mechanic

+

import smesh

-

 

+

 

-

smesh  = - SMESH_mechanic.smesh

+

# create an empty mesh + structure

-

mesh   = - SMESH_mechanic.mesh

+

gen = smesh.smesh

-

salome = SMESH_mechanic.salome

+

mesh = gen.CreateEmptyMesh()

-

 

+

MeshEditor = mesh.GetMeshEditor()

-

# add node

+

 

-

aMeshEditor = mesh.GetMeshEditor()

+

# Create nodes for + 12-hedron with pentagonal faces

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

al = 2 * math.pi + / 5.0

-

    print - "Node addition is OK!"

+

cosal = math.cos(al)

-

else:

+

aa = 13

-

    print - "KO node addition."

+

rr = aa / (2.0 * + math.sin(al/2.0))

-

 

+

dr = 2.0 * rr * + cosal

-

LastNodeId = mesh.NbNodes()

+

r1 = rr + dr

-

 

+

dh = rr * math.sqrt(2.0 + * (1.0 - cosal * (1.0 + 2.0 * cosal)))

-

# add quadrangle

+

hh = 2.0 * dh - + dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh

+ +

 

-

if aMeshEditor.AddNode(40, - 20, 0) == 1:

+

dd = [] # + top

-

    print - "Node addition is OK!"

+

cc = [] # + below top

-

else:

+

bb = [] # + above bottom

-

    print - "KO node addition."

+

aa = [] # + bottom

-

if aMeshEditor.AddFace([mesh.NbNodes(), - LastNodeId, 38, 39]) == 1:

+

 

-

    print - "Quadrangle addition is OK!"

+

for i in range(5):

-

else:

+

    cos_bot + = math.cos(i*al)

-

    print - "KO quadrangle addition."

+

    sin_bot + = math.sin(i*al)

-

 

+

 

+ +

    cos_top + = math.cos(i*al + al/2.0)

+ +

    sin_top + = math.sin(i*al + al/2.0)

+ +

 

+ +

    nd + = MeshEditor.AddNode(rr * cos_top, rr * sin_top, hh     ) + # top

+ +

    nc + = MeshEditor.AddNode(r1 * cos_top, r1 * sin_top, hh - dh) # + below top

-

salome.sg.updateObjBrowser(1) +

    nb + = MeshEditor.AddNode(r1 * cos_bot, r1 * sin_bot,      dh) + # above bottom

+ +

    na + = MeshEditor.AddNode(rr * cos_bot, rr * sin_bot,       0) + # bottom

+ +

    dd.append(nd) + # top

+ +

    cc.append(nc) + # below top

+ +

    bb.append(nb) + # above bottom

+ +

    aa.append(na) + # bottom

+ +

 

+ +

    pass

+ +

 

+ +

# Create a polyhedral + volume (12-hedron with pentagonal faces)

+ +

MeshEditor.AddPolyhedralVolume([dd[0], + dd[1], dd[2], dd[3], dd[4],  # + top

+ +

                                dd[0], + cc[0], bb[1], cc[1], dd[1],  # + -

+ +

                                dd[1], + cc[1], bb[2], cc[2], dd[2],  # + -

+ +

                                dd[2], + cc[2], bb[3], cc[3], dd[3],  # + - below top

+ +

                                dd[3], + cc[3], bb[4], cc[4], dd[4],  # + -

+ +

                                dd[4], + cc[4], bb[0], cc[0], dd[0],  # + -

+ +

                                aa[4], + bb[4], cc[4], bb[0], aa[0],  # + .

+ +

                                aa[3], + bb[3], cc[3], bb[4], aa[4],  # + .

+ +

                                aa[2], + bb[2], cc[2], bb[3], aa[3],  # + . above bottom

+ +

                                aa[1], + bb[1], cc[1], bb[2], aa[2],  # + .

+ +

                                aa[0], + bb[0], cc[0], bb[1], aa[1],  # + .

+ +

                                aa[0], + aa[1], aa[2], aa[3], aa[4]], # + bottom

+ +

                               [5,5,5,5,5,5,5,5,5,5,5,5])

+ +

salome.sg.updateObjBrowser(1)

-

 

+

 

-

Add Tetrahedron

+

Removing Nodes and Elements

-

import SMESH

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import SMESH_mechanic

+

# For the moment smesh package doesn't provide + methods to remove nodes and elements.

-

 

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

smesh  = - SMESH_mechanic.smesh

+

 

-

mesh   = - SMESH_mechanic.mesh

+

Removing Nodes

-

salome = SMESH_mechanic.salome

+

 

-

 

+

import + SMESH_mechanic

-

# add node

+

 

-

aMeshEditor = mesh.GetMeshEditor()

+

mesh = SMESH_mechanic.mesh

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

aMeshEditor = mesh.GetMeshEditor()

-

    print - "Node addition is OK!"

+

 

-

else:

+

# remove nodes #246 + and #255

-

    print - "KO node addition."

+

res = aMeshEditor.RemoveNodes([246, + 255])

-

 

+

if res == 1: print + "Nodes removing is OK!"

-

LastNodeId = mesh.NbNodes()

+

else:        print + "KO nodes removing."

 

-

# add tetrahedron

+

Removing Elements

+ +

import + SMESH_mechanic

-

if aMeshEditor.AddVolume([LastNodeId, - 38, 39, 246]) == 1:

+

mesh = SMESH_mechanic.mesh

-

    print - "Tetrahedron addition is OK!"

+

 

-

else:

+

anEditor = mesh.GetMeshEditor()

-

    print - "KO tetrahedron addition."

+

 

+ +

# remove three elements: + #850, #859 and #814

+ +

res = anEditor.RemoveElements([850, + 859, 814])

+ +

if res == 1: print + "Elements removing is OK!"

+ +

else:        print + "KO Elements removing."  

+ +

 

+ +

Renumbering Nodes and Elements

+ +

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

+ +

# For the moment smesh package doesn't provide + methods to renumber nodes and elements.

+ +

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

+ +

 

+ +

import SMESH_mechanic

+ +

 

-

    

+

mesh = SMESH_mechanic.mesh

-

salome.sg.updateObjBrowser(1) +

anEditor = mesh.GetMeshEditor()

+ +

 

+ +

anEditor.RenumberNodes()

+

Moving Nodes

+ +

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

+ +

# For the moment smesh package doesn't provide + methods to move nodes.

+ +

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

+ +

 

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

mesh = SMESH_mechanic.mesh

+ +

aMeshEditor = mesh.GetMeshEditor()

+

 

-

Add Hexahedron

+

# move node #38

-

import SMESH

+

aMeshEditor.MoveNode(38, + 20., 10., 0.)

-

import SMESH_mechanic

+

 

-

 

+

Diagonal Inversion

-

smesh  = - SMESH_mechanic.smesh

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

mesh   = - SMESH_mechanic.mesh

+

# For the moment smesh package doesn't provide + methods to produce a diagonal inversion.

-

salome = SMESH_mechanic.salome

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

 

+

 

-

# add nodes

+

import salome

-

aMeshEditor = mesh.GetMeshEditor()

+

import smesh

-

if aMeshEditor.AddNode(50, - 10, 0) == 1:

+

 

-

    print - "Node addition is OK!"

+

# create an empty mesh + structure

-

else:

+

gen = smesh.smesh

-

    print - "KO node addition."

+

mesh = gen.CreateEmptyMesh()

-

aNodeId1 = mesh.NbNodes()

+

aMeshEditor = mesh.GetMeshEditor()

-

 

+

 

-

if aMeshEditor.AddNode(47, - 12, 0) == 1:

+

# create the following + mesh:

-

    print - "Node addition is OK!"

+

# .----.----.----.

-

else:

+

# |   /| +   /| +   /|

-

    print - "KO node addition."

+

# |  / + |  / |  / + |

-

aNodeId2 = mesh.NbNodes()

+

# | /  | + /  | /  |

-

 

+

# |/   |/ +   |/ +   |

-

if aMeshEditor.AddNode(50, - 10, 10) == 1:

+

# .----.----.----.

-

    print - "Node addition is OK!"

+

 

-

else:

+

bb = [0, 0, 0, 0]

-

    print - "KO node addition."

+

tt = [0, 0, 0, 0]

-

aNodeId3 = mesh.NbNodes()

+

ff = [0, 0, 0, 0, + 0, 0]

-

 

+

 

-

if aMeshEditor.AddNode(47, - 12, 10) == 1:

+

bb[0] = aMeshEditor.AddNode( + 0., 0., 0.)

-

    print - "Node addition is OK!"

+

bb[1] = aMeshEditor.AddNode(10., + 0., 0.)

-

else:

+

bb[2] = aMeshEditor.AddNode(20., + 0., 0.)

-

    print - "KO node addition."

+

bb[3] = aMeshEditor.AddNode(30., + 0., 0.)

-

aNodeId4 = mesh.NbNodes()

+

 

-

 

+

tt[0] = aMeshEditor.AddNode( + 0., 15., 0.)

-

# add hexahedron

+

tt[1] = aMeshEditor.AddNode(10., + 15., 0.)

-

if aMeshEditor.AddVolume([aNodeId2, - aNodeId1, 38, 39, aNodeId4, aNodeId3, 245, 246]) == 1:

+

tt[2] = aMeshEditor.AddNode(20., + 15., 0.)

-

    print - "Hexahedron addition is OK!"

+

tt[3] = aMeshEditor.AddNode(30., + 15., 0.)

-

else:

+

 

-

    print - "KO Hexahedron addition."

+

ff[0] = aMeshEditor.AddFace([bb[0], + bb[1], tt[1]])

+ +

ff[1] = aMeshEditor.AddFace([bb[0], + tt[1], tt[0]])

+ +

ff[2] = aMeshEditor.AddFace([bb[1], + bb[2], tt[2]])

+ +

ff[3] = aMeshEditor.AddFace([bb[1], + tt[2], tt[1]])

+ +

ff[4] = aMeshEditor.AddFace([bb[2], + bb[3], tt[3]])

+ +

ff[5] = aMeshEditor.AddFace([bb[2], + tt[3], tt[2]])

+ +

 

+ +

# inverse the diagonal + bb[1] - tt[2]

+ +

print "\nDiagonal + inversion ... ",

+ +

res = aMeshEditor.InverseDiag(bb[1], + tt[2])

-

    

+

if not res: print + "failed!"

-

salome.sg.updateObjBrowser(1) +

else:       print + "done."

+ +

 

+ +

salome.sg.updateObjBrowser(1)

-

 

+

Uniting two Triangles

-

Add Polygon

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import salome

+

# For the moment smesh package doesn't provide + methods to unite two triangles.

-

import geompy

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

import math

+

 

-

 

+

import salome

-

import StdMeshers

+

import smesh

-

 

+

 

-

# GEOM module

+

# create an empty mesh structure

-

shape_mesh = geompy.MakeCylinderRH(13, - 77)

+

gen = smesh.smesh

-

geompy.addToStudy(shape_mesh, - "cylinder")

+

mesh = gen.CreateEmptyMesh()

-

 

+

aMeshEditor = mesh.GetMeshEditor()

-

# SMESH module

+

 

-

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")

+

# create the following mesh:

-

smesh.SetCurrentStudy(salome.myStudy)

+

# .----.----.----.

-

mesh = smesh.CreateMesh(shape_mesh)

+

# |   /| +   /| +   /|

-

MeshEditor = mesh.GetMeshEditor()

+

# |  / + |  / |  / + |

-

 

+

# | /  | + /  | /  |

-

# a method to build a polygonal - mesh element with nb_vert angles:

+

# |/   |/ +   |/ +   |

-

def MakePolygon - (a_mesh, x0, y0, z0, radius, nb_vert):

+

# .----.----.----.

-

    node_start_id - = a_mesh.NbNodes() + 1

+

 

-

    al - = 2.0 * math.pi / nb_vert

+

bb = [0, 0, 0, 0]

-

    node_ids - = []

+

tt = [0, 0, 0, 0]

-

    

+

ff = [0, 0, 0, 0, + 0, 0]

-

# Create nodes for a polyhedron

+

 

-

    for - ii in range(nb_vert):

+

bb[0] = aMeshEditor.AddNode( + 0., 0., 0.)

-

        MeshEditor.AddNode(x0 - + radius * math.cos(ii*al),

+

bb[1] = aMeshEditor.AddNode(10., + 0., 0.)

-

                           y0 - + radius * math.sin(ii*al),

+

bb[2] = aMeshEditor.AddNode(20., + 0., 0.)

-

                           z0)

+

bb[3] = aMeshEditor.AddNode(30., + 0., 0.)

-

        node_ids.append(node_start_id - + ii)

+

 

-

        pass

+

tt[0] = aMeshEditor.AddNode( + 0., 15., 0.)

-

    

+

tt[1] = aMeshEditor.AddNode(10., + 15., 0.)

-

# Create a polygon

+

tt[2] = aMeshEditor.AddNode(20., + 15., 0.)

-

    MeshEditor.AddPolygonalFace(node_ids)

+

tt[3] = aMeshEditor.AddNode(30., + 15., 0.)

-

    return - 0

+

 

-

 

+

ff[0] = aMeshEditor.AddFace([bb[0], + bb[1], tt[1]])

-

# Create three polygons

+

ff[1] = aMeshEditor.AddFace([bb[0], + tt[1], tt[0]])

-

MakePolygon(mesh, - 0, 0,  0, - 30, 13)

+

ff[2] = aMeshEditor.AddFace([bb[1], + bb[2], tt[2]])

-

MakePolygon(mesh, - 0, 0, 10, 21,  9)

+

ff[3] = aMeshEditor.AddFace([bb[1], + tt[2], tt[1]])

-

MakePolygon(mesh, - 0, 0, 20, 13,  6)

+

ff[4] = aMeshEditor.AddFace([bb[2], + bb[3], tt[3]])

-

 

+

ff[5] = aMeshEditor.AddFace([bb[2], + tt[3], tt[2]])

-

salome.sg.updateObjBrowser(1) -  

+

 

-

 

+

# delete the diagonal bb[1] - tt[2]

-

Add polyhedron

+

print "\nUnite + two triangles ... ",

-

import - salome

+

res = aMeshEditor.DeleteDiag(bb[1], + tt[2])

-

import geompy

+

if not res: print + "failed!"

-

import math

+

else:       print + "done."

-

 

+

 

-

#import SMESH

+

salome.sg.updateObjBrowser(1) +

-

import StdMeshers

+

Uniting a Set of Triangles

-

 

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

# GEOM

+

# For the moment smesh package doesn't provide + methods to unite a set of triangles.

-

shape_mesh = geompy.MakeCylinderRH(13, - 77)

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

geompy.addToStudy(shape_mesh, - "cylinder")

+

 

-

 

+

import salome

-

# SMESH

+

import smesh

-

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")

+

 

-

smesh.SetCurrentStudy(salome.myStudy)

+

# create an empty mesh + structure

-

mesh = smesh.CreateMesh(shape_mesh)

+

gen = smesh.smesh

-

MeshEditor = mesh.GetMeshEditor()

+

mesh = gen.CreateEmptyMesh()

-

 

+

aMeshEditor = mesh.GetMeshEditor()

-

# Now we are going - to create a 12-hedron:

+

 

-

 

+

# create the following + mesh:

-

# Create nodes for - polyhedron

+

# .----.----.----.

-

al = 2 * math.pi - / 5.0

+

# |   /| +   /| +   /|

-

cosal = math.cos(al)

+

# |  / + |  / |  / + |

-

 

+

# | /  | + /  | /  |

-

aa = 13

+

# |/   |/ +   |/ +   |

-

rr = aa / (2.0 * - math.sin(al/2.0))

+

# .----.----.----.

-

dr = 2.0 * rr * - cosal

+

 

-

r1 = rr + dr

+

bb = [0, 0, 0, 0]

-

dh = rr * math.sqrt(2.0 - * (1.0 - cosal * (1.0 + 2.0 * cosal)))

+

tt = [0, 0, 0, 0]

-

hh = 2.0 * dh - - dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh

+

ff = [0, 0, 0, 0, + 0, 0]

-

 

+

 

-

for i in range(5):

+

bb[0] = aMeshEditor.AddNode( + 0., 0., 0.)

-

    MeshEditor.AddNode(rr*math.cos(i*al), - rr*math.sin(i*al),  0) - # 1,3,5,7, 9 # bottom

+

bb[1] = aMeshEditor.AddNode(10., + 0., 0.)

-

    MeshEditor.AddNode(r1*math.cos(i*al), - r1*math.sin(i*al), dh) # - 2,4,6,8,10 # above bottom

+

bb[2] = aMeshEditor.AddNode(20., + 0., 0.)

-

 

+

bb[3] = aMeshEditor.AddNode(30., + 0., 0.)

-

for i in range(5):

+

 

-

    MeshEditor.AddNode(rr*math.cos(i*al - + al/2.0),

+

tt[0] = aMeshEditor.AddNode( + 0., 15., 0.)

-

                       rr*math.sin(i*al - + al/2.0), hh) # 11,13,15,17,19 # - top

+

tt[1] = aMeshEditor.AddNode(10., + 15., 0.)

-

    MeshEditor.AddNode(r1*math.cos(i*al - + al/2.0),

+

tt[2] = aMeshEditor.AddNode(20., + 15., 0.)

-

                       r1*math.sin(i*al - + al/2.0), hh - dh) # 12,14,16,18,20 # - below top

+

tt[3] = aMeshEditor.AddNode(30., + 15., 0.)

-

 

+

 

-

# Create a polyhedral - volume

+

ff[0] = aMeshEditor.AddFace([bb[0], + bb[1], tt[1]])

-

MeshEditor.AddPolyhedralVolume([ - 1,  3,  5, -  7,  9, -  # - bottom

+

ff[1] = aMeshEditor.AddFace([bb[0], + tt[1], tt[0]])

-

                                 1, -  2, 12, -  4,  3, -  # - .

- -

                                 3, -  4, 14, -  6,  5, -  # - .

- -

                                 5, -  6, 16, -  8,  7, -  # - . above bottom

+

ff[2] = aMeshEditor.AddFace([bb[1], + bb[2], tt[2]])

-

                                 7, -  8, 18, - 10,  9, -  # - .

- -

                                 9, - 10, 20,  2, -  1,  # - .

- -

                                11, - 12,  4, - 14, 13,  # - -

- -

                                13, - 14,  6, - 16, 15,  # - -

- -

                                15, - 16,  8, - 18, 17,  # - - below top

+

ff[3] = aMeshEditor.AddFace([bb[1], + tt[2], tt[1]])

-

                                17, - 18, 10, 20, 19,  # - -

+

ff[4] = aMeshEditor.AddFace([bb[2], + bb[3], tt[3]])

-

                                19, - 20,  2, - 12, 11,  # - -

+

ff[5] = aMeshEditor.AddFace([bb[2], + tt[3], tt[2]])

-

                                11, - 13, 15, 17, 19], # - top

+

 

-

                               [5,5,5,5,5,5,5,5,5,5,5,5])

+

# unite a set of triangles

-

 

+

aFilterMgr = smesh.smesh.CreateFilterManager()

-

salome.sg.updateObjBrowser(1) -  

+

aFunctor = aFilterMgr.CreateMinimumAngle()

-

 

+

print "\nUnite + a set of triangles ... ",

-

Removing Nodes and Elements

+

res = aMeshEditor.TriToQuad([ff[2], + ff[3], ff[4], ff[5]], aFunctor, 60.)

-

Removing Nodes

+

if not res: print + "failed!"

-

 

+

else:       print + "done."

-

import SMESH

+

 

-

import SMESH_mechanic

+

salome.sg.updateObjBrowser(1) +

-

 

+

Orientation

-

smesh  = - SMESH_mechanic.smesh

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

mesh   = - SMESH_mechanic.mesh

+

# For the moment smesh package doesn't provide + methods to change orientation.

-

salome = SMESH_mechanic.salome

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

 

+

 

-

# add node

+

import salome

-

aMeshEditor = mesh.GetMeshEditor()

+

import smesh

-

if aMeshEditor.RemoveNodes([246, - 255]) == 1:

+

 

-

    print - "Node removing is OK!"

+

# SMESH module

-

else:

+

gen = smesh.smesh

-

    print - "KO node removing."

+

mesh = gen.CreateEmptyMesh()

-

    

+

MeshEditor = mesh.GetMeshEditor()

-

salome.sg.updateObjBrowser(1) -

+

 

-

 

+

# build five quadrangles:

-

Removing Elements

+

dx = 10

-

import SMESH

+

dy = 20

-

import SMESH_mechanic

+

 

-

 

+

n1  = + MeshEditor.AddNode(0.0 * dx, 0, 0)

-

smesh  = - SMESH_mechanic.smesh

+

n2  = + MeshEditor.AddNode(1.0 * dx, 0, 0)

-

mesh   = - SMESH_mechanic.mesh

+

n3  = + MeshEditor.AddNode(2.0 * dx, 0, 0)

-

salome = SMESH_mechanic.salome

+

n4  = + MeshEditor.AddNode(3.0 * dx, 0, 0)

-

 

+

n5  = + MeshEditor.AddNode(4.0 * dx, 0, 0)

-

anEditor = mesh.GetMeshEditor()

+

n6  = + MeshEditor.AddNode(5.0 * dx, 0, 0)

-

anEditor.RemoveElements([850, - 859, 814])

+

n7  = + MeshEditor.AddNode(0.0 * dx, dy, 0)

-

 

+

n8  = + MeshEditor.AddNode(1.0 * dx, dy, 0)

-

salome.sg.updateObjBrowser(1) -

+

n9  = + MeshEditor.AddNode(2.0 * dx, dy, 0)

-

 

+

n10 = MeshEditor.AddNode(3.0 + * dx, dy, 0)

-

Renumbering Nodes and Elements

+

n11 = MeshEditor.AddNode(4.0 + * dx, dy, 0)

-

import SMESH

+

n12 = MeshEditor.AddNode(5.0 + * dx, dy, 0)

-

import SMESH_mechanic

+

 

-

 

+

f1 = MeshEditor.AddFace([n1, + n2, n8 , n7 ])

-

mesh   = - SMESH_mechanic.mesh

+

f2 = MeshEditor.AddFace([n2, + n3, n9 , n8 ])

+ +

f3 = MeshEditor.AddFace([n3, + n4, n10, n9 ])

-

salome = SMESH_mechanic.salome

+

f4 = MeshEditor.AddFace([n4, + n5, n11, n10])

-

 

+

f5 = MeshEditor.AddFace([n5, + n6, n12, n11])

-

anEditor = mesh.GetMeshEditor()

+

 

+ +

# Change the orientation + of the second and the fourth faces.

-

anEditor.RenumberNodes()

+

MeshEditor.Reorient([2, + 4])

-

 

+

 

-

salome.sg.updateObjBrowser(1) +

salome.sg.updateObjBrowser(1)

-

 

+

 

-

 

+

Cutting Quadrangles

-

Moving Nodes

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import SMESH

+

# For the moment smesh package doesn't provide + methods to cut quadrangles.

-

import SMESH_mechanic

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

 

+

 

+ +

import SMESH

+ +

import SMESH_mechanic

-

smesh  = - SMESH_mechanic.smesh

+

 

-

mesh   = +

smesh = SMESH_mechanic.smesh

+ +

mesh  = SMESH_mechanic.mesh

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# cut two quadrangles: + 405 and 406

-

# move node

+

aFilterMgr = smesh.CreateFilterManager()

-

aMeshEditor = mesh.GetMeshEditor()

+

aFunctor = aFilterMgr.CreateMinimumAngle()

-

aMeshEditor.MoveNode(38, - 20, 10, 0)

+

 

-

    

+

aMeshEditor = mesh.GetMeshEditor()

-

salome.sg.updateObjBrowser(1) -

+

aMeshEditor.QuadToTri([405, + 406], aFunctor)

-

 

+

 

-

Diagonal Inversion

+

Smoothing

-

import SMESH

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import SMESH_mechanic

+

# For the moment smesh package doesn't provide + methods to perform smoothing.

+ +

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

 

-

smesh  = - SMESH_mechanic.smesh

+

import salome

-

mesh   = - SMESH_mechanic.mesh

+

import geompy

-

salome = SMESH_mechanic.salome

+

 

-

 

+

import SMESH

-

# inverse diagonal

+

import SMESH_mechanic

-

aMeshEditor = mesh.GetMeshEditor()

+

 

-

aMeshEditor.InverseDiag(700, - 642)

+

mesh = SMESH_mechanic.mesh

-

    

+

aMeshEditor = mesh.GetMeshEditor()

-

salome.sg.updateObjBrowser(1) -

+

 

-

 

+

# select the top face

-

Uniting two Triangles

+

faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, + geompy.ShapeType["FACE"])

-

import SMESH

+

face = faces[3]

-

import SMESH_mechanic

+

geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, + face, "face planar with hole")

-

 

+

 

-

smesh  = - SMESH_mechanic.smesh

+

# create a group of faces + to be smoothed

-

mesh   = - SMESH_mechanic.mesh

+

GroupSmooth = mesh.CreateGroupFromGEOM(SMESH.FACE, + "Group of faces (smooth)", face)

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# perform smoothing

-

# delete diagonal

+

# boolean SmoothObject(Object, + IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)

-

aMeshEditor = mesh.GetMeshEditor()

+

res = aMeshEditor.SmoothObject(GroupSmooth, + [], 20, 2., SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH)

-

aMeshEditor.DeleteDiag(700, - 642)

+

 

-

    

+

print "\nSmoothing + ... ",

-

salome.sg.updateObjBrowser(1) +

if not res: print + "failed!"

+ +

else:       print + "done."

+ +

 

+ +

salome.sg.updateObjBrowser(1)

-

 

+

 

-

Uniting a Set of Triangles

+

Extrusion

-

import SMESH

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import SMESH_mechanic

+

# For the moment smesh package doesn't provide + methods to perform extrusion.

-

 

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

smesh  = - SMESH_mechanic.smesh

+

 

-

mesh   = - SMESH_mechanic.mesh

+

import salome

-

salome = SMESH_mechanic.salome

+

import geompy

-

 

+

 

-

# unite a set of triangles

+

import SMESH

-

aFilterMgr = smesh.CreateFilterManager()

+

import SMESH_mechanic

-

aFunctor = aFilterMgr.CreateMinimumAngle()

+

 

-

 

+

mesh = SMESH_mechanic.mesh

-

aMeshEditor = mesh.GetMeshEditor()

+

aMeshEditor = mesh.GetMeshEditor()

-

aMeshEditor.TriToQuad([1145, - 1147, 1159, 1135], aFunctor, 60)

+

 

-

    

+

# select the top face

-

salome.sg.updateObjBrowser(1) -

+

faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, + geompy.ShapeType["FACE"])

-

 

+

face = faces[7]

-

Orientation

+

geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, + face, "face circular top")

-

import - salome

+

 

-

import geompy

+

# create a vector for + extrusion

-

 

+

point = SMESH.PointStruct(0., + 0., 5.)

-

import StdMeshers

+

vector = SMESH.DirStruct(point)

-

 

+

 

-

# GEOM module

+

# create a group to be + extruded

-

shape_mesh = geompy.MakeCylinderRH(13, - 77)

+

GroupTri = mesh.CreateGroupFromGEOM(SMESH.FACE, + "Group of faces (extrusion)", face)

-

geompy.addToStudy(shape_mesh, - "cylinder")

+

 

-

 

+

# perform extrusion of + the group

-

# SMESH module

+

aMeshEditor.ExtrusionSweepObject(GroupTri, + vector, 5)

-

smesh = salome.lcc.FindOrLoadComponent("FactoryServer", - "SMESH")

+

 

-

smesh.SetCurrentStudy(salome.myStudy)

+

salome.sg.updateObjBrowser(1) +

-

mesh = smesh.CreateMesh(shape_mesh)

+

Extrusion along a Path

-

MeshEditor = mesh.GetMeshEditor()

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

 

+

# For the moment smesh package doesn't provide + methods to perform extrusion along a path.

-

# build five quadrangles:

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

node_start_id = mesh.NbNodes() - + 1

+

 

-

dx = 10

+

import math

-

dy = 20

+

import salome

-

 

+

 

-

MeshEditor.AddNode(0.0 - * dx, 0, 0) # 1

+

# Geometry

-

MeshEditor.AddNode(1.0 - * dx, 0, 0) # 2

+

import geompy

-

MeshEditor.AddNode(2.0 - * dx, 0, 0) # 3

+

 

-

MeshEditor.AddNode(3.0 - * dx, 0, 0) # 4

+

# 1. Create points

-

MeshEditor.AddNode(4.0 - * dx, 0, 0) # 5

+

points = [[0, 0], + [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]

-

MeshEditor.AddNode(5.0 - * dx, 0, 0) # 6

+

 

-

 

+

iv = 1

-

MeshEditor.AddNode(0.0 - * dx, dy, 0) # 7

+

vertices = []

-

MeshEditor.AddNode(1.0 - * dx, dy, 0) # 8

+

for point in points:

-

MeshEditor.AddNode(2.0 - * dx, dy, 0) # 9

+

vert + = geompy.MakeVertex(point[0], point[1], 0)

-

MeshEditor.AddNode(3.0 - * dx, dy, 0) # 10

+

geompy.addToStudy(vert, + "Vertex_" + `iv`)

-

MeshEditor.AddNode(4.0 - * dx, dy, 0) # 11

+

vertices.append(vert)

-

MeshEditor.AddNode(5.0 - * dx, dy, 0) # 12

+

iv + += 1

-

 

+

pass

-

MeshEditor.AddFace([1, - 2,  8,  7])

+

 

-

MeshEditor.AddFace([2, - 3,  9,  8])

+

# 2. Create edges and + wires

-

MeshEditor.AddFace([3, - 4, 10,  9])

+

Edge_straight = geompy.MakeEdge(vertices[0], + vertices[4])

-

MeshEditor.AddFace([4, - 5, 11, 10])

+

Edge_bezierrr = geompy.MakeBezier(vertices)

-

MeshEditor.AddFace([5, - 6, 12, 11])

+

Wire_polyline = geompy.MakePolyline(vertices)

-

 

+

Edge_Circle   = + geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])

-

# Change orientation - of the second and the fourth faces.

+

 

-

MeshEditor.Reorient([2, - 4])

+

geompy.addToStudy(Edge_straight, + "Edge_straight")

-

 

+

geompy.addToStudy(Edge_bezierrr, + "Edge_bezierrr")

-

salome.sg.updateObjBrowser(1) -  

+

geompy.addToStudy(Wire_polyline, + "Wire_polyline")

-

 

+

geompy.addToStudy(Edge_Circle +  , "Edge_Circle")

-

Cutting Quadrangles

+

 

-

import SMESH

+

# 3. Explode wire on + edges, as they will be used for mesh extrusion

-

import SMESH_mechanic

+

Wire_polyline_edges + = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])

-

 

+

for ii in range(len(Wire_polyline_edges)):

-

smesh  = - SMESH_mechanic.smesh

+

geompy.addToStudyInFather(Wire_polyline, + Wire_polyline_edges[ii], "Edge_" + `ii + 1`)

-

mesh   = - SMESH_mechanic.mesh

+

pass

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# Mesh

-

# unite a set of triangles

+

import smesh

-

aFilterMgr = smesh.CreateFilterManager()

+

import SMESH

-

aFunctor = aFilterMgr.CreateMinimumAngle()

+

 

-

 

+

gen = smesh.smesh

-

aMeshEditor = mesh.GetMeshEditor()

+

 

-

aMeshEditor.QuadToTri([405, - 406], aFunctor)

+

smeshgui = salome.ImportComponentGUI("SMESH")

-

    

+

smeshgui.Init(salome.myStudyId)

-

salome.sg.updateObjBrowser(1) -

+

 

-

 

+

# 1D algorithm and three + 1D hypotheses

-

Smoothing

+

Wire_discretisation + = gen.CreateHypothesis('Regular_1D', 'libStdMeshersEngine.so')

-

import SMESH

+

 

-

import SMESH_mechanic

+

Nb_Segments_3 = gen.CreateHypothesis('NumberOfSegments', + 'libStdMeshersEngine.so')

-

 

+

Nb_Segments_7 = gen.CreateHypothesis('NumberOfSegments', + 'libStdMeshersEngine.so')

-

smesh  = - SMESH_mechanic.smesh

+

Nb_Segments_8 = gen.CreateHypothesis('NumberOfSegments', + 'libStdMeshersEngine.so')

-

mesh   = - SMESH_mechanic.mesh

+

 

-

salome = SMESH_mechanic.salome

+

Nb_Segments_3.SetNumberOfSegments(3)

-

 

+

Nb_Segments_7.SetNumberOfSegments(7)

-

# smooth

+

Nb_Segments_8.SetNumberOfSegments(8)

-

FacesSmooth = [911, - 931, 950, 864, 932]

+

 

-

GroupSmooth = mesh.CreateGroup(SMESH.FACE,"Group - of faces (smooth)")

+

# Mesh given shape with + given 1d hypothesis

-

GroupSmooth.Add(FacesSmooth)

+

def Mesh1D(shape1d, + hyp1d, name):

-

 

+

mesh1d_tool + = smesh.Mesh(shape1d)

-

aMeshEditor = mesh.GetMeshEditor()

+

mesh1d + = mesh1d_tool.GetMesh()

-

aMeshEditor.SmoothObject(GroupSmooth, - [], 20, 2, SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH)

+

status + = mesh1d.AddHypothesis(shape1d, hyp1d)

-

 

+

status + = mesh1d.AddHypothesis(shape1d, Wire_discretisation)

-

salome.sg.updateObjBrowser(1) -

+

isDone + = mesh1d_tool.Compute()

-

 

+

if + not isDone: print 'Mesh ', name, ': computation failed'

-

 

+

return + mesh1d

-

Extrusion

+

 

-

import SMESH

+

# Create a mesh with + six nodes, seven edges and two quadrangle faces

-

import SMESH_mechanic

+

def MakeQuadMesh2(mesh_name):

-

 

+

quad_1 + = gen.CreateEmptyMesh()

-

smesh  = - SMESH_mechanic.smesh

+

smeshgui.SetName(salome.ObjectToID(quad_1), + mesh_name)

-

mesh   = - SMESH_mechanic.mesh

+

editor_1 + = quad_1.GetMeshEditor()

-

salome = SMESH_mechanic.salome

+

 

-

 

+

# six nodes

-

# extrusion of the group

+

n1 + = editor_1.AddNode(0, 20, 10)

-

point = SMESH.PointStruct(0, - 0, 5)

+

n2 + = editor_1.AddNode(0, 40, 10)

-

vector = SMESH.DirStruct(point)

+

n3 + = editor_1.AddNode(0, 40, 30)

-

FacesTriToQuad = [2381, - 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, - 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, - 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, - 2418, 2419, 2420, 2421, 2422]

+

n4 + = editor_1.AddNode(0, 20, 30)

-

 

+

n5 + = editor_1.AddNode(0,  0, + 30)

-

GroupTriToQuad = mesh.CreateGroup(SMESH.FACE,"Group - of faces (quad)")

+

n6 + = editor_1.AddNode(0,  0, + 10)

-

GroupTriToQuad.Add(FacesTriToQuad)

+

 

-

 

+

# seven edges

-

aMeshEditor = mesh.GetMeshEditor()

+

editor_1.AddEdge([n1, + n2]) # 1

-

aMeshEditor.ExtrusionSweepObject(GroupTriToQuad, - vector, 5)

+

editor_1.AddEdge([n2, + n3]) # 2

-

 

+

editor_1.AddEdge([n3, + n4]) # 3

-

salome.sg.updateObjBrowser(1) -

+

editor_1.AddEdge([n4, + n1]) # 4

-

 

+

editor_1.AddEdge([n4, + n5]) # 5

-

Extrusion along a Path

+

editor_1.AddEdge([n5, + n6]) # 6

-

import geompy

+

editor_1.AddEdge([n6, + n1]) # 7

-

import smesh

+

 

-

import salome

+

# two quadrangle faces

-

import SMESH

+

editor_1.AddFace([n1, + n2, n3, n4]) # 8

-

 

+

editor_1.AddFace([n1, + n4, n5, n6]) # 9

-

# create a face to be - meshed

+

return + [quad_1, editor_1, [1,2,3,4,5,6,7], [8,9]]

-

px = geompy.MakeVertex(100., - 0.  , 0. -  )

+

 

-

py = geompy.MakeVertex(0. -  , 100., - 0.  )

+

# Path meshes

-

pz = geompy.MakeVertex(0. -  , 0.  , - 100.)

+

Edge_straight_mesh + = Mesh1D(Edge_straight, Nb_Segments_7, "Edge_straight")

-

 

+

Edge_bezierrr_mesh + = Mesh1D(Edge_bezierrr, Nb_Segments_7, "Edge_bezierrr")

-

vxy = geompy.MakeVector(px, - py)

+

Wire_polyline_mesh + = Mesh1D(Wire_polyline, Nb_Segments_3, "Wire_polyline")

-

arc = geompy.MakeArc(py, - pz, px)

+

Edge_Circle_mesh   = + Mesh1D(Edge_Circle  , + Nb_Segments_8, "Edge_Circle")

-

 

+

 

-

wire = geompy.MakeWire([vxy, - arc])

+

# Initial meshes (to + be extruded)

-

isPlanarFace = 1

+

[quad_1, editor_1, + ee_1, ff_1] = MakeQuadMesh2("quad_1")

-

 

+

[quad_2, editor_2, + ee_2, ff_2] = MakeQuadMesh2("quad_2")

-

face1 = geompy.MakeFace(wire, - isPlanarFace)

+

[quad_3, editor_3, + ee_3, ff_3] = MakeQuadMesh2("quad_3")

-

id_face1 = geompy.addToStudy(face1, - "Face1")

+

[quad_4, editor_4, + ee_4, ff_4] = MakeQuadMesh2("quad_4")

-

 

+

[quad_5, editor_5, + ee_5, ff_5] = MakeQuadMesh2("quad_5")

-

# create a 2D mesh on - the face

+

[quad_6, editor_6, + ee_6, ff_6] = MakeQuadMesh2("quad_6")

-

trias = smesh.Mesh(face1, - "Face : 2D mesh")

+

[quad_7, editor_7, + ee_7, ff_7] = MakeQuadMesh2("quad_7")

-

 

+

 

-

algo = trias.Segment()

+

# ExtrusionAlongPath

-

algo.NumberOfSegments(6)

+

# IDsOfElements, PathMesh, + PathShape, NodeStart,

-

 

+

# HasAngles, Angles, + HasRefPoint, RefPoint

-

algo = trias.Triangle()

+

 

-

algo.LengthFromEdges()

+

refPoint = SMESH.PointStruct(0, + 0, 0)

-

 

+

 

-

trias.Compute()

+

a10 = 10.0*math.pi/180.0

-

 

+

a45 = 45.0*math.pi/180.0

-

# create a path mesh

+

 

-

px1 = geompy.MakeVertex(100., - 100.  , - 0.  )

+

# 1. Extrusion of two + mesh edges along a straight path

-

py1 = geompy.MakeVertex(-100. -  , -100., - 0.  )

+

error = editor_1.ExtrusionAlongPath([1,2], + Edge_straight_mesh, Edge_straight, 1,

-

pz1 = geompy.MakeVertex(0. -  , 0.  , - 50.)

+

    0, + [], 0, refPoint)

-

 

+

 

-

circle = geompy.MakeCircleThreePnt(py1, - pz1, px1)

+

# 2. Extrusion of one + mesh edge along a curved path

-

id_circle = geompy.addToStudy(circle, - "Path")

+

error = editor_2.ExtrusionAlongPath([2], + Edge_bezierrr_mesh, Edge_bezierrr, 1,

-

 

+

    0, + [], 0, refPoint)

-

circlemesh = smesh.Mesh(circle, - "Path mesh")

+

 

-

 

+

# 3. Extrusion of one + mesh edge along a curved path with usage of angles

-

algo = circlemesh.Segment()

+

error = editor_3.ExtrusionAlongPath([2], + Edge_bezierrr_mesh, Edge_bezierrr, 1,

-

algo.NumberOfSegments(10)

+

    1, + [a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)

-

 

+

 

-

circlemesh.Compute()

+

# 4. Extrusion of one + mesh edge along the path, which is a part of a meshed wire

-

 

+

error = editor_4.ExtrusionAlongPath([4], + Wire_polyline_mesh, Wire_polyline_edges[0], 1,

-

# extrusion of the mesh

+

    1, + [a10, a10, a10], 0, refPoint)

-

# The mesh "trias" - will be extruded along another mesh, which is a sub-mesh of "circlemesh",

+

 

-

# - corresponding to geometry "circle". In this particular case - the path mesh will be the whole "circlemesh"

+

# 5. Extrusion of two + mesh faces along the path, which is a part of a meshed wire

-

 

+

error = editor_5.ExtrusionAlongPath(ff_5 + , Wire_polyline_mesh, Wire_polyline_edges[2], 4,

-

aMeshEditor = trias.GetMesh().GetMeshEditor()

+

    0, + [], 0, refPoint)

-

aMeshEditor.ExtrusionAlongPathObject(trias.GetMesh(), - circlemesh.GetMesh(), circle, 1, 0, [], 0, SMESH.PointStruct(0, 0, 0))

+

 

-

 

+

# 6. Extrusion of two + mesh faces along a closed path

-

salome.sg.updateObjBrowser(1) -

+

error = editor_6.ExtrusionAlongPath(ff_6 + , Edge_Circle_mesh, Edge_Circle, 1,

+ +

    0, + [], 0, refPoint)

+ +

 

+ +

# 7. Extrusion of two + mesh faces along a closed path with usage of angles

+ +

error = editor_7.ExtrusionAlongPath(ff_7, + Edge_Circle_mesh, Edge_Circle, 1,

+ +

    1, + [a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint

+ +

 

+ +

salome.sg.updateObjBrowser(1)

Revolution

-

import SMESH

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import SMESH_mechanic

+

# For the moment smesh package doesn't provide + methods to perform revolution.

-

import math

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

 

+

 

-

smesh  = - SMESH_mechanic.smesh

+

import math

-

mesh   = - SMESH_mechanic.mesh

+

import SMESH

+ +

import SMESH_mechanic

+ +

 

-

salome = SMESH_mechanic.salome

+

mesh = SMESH_mechanic.mesh

-

 

+

aMeshEditor = mesh.GetMeshEditor()

-

# rotate a sweep object

+

 

-

FacesRotate = [492, +

# create a group of faces + to be revolved

+ +

FacesRotate = [492, 493, 502, 503]

-

GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group +

GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group of faces (rotate)")

-

GroupRotate.Add(FacesRotate)

+

GroupRotate.Add(FacesRotate)

-

angle45 =  45*math.pi/180

+

 

-

axisXYZ = SMESH.AxisStruct(-38.3128, - -73.3658, -23.321, -13.3402, -13.3265, 6.66632)

+

# define revolution angle + and axis

-

 

+

angle45 = 45 * math.pi + / 180

-

aMeshEditor = mesh.GetMeshEditor()

+

axisXYZ = SMESH.AxisStruct(-38.3128, + -73.3658, -23.321, -13.3402, -13.3265, 6.66632)

-

aMeshEditor.RotationSweepObject(GroupRotate, - axisXYZ, angle45, 4, 1e-5)

+

 

-

 

+

# perform revolution + of an object

-

salome.sg.updateObjBrowser(1) -

+

aMeshEditor.RotationSweepObject(GroupRotate, + axisXYZ, angle45, 4, 1e-5)

-

 

+

 

Pattern Mapping

-

import salome

+

# + Attention! This script has been written using the old approach basing + on direct usage of SMESH idl interface.

-

import geompy

+

# For the moment smesh package doesn't provide + methods to perform pattern mapping.

-

import SMESH, smesh

+

# In the next SALOME version the scripts will + be updated to use only the commands from smesh package.

-

 

+

 

-

geompy.init_geom(salome.myStudy)

+

import geompy

-

smesh.smesh.SetCurrentStudy(salome.myStudy)

+

import smesh

-

 

+

 

-

# define geometry

+

# define the geometry

-

Box_1 = geompy.MakeBoxDXDYDZ(200, - 200, 200)

+

Box_1 = geompy.MakeBoxDXDYDZ(200., + 200., 200.)

-

geompy.addToStudy(Box_1, +

geompy.addToStudy(Box_1, "Box_1")

-

 

+

 

-

faces = geompy.SubShapeAll(Box_1, +

faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])

-

Face_1 = faces[0]

+

Face_1 = faces[0]

-

Face_2 = faces[1]

+

Face_2 = faces[1]

-

geompy.addToStudyInFather(Box_1, +

geompy.addToStudyInFather(Box_1, Face_1, "Face_1")

-

geompy.addToStudyInFather(Box_1, +

geompy.addToStudyInFather(Box_1, Face_2, "Face_2")

-

 

+

 

-

# build quadrangle mesh - 3x3 on Face_1

+

# build a quadrangle + mesh 3x3 on Face_1

-

Mesh_1 = smesh.Mesh(Face_1)

+

Mesh_1 = smesh.Mesh(Face_1)

-

Wire_discretisation - = Mesh_1.Segment()

+

algo1D = Mesh_1.Segment()

-

Wire_discretisation.NumberOfSegments(3)

+

algo1D.NumberOfSegments(3)

-

Mesh_1.Quadrangle()

+

Mesh_1.Quadrangle()

-

 

+

 

-

isDone = Mesh_1.Compute()

+

isDone = Mesh_1.Compute()

-

if not isDone: print +

if not isDone: print 'Mesh Mesh_1 : computation failed'

-

 

- -

# pattern the mesh

- -

Mesh_2 = smesh.Mesh(Face_2)

+

 

-

Nb_Segments_1 = smesh.smesh.CreateHypothesis('NumberOfSegments', - 'libStdMeshersEngine.so')

+

# build a triangle mesh + on Face_2

-

Nb_Segments_1.SetNumberOfSegments(1)

+

Mesh_2 = smesh.Mesh(Face_2)

-

status = Mesh_2.GetMesh().AddHypothesis(Face_2, - Nb_Segments_1)

+

algo1D = Mesh_2.Segment()

-

status = Mesh_2.GetMesh().AddHypothesis(Face_2, - Wire_discretisation.GetAlgorithm())

+

algo1D.NumberOfSegments(1)

-

Triangle_Mefisto = - Mesh_2.Triangle()

+

algo2D = Mesh_2.Triangle()

-

Max_Element_Area = - Triangle_Mefisto.MaxElementArea(240)

+

algo2D.MaxElementArea(240)

-

 

+

isDone = Mesh_2.Compute()

-

isDone = Mesh_2.Compute()

- -

if not isDone: print +

if not isDone: print 'Mesh Mesh_2 : computation failed'

-

 

+

 

-

# create a pattern

+

# create a pattern

-

pattern = smesh.smesh.GetPattern()

+

pattern = smesh.smesh.GetPattern()

-

isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), +

isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)

-

if (isDone != 1):

+

if (isDone != 1): + print 'LoadFromFace :', pattern.GetErrorCode()

-

print - 'LoadFromFace :', pattern.GetErrorCode()

- -

 

+

 

-

# apply the pattern to +

# apply the pattern to a face of the first mesh

-

pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), +

pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), [17], 0, 0)

-

isDone = pattern.MakeMesh(Mesh_1.GetMesh(), +

isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)

-

if (isDone != 1):

+

if (isDone != 1): + print 'MakeMesh :', pattern.GetErrorCode()

-

print - 'MakeMesh :', pattern.GetErrorCode()

+

 

-

 

- -

salome.sg.updateObjBrowser(1) -

+