6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 from salome.smesh
import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
13 Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
14 f = geompy.SubShapeAllSorted(Box, geompy.ShapeType[
"FACE"])
16 Mesh1 = smesh.Mesh(f[0])
17 Regular_1D = Mesh1.Segment()
18 Nb_Segments_1 = Regular_1D.NumberOfSegments(3)
19 Nb_Segments_1.SetDistrType( 0 )
20 Quadrangle_2D = Mesh1.Quadrangle()
21 isDone = Mesh1.Compute()
24 newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],
True,
"ScaledMesh")
27 Mesh1.Scale(Mesh1,SMESH.PointStruct(200,100,100),[0.5,0.5,0.5],
True,
True)
30 Mesh1.Scale([1,2],SMESH.PointStruct(-100,100,100),[0.8,1.0,0.7],
False)
33 Mesh1.Scale([21],SMESH.PointStruct(0,200,200),[0.7,0.7,0.7],
False)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
15 px = geompy.MakeVertex(100., 0. , 0. )
16 py = geompy.MakeVertex(0. , 100., 0. )
17 pz = geompy.MakeVertex(0. , 0. , 100.)
19 vxy = geompy.MakeVector(px, py)
20 arc = geompy.MakeArc(py, pz, px)
22 wire = geompy.MakeWire([vxy, arc])
25 face1 = geompy.MakeFace(wire, isPlanarFace)
26 id_face1 = geompy.addToStudy(face1,
"Face1")
29 px1 = geompy.MakeVertex( 100., 100., 0.)
30 py1 = geompy.MakeVertex(-100., -100., 0.)
31 pz1 = geompy.MakeVertex( 0., 0., 50.)
33 circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
34 id_circle = geompy.addToStudy(circle,
"Path")
37 trias = smesh.Mesh(face1,
"Face : 2D mesh")
39 algo1D = trias.Segment()
40 algo1D.NumberOfSegments(6)
41 algo2D = trias.Triangle()
42 algo2D.LengthFromEdges()
47 circlemesh = smesh.Mesh(circle,
"Path mesh")
48 algo = circlemesh.Segment()
49 algo.NumberOfSegments(10)
53 trias.ExtrusionAlongPath([], circlemesh, circle,
54 1, 0, [], 0, SMESH.PointStruct(0, 0, 0))
57 print "Number of nodes before MergeNodes:",
60 array_of_nodes_groups = trias.FindCoincidentNodes(tolerance)
62 trias.MergeNodes(array_of_nodes_groups)
64 print "Number of nodes after MergeNodes:", trias.NbNodes()
66 print "Number of elements before MergeEqualElements:"
67 print "Edges : ", trias.NbEdges()
68 print "Triangles : ", trias.NbTriangles()
69 print "Quadrangles: ", trias.NbQuadrangles()
70 print "Volumes : ", trias.NbVolumes()
73 trias.MergeEqualElements()
74 print "Number of elements after MergeEqualElements:"
75 print "Edges : ", trias.NbEdges()
76 print "Triangles : ", trias.NbTriangles()
77 print "Quadrangles: ", trias.NbQuadrangles()
78 print "Volumes : ", trias.NbVolumes()
80 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
15 box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.)
16 facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType[
"FACE"])
19 box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
20 facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType[
"FACE"])
23 edgesList = geompy.SubShapeAll(face2, geompy.ShapeType[
"EDGE"])
26 aComp = geompy.MakeCompound([face1, face2])
27 geompy.addToStudy(aComp,
"Two faces")
30 mesh = smesh.Mesh(aComp,
"Two faces : quadrangle mesh")
32 algo1D = mesh.Segment()
33 algo1D.NumberOfSegments(9)
34 algo2D = mesh.Quadrangle()
36 algo_local = mesh.Segment(edge1)
37 algo_local.Arithmetic1D(1, 4)
38 algo_local.Propagation()
46 mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
17 box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.)
18 facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType[
"FACE"])
21 box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
22 facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType[
"FACE"])
25 edgesList = geompy.SubShapeAll(face2, geompy.ShapeType[
"EDGE"])
28 aComp = geompy.MakeCompound([face1, face2])
29 geompy.addToStudy(aComp,
"Two faces")
32 mesh = smesh.Mesh(aComp,
"Two faces : quadrangle mesh")
34 algo1D = mesh.Segment()
35 algo1D.NumberOfSegments(9)
36 algo2D = mesh.Quadrangle()
38 algo_local = mesh.Segment(edge1)
39 algo_local.Arithmetic1D(1, 4)
40 algo_local.Propagation()
46 mesh.SewConformFreeBorders(5, 45, 6, 3, 24)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
15 OY0 = geompy.MakeVectorDXDYDZ(0, 1, 0)
16 OY1 = geompy.MakeTranslation( OY0, 1, 0, 0, theName=
"OY1" )
17 OY2 = geompy.MakeTranslation( OY0, 1.01, 0, 0, theName=
"OY2" )
18 OY3 = geompy.MakeTranslation( OY0, 2, 0, 0 )
19 q1 = geompy.MakeQuad2Edges( OY0, OY1 )
20 q2 = geompy.MakeQuad2Edges( OY2, OY3 )
22 shape = geompy.MakeCompound( [q1,q2], theName=
'shape' )
25 mesh = smesh.Mesh(shape,
"Two faces : quadrangle mesh")
33 segs1 = mesh.GetSubMeshElementsId( OY1 )
34 segs2 = mesh.GetSubMeshElementsId( OY2 )
36 FirstNodeID1 = mesh.GetElemNode( segs1[0], 0 )
37 SecondNodeID1 = mesh.GetElemNode( segs1[0], 1 )
38 LastNodeID1 = mesh.GetElemNode( segs1[-1], 1 )
39 FirstNodeID2 = mesh.GetElemNode( segs2[0], 0 )
40 SecondNodeID2 = mesh.GetElemNode( segs2[0], 1 )
41 LastNodeID2 = mesh.GetElemNode( segs2[-1], 1 )
43 CreatePolyedrs =
False
45 res = mesh.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
46 FirstNodeID2, SecondNodeID2, LastNodeID2,
47 CreatePolygons, CreatePolyedrs )
49 print "nb polygons:", mesh.NbPolygons()
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 from salome.smesh
import smeshBuilder
11 smesh = smeshBuilder.New(salome.myStudy)
14 box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
15 box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
17 EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType[
"EDGE"])
19 aComp = geompy.MakeCompound([box1, box2])
20 geompy.addToStudy(aComp,
"Two boxes")
23 mesh = smesh.Mesh(aComp,
"Sew Side Elements")
25 algo1D = mesh.Segment()
26 algo1D.NumberOfSegments(2)
27 algo2D = mesh.Quadrangle()
29 algo_local = mesh.Segment(EdgesList[8])
30 algo_local.NumberOfSegments(4)
31 algo_local.Propagation()
38 face1 = geompy.GetFaceNearPoint( aComp, geompy.MakeVertex( 5, 10, 5 ))
39 IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 )
40 print "side faces 1:",IDsOfSide1Elements
42 face1Translated = geompy.MakeTranslation( face1, 0,5,0 )
43 faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,
'=', face1Translated )
44 IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter )
45 print "side faces 2:",IDsOfSide2Elements
48 edge1 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 10, 5 ))
49 segs1 = mesh.GetSubMeshElementsId( edge1 )
50 NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 )
51 NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 )
52 print "nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge]
54 edge2 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 15, 5 ))
55 segs2 = mesh.GetSubMeshElementsId( edge2 )
56 NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 )
57 NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 )
58 print "nodes of side2:", [NodeID1OfSide2ToMerge,NodeID2OfSide2ToMerge]
60 res = mesh.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
61 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
62 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
8 from salome.geom
import geomBuilder
9 geompy = geomBuilder.New(salome.myStudy)
12 from salome.smesh
import smeshBuilder
13 smesh = smeshBuilder.New(salome.myStudy)
17 box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
20 mesh = smesh.Mesh(box,
"Mesh")
31 nodes1 = mesh.CreateEmptyGroup( SMESH.NODE,
'nodes1' )
32 nodes1.Add( [ 119, 125, 131, 137 ] )
35 faces1 = mesh.CreateEmptyGroup( SMESH.FACE,
'faces1' )
36 faces1.Add( [ 144, 151, 158 ] )
39 print "\nMesh before the first nodes duplication:"
40 print "Nodes : ", mesh.NbNodes()
41 print "Edges : ", mesh.NbEdges()
42 print "Quadrangles : ", mesh.NbQuadrangles()
44 groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=
True)
45 print "New nodes:", groupOfCreatedNodes.GetIDs()
47 print "\nMesh after the first nodes duplication:"
48 print "Nodes : ", mesh.NbNodes()
49 print "Edges : ", mesh.NbEdges()
50 print "Quadrangles : ", mesh.NbQuadrangles()
55 edges = mesh.CreateEmptyGroup( SMESH.EDGE,
'edges' )
56 edges.Add( [ 32, 33, 34 ] )
59 nodes2 = mesh.CreateEmptyGroup( SMESH.NODE,
'nodes2' )
60 nodes2.Add( [ 35, 38 ] )
63 faces2 = mesh.CreateEmptyGroup( SMESH.FACE,
'faces2' )
64 faces2.Add( [ 141, 148, 155 ] )
67 print "\nMesh before the second nodes duplication:"
68 print "Nodes : ", mesh.NbNodes()
69 print "Edges : ", mesh.NbEdges()
70 print "Quadrangles : ", mesh.NbQuadrangles()
72 groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=
True )
73 print "New edges:", groupOfNewEdges.GetIDs()
75 print "\nMesh after the second nodes duplication:"
76 print "Nodes : ", mesh.NbNodes()
77 print "Edges : ", mesh.NbEdges()
78 print "Quadrangles : ", mesh.NbQuadrangles()
85 newFacesGroup = mesh.DoubleElements( mesh,
"newFacesGroup" )
88 mesh.DoubleElements( edges, edges.GetName() )
91 mesh.DoubleElements([ 1, 2 ])
94 if salome.sg.hasDesktop():
95 salome.sg.updateObjBrowser(
False)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
16 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
17 gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType[
"FACE"])
18 f1,f2 = gFaces[0],gFaces[1]
19 geompy.addToStudy(box,
"box")
20 geompy.addToStudyInFather(box,f1,
"face1")
21 geompy.addToStudyInFather(box,f2,
"face2")
23 twoFaces = geompy.MakeCompound([f1,f2])
30 dim = SMESH.BND_2DFROM3D
32 init_mesh = smesh.Mesh(box,
"box")
33 init_mesh.AutomaticHexahedralization()
36 faces = init_mesh.GetElementsByType( SMESH.FACE )
37 nb_faces = len( faces )
38 rm_face = faces[ : nb_faces/2]
39 init_mesh.RemoveElements( rm_face )
42 mesh = smesh.CopyMesh( init_mesh,
"2D from 3D")
44 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
47 meshName =
"2D boundary of " + init_mesh.GetName()
48 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
51 meshName = init_mesh.GetName() +
" + boundary"
52 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=
True)
60 dim = SMESH.BND_1DFROM2D
62 init_mesh = smesh.Mesh(f1,
"2D mesh")
63 init_mesh.AutomaticHexahedralization()
66 edges = init_mesh.GetElementsByType( SMESH.EDGE )
67 nb_edges = len( edges )
68 rm_edge = edges[ : nb_edges/2]
69 init_mesh.RemoveElements( rm_edge )
73 mesh = smesh.CopyMesh( init_mesh,
"1D from 2D")
75 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
78 meshName =
"1D boundary of " + init_mesh.GetName()
79 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
82 meshName = init_mesh.GetName() +
" + boundary"
83 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=
True)
92 dim = SMESH.BND_1DFROM3D
94 init_mesh = smesh.Mesh(box,
"box")
95 init_mesh.AutomaticHexahedralization()
97 rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
98 init_mesh.RemoveElements( rm_edges )
101 fGroup1 = init_mesh.Group( f1,
"f1" )
102 fGroup2 = init_mesh.Group( f2,
"f2" )
105 mesh = smesh.CopyMesh( init_mesh,
"1D from 2D groups", toCopyGroups=
True)
106 groups = mesh.GetGroups()
107 nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
110 meshName =
"boundary from groups of " + init_mesh.GetName()
111 groups = init_mesh.GetGroups()
112 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
115 meshName = init_mesh.GetName() +
" + boundary from groups"
116 nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
117 groups=groups, toCopyAll=
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
17 box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
18 faces = geompy.SubShapeAllSorted( box, geompy.ShapeType[
"FACE"])
20 shape = geompy.MakeCompound( faces[:2] )
21 faces = geompy.SubShapeAll( shape, geompy.ShapeType[
"FACE"] )
22 geompy.addToStudy( shape,
"shape")
23 geompy.addToStudyInFather( shape, faces[0],
"faces[0]")
24 geompy.addToStudyInFather( shape, faces[1],
"faces[1]")
27 mesh = smesh.Mesh( shape,
"test_Reorient2D")
28 mesh.AutomaticHexahedralization(0.5)
29 localAlgo = mesh.Segment(faces[0])
30 localAlgo.NumberOfSegments( 11 )
32 group = mesh.Group( faces[1] )
34 vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 )
41 mesh.Reorient2D( mesh, vec, mesh.NbElements() )
46 mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec ))
51 mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0])
54 mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))
59 mesh3D = smesh.Mesh( box,
'3D mesh')
60 mesh3D.AutomaticHexahedralization(0.5)
61 group0 = mesh3D.Group( faces[0] )
62 group1 = mesh3D.Group( faces[1] )
65 nbRev = mesh3D.Reorient2DBy3D([ group0, group1.GetIDs() ], mesh3D, theOutsideNormal=
False)
66 print "Nb reoriented faces:", nbRev
69 nbRev = mesh3D.Reorient2DBy3D( mesh3D, mesh3D, theOutsideNormal=
True)
70 print "Nb re-reoriented faces:", nbRev