From: jfa Date: Thu, 6 Jul 2006 11:20:58 +0000 (+0000) Subject: PAL11898: Improve docs for Extrusion Along a Path. X-Git-Tag: T3_2_1_pre~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b0c5680264603d0338bf2904ee3d1fe93cefb34;p=modules%2Fsmesh.git PAL11898: Improve docs for Extrusion Along a Path. --- diff --git a/doc/salome/gui/SMESH/extrusion_along_a_path.htm b/doc/salome/gui/SMESH/extrusion_along_a_path.htm index 2058125a0..74b811ab6 100755 --- a/doc/salome/gui/SMESH/extrusion_along_a_path.htm +++ b/doc/salome/gui/SMESH/extrusion_along_a_path.htm @@ -1,197 +1,378 @@ - - - - - -Extrusion along a path - - - - - - - - - - - - -

Extrusion along a path

- -

In principle, Extrusion along a path works in the same way as Extrusion, - the main difference is that we define not a vector, but a path of extrusion - which must be a meshed edge or wire. To get an idea of how this algorithm - works, let's see the left image, where we have a 1D circle edge and  a - 2D hexagon to be extruded along this path (in the picture they are angular - because we show the wireframe of the mesh). And now let's see the right - image, showing the result of the operation.  

- -

 

- - --- - - - -
-

-

- -

 

- -

     

- -

 

- -

To use Extrusion along a path:

- -

1. From the Modification - menu choose the Extrusion along - a path item or click button in the toolbar. The - following dialog box will appear:

- -

 

- -

- -

 

- -

2. In the dialog box you should  

- - - -

 

- -

3. There are two optional parameters, which - can be very useful.

- - - -

4. Click the Apply - or OK button.

- -

 

- -

 See - Also a sample TUI Script of an Extrusion - along a Path operation.  

- -

 

- -

 

- - - - + + + + + +Extrusion along a path + + + + + + + + + + + + + +

Extrusion along a path

+ +

In principle, Extrusion along a path + works in the same way as Extrusion, + the main difference is that we define not a vector, but a path of extrusion + which must be a meshed edge. To get an idea of how this algorithm works, + examine several examples, starting from the most simple case of extrusion + along a straight edge. In all examples the same mesh will be extruded + along different paths and with different parameters. This sample 2D mesh + has two quadrangle faces and seven edges. Look at the picture, where white + digits are the node numbers and green are the element numbers:

+ +

.

+ +

 

+ + + + +++ + + + +
+

+

+ +

   

+ +

The left image shows a 1D path mesh, built + on a linear edge, and the initial 2D mesh. The right image shows the result + of extrusion of two edges (#1 and #2) of the initial mesh along the path. + Node #1 of path mesh has been selected as Start + node.

+ +

 

+ + + + ++++ + + + + + + + + + +
+

+

+

+

The left image shows a 1D path mesh, built on curvilinear edge, and + the initial  2D + mesh.

+

The central image shows the result of extrusion of one edge (#2) of + the initial mesh along the path.  Node + #1 of path mesh has been selected as Start + node.

+

The same, but using angles {45, 45, 45, 0, -45, -45, -45}

+ +

 

+ + + + +++ + + + +
+

+

+ +

 

+ +

In this example the path mesh has been built + on a wire (polyline with six edges). The first edge of the wire was used + as Shape (edge), node #1 as Start node. The angles have been defined + as {10, 10, 10}. The middle edge (#4) of the initial mesh has been extruded.

+ +

 

+ + + + +++ + + + +
+

+

+ +

 

+ +

This extrusion bases on the same path mesh + as in the previous example but the third edge of the wire was set as Shape (edge) and node #4 as Start + node. Please note, that the extrusion has been done in direction + from node #4 to node #3, i.e. against the wire direction. In this example + both faces of the initial mesh have been extruded.

+ +

 

+ + + + ++++ + + + + + + + + + +
+

+

+

+

The left image shows a path mesh built on a closed edge (circle).

+

The central image shows the result of extrusion of both faces of the + initial mesh. Note, that no sewing has been done, so, there are six coincident + nodes and two coincident faces in the resulting mesh.

+

The same, but using angles {45, -45, 45, -45, 45, -45, 45, -45}

+ +

 

+ +

 

+ +

To use Extrusion along a path:

+ +

1. From the Modification + menu choose the Extrusion along + a path item or click button in the toolbar. The + following dialog box will appear:

+ +

 

+ +

+ +

 

+ +

2. In the dialog box you should  

+ + + +

Path definition consists of several elements +

+ + + +

 

+ +

3. There are two optional parameters, which + can be very useful.

+ + + +

4. Click the Apply + or OK button. Mesh edges + will be extruded into faces, faces into volumes. The external surface + of the resulting 3d mesh (if faces have been extruded) is covered with + faces, and corners with edges. If the path is closed, the resulting mesh + can contain duplicated nodes and faces, because no sewing is done.

+ +

 

+ +

 See + Also a sample TUI Script of an Extrusion + along a Path operation.  

+ +

 

+ +

 

+ + + + diff --git a/doc/salome/gui/SMESH/image102.gif b/doc/salome/gui/SMESH/image102.gif deleted file mode 100755 index be6a58286..000000000 Binary files a/doc/salome/gui/SMESH/image102.gif and /dev/null differ diff --git a/doc/salome/gui/SMESH/image104.gif b/doc/salome/gui/SMESH/image104.gif deleted file mode 100755 index 3c33feee7..000000000 Binary files a/doc/salome/gui/SMESH/image104.gif and /dev/null differ diff --git a/doc/salome/gui/SMESH/modifying_meshes.htm b/doc/salome/gui/SMESH/modifying_meshes.htm index 8708a02b0..ab474a53d 100755 --- a/doc/salome/gui/SMESH/modifying_meshes.htm +++ b/doc/salome/gui/SMESH/modifying_meshes.htm @@ -1,1579 +1,1833 @@ - - - - - -Modifying Meshes - - - - - - - - - - - -

Modifying Meshes

- -

Adding Nodes and Elements

- -

Add Node

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Edge

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

 

- -

# add edge

- -

LastNodeId = mesh.NbNodes()

- -

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

- -

    print - "Edge addition is OK!"

- -

else:

- -

    print - "KO edge addition."

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Triangle

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

 

- -

LastNodeId = mesh.NbNodes()

- -

 

- -

# add triangle

- -

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

- -

    print - "Triangle addition is OK!"

- -

else:

- -

    print - "KO triangle addition."

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Quadrangle

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

 

- -

LastNodeId = mesh.NbNodes()

- -

 

- -

# add quadrangle

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

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

- -

    print - "Quadrangle addition is OK!"

- -

else:

- -

    print - "KO quadrangle addition."

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Tetrahedron

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

 

- -

LastNodeId = mesh.NbNodes()

- -

 

- -

# add tetrahedron

- -

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

- -

    print - "Tetrahedron addition is OK!"

- -

else:

- -

    print - "KO tetrahedron addition."

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Hexahedron

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add nodes

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

aNodeId1 = mesh.NbNodes()

- -

 

- -

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

- -

    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:

- -

    print - "KO node addition."

- -

aNodeId3 = mesh.NbNodes()

- -

 

- -

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

- -

    print - "Node addition is OK!"

- -

else:

- -

    print - "KO node addition."

- -

aNodeId4 = mesh.NbNodes()

- -

 

- -

# add hexahedron

- -

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

- -

    print - "Hexahedron addition is OK!"

- -

else:

- -

    print - "KO Hexahedron addition."

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Add Polygon

- -

import salome

- -

import geompy

- -

import math

- -

 

- -

import StdMeshers

- -

 

- -

# GEOM module

- -

shape_mesh = geompy.MakeCylinderRH(13, - 77)

- -

geompy.addToStudy(shape_mesh, - "cylinder")

- -

 

- -

# SMESH module

- -

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

- -

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

- -

    node_ids - = []

- -

    

- -

# Create nodes for a polyhedron

- -

    for - ii in range(nb_vert):

- -

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

- -

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

- -

                           z0)

- -

        node_ids.append(node_start_id - + ii)

- -

        pass

- -

    

- -

# Create a polygon

- -

    MeshEditor.AddPolygonalFace(node_ids)

- -

    return - 0

- -

 

- -

# Create three polygons

- -

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

- -

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

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -  

- -

 

- -

Add polyhedron

- -

import - salome

- -

import geompy

- -

import math

- -

 

- -

#import SMESH

- -

import StdMeshers

- -

 

- -

# GEOM

- -

shape_mesh = geompy.MakeCylinderRH(13, - 77)

- -

geompy.addToStudy(shape_mesh, - "cylinder")

- -

 

- -

# SMESH

- -

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

- -

smesh.SetCurrentStudy(salome.myStudy)

- -

mesh = smesh.CreateMesh(shape_mesh)

- -

MeshEditor = mesh.GetMeshEditor()

- -

 

- -

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

- -

 

- -

# 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

- -

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

- -

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

- -

 

- -

for i in range(5):

- -

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

- -

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

- -

 

- -

for i in range(5):

- -

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

- -

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

- -

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

- -

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

- -

 

- -

# Create a polyhedral - volume

- -

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

- -

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

- -

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

- -

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

- -

                                 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

- -

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

- -

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

- -

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

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -  

- -

 

- -

Removing Nodes and Elements

- -

Removing Nodes

- -

 

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# add node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    print - "Node removing is OK!"

- -

else:

- -

    print - "KO node removing."

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Removing Elements

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

anEditor = mesh.GetMeshEditor()

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Renumbering Nodes and Elements

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

anEditor = mesh.GetMeshEditor()

- -

anEditor.RenumberNodes()

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

 

- -

Moving Nodes

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# move node

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Diagonal Inversion

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# inverse diagonal

- -

aMeshEditor = mesh.GetMeshEditor()

- -

aMeshEditor.InverseDiag(700, - 642)

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Uniting two Triangles

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# delete diagonal

- -

aMeshEditor = mesh.GetMeshEditor()

- -

aMeshEditor.DeleteDiag(700, - 642)

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Uniting a Set of Triangles

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# unite a set of triangles

- -

aFilterMgr = smesh.CreateFilterManager()

- -

aFunctor = aFilterMgr.CreateMinimumAngle()

- -

 

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Orientation

- -

import - salome

- -

import geompy

- -

 

- -

import StdMeshers

- -

 

- -

# GEOM module

- -

shape_mesh = geompy.MakeCylinderRH(13, - 77)

- -

geompy.addToStudy(shape_mesh, - "cylinder")

- -

 

- -

# SMESH module

- -

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

- -

smesh.SetCurrentStudy(salome.myStudy)

- -

mesh = smesh.CreateMesh(shape_mesh)

- -

MeshEditor = mesh.GetMeshEditor()

- -

 

- -

# build five quadrangles:

- -

node_start_id = mesh.NbNodes() - + 1

- -

dx = 10

- -

dy = 20

- -

 

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

 

- -

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

- -

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

- -

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

- -

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

- -

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

- -

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

- -

 

- -

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

- -

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

- -

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

- -

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

- -

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

- -

 

- -

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

- -

MeshEditor.Reorient([2, - 4])

- -

 

- -

salome.sg.updateObjBrowser(1) -  

- -

 

- -

Cutting Quadrangles

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# unite a set of triangles

- -

aFilterMgr = smesh.CreateFilterManager()

- -

aFunctor = aFilterMgr.CreateMinimumAngle()

- -

 

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

    

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Smoothing

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# smooth

- -

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

- -

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

- -

GroupSmooth.Add(FacesSmooth)

- -

 

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

 

- -

Extrusion

- -

import SMESH

- -

import SMESH_mechanic

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# extrusion of the group

- -

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

- -

vector = SMESH.DirStruct(point)

- -

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]

- -

 

- -

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

- -

GroupTriToQuad.Add(FacesTriToQuad)

- -

 

- -

aMeshEditor = mesh.GetMeshEditor()

- -

aMeshEditor.ExtrusionSweepObject(GroupTriToQuad, - vector, 5)

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Extrusion along a Path

- -

import geompy

- -

import smesh

- -

import salome

- -

import SMESH

- -

 

- -

# create a face to be - meshed

- -

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

- -

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

- -

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

- -

 

- -

vxy = geompy.MakeVector(px, - py)

- -

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

- -

 

- -

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

- -

isPlanarFace = 1

- -

 

- -

face1 = geompy.MakeFace(wire, - isPlanarFace)

- -

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

- -

 

- -

# create a 2D mesh on - the face

- -

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

- -

 

- -

algo = trias.Segment()

- -

algo.NumberOfSegments(6)

- -

 

- -

algo = trias.Triangle()

- -

algo.LengthFromEdges()

- -

 

- -

trias.Compute()

- -

 

- -

# create a path mesh

- -

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

- -

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

- -

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

- -

 

- -

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

- -

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

- -

 

- -

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

- -

 

- -

algo = circlemesh.Segment()

- -

algo.NumberOfSegments(10)

- -

 

- -

circlemesh.Compute()

- -

 

- -

# extrusion of the mesh

- -

# 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"

- -

 

- -

aMeshEditor = trias.GetMesh().GetMeshEditor()

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

Revolution

- -

import SMESH

- -

import SMESH_mechanic

- -

import math

- -

 

- -

smesh  = - SMESH_mechanic.smesh

- -

mesh   = - SMESH_mechanic.mesh

- -

salome = SMESH_mechanic.salome

- -

 

- -

# rotate a sweep object

- -

FacesRotate = [492, - 493, 502, 503]

- -

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

- -

GroupRotate.Add(FacesRotate)

- -

angle45 =  45*math.pi/180

- -

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

- -

 

- -

aMeshEditor = mesh.GetMeshEditor()

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -

- -

 

- -

Pattern Mapping

- -

Attention! This script was written using old approach, based on direct usage of SMESH idl interface. To be updated for version 3.2.1 to use smesh package. -
  - -

import salome

- -

import geompy

- -

import SMESH, smesh

- -

 

- -

geompy.init_geom(salome.myStudy)

- -

smesh.smesh.SetCurrentStudy(salome.myStudy)

- -

 

- -

# define geometry

- -

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

- -

geompy.addToStudy(Box_1, - "Box_1")

- -

 

- -

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

- -

Face_1 = faces[0]

- -

Face_2 = faces[1]

- -

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

- -

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

- -

 

- -

# build quadrangle mesh - 3x3 on Face_1

- -

Mesh_1 = smesh.Mesh(Face_1)

- -

Wire_discretisation - = Mesh_1.Segment()

- -

Wire_discretisation.NumberOfSegments(3)

- -

Mesh_1.Quadrangle()

- -

 

- -

isDone = Mesh_1.Compute()

- -

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')

- -

Nb_Segments_1.SetNumberOfSegments(1)

- -

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

- -

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

- -

Triangle_Mefisto = - Mesh_2.Triangle()

- -

Max_Element_Area = - Triangle_Mefisto.MaxElementArea(240)

- -

 

- -

isDone = Mesh_2.Compute()

- -

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

- -

 

- -

# create a pattern

- -

pattern = smesh.smesh.GetPattern()

- -

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

- -

if (isDone != 1):

- -

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

- -

 

- -

# apply the pattern to - a face of the first mesh

- -

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

- -

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

- -

if (isDone != 1):

- -

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

- -

 

- -

salome.sg.updateObjBrowser(1) -

- - - - + + + + + +Modifying Meshes + + + + + + + + + + + +

Modifying Meshes

+ +

Adding Nodes and Elements

+ +

Add Node

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Edge

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

 

+ +

# add edge

+ +

LastNodeId = mesh.NbNodes()

+ +

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

+ +

    print + "Edge addition is OK!"

+ +

else:

+ +

    print + "KO edge addition."

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Triangle

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

 

+ +

LastNodeId = mesh.NbNodes()

+ +

 

+ +

# add triangle

+ +

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

+ +

    print + "Triangle addition is OK!"

+ +

else:

+ +

    print + "KO triangle addition."

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Quadrangle

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

 

+ +

LastNodeId = mesh.NbNodes()

+ +

 

+ +

# add quadrangle

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

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

+ +

    print + "Quadrangle addition is OK!"

+ +

else:

+ +

    print + "KO quadrangle addition."

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Tetrahedron

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

 

+ +

LastNodeId = mesh.NbNodes()

+ +

 

+ +

# add tetrahedron

+ +

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

+ +

    print + "Tetrahedron addition is OK!"

+ +

else:

+ +

    print + "KO tetrahedron addition."

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Hexahedron

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add nodes

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

aNodeId1 = mesh.NbNodes()

+ +

 

+ +

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

+ +

    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:

+ +

    print + "KO node addition."

+ +

aNodeId3 = mesh.NbNodes()

+ +

 

+ +

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

+ +

    print + "Node addition is OK!"

+ +

else:

+ +

    print + "KO node addition."

+ +

aNodeId4 = mesh.NbNodes()

+ +

 

+ +

# add hexahedron

+ +

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

+ +

    print + "Hexahedron addition is OK!"

+ +

else:

+ +

    print + "KO Hexahedron addition."

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Add Polygon

+ +

import salome

+ +

import geompy

+ +

import math

+ +

 

+ +

import StdMeshers

+ +

 

+ +

# GEOM module

+ +

shape_mesh = geompy.MakeCylinderRH(13, + 77)

+ +

geompy.addToStudy(shape_mesh, + "cylinder")

+ +

 

+ +

# SMESH module

+ +

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

+ +

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

+ +

    node_ids + = []

+ +

    

+ +

# Create nodes for a polyhedron

+ +

    for + ii in range(nb_vert):

+ +

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

+ +

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

+ +

                           z0)

+ +

        node_ids.append(node_start_id + + ii)

+ +

        pass

+ +

    

+ +

# Create a polygon

+ +

    MeshEditor.AddPolygonalFace(node_ids)

+ +

    return + 0

+ +

 

+ +

# Create three polygons

+ +

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

+ +

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

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +  

+ +

 

+ +

Add polyhedron

+ +

import + salome

+ +

import geompy

+ +

import math

+ +

 

+ +

#import SMESH

+ +

import StdMeshers

+ +

 

+ +

# GEOM

+ +

shape_mesh = geompy.MakeCylinderRH(13, + 77)

+ +

geompy.addToStudy(shape_mesh, + "cylinder")

+ +

 

+ +

# SMESH

+ +

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

+ +

smesh.SetCurrentStudy(salome.myStudy)

+ +

mesh = smesh.CreateMesh(shape_mesh)

+ +

MeshEditor = mesh.GetMeshEditor()

+ +

 

+ +

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

+ +

 

+ +

# 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

+ +

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

+ +

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

+ +

 

+ +

for i in range(5):

+ +

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

+ +

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

+ +

 

+ +

for i in range(5):

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# Create a polyhedral + volume

+ +

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

+ +

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

+ +

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

+ +

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

+ +

                                 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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +  

+ +

 

+ +

Removing Nodes and Elements

+ +

Removing Nodes

+ +

 

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# add node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    print + "Node removing is OK!"

+ +

else:

+ +

    print + "KO node removing."

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Removing Elements

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

anEditor = mesh.GetMeshEditor()

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Renumbering Nodes and Elements

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

anEditor = mesh.GetMeshEditor()

+ +

anEditor.RenumberNodes()

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

 

+ +

Moving Nodes

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# move node

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Diagonal Inversion

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# inverse diagonal

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

aMeshEditor.InverseDiag(700, + 642)

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Uniting two Triangles

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# delete diagonal

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

aMeshEditor.DeleteDiag(700, + 642)

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Uniting a Set of Triangles

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# unite a set of triangles

+ +

aFilterMgr = smesh.CreateFilterManager()

+ +

aFunctor = aFilterMgr.CreateMinimumAngle()

+ +

 

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Orientation

+ +

import + salome

+ +

import geompy

+ +

 

+ +

import StdMeshers

+ +

 

+ +

# GEOM module

+ +

shape_mesh = geompy.MakeCylinderRH(13, + 77)

+ +

geompy.addToStudy(shape_mesh, + "cylinder")

+ +

 

+ +

# SMESH module

+ +

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

+ +

smesh.SetCurrentStudy(salome.myStudy)

+ +

mesh = smesh.CreateMesh(shape_mesh)

+ +

MeshEditor = mesh.GetMeshEditor()

+ +

 

+ +

# build five quadrangles:

+ +

node_start_id = mesh.NbNodes() + + 1

+ +

dx = 10

+ +

dy = 20

+ +

 

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

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

+ +

MeshEditor.Reorient([2, + 4])

+ +

 

+ +

salome.sg.updateObjBrowser(1) +  

+ +

 

+ +

Cutting Quadrangles

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# unite a set of triangles

+ +

aFilterMgr = smesh.CreateFilterManager()

+ +

aFunctor = aFilterMgr.CreateMinimumAngle()

+ +

 

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

    

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Smoothing

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# smooth

+ +

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

+ +

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

+ +

GroupSmooth.Add(FacesSmooth)

+ +

 

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

 

+ +

Extrusion

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# extrusion of the group

+ +

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

+ +

vector = SMESH.DirStruct(point)

+ +

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]

+ +

 

+ +

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

+ +

GroupTriToQuad.Add(FacesTriToQuad)

+ +

 

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

aMeshEditor.ExtrusionSweepObject(GroupTriToQuad, + vector, 5)

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Extrusion along a Path

+ +

import math

+ +

 

+ +

import salome

+ +

salome.salome_init()

+ +

 

+ +

# Geometry

+ +

import geompy

+ +

 

+ +

# 1. Create points

+ +

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

+ +

 

+ +

iv = 1

+ +

vertices = []

+ +

for point in points:

+ +

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

+ +

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

+ +

vertices.append(vert)

+ +

iv + += 1

+ +

pass

+ +

 

+ +

# 2. Create edges and + wires

+ +

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

+ +

Edge_bezierrr = geompy.MakeBezier(vertices)

+ +

Wire_polyline = geompy.MakePolyline(vertices)

+ +

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

+ +

 

+ +

geompy.addToStudy(Edge_straight, + "Edge_straight")

+ +

geompy.addToStudy(Edge_bezierrr, + "Edge_bezierrr")

+ +

geompy.addToStudy(Wire_polyline, + "Wire_polyline")

+ +

geompy.addToStudy(Edge_Circle +  , "Edge_Circle")

+ +

 

+ +

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

+ +

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

+ +

for ii in range(len(Wire_polyline_edges)):

+ +

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

+ +

pass

+ +

 

+ +

# Mesh

+ +

import smesh

+ +

import SMESH

+ +

 

+ +

gen = smesh.smesh

+ +

 

+ +

smeshgui = salome.ImportComponentGUI("SMESH")

+ +

smeshgui.Init(salome.myStudyId)

+ +

 

+ +

# 1D algorithm and three + 1D hypotheses

+ +

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

+ +

 

+ +

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

+ +

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

+ +

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

+ +

 

+ +

Nb_Segments_3.SetNumberOfSegments(3)

+ +

Nb_Segments_7.SetNumberOfSegments(7)

+ +

Nb_Segments_8.SetNumberOfSegments(8)

+ +

 

+ +

# Mesh given shape with + given 1d hypothesis

+ +

def Mesh1D(shape1d, + hyp1d, name):

+ +

mesh1d_tool + = smesh.Mesh(shape1d)

+ +

mesh1d + = mesh1d_tool.GetMesh()

+ +

status + = mesh1d.AddHypothesis(shape1d, hyp1d)

+ +

status + = mesh1d.AddHypothesis(shape1d, Wire_discretisation)

+ +

isDone + = mesh1d_tool.Compute()

+ +

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

+ +

return + mesh1d

+ +

 

+ +

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

+ +

def MakeQuadMesh2(mesh_name):

+ +

quad_1 + = gen.CreateEmptyMesh()

+ +

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

+ +

editor_1 + = quad_1.GetMeshEditor()

+ +

 

+ +

# six nodes

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# seven edges

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# two quadrangle faces

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# Path meshes

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# Initial meshes (to + be extruded)

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

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

+ +

 

+ +

# ExtrusionAlongPath

+ +

# IDsOfElements, PathMesh, + PathShape, NodeStart,

+ +

# HasAngles, Angles, + HasRefPoint, RefPoint

+ +

 

+ +

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

+ +

 

+ +

a10 = 10.0*math.pi/180.0

+ +

a45 = 45.0*math.pi/180.0

+ +

 

+ +

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

+ +

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

+ +

    0, + [], 0, refPoint)

+ +

 

+ +

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

+ +

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

+ +

    0, + [], 0, refPoint)

+ +

 

+ +

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

+ +

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

+ +

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

+ +

 

+ +

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

+ +

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

+ +

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

+ +

 

+ +

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

+ +

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

+ +

    0, + [], 0, refPoint)

+ +

 

+ +

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

+ +

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

+ +

    0, + [], 0, refPoint)

+ +

 

+ +

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

+ +

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

+ +

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

+ +

 

+ +

if salome.sg.hasDesktop():

+ +

salome.sg.updateObjBrowser(1)

+ +

pass

+ +

Revolution

+ +

import SMESH

+ +

import SMESH_mechanic

+ +

import math

+ +

 

+ +

smesh  = + SMESH_mechanic.smesh

+ +

mesh   = + SMESH_mechanic.mesh

+ +

salome = SMESH_mechanic.salome

+ +

 

+ +

# rotate a sweep object

+ +

FacesRotate = [492, + 493, 502, 503]

+ +

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

+ +

GroupRotate.Add(FacesRotate)

+ +

angle45 =  45*math.pi/180

+ +

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

+ +

 

+ +

aMeshEditor = mesh.GetMeshEditor()

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ +

 

+ +

Pattern Mapping

+ +

import salome

+ +

import geompy

+ +

import SMESH, smesh

+ +

 

+ +

geompy.init_geom(salome.myStudy)

+ +

smesh.smesh.SetCurrentStudy(salome.myStudy)

+ +

 

+ +

# define geometry

+ +

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

+ +

geompy.addToStudy(Box_1, + "Box_1")

+ +

 

+ +

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

+ +

Face_1 = faces[0]

+ +

Face_2 = faces[1]

+ +

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

+ +

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

+ +

 

+ +

# build quadrangle mesh + 3x3 on Face_1

+ +

Mesh_1 = smesh.Mesh(Face_1)

+ +

Wire_discretisation + = Mesh_1.Segment()

+ +

Wire_discretisation.NumberOfSegments(3)

+ +

Mesh_1.Quadrangle()

+ +

 

+ +

isDone = Mesh_1.Compute()

+ +

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')

+ +

Nb_Segments_1.SetNumberOfSegments(1)

+ +

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

+ +

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

+ +

Triangle_Mefisto = + Mesh_2.Triangle()

+ +

Max_Element_Area = + Triangle_Mefisto.MaxElementArea(240)

+ +

 

+ +

isDone = Mesh_2.Compute()

+ +

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

+ +

 

+ +

# create a pattern

+ +

pattern = smesh.smesh.GetPattern()

+ +

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

+ +

if (isDone != 1):

+ +

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

+ +

 

+ +

# apply the pattern to + a face of the first mesh

+ +

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

+ +

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

+ +

if (isDone != 1):

+ +

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

+ +

 

+ +

salome.sg.updateObjBrowser(1) +

+ + + + diff --git a/doc/salome/gui/SMESH/pics/a-extusionalongapath2.png b/doc/salome/gui/SMESH/pics/a-extusionalongapath2.png deleted file mode 100755 index f120fc3c0..000000000 Binary files a/doc/salome/gui/SMESH/pics/a-extusionalongapath2.png and /dev/null differ diff --git a/doc/salome/gui/SMESH/pics/circle_angles_after.png b/doc/salome/gui/SMESH/pics/circle_angles_after.png new file mode 100644 index 000000000..f4c606bde Binary files /dev/null and b/doc/salome/gui/SMESH/pics/circle_angles_after.png differ diff --git a/doc/salome/gui/SMESH/pics/circle_simple_after.png b/doc/salome/gui/SMESH/pics/circle_simple_after.png new file mode 100644 index 000000000..99f65b558 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/circle_simple_after.png differ diff --git a/doc/salome/gui/SMESH/pics/circle_simple_before.png b/doc/salome/gui/SMESH/pics/circle_simple_before.png new file mode 100644 index 000000000..95b90373f Binary files /dev/null and b/doc/salome/gui/SMESH/pics/circle_simple_before.png differ diff --git a/doc/salome/gui/SMESH/pics/curvi_angles_after.png b/doc/salome/gui/SMESH/pics/curvi_angles_after.png new file mode 100644 index 000000000..9d06262b0 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/curvi_angles_after.png differ diff --git a/doc/salome/gui/SMESH/pics/curvi_simple_after.png b/doc/salome/gui/SMESH/pics/curvi_simple_after.png new file mode 100644 index 000000000..ae1d98fdf Binary files /dev/null and b/doc/salome/gui/SMESH/pics/curvi_simple_after.png differ diff --git a/doc/salome/gui/SMESH/pics/curvi_simple_before.png b/doc/salome/gui/SMESH/pics/curvi_simple_before.png new file mode 100644 index 000000000..a0bbf73bd Binary files /dev/null and b/doc/salome/gui/SMESH/pics/curvi_simple_before.png differ diff --git a/doc/salome/gui/SMESH/pics/edge_wire_3d_after.png b/doc/salome/gui/SMESH/pics/edge_wire_3d_after.png new file mode 100644 index 000000000..3fab59803 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/edge_wire_3d_after.png differ diff --git a/doc/salome/gui/SMESH/pics/edge_wire_3d_before.png b/doc/salome/gui/SMESH/pics/edge_wire_3d_before.png new file mode 100644 index 000000000..28f986830 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/edge_wire_3d_before.png differ diff --git a/doc/salome/gui/SMESH/pics/edge_wire_after.png b/doc/salome/gui/SMESH/pics/edge_wire_after.png new file mode 100644 index 000000000..408480ecd Binary files /dev/null and b/doc/salome/gui/SMESH/pics/edge_wire_after.png differ diff --git a/doc/salome/gui/SMESH/pics/edge_wire_before.png b/doc/salome/gui/SMESH/pics/edge_wire_before.png new file mode 100644 index 000000000..186528ec7 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/edge_wire_before.png differ diff --git a/doc/salome/gui/SMESH/pics/extrusion1.png b/doc/salome/gui/SMESH/pics/extrusion1.png new file mode 100644 index 000000000..b7b155931 Binary files /dev/null and b/doc/salome/gui/SMESH/pics/extrusion1.png differ diff --git a/doc/salome/gui/SMESH/pics/mesh_for_extr_along_path.png b/doc/salome/gui/SMESH/pics/mesh_for_extr_along_path.png new file mode 100644 index 000000000..4ee52ebfa Binary files /dev/null and b/doc/salome/gui/SMESH/pics/mesh_for_extr_along_path.png differ diff --git a/doc/salome/gui/SMESH/pics/straight_after.png b/doc/salome/gui/SMESH/pics/straight_after.png new file mode 100644 index 000000000..4572fea7b Binary files /dev/null and b/doc/salome/gui/SMESH/pics/straight_after.png differ diff --git a/doc/salome/gui/SMESH/pics/straight_before.png b/doc/salome/gui/SMESH/pics/straight_before.png new file mode 100644 index 000000000..200aad85d Binary files /dev/null and b/doc/salome/gui/SMESH/pics/straight_before.png differ