From: vsr Date: Wed, 13 Apr 2022 07:01:14 +0000 (+0300) Subject: Refactor doc examples X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=30ce39c9b186261abf14b2cfb71d2d3640fb9a45;p=modules%2Fsmesh.git Refactor doc examples --- diff --git a/doc/examples/3dmesh.py b/doc/examples/3dmesh.py deleted file mode 100644 index 0fdfcb68d..000000000 --- a/doc/examples/3dmesh.py +++ /dev/null @@ -1,104 +0,0 @@ -# 3d mesh generation and mesh exploration - -import salome -salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -### -# Geometry: an assembly of a box, a cylinder and a truncated cone -# to be meshed with tetrahedra -### - -# Define values -name = "ex21_lamp" -cote = 60 -section = 20 -size = 200 -radius_1 = 80 -radius_2 = 40 -height = 100 - -# Build a box -box = geompy.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) - -# Build a cylinder -pt1 = geompy.MakeVertex(0, 0, cote/3) -di1 = geompy.MakeVectorDXDYDZ(0, 0, 1) -cyl = geompy.MakeCylinder(pt1, di1, section, size) - -# Build a truncated cone -pt2 = geompy.MakeVertex(0, 0, size) -cone = geompy.MakeCone(pt2, di1, radius_1, radius_2, height) - -# Fuse -box_cyl = geompy.MakeFuse(box, cyl) -piece = geompy.MakeFuse(box_cyl, cone) - -# Add to the study -geompy.addToStudy(piece, name) - -# Create a group of faces -faces_group = geompy.CreateGroup(piece, geompy.ShapeType["FACE"]) -group_name = name + "_grp" -geompy.addToStudy(faces_group, group_name) -faces_group.SetName(group_name) - -# Add faces to the group -faces = geompy.SubShapeAllIDs(piece, geompy.ShapeType["FACE"]) -geompy.UnionIDs(faces_group, faces) - -### -# Create a mesh -### - -# Define a mesh on a geometry -tetra = smesh.Mesh(piece, name) - -# Define 1D algorithm and hypothesis -algo1d = tetra.Segment() -algo1d.LocalLength(10) - -# Define 2D algorithm and hypothesis -algo2d = tetra.Triangle() -algo2d.LengthFromEdges() - -# Define 3D algorithm and hypothesis -algo3d = tetra.Tetrahedron() -algo3d.MaxElementVolume(100) - -# Compute the mesh -tetra.Compute() - -# Create a mesh group of all triangles generated on geom faces present in faces_group -group = tetra.Group(faces_group) - -### -# Explore the mesh -### - -# Retrieve coordinates of nodes -coordStr = "" -for node in tetra.GetNodesId(): - x,y,z = tetra.GetNodeXYZ( node ) - coordStr += "%s (%s, %s, %s) " % ( node, x,y,z ) - pass - -# Retrieve nodal connectivity of triangles -triaStr = "" -for tria in tetra.GetElementsByType( SMESH.FACE ): - nodes = tetra.GetElemNodes( tria ) - triaStr += "%s (%s, %s, %s) " % ( tria, nodes[0], nodes[1], nodes[2] ) - -# Retrieve group contents -groupStr = "" -for group in tetra.GetGroups(): - ids = group.GetIDs() - name = group.GetName() - eType = group.GetType() - groupStr += "'%s' %s: %s \n" % ( name, eType, ids ) - diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt index 8491392e5..94eb39a0c 100644 --- a/doc/examples/CMakeLists.txt +++ b/doc/examples/CMakeLists.txt @@ -51,5 +51,6 @@ ENDIF() IF(SALOME_BUILD_TESTS OR SALOME_BUILD_DOC) INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${EXAMPLES_INSTALL_DIRECTORY}) + INSTALL(FILES mechanic.py DESTINATION ${SALOME_INSTALL_BINS}) INSTALL(DIRECTORY data DESTINATION ${EXAMPLES_INSTALL_DIRECTORY}) ENDIF() diff --git a/doc/examples/cartesian_algo.py b/doc/examples/cartesian_algo.py index da86cf423..584d66715 100644 --- a/doc/examples/cartesian_algo.py +++ b/doc/examples/cartesian_algo.py @@ -1,26 +1,23 @@ # Usage of Body Fitting algorithm - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a sphere -sphere = geompy.MakeSphereR( 50 ) +sphere = geom_builder.MakeSphereR( 50 ) # cut the sphere by a box -box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) -partition = geompy.MakePartition([ sphere ], [ box ], theName="partition") +box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 ) +partition = geom_builder.MakePartition([ sphere ], [ box ], theName="partition") # create a mesh and assign a "Body Fitting" algo -mesh = smesh.Mesh( partition ) +mesh = smesh_builder.Mesh( partition ) cartAlgo = mesh.BodyFitted() # define a cartesian grid using Coordinates @@ -76,16 +73,16 @@ print() # Example of customization of dirtections of the grid axes # make a box with non-orthogonal edges -xDir = geompy.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" ) -yDir = geompy.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" ) -zDir = geompy.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" ) -face = geompy.MakePrismVecH( xDir, yDir, 1.0 ) -box = geompy.MakePrismVecH( face, zDir, 1.0, theName="box" ) +xDir = geom_builder.MakeVectorDXDYDZ( 1.0, 0.1, 0.0, "xDir" ) +yDir = geom_builder.MakeVectorDXDYDZ(-0.1, 1.0, 0.0, "yDir" ) +zDir = geom_builder.MakeVectorDXDYDZ( 0.2, 0.3, 1.0, "zDir" ) +face = geom_builder.MakePrismVecH( xDir, yDir, 1.0 ) +box = geom_builder.MakePrismVecH( face, zDir, 1.0, theName="box" ) spc = "0.1" # spacing # default axes -mesh = smesh.Mesh( box, "custom axes") +mesh = smesh_builder.Mesh( box, "custom axes") algo = mesh.BodyFitted() algo.SetGrid( spc, spc, spc, 10000 ) mesh.Compute() diff --git a/doc/examples/creating_meshes_ex01.py b/doc/examples/creating_meshes_ex01.py index ba8563d6d..e5cb0e934 100644 --- a/doc/examples/creating_meshes_ex01.py +++ b/doc/examples/creating_meshes_ex01.py @@ -2,20 +2,19 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -tetra = smesh.Mesh(box, "MeshBox") +tetra = smesh_builder.Mesh(box, "MeshBox") algo1D = tetra.Segment() algo1D.NumberOfSegments(7) diff --git a/doc/examples/creating_meshes_ex02.py b/doc/examples/creating_meshes_ex02.py index 8a8966a3f..676708c68 100644 --- a/doc/examples/creating_meshes_ex02.py +++ b/doc/examples/creating_meshes_ex02.py @@ -2,25 +2,24 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.) +geom_builder.addToStudy(box, "Box") # select one edge of the box for definition of a local hypothesis -p5 = geompy.MakeVertex(5., 0., 0.) -EdgeX = geompy.GetEdgeNearPoint(box, p5) -geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geom_builder.MakeVertex(5., 0., 0.) +EdgeX = geom_builder.GetEdgeNearPoint(box, p5) +geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box -mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh") +mesh = smesh_builder.Mesh(box, "Box : hexahedral 3D mesh") # create a Regular_1D algorithm for discretization of edges algo1D = mesh.Segment() @@ -46,12 +45,11 @@ algo_local.Propagation() # assign a hexahedral algorithm mesh.Hexahedron() - # any sub-shape can be meshed individually -- # compute mesh on two surfaces using different methods # get surfaces -surfaces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +surfaces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) # method 1: no sub-mesh is created mesh.Compute( surfaces[0] ) @@ -60,7 +58,5 @@ mesh.Compute( surfaces[0] ) submesh = mesh.GetSubMesh( surfaces[2], "submesh 2" ) submesh.Compute() - - # compute the whole mesh mesh.Compute() diff --git a/doc/examples/creating_meshes_ex03.py b/doc/examples/creating_meshes_ex03.py index fc20d3660..5ad4e10a0 100644 --- a/doc/examples/creating_meshes_ex03.py +++ b/doc/examples/creating_meshes_ex03.py @@ -2,19 +2,18 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"]) +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200) +[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geom_builder.SubShapeAllSorted(Box_1, geom_builder.ShapeType["FACE"]) # create Mesh object on Box shape -Mesh_1 = smesh.Mesh(Box_1) +Mesh_1 = smesh_builder.Mesh(Box_1) # assign mesh algorithms and hypotheses Regular_1D = Mesh_1.Segment() diff --git a/doc/examples/creating_meshes_ex04.py b/doc/examples/creating_meshes_ex04.py index 7101a0226..3298e971c 100644 --- a/doc/examples/creating_meshes_ex04.py +++ b/doc/examples/creating_meshes_ex04.py @@ -2,13 +2,12 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() def PrintMeshInfo(theMesh): aMesh = theMesh.GetMesh() @@ -20,17 +19,17 @@ def PrintMeshInfo(theMesh): pass # create a box -box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) -geompy.addToStudy(box, "box") +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.) +geom_builder.addToStudy(box, "box") # select one edge of the box for definition of a local hypothesis -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) +subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["EDGE"]) edge = subShapeList[0] -name = geompy.SubShapeName(edge, box) -geompy.addToStudyInFather(box, edge, name) +name = geom_builder.SubShapeName(edge, box) +geom_builder.addToStudyInFather(box, edge, name) # create a mesh -tria = smesh.Mesh(box, "Mesh 2D") +tria = smesh_builder.Mesh(box, "Mesh 2D") algo1D = tria.Segment() hyp1 = algo1D.NumberOfSegments(3) algo2D = tria.Triangle() diff --git a/doc/examples/creating_meshes_ex05.py b/doc/examples/creating_meshes_ex05.py index 725c7e953..5c2ab863b 100644 --- a/doc/examples/creating_meshes_ex05.py +++ b/doc/examples/creating_meshes_ex05.py @@ -1,21 +1,24 @@ # Export of a Mesh +import os +import tempfile +import MEDLoader + import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -tetra = smesh.Mesh(box, "MeshBox") +tetra = smesh_builder.Mesh(box, "MeshBox") tetra.Segment().NumberOfSegments(7) tetra.Triangle() tetra.Tetrahedron() @@ -24,12 +27,11 @@ tetra.Tetrahedron() tetra.Compute() # export the mesh in a MED file -import tempfile medFile = tempfile.NamedTemporaryFile(suffix=".med").name tetra.ExportMED( medFile, 0 ) # export a group in a MED file -face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side +face = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0] # a box side group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the tetra.ExportMED( medFile, meshPart=group ) @@ -37,12 +39,10 @@ tetra.ExportMED( medFile, meshPart=group ) # autoDimension parameter # ======================== -face = geompy.MakeFaceHW( 10, 10, 1, "rectangle" ) -mesh2D = smesh.Mesh( face, "mesh2D" ) +face = geom_builder.MakeFaceHW( 10, 10, 1, "rectangle" ) +mesh2D = smesh_builder.Mesh( face, "mesh2D" ) mesh2D.AutomaticHexahedralization(0) -import MEDLoader, os - # exported mesh is in 2D space because it is a planar mesh lying # on XOY plane, and autoDimension=True by default mesh2D.ExportMED( medFile ) diff --git a/doc/examples/creating_meshes_ex06.py b/doc/examples/creating_meshes_ex06.py index 60360e14b..a460eeb8b 100644 --- a/doc/examples/creating_meshes_ex06.py +++ b/doc/examples/creating_meshes_ex06.py @@ -2,19 +2,19 @@ # # This example uses Partition to divide the cylinder into blocks, which is # a general approach. But for the case of cylinder there is a dedicated -# command creating a blocked cylinder: geompy.MakeDividedCylinder() +# command creating a blocked cylinder: geom_builder.MakeDividedCylinder() + +import math import salome salome.salome_init_without_session() + import GEOM from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import math +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Parameters # ---------- @@ -25,87 +25,87 @@ height = 200 # Build a cylinder # ---------------- -base = geompy.MakeVertex(0, 0, 0) -direction = geompy.MakeVectorDXDYDZ(0, 0, 1) +base = geom_builder.MakeVertex(0, 0, 0) +direction = geom_builder.MakeVectorDXDYDZ(0, 0, 1) -cylinder = geompy.MakeCylinder(base, direction, radius, height) +cylinder = geom_builder.MakeCylinder(base, direction, radius, height) -geompy.addToStudy(cylinder, "cylinder") +geom_builder.addToStudy(cylinder, "cylinder") # Build blocks # ------------ size = radius/2.0 -box_rot = geompy.MakeBox(-size, -size, 0, +size, +size, height) -box_axis = geompy.MakeLine(base, direction) -box = geompy.MakeRotation(box_rot, box_axis, math.pi/4) +box_rot = geom_builder.MakeBox(-size, -size, 0, +size, +size, height) +box_axis = geom_builder.MakeLine(base, direction) +box = geom_builder.MakeRotation(box_rot, box_axis, math.pi/4) -hole = geompy.MakeCut(cylinder, box) +hole = geom_builder.MakeCut(cylinder, box) plane_trim = 2000 -plane_a = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim) -plane_b = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim) +plane_a = geom_builder.MakePlane(base, geom_builder.MakeVectorDXDYDZ(1, 0, 0), plane_trim) +plane_b = geom_builder.MakePlane(base, geom_builder.MakeVectorDXDYDZ(0, 1, 0), plane_trim) -blocks_part = geompy.MakePartition([hole], [plane_a, plane_b], [], [], geompy.ShapeType["SOLID"]) -blocks_list = [box] + geompy.SubShapeAll(blocks_part, geompy.ShapeType["SOLID"]) -blocks_all = geompy.MakeCompound(blocks_list) -blocks = geompy.MakeGlueFaces(blocks_all, 0.0001) +blocks_part = geom_builder.MakePartition([hole], [plane_a, plane_b], [], [], geom_builder.ShapeType["SOLID"]) +blocks_list = [box] + geom_builder.SubShapeAll(blocks_part, geom_builder.ShapeType["SOLID"]) +blocks_all = geom_builder.MakeCompound(blocks_list) +blocks = geom_builder.MakeGlueFaces(blocks_all, 0.0001) -geompy.addToStudy(blocks, "cylinder:blocks") +geom_builder.addToStudy(blocks, "cylinder:blocks") # Build geometric groups # ---------------------- -group_a = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"]) -geompy.addToStudyInFather(blocks, group_a, "baseA") -items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base, GEOM.ST_ON) -geompy.UnionIDs(group_a, items) +group_a = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["FACE"]) +geom_builder.addToStudyInFather(blocks, group_a, "baseA") +items = geom_builder.GetShapesOnPlaneWithLocationIDs(blocks, geom_builder.ShapeType["FACE"], direction, base, GEOM.ST_ON) +geom_builder.UnionIDs(group_a, items) -base_b = geompy.MakeVertex(0, 0, height) -group_b = geompy.CreateGroup(blocks, geompy.ShapeType["FACE"]) -geompy.addToStudyInFather(blocks, group_b, "baseB") -items = geompy.GetShapesOnPlaneWithLocationIDs(blocks, geompy.ShapeType["FACE"], direction, base_b, GEOM.ST_ON) -geompy.UnionIDs(group_b, items) +base_b = geom_builder.MakeVertex(0, 0, height) +group_b = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["FACE"]) +geom_builder.addToStudyInFather(blocks, group_b, "baseB") +items = geom_builder.GetShapesOnPlaneWithLocationIDs(blocks, geom_builder.ShapeType["FACE"], direction, base_b, GEOM.ST_ON) +geom_builder.UnionIDs(group_b, items) -group_1 = geompy.CreateGroup(blocks, geompy.ShapeType["SOLID"]) -geompy.addToStudyInFather(blocks, group_1, "limit") -group_1_all = geompy.SubShapeAllIDs(blocks, geompy.ShapeType["SOLID"]) -geompy.UnionIDs(group_1, group_1_all) -group_1_box = geompy.GetBlockNearPoint(blocks, base) -geompy.DifferenceList(group_1, [group_1_box]) +group_1 = geom_builder.CreateGroup(blocks, geom_builder.ShapeType["SOLID"]) +geom_builder.addToStudyInFather(blocks, group_1, "limit") +group_1_all = geom_builder.SubShapeAllIDs(blocks, geom_builder.ShapeType["SOLID"]) +geom_builder.UnionIDs(group_1, group_1_all) +group_1_box = geom_builder.GetBlockNearPoint(blocks, base) +geom_builder.DifferenceList(group_1, [group_1_box]) # Mesh the blocks with hexahedral # ------------------------------- -smesh.UpdateStudy() +smesh_builder.UpdateStudy() -hexa = smesh.Mesh(blocks) +hexa = smesh_builder.Mesh(blocks) hexa_1d = hexa.Segment() hexa_1d.NumberOfSegments(1) -vertex = geompy.MakeVertex(+radius, +radius, 0) -edge = geompy.GetEdgeNearPoint(blocks, vertex) +vertex = geom_builder.MakeVertex(+radius, +radius, 0) +edge = geom_builder.GetEdgeNearPoint(blocks, vertex) algo = hexa.Segment(edge) algo.NumberOfSegments(5) algo.Propagation() -vertex = geompy.MakeVertex(-radius, +radius, 0) -edge = geompy.GetEdgeNearPoint(blocks, vertex) +vertex = geom_builder.MakeVertex(-radius, +radius, 0) +edge = geom_builder.GetEdgeNearPoint(blocks, vertex) algo = hexa.Segment(edge) algo.NumberOfSegments(8) algo.Propagation() -vertex = geompy.MakeVertex((radius+size)/2, 0, 0) -edge = geompy.GetEdgeNearPoint(blocks, vertex) +vertex = geom_builder.MakeVertex((radius+size)/2, 0, 0) +edge = geom_builder.GetEdgeNearPoint(blocks, vertex) algo = hexa.Segment(edge) algo.NumberOfSegments(10) algo.Propagation() -vertex = geompy.MakeVertex(+radius, 0, height/2) -edge = geompy.GetEdgeNearPoint(blocks, vertex) +vertex = geom_builder.MakeVertex(+radius, 0, height/2) +edge = geom_builder.GetEdgeNearPoint(blocks, vertex) algo = hexa.Segment(edge) algo.NumberOfSegments(20) algo.Propagation() diff --git a/doc/examples/creating_meshes_ex07.py b/doc/examples/creating_meshes_ex07.py index f18109cda..4a181c237 100644 --- a/doc/examples/creating_meshes_ex07.py +++ b/doc/examples/creating_meshes_ex07.py @@ -2,44 +2,46 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() ## create a bottom box -Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.) +Box_inf = geom_builder.MakeBox(0., 0., 0., 200., 200., 50.) # get a top face -Psup1=geompy.MakeVertex(100., 100., 50.) -Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1) +Psup1=geom_builder.MakeVertex(100., 100., 50.) +Fsup1=geom_builder.GetFaceNearPoint(Box_inf, Psup1) # get a bottom face -Pinf1=geompy.MakeVertex(100., 100., 0.) -Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1) +Pinf1=geom_builder.MakeVertex(100., 100., 0.) +Finf1=geom_builder.GetFaceNearPoint(Box_inf, Pinf1) ## create a top box -Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.) +Box_sup = geom_builder.MakeBox(100., 100., 50., 200., 200., 100.) # get a top face -Psup2=geompy.MakeVertex(150., 150., 100.) -Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2) +Psup2=geom_builder.MakeVertex(150., 150., 100.) +Fsup2=geom_builder.GetFaceNearPoint(Box_sup, Psup2) # get a bottom face -Pinf2=geompy.MakeVertex(150., 150., 50.) -Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2) +Pinf2=geom_builder.MakeVertex(150., 150., 50.) +Finf2=geom_builder.GetFaceNearPoint(Box_sup, Pinf2) ## Publish in the study -geompy.addToStudy(Box_inf, "Box_inf") -geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup") -geompy.addToStudyInFather(Box_inf, Finf1, "Finf") +geom_builder.addToStudy(Box_inf, "Box_inf") +geom_builder.addToStudyInFather(Box_inf, Fsup1, "Fsup") +geom_builder.addToStudyInFather(Box_inf, Finf1, "Finf") -geompy.addToStudy(Box_sup, "Box_sup") -geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup") -geompy.addToStudyInFather(Box_sup, Finf2, "Finf") +geom_builder.addToStudy(Box_sup, "Box_sup") +geom_builder.addToStudyInFather(Box_sup, Fsup2, "Fsup") +geom_builder.addToStudyInFather(Box_sup, Finf2, "Finf") -smesh.UpdateStudy() +smesh_builder.UpdateStudy() ## create a bottom mesh -Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf") +Mesh_inf = smesh_builder.Mesh(Box_inf, "Mesh_inf") algo1D_1=Mesh_inf.Segment() algo1D_1.NumberOfSegments(10) algo2D_1=Mesh_inf.Quadrangle() @@ -52,7 +54,7 @@ Gsup1=Mesh_inf.Group(Fsup1, "Sup") Ginf1=Mesh_inf.Group(Finf1, "Inf") ## create a top mesh -Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup") +Mesh_sup = smesh_builder.Mesh(Box_sup, "Mesh_sup") algo1D_2=Mesh_sup.Segment() algo1D_2.NumberOfSegments(5) algo2D_2=Mesh_sup.Quadrangle() @@ -67,19 +69,18 @@ Ginf2=Mesh_sup.Group(Finf2, "Inf") ## create compounds # create a compound of two meshes with renaming namesake groups and # merging elements with the given tolerance -Compound1 = smesh.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05, - name='Compound with RenamedGrps and MergeElems') +Compound1 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 0, 1, 1e-05, + name='Compound with RenamedGrps and MergeElems') # create a compound of two meshes with uniting namesake groups and # creating groups of all elements -Compound2 = smesh.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True, - name='Compound with UniteGrps and GrpsOfAllElems') +Compound2 = smesh_builder.Concatenate([Mesh_inf, Mesh_sup], 1, 0, 1e-05, True, + name='Compound with UniteGrps and GrpsOfAllElems') # copy Gsup1 into a separate mesh and translate it groupMesh = Mesh_inf.TranslateObjectMakeMesh( Gsup1, [300,0,0] ) # add Ginf2 to groupMesh -smesh.Concatenate([Ginf2], False, meshToAppendTo = groupMesh ) - +smesh_builder.Concatenate([Ginf2], False, meshToAppendTo = groupMesh ) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() diff --git a/doc/examples/creating_meshes_ex08.py b/doc/examples/creating_meshes_ex08.py index 2f506fa2b..71fdff73b 100644 --- a/doc/examples/creating_meshes_ex08.py +++ b/doc/examples/creating_meshes_ex08.py @@ -2,20 +2,20 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make geometry of a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0] +box = geom_builder.MakeBoxDXDYDZ(100,100,100) +face = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"])[0] # generate a prismatic 3D mesh -mesh = smesh.Mesh(box, "box") +mesh = smesh_builder.Mesh(box, "box") localAlgo = mesh.Triangle(face) mesh.Segment().NumberOfSegments( 3 ) mesh.Quadrangle() @@ -30,30 +30,30 @@ subMesh = localAlgo.GetSubMesh() # make a new mesh by copying different parts of the mesh # 1. copy the whole mesh -newMesh = smesh.CopyMesh( mesh, "whole mesh copy") +newMesh = smesh_builder.CopyMesh( mesh, "whole mesh copy") # 2. copy a group of 2D elements along with groups -newMesh = smesh.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True) +newMesh = smesh_builder.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True) # 3. copy a group of nodes -newMesh = smesh.CopyMesh( nGroup, "node group copy") +newMesh = smesh_builder.CopyMesh( nGroup, "node group copy") # 4. copy some faces faceIds = fGroup.GetIDs()[-10:] -newMesh = smesh.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy") +newMesh = smesh_builder.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy") # 5. copy some nodes nodeIds = nGroup.GetIDs()[-10:] -newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy") +newMesh = smesh_builder.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy") # 6. copy a sub-mesh -newMesh = smesh.CopyMesh( subMesh, "sub-mesh copy" ) +newMesh = smesh_builder.CopyMesh( subMesh, "sub-mesh copy" ) # make a new mesh with same hypotheses on a modified geometry -smallBox = geompy.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 ) -cutBox = geompy.MakeCut( box, smallBox, theName="box - smallBox" ) +smallBox = geom_builder.MakeScaleAlongAxes( box, None, 1, 0.5, 0.5 ) +cutBox = geom_builder.MakeCut( box, smallBox, theName="box - smallBox" ) -ok, newMesh, groups, submehses, hyps, invIDs = smesh.CopyMeshWithGeom( mesh, cutBox, "cutBox" ) +ok, newMesh, groups, submehses, hyps, invIDs = smesh_builder.CopyMeshWithGeom( mesh, cutBox, "cutBox" ) newMesh.Compute() diff --git a/doc/examples/defining_hypotheses_adaptive1d.py b/doc/examples/defining_hypotheses_adaptive1d.py index 48d927daa..d28342a19 100644 --- a/doc/examples/defining_hypotheses_adaptive1d.py +++ b/doc/examples/defining_hypotheses_adaptive1d.py @@ -1,20 +1,25 @@ -import salome, math +# Usage of Adaptive 1D hypothesis + +import math + +import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) -tool = geompy.MakeTranslation( box, 50, 0, 10 ) -axis = geompy.MakeVector( geompy.MakeVertex( 100, 0, 100 ),geompy.MakeVertex( 100, 10, 100 ),) -tool = geompy.Rotate( tool, axis, math.pi * 25 / 180. ) -shape = geompy.MakeCut( box, tool ) -cyl = geompy.MakeCylinder( geompy.MakeVertex( -10,5, 95 ), geompy.MakeVectorDXDYDZ(1,0,0), 2, 90) -shape = geompy.MakeCut( shape, cyl ) -tool = geompy.MakeBoxTwoPnt( geompy.MakeVertex( -10, 2, 15 ), geompy.MakeVertex( 90, 5, 16 )) -shape = geompy.MakeCut( shape, tool, theName="shape" ) +box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 ) +tool = geom_builder.MakeTranslation( box, 50, 0, 10 ) +axis = geom_builder.MakeVector( geom_builder.MakeVertex( 100, 0, 100 ),geom_builder.MakeVertex( 100, 10, 100 ),) +tool = geom_builder.Rotate( tool, axis, math.pi * 25 / 180. ) +shape = geom_builder.MakeCut( box, tool ) +cyl = geom_builder.MakeCylinder( geom_builder.MakeVertex( -10,5, 95 ), geom_builder.MakeVectorDXDYDZ(1,0,0), 2, 90) +shape = geom_builder.MakeCut( shape, cyl ) +tool = geom_builder.MakeBoxTwoPnt( geom_builder.MakeVertex( -10, 2, 15 ), geom_builder.MakeVertex( 90, 5, 16 )) +shape = geom_builder.MakeCut( shape, tool, theName="shape" ) # Parameters of Adaptive hypothesis. minSize and maxSize are such that they do not limit # size of segments because size of geometrical features lies within [2.-100.] range, hence @@ -23,8 +28,7 @@ minSize = 0.1 maxSize = 200 deflection = 0.05 -mesh = smesh.Mesh( shape ) +mesh = smesh_builder.Mesh( shape ) mesh.Segment().Adaptive( minSize, maxSize, deflection ) mesh.Triangle().MaxElementArea( 300 ) mesh.Compute() - diff --git a/doc/examples/defining_hypotheses_ex01.py b/doc/examples/defining_hypotheses_ex01.py index 0a2401d52..734c7ea02 100644 --- a/doc/examples/defining_hypotheses_ex01.py +++ b/doc/examples/defining_hypotheses_ex01.py @@ -4,23 +4,23 @@ import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() - from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.) +geom_builder.addToStudy(box, "Box") # create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") +hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh") # create a Regular 1D algorithm for edges algo1D = hexa.Segment() # optionally reverse node distribution on certain edges -allEdges = geompy.SubShapeAllSorted( box, geompy.ShapeType["EDGE"]) +allEdges = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["EDGE"]) reversedEdges = [ allEdges[0], allEdges[4] ] # define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length @@ -33,7 +33,6 @@ gpAlgo.GeometricProgression( 1, 1.2 ) # propagate distribution of nodes computed using "Geometric Progression" to parallel edges gpAlgo.PropagationOfDistribution() - # create a quadrangle 2D algorithm for faces hexa.Quadrangle() diff --git a/doc/examples/defining_hypotheses_ex02.py b/doc/examples/defining_hypotheses_ex02.py index c5a5ce205..29e15745d 100644 --- a/doc/examples/defining_hypotheses_ex02.py +++ b/doc/examples/defining_hypotheses_ex02.py @@ -2,34 +2,33 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a face from arc and straight segment -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) +px = geom_builder.MakeVertex(100., 0. , 0. ) +py = geom_builder.MakeVertex(0. , 100., 0. ) +pz = geom_builder.MakeVertex(0. , 0. , 100.) -exy = geompy.MakeEdge(px, py) -arc = geompy.MakeArc(py, pz, px) +exy = geom_builder.MakeEdge(px, py) +arc = geom_builder.MakeArc(py, pz, px) -wire = geompy.MakeWire([exy, arc]) +wire = geom_builder.MakeWire([exy, arc]) isPlanarFace = 1 -face1 = geompy.MakeFace(wire, isPlanarFace) -geompy.addToStudy(face1,"Face1") +face1 = geom_builder.MakeFace(wire, isPlanarFace) +geom_builder.addToStudy(face1,"Face1") # get edges from the face -e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"]) -geompy.addToStudyInFather(face1, e_arc, "Arc Edge") +e_straight,e_arc = geom_builder.SubShapeAll(face1, geom_builder.ShapeType["EDGE"]) +geom_builder.addToStudyInFather(face1, e_arc, "Arc Edge") # create hexahedral mesh -hexa = smesh.Mesh(face1, "Face : triangle mesh") +hexa = smesh_builder.Mesh(face1, "Face : triangle mesh") # define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments algo1D = hexa.Segment() diff --git a/doc/examples/defining_hypotheses_ex03.py b/doc/examples/defining_hypotheses_ex03.py index 14af89e19..21be409db 100644 --- a/doc/examples/defining_hypotheses_ex03.py +++ b/doc/examples/defining_hypotheses_ex03.py @@ -2,25 +2,24 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.) +geom_builder.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = geompy.MakeVertex(5., 0., 0.) -EdgeX = geompy.GetEdgeNearPoint(box, p5) -geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geom_builder.MakeVertex(5., 0., 0.) +EdgeX = geom_builder.GetEdgeNearPoint(box, p5) +geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") +hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh") # set algorithms algo1D = hexa.Segment() diff --git a/doc/examples/defining_hypotheses_ex04.py b/doc/examples/defining_hypotheses_ex04.py index bb38eeb9d..043ff1e44 100644 --- a/doc/examples/defining_hypotheses_ex04.py +++ b/doc/examples/defining_hypotheses_ex04.py @@ -2,25 +2,24 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.) +geom_builder.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = geompy.MakeVertex(5., 0., 0.) -EdgeX = geompy.GetEdgeNearPoint(box, p5) -geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geom_builder.MakeVertex(5., 0., 0.) +EdgeX = geom_builder.GetEdgeNearPoint(box, p5) +geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") +hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh") # set algorithms algo1D = hexa.Segment() diff --git a/doc/examples/defining_hypotheses_ex05.py b/doc/examples/defining_hypotheses_ex05.py index 25fe5429f..4b2d1a75b 100644 --- a/doc/examples/defining_hypotheses_ex05.py +++ b/doc/examples/defining_hypotheses_ex05.py @@ -2,31 +2,30 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a face -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) +px = geom_builder.MakeVertex(100., 0. , 0. ) +py = geom_builder.MakeVertex(0. , 100., 0. ) +pz = geom_builder.MakeVertex(0. , 0. , 100.) -vxy = geompy.MakeVector(px, py) -arc = geompy.MakeArc(py, pz, px) -wire = geompy.MakeWire([vxy, arc]) +vxy = geom_builder.MakeVector(px, py) +arc = geom_builder.MakeArc(py, pz, px) +wire = geom_builder.MakeWire([vxy, arc]) isPlanarFace = 1 -face = geompy.MakeFace(wire, isPlanarFace) +face = geom_builder.MakeFace(wire, isPlanarFace) # add the face in the study -id_face = geompy.addToStudy(face, "Face to be meshed") +id_face = geom_builder.addToStudy(face, "Face to be meshed") # create a mesh -tria_mesh = smesh.Mesh(face, "Face : triangulation") +tria_mesh = smesh_builder.Mesh(face, "Face : triangulation") # define 1D meshing: algo = tria_mesh.Segment() diff --git a/doc/examples/defining_hypotheses_ex06.py b/doc/examples/defining_hypotheses_ex06.py index 687de13f7..aa0cb45bf 100644 --- a/doc/examples/defining_hypotheses_ex06.py +++ b/doc/examples/defining_hypotheses_ex06.py @@ -2,20 +2,19 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +from salome.geom import geomBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a cylinder -cyl = geompy.MakeCylinderRH(30., 50.) -geompy.addToStudy(cyl, "cyl") +cyl = geom_builder.MakeCylinderRH(30., 50.) +geom_builder.addToStudy(cyl, "cyl") # create a mesh on the cylinder -tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh") +tetra = smesh_builder.Mesh(cyl, "Cylinder : tetrahedrical mesh") # assign algorithms algo1D = tetra.Segment() diff --git a/doc/examples/defining_hypotheses_ex07.py b/doc/examples/defining_hypotheses_ex07.py index 2beb838d2..7295778f0 100644 --- a/doc/examples/defining_hypotheses_ex07.py +++ b/doc/examples/defining_hypotheses_ex07.py @@ -2,25 +2,24 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create sketchers -sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") -sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") +sketcher1 = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") +sketcher2 = geom_builder.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") # create a face from two wires isPlanarFace = 1 -face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace) -geompy.addToStudy(face1, "Face1") +face1 = geom_builder.MakeFaces([sketcher1, sketcher2], isPlanarFace) +geom_builder.addToStudy(face1, "Face1") # create a mesh -tria = smesh.Mesh(face1, "Face : triangle 2D mesh") +tria = smesh_builder.Mesh(face1, "Face : triangle 2D mesh") # Define 1D meshing algo1D = tria.Segment() diff --git a/doc/examples/defining_hypotheses_ex08.py b/doc/examples/defining_hypotheses_ex08.py index ee0af3912..43d77f1c2 100644 --- a/doc/examples/defining_hypotheses_ex08.py +++ b/doc/examples/defining_hypotheses_ex08.py @@ -2,26 +2,25 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -base = geompy.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 20 10:TT 0 10:WF", theName="F") -box = geompy.MakePrismDXDYDZ( base, 0,0,10 ) -geompy.addToStudy(box, "Box") +base = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 20 10:TT 0 10:WF", theName="F") +box = geom_builder.MakePrismDXDYDZ( base, 0,0,10 ) +geom_builder.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = geompy.MakeVertex(5., 0., 0.) -EdgeX = geompy.GetEdgeNearPoint(box, p5) -geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geom_builder.MakeVertex(5., 0., 0.) +EdgeX = geom_builder.GetEdgeNearPoint(box, p5) +geom_builder.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Propagation of hypothesis") +hexa = smesh_builder.Mesh(box, "Propagation of hypothesis") # set global algorithms and hypotheses algo1D = hexa.Segment() @@ -42,9 +41,8 @@ algo_local.Propagation() # compute the mesh which contains prisms hexa.Compute() - # create another mesh on the box -mesh = smesh.Mesh(box, "Propagation of distribution of nodes") +mesh = smesh_builder.Mesh(box, "Propagation of distribution of nodes") # set global algorithms and hypotheses algo1D = mesh.Segment() diff --git a/doc/examples/defining_hypotheses_ex09.py b/doc/examples/defining_hypotheses_ex09.py index 7ac2a0fb4..c9cc52f61 100644 --- a/doc/examples/defining_hypotheses_ex09.py +++ b/doc/examples/defining_hypotheses_ex09.py @@ -2,20 +2,19 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ(10., 10., 10.) +geom_builder.addToStudy(box, "Box") # Create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") +hexa = smesh_builder.Mesh(box, "Box : hexahedrical mesh") # create a Regular 1D algorithm for edges algo1D = hexa.Segment() @@ -33,7 +32,7 @@ algo1D.Arithmetic1D(1, 4) hexa.Compute() # 2. Create a tetrahedral mesh on the box -tetra = smesh.Mesh(box, "Box : tetrahedrical mesh") +tetra = smesh_builder.Mesh(box, "Box : tetrahedrical mesh") # create a Regular 1D algorithm for edges algo1D = tetra.Segment() diff --git a/doc/examples/defining_hypotheses_ex10.py b/doc/examples/defining_hypotheses_ex10.py index 0801c2cfc..0a1b3d85c 100644 --- a/doc/examples/defining_hypotheses_ex10.py +++ b/doc/examples/defining_hypotheses_ex10.py @@ -4,58 +4,55 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Prepare geometry # Create a parallelepiped -box = geompy.MakeBoxDXDYDZ(200, 100, 70) -geompy.addToStudy( box, "box" ) +box = geom_builder.MakeBoxDXDYDZ(200, 100, 70) +geom_builder.addToStudy( box, "box" ) # Get geom faces to mesh with triangles in the 1ts and 2nd meshes -faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +faces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) # 2 adjacent faces of the box f1 = faces[2] f2 = faces[0] # face opposite to f2 -f2opp = geompy.GetOppositeFace( box, f2 ) +f2opp = geom_builder.GetOppositeFace( box, f2 ) # Get vertices used to specify how to associate sides of faces at projection -[v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2] -[v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2] -geompy.addToStudyInFather( box, v1F1, "v1F1" ) -geompy.addToStudyInFather( box, v2F1, "v2F1" ) -geompy.addToStudyInFather( box, v1F2, "v1F2" ) -geompy.addToStudyInFather( box, v2F2, "v2F2" ) +[v1F1, v2F1] = geom_builder.SubShapeAll(f1, geom_builder.ShapeType["VERTEX"])[:2] +[v1F2, v2F2] = geom_builder.SubShapeAll(f2, geom_builder.ShapeType["VERTEX"])[:2] +geom_builder.addToStudyInFather( box, v1F1, "v1F1" ) +geom_builder.addToStudyInFather( box, v2F1, "v2F1" ) +geom_builder.addToStudyInFather( box, v1F2, "v1F2" ) +geom_builder.addToStudyInFather( box, v2F2, "v2F2" ) # Make group of 3 edges of f1 and f2 -edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"]) -geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3]) -edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"]) -geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3]) -geompy.addToStudyInFather( box, edgesF1, "edgesF1" ) -geompy.addToStudyInFather( box, edgesF2, "edgesF2" ) - +edgesF1 = geom_builder.CreateGroup(f1, geom_builder.ShapeType["EDGE"]) +geom_builder.UnionList( edgesF1, geom_builder.SubShapeAll(f1, geom_builder.ShapeType["EDGE"])[:3]) +edgesF2 = geom_builder.CreateGroup(f2, geom_builder.ShapeType["EDGE"]) +geom_builder.UnionList( edgesF2, geom_builder.SubShapeAll(f2, geom_builder.ShapeType["EDGE"])[:3]) +geom_builder.addToStudyInFather( box, edgesF1, "edgesF1" ) +geom_builder.addToStudyInFather( box, edgesF2, "edgesF2" ) # Make the source mesh with prisms -src_mesh = smesh.Mesh(box, "Source mesh") +src_mesh = smesh_builder.Mesh(box, "Source mesh") src_mesh.Segment().NumberOfSegments(9,10) src_mesh.Quadrangle() src_mesh.Hexahedron() src_mesh.Triangle(f1) # triangular sub-mesh src_mesh.Compute() - # Mesh the box using projection algorithms # Define the same global 1D and 2D hypotheses -tgt_mesh = smesh.Mesh(box, "Target mesh") +tgt_mesh = smesh_builder.Mesh(box, "Target mesh") tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True) tgt_mesh.Quadrangle() @@ -81,4 +78,4 @@ proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 ) tgt_mesh.Compute() # Move the source mesh to visually compare the two meshes -src_mesh.TranslateObject( src_mesh, smesh.MakeDirStruct( 210, 0, 0 ), Copy=False) +src_mesh.TranslateObject( src_mesh, smesh_builder.MakeDirStruct( 210, 0, 0 ), Copy=False) diff --git a/doc/examples/defining_hypotheses_ex11.py b/doc/examples/defining_hypotheses_ex11.py index 5e85222ad..d2ffdcc6d 100644 --- a/doc/examples/defining_hypotheses_ex11.py +++ b/doc/examples/defining_hypotheses_ex11.py @@ -1,40 +1,37 @@ # Projection 1D2D - # Project triangles from one meshed face to another mesh on the same box import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Prepare geometry # Create a box -box = geompy.MakeBoxDXDYDZ(100, 100, 100) +box = geom_builder.MakeBoxDXDYDZ(100, 100, 100) # Get geom faces to mesh with triangles in the 1ts and 2nd meshes -faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +faces = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) # 2 adjacent faces of the box Face_1 = faces[2] Face_2 = faces[0] -geompy.addToStudy( box, 'box' ) -geompy.addToStudyInFather( box, Face_1, 'Face_1' ) -geompy.addToStudyInFather( box, Face_2, 'Face_2' ) - +geom_builder.addToStudy( box, 'box' ) +geom_builder.addToStudyInFather( box, Face_1, 'Face_1' ) +geom_builder.addToStudyInFather( box, Face_2, 'Face_2' ) # Make the source mesh triangulated by MEFISTO -src_mesh = smesh.Mesh(Face_1, "Source mesh") +src_mesh = smesh_builder.Mesh(Face_1, "Source mesh") src_mesh.Segment().NumberOfSegments(15) src_mesh.Triangle() src_mesh.Compute() # Mesh the target mesh using the algorithm Projection1D2D -tgt_mesh = smesh.Mesh(Face_2, "Target mesh") +tgt_mesh = smesh_builder.Mesh(Face_2, "Target mesh") tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh) tgt_mesh.Compute() diff --git a/doc/examples/defining_hypotheses_ex12.py b/doc/examples/defining_hypotheses_ex12.py index 9db644836..d7f9ff5b6 100644 --- a/doc/examples/defining_hypotheses_ex12.py +++ b/doc/examples/defining_hypotheses_ex12.py @@ -2,25 +2,23 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -from salome.StdMeshers import StdMeshersBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Create face and explode it on edges -face = geompy.MakeFaceHW(100, 100, 1) -edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"]) -geompy.addToStudy( face, "Face" ) +face = geom_builder.MakeFaceHW(100, 100, 1) +edges = geom_builder.SubShapeAllSorted(face, geom_builder.ShapeType["EDGE"]) +geom_builder.addToStudy( face, "Face" ) # get the first edge from exploded result -edge1 = geompy.GetSubShapeID(face, edges[0]) +edge1 = geom_builder.GetSubShapeID(face, edges[0]) # Define Mesh on previously created face -Mesh_1 = smesh.Mesh(face) +Mesh_1 = smesh_builder.Mesh(face) # Create Fixed Point 1D hypothesis and define parameters. # Note: values greater than 1.0 and less than 0.0 are not taken into account; @@ -29,7 +27,7 @@ Mesh_1 = smesh.Mesh(face) # The number of segments should correspond to the number of points (NbSeg = NbPnt-1); # extra values of segments splitting parameter are not taken into account, # while missing values are considered to be equal to 1. -Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D') +Fixed_points_1D_1 = smesh_builder.CreateHypothesis('FixedPoints1D') Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] ) Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] ) Fixed_points_1D_1.SetReversedEdges( [edge1] ) diff --git a/doc/examples/defining_hypotheses_ex13.py b/doc/examples/defining_hypotheses_ex13.py index c7c736cff..f1b359e50 100644 --- a/doc/examples/defining_hypotheses_ex13.py +++ b/doc/examples/defining_hypotheses_ex13.py @@ -2,25 +2,23 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -# Create face from the wire and add to study -Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1]) -geompy.addToStudy(Face,"Face") -circle, radius1, radius2 = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"]) -geompy.addToStudyInFather(Face, radius1,"radius1") -geompy.addToStudyInFather(Face, radius2,"radius2") -geompy.addToStudyInFather(Face, circle,"circle") +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() +# Create face from the wire and add to study +Face = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1]) +geom_builder.addToStudy(Face,"Face") +circle, radius1, radius2 = geom_builder.SubShapeAllSorted(Face, geom_builder.ShapeType["EDGE"]) +geom_builder.addToStudyInFather(Face, radius1,"radius1") +geom_builder.addToStudyInFather(Face, radius2,"radius2") +geom_builder.addToStudyInFather(Face, circle,"circle") # Define geometry for mesh, and Radial Quadrange algorithm -mesh = smesh.Mesh(Face) +mesh = smesh_builder.Mesh(Face) radial_Quad_algo = mesh.Quadrangle(algo=smeshBuilder.RADIAL_QUAD) # The Radial Quadrange algorithm can work without any hypothesis diff --git a/doc/examples/defining_hypotheses_ex14.py b/doc/examples/defining_hypotheses_ex14.py index f1e7e39f3..accc5879b 100644 --- a/doc/examples/defining_hypotheses_ex14.py +++ b/doc/examples/defining_hypotheses_ex14.py @@ -4,22 +4,21 @@ import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() - from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -# Get 1/4 part from the disk face. -Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100) -Disk_1 = geompy.MakeDiskR(100, 1) -Common_1 = geompy.MakeCommon(Disk_1, Box_1) -triaVertex = geompy.GetVertexNearPoint( Common_1, geompy.MakeVertex(0,0,0) ) -geompy.addToStudy( Common_1, "Common_1" ) -geompy.addToStudyInFather( Common_1, triaVertex, "triaVertex" ) +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() +# Get 1/4 part from the disk face. +Box_1 = geom_builder.MakeBoxDXDYDZ(100, 100, 100) +Disk_1 = geom_builder.MakeDiskR(100, 1) +Common_1 = geom_builder.MakeCommon(Disk_1, Box_1) +triaVertex = geom_builder.GetVertexNearPoint( Common_1, geom_builder.MakeVertex(0,0,0) ) +geom_builder.addToStudy( Common_1, "Common_1" ) +geom_builder.addToStudyInFather( Common_1, triaVertex, "triaVertex" ) # Set the Geometry for meshing -Mesh_1 = smesh.Mesh(Common_1) +Mesh_1 = smesh_builder.Mesh(Common_1) # Define 1D hypothesis Regular_1D = Mesh_1.Segment() diff --git a/doc/examples/defining_hypotheses_ex15.py b/doc/examples/defining_hypotheses_ex15.py index 7b0cfbaa4..d1c711844 100644 --- a/doc/examples/defining_hypotheses_ex15.py +++ b/doc/examples/defining_hypotheses_ex15.py @@ -2,23 +2,25 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Make quadrangle face and explode it on edges. -Vertex_1 = geompy.MakeVertex(0, 0, 0) -Vertex_2 = geompy.MakeVertex(40, 0, 0) -Vertex_3 = geompy.MakeVertex(40, 30, 0) -Vertex_4 = geompy.MakeVertex(0, 30, 0) -Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2) -[Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"]) -geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" ) -geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" ) +Vertex_1 = geom_builder.MakeVertex(0, 0, 0) +Vertex_2 = geom_builder.MakeVertex(40, 0, 0) +Vertex_3 = geom_builder.MakeVertex(40, 30, 0) +Vertex_4 = geom_builder.MakeVertex(0, 30, 0) +Quadrangle_Face_1 = geom_builder.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2) +[Edge_1,Edge_2,Edge_3,Edge_4] = geom_builder.SubShapeAllSorted(Quadrangle_Face_1, geom_builder.ShapeType["EDGE"]) +geom_builder.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" ) +geom_builder.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" ) # Set the Geometry for meshing -Mesh_1 = smesh.Mesh(Quadrangle_Face_1) +Mesh_1 = smesh_builder.Mesh(Quadrangle_Face_1) # Create Quadrangle parameters and # define the Type as Quadrangle Preference diff --git a/doc/examples/defining_hypotheses_ex16.py b/doc/examples/defining_hypotheses_ex16.py index 2826aa15e..850bc4865 100644 --- a/doc/examples/defining_hypotheses_ex16.py +++ b/doc/examples/defining_hypotheses_ex16.py @@ -2,35 +2,35 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Make a patritioned box -box = geompy.MakeBoxDXDYDZ(100,100,100) +box = geom_builder.MakeBoxDXDYDZ(100,100,100) -N = geompy.MakeVectorDXDYDZ( 1,0,0 ) -O = geompy.MakeVertex( 50,0,0 ) -plane = geompy.MakePlane( O, N, 200 ) # plane YOZ +N = geom_builder.MakeVectorDXDYDZ( 1,0,0 ) +O = geom_builder.MakeVertex( 50,0,0 ) +plane = geom_builder.MakePlane( O, N, 200 ) # plane YOZ -shape2boxes = geompy.MakeHalfPartition( box, plane ) -boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"]) +shape2boxes = geom_builder.MakeHalfPartition( box, plane ) +boxes = geom_builder.SubShapeAllSorted(shape2boxes, geom_builder.ShapeType["SOLID"]) -geompy.addToStudy( boxes[0], "boxes[0]") -geompy.addToStudy( boxes[1], "boxes[1]") -midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5] -geompy.addToStudyInFather( boxes[0], midFace0, "middle Face") -midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0] -geompy.addToStudyInFather( boxes[1], midFace1, "middle Face") +geom_builder.addToStudy( boxes[0], "boxes[0]") +geom_builder.addToStudy( boxes[1], "boxes[1]") +midFace0 = geom_builder.SubShapeAllSorted(boxes[0], geom_builder.ShapeType["FACE"])[5] +geom_builder.addToStudyInFather( boxes[0], midFace0, "middle Face") +midFace1 = geom_builder.SubShapeAllSorted(boxes[1], geom_builder.ShapeType["FACE"])[0] +geom_builder.addToStudyInFather( boxes[1], midFace1, "middle Face") # Mesh one of boxes with quadrangles. It is a source mesh -srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin +srcMesh = smesh_builder.Mesh(boxes[0], "source mesh") # box coloser to CS origin nSeg1 = srcMesh.Segment().NumberOfSegments(4) srcMesh.Quadrangle() srcMesh.Compute() @@ -38,7 +38,7 @@ srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE ) # Import faces from midFace0 to the target mesh -tgtMesh = smesh.Mesh(boxes[1], "target mesh") +tgtMesh = smesh_builder.Mesh(boxes[1], "target mesh") importAlgo = tgtMesh.UseExisting2DElements(midFace1) import2hyp = importAlgo.SourceFaces( [srcFaceGroup] ) tgtMesh.Segment().NumberOfSegments(3) diff --git a/doc/examples/defining_hypotheses_ex17.py b/doc/examples/defining_hypotheses_ex17.py index da76f2210..917ddd487 100644 --- a/doc/examples/defining_hypotheses_ex17.py +++ b/doc/examples/defining_hypotheses_ex17.py @@ -2,32 +2,32 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -X = geompy.MakeVectorDXDYDZ( 1,0,0 ) -O = geompy.MakeVertex( 100,50,50 ) -plane = geompy.MakePlane( O, X, 200 ) # plane YZ +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +X = geom_builder.MakeVectorDXDYDZ( 1,0,0 ) +O = geom_builder.MakeVertex( 100,50,50 ) +plane = geom_builder.MakePlane( O, X, 200 ) # plane YZ -box = geompy.MakeBoxDXDYDZ(200,100,100) +box = geom_builder.MakeBoxDXDYDZ(200,100,100) -shape = geompy.MakeHalfPartition( box, plane ) +shape = geom_builder.MakeHalfPartition( box, plane ) -faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"]) +faces = geom_builder.SubShapeAllSorted(shape, geom_builder.ShapeType["FACE"]) face1 = faces[1] ignoreFaces = [ faces[0], faces[-1]] -geompy.addToStudy( shape, "shape" ) -geompy.addToStudyInFather( shape, face1, "face1") +geom_builder.addToStudy( shape, "shape" ) +geom_builder.addToStudyInFather( shape, face1, "face1") # 3D Viscous layers -mesh = smesh.Mesh(shape, "CFD") +mesh = smesh_builder.Mesh(shape, "CFD") mesh.Segment().NumberOfSegments( 4 ) @@ -56,9 +56,9 @@ mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA) # 2D Viscous layers # 3 edges of the 4 edges of face1 -edgeIds = geompy.SubShapeAllIDs( face1, geompy.ShapeType["EDGE"])[:-1] +edgeIds = geom_builder.SubShapeAllIDs( face1, geom_builder.ShapeType["EDGE"])[:-1] -mesh = smesh.Mesh(face1,"VicsousLayers2D") +mesh = smesh_builder.Mesh(face1,"VicsousLayers2D") mesh.Segment().NumberOfSegments( 5 ) # viscous layers will be created on 1 edge, as we set 3 edges to ignore diff --git a/doc/examples/defining_hypotheses_len_near_vertex.py b/doc/examples/defining_hypotheses_len_near_vertex.py index 62379eb8e..f2f024ffd 100644 --- a/doc/examples/defining_hypotheses_len_near_vertex.py +++ b/doc/examples/defining_hypotheses_len_near_vertex.py @@ -4,16 +4,18 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) +box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 ) # make a mesh -mesh = smesh.Mesh( box ) +mesh = smesh_builder.Mesh( box ) # define quadrangle meshing algo1d = mesh.Segment() diff --git a/doc/examples/filters_belong2group.py b/doc/examples/filters_belong2group.py index b3b5b61b7..e8d039558 100644 --- a/doc/examples/filters_belong2group.py +++ b/doc/examples/filters_belong2group.py @@ -1,8 +1,7 @@ # Belong to Mesh Group criterion # create mesh -from SMESH_mechanic import * -print() +from mechanic import * # create a group of all faces (quadrangles) generated on sub_face3 quads_on_face3 = mesh.MakeGroup("quads_on_face3", SMESH.FACE, SMESH.FT_BelongToGeom,'=',sub_face3) @@ -11,8 +10,8 @@ print("There are %s quadrangles generated on '%s' and included in the group '%s' # create a group of all the rest quadrangles, generated on other faces by combining 2 criteria: # - negated FT_BelongToMeshGroup to select elements not included in quads_on_face3 # - FT_ElemGeomType to select quadrangles -not_on_face3 = smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=',quads_on_face3, SMESH.FT_LogicalNOT ) -quadrangles = smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_QUADRANGLE ) +not_on_face3 = smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=',quads_on_face3, SMESH.FT_LogicalNOT ) +quadrangles = smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_QUADRANGLE ) rest_quads = mesh.MakeGroupByCriteria("rest_quads", [ not_on_face3, quadrangles ]) print("'%s' group includes all the rest %s quadrangles" % ( rest_quads.GetName(), rest_quads.Size() )) diff --git a/doc/examples/filters_ex01.py b/doc/examples/filters_ex01.py index f323ecb76..5f1604f8e 100644 --- a/doc/examples/filters_ex01.py +++ b/doc/examples/filters_ex01.py @@ -2,22 +2,22 @@ # This script demonstrates various usages of filters # create mesh -from SMESH_mechanic import * +from mechanic import * # get faces with aspect ratio > 2.5 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 2.5) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with aspect ratio > 2.5:", len(ids)) # get faces with aspect ratio > 1.5 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, '>', 1.5, mesh=mesh) ids = filter.GetIDs() print("Number of faces with aspect ratio > 1.5:", len(ids)) # copy the faces with aspect ratio > 1.5 to another mesh; # this demonstrates that a filter can be used where usually a group or sub-mesh is acceptable filter.SetMesh( mesh.GetMesh() ) # - actually non necessary as mesh is set at filter creation -mesh2 = smesh.CopyMesh( filter, "AR > 1.5" ) +mesh2 = smesh_builder.CopyMesh( filter, "AR > 1.5" ) print("Number of copied faces with aspect ratio > 1.5:", mesh2.NbFaces()) # create a group (Group on Filter) of faces with Aspect Ratio < 1.5 @@ -26,8 +26,8 @@ print("Number of faces with aspect ratio < 1.5:", group.Size()) # combine several criteria to Create a Group of only Triangular faces with Aspect Ratio < 1.5; # note that contents of a GroupOnFilter is dynamically updated as the mesh changes -crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ), - smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ] +crit = [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_AspectRatio, '<', 1.5, BinaryOp=SMESH.FT_LogicalAND ), + smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) ] triaGroup = mesh.MakeGroupByCriteria( "Tria AR < 1.5", crit ) print("Number of triangles with aspect ratio < 1.5:", triaGroup.Size()) diff --git a/doc/examples/filters_ex02.py b/doc/examples/filters_ex02.py index 6a392ce41..1e00b70f5 100644 --- a/doc/examples/filters_ex02.py +++ b/doc/examples/filters_ex02.py @@ -1,10 +1,9 @@ # Aspect ratio 3D # create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get volumes with aspect ratio < 2.0 -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_LessThan, 2.0) ids = mesh.GetIdsFromFilter(filter) print("Number of volumes with aspect ratio < 2.0:", len(ids)) diff --git a/doc/examples/filters_ex03.py b/doc/examples/filters_ex03.py index e01b60df5..c10c1eb8f 100644 --- a/doc/examples/filters_ex03.py +++ b/doc/examples/filters_ex03.py @@ -1,8 +1,9 @@ # Warping angle # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces with warping angle = 2.0e-13 with tolerance 5.0e-14 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Warping, "=", 2.0e-13, Tolerance=5.0e-14) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)) diff --git a/doc/examples/filters_ex04.py b/doc/examples/filters_ex04.py index 2b274837a..96d9e2e5e 100644 --- a/doc/examples/filters_ex04.py +++ b/doc/examples/filters_ex04.py @@ -1,8 +1,9 @@ # Minimum angle # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces with minimum angle > 75 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,">", 75) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle,">", 75) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with minimum angle > 75:", len(ids)) diff --git a/doc/examples/filters_ex05.py b/doc/examples/filters_ex05.py index c470db6bc..f3ddf6a3b 100644 --- a/doc/examples/filters_ex05.py +++ b/doc/examples/filters_ex05.py @@ -1,8 +1,9 @@ # Taper # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces with taper < 1.e-15 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_LessThan, 1.e-15) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with taper < 1.e-15:", len(ids)) diff --git a/doc/examples/filters_ex06.py b/doc/examples/filters_ex06.py index 94666f70c..a62dbf600 100644 --- a/doc/examples/filters_ex06.py +++ b/doc/examples/filters_ex06.py @@ -1,8 +1,9 @@ # Skew # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces with skew > 50 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 50) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with skew > 50:", len(ids)) diff --git a/doc/examples/filters_ex07.py b/doc/examples/filters_ex07.py index 7d781dc22..1684de1b6 100644 --- a/doc/examples/filters_ex07.py +++ b/doc/examples/filters_ex07.py @@ -1,10 +1,11 @@ # Area # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces with area > 60 and < 90 -criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60) -criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90) -filter = smesh.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND) +criterion1 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60) +criterion2 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90) +filter = smesh_builder.GetFilterFromCriteria([criterion1,criterion2], SMESH.FT_LogicalAND) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with area in range (60,90):", len(ids)) diff --git a/doc/examples/filters_ex08.py b/doc/examples/filters_ex08.py index 479de961e..a56e45bbe 100644 --- a/doc/examples/filters_ex08.py +++ b/doc/examples/filters_ex08.py @@ -1,10 +1,9 @@ # Volume # create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get volumes faces with volume > 100 -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_MoreThan, 100) ids = mesh.GetIdsFromFilter(filter) print("Number of volumes with volume > 100:", len(ids)) diff --git a/doc/examples/filters_ex09.py b/doc/examples/filters_ex09.py index 8e2ebfd3d..d78f685ba 100644 --- a/doc/examples/filters_ex09.py +++ b/doc/examples/filters_ex09.py @@ -1,21 +1,23 @@ # Free borders -# initialize SALOME and modules -import salome, SMESH +import salome salome.salome_init_without_session() + +import SMESH from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create mesh -face = geompy.MakeFaceHW(100, 100, 1, theName="quadrangle") -mesh = smesh.Mesh(face) +face = geom_builder.MakeFaceHW(100, 100, 1, theName="quadrangle") +mesh = smesh_builder.Mesh(face) mesh.Segment().NumberOfSegments(10) mesh.Triangle().MaxElementArea(25) mesh.Compute() # get all free borders -filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) +filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) ids = mesh.GetIdsFromFilter(filter) print("Number of edges on free borders:", len(ids)) diff --git a/doc/examples/filters_ex10.py b/doc/examples/filters_ex10.py index b90e5188f..8f27a7c18 100644 --- a/doc/examples/filters_ex10.py +++ b/doc/examples/filters_ex10.py @@ -1,22 +1,24 @@ # Free edges -# initialize SALOME and modules -import salome, SMESH +import salome salome.salome_init_without_session() + +import SMESH from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create mesh -face = geompy.MakeFaceHW(100, 100, 1) -geompy.addToStudy( face, "quadrangle" ) -mesh = smesh.Mesh(face) +face = geom_builder.MakeFaceHW(100, 100, 1) +geom_builder.addToStudy( face, "quadrangle" ) +mesh = smesh_builder.Mesh(face) mesh.Segment().NumberOfSegments(10) mesh.Triangle().MaxElementArea(25) mesh.Compute() # get all faces with free edges -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with free edges:", len(ids)) diff --git a/doc/examples/filters_ex11.py b/doc/examples/filters_ex11.py index 47b62e282..3c4751bd3 100644 --- a/doc/examples/filters_ex11.py +++ b/doc/examples/filters_ex11.py @@ -1,10 +1,12 @@ # Free nodes # create mesh -from SMESH_mechanic import * +from mechanic import * + # add node mesh.AddNode(0,0,0) + # get all free nodes -filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) +filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) ids = mesh.GetIdsFromFilter(filter) print("Number of free nodes:", len(ids)) diff --git a/doc/examples/filters_ex12.py b/doc/examples/filters_ex12.py index 5dfd81ad4..9dc021307 100644 --- a/doc/examples/filters_ex12.py +++ b/doc/examples/filters_ex12.py @@ -1,8 +1,9 @@ # Free faces # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all free faces -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces) ids = mesh.GetIdsFromFilter(filter) print("Number of free faces:", len(ids)) diff --git a/doc/examples/filters_ex13.py b/doc/examples/filters_ex13.py index ae64b565a..89e7acdca 100644 --- a/doc/examples/filters_ex13.py +++ b/doc/examples/filters_ex13.py @@ -1,10 +1,12 @@ # Bare border faces # create mesh -from SMESH_mechanic import * +from mechanic import * + # remove some faces to have faces with bare borders mesh.RemoveElements( mesh.GetElementsByType(SMESH.FACE)[0:5] ) + # get all faces with bare borders -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace) ids = mesh.GetIdsFromFilter(filter) print("Faces with bare borders:", ids) diff --git a/doc/examples/filters_ex14.py b/doc/examples/filters_ex14.py index 2e68ae8f2..a5e02736b 100644 --- a/doc/examples/filters_ex14.py +++ b/doc/examples/filters_ex14.py @@ -1,9 +1,10 @@ # Coplanar faces # create mesh -from SMESH_mechanic import * +from mechanic import * + faceID = mesh.GetElementsByType(SMESH.FACE)[0] # get all faces co-planar to the first face with tolerance 5 degrees -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_CoplanarFaces,faceID,Tolerance=5.0) ids = mesh.GetIdsFromFilter(filter) print("Number of faces coplanar with the first one:", len(ids)) diff --git a/doc/examples/filters_ex15.py b/doc/examples/filters_ex15.py index 70c8cae5c..ff022e690 100644 --- a/doc/examples/filters_ex15.py +++ b/doc/examples/filters_ex15.py @@ -1,7 +1,9 @@ # Over-constrained faces + # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all over-constrained faces -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace) ids = mesh.GetIdsFromFilter(filter) print("Over-constrained faces:", ids) diff --git a/doc/examples/filters_ex16.py b/doc/examples/filters_ex16.py index 4e3d27be4..9b9f5523e 100644 --- a/doc/examples/filters_ex16.py +++ b/doc/examples/filters_ex16.py @@ -1,31 +1,29 @@ # Double edges, Double faces, Double volumes - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make a mesh on a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = smesh.Mesh( box, "Box" ) +box = geom_builder.MakeBoxDXDYDZ(100,100,100) +mesh = smesh_builder.Mesh( box, "Box" ) mesh.Segment().NumberOfSegments(10) mesh.Quadrangle() mesh.Hexahedron() mesh.Compute() # copy all elements with translation and Merge nodes -mesh.TranslateObject( mesh, smesh.MakeDirStruct( 10,0,0), Copy=True ) +mesh.TranslateObject( mesh, smesh_builder.MakeDirStruct( 10,0,0), Copy=True ) mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) ) # create filters to find equal elements -equalEdgesFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges) -equalFacesFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces) -equalVolumesFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes) +equalEdgesFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges) +equalFacesFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces) +equalVolumesFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_EqualVolumes) # get equal elements print("Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))) print("Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))) diff --git a/doc/examples/filters_ex17.py b/doc/examples/filters_ex17.py index 83eda322c..43a5af866 100644 --- a/doc/examples/filters_ex17.py +++ b/doc/examples/filters_ex17.py @@ -2,15 +2,17 @@ import salome salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() + import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make a mesh on a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = smesh.Mesh( box, "Box" ) +box = geom_builder.MakeBoxDXDYDZ(100,100,100) +mesh = smesh_builder.Mesh( box, "Box" ) mesh.Segment().NumberOfSegments(10) mesh.Quadrangle() mesh.Hexahedron() @@ -18,6 +20,6 @@ mesh.Compute() # copy all elements with translation mesh.TranslateObject( mesh, [10,0,0], Copy=True ) # create a filter to find nodes equal within tolerance of 1e-5 -filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5) +filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_EqualNodes, Tolerance=1e-5) # get equal nodes print("Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))) diff --git a/doc/examples/filters_ex18.py b/doc/examples/filters_ex18.py index c4ec48107..f5c0e7d3b 100644 --- a/doc/examples/filters_ex18.py +++ b/doc/examples/filters_ex18.py @@ -2,15 +2,17 @@ import salome salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() + import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make a mesh on a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = smesh.Mesh( box, "Box" ) +box = geom_builder.MakeBoxDXDYDZ(100,100,100) +mesh = smesh_builder.Mesh( box, "Box" ) mesh.Segment().NumberOfSegments(10) mesh.Quadrangle() mesh.Hexahedron() @@ -20,6 +22,6 @@ mesh.TranslateObject( mesh, [10,0,0], Copy=True ) mesh.MergeNodes( mesh.FindCoincidentNodes( 1e-5 )) # get mesh edges with number of connected elements (faces and volumes) == 3 -filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3) +filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 3) ids = mesh.GetIdsFromFilter(filter) print("Number of border edges with 3 faces connected:", len(ids)) diff --git a/doc/examples/filters_ex19.py b/doc/examples/filters_ex19.py index cb1c545a3..b55a08a89 100644 --- a/doc/examples/filters_ex19.py +++ b/doc/examples/filters_ex19.py @@ -1,8 +1,9 @@ # Borders at multi-connection 2D # create mesh -from SMESH_mechanic import * +from mechanic import * + # get faces which consist of edges belonging to 2 mesh elements -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, 2) ids = mesh.GetIdsFromFilter(filter) print("Number of faces consisting of edges belonging to 2 faces:", len(ids)) diff --git a/doc/examples/filters_ex20.py b/doc/examples/filters_ex20.py index c55b56b23..d0a22f6a8 100644 --- a/doc/examples/filters_ex20.py +++ b/doc/examples/filters_ex20.py @@ -1,8 +1,9 @@ # Length # create mesh -from SMESH_mechanic import * +from mechanic import * + # get edges with length > 14 -filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14) +filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, 14) ids = mesh.GetIdsFromFilter(filter) print("Number of edges with length > 14:", len(ids)) diff --git a/doc/examples/filters_ex21.py b/doc/examples/filters_ex21.py index 81d408701..229a0ca44 100644 --- a/doc/examples/filters_ex21.py +++ b/doc/examples/filters_ex21.py @@ -1,8 +1,9 @@ # Length 2D # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all faces that have edges with length > 14 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, 14) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 14) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with maximum edge length > 14:", len(ids)) diff --git a/doc/examples/filters_ex22.py b/doc/examples/filters_ex22.py index cb7971bd6..96f8bda65 100644 --- a/doc/examples/filters_ex22.py +++ b/doc/examples/filters_ex22.py @@ -1,8 +1,9 @@ # Element Diameter 2D # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all faces that have elements with length > 10 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10) ids = mesh.GetIdsFromFilter(filter) print("Number of faces with maximum element length > 10:", len(ids)) diff --git a/doc/examples/filters_ex23.py b/doc/examples/filters_ex23.py index 8c995090b..8a34c163c 100644 --- a/doc/examples/filters_ex23.py +++ b/doc/examples/filters_ex23.py @@ -1,10 +1,9 @@ # Element Diameter 3D # create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get all volumes that have elements with length > 10 -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, 10) ids = mesh.GetIdsFromFilter(filter) print("Number of volumes with maximum element length > 10:", len(ids)) diff --git a/doc/examples/filters_ex24.py b/doc/examples/filters_ex24.py index ffe922691..2d8075cec 100644 --- a/doc/examples/filters_ex24.py +++ b/doc/examples/filters_ex24.py @@ -1,12 +1,11 @@ # Bare border volumes # create mesh -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # remove some volumes to have volumes with bare borders mesh.RemoveElements(mesh.GetElementsByType(SMESH.VOLUME)[0:5]) # get all volumes with bare borders -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume) ids = mesh.GetIdsFromFilter(filter) print("Volumes with bare borders:", ids) diff --git a/doc/examples/filters_ex25.py b/doc/examples/filters_ex25.py index f3083f7fb..2cae3e14f 100644 --- a/doc/examples/filters_ex25.py +++ b/doc/examples/filters_ex25.py @@ -1,10 +1,9 @@ # Over-constrained volumes # create mesh -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get all over-constrained volumes -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume) ids = mesh.GetIdsFromFilter(filter) print("Over-constrained volumes:", ids) diff --git a/doc/examples/filters_ex26.py b/doc/examples/filters_ex26.py index ea7cff8ac..71bfc4b15 100644 --- a/doc/examples/filters_ex26.py +++ b/doc/examples/filters_ex26.py @@ -1,8 +1,9 @@ # Belong to Geom # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all faces which nodes lie on the face sub_face3 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3) ids = mesh.GetIdsFromFilter(filter) print("Number of faces which nodes lie on sub_face3:", len(ids)) diff --git a/doc/examples/filters_ex27.py b/doc/examples/filters_ex27.py index e05ecbeff..8ac06e38d 100644 --- a/doc/examples/filters_ex27.py +++ b/doc/examples/filters_ex27.py @@ -1,8 +1,9 @@ # Lying on Geom # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all faces at least one node of each lies on the face sub_face3 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_LyingOnGeom, sub_face3) ids = mesh.GetIdsFromFilter(filter) print("Number of faces at least one node of each lies on sub_face3:", len(ids)) diff --git a/doc/examples/filters_ex28.py b/doc/examples/filters_ex28.py index f0382ac65..19e698391 100644 --- a/doc/examples/filters_ex28.py +++ b/doc/examples/filters_ex28.py @@ -1,11 +1,13 @@ # Belong to Plane # create mesh -from SMESH_mechanic import * +from mechanic import * + # create plane -plane_1 = geompy.MakePlane(p3,seg1,2000) -geompy.addToStudy(plane_1, "plane_1") +plane_1 = geom_builder.MakePlane(p3,seg1,2000) +geom_builder.addToStudy(plane_1, "plane_1") + # get all nodes which lie on the plane \a plane_1 -filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1) +filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_BelongToPlane, plane_1) ids = mesh.GetIdsFromFilter(filter) print("Number of nodes which lie on the plane plane_1:", len(ids)) diff --git a/doc/examples/filters_ex29.py b/doc/examples/filters_ex29.py index e6b817a4c..5b2b9db2d 100644 --- a/doc/examples/filters_ex29.py +++ b/doc/examples/filters_ex29.py @@ -1,8 +1,9 @@ # Belong to Cylinder # create mesh -from SMESH_mechanic import * +from mechanic import * + # get all faces which lie on the cylindrical face \a sub_face1 -filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1) +filter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToCylinder, sub_face1) ids = mesh.GetIdsFromFilter(filter) print("Number of faces which lie on the cylindrical surface sub_face1:", len(ids)) diff --git a/doc/examples/filters_ex30.py b/doc/examples/filters_ex30.py index 856010b9d..b34bdadb0 100644 --- a/doc/examples/filters_ex30.py +++ b/doc/examples/filters_ex30.py @@ -1,12 +1,14 @@ # Belong to Surface # create mesh -from SMESH_mechanic import * +from mechanic import * + # create b-spline -spline_1 = geompy.MakeInterpol([p4,p6,p3,p1]) -surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 ) -geompy.addToStudy(surface_1, "surface_1") +spline_1 = geom_builder.MakeInterpol([p4,p6,p3,p1]) +surface_1 = geom_builder.MakePrismVecH( spline_1, vz, 70.0 ) +geom_builder.addToStudy(surface_1, "surface_1") + # get all nodes which lie on the surface \a surface_1 -filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1) +filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_BelongToGenSurface, surface_1) ids = mesh.GetIdsFromFilter(filter) print("Number of nodes which lie on the surface surface_1:", len(ids)) diff --git a/doc/examples/filters_ex31.py b/doc/examples/filters_ex31.py index 209bb9f77..5bbad4ec8 100644 --- a/doc/examples/filters_ex31.py +++ b/doc/examples/filters_ex31.py @@ -1,12 +1,13 @@ # Range of IDs # create mesh -from SMESH_mechanic import * +from mechanic import * + # get nodes with identifiers [5-10] and [15-30] -criterion1 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="5-10",\ - BinaryOp=SMESH.FT_LogicalOR) -criterion2 = smesh.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="15-30") -filter = smesh.CreateFilterManager().CreateFilter() +criterion1 = smesh_builder.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="5-10",\ + BinaryOp=SMESH.FT_LogicalOR) +criterion2 = smesh_builder.GetCriterion(SMESH.NODE, SMESH.FT_RangeOfIds, Threshold="15-30") +filter = smesh_builder.CreateFilterManager().CreateFilter() filter.SetCriteria([criterion1,criterion2]) ids = mesh.GetIdsFromFilter(filter) print("Number of nodes in ranges [5-10] and [15-30]:", len(ids)) diff --git a/doc/examples/filters_ex32.py b/doc/examples/filters_ex32.py index 5630f7812..f0e07815c 100644 --- a/doc/examples/filters_ex32.py +++ b/doc/examples/filters_ex32.py @@ -1,10 +1,9 @@ # Badly oriented volume # create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get all badly oriented volumes -filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume) +filter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume) ids = mesh.GetIdsFromFilter(filter) print("Number of badly oriented volumes:", len(ids)) diff --git a/doc/examples/filters_ex33.py b/doc/examples/filters_ex33.py index 4e54e55a7..8d90a6533 100644 --- a/doc/examples/filters_ex33.py +++ b/doc/examples/filters_ex33.py @@ -1,11 +1,11 @@ # Linear / quadratic # create mesh -from SMESH_mechanic import * +from mechanic import * # get linear and quadratic edges -filter_linear = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic) -filter_quadratic = smesh.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT) +filter_linear = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic) +filter_quadratic = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic, SMESH.FT_LogicalNOT) ids_linear = mesh.GetIdsFromFilter(filter_linear) ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic) print("Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)) diff --git a/doc/examples/filters_ex34.py b/doc/examples/filters_ex34.py index 9e29e97d3..5fcb89ae8 100644 --- a/doc/examples/filters_ex34.py +++ b/doc/examples/filters_ex34.py @@ -1,7 +1,8 @@ # Group color # create mesh -from SMESH_mechanic import * +from mechanic import * + # create group of edges all_edges = mesh.GetElementsByType(SMESH.EDGE) grp = mesh.MakeGroupByIds("edges group", SMESH.EDGE, all_edges[:len(all_edges) // 4]) @@ -9,6 +10,6 @@ import SALOMEDS c = SALOMEDS.Color(0.1, 0.5, 1.0) grp.SetColor(c) # get number of the edges not belonging to the group with the given color -filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT) +filter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT) ids = mesh.GetIdsFromFilter(filter) print ("Number of edges not belonging to the group with color (0.1, 0.5, 1.0):", len(ids)) diff --git a/doc/examples/filters_ex35.py b/doc/examples/filters_ex35.py index fea0902b9..a44fce582 100644 --- a/doc/examples/filters_ex35.py +++ b/doc/examples/filters_ex35.py @@ -1,14 +1,13 @@ # Geometry type # create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() +from mechanic import * + # get all triangles, quadrangles, tetrahedrons, pyramids -filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_TRIANGLE) -filter_qua = smesh.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE) -filter_tet = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_TETRA) -filter_pyr = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_PYRAMID) +filter_tri = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_TRIANGLE) +filter_qua = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE) +filter_tet = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_TETRA) +filter_pyr = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_ElemGeomType, SMESH.Geom_PYRAMID) ids_tri = mesh.GetIdsFromFilter(filter_tri) ids_qua = mesh.GetIdsFromFilter(filter_qua) ids_tet = mesh.GetIdsFromFilter(filter_tet) diff --git a/doc/examples/filters_ex36.py b/doc/examples/filters_ex36.py index ec1e2b4fb..ebf39f325 100644 --- a/doc/examples/filters_ex36.py +++ b/doc/examples/filters_ex36.py @@ -1,14 +1,14 @@ # Combine several criteria into a filter # create mesh -from SMESH_mechanic import * +from mechanic import * # get all the quadrangle faces ... -criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND) +criterion1 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND) # ... but those from sub_face3 -criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT) +criterion2 = smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT) -quadFilter = smesh.GetFilterFromCriteria([criterion1,criterion2]) +quadFilter = smesh_builder.GetFilterFromCriteria([criterion1,criterion2]) # get faces satisfying the criteria ids = mesh.GetIdsFromFilter(quadFilter) diff --git a/doc/examples/filters_ex37.py b/doc/examples/filters_ex37.py index 0f1a0a8ff..821e2418b 100644 --- a/doc/examples/filters_ex37.py +++ b/doc/examples/filters_ex37.py @@ -1,15 +1,15 @@ # Entity type # create a mesh -from SMESH_mechanic import * +from mechanic import * # make the mesh quadratic mesh.ConvertToQuadratic() # make some elements bi-quadratic -for face in SubFaceL[: len(SubFaceL) // 2]: +for face in shape_faces[: len(shape_faces) // 2]: mesh.ConvertToQuadratic( theSubMesh=mesh.Group( face ), theToBiQuad=True ) # get triangles with 7 nodes -filter_tri = smesh.GetFilter(SMESH.FACE, SMESH.FT_EntityType,'=', SMESH.Entity_BiQuad_Triangle ) +filter_tri = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_EntityType,'=', SMESH.Entity_BiQuad_Triangle ) ids_tri = mesh.GetIdsFromFilter(filter_tri) print("Number of bi-quadratic triangles:", len(ids_tri)) diff --git a/doc/examples/filters_ex38.py b/doc/examples/filters_ex38.py index 2193c6615..1aee7325e 100644 --- a/doc/examples/filters_ex38.py +++ b/doc/examples/filters_ex38.py @@ -1,7 +1,7 @@ # Ball diameter # create a mesh -from SMESH_mechanic import * +from mechanic import * # create several balls with increasing diameter for i in range(1,10): @@ -10,6 +10,6 @@ for i in range(1,10): pass # get balls with diameter > 5. -diam_filter = smesh.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,'>', 5. ) +diam_filter = smesh_builder.GetFilter(SMESH.BALL, SMESH.FT_BallDiameter,'>', 5. ) ids = mesh.GetIdsFromFilter( diam_filter ) print("Number of balls with diameter > 5:", len(ids)) diff --git a/doc/examples/filters_ex39.py b/doc/examples/filters_ex39.py index 52de1c3d7..b66a8d0b7 100644 --- a/doc/examples/filters_ex39.py +++ b/doc/examples/filters_ex39.py @@ -1,24 +1,27 @@ # "Elements of a domain" filter and "Renumber" hypothesis -import salome, SMESH +import salome salome.salome_init_without_session() + +import SMESH from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create two boxes to have two domains in the mesh -box1 = geompy.MakeBoxDXDYDZ( 100,100,100 ) -box2 = geompy.MakeTranslation( box1, 200, 0, 0 ) -boxes = geompy.MakeCompound( [box1, box2] ) -box1, box2 = geompy.SubShapeAll( boxes, geompy.ShapeType["SHAPE"], "box") +box1 = geom_builder.MakeBoxDXDYDZ( 100,100,100 ) +box2 = geom_builder.MakeTranslation( box1, 200, 0, 0 ) +boxes = geom_builder.MakeCompound( [box1, box2] ) +box1, box2 = geom_builder.SubShapeAll( boxes, geom_builder.ShapeType["SHAPE"], "box") -vertex = geompy.SubShape( box1, geompy.ShapeType["VERTEX"], [1] ) +vertex = geom_builder.SubShape( box1, geom_builder.ShapeType["VERTEX"], [1] ) # create a mesh -mesh = smesh.Mesh( boxes ) +mesh = smesh_builder.Mesh( boxes ) mesh.Segment(box1).NumberOfSegments( 5 ) # to have different nb of elements on the boxes mesh.Segment(box2).NumberOfSegments( 10 ) mesh.Quadrangle() @@ -27,8 +30,8 @@ ijkAlgo = mesh.Hexahedron() # Use Renumber hypothesis to get hexahedra and nodes numbered like in a structured mesh. # k axis of box1 will be ( 100,100,0 ) - ( 100,100,100 ) # k axis of box2 will be ( 0,0,0 ) - (0,0,100), by default -v000 = geompy.MakeVertex( 100,100,0, theName='v000' ) # can use box sub-vertex or standalone one -v001 = geompy.GetVertexNearPoint( box1, geompy.MakeVertex(100,100,100), theName='v001') +v000 = geom_builder.MakeVertex( 100,100,0, theName='v000' ) # can use box sub-vertex or standalone one +v001 = geom_builder.GetVertexNearPoint( box1, geom_builder.MakeVertex(100,100,100), theName='v001') ijkAlgo.Renumber([ smeshBuilder.BlockCS( box1, v000, v001 ) ]) mesh.Compute() @@ -36,18 +39,17 @@ mesh.Compute() # Create filters with FT_ConnectedElements criterion by pointing a domain in different ways: # using point coordinates in box_1 -nodeFilter = smesh.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements, "=", "1.,2,10", mesh=mesh ) +nodeFilter = smesh_builder.GetFilter( SMESH.NODE, SMESH.FT_ConnectedElements, "=", "1.,2,10", mesh=mesh ) print("Nb. nodes in box_1:", len( nodeFilter.GetIDs())) # using point coordinates in box_2 -edgeFilter = smesh.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements, "=", [202,1,1 ], mesh=mesh ) +edgeFilter = smesh_builder.GetFilter( SMESH.EDGE, SMESH.FT_ConnectedElements, "=", [202,1,1 ], mesh=mesh ) print("Nb. segments in box_2:", len( edgeFilter.GetIDs())) # using a geom vertex of box_1 -faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements, "=", vertex, mesh=mesh ) +faceFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_ConnectedElements, "=", vertex, mesh=mesh ) print("Nb. faces in box_1:", len( edgeFilter.GetIDs())) # using node ID in box_2 -voluFilter = smesh.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements, "=", 10, mesh=mesh ) +voluFilter = smesh_builder.GetFilter( SMESH.VOLUME, SMESH.FT_ConnectedElements, "=", 10, mesh=mesh ) print("Nb. volumes in box_2:", len( voluFilter.GetIDs())) - diff --git a/doc/examples/filters_node_nb_conn.py b/doc/examples/filters_node_nb_conn.py index dc7ce0ea1..052ff9dc8 100644 --- a/doc/examples/filters_node_nb_conn.py +++ b/doc/examples/filters_node_nb_conn.py @@ -1,9 +1,9 @@ # Number of connectivities of a node # create a mesh -from SMESH_mechanic import * +from mechanic import * # get nodes connected to more than 6 tetrahedra -conn_nb_filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,'>', 6 ) +conn_nb_filter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_NodeConnectivityNumber,'>', 6 ) ids = mesh.GetIdsFromFilter( conn_nb_filter ) print("Number of nodes connected to more than 6 tetrahedra:", len(ids)) diff --git a/doc/examples/generate_flat_elements.py b/doc/examples/generate_flat_elements.py index d14cb0495..b17c55f91 100644 --- a/doc/examples/generate_flat_elements.py +++ b/doc/examples/generate_flat_elements.py @@ -3,45 +3,44 @@ # This example represents an iron cable (a thin cylinder) in a concrete block (a big cylinder). # The big cylinder is defined by two geometric volumes. - import salome salome.salome_init_without_session() + import GEOM +import SMESH from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # geometry -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Vertex_1 = geompy.MakeVertex(50, 0, 0) -Cylinder_1 = geompy.MakeCylinder(O, OX, 10, 500) -Cylinder_2 = geompy.MakeCylinder(Vertex_1, OX, 100, 400) -Vertex_2 = geompy.MakeVertex(-200, -200, -200) -Vertex_3 = geompy.MakeVertex(250, 200, 200) -Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_3) -Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2) -Partition_1 = geompy.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) -[Solid_1,Solid_2] = geompy.GetShapesOnShape(Cylinder_1, Partition_1, geompy.ShapeType["SOLID"], GEOM.ST_IN) -[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], GEOM.ST_IN) -Vertex_4 = geompy.MakeVertex(450, 0, 0) -Vertex_5 = geompy.MakeVertex(500, 0, 0) -Vertex_6 = geompy.MakeVertex(550, 0, 0) -vec1 = geompy.MakeVector(Vertex_4, Vertex_5) -vec2 = geompy.MakeVector(Vertex_5, Vertex_6) -[Face_1] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec1, GEOM.ST_ON) -[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, GEOM.ST_ON) +O = geom_builder.MakeVertex(0, 0, 0) +OX = geom_builder.MakeVectorDXDYDZ(1, 0, 0) +OY = geom_builder.MakeVectorDXDYDZ(0, 1, 0) +OZ = geom_builder.MakeVectorDXDYDZ(0, 0, 1) +Vertex_1 = geom_builder.MakeVertex(50, 0, 0) +Cylinder_1 = geom_builder.MakeCylinder(O, OX, 10, 500) +Cylinder_2 = geom_builder.MakeCylinder(Vertex_1, OX, 100, 400) +Vertex_2 = geom_builder.MakeVertex(-200, -200, -200) +Vertex_3 = geom_builder.MakeVertex(250, 200, 200) +Box_1 = geom_builder.MakeBoxTwoPnt(Vertex_2, Vertex_3) +Fuse_1 = geom_builder.MakeFuse(Cylinder_1, Cylinder_2) +Partition_1 = geom_builder.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geom_builder.ShapeType["SOLID"], 0, [], 0) +[Solid_1,Solid_2] = geom_builder.GetShapesOnShape(Cylinder_1, Partition_1, geom_builder.ShapeType["SOLID"], GEOM.ST_IN) +[Solid_3,Solid_4] = geom_builder.GetShapesOnShape(Cylinder_2, Partition_1, geom_builder.ShapeType["SOLID"], GEOM.ST_IN) +Vertex_4 = geom_builder.MakeVertex(450, 0, 0) +Vertex_5 = geom_builder.MakeVertex(500, 0, 0) +Vertex_6 = geom_builder.MakeVertex(550, 0, 0) +vec1 = geom_builder.MakeVector(Vertex_4, Vertex_5) +vec2 = geom_builder.MakeVector(Vertex_5, Vertex_6) +[Face_1] = geom_builder.GetShapesOnPlane(Partition_1, geom_builder.ShapeType["FACE"], vec1, GEOM.ST_ON) +[Face_2] = geom_builder.GetShapesOnPlane(Partition_1, geom_builder.ShapeType["FACE"], vec2, GEOM.ST_ON) # meshing (we have linear tetrahedrons here, but other elements are OK) -Mesh_1 = smesh.Mesh(Partition_1) +Mesh_1 = smesh_builder.Mesh(Partition_1) Regular_1D = Mesh_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(15) MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO) diff --git a/doc/examples/grouping_elements_ex01.py b/doc/examples/grouping_elements_ex01.py index c35de336b..e76dbdedf 100644 --- a/doc/examples/grouping_elements_ex01.py +++ b/doc/examples/grouping_elements_ex01.py @@ -1,14 +1,9 @@ # Create a Standalone Group -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Get ids of all faces with area > 100 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -73,8 +68,3 @@ aGroup.AddFrom( aGroup2 ) # removes entities aGroup.Remove( [2,3,4] ) - - - - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex02.py b/doc/examples/grouping_elements_ex02.py index 16feda41f..e3ddd4e22 100644 --- a/doc/examples/grouping_elements_ex02.py +++ b/doc/examples/grouping_elements_ex02.py @@ -1,35 +1,33 @@ # Create a Group on Geometry - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBox(0., 0., 0., 100., 100., 100.) -geompy.addToStudy(box, "box") +box = geom_builder.MakeBox(0., 0., 0., 100., 100., 100.) +geom_builder.addToStudy(box, "box") # add the first face of the box to the study -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +subShapeList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) face = subShapeList[0] -geompy.addToStudyInFather(box, face, "face 1") +geom_builder.addToStudyInFather(box, face, "face 1") # create group of edges on the face -aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"]) -geompy.AddObject(aGeomGroupE, 3) -geompy.AddObject(aGeomGroupE, 6) -geompy.AddObject(aGeomGroupE, 8) -geompy.AddObject(aGeomGroupE, 10) -geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges") +aGeomGroupE = geom_builder.CreateGroup(face, geom_builder.ShapeType["EDGE"]) +geom_builder.AddObject(aGeomGroupE, 3) +geom_builder.AddObject(aGeomGroupE, 6) +geom_builder.AddObject(aGeomGroupE, 8) +geom_builder.AddObject(aGeomGroupE, 10) +geom_builder.addToStudyInFather(face, aGeomGroupE, "Group of Edges") # create quadrangle 2D mesh on the box -quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh") +quadra = smesh_builder.Mesh(box, "Box : quadrangle 2D mesh") algo1D = quadra.Segment() quadra.Quadrangle() algo1D.NumberOfSegments(7) @@ -42,5 +40,3 @@ aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1") # create SMESH group on with default name aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex03.py b/doc/examples/grouping_elements_ex03.py index d6d6e83d9..2de59d734 100644 --- a/doc/examples/grouping_elements_ex03.py +++ b/doc/examples/grouping_elements_ex03.py @@ -1,32 +1,29 @@ # Create a Group on Filter - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ(10,10,10) +box = geom_builder.MakeBoxDXDYDZ(10,10,10) # make a mesh with quadrangles of different area in range [1,16] -mesh = smesh.Mesh(box,"Quad mesh") +mesh = smesh_builder.Mesh(box,"Quad mesh") hyp1D = mesh.Segment().StartEndLength( 1, 4 ) mesh.Quadrangle() mesh.Compute() # create a group on filter selecting faces of medium size critaria = [ \ - smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ), - smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 ) + smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ), + smesh_builder.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 ) ] -filt = smesh.GetFilterFromCriteria( critaria ) +filt = smesh_builder.GetFilterFromCriteria( critaria ) filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt ) print("Group on filter contains %s elements" % filtGroup.Size()) @@ -37,13 +34,11 @@ mesh.Compute() print("After mesh change, group on filter contains %s elements" % filtGroup.Size()) # set a new filter defining the group -filt2 = smesh.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" ) +filt2 = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" ) filtGroup.SetFilter( filt2 ) print("With a new filter, group on filter contains %s elements" % filtGroup.Size()) # group is updated at modification of the filter -filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )]) +filt2.SetCriteria( [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )]) filtIDs3 = filtGroup.GetIDs() print("After filter modification, group on filter contains %s elements" % filtGroup.Size()) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex04.py b/doc/examples/grouping_elements_ex04.py index e0e58acc9..d3b88c13b 100644 --- a/doc/examples/grouping_elements_ex04.py +++ b/doc/examples/grouping_elements_ex04.py @@ -1,14 +1,9 @@ # Edit a Group -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Get ids of all faces with area > 35 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -19,7 +14,7 @@ aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 35") aGroup.Add(anIds) # Get ids of all faces with area > 40 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -41,5 +36,3 @@ for i in range(len(aGroupElemIDs)): j = j + 1 pass print("") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex05.py b/doc/examples/grouping_elements_ex05.py index 96aa7fa56..a1ef0a55d 100644 --- a/doc/examples/grouping_elements_ex05.py +++ b/doc/examples/grouping_elements_ex05.py @@ -1,14 +1,10 @@ # Union of groups -import SMESH_mechanic -import SMESH, SALOMEDS - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * +import SALOMEDS # Criterion : AREA > 20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -19,7 +15,7 @@ aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20") aGroup1.Add(anIds) # Criterion : AREA = 20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -37,7 +33,7 @@ print("Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())) # Please note that also there is UnionGroups() method which works with two groups only # Criterion : AREA < 20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -51,5 +47,3 @@ aGroup4.SetColor( SALOMEDS.Color(1.,0.,0.)); # create union group : area >= 20 and area < 20 aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area") print("Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex06.py b/doc/examples/grouping_elements_ex06.py index 9423cf7d4..e6bbd495c 100644 --- a/doc/examples/grouping_elements_ex06.py +++ b/doc/examples/grouping_elements_ex06.py @@ -1,14 +1,9 @@ # Intersection of groups -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : AREA > 20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -19,7 +14,7 @@ aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20") aGroup1.Add(anIds) # Criterion : AREA < 60 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -34,4 +29,3 @@ aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60") print("Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())) # Please note that also there is IntersectGroups() method which works with two groups only -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex07.py b/doc/examples/grouping_elements_ex07.py index 800e8e80a..98108fdc3 100644 --- a/doc/examples/grouping_elements_ex07.py +++ b/doc/examples/grouping_elements_ex07.py @@ -1,14 +1,9 @@ # Cut of groups -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : AREA > 20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -18,7 +13,7 @@ print("Criterion: Area > 20, Nb = ", len(anIds)) aGroupMain = mesh.MakeGroupByIds("Area > 20", SMESH.FACE, anIds) # Criterion : AREA < 60 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) anIds = mesh.GetIdsFromFilter(aFilter) @@ -31,5 +26,3 @@ aGroupTool = mesh.MakeGroupByIds("Area < 60", SMESH.FACE, anIds) aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60") print("Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())) # Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex08.py b/doc/examples/grouping_elements_ex08.py index 76dc93fcc..244e8c73c 100644 --- a/doc/examples/grouping_elements_ex08.py +++ b/doc/examples/grouping_elements_ex08.py @@ -1,14 +1,10 @@ # Creating groups of entities basing on nodes of other groups -import SMESH_mechanic -import SMESH, SALOMEDS - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * +import SALOMEDS # Criterion : AREA > 100 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) # create a group by adding elements with area > 100 aSrcGroup1 = mesh.GroupOnFilter(SMESH.FACE, "Area > 100", aFilter) @@ -16,7 +12,7 @@ aSrcGroup1.SetColor( SALOMEDS.Color(1.,1.,0.)) print("Criterion: Area > 100, Nb = ", aSrcGroup1.Size()) # Criterion : AREA < 30 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.) # create a group by adding elements with area < 30 aSrcGroup2 = mesh.GroupOnFilter(SMESH.FACE, "Area < 30", aFilter) @@ -29,5 +25,3 @@ aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.EDGE, "Edges" ) # Create group of nodes using source groups of faces aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.NODE, "Nodes" ) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/grouping_elements_ex09.py b/doc/examples/grouping_elements_ex09.py index 988dad3cf..e46dedabc 100644 --- a/doc/examples/grouping_elements_ex09.py +++ b/doc/examples/grouping_elements_ex09.py @@ -2,14 +2,16 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder from salome.smesh import smeshBuilder -geompy = geomBuilder.New() -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a mesh on a box -box = geompy.MakeBoxDXDYDZ( 10,10,10, theName="Box" ) -mesh = smesh.Mesh(box,"Mesh") +box = geom_builder.MakeBoxDXDYDZ( 10,10,10, theName="Box" ) +mesh = smesh_builder.Mesh(box,"Mesh") mesh.AutomaticHexahedralization() # create groups of faces of each side of the box diff --git a/doc/examples/measurements_ex01.py b/doc/examples/measurements_ex01.py index b8ccae02a..a0c9991a8 100644 --- a/doc/examples/measurements_ex01.py +++ b/doc/examples/measurements_ex01.py @@ -2,57 +2,69 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook -from SMESH_mechanic import mesh as mesh1 -from SMESH_test1 import mesh as mesh2 +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +# create and mesh two boxes + +p1 = geom_builder.MakeVertex(10.0, 10.0, 10.0) +p2 = geom_builder.MakeVertex(20.0, 20.0, 20.0) +p3 = geom_builder.MakeVertex(30.0, 40.0, 50.0) +p4 = geom_builder.MakeVertex(70.0, 100.0, 200.0) + +box1 = geom_builder.MakeBoxTwoPnt(p1, p2) +box2 = geom_builder.MakeBoxTwoPnt(p3, p4) + +mesh1 = smesh_builder.Mesh(box1, 'box1') +mesh1.Segment().NumberOfSegments(2) +mesh1.Triangle().MaxElementArea(10) + +mesh2 = smesh_builder.Mesh(box2, 'box2') +mesh2.Segment().NumberOfSegments(5) +mesh2.Triangle().MaxElementArea(20) mesh1.Compute() mesh2.Compute() -# compute min distance from mesh1 to the origin (not available yet) -smesh.MinDistance(mesh1) +# compute min distance from grp1 to the origin (not available yet) +smesh_builder.MinDistance(mesh1) # compute min distance from node 10 of mesh1 to the origin -smesh.MinDistance(mesh1, id1=10) +smesh_builder.MinDistance(mesh1, id1=10) # ... or mesh1.MinDistance(10) # compute min distance between nodes 10 and 20 of mesh1 -smesh.MinDistance(mesh1, id1=10, id2=20) +smesh_builder.MinDistance(mesh1, id1=10, id2=20) # ... or mesh1.MinDistance(10, 20) # compute min distance from element 100 of mesh1 to the origin (not available yet) -smesh.MinDistance(mesh1, id1=100, isElem1=True) +smesh_builder.MinDistance(mesh1, id1=100, isElem1=True) # ... or mesh1.MinDistance(100, isElem1=True) # compute min distance between elements 100 and 200 of mesh1 (not available yet) -smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True) +smesh_builder.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True) # ... or mesh1.MinDistance(100, 200, True, True) # compute min distance from element 100 to node 20 of mesh1 (not available yet) -smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True) +smesh_builder.MinDistance(mesh1, id1=100, id2=20, isElem1=True) # ... or mesh1.MinDistance(100, 20, True) # compute min distance from mesh1 to mesh2 (not available yet) -smesh.MinDistance(mesh1, mesh2) +smesh_builder.MinDistance(mesh1, mesh2) # compute min distance from node 10 of mesh1 to node 20 of mesh2 -smesh.MinDistance(mesh1, mesh2, 10, 20) +smesh_builder.MinDistance(mesh1, mesh2, 10, 20) # compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet) -smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True) +smesh_builder.MinDistance(mesh1, mesh2, 10, 200, isElem2=True) # etc... - diff --git a/doc/examples/measurements_ex02.py b/doc/examples/measurements_ex02.py index 20c04bcc8..33bffbaea 100644 --- a/doc/examples/measurements_ex02.py +++ b/doc/examples/measurements_ex02.py @@ -1,19 +1,31 @@ # Bounding Box - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook -from SMESH_mechanic import mesh as mesh1 -from SMESH_test1 import mesh as mesh2 +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +# create and mesh two boxes + +p1 = geom_builder.MakeVertex(10.0, 10.0, 10.0) +p2 = geom_builder.MakeVertex(20.0, 20.0, 20.0) +p3 = geom_builder.MakeVertex(30.0, 40.0, 50.0) +p4 = geom_builder.MakeVertex(70.0, 100.0, 200.0) + +box1 = geom_builder.MakeBoxTwoPnt(p1, p2) +box2 = geom_builder.MakeBoxTwoPnt(p3, p4) + +mesh1 = smesh_builder.Mesh(box1, 'box1') +mesh1.Segment().NumberOfSegments(2) +mesh1.Triangle().MaxElementArea(10) + +mesh2 = smesh_builder.Mesh(box2, 'box2') +mesh2.Segment().NumberOfSegments(5) +mesh2.Triangle().MaxElementArea(20) mesh1.Compute() mesh2.Compute() @@ -21,13 +33,13 @@ mesh2.Compute() # compute bounding box for mesh1 mesh1.BoundingBox() -# compute bounding box for list of nodes of mesh1 -mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381]) +# compute bounding box for list of nodes of mesh2 +mesh2.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381]) -# compute bounding box for list of elements of mesh1 -mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True) +# compute bounding box for list of elements of mesh2 +mesh2.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True) # compute common bounding box of mesh1 and mesh2 -smesh.BoundingBox([mesh1, mesh2]) +smesh_builder.BoundingBox([mesh1, mesh2]) # etc... diff --git a/doc/examples/measurements_ex03.py b/doc/examples/measurements_ex03.py index 217d9cb23..44d2f6e71 100644 --- a/doc/examples/measurements_ex03.py +++ b/doc/examples/measurements_ex03.py @@ -1,22 +1,20 @@ # Basic Properties - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -face = geompy.SubShapeAllSorted(box, geompy.ShapeType['FACE'])[0] +box = geom_builder.MakeBoxDXDYDZ(100,100,100) +face = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType['FACE'])[0] # mesh a box -mesh = smesh.Mesh(box) +mesh = smesh_builder.Mesh(box) submesh_1d = mesh.Segment().NumberOfSegments(5) submesh_2d = mesh.Quadrangle() submesh_3d = mesh.Hexahedron() @@ -31,7 +29,7 @@ group_2d = mesh.Group(face) print("Get basic properties: approach 1 (via measurements tool) ----") -measure = smesh.CreateMeasurements() +measure = smesh_builder.CreateMeasurements() print("* for mesh:") print(" length:", measure.Length(mesh.mesh)) @@ -53,19 +51,19 @@ measure.UnRegister() print("Get basic properties: approach 2 (via smeshBuilder) ----") print("* for mesh:") -print(" length:", smesh.GetLength(mesh)) -print(" area:", smesh.GetArea(mesh)) -print(" volume:", smesh.GetVolume(mesh)) +print(" length:", smesh_builder.GetLength(mesh)) +print(" area:", smesh_builder.GetArea(mesh)) +print(" volume:", smesh_builder.GetVolume(mesh)) print("* for group (2d):") -print(" length:", smesh.GetLength(group_2d)) -print(" area:", smesh.GetArea(group_2d)) -print(" volume:", smesh.GetVolume(group_2d)) +print(" length:", smesh_builder.GetLength(group_2d)) +print(" area:", smesh_builder.GetArea(group_2d)) +print(" volume:", smesh_builder.GetVolume(group_2d)) print("* for submesh (2d):") -print(" length:", smesh.GetLength(submesh_2d_face)) -print(" area:", smesh.GetArea(submesh_2d_face)) -print(" volume:", smesh.GetVolume(submesh_2d_face)) +print(" length:", smesh_builder.GetLength(submesh_2d_face)) +print(" area:", smesh_builder.GetArea(submesh_2d_face)) +print(" volume:", smesh_builder.GetVolume(submesh_2d_face)) print("Get basic properties: approach 3 (via smeshBuilder.Mesh) ----") diff --git a/doc/examples/measurements_ex04.py b/doc/examples/measurements_ex04.py index b143267ba..ab66d2cc0 100644 --- a/doc/examples/measurements_ex04.py +++ b/doc/examples/measurements_ex04.py @@ -1,10 +1,11 @@ # Angle measurement - import salome salome.salome_init_without_session() + from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +smesh_builder = smeshBuilder.New() # use smeshBuilder.GetAngle() to compute angle between 3 arbitrary points @@ -12,15 +13,14 @@ p0 = [1,0,0] p1 = [0,0,0] p2 = [0,1,0] -a1 = smesh.GetAngle(p0, p1, p2) +a1 = smesh_builder.GetAngle(p0, p1, p2) print("Right angle measure", a1 ) # use Mesh.GetAngle() to compute angle between 3 nodes of a mesh -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() n0 = mesh.AddNode( *p0 ) n1 = mesh.AddNode( *p1 ) n2 = mesh.AddNode( *p2 ) a2 = mesh.GetAngle( n0,n1,n2 ) - diff --git a/doc/examples/mechanic.py b/doc/examples/mechanic.py new file mode 100644 index 000000000..902ce7184 --- /dev/null +++ b/doc/examples/mechanic.py @@ -0,0 +1,86 @@ +# Inspired by SMESH_mechanic.py. +# Creates geometry and a mesh to be used in other examples +# -------------------------------------------------------- + +import salome +salome.salome_init_without_session() + +import SMESH +from salome.geom import geomBuilder +from salome.smesh import smeshBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +# Geometry +# -------- + +# create planar face on a wire combined from a segment and three arcs + +p1 = geom_builder.MakeVertex(100.0, 0.0, 0.0) +p2 = geom_builder.MakeVertex(50.0, 50.0, 0.0) +p3 = geom_builder.MakeVertex(100.0, 100.0, 0.0) +arc1 = geom_builder.MakeArc(p1, p2, p3) + +p4 = geom_builder.MakeVertex(170.0, 100.0, 0.0) +seg1 = geom_builder.MakeVector(p3, p4) + +p5 = geom_builder.MakeVertex(200.0, 70.0, 0.0) +p6 = geom_builder.MakeVertex(170.0, 40.0, 0.0) +arc2 = geom_builder.MakeArc(p4, p5, p6) + +p7 = geom_builder.MakeVertex(120.0, 30.0, 0.0) +arc3 = geom_builder.MakeArc(p6, p7, p1) + +wire1 = geom_builder.MakeWire([arc1, seg1, arc2, arc3]) +face1 = geom_builder.MakeFace(wire1, True) + +# create main shape by extruding just created planar face + +pO = geom_builder.MakeVertex(0.0, 0.0, 0.0) +pz = geom_builder.MakeVertex(0.0, 0.0, 100.0) +vz = geom_builder.MakeVector(pO, pz) +prism1 = geom_builder.MakePrismVecH(face1, vz, 100.0) + +# create two cylinders + +pc1 = geom_builder.MakeVertex(90.0, 50.0, -40.0) +pc2 = geom_builder.MakeVertex(170.0, 70.0, -40.0) + +cyl1 = geom_builder.MakeCylinder(pc1, vz, 20.0, 180.0) +cyl2 = geom_builder.MakeCylinder(pc2, vz, 20.0, 180.0) + +# create final shape by cutting one cylinder and fusing with another + +shape = geom_builder.MakeBoolean(prism1, cyl1, 2) +mechanic = geom_builder.MakeBoolean(shape, cyl2, 3) + +# get all faces from shape and keep sub of them into variables for future processing + +shape_faces = geom_builder.SubShapeAllSorted(mechanic, geom_builder.ShapeType["FACE"]) + +sub_face1 = shape_faces[0] +sub_face2 = shape_faces[4] +sub_face3 = shape_faces[5] +sub_face4 = shape_faces[10] + +# Mesh +# ---- + +# create tria+tetra mesh from mechanic shape + +mesh = smesh_builder.Mesh(mechanic, "mechanic") +mesh.Segment().NumberOfSegments(10) +mesh.Triangle().MaxElementArea(25) +mesh.Tetrahedron() + +# create quad sub-meshes on faces sub_face1 - sub_face4 + +mesh.Quadrangle(sub_face1) +mesh.Quadrangle(sub_face2) +mesh.Quadrangle(sub_face3) +mesh.Quadrangle(sub_face4) + +# finally compute whole mesh + +mesh.Compute() diff --git a/doc/examples/mesh_3d.py b/doc/examples/mesh_3d.py new file mode 100644 index 000000000..69bd3f0e1 --- /dev/null +++ b/doc/examples/mesh_3d.py @@ -0,0 +1,104 @@ +# 3d mesh generation and mesh exploration + +import salome +salome.salome_init_without_session() + +import SMESH +from salome.geom import geomBuilder +from salome.smesh import smeshBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +### +# Geometry: an assembly of a box, a cylinder and a truncated cone +# to be meshed with tetrahedra +### + +# Define values +name = "ex21_lamp" +cote = 60 +section = 20 +size = 200 +radius_1 = 80 +radius_2 = 40 +height = 100 + +# Build a box +box = geom_builder.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) + +# Build a cylinder +pt1 = geom_builder.MakeVertex(0, 0, cote/3) +di1 = geom_builder.MakeVectorDXDYDZ(0, 0, 1) +cyl = geom_builder.MakeCylinder(pt1, di1, section, size) + +# Build a truncated cone +pt2 = geom_builder.MakeVertex(0, 0, size) +cone = geom_builder.MakeCone(pt2, di1, radius_1, radius_2, height) + +# Fuse +box_cyl = geom_builder.MakeFuse(box, cyl) +piece = geom_builder.MakeFuse(box_cyl, cone) + +# Add to the study +geom_builder.addToStudy(piece, name) + +# Create a group of faces +faces_group = geom_builder.CreateGroup(piece, geom_builder.ShapeType["FACE"]) +group_name = name + "_grp" +geom_builder.addToStudy(faces_group, group_name) +faces_group.SetName(group_name) + +# Add faces to the group +faces = geom_builder.SubShapeAllIDs(piece, geom_builder.ShapeType["FACE"]) +geom_builder.UnionIDs(faces_group, faces) + +### +# Create a mesh +### + +# Define a mesh on a geometry +tetra = smesh_builder.Mesh(piece, name) + +# Define 1D algorithm and hypothesis +algo1d = tetra.Segment() +algo1d.LocalLength(10) + +# Define 2D algorithm and hypothesis +algo2d = tetra.Triangle() +algo2d.LengthFromEdges() + +# Define 3D algorithm and hypothesis +algo3d = tetra.Tetrahedron() +algo3d.MaxElementVolume(100) + +# Compute the mesh +tetra.Compute() + +# Create a mesh group of all triangles generated on geom faces present in faces_group +group = tetra.Group(faces_group) + +### +# Explore the mesh +### + +# Retrieve coordinates of nodes +coordStr = "" +for node in tetra.GetNodesId(): + x,y,z = tetra.GetNodeXYZ( node ) + coordStr += "%s (%s, %s, %s) " % ( node, x,y,z ) + pass + +# Retrieve nodal connectivity of triangles +triaStr = "" +for tria in tetra.GetElementsByType( SMESH.FACE ): + nodes = tetra.GetElemNodes( tria ) + triaStr += "%s (%s, %s, %s) " % ( tria, nodes[0], nodes[1], nodes[2] ) + +# Retrieve group contents +groupStr = "" +for group in tetra.GetGroups(): + ids = group.GetIDs() + name = group.GetName() + eType = group.GetType() + groupStr += "'%s' %s: %s \n" % ( name, eType, ids ) diff --git a/doc/examples/modifying_meshes_cut_triangles.py b/doc/examples/modifying_meshes_cut_triangles.py index 250b55952..f45cc190c 100644 --- a/doc/examples/modifying_meshes_cut_triangles.py +++ b/doc/examples/modifying_meshes_cut_triangles.py @@ -2,11 +2,13 @@ import salome salome.salome_init_without_session() + from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +smesh_builder = smeshBuilder.New() # create 3 triangles and 1 segment all sharing edge 1-2 -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() n1 = mesh.AddNode( 0, 0, 0) n2 = mesh.AddNode( 0, 0, -10) n3 = mesh.AddNode( 10, 0, 0) diff --git a/doc/examples/modifying_meshes_ex01.py b/doc/examples/modifying_meshes_ex01.py index 2214610cb..ceeb3c02d 100644 --- a/doc/examples/modifying_meshes_ex01.py +++ b/doc/examples/modifying_meshes_ex01.py @@ -4,10 +4,9 @@ import salome salome.salome_init_without_session() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +smesh_builder = smeshBuilder.New() - -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # add node new_id = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex02.py b/doc/examples/modifying_meshes_ex02.py index 7b0b9f348..1f1aeca3d 100644 --- a/doc/examples/modifying_meshes_ex02.py +++ b/doc/examples/modifying_meshes_ex02.py @@ -4,10 +4,9 @@ import salome salome.salome_init_without_session() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +smesh_builder = smeshBuilder.New() - -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # add node node_id = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex03.py b/doc/examples/modifying_meshes_ex03.py index 59198ccd6..d5a524904 100644 --- a/doc/examples/modifying_meshes_ex03.py +++ b/doc/examples/modifying_meshes_ex03.py @@ -1,23 +1,21 @@ # Add 0D Element on Element Nodes - import salome salome.salome_init_without_session() +import SMESH from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a geometry -box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) -face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] +box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 ) +face = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0] # make 3D mesh -mesh = smesh.Mesh( box ) +mesh = smesh_builder.Mesh( box ) mesh.AutomaticHexahedralization(0) # create 0D elements on all nodes of the mesh @@ -38,9 +36,9 @@ group = mesh.Group( face, "faceGroup" ) res = mesh.Add0DElementsToAllNodes( group ) # remove all 0D elements -mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D, - SMESH.FT_ElemGeomType, - "=",SMESH.Geom_POINT ))) +mesh.RemoveElements( mesh.GetIdsFromFilter( smesh_builder.GetFilter( SMESH.ELEM0D, + SMESH.FT_ElemGeomType, + "=",SMESH.Geom_POINT ))) # create 0D elements on all nodes of some elements res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() ) diff --git a/doc/examples/modifying_meshes_ex04.py b/doc/examples/modifying_meshes_ex04.py index ad8d151b0..ffd16eb7f 100644 --- a/doc/examples/modifying_meshes_ex04.py +++ b/doc/examples/modifying_meshes_ex04.py @@ -1,9 +1,6 @@ # Add Edge -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print("") +from mechanic import * # add node n1 = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex05.py b/doc/examples/modifying_meshes_ex05.py index c48042a6f..ba62dfc56 100644 --- a/doc/examples/modifying_meshes_ex05.py +++ b/doc/examples/modifying_meshes_ex05.py @@ -1,9 +1,6 @@ # Add Triangle -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print("") +from mechanic import * # add node n1 = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex06.py b/doc/examples/modifying_meshes_ex06.py index ff568e0f1..449f75338 100644 --- a/doc/examples/modifying_meshes_ex06.py +++ b/doc/examples/modifying_meshes_ex06.py @@ -1,9 +1,6 @@ # Add Quadrangle -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print("") +from mechanic import * # add node n1 = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex07.py b/doc/examples/modifying_meshes_ex07.py index 93fa2d1cc..898c3a2f9 100644 --- a/doc/examples/modifying_meshes_ex07.py +++ b/doc/examples/modifying_meshes_ex07.py @@ -1,9 +1,6 @@ # Add Tetrahedron -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print("") +from mechanic import * # add node n1 = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex08.py b/doc/examples/modifying_meshes_ex08.py index 1cf27c5df..5face16ec 100644 --- a/doc/examples/modifying_meshes_ex08.py +++ b/doc/examples/modifying_meshes_ex08.py @@ -1,9 +1,6 @@ # Add Hexahedron -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print("") +from mechanic import * # add nodes nId1 = mesh.AddNode(50, 10, 0) diff --git a/doc/examples/modifying_meshes_ex09.py b/doc/examples/modifying_meshes_ex09.py index 914e91b5b..b015f1046 100644 --- a/doc/examples/modifying_meshes_ex09.py +++ b/doc/examples/modifying_meshes_ex09.py @@ -3,12 +3,12 @@ import salome salome.salome_init_without_session() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # a method to build a polygonal mesh element with angles: def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder): @@ -32,5 +32,3 @@ def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert, smesh_builder): f1 = MakePolygon(mesh, 0, 0, 0, 30, 13, smesh_builder=mesh) f2 = MakePolygon(mesh, 0, 0, 10, 21, 9, smesh_builder=mesh) f3 = MakePolygon(mesh, 0, 0, 20, 13, 6, smesh_builder=mesh) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex10.py b/doc/examples/modifying_meshes_ex10.py index ed49c4fa6..d880897fb 100644 --- a/doc/examples/modifying_meshes_ex10.py +++ b/doc/examples/modifying_meshes_ex10.py @@ -1,16 +1,16 @@ # Add Polyhedron +import math import salome salome.salome_init_without_session() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import math +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # Create nodes for 12-hedron with pentagonal faces al = 2 * math.pi / 5.0 @@ -58,6 +58,3 @@ mesh.AddPolyhedralVolume([dd[0], dd[1], dd[2], dd[3], dd[4], # top 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]) - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex11.py b/doc/examples/modifying_meshes_ex11.py index 16ffe8777..268ec1235 100644 --- a/doc/examples/modifying_meshes_ex11.py +++ b/doc/examples/modifying_meshes_ex11.py @@ -1,18 +1,30 @@ # Removing Nodes -import SMESH_mechanic -mesh = SMESH_mechanic.mesh +import salome +salome.salome_init_without_session() + +from salome.geom import geomBuilder +from salome.smesh import smeshBuilder + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +# create and mesh two boxes + +box = geom_builder.MakeBoxDXDYDZ(10.0, 10.0, 10.0) +mesh = smesh_builder.Mesh(box, 'box') +mesh.Segment().NumberOfSegments(10) +mesh.Triangle().MaxElementArea(5) + +mesh.Compute() +print("After Compute(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces())) # remove nodes #246 and #255 res = mesh.RemoveNodes([246, 255]) -if res == 1: print("Nodes removing is OK!") -else: print("KO nodes removing.") - +print("After RemoveNodes(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces())) -# Removing a Node with Reconnection -# ================================== +# removing node #100 with reconnection -print("Before RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces())) -mesh.RemoveNodeWithReconnection( 600 ) -print("After RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces())) +mesh.RemoveNodeWithReconnection( 100 ) +print("After RemoveNodeWithReconnection(): %s nodes, %s faces" % ( mesh.NbNodes(), mesh.NbFaces())) diff --git a/doc/examples/modifying_meshes_ex12.py b/doc/examples/modifying_meshes_ex12.py index 8ef8356f0..74c9797e8 100644 --- a/doc/examples/modifying_meshes_ex12.py +++ b/doc/examples/modifying_meshes_ex12.py @@ -1,8 +1,6 @@ # Removing Elements -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh +from mechanic import * # remove three elements: #850, #859 and #814 res = mesh.RemoveElements([850, 859, 814]) diff --git a/doc/examples/modifying_meshes_ex13.py b/doc/examples/modifying_meshes_ex13.py index 3c2e4e0bf..0ef3c30b2 100644 --- a/doc/examples/modifying_meshes_ex13.py +++ b/doc/examples/modifying_meshes_ex13.py @@ -1,8 +1,6 @@ # Removing Orphan Nodes -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh +from mechanic import * # add orphan nodes mesh.AddNode(0,0,0) diff --git a/doc/examples/modifying_meshes_ex15.py b/doc/examples/modifying_meshes_ex15.py index 7d62245e8..cd058178a 100644 --- a/doc/examples/modifying_meshes_ex15.py +++ b/doc/examples/modifying_meshes_ex15.py @@ -1,27 +1,24 @@ # Moving Nodes - import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ(200, 200, 200) +box = geom_builder.MakeBoxDXDYDZ(200, 200, 200) -mesh = smesh.Mesh( box ) +mesh = smesh_builder.Mesh( box ) mesh.Segment().AutomaticLength(0.1) mesh.Quadrangle() mesh.Compute() # find node at (0,0,0) which is located on a geom vertex node000 = None -for vId in geompy.SubShapeAllIDs( box, geompy.ShapeType["VERTEX"]): +for vId in geom_builder.SubShapeAllIDs( box, geom_builder.ShapeType["VERTEX"]): if node000: break nodeIds = mesh.GetSubMeshNodesId( vId, True ) for node in nodeIds: diff --git a/doc/examples/modifying_meshes_ex16.py b/doc/examples/modifying_meshes_ex16.py index 82bd0e0cf..49c009ea9 100644 --- a/doc/examples/modifying_meshes_ex16.py +++ b/doc/examples/modifying_meshes_ex16.py @@ -1,20 +1,15 @@ # Diagonal Inversion - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # create the following mesh: # .----.----.----. @@ -50,5 +45,3 @@ print("\nDiagonal inversion ... ", end=' ') res = mesh.InverseDiag(bb[1], tt[2]) if not res: print("failed!") else: print("done.") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex17.py b/doc/examples/modifying_meshes_ex17.py index 833c5027f..cc827462b 100644 --- a/doc/examples/modifying_meshes_ex17.py +++ b/doc/examples/modifying_meshes_ex17.py @@ -1,20 +1,14 @@ # Uniting two Triangles - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # create the following mesh: # .----.----.----. @@ -50,5 +44,3 @@ print("\nUnite two triangles ... ", end=' ') res = mesh.DeleteDiag(bb[1], tt[2]) if not res: print("failed!") else: print("done.") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex18.py b/doc/examples/modifying_meshes_ex18.py index 738e8d213..40a890bb4 100644 --- a/doc/examples/modifying_meshes_ex18.py +++ b/doc/examples/modifying_meshes_ex18.py @@ -1,20 +1,15 @@ # Uniting a Set of Triangles - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # create the following mesh: # .----.----.----. @@ -50,5 +45,3 @@ print("\nUnite a set of triangles ... ", end=' ') res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.) if not res: print("failed!") else: print("done.") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex19.py b/doc/examples/modifying_meshes_ex19.py index 386a3cb56..79f4cc9c8 100644 --- a/doc/examples/modifying_meshes_ex19.py +++ b/doc/examples/modifying_meshes_ex19.py @@ -1,20 +1,14 @@ # Orientation - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() # create an empty mesh structure -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # build five quadrangles: dx = 10 @@ -41,5 +35,3 @@ f5 = mesh.AddFace([n5, n6, n12, n11]) # Change the orientation of the second and the fourth faces. mesh.Reorient([2, 4]) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex20.py b/doc/examples/modifying_meshes_ex20.py index ffbff360a..87f387730 100644 --- a/doc/examples/modifying_meshes_ex20.py +++ b/doc/examples/modifying_meshes_ex20.py @@ -1,10 +1,6 @@ # Cutting Quadrangles -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh +from mechanic import * # cut two quadrangles: 405 and 406 mesh.QuadToTri([405, 406], SMESH.FT_MinimumAngle) diff --git a/doc/examples/modifying_meshes_ex21.py b/doc/examples/modifying_meshes_ex21.py index 6aa3f230d..4b9edc3a2 100644 --- a/doc/examples/modifying_meshes_ex21.py +++ b/doc/examples/modifying_meshes_ex21.py @@ -1,35 +1,17 @@ # Smoothing - -import salome -salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() - -import SMESH_mechanic - -#smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh +from mechanic import * # select the top face -faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"]) -face = faces[3] -geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole") +faces = geom_builder.SubShapeAllSorted(mechanic, geom_builder.ShapeType["FACE"]) # create a group of faces to be smoothed -GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", SMESH.FACE) +group_smooth = mesh.GroupOnGeom(faces[3], "Group of faces (smooth)", SMESH.FACE) # perform smoothing # boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) -res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH) +res = mesh.SmoothObject(group_smooth, [], 20, 2., smesh_builder.CENTROIDAL_SMOOTH) print("\nSmoothing ... ", end=' ') if not res: print("failed!") else: print("done.") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex22.py b/doc/examples/modifying_meshes_ex22.py index 94ce7561d..ca1e30e9f 100644 --- a/doc/examples/modifying_meshes_ex22.py +++ b/doc/examples/modifying_meshes_ex22.py @@ -3,17 +3,18 @@ # There is a series of Extrusion Along Line methods added at different times; # a fully functional method is ExtrusionSweepObjects() -import salome, math +import math + +import salome salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +smesh_builder = smeshBuilder.New() # create an empty mesh -mesh = smesh.Mesh() +mesh = smesh_builder.Mesh() # add a node mesh.AddNode( 0.,0.,0. ) @@ -57,9 +58,9 @@ mesh.ExtrusionSweepObject( obj, stepVector, nbSteps ) # extrude all nodes and triangle faces of the disk quarter, applying a scale factor diskGroup = mesh.GetGroupByName( "line_rotated", SMESH.FACE )[0] -crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ), - smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )] -trianglesFilter = smesh.GetFilterFromCriteria( crit ) +crit = [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ), + smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )] +trianglesFilter = smesh_builder.GetFilterFromCriteria( crit ) nodes = [ diskGroup ] edges = [] @@ -79,5 +80,3 @@ elements = cylGroup stepSize = 5. nbSteps = 2 mesh.ExtrusionByNormal( elements, stepSize, nbSteps ) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex23.py b/doc/examples/modifying_meshes_ex23.py index d2f52b229..673569516 100644 --- a/doc/examples/modifying_meshes_ex23.py +++ b/doc/examples/modifying_meshes_ex23.py @@ -4,13 +4,13 @@ import math import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # 1. Create points points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]] @@ -18,33 +18,30 @@ points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, iv = 1 vertices = [] for point in points: - vert = geompy.MakeVertex(point[0], point[1], 0) - #geompy.addToStudy(vert, "Vertex_" + repr(iv)) + vert = geom_builder.MakeVertex(point[0], point[1], 0) 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]) +Edge_straight = geom_builder.MakeEdge(vertices[0], vertices[4]) +Edge_bezierrr = geom_builder.MakeBezier(vertices) +Wire_polyline = geom_builder.MakePolyline(vertices) +Edge_Circle = geom_builder.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") +geom_builder.addToStudy(Edge_straight, "Edge_straight") +geom_builder.addToStudy(Edge_bezierrr, "Edge_bezierrr") +geom_builder.addToStudy(Wire_polyline, "Wire_polyline") +geom_builder.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"]) +Wire_polyline_edges = geom_builder.SubShapeAll(Wire_polyline, geom_builder.ShapeType["EDGE"]) for ii in range(len(Wire_polyline_edges)): - geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + repr(ii + 1)) - pass + geom_builder.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + repr(ii + 1)) # Mesh # Mesh the given shape with the given 1d hypothesis -def Mesh1D(shape1d, nbSeg, name, smesh_builder): +def Mesh1D(shape1d, nbSeg, name): mesh1d_tool = smesh_builder.Mesh(shape1d, name) algo = mesh1d_tool.Segment() hyp = algo.NumberOfSegments(nbSeg) @@ -53,7 +50,7 @@ def Mesh1D(shape1d, nbSeg, name, smesh_builder): return mesh1d_tool # Create a mesh with six nodes, seven edges and two quadrangle faces -def MakeQuadMesh2(mesh_name, smesh_builder): +def MakeQuadMesh2(mesh_name): quad_1 = smesh_builder.Mesh(name = mesh_name) # six nodes @@ -79,19 +76,19 @@ def MakeQuadMesh2(mesh_name, smesh_builder): return [quad_1, [1,2,3,4,5,6,7], [8,9]] # Path meshes -Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight", smesh_builder=smesh) -Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr", smesh_builder=smesh) -Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline", smesh_builder=smesh) -Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle" , smesh_builder=smesh) +Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight") +Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr") +Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline") +Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle") # Initial meshes (to be extruded) -[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1", smesh_builder=smesh) -[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2", smesh_builder=smesh) -[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3", smesh_builder=smesh) -[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4", smesh_builder=smesh) -[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5", smesh_builder=smesh) -[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6", smesh_builder=smesh) -[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7", smesh_builder=smesh) +[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1") +[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2") +[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3") +[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4") +[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5") +[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6") +[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7") # ExtrusionAlongPath # IDsOfElements, PathMesh, PathShape, NodeStart, @@ -137,13 +134,13 @@ error = quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1, # HasRefPoint=False, RefPoint=[0,0,0], MakeGroups=False, # ScaleFactors=[], ScalesVariation=False -quad_1 = MakeQuadMesh2("quad_1", smesh_builder=smesh)[0] -quad_2 = MakeQuadMesh2("quad_2", smesh_builder=smesh)[0] -quad_3 = MakeQuadMesh2("quad_3", smesh_builder=smesh)[0] -quad_4 = MakeQuadMesh2("quad_4", smesh_builder=smesh)[0] -quad_5 = MakeQuadMesh2("quad_5", smesh_builder=smesh)[0] -quad_6 = MakeQuadMesh2("quad_6", smesh_builder=smesh)[0] -quad_7 = MakeQuadMesh2("quad_7", smesh_builder=smesh)[0] +quad_1 = MakeQuadMesh2("quad_1")[0] +quad_2 = MakeQuadMesh2("quad_2")[0] +quad_3 = MakeQuadMesh2("quad_3")[0] +quad_4 = MakeQuadMesh2("quad_4")[0] +quad_5 = MakeQuadMesh2("quad_5")[0] +quad_6 = MakeQuadMesh2("quad_6")[0] +quad_7 = MakeQuadMesh2("quad_7")[0] # 1. Extrusion of two mesh edges along a straight path nn, ee, ff = [], [1,2], [] @@ -175,6 +172,3 @@ error = quad_6.ExtrusionAlongPathObjects( nn, ee, ff, Edge_Circle_mesh ) nn, ee, ff = [], [], quad_7 error = quad_7.ExtrusionAlongPathObjects( nn, ee, ff, Edge_Circle_mesh, Edge_Circle, Angles=[a45, -a45, a45, -a45, a45, -a45, a45, -a45]) - - -salome.sg.updateObjBrowser() diff --git a/doc/examples/modifying_meshes_ex24.py b/doc/examples/modifying_meshes_ex24.py index d07a7ca5b..07f698093 100644 --- a/doc/examples/modifying_meshes_ex24.py +++ b/doc/examples/modifying_meshes_ex24.py @@ -1,12 +1,8 @@ # Revolution import math -import SMESH -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -smesh = SMESH_mechanic.smesh +from mechanic import * # create a group of faces to be revolved FacesRotate = [492, 493, 502, 503] diff --git a/doc/examples/modifying_meshes_ex25.py b/doc/examples/modifying_meshes_ex25.py index 7a6804b06..39250d3a3 100644 --- a/doc/examples/modifying_meshes_ex25.py +++ b/doc/examples/modifying_meshes_ex25.py @@ -1,29 +1,28 @@ # Pattern Mapping - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # define the geometry -Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.) -geompy.addToStudy(Box_1, "Box_1") +Box_1 = geom_builder.MakeBoxDXDYDZ(200., 200., 200.) +geom_builder.addToStudy(Box_1, "Box_1") -faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"]) +faces = geom_builder.SubShapeAll(Box_1, geom_builder.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") +geom_builder.addToStudyInFather(Box_1, Face_1, "Face_1") +geom_builder.addToStudyInFather(Box_1, Face_2, "Face_2") # build a quadrangle mesh 3x3 on Face_1 -Mesh_1 = smesh.Mesh(Face_1) +Mesh_1 = smesh_builder.Mesh(Face_1) algo1D = Mesh_1.Segment() algo1D.NumberOfSegments(3) Mesh_1.Quadrangle() @@ -32,7 +31,7 @@ isDone = Mesh_1.Compute() if not isDone: print('Mesh Mesh_1 : computation failed') # build a triangle mesh on Face_2 -Mesh_2 = smesh.Mesh(Face_2) +Mesh_2 = smesh_builder.Mesh(Face_2) algo1D = Mesh_2.Segment() algo1D.NumberOfSegments(1) @@ -43,7 +42,7 @@ isDone = Mesh_2.Compute() if not isDone: print('Mesh Mesh_2 : computation failed') # create a 2d pattern -pattern = smesh.GetPattern() +pattern = smesh_builder.GetPattern() isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0) if (isDone != 1): print('LoadFromFace :', pattern.GetErrorCode()) @@ -56,7 +55,7 @@ isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0) if (isDone != 1): print('MakeMesh :', pattern.GetErrorCode()) # create quadrangle mesh -Mesh_3 = smesh.Mesh(Box_1) +Mesh_3 = smesh_builder.Mesh(Box_1) Mesh_3.Segment().NumberOfSegments(1) Mesh_3.Quadrangle() Mesh_3.Hexahedron() @@ -64,7 +63,7 @@ isDone = Mesh_3.Compute() if not isDone: print('Mesh Mesh_3 : computation failed') # create a 3d pattern (hexahedrons) -pattern_hexa = smesh.GetPattern() +pattern_hexa = smesh_builder.GetPattern() smp_hexa = """!!! Nb of points: 15 @@ -99,7 +98,7 @@ isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True) if (isDone != 1): print('MakeMesh :', pattern_hexa.GetErrorCode()) # create one more quadrangle mesh -Mesh_4 = smesh.Mesh(Box_1) +Mesh_4 = smesh_builder.Mesh(Box_1) Mesh_4.Segment().NumberOfSegments(1) Mesh_4.Quadrangle() Mesh_4.Hexahedron() @@ -107,7 +106,7 @@ isDone = Mesh_4.Compute() if not isDone: print('Mesh Mesh_4 : computation failed') # create another 3d pattern (pyramids) -pattern_pyra = smesh.GetPattern() +pattern_pyra = smesh_builder.GetPattern() smp_pyra = """!!! Nb of points: 9 diff --git a/doc/examples/modifying_meshes_ex26.py b/doc/examples/modifying_meshes_ex26.py index defd6ba1d..664291f99 100644 --- a/doc/examples/modifying_meshes_ex26.py +++ b/doc/examples/modifying_meshes_ex26.py @@ -1,24 +1,22 @@ # Convert mesh to/from quadratic - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create sphere of radius 100 -Sphere = geompy.MakeSphereR( 100 ) -geompy.addToStudy( Sphere, "Sphere" ) +Sphere = geom_builder.MakeSphereR( 100 ) +geom_builder.addToStudy( Sphere, "Sphere" ) # create simple trihedral mesh -Mesh = smesh.Mesh(Sphere) +Mesh = smesh_builder.Mesh(Sphere) Regular_1D = Mesh.Segment() Nb_Segments = Regular_1D.NumberOfSegments(5) MEFISTO_2D = Mesh.Triangle() diff --git a/doc/examples/modifying_meshes_split_vol.py b/doc/examples/modifying_meshes_split_vol.py index 35eea6aab..f41fafe05 100644 --- a/doc/examples/modifying_meshes_split_vol.py +++ b/doc/examples/modifying_meshes_split_vol.py @@ -4,16 +4,17 @@ import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # mesh a hexahedral mesh -box = geompy.MakeBoxDXDYDZ (1, 1, 1 ) -mesh = smesh.Mesh( box ) +box = geom_builder.MakeBoxDXDYDZ (1, 1, 1 ) +mesh = smesh_builder.Mesh( box ) mesh.AutomaticHexahedralization(0) print("Nb volumes mesh: %s" % mesh.NbHexas()) # split each hexahedron into 6 tetrahedra -mesh.SplitVolumesIntoTetra( mesh, smesh.Hex_6Tet ) +mesh.SplitVolumesIntoTetra( mesh, smesh_builder.Hex_6Tet ) print("Nb volumes mesh: %s" % mesh.NbTetras()) diff --git a/doc/examples/notebook_smesh.py b/doc/examples/notebook_smesh.py index 959cc20bd..8d90ad382 100644 --- a/doc/examples/notebook_smesh.py +++ b/doc/examples/notebook_smesh.py @@ -1,19 +1,17 @@ # Using SALOME NoteBook - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() +from salome_notebook import notebook -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # set variables -notebook = salome_notebook.notebook notebook.set("Length", 100) notebook.set("Width", 200) notebook.set("Offset", 50) @@ -23,11 +21,11 @@ notebook.set("MaxElementArea", 800) notebook.set("MaxElementVolume", 900) # create a box -box = geompy.MakeBoxDXDYDZ("Length", "Width", 300) -idbox = geompy.addToStudy(box, "Box") +box = geom_builder.MakeBoxDXDYDZ("Length", "Width", 300) +idbox = geom_builder.addToStudy(box, "Box") # create a mesh -tetra = smesh.Mesh(box, "MeshBox") +tetra = smesh_builder.Mesh(box, "MeshBox") algo1D = tetra.Segment() algo1D.NumberOfSegments("NbSegments") diff --git a/doc/examples/prism_3d_algo.py b/doc/examples/prism_3d_algo.py index 06a2c5cc2..20ab781e8 100644 --- a/doc/examples/prism_3d_algo.py +++ b/doc/examples/prism_3d_algo.py @@ -4,15 +4,14 @@ import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() - -import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -OX = geompy.MakeVectorDXDYDZ(1,0,0) -OY = geompy.MakeVectorDXDYDZ(0,1,0) -OZ = geompy.MakeVectorDXDYDZ(0,0,1) +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +OX = geom_builder.MakeVectorDXDYDZ(1,0,0) +OY = geom_builder.MakeVectorDXDYDZ(0,1,0) +OZ = geom_builder.MakeVectorDXDYDZ(0,0,1) # Y ^ Make geometry of a "pipe" with the following base (cross section). # | Big central quadrangles will be meshed with triangles, walls @@ -31,30 +30,28 @@ OZ = geompy.MakeVectorDXDYDZ(0,0,1) # | | | | | | | --> # +--+--+--+--+--+--+ X -quadBig = geompy.MakeFaceHW( 20,20, 1 ) -quadBig = geompy.MakeTranslation( quadBig, 15,15,0 ) -quadSmall = geompy.MakeFaceHW( 10,10, 1 ) -smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 ) -smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 ) -smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:] +quadBig = geom_builder.MakeFaceHW( 20,20, 1 ) +quadBig = geom_builder.MakeTranslation( quadBig, 15,15,0 ) +quadSmall = geom_builder.MakeFaceHW( 10,10, 1 ) +smallQuads1 = geom_builder.MakeMultiTranslation1D( quadSmall, OX, 10, 3 ) +smallQuads2 = geom_builder.MakeMultiTranslation1D( quadSmall, OY, 10, 3 ) +smallQuads2 = geom_builder.SubShapeAllSortedCentres( smallQuads2, geom_builder.ShapeType["FACE"])[1:] -base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig]) -axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ ) -base = geompy.MultiRotate1DNbTimes( base, axis, 4) -base = geompy.MakePartition( [base], theName="base") -path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0]) +base = geom_builder.MakeCompound( smallQuads2 + [smallQuads1, quadBig]) +axis = geom_builder.MakeLine( geom_builder.MakeVertex( 25,25,0), OZ ) +base = geom_builder.MultiRotate1DNbTimes( base, axis, 4) +base = geom_builder.MakePartition( [base], theName="base") +path = geom_builder.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0]) # Make the pipe, each quadrangle of the base turns into a prism with composite wall faces -pipe = geompy.MakePipe( base, path ) -prisms = geompy.MakePartition( [pipe], theName="prisms") - +pipe = geom_builder.MakePipe( base, path ) +prisms = geom_builder.MakePartition( [pipe], theName="prisms") # get base faces of the prism to define sub-mesh on them -smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad") -bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad") - +smallQuad = geom_builder.GetFaceNearPoint( prisms, geom_builder.MakeVertex( 0,0,0 ), "smallQuad") +bigQuad = geom_builder.GetFaceNearPoint( prisms, geom_builder.MakeVertex( 15,15,0 ), "bigQuad") -mesh = smesh.Mesh( prisms ) +mesh = smesh_builder.Mesh( prisms ) # assign Global hypotheses diff --git a/doc/examples/quad_medial_axis_algo.py b/doc/examples/quad_medial_axis_algo.py index 5937d03ac..450827bd4 100644 --- a/doc/examples/quad_medial_axis_algo.py +++ b/doc/examples/quad_medial_axis_algo.py @@ -4,21 +4,23 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a ring face -circleEdge1 = geompy.MakeCircleR( 3 ) -circleEdge2 = geompy.MakeCircleR( 7 ) -ring = geompy.MakeFaceWires( [ circleEdge1, circleEdge2 ], True, theName='Ring' ) -circleLen1 = geompy.BasicProperties( circleEdge1 )[0] -circleLen2 = geompy.BasicProperties( circleEdge2 )[0] +circleEdge1 = geom_builder.MakeCircleR( 3 ) +circleEdge2 = geom_builder.MakeCircleR( 7 ) +ring = geom_builder.MakeFaceWires( [ circleEdge1, circleEdge2 ], True, theName='Ring' ) +circleLen1 = geom_builder.BasicProperties( circleEdge1 )[0] +circleLen2 = geom_builder.BasicProperties( circleEdge2 )[0] # make a mesh -mesh = smesh.Mesh( ring ) +mesh = smesh_builder.Mesh( ring ) circNbSeg = 60 algo1d = mesh.Segment() diff --git a/doc/examples/quality_controls_defl.py b/doc/examples/quality_controls_defl.py index 97553e02f..42c04a315 100644 --- a/doc/examples/quality_controls_defl.py +++ b/doc/examples/quality_controls_defl.py @@ -1,22 +1,22 @@ # Deflection 2D - import salome salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # fuse a box and a sphere -Sphere_1 = geompy.MakeSphereR(100) -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Fuse = geompy.MakeFuse( Sphere_1, Box_1, theName="box + sphere" ) +Sphere_1 = geom_builder.MakeSphereR(100) +Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200) +Fuse = geom_builder.MakeFuse( Sphere_1, Box_1, theName="box + sphere" ) # create a mesh -mesh = smesh.Mesh( Fuse, "Deflection_2D") +mesh = smesh_builder.Mesh( Fuse, "Deflection_2D") algo = mesh.Segment() algo.LocalLength(35) algo = mesh.Triangle() @@ -34,12 +34,10 @@ print("deflection of face %s = %s" % ( faceID, defl )) margin = minMax[1] / 2 # get all faces with deflection LESS than the margin -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Deflection2D, '<', margin, mesh=mesh) anIds = aFilter.GetIDs() print("%s faces have deflection less than %s" %( len(anIds), margin )) # create a group of faces with deflection MORE than the margin aGroup = mesh.MakeGroup("Deflection > " + repr(margin), SMESH.FACE, SMESH.FT_Deflection2D,'>',margin) print("%s faces have deflection more than %s: %s ..." %( aGroup.Size(), margin, aGroup.GetIDs()[:10] )) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex01.py b/doc/examples/quality_controls_ex01.py index 2cb3c97fc..dda1aca12 100644 --- a/doc/examples/quality_controls_ex01.py +++ b/doc/examples/quality_controls_ex01.py @@ -1,25 +1,24 @@ # Free Borders - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeShell(FaceList) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Mesh_free_borders") +mesh = smesh_builder.Mesh(box, "Mesh_free_borders") algo = mesh.Segment() algo.NumberOfSegments(5) algo = mesh.Triangle() @@ -27,7 +26,7 @@ algo.MaxElementArea(20.) mesh.Compute() # criterion : free borders -aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) +aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -43,5 +42,3 @@ print("") # create a group aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Free borders") aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex02.py b/doc/examples/quality_controls_ex02.py index c03942010..3b48bf305 100644 --- a/doc/examples/quality_controls_ex02.py +++ b/doc/examples/quality_controls_ex02.py @@ -1,25 +1,24 @@ # Borders at Multiconnection - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeShell(FaceList) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections") +mesh = smesh_builder.Mesh(box, "Mesh_borders_at_multi-connections") algo = mesh.Segment() algo.NumberOfSegments(5) algo = mesh.Triangle() @@ -29,7 +28,7 @@ mesh.Compute() # Criterion : Borders at multi-connection nb_conn = 2 -aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, nb_conn) +aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, nb_conn) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -45,5 +44,3 @@ print("") # create a group aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Borders at multi-connections") aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex03.py b/doc/examples/quality_controls_ex03.py index 65db46bbf..9958d7115 100644 --- a/doc/examples/quality_controls_ex03.py +++ b/doc/examples/quality_controls_ex03.py @@ -1,25 +1,24 @@ # Length 1D - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeShell(FaceList) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Mesh_Length_1D") +mesh = smesh_builder.Mesh(box, "Mesh_Length_1D") algo = mesh.Segment() algo.NumberOfSegments(5) algo = mesh.Triangle() @@ -29,7 +28,7 @@ mesh.Compute() # Criterion : Length > 3. length_margin = 3. -aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin) +aFilter = smesh_builder.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -45,5 +44,3 @@ print("") # create a group aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + repr(length_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex04.py b/doc/examples/quality_controls_ex04.py index 07867cc2f..b4c1dd252 100644 --- a/doc/examples/quality_controls_ex04.py +++ b/doc/examples/quality_controls_ex04.py @@ -1,19 +1,14 @@ # Free Edges -import SMESH_mechanic -import SMESH +from mechanic import * -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -aFilterMgr = smesh.CreateFilterManager() +aFilterMgr = smesh_builder.CreateFilterManager() # Remove some elements to obtain free edges # Criterion : AREA > 95. area_margin = 95. -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -36,5 +31,3 @@ for i in range(len(aBorders)): aGroupF.Add([aBorder.myElemId]) aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2]) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex05.py b/doc/examples/quality_controls_ex05.py index b01e35cae..d9a415deb 100644 --- a/doc/examples/quality_controls_ex05.py +++ b/doc/examples/quality_controls_ex05.py @@ -1,22 +1,21 @@ # Free Nodes - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Mesh_free_nodes") +mesh = smesh_builder.Mesh(box, "Mesh_free_nodes") algo = mesh.Segment() algo.NumberOfSegments(10) algo = mesh.Triangle(smeshBuilder.MEFISTO) @@ -27,14 +26,14 @@ mesh.Compute() # Criterion : AREA < 80. area_margin = 80. -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, area_margin) anIds = mesh.GetIdsFromFilter(aFilter) mesh.RemoveElements(anIds) # criterion : free nodes -aFilter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) +aFilter = smesh_builder.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) anNodeIds = mesh.GetIdsFromFilter(aFilter) # create a group @@ -50,5 +49,3 @@ for i in range(len(anNodeIds)): j = j + 1 pass print("") - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex06.py b/doc/examples/quality_controls_ex06.py index c0cecd4b0..f487e6b5f 100644 --- a/doc/examples/quality_controls_ex06.py +++ b/doc/examples/quality_controls_ex06.py @@ -1,45 +1,44 @@ # Free Faces - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -####### GEOM part ######## +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6]) -Box_1 = geompy.GetMainShape(Box_1_vertex_6) -Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16]) -Box_1 = geompy.GetMainShape(Box_1_vertex_16) -Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11]) -Box_1 = geompy.GetMainShape(Box_1_vertex_11) -Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000) -Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) - -Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19]) -Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21]) -Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000) +####### GEOM part ######## -geompy.addToStudy( Box_1, "Box_1" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" ) -geompy.addToStudy( Plane_1, "Plane_1" ) -geompy.addToStudy( Partition_1, "Partition_1" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" ) -geompy.addToStudy( Plane_2, "Plane_2" ) +Box_1 = geom_builder.MakeBoxDXDYDZ(200, 200, 200) +Box_1_vertex_6 = geom_builder.GetSubShape(Box_1, [6]) +Box_1 = geom_builder.GetMainShape(Box_1_vertex_6) +Box_1_vertex_16 = geom_builder.GetSubShape(Box_1, [16]) +Box_1 = geom_builder.GetMainShape(Box_1_vertex_16) +Box_1_vertex_11 = geom_builder.GetSubShape(Box_1, [11]) +Box_1 = geom_builder.GetMainShape(Box_1_vertex_11) +Plane_1 = geom_builder.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000) +Partition_1 = geom_builder.MakePartition([Box_1], [Plane_1], [], [], geom_builder.ShapeType["SOLID"], 0, [], 0) + +Box_1_vertex_19 = geom_builder.GetSubShape(Box_1, [19]) +Box_1_vertex_21 = geom_builder.GetSubShape(Box_1, [21]) +Plane_2 = geom_builder.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000) + +geom_builder.addToStudy( Box_1, "Box_1" ) +geom_builder.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" ) +geom_builder.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" ) +geom_builder.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" ) +geom_builder.addToStudy( Plane_1, "Plane_1" ) +geom_builder.addToStudy( Partition_1, "Partition_1" ) +geom_builder.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" ) +geom_builder.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" ) +geom_builder.addToStudy( Plane_2, "Plane_2" ) ###### SMESH part ###### -Mesh_1 = smesh.Mesh(Partition_1) +Mesh_1 = smesh_builder.Mesh(Partition_1) Regular_1D = Mesh_1.Segment() Max_Size_1 = Regular_1D.MaxSize(34.641) MEFISTO_2D = Mesh_1.Triangle() @@ -47,7 +46,7 @@ Tetrahedronn = Mesh_1.Tetrahedron() isDone = Mesh_1.Compute() # create a group of free faces -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces ) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces ) aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces") @@ -64,15 +63,13 @@ for i in range(len(aFaceIds)): print("") #filter faces from plane 2 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_2) aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) aGroup.Remove(aFaceIds) # create a group of shared faces (located on partition boundary inside box) -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1) aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Shared_faces") aGroup.Add(aFaceIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex07.py b/doc/examples/quality_controls_ex07.py index d7f296546..ce88f3773 100644 --- a/doc/examples/quality_controls_ex07.py +++ b/doc/examples/quality_controls_ex07.py @@ -1,22 +1,19 @@ # Bare border faces - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ(100, 100, 100) -geompy.addToStudy( box, "box" ) +box = geom_builder.MakeBoxDXDYDZ(100, 100, 100) +geom_builder.addToStudy( box, "box" ) -mesh = smesh.Mesh(box) +mesh = smesh_builder.Mesh(box) mesh.Segment().NumberOfSegments(3) mesh.Quadrangle() mesh.Compute() diff --git a/doc/examples/quality_controls_ex08.py b/doc/examples/quality_controls_ex08.py index 8fc367ea0..61c7a2553 100644 --- a/doc/examples/quality_controls_ex08.py +++ b/doc/examples/quality_controls_ex08.py @@ -1,26 +1,23 @@ # Bare border volumes - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ(100, 30, 10) +box = geom_builder.MakeBoxDXDYDZ(100, 30, 10) # the smallest face of the box -face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0] +face = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["FACE"])[0] -geompy.addToStudy( box, "box" ) -geompy.addToStudyInFather( box, face, "face" ) +geom_builder.addToStudy( box, "box" ) +geom_builder.addToStudyInFather( box, face, "face" ) -mesh = smesh.Mesh(box) +mesh = smesh_builder.Mesh(box) mesh.AutomaticHexahedralization(); # remove half of mesh faces from the smallest face diff --git a/doc/examples/quality_controls_ex09.py b/doc/examples/quality_controls_ex09.py index 92a8f052f..c05ba61ca 100644 --- a/doc/examples/quality_controls_ex09.py +++ b/doc/examples/quality_controls_ex09.py @@ -1,20 +1,15 @@ # Over-constrained faces - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() -mesh = smesh.Mesh() -faceFilter = smesh.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace) +mesh = smesh_builder.Mesh() +faceFilter = smesh_builder.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace) #make an edge n1 = mesh.AddNode(0,0,0) @@ -23,5 +18,5 @@ edge = mesh.AddEdge([n1,n2]) assert( not mesh.GetIdsFromFilter( faceFilter )) # make faces -mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 5) +mesh.ExtrusionSweep([edge], smesh_builder.MakeDirStruct(0,7,0), 5) assert( 5 == len( mesh.GetIdsFromFilter( faceFilter ))) diff --git a/doc/examples/quality_controls_ex10.py b/doc/examples/quality_controls_ex10.py index b71b5d6da..b36923442 100644 --- a/doc/examples/quality_controls_ex10.py +++ b/doc/examples/quality_controls_ex10.py @@ -1,25 +1,20 @@ # Over-constrained volumes - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +smesh_builder = smeshBuilder.New() -mesh = smesh.Mesh() -volumeFilter = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_OverConstrainedVolume) +mesh = smesh_builder.Mesh() +volumeFilter = smesh_builder.GetFilter(SMESH.VOLUME,SMESH.FT_OverConstrainedVolume) # make volumes by extrusion of one face n1 = mesh.AddNode(0,0,0) n2 = mesh.AddNode(10,0,0) edge = mesh.AddEdge([n1,n2]) -mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 1) -mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh.MakeDirStruct(0,0,5), 7) +mesh.ExtrusionSweep([edge], smesh_builder.MakeDirStruct(0,7,0), 1) +mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh_builder.MakeDirStruct(0,0,5), 7) assert( 7 == len( mesh.GetIdsFromFilter( volumeFilter ))) diff --git a/doc/examples/quality_controls_ex11.py b/doc/examples/quality_controls_ex11.py index fbc2b7c5f..1b08179f1 100644 --- a/doc/examples/quality_controls_ex11.py +++ b/doc/examples/quality_controls_ex11.py @@ -1,25 +1,24 @@ # Length 2D - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") +box = geom_builder.MakeShell(FaceList) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Mesh_Length_2D") +mesh = smesh_builder.Mesh(box, "Mesh_Length_2D") algo = mesh.Segment() algo.NumberOfSegments(5) algo = mesh.Triangle() @@ -29,7 +28,7 @@ mesh.Compute() # Criterion : Length 2D > 5.7 length_margin = 5.7 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, length_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, length_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -46,5 +45,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + repr(length_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex12.py b/doc/examples/quality_controls_ex12.py index f6227793c..a76fa3543 100644 --- a/doc/examples/quality_controls_ex12.py +++ b/doc/examples/quality_controls_ex12.py @@ -1,25 +1,24 @@ # Borders at Multiconnection 2D - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a compound of two glued boxes -box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -box2 = geompy.MakeTranslation(box1, 0., 20., 0) -comp = geompy.MakeCompound([box1, box2]) -box = geompy.MakeGlueFaces(comp, 0.000001) -idbox = geompy.addToStudy(box, "box") +box1 = geom_builder.MakeBox(0., 0., 0., 20., 20., 15.) +box2 = geom_builder.MakeTranslation(box1, 0., 20., 0) +comp = geom_builder.MakeCompound([box1, box2]) +box = geom_builder.MakeGlueFaces(comp, 0.000001) +idbox = geom_builder.addToStudy(box, "box") # create a mesh -mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh") +mesh = smesh_builder.Mesh(box, "Box compound : 2D triangle mesh") algo = mesh.Segment() algo.NumberOfSegments(5) algo = mesh.Triangle() @@ -29,7 +28,7 @@ mesh.Compute() # Criterion : MULTI-CONNECTION 2D = 3 nb_conn = 3 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_EqualTo, nb_conn) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_EqualTo, nb_conn) anIds = mesh.GetIdsFromFilter(aFilter) @@ -46,5 +45,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + repr(nb_conn)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex13.py b/doc/examples/quality_controls_ex13.py index 5cee2a8dd..994025f1d 100644 --- a/doc/examples/quality_controls_ex13.py +++ b/doc/examples/quality_controls_ex13.py @@ -1,16 +1,11 @@ # Area -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : AREA > 100. area_margin = 100. -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + repr(area_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex14.py b/doc/examples/quality_controls_ex14.py index ab939bae8..23f9f5e78 100644 --- a/doc/examples/quality_controls_ex14.py +++ b/doc/examples/quality_controls_ex14.py @@ -1,16 +1,11 @@ # Taper -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : Taper > 3e-20 taper_margin = 3e-20 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + repr(taper_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex15.py b/doc/examples/quality_controls_ex15.py index d7cb29071..2775b2073 100644 --- a/doc/examples/quality_controls_ex15.py +++ b/doc/examples/quality_controls_ex15.py @@ -1,16 +1,11 @@ # Aspect Ratio -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : ASPECT RATIO > 1.8 ar_margin = 1.8 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, ar_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, ar_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + repr(ar_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex16.py b/doc/examples/quality_controls_ex16.py index 645b2cd23..df4ba5eae 100644 --- a/doc/examples/quality_controls_ex16.py +++ b/doc/examples/quality_controls_ex16.py @@ -1,16 +1,11 @@ # Minimum Angle -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : MINIMUM ANGLE < 35. min_angle = 35. -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, min_angle) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, min_angle) anIds = mesh.GetIdsFromFilter(aFilter) @@ -28,5 +23,3 @@ print("") aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Minimum Angle < " + repr(min_angle)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex17.py b/doc/examples/quality_controls_ex17.py index a22f5e5ff..b8ebd9ae7 100644 --- a/doc/examples/quality_controls_ex17.py +++ b/doc/examples/quality_controls_ex17.py @@ -1,16 +1,11 @@ # Warping -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : WARP ANGLE > 1e-15 wa_margin = 1e-15 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -28,5 +23,3 @@ print("") aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Warp > " + repr(wa_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex18.py b/doc/examples/quality_controls_ex18.py index 9f6f7a3f3..1ca2cb4b4 100644 --- a/doc/examples/quality_controls_ex18.py +++ b/doc/examples/quality_controls_ex18.py @@ -1,16 +1,11 @@ # Skew -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : Skew > 38. skew_margin = 38. -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + repr(skew_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex19.py b/doc/examples/quality_controls_ex19.py index 62ef71030..daf2f8345 100644 --- a/doc/examples/quality_controls_ex19.py +++ b/doc/examples/quality_controls_ex19.py @@ -1,16 +1,11 @@ # Element Diameter 2D -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome +from mechanic import * # Criterion : ELEMENT DIAMETER 2D > 10 mel_2d_margin = 10 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, mel_2d_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, mel_2d_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + repr(mel_2d_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex20.py b/doc/examples/quality_controls_ex20.py index dd594c193..27679198c 100644 --- a/doc/examples/quality_controls_ex20.py +++ b/doc/examples/quality_controls_ex20.py @@ -1,16 +1,11 @@ # Aspect Ratio 3D -import SMESH_mechanic_tetra -import SMESH - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome +from mechanic import * # Criterion : ASPECT RATIO 3D > 4.5 ar_margin = 4.5 -aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreThan, ar_margin) +aFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreThan, ar_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -28,5 +23,3 @@ print("") aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + repr(ar_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex21.py b/doc/examples/quality_controls_ex21.py index 683e314b7..1fb8bb4dd 100644 --- a/doc/examples/quality_controls_ex21.py +++ b/doc/examples/quality_controls_ex21.py @@ -1,16 +1,11 @@ # Volume -import SMESH_mechanic_tetra -import SMESH - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome +from mechanic import * # Criterion : VOLUME < 7. volume_margin = 7. -aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, volume_margin) +aFilter = smesh_builder.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, volume_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -29,5 +24,3 @@ print("") aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Volume < " + repr(volume_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/quality_controls_ex22.py b/doc/examples/quality_controls_ex22.py index 131091f8c..c33c3ecf1 100644 --- a/doc/examples/quality_controls_ex22.py +++ b/doc/examples/quality_controls_ex22.py @@ -1,16 +1,11 @@ # Element Diameter 3D -import SMESH_mechanic_tetra -import SMESH - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome +from mechanic import * # Criterion : ELEMENT DIAMETER 3D > 10 mel_3d_margin = 10 -aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, mel_3d_margin) +aFilter = smesh_builder.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, mel_3d_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -27,5 +22,3 @@ print("") # create a group aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + repr(mel_3d_margin)) aGroup.Add(anIds) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/radial_prism_3d_algo.py b/doc/examples/radial_prism_3d_algo.py index fe29e52dc..a2623d846 100644 --- a/doc/examples/radial_prism_3d_algo.py +++ b/doc/examples/radial_prism_3d_algo.py @@ -2,25 +2,25 @@ import salome salome.salome_init_without_session() + from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -# Create geometry: hollow sphere +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -sphere_1 = geompy.MakeSphereR( 100 ) -sphere_2 = geompy.MakeSphereR( 50 ) +# Create geometry: hollow sphere -hollow_sphere = geompy.MakeCut( sphere_1, sphere_2, theName="hollow sphere") +sphere_1 = geom_builder.MakeSphereR( 100 ) +sphere_2 = geom_builder.MakeSphereR( 50 ) -faces = geompy.ExtractShapes( hollow_sphere, geompy.ShapeType["FACE"] ) +hollow_sphere = geom_builder.MakeCut( sphere_1, sphere_2, theName="hollow sphere") +faces = geom_builder.ExtractShapes( hollow_sphere, geom_builder.ShapeType["FACE"] ) # Create mesh -mesh = smesh.Mesh( hollow_sphere, "Mesh of hollow sphere" ) +mesh = smesh_builder.Mesh( hollow_sphere, "Mesh of hollow sphere" ) # assign Global Radial Prism algorithm prism_algo = mesh.Prism() diff --git a/doc/examples/split_biquad.py b/doc/examples/split_biquad.py index f9d97b31a..90d544e36 100644 --- a/doc/examples/split_biquad.py +++ b/doc/examples/split_biquad.py @@ -4,23 +4,23 @@ import salome salome.salome_init_without_session() from salome.geom import geomBuilder -geompy = geomBuilder.New() - from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make a shape consisting of two quadranges -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OY1 = geompy.MakeTranslation( OY, 1, 0, 0 ) -OY2 = geompy.MakeTranslation( OY, 2, 0, 0 ) -q1 = geompy.MakeQuad2Edges( OY, OY1 ) -q2 = geompy.MakeQuad2Edges( OY1, OY2 ) +OY = geom_builder.MakeVectorDXDYDZ(0, 1, 0) +OY1 = geom_builder.MakeTranslation( OY, 1, 0, 0 ) +OY2 = geom_builder.MakeTranslation( OY, 2, 0, 0 ) +q1 = geom_builder.MakeQuad2Edges( OY, OY1 ) +q2 = geom_builder.MakeQuad2Edges( OY1, OY2 ) -shape = geompy.Partition( [q1,q2], theName='shape' ) -ff = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"], theName="quad" ) +shape = geom_builder.Partition( [q1,q2], theName='shape' ) +ff = geom_builder.SubShapeAll( shape, geom_builder.ShapeType["FACE"], theName="quad" ) # mesh one quadrange with quadrangless and the other with triangles -mesh = smesh.Mesh( shape ) +mesh = smesh_builder.Mesh( shape ) mesh.Segment().NumberOfSegments(1) mesh.Quadrangle() mesh.Triangle( ff[1] ) diff --git a/doc/examples/test_homard_adapt.py b/doc/examples/test_homard_adapt.py index fc81734e7..0e250eee0 100644 --- a/doc/examples/test_homard_adapt.py +++ b/doc/examples/test_homard_adapt.py @@ -7,7 +7,6 @@ import tempfile import salome salome.salome_init_without_session() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder import SMESHHOMARD diff --git a/doc/examples/test_uniform_refinement.py b/doc/examples/test_uniform_refinement.py index 08ec65533..96139e01b 100644 --- a/doc/examples/test_uniform_refinement.py +++ b/doc/examples/test_uniform_refinement.py @@ -7,7 +7,6 @@ import tempfile import salome salome.salome_init_without_session() -import SMESH, SALOMEDS from salome.smesh import smeshBuilder import SMESHHOMARD diff --git a/doc/examples/tests.set b/doc/examples/tests.set index bd2e734f1..ebdc95461 100644 --- a/doc/examples/tests.set +++ b/doc/examples/tests.set @@ -23,7 +23,6 @@ # --------------------------------------------------------------------------- SET(BAD_TESTS - 3dmesh.py a3DmeshOnModified2Dmesh.py creating_meshes_ex01.py creating_meshes_ex03.py @@ -40,6 +39,7 @@ SET(BAD_TESTS filters_ex35.py generate_flat_elements.py modifying_meshes_ex26.py + mesh_3d.py notebook_smesh.py quality_controls_ex06.py quality_controls_ex20.py diff --git a/doc/examples/transforming_meshes_ex01.py b/doc/examples/transforming_meshes_ex01.py index 93f5196c0..27dd16124 100644 --- a/doc/examples/transforming_meshes_ex01.py +++ b/doc/examples/transforming_meshes_ex01.py @@ -1,8 +1,6 @@ # Translation -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh +from mechanic import * # define translation vector vector = [-150., -150., 0.] diff --git a/doc/examples/transforming_meshes_ex02.py b/doc/examples/transforming_meshes_ex02.py index 5b3ff287e..d516a795f 100644 --- a/doc/examples/transforming_meshes_ex02.py +++ b/doc/examples/transforming_meshes_ex02.py @@ -2,11 +2,7 @@ import math -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh +from mechanic import * # define rotation axis and angle axisXYZ = SMESH.AxisStruct(0., 0., 0., 5., 5., 20.) diff --git a/doc/examples/transforming_meshes_ex03.py b/doc/examples/transforming_meshes_ex03.py index edd4cb438..07c8bb86a 100644 --- a/doc/examples/transforming_meshes_ex03.py +++ b/doc/examples/transforming_meshes_ex03.py @@ -2,18 +2,18 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -Box = geompy.MakeBoxDXDYDZ(200, 200, 200) -f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() + +Box = geom_builder.MakeBoxDXDYDZ(200, 200, 200) +f = geom_builder.SubShapeAllSorted(Box, geom_builder.ShapeType["FACE"]) -Mesh1 = smesh.Mesh(f[0]) +Mesh1 = smesh_builder.Mesh(f[0]) Regular_1D = Mesh1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(3) Nb_Segments_1.SetDistrType( 0 ) diff --git a/doc/examples/transforming_meshes_ex04.py b/doc/examples/transforming_meshes_ex04.py index 910035521..cd421fe7e 100644 --- a/doc/examples/transforming_meshes_ex04.py +++ b/doc/examples/transforming_meshes_ex04.py @@ -1,14 +1,8 @@ # Symmetry -import math - -import SMESH_mechanic -import SMESH - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh +from mechanic import * # create a symmetrical copy of the mesh mirrored through a point axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0) -mesh.Mirror([], axis, smesh.POINT, 1) +mesh.Mirror([], axis, smesh_builder.POINT, 1) diff --git a/doc/examples/transforming_meshes_ex05.py b/doc/examples/transforming_meshes_ex05.py index 0adf0247c..4d3b349e9 100644 --- a/doc/examples/transforming_meshes_ex05.py +++ b/doc/examples/transforming_meshes_ex05.py @@ -1,14 +1,12 @@ # Merging Nodes -import SMESH_mechanic, SMESH -mesh = SMESH_mechanic.mesh -smesh = SMESH_mechanic.smesh +from mechanic import * # criterion of coincidence Tolerance = 4.0 # find close nodes of triangle elements only -triangleFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) +triangleFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_ElemGeomType,'=', SMESH.Geom_TRIANGLE ) GroupsOfNodesOfTriangles = mesh.FindCoincidentNodesOnPart([triangleFilter],Tolerance) # prevent nodes located on geom edges from removal during merge: @@ -17,7 +15,6 @@ allSegs = mesh.MakeGroup( "all segments", SMESH.EDGE, SMESH.FT_ElemGeomType,'=', mesh.MergeNodes(GroupsOfNodesOfTriangles, NodesToKeep=allSegs) - # find close nodes in the whole mesh GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance) diff --git a/doc/examples/transforming_meshes_ex06.py b/doc/examples/transforming_meshes_ex06.py index 964449fe3..2600cb734 100644 --- a/doc/examples/transforming_meshes_ex06.py +++ b/doc/examples/transforming_meshes_ex06.py @@ -1,39 +1,39 @@ # Merging Elements - import salome salome.salome_init_without_session() -from salome.geom import geomBuilder -geompy = geomBuilder.New() import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a face to be meshed -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) +px = geom_builder.MakeVertex(100., 0. , 0. ) +py = geom_builder.MakeVertex(0. , 100., 0. ) +pz = geom_builder.MakeVertex(0. , 0. , 100.) -vxy = geompy.MakeVector(px, py) -arc = geompy.MakeArc(py, pz, px) +vxy = geom_builder.MakeVector(px, py) +arc = geom_builder.MakeArc(py, pz, px) -wire = geompy.MakeWire([vxy, arc]) +wire = geom_builder.MakeWire([vxy, arc]) isPlanarFace = 1 -face1 = geompy.MakeFace(wire, isPlanarFace) -id_face1 = geompy.addToStudy(face1, "Face1") +face1 = geom_builder.MakeFace(wire, isPlanarFace) +id_face1 = geom_builder.addToStudy(face1, "Face1") # create a circle to be an extrusion path -px1 = geompy.MakeVertex( 100., 100., 0.) -py1 = geompy.MakeVertex(-100., -100., 0.) -pz1 = geompy.MakeVertex( 0., 0., 50.) +px1 = geom_builder.MakeVertex( 100., 100., 0.) +py1 = geom_builder.MakeVertex(-100., -100., 0.) +pz1 = geom_builder.MakeVertex( 0., 0., 50.) -circle = geompy.MakeCircleThreePnt(py1, pz1, px1) -id_circle = geompy.addToStudy(circle, "Path") +circle = geom_builder.MakeCircleThreePnt(py1, pz1, px1) +id_circle = geom_builder.addToStudy(circle, "Path") # create a 2D mesh on the face -trias = smesh.Mesh(face1, "Face : 2D mesh") +trias = smesh_builder.Mesh(face1, "Face : 2D mesh") algo1D = trias.Segment() algo1D.NumberOfSegments(6) @@ -46,7 +46,7 @@ trias.Compute() faceTriGroup = trias.Group( face1, "face triangles" ) # create a path mesh -circlemesh = smesh.Mesh(circle, "Path mesh") +circlemesh = smesh_builder.Mesh(circle, "Path mesh") algo = circlemesh.Segment() algo.NumberOfSegments(10) circlemesh.Compute() @@ -82,5 +82,3 @@ print("Number of elements after MergeEqualElements:") print("Edges : ", trias.NbEdges()) print("Faces : ", trias.NbFaces()) print("Volumes : ", trias.NbVolumes()) - -salome.sg.updateObjBrowser() diff --git a/doc/examples/transforming_meshes_ex07.py b/doc/examples/transforming_meshes_ex07.py index 65865aca5..db7a6cb7c 100644 --- a/doc/examples/transforming_meshes_ex07.py +++ b/doc/examples/transforming_meshes_ex07.py @@ -1,33 +1,31 @@ # Sew Meshes Border to Side - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create two faces of a box -box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.) -facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +box1 = geom_builder.MakeBox(0., 0., -10., 30., 20., 25.) +facesList1 = geom_builder.SubShapeAll(box1, geom_builder.ShapeType["FACE"]) face1 = facesList1[2] -box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) -facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +box2 = geom_builder.MakeBox(0., 5., 0., 20., 20., 15.) +facesList2 = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["FACE"]) face2 = facesList2[1] -edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) +edgesList = geom_builder.SubShapeAll(face2, geom_builder.ShapeType["EDGE"]) edge1 = edgesList[2] -aComp = geompy.MakeCompound([face1, face2]) -geompy.addToStudy(aComp, "Two faces") +aComp = geom_builder.MakeCompound([face1, face2]) +geom_builder.addToStudy(aComp, "Two faces") # create a mesh on two faces -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") +mesh = smesh_builder.Mesh(aComp, "Two faces : quadrangle mesh") algo1D = mesh.Segment() algo1D.NumberOfSegments(9) diff --git a/doc/examples/transforming_meshes_ex08.py b/doc/examples/transforming_meshes_ex08.py index 542bb5f54..3de67b9df 100644 --- a/doc/examples/transforming_meshes_ex08.py +++ b/doc/examples/transforming_meshes_ex08.py @@ -1,35 +1,31 @@ # Sew Conform Free Borders - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create two faces of the box -box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.) -facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +box1 = geom_builder.MakeBox(0., 0., -10., 20., 20., 15.) +facesList1 = geom_builder.SubShapeAll(box1, geom_builder.ShapeType["FACE"]) face1 = facesList1[2] -box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) -facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +box2 = geom_builder.MakeBox(0., 5., 0., 20., 20., 15.) +facesList2 = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["FACE"]) face2 = facesList2[1] -edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) +edgesList = geom_builder.SubShapeAll(face2, geom_builder.ShapeType["EDGE"]) edge1 = edgesList[2] -aComp = geompy.MakeCompound([face1, face2]) -geompy.addToStudy(aComp, "Two faces") +aComp = geom_builder.MakeCompound([face1, face2]) +geom_builder.addToStudy(aComp, "Two faces") # create a mesh on two faces -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") +mesh = smesh_builder.Mesh(aComp, "Two faces : quadrangle mesh") algo1D = mesh.Segment() algo1D.NumberOfSegments(9) diff --git a/doc/examples/transforming_meshes_ex09.py b/doc/examples/transforming_meshes_ex09.py index bbc76691c..19ab5ed95 100644 --- a/doc/examples/transforming_meshes_ex09.py +++ b/doc/examples/transforming_meshes_ex09.py @@ -1,28 +1,26 @@ # Sew Free Borders - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # make two not sewed quadranges -OY0 = geompy.MakeVectorDXDYDZ(0, 1, 0) -OY1 = geompy.MakeTranslation( OY0, 1, 0, 0, theName="OY1" ) -OY2 = geompy.MakeTranslation( OY0, 1.01, 0, 0, theName="OY2" ) -OY3 = geompy.MakeTranslation( OY0, 2, 0, 0 ) -q1 = geompy.MakeQuad2Edges( OY0, OY1 ) -q2 = geompy.MakeQuad2Edges( OY2, OY3 ) +OY0 = geom_builder.MakeVectorDXDYDZ(0, 1, 0) +OY1 = geom_builder.MakeTranslation( OY0, 1, 0, 0, theName="OY1" ) +OY2 = geom_builder.MakeTranslation( OY0, 1.01, 0, 0, theName="OY2" ) +OY3 = geom_builder.MakeTranslation( OY0, 2, 0, 0 ) +q1 = geom_builder.MakeQuad2Edges( OY0, OY1 ) +q2 = geom_builder.MakeQuad2Edges( OY2, OY3 ) -shape = geompy.MakeCompound( [q1,q2], theName='shape' ) +shape = geom_builder.MakeCompound( [q1,q2], theName='shape' ) # make a non-uniform quadrangle mesh on two faces -mesh = smesh.Mesh(shape, "Two faces : quadrangle mesh") +mesh = smesh_builder.Mesh(shape, "Two faces : quadrangle mesh") mesh.Segment().Arithmetic1D( 0.1, 0.4 ) mesh.Segment(q1).NumberOfSegments( 5 ) mesh.Quadrangle() @@ -47,4 +45,3 @@ res = mesh.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, CreatePolygons, CreatePolyedrs ) print(res) print("nb polygons:", mesh.NbPolygons()) - diff --git a/doc/examples/transforming_meshes_ex10.py b/doc/examples/transforming_meshes_ex10.py index f3de43d21..36c2f5c22 100644 --- a/doc/examples/transforming_meshes_ex10.py +++ b/doc/examples/transforming_meshes_ex10.py @@ -2,25 +2,25 @@ import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create two boxes -box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.) -box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.) +box1 = geom_builder.MakeBox(0., 0., 0., 10., 10., 10.) +box2 = geom_builder.MakeBox(0., 15., 0., 20., 25., 10.) -EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) +EdgesList = geom_builder.SubShapeAll(box2, geom_builder.ShapeType["EDGE"]) -aComp = geompy.MakeCompound([box1, box2]) -geompy.addToStudy(aComp, "Two boxes") +aComp = geom_builder.MakeCompound([box1, box2]) +geom_builder.addToStudy(aComp, "Two boxes") # create a mesh on two boxes -mesh = smesh.Mesh(aComp, "Sew Side Elements") +mesh = smesh_builder.Mesh(aComp, "Sew Side Elements") algo1D = mesh.Segment() algo1D.NumberOfSegments(2) @@ -35,23 +35,23 @@ mesh.Compute() # sew side elements # find elements to sew -face1 = geompy.GetFaceNearPoint( aComp, geompy.MakeVertex( 5, 10, 5 )) +face1 = geom_builder.GetFaceNearPoint( aComp, geom_builder.MakeVertex( 5, 10, 5 )) IDsOfSide1Elements = mesh.GetSubMeshElementsId( face1 ) print("side faces 1:",IDsOfSide1Elements) -face1Translated = geompy.MakeTranslation( face1, 0,5,0 ) -faceFilter = smesh.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated ) +face1Translated = geom_builder.MakeTranslation( face1, 0,5,0 ) +faceFilter = smesh_builder.GetFilter( SMESH.FACE, SMESH.FT_BelongToGeom,'=', face1Translated ) IDsOfSide2Elements = mesh.GetIdsFromFilter( faceFilter ) print("side faces 2:",IDsOfSide2Elements) # find corresponding nodes on sides -edge1 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 10, 5 )) +edge1 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 10, 5 )) segs1 = mesh.GetSubMeshElementsId( edge1 ) # mesh segments generated on edge1 NodeID1OfSide1ToMerge = mesh.GetElemNode( segs1[0], 0 ) NodeID2OfSide1ToMerge = mesh.GetElemNode( segs1[0], 1 ) print("nodes of side1:", [NodeID1OfSide1ToMerge,NodeID2OfSide1ToMerge]) -edge2 = geompy.GetEdgeNearPoint( aComp, geompy.MakeVertex( 0, 15, 5 )) +edge2 = geom_builder.GetEdgeNearPoint( aComp, geom_builder.MakeVertex( 0, 15, 5 )) segs2 = mesh.GetSubMeshElementsId( edge2 ) # mesh segments generated on edge2 NodeID1OfSide2ToMerge = mesh.GetElemNode( segs2[0], 0 ) NodeID2OfSide2ToMerge = mesh.GetElemNode( segs2[0], 1 ) diff --git a/doc/examples/transforming_meshes_ex11.py b/doc/examples/transforming_meshes_ex11.py index d4137e41d..5fddd3015 100644 --- a/doc/examples/transforming_meshes_ex11.py +++ b/doc/examples/transforming_meshes_ex11.py @@ -1,23 +1,21 @@ # Duplicate nodes or/and elements - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() - import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Create a box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +box = geom_builder.MakeBox(0., 0., 0., 100., 200., 300.) # Define hexa mesh on a box -mesh = smesh.Mesh(box, "Mesh") +mesh = smesh_builder.Mesh(box, "Mesh") mesh.Segment().NumberOfSegments(7) mesh.Quadrangle() mesh.Hexahedron() @@ -89,7 +87,3 @@ mesh.DoubleElements( edges, edges.GetName() ) # Duplicate two first edges of the mesh mesh.DoubleElements([ 1, 2 ]) - -# Update object browser -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser() diff --git a/doc/examples/transforming_meshes_ex12.py b/doc/examples/transforming_meshes_ex12.py index 65b05d7d5..edf912024 100644 --- a/doc/examples/transforming_meshes_ex12.py +++ b/doc/examples/transforming_meshes_ex12.py @@ -1,26 +1,23 @@ # Create boundary elements - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() -box = geompy.MakeBoxDXDYDZ(100, 100, 100) -gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBoxDXDYDZ(100, 100, 100) +gFaces = geom_builder.SubShapeAllSorted(box, geom_builder.ShapeType["FACE"]) f1,f2 = gFaces[0],gFaces[1] -geompy.addToStudy(box,"box") -geompy.addToStudyInFather(box,f1,"face1") -geompy.addToStudyInFather(box,f2,"face2") +geom_builder.addToStudy(box,"box") +geom_builder.addToStudyInFather(box,f1,"face1") +geom_builder.addToStudyInFather(box,f2,"face2") -twoFaces = geompy.MakeCompound([f1,f2]) +twoFaces = geom_builder.MakeCompound([f1,f2]) ## ----------- ## @@ -29,7 +26,7 @@ twoFaces = geompy.MakeCompound([f1,f2]) ## ----------- dim = SMESH.BND_2DFROM3D -init_mesh = smesh.Mesh(box, "box") +init_mesh = smesh_builder.Mesh(box, "box") init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons # remove some faces @@ -39,7 +36,7 @@ rm_face = faces[ : nb_faces // 2] init_mesh.RemoveElements( rm_face ) # restore boundary in this mesh -mesh = smesh.CopyMesh( init_mesh, "2D from 3D") +mesh = smesh_builder.CopyMesh( init_mesh, "2D from 3D") groupName = "bnd 2D" nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) @@ -51,7 +48,6 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam meshName = init_mesh.GetName() + " + boundary" nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) - ## ----------- ## ## 1D from 2D @@ -59,7 +55,7 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam ## ----------- dim = SMESH.BND_1DFROM2D -init_mesh = smesh.Mesh(f1, "2D mesh") +init_mesh = smesh_builder.Mesh(f1, "2D mesh") init_mesh.AutomaticHexahedralization() # remove some edges @@ -70,7 +66,7 @@ init_mesh.RemoveElements( rm_edge ) # restore boundary edges in this mesh -mesh = smesh.CopyMesh( init_mesh, "1D from 2D") +mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D") groupName = "bnd 1D" nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) @@ -82,8 +78,6 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam meshName = init_mesh.GetName() + " + boundary" nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) - - ## ------------------ ## ## 1D from 2D GROUPS @@ -91,7 +85,7 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam ## ------------------ dim = SMESH.BND_1DFROM3D -init_mesh = smesh.Mesh(box, "box") +init_mesh = smesh_builder.Mesh(box, "box") init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons # remove all edges rm_edges = init_mesh.GetElementsByType( SMESH.EDGE ) @@ -102,7 +96,7 @@ fGroup1 = init_mesh.Group( f1, "f1" ) fGroup2 = init_mesh.Group( f2, "f2" ) # make 1D boundary around groups in this mesh -mesh = smesh.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True) +mesh = smesh_builder.CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True) groups = mesh.GetGroups() nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups) diff --git a/doc/examples/transforming_meshes_ex13.py b/doc/examples/transforming_meshes_ex13.py index d4b553963..d8fade895 100644 --- a/doc/examples/transforming_meshes_ex13.py +++ b/doc/examples/transforming_meshes_ex13.py @@ -1,37 +1,34 @@ # Reorient faces - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a geometry consisting of two faces -box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) -faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBoxDXDYDZ( 10, 10, 10 ) +faces = geom_builder.SubShapeAllSorted( box, geom_builder.ShapeType["FACE"]) -shape = geompy.MakeCompound( faces[:2] ) -faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] ) -geompy.addToStudy( shape, "shape") -geompy.addToStudyInFather( shape, faces[0], "faces[0]") -geompy.addToStudyInFather( shape, faces[1], "faces[1]") +shape = geom_builder.MakeCompound( faces[:2] ) +faces = geom_builder.SubShapeAll( shape, geom_builder.ShapeType["FACE"] ) +geom_builder.addToStudy( shape, "shape") +geom_builder.addToStudyInFather( shape, faces[0], "faces[0]") +geom_builder.addToStudyInFather( shape, faces[1], "faces[1]") # create a 2D mesh -mesh = smesh.Mesh( shape, "test_Reorient2D") +mesh = smesh_builder.Mesh( shape, "test_Reorient2D") mesh.AutomaticHexahedralization(0.5) localAlgo = mesh.Segment(faces[0]) localAlgo.NumberOfSegments( 11 ) mesh.Compute() group = mesh.Group( faces[1] ) -vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 ) +vec = geom_builder.MakeVectorDXDYDZ( 1, 1, 1 ) # ============ # Reorient2D() @@ -47,12 +44,12 @@ mesh.Reorient2D( mesh, vec, mesh.NbElements() ) # 2DObject - a sub-mesh # Direction - components of a vector # FaceOrPoint - a GEOM object (vertex) -mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec )) +mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geom_builder.GetFirstVertex( vec )) # # 2DObject - a group of faces # Direction - a SMESH.DirStruct structure # FaceOrPoint - coordinates of a point -mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0]) +mesh.Reorient2D( group, smesh_builder.MakeDirStruct( -10, 1, 10 ), [0,0,0]) # # FaceOrPoint - a SMESH.PointStruct structure mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0)) @@ -73,7 +70,7 @@ mesh.Reorient2DByNeighbours([group]) # Use Reorient2DBy3D() to orient faces of 2 geom faces to have their normal pointing inside volumes -mesh3D = smesh.Mesh( box, '3D mesh') +mesh3D = smesh_builder.Mesh( box, '3D mesh') mesh3D.AutomaticHexahedralization(0.5) group0 = mesh3D.Group( faces[0] ) group1 = mesh3D.Group( faces[1] ) @@ -85,4 +82,3 @@ print("Nb reoriented faces:", nbRev) # orient the reversed faces back nbRev = mesh3D.Reorient2DBy3D( mesh3D, mesh3D, theOutsideNormal=True) print("Nb re-reoriented faces:", nbRev) - diff --git a/doc/examples/use_existing_faces.py b/doc/examples/use_existing_faces.py index 0d4139255..4cdb9f26a 100644 --- a/doc/examples/use_existing_faces.py +++ b/doc/examples/use_existing_faces.py @@ -1,19 +1,16 @@ # Usage of "Use Faces to be Created Manually" algorithm - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() -import salome_notebook + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # define my 2D algorithm -def my2DMeshing(geomFace, geom_builder, smesh_builder): +def my2DMeshing(geomFace, mesh): import numpy as np # find gravity center of geomFace @@ -42,9 +39,9 @@ def my2DMeshing(geomFace, geom_builder, smesh_builder): nodes = [] for edge, isForward in sortedEdges: v1,v2 = geom_builder.SubShapeAll( edge, geom_builder.ShapeType["VERTEX"]) - edgeNodes = smesh_builder.GetSubMeshNodesId( v2, all=False ) + \ - smesh_builder.GetSubMeshNodesId( edge, all=False ) + \ - smesh_builder.GetSubMeshNodesId( v1, all=False ) + edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \ + mesh.GetSubMeshNodesId( edge, all=False ) + \ + mesh.GetSubMeshNodesId( v1, all=False ) if not isForward: edgeNodes.reverse() nodes.extend( edgeNodes[:-1] ) @@ -53,10 +50,10 @@ def my2DMeshing(geomFace, geom_builder, smesh_builder): r2 = 1 - r1 nodesInside = [] for n in nodes: - nXYZ = smesh_builder.GetNodeXYZ( n ) + nXYZ = mesh.GetNodeXYZ( n ) newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ )) - nodesInside.append( smesh_builder.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] )) - smesh_builder.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 ) + nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] )) + mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 ) # find out orientation of faces to create # geomFace normal @@ -68,8 +65,8 @@ def my2DMeshing(geomFace, geom_builder, smesh_builder): if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face faceNormXYZ = np.multiply( -1., faceNormXYZ ) # mesh face normal - e1 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodes[1] )) - e2 = np.subtract( smesh_builder.GetNodeXYZ( nodes[0] ), smesh_builder.GetNodeXYZ( nodesInside[0] )) + e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] )) + e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] )) meshNorm = np.cross( e1, e2 ) # faces orientation reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 ) @@ -80,29 +77,29 @@ def my2DMeshing(geomFace, geom_builder, smesh_builder): n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1] iN -= 1 if reverse: - f = smesh_builder.AddFace( [n1, n2, n3, n4] ) + f = mesh.AddFace( [n1, n2, n3, n4] ) else: - f = smesh_builder.AddFace( [n4, n3, n2, n1] ) + f = mesh.AddFace( [n4, n3, n2, n1] ) # new faces must be assigned to geometry to allow 3D algorithm finding them - smesh_builder.SetMeshElementOnShape( f, geomFace ) + mesh.SetMeshElementOnShape( f, geomFace ) if reverse: nodesInside.reverse() - polygon = smesh_builder.AddPolygonalFace( nodesInside ) - smesh_builder.SetMeshElementOnShape( polygon, geomFace ) + polygon = mesh.AddPolygonalFace( nodesInside ) + mesh.SetMeshElementOnShape( polygon, geomFace ) return # create geometry and get faces to mesh with my2DMeshing() -box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) -f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] -f2 = geompy.GetOppositeFace( box, f1 ) -geompy.addToStudy( box, "box" ) -geompy.addToStudy( f1, "f1" ) -geompy.addToStudy( f2, "f2" ) +box = geom_builder.MakeBoxDXDYDZ( 100, 100, 100 ) +f1 = geom_builder.SubShapeAll( box, geom_builder.ShapeType["FACE"])[0] +f2 = geom_builder.GetOppositeFace( box, f1 ) +geom_builder.addToStudy( box, "box" ) +geom_builder.addToStudy( f1, "f1" ) +geom_builder.addToStudy( f2, "f2" ) # compute 1D mesh -mesh = smesh.Mesh( box ) +mesh = smesh_builder.Mesh( box ) mesh.Segment().NumberOfSegments( 5 ) mesh.Compute() @@ -110,8 +107,8 @@ mesh.Compute() mesh.Quadrangle() mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing(); mesh.UseExistingFaces(f2) # assign UseExistingFaces() BEFORE calling my2DMeshing()! -my2DMeshing(f1, geom_builder=geompy, smesh_builder=mesh) -my2DMeshing(f2, geom_builder=geompy, smesh_builder=mesh) +my2DMeshing(f1, mesh) +my2DMeshing(f2, mesh) assert mesh.Compute() # compute 3D mesh diff --git a/doc/examples/viewing_meshes_ex01.py b/doc/examples/viewing_meshes_ex01.py index 0e8899eeb..e75f036a3 100644 --- a/doc/examples/viewing_meshes_ex01.py +++ b/doc/examples/viewing_meshes_ex01.py @@ -1,23 +1,22 @@ # Viewing Mesh Infos - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # create a box -box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) -geompy.addToStudy(box, "box") -[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +box = geom_builder.MakeBox(0., 0., 0., 20., 20., 20.) +geom_builder.addToStudy(box, "box") +[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geom_builder.SubShapeAll(box, geom_builder.ShapeType["FACE"]) # create a mesh -tetra = smesh.Mesh(box, "MeshBox") +tetra = smesh_builder.Mesh(box, "MeshBox") algo1D = tetra.Segment() algo1D.NumberOfSegments(3) @@ -60,7 +59,7 @@ print(" polyhedrons : ", tetra.NbPolyhedrons()) # Get Information About Mesh by GetMeshInfo print("\nInformation about mesh by GetMeshInfo:") -info = smesh.GetMeshInfo(tetra) +info = smesh_builder.GetMeshInfo(tetra) keys = list(info.keys()); keys.sort() for i in keys: print(" %s : %d" % ( i, info[i] )) @@ -68,7 +67,7 @@ for i in keys: # Get Information About Group by GetMeshInfo print("\nInformation about group by GetMeshInfo:") -info = smesh.GetMeshInfo(group) +info = smesh_builder.GetMeshInfo(group) keys = list(info.keys()); keys.sort() for i in keys: print(" %s : %d" % ( i, info[i] )) @@ -76,7 +75,7 @@ for i in keys: # Get Information About SubMesh by GetMeshInfo print("\nInformation about Submesh by GetMeshInfo:") -info = smesh.GetMeshInfo(submesh) +info = smesh_builder.GetMeshInfo(submesh) keys = list(info.keys()); keys.sort() for i in keys: print(" %s : %d" % ( i, info[i] )) diff --git a/doc/examples/viewing_meshes_ex02.py b/doc/examples/viewing_meshes_ex02.py index 402e89b97..a2f2ed17a 100644 --- a/doc/examples/viewing_meshes_ex02.py +++ b/doc/examples/viewing_meshes_ex02.py @@ -1,21 +1,20 @@ # Find Element by Point - import salome salome.salome_init_without_session() -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New() -import SMESH, SALOMEDS +import SMESH +from salome.geom import geomBuilder from salome.smesh import smeshBuilder -smesh = smeshBuilder.New() + +geom_builder = geomBuilder.New() +smesh_builder = smeshBuilder.New() # Create a geometry to mesh -box = geompy.MakeBoxDXDYDZ(100,100,100) +box = geom_builder.MakeBoxDXDYDZ(100,100,100) # Create a mesh -mesh = smesh.Mesh(box,"Mesh") +mesh = smesh_builder.Mesh(box,"Mesh") mesh.AutomaticHexahedralization() mesh.Compute() diff --git a/doc/gui/input/smeshpy_interface.rst b/doc/gui/input/smeshpy_interface.rst index 16cb689c8..2cdf76b6f 100644 --- a/doc/gui/input/smeshpy_interface.rst +++ b/doc/gui/input/smeshpy_interface.rst @@ -76,10 +76,10 @@ generation and for retrieving basic information on mesh nodes, elements and grou Example of 3d mesh generation: ############################## -.. literalinclude:: ../../examples/3dmesh.py +.. literalinclude:: ../../examples/mesh_3d.py :language: python -:download:`Download this script <../../examples/3dmesh.py>` +:download:`Download this script <../../examples/mesh_3d.py>` Examples of Python scripts for Mesh operations are available by the following links: