From: vsr Date: Thu, 4 Apr 2013 07:08:19 +0000 (+0000) Subject: Merge from BR_plugins_pbyacs 03/04/2013 X-Git-Tag: V7_2_0rc1~36 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=54182913fbb9df65a3f4cc96f55db3618835ecd8 Merge from BR_plugins_pbyacs 03/04/2013 --- diff --git a/adm_local/unix/config_files/check_SMESH.m4 b/adm_local/unix/config_files/check_SMESH.m4 index b8290a22e..387759198 100644 --- a/adm_local/unix/config_files/check_SMESH.m4 +++ b/adm_local/unix/config_files/check_SMESH.m4 @@ -64,7 +64,7 @@ fi #CCRTif test -f ${SMESH_DIR}/bin/salome/libSMESH_Swig.py ; then #if test -f ${SMESH_DIR}/bin/salome/MED_Test ; then -if test -f ${SMESH_DIR}/bin/salome/smesh.py ; then +if test -f ${SMESH_DIR}/bin/salome/SMESH_test.py ; then SMesh_ok=yes AC_MSG_RESULT(Using SMesh module distribution in ${SMESH_DIR}) diff --git a/doc/salome/examples/3dmesh.py b/doc/salome/examples/3dmesh.py index bd6d3b4cc..67a707533 100644 --- a/doc/salome/examples/3dmesh.py +++ b/doc/salome/examples/3dmesh.py @@ -1,7 +1,14 @@ # 3d mesh generation -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) ### # Geometry: an assembly of a box, a cylinder and a truncated cone @@ -18,33 +25,33 @@ radius_2 = 40 height = 100 # Build a box -box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) +box = geompy.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) # Build a cylinder -pt1 = MakeVertex(0, 0, cote/3) -di1 = MakeVectorDXDYDZ(0, 0, 1) -cyl = MakeCylinder(pt1, di1, section, size) +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 = MakeVertex(0, 0, size) -cone = MakeCone(pt2, di1, radius_1, radius_2, height) +pt2 = geompy.MakeVertex(0, 0, size) +cone = geompy.MakeCone(pt2, di1, radius_1, radius_2, height) # Fuse -box_cyl = MakeFuse(box, cyl) -piece = MakeFuse(box_cyl, cone) +box_cyl = geompy.MakeFuse(box, cyl) +piece = geompy.MakeFuse(box_cyl, cone) # Add to the study -addToStudy(piece, name) +geompy.addToStudy(piece, name) # Create a group of faces -group = CreateGroup(piece, ShapeType["FACE"]) +group = geompy.CreateGroup(piece, geompy.ShapeType["FACE"]) group_name = name + "_grp" -addToStudy(group, group_name) +geompy.addToStudy(group, group_name) group.SetName(group_name) # Add faces to the group -faces = SubShapeAllIDs(piece, ShapeType["FACE"]) -UnionIDs(group, faces) +faces = geompy.SubShapeAllIDs(piece, geompy.ShapeType["FACE"]) +geompy.UnionIDs(group, faces) ### # Create a mesh diff --git a/doc/salome/examples/cartesian_algo.py b/doc/salome/examples/cartesian_algo.py index b15455f28..dc0dc23cf 100644 --- a/doc/salome/examples/cartesian_algo.py +++ b/doc/salome/examples/cartesian_algo.py @@ -1,14 +1,24 @@ # Usage of Body Fitting algorithm -from smesh import * -SetCurrentStudy(salome.myStudy) + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create a sphere sphere = geompy.MakeSphereR( 50 ) geompy.addToStudy( sphere, "sphere" ) # create a mesh and assign a "Body Fitting" algo -mesh = Mesh( sphere ) +mesh = smesh.Mesh( sphere ) cartAlgo = mesh.BodyFitted() # define a cartesian grid using Coordinates diff --git a/doc/salome/examples/creating_meshes_ex01.py b/doc/salome/examples/creating_meshes_ex01.py index 0b93356c4..f328d0582 100644 --- a/doc/salome/examples/creating_meshes_ex01.py +++ b/doc/salome/examples/creating_meshes_ex01.py @@ -1,7 +1,14 @@ # Construction of a Mesh -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) diff --git a/doc/salome/examples/creating_meshes_ex02.py b/doc/salome/examples/creating_meshes_ex02.py index c541b4add..fe9f72f08 100644 --- a/doc/salome/examples/creating_meshes_ex02.py +++ b/doc/salome/examples/creating_meshes_ex02.py @@ -1,16 +1,23 @@ # Construction of a Submesh -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") # select one edge of the box for definition of a local hypothesis -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geompy.MakeVertex(5., 0., 0.) +EdgeX = geompy.GetEdgeNearPoint(box, p5) +geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh") diff --git a/doc/salome/examples/creating_meshes_ex03.py b/doc/salome/examples/creating_meshes_ex03.py index 7b219f3a6..7cf85b786 100644 --- a/doc/salome/examples/creating_meshes_ex03.py +++ b/doc/salome/examples/creating_meshes_ex03.py @@ -1,9 +1,14 @@ # Change priority of submeshes in Mesh import salome -import geompy -import smesh -import SMESH +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) 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"]) @@ -24,7 +29,7 @@ Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000) Regular_1D_1 = Mesh_1.Segment(geom=Face_1) Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4) Nb_Segments_2.SetDistrType( 0 ) -MEFISTO_2D_1 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_1) +MEFISTO_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_1) Length_From_Edges_2D = MEFISTO_2D_1.LengthFromEdges() SubMesh_1 = MEFISTO_2D_1.GetSubMesh() @@ -32,7 +37,7 @@ SubMesh_1 = MEFISTO_2D_1.GetSubMesh() Regular_1D_2 = Mesh_1.Segment(geom=Face_2) Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8) Nb_Segments_3.SetDistrType( 0 ) -MEFISTO_2D_2 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_2) +MEFISTO_2D_2 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_2) Length_From_Edges_2D_1 = MEFISTO_2D_2.LengthFromEdges() SubMesh_2 = MEFISTO_2D_2.GetSubMesh() @@ -40,7 +45,7 @@ SubMesh_2 = MEFISTO_2D_2.GetSubMesh() Regular_1D_3 = Mesh_1.Segment(geom=Face_3) Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12) Nb_Segments_4.SetDistrType( 0 ) -MEFISTO_2D_3 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_3) +MEFISTO_2D_3 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_3) Length_From_Edges_2D_2 = MEFISTO_2D_3.LengthFromEdges() SubMesh_3 = MEFISTO_2D_3.GetSubMesh() diff --git a/doc/salome/examples/creating_meshes_ex04.py b/doc/salome/examples/creating_meshes_ex04.py index 33106c775..f2cdfdb87 100644 --- a/doc/salome/examples/creating_meshes_ex04.py +++ b/doc/salome/examples/creating_meshes_ex04.py @@ -1,7 +1,14 @@ # Editing of a mesh -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) def PrintMeshInfo(theMesh): aMesh = theMesh.GetMesh() diff --git a/doc/salome/examples/creating_meshes_ex05.py b/doc/salome/examples/creating_meshes_ex05.py index 6ba410307..98e921a06 100644 --- a/doc/salome/examples/creating_meshes_ex05.py +++ b/doc/salome/examples/creating_meshes_ex05.py @@ -1,7 +1,14 @@ # Export of a Mesh -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) diff --git a/doc/salome/examples/creating_meshes_ex06.py b/doc/salome/examples/creating_meshes_ex06.py index 96b2a29c7..d16e067d3 100644 --- a/doc/salome/examples/creating_meshes_ex06.py +++ b/doc/salome/examples/creating_meshes_ex06.py @@ -1,12 +1,17 @@ # Creating a hexahedral mesh on a cylinder. # Note: it is a copy of 'ex24_cylinder.py' from SMESH_SWIG -import math - -import geompy -import smesh import salome -geo = geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +import math # Parameters # ---------- @@ -17,62 +22,62 @@ height = 200 # Build a cylinder # ---------------- -base = geo.MakeVertex(0, 0, 0) -direction = geo.MakeVectorDXDYDZ(0, 0, 1) +base = geompy.MakeVertex(0, 0, 0) +direction = geompy.MakeVectorDXDYDZ(0, 0, 1) -cylinder = geo.MakeCylinder(base, direction, radius, height) +cylinder = geompy.MakeCylinder(base, direction, radius, height) -geo.addToStudy(cylinder, "cylinder") +geompy.addToStudy(cylinder, "cylinder") # Build blocks # ------------ size = radius/2.0 -box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height) -box_axis = geo.MakeLine(base, direction) -box = geo.MakeRotation(box_rot, box_axis, math.pi/4) +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) -hole = geo.MakeCut(cylinder, box) +hole = geompy.MakeCut(cylinder, box) plane_trim = 2000 -plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim) -plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim) +plane_a = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim) +plane_b = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim) -blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"]) -blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"]) -blocks_all = geo.MakeCompound(blocks_list) -blocks = geo.MakeGlueFaces(blocks_all, 0.0001) +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) -geo.addToStudy(blocks, "cylinder:blocks") +geompy.addToStudy(blocks, "cylinder:blocks") # Build geometric groups # ---------------------- def group(name, shape, type, base=None, direction=None): - t = geo.ShapeType[type] - g = geo.CreateGroup(shape, t) + t = geompy.ShapeType[type] + g = geompy.CreateGroup(shape, t) - geo.addToStudy(g, name) + geompy.addToStudy(g, name) g.SetName(name) if base!=None: - l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON) - geo.UnionIDs(g, l) + l = geompy.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, GEOM.ST_ON) + geompy.UnionIDs(g, l) return g group_a = group("baseA", blocks, "FACE", base, direction) -base_b = geo.MakeVertex(0, 0, height) +base_b = geompy.MakeVertex(0, 0, height) group_b = group("baseB", blocks, "FACE", base_b, direction) group_1 = group("limit", blocks, "SOLID") -group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"]) -geo.UnionIDs(group_1, group_1_all) -group_1_box = geo.GetBlockNearPoint(blocks, base) -geo.DifferenceList(group_1, [group_1_box]) +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]) # Mesh the blocks with hexahedral # ------------------------------- @@ -80,8 +85,8 @@ geo.DifferenceList(group_1, [group_1_box]) smesh.SetCurrentStudy(salome.myStudy) def discretize(x, y, z, n, s=blocks): - p = geo.MakeVertex(x, y, z) - e = geo.GetEdgeNearPoint(s, p) + p = geompy.MakeVertex(x, y, z) + e = geompy.GetEdgeNearPoint(s, p) a = hexa.Segment(e) a.NumberOfSegments(n) a.Propagation() diff --git a/doc/salome/examples/creating_meshes_ex07.py b/doc/salome/examples/creating_meshes_ex07.py index 3140acee8..65a4f742e 100644 --- a/doc/salome/examples/creating_meshes_ex07.py +++ b/doc/salome/examples/creating_meshes_ex07.py @@ -2,8 +2,14 @@ # Note: it is a copy of 'SMESH_BuildCompound.py' from SMESH_SWIG import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) ## create a bottom box Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.) @@ -65,9 +71,9 @@ Ginf2=Mesh_sup.Group(Finf2, "Inf") ## create compounds # create a compound of two meshes with renaming groups with the same names and # merging of elements with the given tolerance -Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) +Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems') # create a compound of two meshes with uniting groups with the same names and # creating groups of all elements -Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) +Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems') diff --git a/doc/salome/examples/creating_meshes_ex08.py b/doc/salome/examples/creating_meshes_ex08.py index a76e8d175..18f9dad01 100644 --- a/doc/salome/examples/creating_meshes_ex08.py +++ b/doc/salome/examples/creating_meshes_ex08.py @@ -1,40 +1,47 @@ # Mesh Copying -from smesh import * -SetCurrentStudy(salome.myStudy) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # make geometry of a box box = geompy.MakeBoxDXDYDZ(100,100,100) face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0] # generate 3D mesh -mesh = Mesh(box) +mesh = smesh.Mesh(box) localAlgo = mesh.Triangle(face) mesh.AutomaticHexahedralization() # objects to copy fGroup = mesh.GroupOnGeom( face, "2D on face") -nGroup = mesh.GroupOnGeom( face, "nodes on face", NODE) +nGroup = mesh.GroupOnGeom( face, "nodes on face", SMESH.NODE) subMesh = localAlgo.GetSubMesh() # make a new mesh by copying different parts of the mesh # 1. copy the whole mesh -newMesh = CopyMesh( mesh, "whole mesh copy") +newMesh = smesh.CopyMesh( mesh, "whole mesh copy") # 2. copy a group of 2D elements along with groups -newMesh = CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True) +newMesh = smesh.CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True) # 3. copy a group of nodes with preseving their ids -newMesh = CopyMesh( nGroup, "node group copy", toKeepIDs=True) +newMesh = smesh.CopyMesh( nGroup, "node group copy", toKeepIDs=True) # 4. copy some faces faceIds = fGroup.GetIDs()[-10:] -newMesh = CopyMesh( mesh.GetIDSource( faceIds, FACE ), "some faces copy") +newMesh = smesh.CopyMesh( mesh.GetIDSource( faceIds, SMESH.FACE ), "some faces copy") # 5. copy some nodes nodeIds = nGroup.GetIDs()[-10:] -newMesh = CopyMesh( mesh.GetIDSource( nodeIds, NODE), "some nodes copy") +newMesh = smesh.CopyMesh( mesh.GetIDSource( nodeIds, SMESH.NODE), "some nodes copy") # 6. copy a sub-mesh -newMesh = CopyMesh( subMesh, "submesh copy" ) +newMesh = smesh.CopyMesh( subMesh, "submesh copy" ) diff --git a/doc/salome/examples/defining_hypotheses_ex01.py b/doc/salome/examples/defining_hypotheses_ex01.py index 6efb1cfb9..4bb75c56b 100644 --- a/doc/salome/examples/defining_hypotheses_ex01.py +++ b/doc/salome/examples/defining_hypotheses_ex01.py @@ -1,7 +1,14 @@ # Arithmetic 1D -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBoxDXDYDZ(10., 10., 10.) diff --git a/doc/salome/examples/defining_hypotheses_ex02.py b/doc/salome/examples/defining_hypotheses_ex02.py index b0726a1ca..3662d5632 100644 --- a/doc/salome/examples/defining_hypotheses_ex02.py +++ b/doc/salome/examples/defining_hypotheses_ex02.py @@ -1,7 +1,14 @@ # Deflection 1D and Number of Segments -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a face from arc and straight segment px = geompy.MakeVertex(100., 0. , 0. ) diff --git a/doc/salome/examples/defining_hypotheses_ex03.py b/doc/salome/examples/defining_hypotheses_ex03.py index cfb1ca86c..05a984b77 100644 --- a/doc/salome/examples/defining_hypotheses_ex03.py +++ b/doc/salome/examples/defining_hypotheses_ex03.py @@ -1,16 +1,23 @@ # Start and End Length -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geompy.MakeVertex(5., 0., 0.) +EdgeX = geompy.GetEdgeNearPoint(box, p5) +geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box hexa = smesh.Mesh(box, "Box : hexahedrical mesh") diff --git a/doc/salome/examples/defining_hypotheses_ex04.py b/doc/salome/examples/defining_hypotheses_ex04.py index 0a17f5ca1..8ebddfc5c 100644 --- a/doc/salome/examples/defining_hypotheses_ex04.py +++ b/doc/salome/examples/defining_hypotheses_ex04.py @@ -1,16 +1,23 @@ # Local Length -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geompy.MakeVertex(5., 0., 0.) +EdgeX = geompy.GetEdgeNearPoint(box, p5) +geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box hexa = smesh.Mesh(box, "Box : hexahedrical mesh") diff --git a/doc/salome/examples/defining_hypotheses_ex05.py b/doc/salome/examples/defining_hypotheses_ex05.py index fcf03d0d6..d2b98f1cc 100644 --- a/doc/salome/examples/defining_hypotheses_ex05.py +++ b/doc/salome/examples/defining_hypotheses_ex05.py @@ -1,8 +1,14 @@ # Maximum Element Area -import geompy -import smesh -import salome +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a face px = geompy.MakeVertex(100., 0. , 0. ) diff --git a/doc/salome/examples/defining_hypotheses_ex06.py b/doc/salome/examples/defining_hypotheses_ex06.py index 24bc4da39..d6978dfc3 100644 --- a/doc/salome/examples/defining_hypotheses_ex06.py +++ b/doc/salome/examples/defining_hypotheses_ex06.py @@ -1,7 +1,14 @@ # Maximum Element Volume -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a cylinder cyl = geompy.MakeCylinderRH(30., 50.) diff --git a/doc/salome/examples/defining_hypotheses_ex07.py b/doc/salome/examples/defining_hypotheses_ex07.py index 59d7521a2..c2dc2cfb0 100644 --- a/doc/salome/examples/defining_hypotheses_ex07.py +++ b/doc/salome/examples/defining_hypotheses_ex07.py @@ -1,7 +1,14 @@ # Length from Edges -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create sketchers sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") diff --git a/doc/salome/examples/defining_hypotheses_ex08.py b/doc/salome/examples/defining_hypotheses_ex08.py index 438773427..34fcbc377 100644 --- a/doc/salome/examples/defining_hypotheses_ex08.py +++ b/doc/salome/examples/defining_hypotheses_ex08.py @@ -1,16 +1,23 @@ # Propagation -from geompy import * -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") # get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") +p5 = geompy.MakeVertex(5., 0., 0.) +EdgeX = geompy.GetEdgeNearPoint(box, p5) +geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") # create a hexahedral mesh on the box hexa = smesh.Mesh(box, "Box : hexahedrical mesh") diff --git a/doc/salome/examples/defining_hypotheses_ex09.py b/doc/salome/examples/defining_hypotheses_ex09.py index 9956e4ba5..1ad07c605 100644 --- a/doc/salome/examples/defining_hypotheses_ex09.py +++ b/doc/salome/examples/defining_hypotheses_ex09.py @@ -1,7 +1,14 @@ # Defining Meshing Algorithms -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBoxDXDYDZ(10., 10., 10.) diff --git a/doc/salome/examples/defining_hypotheses_ex10.py b/doc/salome/examples/defining_hypotheses_ex10.py index 644908be2..1ebd7d81c 100644 --- a/doc/salome/examples/defining_hypotheses_ex10.py +++ b/doc/salome/examples/defining_hypotheses_ex10.py @@ -2,7 +2,15 @@ # Project prisms from one meshed box to another mesh on the same box -from smesh import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Prepare geometry @@ -36,7 +44,7 @@ geompy.addToStudyInFather( box, edgesF2, "edgesF2" ) # Make the source mesh with prisms -src_mesh = Mesh(box, "Source mesh") +src_mesh = smesh.Mesh(box, "Source mesh") src_mesh.Segment().NumberOfSegments(9,10) src_mesh.Quadrangle() src_mesh.Hexahedron() @@ -47,7 +55,7 @@ src_mesh.Compute() # Mesh the box using projection algoritms # Define the same global 1D and 2D hypotheses -tgt_mesh = Mesh(box, "Target mesh") +tgt_mesh = smesh.Mesh(box, "Target mesh") tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True) tgt_mesh.Quadrangle() @@ -73,4 +81,4 @@ proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 ) tgt_mesh.Compute() # Move the source mesh to visualy compare the two meshes -src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False) +src_mesh.TranslateObject( src_mesh, smesh.MakeDirStruct( 210, 0, 0 ), Copy=False) diff --git a/doc/salome/examples/defining_hypotheses_ex11.py b/doc/salome/examples/defining_hypotheses_ex11.py index be5504778..961a56d9c 100644 --- a/doc/salome/examples/defining_hypotheses_ex11.py +++ b/doc/salome/examples/defining_hypotheses_ex11.py @@ -2,7 +2,15 @@ # Project triangles from one meshed face to another mesh on the same box -from smesh import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Prepare geometry @@ -20,7 +28,7 @@ geompy.addToStudyInFather( box, Face_1, 'Face_1' ) geompy.addToStudyInFather( box, Face_2, 'Face_2' ) # Make the source mesh with Netgem2D -src_mesh = Mesh(Face_1, "Source mesh") +src_mesh = smesh.Mesh(Face_1, "Source mesh") src_mesh.Segment().NumberOfSegments(15) src_mesh.Triangle() src_mesh.Compute() diff --git a/doc/salome/examples/defining_hypotheses_ex12.py b/doc/salome/examples/defining_hypotheses_ex12.py index dd891a73e..5b6842fb3 100644 --- a/doc/salome/examples/defining_hypotheses_ex12.py +++ b/doc/salome/examples/defining_hypotheses_ex12.py @@ -1,8 +1,14 @@ # 1D Mesh with Fixed Points example import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import StdMeshers # Create face and explode it on edges diff --git a/doc/salome/examples/defining_hypotheses_ex13.py b/doc/salome/examples/defining_hypotheses_ex13.py index 283984916..32fbef438 100644 --- a/doc/salome/examples/defining_hypotheses_ex13.py +++ b/doc/salome/examples/defining_hypotheses_ex13.py @@ -1,8 +1,14 @@ # Radial Quadrangle 1D2D example -from smesh import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -SetCurrentStudy(salome.myStudy) +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # 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]) @@ -16,7 +22,7 @@ geompy.addToStudyInFather(Face, circle,"circle") # Define geometry for mesh, and Radial Quadrange algorithm mesh = smesh.Mesh(Face) -radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD) +radial_Quad_algo = mesh.Quadrangle(algo=smeshBuilder.RADIAL_QUAD) # The Radial Quadrange algorithm can work without any hypothesis # In this case it uses "Default Nb of Segments" preferences parameter to discretize edges diff --git a/doc/salome/examples/defining_hypotheses_ex14.py b/doc/salome/examples/defining_hypotheses_ex14.py index 6c93e3d27..3f55844cf 100644 --- a/doc/salome/examples/defining_hypotheses_ex14.py +++ b/doc/salome/examples/defining_hypotheses_ex14.py @@ -1,7 +1,14 @@ # Quadrangle Parameters example 1 (meshing a face with 3 edges) -from smesh import * -SetCurrentStudy(salome.myStudy) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Get 1/4 part from the disk face. Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100) diff --git a/doc/salome/examples/defining_hypotheses_ex15.py b/doc/salome/examples/defining_hypotheses_ex15.py index a08dfbfae..6e077d894 100644 --- a/doc/salome/examples/defining_hypotheses_ex15.py +++ b/doc/salome/examples/defining_hypotheses_ex15.py @@ -1,7 +1,14 @@ # Quadrangle Parameters example 2 (using different types) -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import StdMeshers # Make quadrangle face and explode it on edges. diff --git a/doc/salome/examples/defining_hypotheses_ex16.py b/doc/salome/examples/defining_hypotheses_ex16.py index 493034020..9125787b2 100644 --- a/doc/salome/examples/defining_hypotheses_ex16.py +++ b/doc/salome/examples/defining_hypotheses_ex16.py @@ -1,7 +1,14 @@ # "Use Existing Elements" example -from smesh import * -SetCurrentStudy(salome.myStudy) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Make a patritioned box @@ -23,15 +30,15 @@ geompy.addToStudyInFather( boxes[1], midFace1, "middle Face") # Mesh one of boxes with quadrangles. It is a source mesh -srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin +srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin nSeg1 = srcMesh.Segment().NumberOfSegments(4) srcMesh.Quadrangle() srcMesh.Compute() -srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE ) +srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE ) # Import faces from midFace0 to the target mesh -tgtMesh = Mesh(boxes[1], "target mesh") +tgtMesh = smesh.Mesh(boxes[1], "target mesh") importAlgo = tgtMesh.UseExisting2DElements(midFace1) import2hyp = importAlgo.SourceFaces( [srcFaceGroup] ) tgtMesh.Segment().NumberOfSegments(3) diff --git a/doc/salome/examples/defining_hypotheses_ex17.py b/doc/salome/examples/defining_hypotheses_ex17.py index dc3ee9bc8..d21638fcc 100644 --- a/doc/salome/examples/defining_hypotheses_ex17.py +++ b/doc/salome/examples/defining_hypotheses_ex17.py @@ -1,7 +1,14 @@ # Viscous layers construction -from smesh import * -SetCurrentStudy(salome.myStudy) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) X = geompy.MakeVectorDXDYDZ( 1,0,0 ) O = geompy.MakeVertex( 100,50,50 ) @@ -19,7 +26,7 @@ geompy.addToStudy( shape, "shape" ) geompy.addToStudyInFather( shape, face1, "face1") -mesh = Mesh(shape, "CFD") +mesh = smesh.Mesh(shape, "CFD") mesh.Segment().NumberOfSegments( 4 ) @@ -35,6 +42,6 @@ layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFa mesh.Compute() -mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA) -mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID) -mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA) +mesh.MakeGroup("Tetras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_TETRA) +mesh.MakeGroup("Pyras",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PYRAMID) +mesh.MakeGroup("Prims",SMESH.VOLUME,SMESH.FT_ElemGeomType,"=",SMESH.Geom_PENTA) diff --git a/doc/salome/examples/filters_ex01.py b/doc/salome/examples/filters_ex01.py index 986904774..86be38182 100644 --- a/doc/salome/examples/filters_ex01.py +++ b/doc/salome/examples/filters_ex01.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get faces with aspect ratio > 6.5 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 6.5) +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 6.5) ids = mesh.GetIdsFromFilter(filter) print "Number of faces with aspect ratio > 6.5:", len(ids) diff --git a/doc/salome/examples/filters_ex02.py b/doc/salome/examples/filters_ex02.py index f69217398..5709ef4b0 100644 --- a/doc/salome/examples/filters_ex02.py +++ b/doc/salome/examples/filters_ex02.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # get volumes with aspect ratio < 2.0 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_LessThan, 2.0) +filter = smesh.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/salome/examples/filters_ex03.py b/doc/salome/examples/filters_ex03.py index 5afe3a44e..c9313bceb 100644 --- a/doc/salome/examples/filters_ex03.py +++ b/doc/salome/examples/filters_ex03.py @@ -3,7 +3,7 @@ # create mesh from SMESH_mechanic import * # get faces with warping angle = 2.0e-13 with tolerance 5.0e-14 -criterion = smesh.GetCriterion(smesh.FACE, smesh.FT_Warping, smesh.FT_EqualTo, 2.0e-13) +criterion = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_EqualTo, 2.0e-13) criterion.Tolerance = 5.0e-14 filter = smesh.CreateFilterManager().CreateFilter() filter.SetCriteria([criterion]) diff --git a/doc/salome/examples/filters_ex04.py b/doc/salome/examples/filters_ex04.py index d4d31a76c..fef619c80 100644 --- a/doc/salome/examples/filters_ex04.py +++ b/doc/salome/examples/filters_ex04.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get faces with minimum angle > 75 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle,">", 75) +filter = smesh.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/salome/examples/filters_ex05.py b/doc/salome/examples/filters_ex05.py index b15225194..c1c185275 100644 --- a/doc/salome/examples/filters_ex05.py +++ b/doc/salome/examples/filters_ex05.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.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/salome/examples/filters_ex06.py b/doc/salome/examples/filters_ex06.py index 0f609a569..610a9a9e8 100644 --- a/doc/salome/examples/filters_ex06.py +++ b/doc/salome/examples/filters_ex06.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get faces with skew > 50 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 50) +filter = smesh.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/salome/examples/filters_ex07.py b/doc/salome/examples/filters_ex07.py index 723d8d282..6c42d5217 100644 --- a/doc/salome/examples/filters_ex07.py +++ b/doc/salome/examples/filters_ex07.py @@ -3,9 +3,9 @@ # create mesh from SMESH_mechanic import * # get faces with area > 60 and < 90 -criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 60,\ - smesh.FT_Undefined, smesh.FT_LogicalAND) -criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 90) +criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 60,\ + SMESH.FT_Undefined, SMESH.FT_LogicalAND) +criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 90) filter = smesh.CreateFilterManager().CreateFilter() filter.SetCriteria([criterion1,criterion2]) ids = mesh.GetIdsFromFilter(filter) diff --git a/doc/salome/examples/filters_ex08.py b/doc/salome/examples/filters_ex08.py index 2bc96b672..d87f97453 100644 --- a/doc/salome/examples/filters_ex08.py +++ b/doc/salome/examples/filters_ex08.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # get volumes faces with volume > 100 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_MoreThan, 100) +filter = smesh.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/salome/examples/filters_ex09.py b/doc/salome/examples/filters_ex09.py index 0d045b7b7..9efa00871 100644 --- a/doc/salome/examples/filters_ex09.py +++ b/doc/salome/examples/filters_ex09.py @@ -1,7 +1,17 @@ # Free borders # create mesh -import geompy, smesh, StdMeshers + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + face = geompy.MakeFaceHW(100, 100, 1) geompy.addToStudy( face, "quadrangle" ) mesh = smesh.Mesh(face) @@ -9,6 +19,6 @@ mesh.Segment().NumberOfSegments(10) mesh.Triangle().MaxElementArea(25) mesh.Compute() # get all free borders -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) +filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) ids = mesh.GetIdsFromFilter(filter) print "Number of edges on free borders:", len(ids) diff --git a/doc/salome/examples/filters_ex10.py b/doc/salome/examples/filters_ex10.py index bbbdd9889..423b91029 100644 --- a/doc/salome/examples/filters_ex10.py +++ b/doc/salome/examples/filters_ex10.py @@ -1,7 +1,17 @@ # Free edges # create mesh -import geompy, smesh, StdMeshers + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + face = geompy.MakeFaceHW(100, 100, 1) geompy.addToStudy( face, "quadrangle" ) mesh = smesh.Mesh(face) @@ -9,6 +19,6 @@ 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.GetFilter(SMESH.FACE, SMESH.FT_FreeEdges) ids = mesh.GetIdsFromFilter(filter) print "Number of faces with free edges:", len(ids) diff --git a/doc/salome/examples/filters_ex11.py b/doc/salome/examples/filters_ex11.py index 4d754bc00..5f1bf4c68 100644 --- a/doc/salome/examples/filters_ex11.py +++ b/doc/salome/examples/filters_ex11.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * # add node mesh.AddNode(0,0,0) # get all free nodes -filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes) +filter = smesh.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) ids = mesh.GetIdsFromFilter(filter) print "Number of free nodes:", len(ids) diff --git a/doc/salome/examples/filters_ex12.py b/doc/salome/examples/filters_ex12.py index dfb0f40ba..a1f20dcf3 100644 --- a/doc/salome/examples/filters_ex12.py +++ b/doc/salome/examples/filters_ex12.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get all free faces -filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces) +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces) ids = mesh.GetIdsFromFilter(filter) print "Number of free faces:", len(ids) diff --git a/doc/salome/examples/filters_ex13.py b/doc/salome/examples/filters_ex13.py index e20937d1b..f56d39f84 100644 --- a/doc/salome/examples/filters_ex13.py +++ b/doc/salome/examples/filters_ex13.py @@ -3,8 +3,8 @@ # create mesh from SMESH_mechanic import * # remove some faces to have faces with bare borders -mesh.RemoveElements( mesh.GetElementsByType(smesh.FACE)[0:5] ) +mesh.RemoveElements( mesh.GetElementsByType(SMESH.FACE)[0:5] ) # get all faces bare borders -filter = smesh.GetFilter(smesh.FACE, smesh.FT_BareBorderFace) +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_BareBorderFace) ids = mesh.GetIdsFromFilter(filter) print "Faces with bare borders:", ids diff --git a/doc/salome/examples/filters_ex14.py b/doc/salome/examples/filters_ex14.py index 01ea27ab9..a9021f98c 100644 --- a/doc/salome/examples/filters_ex14.py +++ b/doc/salome/examples/filters_ex14.py @@ -2,8 +2,8 @@ # create mesh from SMESH_mechanic import * -faceID = mesh.GetElementsByType(smesh.FACE)[0] +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.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/salome/examples/filters_ex15.py b/doc/salome/examples/filters_ex15.py index 2044c6048..3f1344704 100644 --- a/doc/salome/examples/filters_ex15.py +++ b/doc/salome/examples/filters_ex15.py @@ -2,6 +2,6 @@ # create mesh from SMESH_mechanic import * # get all over-constrained faces -filter = smesh.GetFilter(smesh.FACE, smesh.FT_OverConstrainedFace) +filter = smesh.GetFilter(SMESH.FACE, SMESH.FT_OverConstrainedFace) ids = mesh.GetIdsFromFilter(filter) print "Over-constrained faces:", ids diff --git a/doc/salome/examples/filters_ex16.py b/doc/salome/examples/filters_ex16.py index 3c7159d9f..bdca2d86a 100644 --- a/doc/salome/examples/filters_ex16.py +++ b/doc/salome/examples/filters_ex16.py @@ -1,20 +1,31 @@ # Double edges, Double faces, Double volumes -from smesh import * + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # make a mesh on a box box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = Mesh( box, "Box" ) +mesh = smesh.Mesh( box, "Box" ) mesh.Segment().NumberOfSegments(10) mesh.Quadrangle() mesh.Hexahedron() mesh.Compute() # copy all elements with translation and Merge nodes -mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True ) +mesh.TranslateObject( mesh, smesh.MakeDirStruct( 10,0,0), Copy=True ) mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) ) # create filters to find equal elements -equalEdgesFilter = GetFilter(SMESH.EDGE, FT_EqualEdges) -equalFacesFilter = GetFilter(SMESH.FACE, FT_EqualFaces) -equalVolumesFilter = GetFilter(SMESH.VOLUME, FT_EqualVolumes) +equalEdgesFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_EqualEdges) +equalFacesFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_EqualFaces) +equalVolumesFilter = smesh.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/salome/examples/filters_ex17.py b/doc/salome/examples/filters_ex17.py index b79f4a74d..c3f80d65a 100644 --- a/doc/salome/examples/filters_ex17.py +++ b/doc/salome/examples/filters_ex17.py @@ -1,16 +1,27 @@ # Double nodes -from smesh import * + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # make a mesh on a box box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = Mesh( box, "Box" ) +mesh = smesh.Mesh( box, "Box" ) mesh.Segment().NumberOfSegments(10) mesh.Quadrangle() mesh.Hexahedron() mesh.Compute() # copy all elements with translation -mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True ) +mesh.TranslateObject( mesh, smesh.MakeDirStruct( 10,0,0), Copy=True ) # create filters to find nodes equal within tolerance of 1e-5 -filter = GetFilter(SMESH.NODE, FT_EqualNodes, Tolerance=1e-5) +filter = smesh.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/salome/examples/filters_ex18.py b/doc/salome/examples/filters_ex18.py index 30158e28b..805f54e06 100644 --- a/doc/salome/examples/filters_ex18.py +++ b/doc/salome/examples/filters_ex18.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get border edges with number of connected faces = 5 -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, 5) +filter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, 5) ids = mesh.GetIdsFromFilter(filter) print "Number of border edges with 5 faces connected:", len(ids) diff --git a/doc/salome/examples/filters_ex19.py b/doc/salome/examples/filters_ex19.py index 41b7cc762..3ac78794f 100644 --- a/doc/salome/examples/filters_ex19.py +++ b/doc/salome/examples/filters_ex19.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get faces which consist of edges belonging to 2 mesh elements -filter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, 2) +filter = smesh.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/salome/examples/filters_ex20.py b/doc/salome/examples/filters_ex20.py index 37227c49d..1bdc00b53 100644 --- a/doc/salome/examples/filters_ex20.py +++ b/doc/salome/examples/filters_ex20.py @@ -3,6 +3,6 @@ # create mesh from SMESH_mechanic import * # get edges with length > 14 -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, 14) +filter = smesh.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/salome/examples/filters_ex21.py b/doc/salome/examples/filters_ex21.py index 0882fe294..79c88434b 100644 --- a/doc/salome/examples/filters_ex21.py +++ b/doc/salome/examples/filters_ex21.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, 14) ids = mesh.GetIdsFromFilter(filter) print "Number of faces with maximum edge length > 14:", len(ids) diff --git a/doc/salome/examples/filters_ex22.py b/doc/salome/examples/filters_ex22.py index f65421786..0271110fe 100644 --- a/doc/salome/examples/filters_ex22.py +++ b/doc/salome/examples/filters_ex22.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.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/salome/examples/filters_ex23.py b/doc/salome/examples/filters_ex23.py index 848f8d92c..49569dfe8 100644 --- a/doc/salome/examples/filters_ex23.py +++ b/doc/salome/examples/filters_ex23.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # get all volumes that have elements with length > 10 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, 10) +filter = smesh.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/salome/examples/filters_ex24.py b/doc/salome/examples/filters_ex24.py index 036ba037e..bab47e2a7 100644 --- a/doc/salome/examples/filters_ex24.py +++ b/doc/salome/examples/filters_ex24.py @@ -7,6 +7,6 @@ mesh.Compute() # remove some volumes to have volumes with bare borders mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] ) # get all volumes with bare borders -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BareBorderVolume) +filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BareBorderVolume) ids = mesh.GetIdsFromFilter(filter) print "Volumes with bare borders:", ids diff --git a/doc/salome/examples/filters_ex25.py b/doc/salome/examples/filters_ex25.py index 7e4489848..06862c75f 100644 --- a/doc/salome/examples/filters_ex25.py +++ b/doc/salome/examples/filters_ex25.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # get all over-constrained volumes -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_OverConstrainedVolume) +filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_OverConstrainedVolume) ids = mesh.GetIdsFromFilter(filter) print "Over-constrained volumes:", ids diff --git a/doc/salome/examples/filters_ex26.py b/doc/salome/examples/filters_ex26.py index 3c5ce2965..d544466e4 100644 --- a/doc/salome/examples/filters_ex26.py +++ b/doc/salome/examples/filters_ex26.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.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/salome/examples/filters_ex27.py b/doc/salome/examples/filters_ex27.py index 10067ea07..4c38bd92f 100644 --- a/doc/salome/examples/filters_ex27.py +++ b/doc/salome/examples/filters_ex27.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.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/salome/examples/filters_ex28.py b/doc/salome/examples/filters_ex28.py index 032b966a5..12da64cc7 100644 --- a/doc/salome/examples/filters_ex28.py +++ b/doc/salome/examples/filters_ex28.py @@ -3,10 +3,9 @@ # create mesh from SMESH_mechanic import * # create plane -import geompy plane_1 = geompy.MakePlane(p3,seg1,2000) geompy.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.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/salome/examples/filters_ex29.py b/doc/salome/examples/filters_ex29.py index c256724b3..b4a454ad7 100644 --- a/doc/salome/examples/filters_ex29.py +++ b/doc/salome/examples/filters_ex29.py @@ -3,6 +3,6 @@ # create mesh from SMESH_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.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/salome/examples/filters_ex30.py b/doc/salome/examples/filters_ex30.py index 19c213810..9d161a763 100644 --- a/doc/salome/examples/filters_ex30.py +++ b/doc/salome/examples/filters_ex30.py @@ -7,6 +7,6 @@ spline_1 = geompy.MakeInterpol([p4,p6,p3,p1]) surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 ) geompy.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.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/salome/examples/filters_ex31.py b/doc/salome/examples/filters_ex31.py index 4a2acbfa8..ea9b99e0e 100644 --- a/doc/salome/examples/filters_ex31.py +++ b/doc/salome/examples/filters_ex31.py @@ -3,9 +3,9 @@ # create mesh from SMESH_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") +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() filter.SetCriteria([criterion1,criterion2]) ids = mesh.GetIdsFromFilter(filter) diff --git a/doc/salome/examples/filters_ex32.py b/doc/salome/examples/filters_ex32.py index 726ca153f..5ce64d625 100644 --- a/doc/salome/examples/filters_ex32.py +++ b/doc/salome/examples/filters_ex32.py @@ -5,6 +5,6 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # get all badly oriented volumes -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BadOrientedVolume) +filter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_BadOrientedVolume) ids = mesh.GetIdsFromFilter(filter) print "Number of badly oriented volumes:", len(ids) diff --git a/doc/salome/examples/filters_ex33.py b/doc/salome/examples/filters_ex33.py index 2fbaab03e..c844e9063 100644 --- a/doc/salome/examples/filters_ex33.py +++ b/doc/salome/examples/filters_ex33.py @@ -3,8 +3,8 @@ # create mesh from SMESH_mechanic import * # get number of 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.GetFilter(SMESH.EDGE, SMESH.FT_LinearOrQuadratic) +filter_quadratic = smesh.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/salome/examples/filters_ex34.py b/doc/salome/examples/filters_ex34.py index 8e63056b4..980509dbe 100644 --- a/doc/salome/examples/filters_ex34.py +++ b/doc/salome/examples/filters_ex34.py @@ -3,12 +3,12 @@ # create mesh from SMESH_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]) +all_edges = mesh.GetElementsByType(SMESH.EDGE) +grp = mesh.MakeGroupByIds("edges group", SMESH.EDGE, all_edges[:len(all_edges)/4]) 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.GetFilter(SMESH.EDGE, SMESH.FT_GroupColor, c, SMESH.FT_LogicalNOT) ids = mesh.GetIdsFromFilter(filter) print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids) diff --git a/doc/salome/examples/filters_ex35.py b/doc/salome/examples/filters_ex35.py index 369d7323a..4a3c2bd3c 100644 --- a/doc/salome/examples/filters_ex35.py +++ b/doc/salome/examples/filters_ex35.py @@ -5,10 +5,10 @@ from SMESH_mechanic import * mesh.Tetrahedron() mesh.Compute() # 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.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) ids_tri = mesh.GetIdsFromFilter(filter_tri) ids_qua = mesh.GetIdsFromFilter(filter_qua) ids_tet = mesh.GetIdsFromFilter(filter_tet) diff --git a/doc/salome/examples/filters_ex36.py b/doc/salome/examples/filters_ex36.py index 7675bc9f6..3dc8e4fc6 100644 --- a/doc/salome/examples/filters_ex36.py +++ b/doc/salome/examples/filters_ex36.py @@ -3,11 +3,11 @@ # create mesh from SMESH_mechanic import * # get all the quadrangle faces ... -criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE, smesh.FT_LogicalAND) +criterion1 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_ElemGeomType, SMESH.Geom_QUADRANGLE, SMESH.FT_LogicalAND) # ... AND do NOT get those from sub_face3 -criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_BelongToGeom, sub_face3, smesh.FT_LogicalNOT) +criterion2 = smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGeom, sub_face3, SMESH.FT_LogicalNOT) filter = smesh.CreateFilterManager().CreateFilter() filter.SetCriteria([criterion1,criterion2]) ids = mesh.GetIdsFromFilter(filter) -myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids) +myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",SMESH.FACE,ids) diff --git a/doc/salome/examples/generate_flat_elements.py b/doc/salome/examples/generate_flat_elements.py index a23c200a4..df187188b 100644 --- a/doc/salome/examples/generate_flat_elements.py +++ b/doc/salome/examples/generate_flat_elements.py @@ -3,9 +3,17 @@ # This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder). # The big cylinder is defined by two geometric volumes. -import geompy -import smesh -import SMESH + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + # geometry @@ -21,22 +29,22 @@ 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"], geompy.GEOM.ST_IN) -[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN) +[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, geompy.GEOM.ST_ON) -[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, geompy.GEOM.ST_ON) +[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) # meshing (we have linear tetrahedrons here, but other elements are OK) Mesh_1 = smesh.Mesh(Partition_1) Regular_1D = Mesh_1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(15) -MEFISTO_2D = Mesh_1.Triangle(algo=smesh.MEFISTO) +MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO) Length_From_Edges_2D = MEFISTO_2D.LengthFromEdges() ALGO3D = Mesh_1.Tetrahedron() isDone = Mesh_1.Compute() diff --git a/doc/salome/examples/grouping_elements_ex01.py b/doc/salome/examples/grouping_elements_ex01.py index d0971d621..013332766 100644 --- a/doc/salome/examples/grouping_elements_ex01.py +++ b/doc/salome/examples/grouping_elements_ex01.py @@ -1,21 +1,22 @@ # Create a Standalone Group import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Get ids of all faces with area > 100 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) anIds = mesh.GetIdsFromFilter(aFilter) # create a group consisting of faces with area > 100 -aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds) +aGroup1 = mesh.MakeGroupByIds("Area > 100", SMESH.FACE, anIds) # create a group that contains all nodes from the mesh -aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes") +aGroup2 = mesh.CreateEmptyGroup(SMESH.NODE, "all nodes") aGroup2.AddFrom(mesh.mesh) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/grouping_elements_ex02.py b/doc/salome/examples/grouping_elements_ex02.py index 228248d7f..909a9b482 100644 --- a/doc/salome/examples/grouping_elements_ex02.py +++ b/doc/salome/examples/grouping_elements_ex02.py @@ -1,8 +1,15 @@ # Create a Group on Geometry + import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBox(0., 0., 0., 100., 100., 100.) diff --git a/doc/salome/examples/grouping_elements_ex03.py b/doc/salome/examples/grouping_elements_ex03.py index 05fb69d57..375749cb4 100644 --- a/doc/salome/examples/grouping_elements_ex03.py +++ b/doc/salome/examples/grouping_elements_ex03.py @@ -1,23 +1,33 @@ # Create a Group on Filter -from smesh import * -SetCurrentStudy(salome.myStudy) + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + box = geompy.MakeBoxDXDYDZ(10,10,10) # make a mesh with quadrangles of different area in range [1,16] -mesh = Mesh(box,"Quad mesh") +mesh = smesh.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 = [ \ - GetCriterion(FACE, FT_Area, ">", 1.1, BinaryOp=FT_LogicalAND ), - GetCriterion(FACE, FT_Area, "<", 15.0 ) + smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, ">", 1.1, BinaryOp=SMESH.FT_LogicalAND ), + smesh.GetCriterion(SMESH.FACE, SMESH.FT_Area, "<", 15.0 ) ] -filt = GetFilterFromCriteria( critaria ) -filtGroup = mesh.GroupOnFilter( FACE, "group on filter", filt ) +filt = smesh.GetFilterFromCriteria( critaria ) +filtGroup = mesh.GroupOnFilter( SMESH.FACE, "group on filter", filt ) print "Group on filter contains %s elemens" % filtGroup.Size() # group on filter is updated if the mesh is modified @@ -27,12 +37,12 @@ mesh.Compute() print "After mesh change, group on filter contains %s elemens" % filtGroup.Size() # set a new filter defining the group -filt2 = GetFilter( FACE, FT_RangeOfIds, "1-50" ) +filt2 = smesh.GetFilter( SMESH.FACE, SMESH.FT_RangeOfIds, "1-50" ) filtGroup.SetFilter( filt2 ) print "With a new filter, group on filter contains %s elemens" % filtGroup.Size() # group is updated at modification of the filter -filt2.SetCriteria( [ GetCriterion( FACE, FT_RangeOfIds, "1-70" )]) +filt2.SetCriteria( [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_RangeOfIds, "1-70" )]) filtIDs3 = filtGroup.GetIDs() print "After filter modification, group on filter contains %s elemens" % filtGroup.Size() diff --git a/doc/salome/examples/grouping_elements_ex04.py b/doc/salome/examples/grouping_elements_ex04.py index 730a2ca6b..ebd59e76f 100644 --- a/doc/salome/examples/grouping_elements_ex04.py +++ b/doc/salome/examples/grouping_elements_ex04.py @@ -1,24 +1,25 @@ # Edit a Group import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Get ids of all faces with area > 35 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 35.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area > 35, Nb = ", len(anIds) # create a group by adding elements with area > 35 -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35") +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.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 40.) anIds = mesh.GetIdsFromFilter(aFilter) diff --git a/doc/salome/examples/grouping_elements_ex05.py b/doc/salome/examples/grouping_elements_ex05.py index 90453fed1..9883ebda2 100644 --- a/doc/salome/examples/grouping_elements_ex05.py +++ b/doc/salome/examples/grouping_elements_ex05.py @@ -1,31 +1,32 @@ # Union of groups import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area > 20, Nb = ", len( anIds ) # create a group by adding elements with area > 20 -aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20") +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.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_EqualTo, 20.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area = 20, Nb = ", len( anIds ) # create a group by adding elements with area = 20 -aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" ) +aGroup2 = mesh.CreateEmptyGroup( SMESH.FACE, "Area = 20" ) aGroup2.Add(anIds) @@ -35,14 +36,14 @@ 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.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area < 20, Nb = ", len(anIds) # create a group by adding elements with area < 20 -aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20") +aGroup4 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 20") aGroup4.Add(anIds) # create union group : area >= 20 and area < 20 diff --git a/doc/salome/examples/grouping_elements_ex06.py b/doc/salome/examples/grouping_elements_ex06.py index cc8146fb9..060a22d6c 100644 --- a/doc/salome/examples/grouping_elements_ex06.py +++ b/doc/salome/examples/grouping_elements_ex06.py @@ -1,31 +1,32 @@ # Intersection of groups import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area > 20, Nb = ", len(anIds) # create a group by adding elements with area > 20 -aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20") +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.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area < 60, Nb = ", len(anIds) # create a group by adding elements with area < 60 -aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60") +aGroup2 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 60") aGroup2.Add(anIds) # create an intersection of groups : 20 < area < 60 diff --git a/doc/salome/examples/grouping_elements_ex07.py b/doc/salome/examples/grouping_elements_ex07.py index 5bcccd0c7..891ed889a 100644 --- a/doc/salome/examples/grouping_elements_ex07.py +++ b/doc/salome/examples/grouping_elements_ex07.py @@ -1,30 +1,31 @@ # Cut of groups import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 20.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area > 20, Nb = ", len(anIds) # create a group by adding elements with area > 20 -aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, 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.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 60.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area < 60, Nb = ", len(anIds) # create a group by adding elements with area < 60 -aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds) +aGroupTool = mesh.MakeGroupByIds("Area < 60", SMESH.FACE, anIds) # create a cut of groups : area >= 60 aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60") diff --git a/doc/salome/examples/grouping_elements_ex08.py b/doc/salome/examples/grouping_elements_ex08.py index a86ec6317..fa78d72f3 100644 --- a/doc/salome/examples/grouping_elements_ex08.py +++ b/doc/salome/examples/grouping_elements_ex08.py @@ -1,35 +1,36 @@ # Creating groups of entities from existing groups of superior dimensions import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh salome = SMESH_mechanic.salome # Criterion : AREA > 100 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area > 100, Nb = ", len(anIds) # create a group by adding elements with area > 100 -aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds) +aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", SMESH.FACE, anIds) # Criterion : AREA < 30 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_LessThan, 30.) anIds = mesh.GetIdsFromFilter(aFilter) print "Criterion: Area < 30, Nb = ", len(anIds) # create a group by adding elements with area < 30 -aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds) +aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", SMESH.FACE, anIds) # Create group of edges using source groups of faces -aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" ) +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" ) +aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], SMESH.NODE, "Nodes" ) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/measurements_ex01.py b/doc/salome/examples/measurements_ex01.py index 967754709..d8a5bd71c 100644 --- a/doc/salome/examples/measurements_ex01.py +++ b/doc/salome/examples/measurements_ex01.py @@ -1,6 +1,16 @@ # Minimum Distance -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + from SMESH_mechanic import mesh as mesh1 from SMESH_test1 import mesh as mesh2 diff --git a/doc/salome/examples/measurements_ex02.py b/doc/salome/examples/measurements_ex02.py index 3333bc0e5..b5fbf8b1f 100644 --- a/doc/salome/examples/measurements_ex02.py +++ b/doc/salome/examples/measurements_ex02.py @@ -1,6 +1,17 @@ # Bounding Box -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + from SMESH_mechanic import mesh as mesh1 from SMESH_test1 import mesh as mesh2 diff --git a/doc/salome/examples/modifying_meshes_ex01.py b/doc/salome/examples/modifying_meshes_ex01.py index ee183d708..434cc1a7e 100644 --- a/doc/salome/examples/modifying_meshes_ex01.py +++ b/doc/salome/examples/modifying_meshes_ex01.py @@ -1,6 +1,17 @@ # Add Node -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex02.py b/doc/salome/examples/modifying_meshes_ex02.py index c99bf2aff..563295c54 100644 --- a/doc/salome/examples/modifying_meshes_ex02.py +++ b/doc/salome/examples/modifying_meshes_ex02.py @@ -1,6 +1,17 @@ # Add 0D Element -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex03.py b/doc/salome/examples/modifying_meshes_ex03.py index 19b423e03..beefe20ce 100644 --- a/doc/salome/examples/modifying_meshes_ex03.py +++ b/doc/salome/examples/modifying_meshes_ex03.py @@ -1,6 +1,17 @@ # Add 0D Element on Element Nodes -import smesh, SMESH, geompy + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create a geometry box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) diff --git a/doc/salome/examples/modifying_meshes_ex09.py b/doc/salome/examples/modifying_meshes_ex09.py index 2fd91114d..476ebbbdc 100644 --- a/doc/salome/examples/modifying_meshes_ex09.py +++ b/doc/salome/examples/modifying_meshes_ex09.py @@ -1,9 +1,18 @@ # Add Polygon import math + import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook -import smesh # create an empty mesh structure mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex10.py b/doc/salome/examples/modifying_meshes_ex10.py index 1d1af1942..894fe9d4c 100644 --- a/doc/salome/examples/modifying_meshes_ex10.py +++ b/doc/salome/examples/modifying_meshes_ex10.py @@ -1,7 +1,17 @@ # Add Polyhedron + import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + import math # create an empty mesh structure diff --git a/doc/salome/examples/modifying_meshes_ex15.py b/doc/salome/examples/modifying_meshes_ex15.py index 49676d0ee..ae6d5eae7 100644 --- a/doc/salome/examples/modifying_meshes_ex15.py +++ b/doc/salome/examples/modifying_meshes_ex15.py @@ -1,18 +1,28 @@ # Moving Nodes -from geompy import * -from smesh import * -box = MakeBoxDXDYDZ(200, 200, 200) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -mesh = Mesh( box ) +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + + +box = geompy.MakeBoxDXDYDZ(200, 200, 200) + +mesh = smesh.Mesh( box ) mesh.Segment().AutomaticLength(0.1) mesh.Quadrangle() mesh.Compute() # find node at (0,0,0) node000 = None -for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]): +for vId in geompy.SubShapeAllIDs( box, geompy.ShapeType["VERTEX"]): if node000: break nodeIds = mesh.GetSubMeshNodesId( vId, True ) for node in nodeIds: diff --git a/doc/salome/examples/modifying_meshes_ex16.py b/doc/salome/examples/modifying_meshes_ex16.py index 6567dff19..076cebf6c 100644 --- a/doc/salome/examples/modifying_meshes_ex16.py +++ b/doc/salome/examples/modifying_meshes_ex16.py @@ -1,7 +1,17 @@ # Diagonal Inversion + import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create an empty mesh structure mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex17.py b/doc/salome/examples/modifying_meshes_ex17.py index 732953ab2..c45fd2829 100644 --- a/doc/salome/examples/modifying_meshes_ex17.py +++ b/doc/salome/examples/modifying_meshes_ex17.py @@ -1,7 +1,17 @@ # Uniting two Triangles + import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create an empty mesh structure mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex18.py b/doc/salome/examples/modifying_meshes_ex18.py index 9f7393022..60b395af9 100644 --- a/doc/salome/examples/modifying_meshes_ex18.py +++ b/doc/salome/examples/modifying_meshes_ex18.py @@ -1,7 +1,17 @@ # Uniting a Set of Triangles + import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create an empty mesh structure mesh = smesh.Mesh() @@ -37,7 +47,7 @@ ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]]) # unite a set of triangles print "\nUnite a set of triangles ... ", -res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], smesh.FT_MinimumAngle, 60.) +res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.) if not res: print "failed!" else: print "done." diff --git a/doc/salome/examples/modifying_meshes_ex19.py b/doc/salome/examples/modifying_meshes_ex19.py index c3eaf4977..7223fb099 100644 --- a/doc/salome/examples/modifying_meshes_ex19.py +++ b/doc/salome/examples/modifying_meshes_ex19.py @@ -1,7 +1,17 @@ # Orientation + import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create an empty mesh structure mesh = smesh.Mesh() diff --git a/doc/salome/examples/modifying_meshes_ex20.py b/doc/salome/examples/modifying_meshes_ex20.py index aa52da784..ffbff360a 100644 --- a/doc/salome/examples/modifying_meshes_ex20.py +++ b/doc/salome/examples/modifying_meshes_ex20.py @@ -1,9 +1,10 @@ # Cutting Quadrangles import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # cut two quadrangles: 405 and 406 -mesh.QuadToTri([405, 406], smesh.FT_MinimumAngle) +mesh.QuadToTri([405, 406], SMESH.FT_MinimumAngle) diff --git a/doc/salome/examples/modifying_meshes_ex21.py b/doc/salome/examples/modifying_meshes_ex21.py index ece705c7d..50355fd8b 100644 --- a/doc/salome/examples/modifying_meshes_ex21.py +++ b/doc/salome/examples/modifying_meshes_ex21.py @@ -1,11 +1,19 @@ # Smoothing + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import SMESH_mechanic -smesh = SMESH_mechanic.smesh +#smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # select the top face @@ -14,7 +22,7 @@ face = faces[3] geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole") # create a group of faces to be smoothed -GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", smesh.FACE) +GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", SMESH.FACE) # perform smoothing diff --git a/doc/salome/examples/modifying_meshes_ex22.py b/doc/salome/examples/modifying_meshes_ex22.py index e9dcb3c96..e6d5fd6ed 100644 --- a/doc/salome/examples/modifying_meshes_ex22.py +++ b/doc/salome/examples/modifying_meshes_ex22.py @@ -1,11 +1,19 @@ # Extrusion + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import SMESH_mechanic -smesh = SMESH_mechanic.smesh +#smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # select the top face @@ -14,11 +22,11 @@ face = faces[7] geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face circular top") # create a vector for extrusion -point = smesh.PointStruct(0., 0., 5.) -vector = smesh.DirStruct(point) +point = SMESH.PointStruct(0., 0., 5.) +vector = SMESH.DirStruct(point) # create a group to be extruded -GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", smesh.FACE) +GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", SMESH.FACE) # perform extrusion of the group mesh.ExtrusionSweepObject(GroupTri, vector, 5) diff --git a/doc/salome/examples/modifying_meshes_ex23.py b/doc/salome/examples/modifying_meshes_ex23.py index a789b76f0..bad439d99 100644 --- a/doc/salome/examples/modifying_meshes_ex23.py +++ b/doc/salome/examples/modifying_meshes_ex23.py @@ -1,10 +1,16 @@ # Extrusion along a Path import math + import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -# Geometry -import geompy +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # 1. Create points points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]] @@ -36,7 +42,6 @@ for ii in range(len(Wire_polyline_edges)): pass # Mesh -import smesh # Mesh the given shape with the given 1d hypothesis def Mesh1D(shape1d, nbSeg, name): @@ -91,7 +96,7 @@ Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle") # ExtrusionAlongPath # IDsOfElements, PathMesh, PathShape, NodeStart, # HasAngles, Angles, HasRefPoint, RefPoint -refPoint = smesh.PointStruct(0, 0, 0) +refPoint = SMESH.PointStruct(0, 0, 0) a10 = 10.0*math.pi/180.0 a45 = 45.0*math.pi/180.0 diff --git a/doc/salome/examples/modifying_meshes_ex25.py b/doc/salome/examples/modifying_meshes_ex25.py index e8801e003..4072560c4 100644 --- a/doc/salome/examples/modifying_meshes_ex25.py +++ b/doc/salome/examples/modifying_meshes_ex25.py @@ -1,7 +1,15 @@ # Pattern Mapping -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # define the geometry Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.) @@ -41,7 +49,7 @@ isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0) if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode() # apply the pattern to a face of the first mesh -facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE) +facesToSplit = Mesh_1.GetElementsByType(SMESH.FACE) print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit)) pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0) isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0) @@ -84,7 +92,7 @@ smp_hexa = """!!! Nb of points: pattern_hexa.LoadFromFile(smp_hexa) # apply the pattern to a mesh -volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME) +volsToSplit = Mesh_3.GetElementsByType(SMESH.VOLUME) print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit)) pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3) isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True) @@ -123,7 +131,7 @@ smp_pyra = """!!! Nb of points: pattern_pyra.LoadFromFile(smp_pyra) # apply the pattern to a face mesh -volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME) +volsToSplit = Mesh_4.GetElementsByType(SMESH.VOLUME) print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit)) pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0) isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True) diff --git a/doc/salome/examples/modifying_meshes_ex26.py b/doc/salome/examples/modifying_meshes_ex26.py index aa8cb4379..4a8eba75e 100644 --- a/doc/salome/examples/modifying_meshes_ex26.py +++ b/doc/salome/examples/modifying_meshes_ex26.py @@ -1,7 +1,15 @@ # Convert mesh to/from quadratic -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create sphere of radius 100 diff --git a/doc/salome/examples/notebook_smesh.py b/doc/salome/examples/notebook_smesh.py index 9cccc7b5b..e52ef1b54 100644 --- a/doc/salome/examples/notebook_smesh.py +++ b/doc/salome/examples/notebook_smesh.py @@ -1,7 +1,15 @@ # Using SALOME NoteBook -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import salome_notebook # set variables @@ -34,6 +42,6 @@ algo3D.MaxElementVolume("MaxElementVolume") ret = tetra.Compute() # translate the mesh -point = smesh.PointStruct("Offset", 0., 0.) -vector = smesh.DirStruct(point) +point = SMESH.PointStruct("Offset", 0., 0.) +vector = SMESH.DirStruct(point) tetra.TranslateObject(tetra, vector, 0) diff --git a/doc/salome/examples/quality_controls_ex01.py b/doc/salome/examples/quality_controls_ex01.py index f411d2e61..0f73a5619 100644 --- a/doc/salome/examples/quality_controls_ex01.py +++ b/doc/salome/examples/quality_controls_ex01.py @@ -1,9 +1,15 @@ # Free Borders + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create open shell: a box without one plane box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) @@ -21,7 +27,7 @@ algo.MaxElementArea(20.) mesh.Compute() # criterion : free borders -aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) +aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_FreeBorders) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -35,7 +41,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.GetMesh().CreateGroup(smesh.EDGE, "Free borders") +aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Free borders") aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex02.py b/doc/salome/examples/quality_controls_ex02.py index 5373c4d6f..491c81eb4 100644 --- a/doc/salome/examples/quality_controls_ex02.py +++ b/doc/salome/examples/quality_controls_ex02.py @@ -1,10 +1,15 @@ # Borders at Multiconnection + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh -import SMESH +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create open shell: a box without one plane box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) @@ -24,7 +29,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.GetFilter(SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, nb_conn) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -38,7 +43,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.GetMesh().CreateGroup(smesh.EDGE, "Borders at multi-connections") +aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Borders at multi-connections") aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex03.py b/doc/salome/examples/quality_controls_ex03.py index eaa607b94..b1da190f5 100644 --- a/doc/salome/examples/quality_controls_ex03.py +++ b/doc/salome/examples/quality_controls_ex03.py @@ -1,9 +1,15 @@ # Length 1D + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create open shell: a box without one plane box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) @@ -23,7 +29,7 @@ mesh.Compute() # Criterion : Length > 3. length_margin = 3. -aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin) +aFilter = smesh.GetFilter(SMESH.EDGE, SMESH.FT_Length, SMESH.FT_MoreThan, length_margin) anIds = mesh.GetIdsFromFilter(aFilter) # print the result @@ -37,7 +43,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.GetMesh().CreateGroup(smesh.EDGE, "Edges with length > " + `length_margin`) +aGroup = mesh.GetMesh().CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex04.py b/doc/salome/examples/quality_controls_ex04.py index d26eb4d82..c687d9293 100644 --- a/doc/salome/examples/quality_controls_ex04.py +++ b/doc/salome/examples/quality_controls_ex04.py @@ -1,6 +1,7 @@ # Free Edges import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -12,7 +13,7 @@ aFilterMgr = smesh.CreateFilterManager() # Criterion : AREA > 95. area_margin = 95. -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -22,8 +23,8 @@ mesh.RemoveElements(anIds) aBorders = mesh.GetFreeBorders() # create groups -aGroupF = mesh.CreateEmptyGroup(smesh.FACE, "Faces with free edges") -aGroupN = mesh.CreateEmptyGroup(smesh.NODE, "Nodes on free edges") +aGroupF = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with free edges") +aGroupN = mesh.CreateEmptyGroup(SMESH.NODE, "Nodes on free edges") # fill groups with elements, corresponding to the criterion print "" diff --git a/doc/salome/examples/quality_controls_ex05.py b/doc/salome/examples/quality_controls_ex05.py index 90c7c0451..f03456596 100644 --- a/doc/salome/examples/quality_controls_ex05.py +++ b/doc/salome/examples/quality_controls_ex05.py @@ -1,9 +1,15 @@ # Free Nodes + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) @@ -13,7 +19,7 @@ idbox = geompy.addToStudy(box, "box") mesh = smesh.Mesh(box, "Mesh_free_nodes") algo = mesh.Segment() algo.NumberOfSegments(10) -algo = mesh.Triangle(smesh.MEFISTO) +algo = mesh.Triangle(smeshBuilder.MEFISTO) algo.MaxElementArea(150.) mesh.Compute() @@ -21,18 +27,18 @@ mesh.Compute() # Criterion : AREA < 80. area_margin = 80. -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin) +aFilter = smesh.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.GetFilter(SMESH.NODE, SMESH.FT_FreeNodes) anNodeIds = mesh.GetIdsFromFilter(aFilter) # create a group -aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes") +aGroup = mesh.CreateEmptyGroup(SMESH.NODE, "Free_nodes") aGroup.Add(anNodeIds) # print the result diff --git a/doc/salome/examples/quality_controls_ex06.py b/doc/salome/examples/quality_controls_ex06.py index 2fe67abf6..861206bb3 100644 --- a/doc/salome/examples/quality_controls_ex06.py +++ b/doc/salome/examples/quality_controls_ex06.py @@ -1,7 +1,15 @@ # Free Faces + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) ####### GEOM part ######## @@ -30,9 +38,6 @@ geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" ) geompy.addToStudy( Plane_2, "Plane_2" ) ###### SMESH part ###### -import smesh - -import StdMeshers Mesh_1 = smesh.Mesh(Partition_1) Regular_1D = Mesh_1.Segment() @@ -42,10 +47,10 @@ Tetrahedronn = Mesh_1.Tetrahedron() isDone = Mesh_1.Compute() # create a group of free faces -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces ) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_FreeFaces ) aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) -aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces") +aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Free_faces") aGroup.Add(aFaceIds) # print the result @@ -59,15 +64,15 @@ for i in range(len(aFaceIds)): print "" #filter faces from plane 2 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2) +aFilter = smesh.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.GetFilter(SMESH.FACE, SMESH.FT_BelongToPlane, Plane_1) aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) -aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces") +aGroup = Mesh_1.CreateEmptyGroup(SMESH.FACE, "Shared_faces") aGroup.Add(aFaceIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex07.py b/doc/salome/examples/quality_controls_ex07.py index a2be02932..5e84f2bfc 100644 --- a/doc/salome/examples/quality_controls_ex07.py +++ b/doc/salome/examples/quality_controls_ex07.py @@ -1,7 +1,17 @@ # Bare border faces -from smesh import * -SetCurrentStudy(salome.myStudy) + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + box = geompy.MakeBoxDXDYDZ(100, 100, 100) geompy.addToStudy( box, "box" ) @@ -12,8 +22,8 @@ mesh.Quadrangle() mesh.Compute() # remove 2 faces -allFaces = mesh.GetElementsByType(FACE) +allFaces = mesh.GetElementsByType(SMESH.FACE) mesh.RemoveElements( allFaces[0:2]) -bareGroup = mesh.MakeGroup("bare faces", FACE, FT_BareBorderFace) +bareGroup = mesh.MakeGroup("bare faces", SMESH.FACE, SMESH.FT_BareBorderFace) assert(bareGroup.Size() == 3) diff --git a/doc/salome/examples/quality_controls_ex08.py b/doc/salome/examples/quality_controls_ex08.py index 77e7e4c94..541af64a3 100644 --- a/doc/salome/examples/quality_controls_ex08.py +++ b/doc/salome/examples/quality_controls_ex08.py @@ -1,7 +1,17 @@ # Bare border volumes -from smesh import * -SetCurrentStudy(salome.myStudy) + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + box = geompy.MakeBoxDXDYDZ(100, 30, 10) # the smallest face of the box @@ -10,7 +20,7 @@ face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0] geompy.addToStudy( box, "box" ) geompy.addToStudyInFather( box, face, "face" ) -mesh = Mesh(box) +mesh = smesh.Mesh(box) mesh.AutomaticHexahedralization(); # remove half of mesh faces from the smallest face @@ -19,5 +29,5 @@ faceToRemove = faceFaces[: len(faceFaces)/2] mesh.RemoveElements( faceToRemove ) # make a group of volumes missing the removed faces -bareGroup = mesh.MakeGroup("bare volumes", VOLUME, FT_BareBorderVolume) +bareGroup = mesh.MakeGroup("bare volumes", SMESH.VOLUME, SMESH.FT_BareBorderVolume) assert(bareGroup.Size() == len( faceToRemove)) diff --git a/doc/salome/examples/quality_controls_ex09.py b/doc/salome/examples/quality_controls_ex09.py index c4ca44e80..aca903ae0 100644 --- a/doc/salome/examples/quality_controls_ex09.py +++ b/doc/salome/examples/quality_controls_ex09.py @@ -1,10 +1,20 @@ # Over-constrained faces -from smesh import * -SetCurrentStudy(salome.myStudy) -mesh = Mesh() -faceFilter = GetFilter(FACE,FT_OverConstrainedFace) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + + +mesh = smesh.Mesh() +faceFilter = smesh.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace) #make an edge n1 = mesh.AddNode(0,0,0) @@ -13,5 +23,5 @@ edge = mesh.AddEdge([n1,n2]) assert( not mesh.GetIdsFromFilter( faceFilter )) # make faces -mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 5) +mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 5) assert( 2 == len( mesh.GetIdsFromFilter( faceFilter ))) diff --git a/doc/salome/examples/quality_controls_ex10.py b/doc/salome/examples/quality_controls_ex10.py index 49ef2e72a..041183224 100644 --- a/doc/salome/examples/quality_controls_ex10.py +++ b/doc/salome/examples/quality_controls_ex10.py @@ -1,15 +1,25 @@ # Over-constrained volumes -from smesh import * -SetCurrentStudy(salome.myStudy) -mesh = Mesh() -volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume) +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + + +mesh = smesh.Mesh() +volumeFilter = smesh.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], MakeDirStruct(0,7,0), 1) -mesh.ExtrusionSweep( mesh.GetElementsByType(FACE), MakeDirStruct(0,0,5), 7) +mesh.ExtrusionSweep([edge], smesh.MakeDirStruct(0,7,0), 1) +mesh.ExtrusionSweep( mesh.GetElementsByType(SMESH.FACE), smesh.MakeDirStruct(0,0,5), 7) assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter ))) diff --git a/doc/salome/examples/quality_controls_ex11.py b/doc/salome/examples/quality_controls_ex11.py index ca955b6ab..69352be34 100644 --- a/doc/salome/examples/quality_controls_ex11.py +++ b/doc/salome/examples/quality_controls_ex11.py @@ -1,9 +1,15 @@ # Length 2D + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create open shell: a box without one plane box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) @@ -23,7 +29,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.GetFilter(SMESH.FACE, SMESH.FT_Length2D, SMESH.FT_MoreThan, length_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -38,7 +44,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Faces with length 2D > " + `length_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex12.py b/doc/salome/examples/quality_controls_ex12.py index 28a0192c5..4ddcc387d 100644 --- a/doc/salome/examples/quality_controls_ex12.py +++ b/doc/salome/examples/quality_controls_ex12.py @@ -1,9 +1,15 @@ # Borders at Multiconnection 2D + import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a compound of two glued boxes box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) @@ -23,7 +29,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.GetFilter(SMESH.FACE, SMESH.FT_MultiConnection2D, SMESH.FT_EqualTo, nb_conn) anIds = mesh.GetIdsFromFilter(aFilter) @@ -38,7 +44,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Borders at multi-connection 2D = " + `nb_conn`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex13.py b/doc/salome/examples/quality_controls_ex13.py index 1673fc737..10810c849 100644 --- a/doc/salome/examples/quality_controls_ex13.py +++ b/doc/salome/examples/quality_controls_ex13.py @@ -1,6 +1,7 @@ # Area import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : AREA > 100. area_margin = 100. -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, area_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Area > " + `area_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex14.py b/doc/salome/examples/quality_controls_ex14.py index 379affdbd..50f87fbf7 100644 --- a/doc/salome/examples/quality_controls_ex14.py +++ b/doc/salome/examples/quality_controls_ex14.py @@ -1,6 +1,7 @@ # Taper import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : Taper > 3e-20 taper_margin = 3e-20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, taper_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Taper > " + `taper_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex15.py b/doc/salome/examples/quality_controls_ex15.py index 5ca56db0b..2c8fe7c6c 100644 --- a/doc/salome/examples/quality_controls_ex15.py +++ b/doc/salome/examples/quality_controls_ex15.py @@ -1,6 +1,7 @@ # Aspect Ratio import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : ASPECT RATIO > 1.8 ar_margin = 1.8 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, ar_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Aspect Ratio > " + `ar_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex16.py b/doc/salome/examples/quality_controls_ex16.py index a20f38f7b..5d8bade8a 100644 --- a/doc/salome/examples/quality_controls_ex16.py +++ b/doc/salome/examples/quality_controls_ex16.py @@ -1,6 +1,7 @@ # Minimum Angle import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : MINIMUM ANGLE < 35. min_angle = 35. -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, min_angle) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Minimum Angle < " + `min_angle`) aGroup.Add(anIds) diff --git a/doc/salome/examples/quality_controls_ex17.py b/doc/salome/examples/quality_controls_ex17.py index fcc596c75..bd87eae42 100644 --- a/doc/salome/examples/quality_controls_ex17.py +++ b/doc/salome/examples/quality_controls_ex17.py @@ -1,6 +1,7 @@ # Warping import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : WARP ANGLE > 1e-15 wa_margin = 1e-15 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, wa_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Warp > " + `wa_margin`) aGroup.Add(anIds) diff --git a/doc/salome/examples/quality_controls_ex18.py b/doc/salome/examples/quality_controls_ex18.py index 42e4b30e8..972652c38 100644 --- a/doc/salome/examples/quality_controls_ex18.py +++ b/doc/salome/examples/quality_controls_ex18.py @@ -1,6 +1,7 @@ # Skew import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # Criterion : Skew > 38. skew_margin = 38. -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin) +aFilter = smesh.GetFilter(SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, skew_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Skew > " + `skew_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex19.py b/doc/salome/examples/quality_controls_ex19.py index abe195200..8b7e89a15 100644 --- a/doc/salome/examples/quality_controls_ex19.py +++ b/doc/salome/examples/quality_controls_ex19.py @@ -1,6 +1,7 @@ # Element Diameter 2D import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic.salome # 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.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, mel_2d_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 2D > " + `mel_2d_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 2D > " + `mel_2d_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex20.py b/doc/salome/examples/quality_controls_ex20.py index 9e332e0dc..40a7bf155 100644 --- a/doc/salome/examples/quality_controls_ex20.py +++ b/doc/salome/examples/quality_controls_ex20.py @@ -1,6 +1,7 @@ # Aspect Ratio 3D import SMESH_mechanic_tetra +import SMESH smesh = SMESH_mechanic_tetra.smesh mesh = SMESH_mechanic_tetra.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic_tetra.salome # 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.GetFilter(SMESH.VOLUME, SMESH.FT_AspectRatio3D, SMESH.FT_MoreThan, ar_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Aspect Ratio 3D > " + `ar_margin`) aGroup.Add(anIds) diff --git a/doc/salome/examples/quality_controls_ex21.py b/doc/salome/examples/quality_controls_ex21.py index 833ffff81..29e384357 100644 --- a/doc/salome/examples/quality_controls_ex21.py +++ b/doc/salome/examples/quality_controls_ex21.py @@ -1,6 +1,7 @@ # Volume import SMESH_mechanic_tetra +import SMESH smesh = SMESH_mechanic_tetra.smesh mesh = SMESH_mechanic_tetra.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic_tetra.salome # Criterion : VOLUME < 7. volume_margin = 7. -aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin) +aFilter = smesh.GetFilter(SMESH.VOLUME, SMESH.FT_Volume3D, SMESH.FT_LessThan, volume_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -25,7 +26,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.VOLUME, "Volume < " + `volume_margin`) aGroup.Add(anIds) diff --git a/doc/salome/examples/quality_controls_ex22.py b/doc/salome/examples/quality_controls_ex22.py index 5264b1ade..7cd582366 100644 --- a/doc/salome/examples/quality_controls_ex22.py +++ b/doc/salome/examples/quality_controls_ex22.py @@ -1,6 +1,7 @@ # Element Diameter 3D import SMESH_mechanic_tetra +import SMESH smesh = SMESH_mechanic_tetra.smesh mesh = SMESH_mechanic_tetra.mesh @@ -9,7 +10,7 @@ salome = SMESH_mechanic_tetra.salome # 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.GetFilter(SMESH.FACE, SMESH.FT_MaxElementLength3D, SMESH.FT_MoreThan, mel_3d_margin) anIds = mesh.GetIdsFromFilter(aFilter) @@ -24,7 +25,7 @@ for i in range(len(anIds)): print "" # create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 3D > " + `mel_3d_margin`) +aGroup = mesh.CreateEmptyGroup(SMESH.FACE, "Element Diameter 3D > " + `mel_3d_margin`) aGroup.Add(anIds) salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/transforming_meshes_ex01.py b/doc/salome/examples/transforming_meshes_ex01.py index 0ea75cc85..dc61324ec 100644 --- a/doc/salome/examples/transforming_meshes_ex01.py +++ b/doc/salome/examples/transforming_meshes_ex01.py @@ -1,13 +1,14 @@ # Translation import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # define translation vector -point = smesh.PointStruct(-150., -150., 0.) -vector =smesh.DirStruct(point) +point = SMESH.PointStruct(-150., -150., 0.) +vector =SMESH.DirStruct(point) # translate a mesh doCopy = 1 diff --git a/doc/salome/examples/transforming_meshes_ex02.py b/doc/salome/examples/transforming_meshes_ex02.py index f96a6bb41..5b3ff287e 100644 --- a/doc/salome/examples/transforming_meshes_ex02.py +++ b/doc/salome/examples/transforming_meshes_ex02.py @@ -3,12 +3,13 @@ import math import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # define rotation axis and angle -axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.) +axisXYZ = SMESH.AxisStruct(0., 0., 0., 5., 5., 20.) angle270 = 1.5 * math.pi # rotate a mesh diff --git a/doc/salome/examples/transforming_meshes_ex03.py b/doc/salome/examples/transforming_meshes_ex03.py index da8105a67..a6f7701f8 100644 --- a/doc/salome/examples/transforming_meshes_ex03.py +++ b/doc/salome/examples/transforming_meshes_ex03.py @@ -1,11 +1,18 @@ # Scale -import geompy +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + Box = geompy.MakeBoxDXDYDZ(200, 200, 200) f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) -import smesh,SMESH -import StdMeshers Mesh1 = smesh.Mesh(f[0]) Regular_1D = Mesh1.Segment() Nb_Segments_1 = Regular_1D.NumberOfSegments(3) diff --git a/doc/salome/examples/transforming_meshes_ex04.py b/doc/salome/examples/transforming_meshes_ex04.py index 0bfea6188..910035521 100644 --- a/doc/salome/examples/transforming_meshes_ex04.py +++ b/doc/salome/examples/transforming_meshes_ex04.py @@ -3,11 +3,12 @@ import math import SMESH_mechanic +import SMESH smesh = SMESH_mechanic.smesh mesh = SMESH_mechanic.mesh # create a symmetrical copy of the mesh mirrored through a point -axis = smesh.AxisStruct(0, 0, 0, 0, 0, 0) +axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0) mesh.Mirror([], axis, smesh.POINT, 1) diff --git a/doc/salome/examples/transforming_meshes_ex06.py b/doc/salome/examples/transforming_meshes_ex06.py index fe8c91db3..c9c8353d8 100644 --- a/doc/salome/examples/transforming_meshes_ex06.py +++ b/doc/salome/examples/transforming_meshes_ex06.py @@ -1,8 +1,15 @@ # Merging Elements + import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a face to be meshed px = geompy.MakeVertex(100., 0. , 0. ) @@ -44,7 +51,7 @@ circlemesh.Compute() # extrusion of the mesh trias.ExtrusionAlongPath([], circlemesh, circle, - 1, 0, [], 0, smesh.PointStruct(0, 0, 0)) + 1, 0, [], 0, SMESH.PointStruct(0, 0, 0)) # merge nodes print "Number of nodes before MergeNodes:", diff --git a/doc/salome/examples/transforming_meshes_ex07.py b/doc/salome/examples/transforming_meshes_ex07.py index bb42d33eb..227eb636e 100644 --- a/doc/salome/examples/transforming_meshes_ex07.py +++ b/doc/salome/examples/transforming_meshes_ex07.py @@ -1,7 +1,15 @@ # Sew Meshes Border to Side -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create two faces of a box box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.) diff --git a/doc/salome/examples/transforming_meshes_ex08.py b/doc/salome/examples/transforming_meshes_ex08.py index e028735a0..77042de99 100644 --- a/doc/salome/examples/transforming_meshes_ex08.py +++ b/doc/salome/examples/transforming_meshes_ex08.py @@ -1,7 +1,17 @@ # Sew Conform Free Borders -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create two faces of the box box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.) diff --git a/doc/salome/examples/transforming_meshes_ex09.py b/doc/salome/examples/transforming_meshes_ex09.py index 5f92fd1ad..62fea88d1 100644 --- a/doc/salome/examples/transforming_meshes_ex09.py +++ b/doc/salome/examples/transforming_meshes_ex09.py @@ -1,7 +1,15 @@ # Sew Free Borders -import geompy -import smesh + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create two faces of the box box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) diff --git a/doc/salome/examples/transforming_meshes_ex10.py b/doc/salome/examples/transforming_meshes_ex10.py index c54aca660..426a011a6 100644 --- a/doc/salome/examples/transforming_meshes_ex10.py +++ b/doc/salome/examples/transforming_meshes_ex10.py @@ -1,7 +1,14 @@ # Sew Side Elements -import geompy -import smesh +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create two boxes box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.) diff --git a/doc/salome/examples/transforming_meshes_ex11.py b/doc/salome/examples/transforming_meshes_ex11.py index f94aafeda..0c3bee898 100644 --- a/doc/salome/examples/transforming_meshes_ex11.py +++ b/doc/salome/examples/transforming_meshes_ex11.py @@ -1,8 +1,15 @@ # Duplicate nodes + import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Create a box @@ -20,11 +27,11 @@ mesh.Compute() # Without the duplication of border elements # Nodes to duplicate -nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' ) +nodes1 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes1' ) nodes1.Add( [ 119, 125, 131, 137 ] ) # Group of faces to replace nodes with new ones -faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' ) +faces1 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces1' ) faces1.Add( [ 144, 151, 158 ] ) # Duplicate nodes @@ -44,15 +51,15 @@ print "Quadrangles : ", mesh.NbQuadrangles() # With the duplication of border elements # Edges to duplicate -edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' ) +edges = mesh.CreateEmptyGroup( SMESH.EDGE, 'edges' ) edges.Add( [ 32, 33, 34 ] ) # Nodes not to duplicate -nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' ) +nodes2 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes2' ) nodes2.Add( [ 35, 38 ] ) # Group of faces to replace nodes with new ones -faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' ) +faces2 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces2' ) faces2.Add( [ 141, 148, 155 ] ) # Duplicate nodes diff --git a/doc/salome/examples/transforming_meshes_ex12.py b/doc/salome/examples/transforming_meshes_ex12.py index 0380cc363..e1d850ec6 100644 --- a/doc/salome/examples/transforming_meshes_ex12.py +++ b/doc/salome/examples/transforming_meshes_ex12.py @@ -1,7 +1,17 @@ # Create boundary elements -from smesh import * -SetCurrentStudy(salome.myStudy) + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + box = geompy.MakeBoxDXDYDZ(100, 100, 100) gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) @@ -19,7 +29,7 @@ twoFaces = geompy.MakeCompound([f1,f2]) ## ----------- dim = SMESH.BND_2DFROM3D -init_mesh = Mesh(box, "box") +init_mesh = smesh.Mesh(box, "box") init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons # remove some faces @@ -29,7 +39,7 @@ rm_face = faces[ : nb_faces/2] init_mesh.RemoveElements( rm_face ) # restore boundary in this mesh -mesh = CopyMesh( init_mesh, "2D from 3D") +mesh = smesh.CopyMesh( init_mesh, "2D from 3D") groupName = "bnd 2D" nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) @@ -49,7 +59,7 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam ## ----------- dim = SMESH.BND_1DFROM2D -init_mesh = Mesh(f1, "2D mesh") +init_mesh = smesh.Mesh(f1, "2D mesh") init_mesh.AutomaticHexahedralization() # remove some edges @@ -60,7 +70,7 @@ init_mesh.RemoveElements( rm_edge ) # restore boundary edges in this mesh -mesh = CopyMesh( init_mesh, "1D from 2D") +mesh = smesh.CopyMesh( init_mesh, "1D from 2D") groupName = "bnd 1D" nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) @@ -81,7 +91,7 @@ nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshNam ## ------------------ dim = SMESH.BND_1DFROM3D -init_mesh = Mesh(box, "box") +init_mesh = smesh.Mesh(box, "box") init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons # remove all edges rm_edges = init_mesh.GetElementsByType( SMESH.EDGE ) @@ -92,7 +102,7 @@ fGroup1 = init_mesh.Group( f1, "f1" ) fGroup2 = init_mesh.Group( f2, "f2" ) # make 1D boundary around groups in this mesh -mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True) +mesh = smesh.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/salome/examples/transforming_meshes_ex13.py b/doc/salome/examples/transforming_meshes_ex13.py index 0126b7108..fb56273ba 100644 --- a/doc/salome/examples/transforming_meshes_ex13.py +++ b/doc/salome/examples/transforming_meshes_ex13.py @@ -1,6 +1,17 @@ # Reorient faces by vector -import smesh, geompy, SMESH + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + # create a geometry consisting of two faces box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) diff --git a/doc/salome/examples/use_existing_faces.py b/doc/salome/examples/use_existing_faces.py index 12b5a9a56..631316444 100644 --- a/doc/salome/examples/use_existing_faces.py +++ b/doc/salome/examples/use_existing_faces.py @@ -1,6 +1,17 @@ # Use existing faces algorithm -import smesh, geompy + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) +import salome_notebook + import numpy as np # define my 2D algorithm diff --git a/doc/salome/examples/viewing_meshes_ex01.py b/doc/salome/examples/viewing_meshes_ex01.py index b2fa7df40..85bc69fbc 100644 --- a/doc/salome/examples/viewing_meshes_ex01.py +++ b/doc/salome/examples/viewing_meshes_ex01.py @@ -1,8 +1,15 @@ # Viewing Mesh Infos -import geompy -import smesh -import SMESH + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create a box box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) diff --git a/doc/salome/examples/viewing_meshes_ex02.py b/doc/salome/examples/viewing_meshes_ex02.py index cd096ca76..2ed0a214b 100644 --- a/doc/salome/examples/viewing_meshes_ex02.py +++ b/doc/salome/examples/viewing_meshes_ex02.py @@ -1,8 +1,15 @@ # Find Element by Point -import geompy -import smesh -import SMESH + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Create a geometry to mesh box = geompy.MakeBoxDXDYDZ(100,100,100) diff --git a/doc/salome/gui/SMESH/Makefile.am b/doc/salome/gui/SMESH/Makefile.am index 2b47b8112..dcdcd8975 100755 --- a/doc/salome/gui/SMESH/Makefile.am +++ b/doc/salome/gui/SMESH/Makefile.am @@ -35,16 +35,7 @@ DOC_PYTHONPATH=$(prefix)/bin/salome:$(prefix)/lib/python$(PYTHON_VERSION)/site-p DOC_LD_LIBRARY_PATH=$(prefix)lib/salome:${MED_ROOT_DIR}/lib/salome:${GEOM_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/salome DOC_SMESH_MeshersList=StdMeshers -# to have smesh.py in the documentation instead of smeshDC.py -# we create dummy smesh.py from the smeshDC.py -smesh.py: ../../../../src/SMESH_SWIG/smeshDC.py - @awk '/^class Mesh:/ { mesh_found=1 } // { if (mesh_found) {print $$0; next} } /^ +(def|#)/ { match( $$0, /^ +/); print substr( $$0, 1+RLENGTH ); next } /^class smeshDC/ { next } //' \ - $< > $@ - -tmp/smesh.py: $(top_srcdir)/src/SMESH_SWIG/StdMeshersDC.py $(srcdir)/collect_mesh_methods.py - @mkdir -p tmp && PYTHONPATH=$(DOC_PYTHONPATH):${PYTHONPATH} LD_LIBRARY_PATH=$(DOC_LD_LIBRARY_PATH):${LD_LIBRARY_PATH} SMESH_MeshersList=$(DOC_SMESH_MeshersList) $(PYTHON) $(srcdir)/collect_mesh_methods.py -o $@ StdMeshers - -usr_docs: doxyfile_py doxyfile smesh.py tmp/smesh.py +usr_docs: doxyfile_py doxyfile @$(DOXYGEN) doxyfile_py ; \ $(DOXYGEN) doxyfile diff --git a/doc/salome/gui/SMESH/doxyfile_py.in b/doc/salome/gui/SMESH/doxyfile_py.in index 381ed77b3..e9495d4bf 100755 --- a/doc/salome/gui/SMESH/doxyfile_py.in +++ b/doc/salome/gui/SMESH/doxyfile_py.in @@ -99,10 +99,9 @@ EXAMPLE_RECURSIVE = NO #--------------------------------------------------------------------------- #Input related options #--------------------------------------------------------------------------- -INPUT = smesh.py \ +INPUT = @top_srcdir@/src/SMESH_SWIG/smeshBuilder.py \ @top_srcdir@/src/SMESH_SWIG/smesh_algorithm.py \ - @top_srcdir@/src/SMESH_SWIG/StdMeshersDC.py \ - tmp/smesh.py + @top_srcdir@/src/SMESH_SWIG/StdMeshersBuilder.py FILE_PATTERNS = IMAGE_PATH = @srcdir@/images RECURSIVE = NO diff --git a/doc/salome/gui/SMESH/input/smeshpy_interface.doc b/doc/salome/gui/SMESH/input/smeshpy_interface.doc index 72d4585e1..2542a93e3 100644 --- a/doc/salome/gui/SMESH/input/smeshpy_interface.doc +++ b/doc/salome/gui/SMESH/input/smeshpy_interface.doc @@ -9,17 +9,17 @@ Documentation for SALOME %Mesh module Python API is available in two forms: - Structured documentation, where all methods and classes are grouped by their functionality, like it is done in the GUI documentation - Linear documentation grouped only by classes, declared -in the \ref smesh and StdMeshersDC Python packages. +in the \ref SMESH_SWIG.smeshBuilder "smeshBuilder" and \ref SMESH_SWIG.StdMeshersBuilder "StdMeshersBuilder" Python packages. -Python package \ref smesh provides an interface to create and handle +Class \ref SMESH_SWIG.smeshBuilder.smeshBuilder "smeshBuilder" provides an interface to create and handle meshes. It can be used to create an empty mesh or to import mesh from the data file. As soon as mesh is created, it is possible to manage it via its own -methods, described in \ref smesh.Mesh "class Mesh" documentation. +methods, described in \ref SMESH_SWIG.smeshBuilder.Mesh "class Mesh" documentation. -Class \ref smesh.Mesh "Mesh" allows assigning algorithms to a mesh. +Class \ref SMESH_SWIG.smeshBuilder.Mesh "Mesh" allows assigning algorithms to a mesh. Please note that some algorithms, included in the standard SALOME -distribution are always available. Python package \ref StdMeshersDC +distribution are always available. Python package \ref SMESH_SWIG.StdMeshersBuilder "StdMeshersBuilder" provides an interface for standard meshing algorithms included into the SALOME %Mesh module distribution, like: - REGULAR (1D) diff --git a/doc/salome/gui/SMESH/input/tui_filters.doc b/doc/salome/gui/SMESH/input/tui_filters.doc index eaf5d2803..9f8bff80d 100755 --- a/doc/salome/gui/SMESH/input/tui_filters.doc +++ b/doc/salome/gui/SMESH/input/tui_filters.doc @@ -23,8 +23,8 @@ Python scripts. \section filter_aspect_ratio Aspect ratio Filter 2D mesh elements (faces) according to the aspect ratio value: -- element type should be \a smesh.FACE -- functor type should be \a smesh.FT_AspectRatio +- element type should be \a SMESH.FACE +- functor type should be \a SMESH.FT_AspectRatio - threshold is floating point value (aspect ratio) \tui_script{filters_ex01.py} @@ -34,8 +34,8 @@ Filter 2D mesh elements (faces) according to the aspect ratio value: \section filter_aspect_ratio_3d Aspect ratio 3D Filter 3D mesh elements (volumes) according to the aspect ratio value: -- element type is \a smesh.VOLUME -- functor type is \a smesh.FT_AspectRatio3D +- element type is \a SMESH.VOLUME +- functor type is \a SMESH.FT_AspectRatio3D - threshold is floating point value (aspect ratio) \tui_script{filters_ex02.py} @@ -45,8 +45,8 @@ Filter 3D mesh elements (volumes) according to the aspect ratio value: \section filter_warping_angle Warping angle Filter 2D mesh elements (faces) according to the warping angle value: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_Warping +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_Warping - threshold is floating point value (warping angle) \tui_script{filters_ex03.py} @@ -56,8 +56,8 @@ Filter 2D mesh elements (faces) according to the warping angle value: \section filter_minimum_angle Minimum angle Filter 2D mesh elements (faces) according to the minimum angle value: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_MinimumAngle +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_MinimumAngle - threshold is floating point value (minimum angle) \tui_script{filters_ex04.py} @@ -67,8 +67,8 @@ Filter 2D mesh elements (faces) according to the minimum angle value: \section filter_taper Taper Filter 2D mesh elements (faces) according to the taper value: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_Taper +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_Taper - threshold is floating point value (taper) \tui_script{filters_ex05.py} @@ -78,8 +78,8 @@ Filter 2D mesh elements (faces) according to the taper value: \section filter_skew Skew Filter 2D mesh elements (faces) according to the skew value: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_Skew +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_Skew - threshold is floating point value (skew) \tui_script{filters_ex06.py} @@ -89,8 +89,8 @@ Filter 2D mesh elements (faces) according to the skew value: \section filter_area Area Filter 2D mesh elements (faces) according to the area value: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_Area +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_Area - threshold is floating point value (area) \tui_script{filters_ex07.py} @@ -100,8 +100,8 @@ Filter 2D mesh elements (faces) according to the area value: \section filter_volume Volume Filter 3D mesh elements (volumes) according to the volume value: -- element type is \a smesh.VOLUME -- functor type is \a smesh.FT_Volume3D +- element type is \a SMESH.VOLUME +- functor type is \a SMESH.FT_Volume3D - threshold is floating point value (volume) \tui_script{filters_ex08.py} @@ -111,8 +111,8 @@ Filter 3D mesh elements (volumes) according to the volume value: \section filter_free_borders Free borders Filter 1D mesh elements (edges) which represent free borders of a mesh: -- element type is \a smesh.EDGE -- functor type is \a smesh.FT_FreeBorders +- element type is \a SMESH.EDGE +- functor type is \a SMESH.FT_FreeBorders - threshold value is not required \tui_script{filters_ex09.py} @@ -123,8 +123,8 @@ Filter 1D mesh elements (edges) which represent free borders of a mesh: Filter 2D mesh elements (faces) consisting of edges belonging to one element of mesh only: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_FreeEdges +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_FreeEdges - threshold value is not required \tui_script{filters_ex10.py} @@ -134,8 +134,8 @@ element of mesh only: \section filter_free_nodes Free nodes Filter free nodes: -- element type is \a smesh.NODE -- functor type is \a smesh.FT_FreeNodes +- element type is \a SMESH.NODE +- functor type is \a SMESH.FT_FreeNodes - threshold value is not required \tui_script{filters_ex11.py} @@ -145,8 +145,8 @@ Filter free nodes: \section filter_free_faces Free faces Filter free faces: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_FreeFaces +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_FreeFaces - threshold value is not required \tui_script{filters_ex12.py} @@ -156,8 +156,8 @@ Filter free faces: \section filter_bare_border_faces Bare border faces Filter faces with bare borders: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_BareBorderFace +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_BareBorderFace - threshold value is not required \tui_script{filters_ex13.py} @@ -167,8 +167,8 @@ Filter faces with bare borders: \section filter_coplanar_faces Coplanar faces Filter faces with bare borders: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_CoplanarFaces +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_CoplanarFaces - threshold value is the face ID - tolerance is in degrees @@ -177,8 +177,8 @@ Filter faces with bare borders: \section filter_over_constrained_faces Over-constrained faces Filter over-constrained faces: -- element type is \a smesh.FACE -- functor type is \a smesh.FT_OverConstrainedFace +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_OverConstrainedFace - threshold value is not required \tui_script{filters_ex15.py} @@ -188,9 +188,9 @@ Filter over-constrained faces: \section filter_double_elements Double edges, Double faces, Double volumes filter mesh elements basing on the same set of nodes: -- element type is either \a smesh.EGDE, \a smesh.FACE or \a smesh.VOLUME -- functor type is either \a smesh.FT_EqualEdges, \a - smesh.FT_EqualFaces or \a smesh.FT_EqualVolumes, +- element type is either \a smesh.EGDE, \a SMESH.FACE or \a SMESH.VOLUME +- functor type is either \a SMESH.FT_EqualEdges, \a + SMESH.FT_EqualFaces or \a SMESH.FT_EqualVolumes, - threshold value is not required \tui_script{filters_ex16.py} @@ -199,8 +199,8 @@ filter mesh elements basing on the same set of nodes: \section tui_double_nodes_control Double nodes filters mesh nodes which are coincident with other nodes (within a given tolerance): -- element type is \a smesh.NODE -- functor type is \a smesh.FT_EqualNodes +- element type is \a SMESH.NODE +- functor type is \a SMESH.FT_EqualNodes - threshold value is not required - default tolerance is 1.0e-7 @@ -211,8 +211,8 @@ filters mesh nodes which are coincident with other nodes (within a given toleran Filter border 1D mesh elements (edges) according to the specified number of connections (faces belonging the border edges) -- element type is \a smesh.EDGE -- functor type is \a smesh.FT_MultiConnection +- element type is \a SMESH.EDGE +- functor type is \a SMESH.FT_MultiConnection - threshold is integer value (number of connections) \tui_script{filters_ex18.py} @@ -223,8 +223,8 @@ connections (faces belonging the border edges) Filter 2D mesh elements (faces) which consist of edges belonging to the specified number of mesh elements -- element type is \a smesh.FACE -- functor type is \a smesh.FT_MultiConnection2D +- element type is \a SMESH.FACE +- functor type is \a SMESH.FT_MultiConnection2D - threshold is integer value (number of connections) \tui_script{filters_ex19.py} @@ -234,8 +234,8 @@ to the specified number of mesh elements \section filter_length Length Filter 1D mesh elements (edges) according to the edge length value: -- element type should be \a smesh.EDGE -- functor type should be \a smesh.FT_Length +- element type should be \a SMESH.EDGE +- functor type should be \a SMESH.FT_Length - threshold is floating point value (length) \tui_script{filters_ex20.py} @@ -246,8 +246,8 @@ Filter 1D mesh elements (edges) according to the edge length value: Filter 2D mesh elements (faces) corresponding to the maximum length. value of its edges: -- element type should be \a smesh.FACE -- functor type should be \a smesh.FT_Length2D +- element type should be \a SMESH.FACE +- functor type should be \a SMESH.FT_Length2D - threshold is floating point value (edge length) \tui_script{filters_ex21.py} @@ -258,8 +258,8 @@ value of its edges: Filter 2D mesh elements (faces) corresponding to the maximum length value of its edges and diagonals: -- element type should be \a smesh.FACE -- functor type should be \a smesh.FT_MaxElementLength2D +- element type should be \a SMESH.FACE +- functor type should be \a SMESH.FT_MaxElementLength2D - threshold is floating point value (edge/diagonal length) \tui_script{filters_ex22.py} @@ -270,8 +270,8 @@ value of its edges and diagonals: Filter 3D mesh elements (volumes) corresponding to the maximum length value of its edges and diagonals: -- element type should be \a smesh.VOLUME -- functor type should be \a smesh.FT_MaxElementLength3D +- element type should be \a SMESH.VOLUME +- functor type should be \a SMESH.FT_MaxElementLength3D - threshold is floating point value (edge/diagonal length) \tui_script{filters_ex23.py} @@ -281,8 +281,8 @@ value of its edges and diagonals: \section filter_bare_border_volumes Bare border volumes Filter 3D mesh elements with bare borders: -- element type is \a smesh.VOLUME -- functor type is \a smesh.FT_BareBorderVolume +- element type is \a SMESH.VOLUME +- functor type is \a SMESH.FT_BareBorderVolume - threshold value is not required \tui_script{filters_ex24.py} @@ -292,8 +292,8 @@ Filter 3D mesh elements with bare borders: \section filter_over_constrained_volumes Over-constrained volumes Filter over-constrained volumes: -- element type is \a smesh.VOLUME -- functor type is \a smesh.FT_OverConstrainedVolume +- element type is \a SMESH.VOLUME +- functor type is \a SMESH.FT_OverConstrainedVolume - threshold value is not required \tui_script{filters_ex25.py} @@ -304,8 +304,8 @@ Filter over-constrained volumes: Filter mesh entities (nodes or elements) which all nodes lie on the shape defined by threshold value: -- element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME -- functor type should be \a smesh.FT_BelongToGeom +- element type can be any entity type, from \a SMESH.NODE to \a SMESH.VOLUME +- functor type should be \a SMESH.FT_BelongToGeom - threshold is geometrical object \tui_script{filters_ex26.py} @@ -314,8 +314,8 @@ shape defined by threshold value: Filter mesh entities (nodes or elements) at least one node of which lies on the shape defined by threshold value: -- element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME -- functor type should be \a smesh.FT_LyingOnGeom +- element type can be any entity type, from \a SMESH.NODE to \a SMESH.VOLUME +- functor type should be \a SMESH.FT_LyingOnGeom - threshold is geometrical object \tui_script{filters_ex27.py} @@ -324,8 +324,8 @@ shape defined by threshold value: Filter mesh entities (nodes or elements) which all nodes belong to the plane defined by threshold value with the given tolerance: -- element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE -- functor type should be \a smesh.FT_BelongToPlane +- element type can be: \a SMESH.NODE, \a SMESH.EDGE, \a SMESH.FACE +- functor type should be \a SMESH.FT_BelongToPlane - threshold is geometrical object (plane) - default tolerance is 1.0e-7 @@ -335,8 +335,8 @@ plane defined by threshold value with the given tolerance: Filter mesh entities (nodes or elements) which all nodes belong to the cylindrical face defined by threshold value with the given tolerance: -- element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE -- functor type should be \a smesh.FT_BelongToCylinder +- element type can be: \a , \a SMESH.EDGE, \a SMESH.FACE +- functor type should be \a SMESH.FT_BelongToCylinder - threshold is geometrical object (cylindrical face) - default tolerance is 1.0e-7 @@ -346,8 +346,8 @@ cylindrical face defined by threshold value with the given tolerance: Filter mesh entities (nodes or elements) which all nodes belong to the arbitrary surface defined by threshold value with the given tolerance: -- element type can be: \a smesh.NODE, \a smesh.EDGE, \a smesh.FACE -- functor type should be \a smesh.FT_BelongToGenSurface +- element type can be: \a SMESH.NODE, \a SMESH.EDGE, \a SMESH.FACE +- functor type should be \a SMESH.FT_BelongToGenSurface - threshold is geometrical object (arbitrary surface) - default tolerance is 1.0e-7 @@ -357,8 +357,8 @@ arbitrary surface defined by threshold value with the given tolerance: Filter mesh entities elements (nodes or elements) according to the specified identifiers range: -- element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME -- functor type is \a smesh.FT_RangeOfIds +- element type can be any entity type, from \a SMESH.NODE to \a SMESH.VOLUME +- functor type is \a SMESH.FT_RangeOfIds - threshold is string listing required IDs and/or ranges of IDs, e.g."1,2,3,50-60,63,67,70-78" \tui_script{filters_ex31.py} @@ -367,8 +367,8 @@ specified identifiers range: Filter 3D mesh elements (volumes), which are incorrectly oriented from the point of view of MED convention. -- element type should be \a smesh.VOLUME -- functor type is \a smesh.FT_BadOrientedVolume +- element type should be \a SMESH.VOLUME +- functor type is \a SMESH.FT_BadOrientedVolume - threshold is not required \tui_script{filters_ex32.py} @@ -376,10 +376,10 @@ the point of view of MED convention. \section filter_linear_or_quadratic Linear / quadratic Filter linear / quadratic mesh elements: -- element type should be any element type, e.g.: \a smesh.EDGE, \a smesh.FACE, \a smesh.VOLUME -- functor type is \a smesh.FT_LinearOrQuadratic +- element type should be any element type, e.g.: \a SMESH.EDGE, \a SMESH.FACE, \a SMESH.VOLUME +- functor type is \a SMESH.FT_LinearOrQuadratic - threshold is not required -- if unary operator is set to smesh.FT_LogicalNOT, the quadratic +- if unary operator is set to SMESH.FT_LogicalNOT, the quadratic elements are selected, otherwise (by default) linear elements are selected \tui_script{filters_ex33.py} @@ -387,8 +387,8 @@ elements are selected, otherwise (by default) linear elements are selected \section filter_group_color Group color Filter mesh entities, belonging to the group with the color defined by the threshold value. -- element type can be any entity type, from \a smesh.NODE to \a smesh.VOLUME -- functor type is \a smesh.FT_GroupColor +- element type can be any entity type, from \a SMESH.NODE to \a SMESH.VOLUME +- functor type is \a SMESH.FT_GroupColor - threshold should be of SALOMEDS.Color type \tui_script{filters_ex34.py} @@ -398,8 +398,8 @@ Filter mesh entities, belonging to the group with the color defined by the thres Filter mesh elements by the geometric type defined with the threshold value. The list of available geometric types depends on the element entity type. -- element type should be any element type, e.g.: \a smesh.EDGE, \a smesh.FACE, \a smesh.VOLUME -- functor type should be \a smesh.FT_ElemGeomType +- element type should be any element type, e.g.: \a SMESH.EDGE, \a SMESH.FACE, \a SMESH.VOLUME +- functor type should be \a SMESH.FT_ElemGeomType - threshold is of smesh.GeometryType value \tui_script{filters_ex35.py} diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index af3dd63aa..81c8ba228 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -227,7 +227,7 @@ output ="EDGE" dim ="1"> - CompositeSegment_1D=Segment(algo=smesh.COMPOSITE) + CompositeSegment_1D=Segment(algo=smeshBuilder.COMPOSITE) LocalLength=LocalLength(SetLength(), ,SetPrecision()) MaxLength=MaxSize(SetLength()) Arithmetic1D=Arithmetic1D(SetStartLength(),SetEndLength(),SetReversedEdges()) @@ -244,7 +244,7 @@ output="EDGE" dim="1"> - Python_1D=Segment(algo=smesh.PYTHON) + Python_1D=Segment(algo=smeshBuilder.PYTHON) PythonSplit1D=PythonSplit1D(SetNumberOfSegments(),SetPythonLog10RatioFunction()) @@ -258,7 +258,7 @@ output ="TRIA" dim ="2"> - MEFISTO_2D=Triangle(algo=smesh.MEFISTO) + MEFISTO_2D=Triangle(algo=smeshBuilder.MEFISTO) LengthFromEdges=LengthFromEdges() MaxElementArea=MaxElementArea(SetMaxElementArea()) ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreEdges()) @@ -274,7 +274,7 @@ output ="QUAD" dim ="2"> - Quadrangle_2D=Quadrangle(algo=smesh.QUADRANGLE) + Quadrangle_2D=Quadrangle(algo=smeshBuilder.QUADRANGLE) QuadrangleParams=QuadrangleParameters(SetQuadType(),SetTriaVertex()) ViscousLayers2D=ViscousLayers2D(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreEdges()) @@ -288,7 +288,7 @@ opt-hypos="ViscousLayers" dim ="3"> - Hexa_3D=Hexahedron(algo=smesh.Hexa) + Hexa_3D=Hexahedron(algo=smeshBuilder.Hexa) ViscousLayers=ViscousLayers(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreFaces()) @@ -419,7 +419,7 @@ output ="QUAD,TRIA" dim ="2"> - RadialQuadrangle_1D2D=Quadrangle(algo=smesh.RADIAL_QUAD) + RadialQuadrangle_1D2D=Quadrangle(algo=smeshBuilder.RADIAL_QUAD) NumberOfLayers2D=NumberOfLayers(SetNumberOfLayers()) diff --git a/src/OBJECT/SMESH_Object.h b/src/OBJECT/SMESH_Object.h index 84d42dd25..dbafd97bc 100644 --- a/src/OBJECT/SMESH_Object.h +++ b/src/OBJECT/SMESH_Object.h @@ -24,7 +24,6 @@ // File : SMESH_Object.h // Author : Nicolas REJNERI // Module : SMESH -// $Header$ // #ifndef SMESH_OBJECT_H #define SMESH_OBJECT_H diff --git a/src/OBJECT/SMESH_ObjectDef.h b/src/OBJECT/SMESH_ObjectDef.h index 5f3733447..116ee532d 100644 --- a/src/OBJECT/SMESH_ObjectDef.h +++ b/src/OBJECT/SMESH_ObjectDef.h @@ -24,7 +24,6 @@ // File : SMESH_Object.h // Author : Nicolas REJNERI // Module : SMESH -// $Header$ // #ifndef SMESH_OBJECTDEF_H #define SMESH_OBJECTDEF_H diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index b8f6840b7..9994f8f8a 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -345,7 +345,7 @@ namespace { //================================================================================ /*! - * \brief Convert a python script using commands of smesh.py + * \brief Convert a python script using commands of smeshBuilder.py * \param theScript - Input script * \param theEntry2AccessorMethod - returns method names to access to * objects wrapped with python class @@ -498,7 +498,7 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod //================================================================================ /*! - * \brief name of SMESH_Gen in smesh.py + * \brief name of SMESH_Gen in smeshBuilder.py */ //================================================================================ @@ -916,7 +916,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) // Replace name of SMESH_Gen - // names of SMESH_Gen methods fully equal to methods defined in smesh.py + // names of SMESH_Gen methods fully equal to methods defined in smeshBuilder.py static TStringSet smeshpyMethods; if ( smeshpyMethods.empty() ) { const char * names[] = diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index 19a4648a1..f2df48dc5 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -47,8 +47,8 @@ * This file was created in order to respond to requirement of bug PAL10494: * SMESH python dump uses idl interface. * - * The creation reason is that smesh.py commands defining hypotheses encapsulate - * several SMESH engine method calls. As well, the dependencies between smesh.py + * The creation reason is that smeshBuilder.py commands defining hypotheses encapsulate + * several SMESH engine method calls. As well, the dependencies between smeshBuilder.py * classes differ from ones between corresponding SMESH IDL interfaces. * * Everything here is for internal usage by SMESH_2smeshpy::ConvertScript() diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 15770dcc8..8736356ac 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -869,9 +869,9 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aScript += helper + "aFilterManager = " + aSMESHGen + ".CreateFilterManager()\n\t"; aScript += helper + "aMeasurements = " + aSMESHGen + ".CreateMeasurements()\n\t"; if ( isPublished ) - aScript += aSMESHGen + ".SetCurrentStudy(theStudy)"; + aScript += aSMESHGen + " = smeshBuilder.New(theStudy)"; else - aScript += aSMESHGen + ".SetCurrentStudy(None)"; + aScript += aSMESHGen + " = smeshBuilder.New(None)"; // import python files corresponding to plugins set moduleNameSet; @@ -880,14 +880,14 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl string moduleName = hyp_creator->second->GetModuleName(); bool newModule = moduleNameSet.insert( moduleName ).second; if ( newModule ) - aScript += helper + "\n\t" + "import " + (char*) moduleName.c_str(); + aScript += helper + "\n\t" + "from salome." + (char*) moduleName.c_str() + " import " + (char*) moduleName.c_str() +"Builder"; } // Dump trace of restored study if (theSavedTrace.Length() > 0) { - // For the convertion of IDL API calls -> smesh.py API, "smesh" standing for SMESH_Gen + // For the convertion of IDL API calls -> smeshBuilder.py API, "smesh" standing for SMESH_Gen // was replaces with "smeshgen" (==TPythonDump::SMESHGenName()). - // Change "smesh" -> "smeshgen" in the trace saved before passage to smesh.py API + // Change "smesh" -> "smeshgen" in the trace saved before passage to smeshBuilder.py API bool isNewVersion = theSavedTrace.Location( anOldGen + ".", 1, theSavedTrace.Length() ); if ( !isNewVersion ) { @@ -915,7 +915,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl aScript += helper + "\n" + aNewLines; } - // Convert IDL API calls into smesh.py API. + // Convert IDL API calls into smeshBuilder.py API. // Some objects are wrapped with python classes and // Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod; @@ -1003,7 +1003,8 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl TCollection_AsciiString initPart = "import "; if ( isMultiFile ) initPart += helper + "salome, "; - initPart += aSmeshpy + ", SMESH, SALOMEDS\n"; + initPart += " SMESH, SALOMEDS\n"; + initPart += "from salome.smesh import smeshBuilder\n"; if ( importGeom && isMultiFile ) { initPart += ("\n## import GEOM dump file ## \n" @@ -1026,7 +1027,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl if ( aRemovedObjIDs.count( seqRemoved.Value(ir) )) continue; anUpdatedScript += "\n\tSO = theStudy.FindObjectIOR(theStudy.ConvertObjectToIOR("; anUpdatedScript += seqRemoved.Value(ir); - // for object wrapped by class of smesh.py + // for object wrapped by class of smeshBuilder.py anEntry = theObjectNames( seqRemoved.Value(ir) ); if ( anEntry2AccessorMethod.IsBound( anEntry ) ) anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry ); diff --git a/src/SMESH_I/SMESH_PythonDump.hxx b/src/SMESH_I/SMESH_PythonDump.hxx index d1ba4f4ce..598ad9fb3 100644 --- a/src/SMESH_I/SMESH_PythonDump.hxx +++ b/src/SMESH_I/SMESH_PythonDump.hxx @@ -50,7 +50,7 @@ class SMESH_2smeshpy { public: /*! - * \brief Convert a python script using commands of smesh.py + * \brief Convert a python script using commands of smeshBuilder.py * \param theScript - Input script * \param theEntry2AccessorMethod - returns method names to access to * objects wrapped with python class diff --git a/src/SMESH_SWIG/Makefile.am b/src/SMESH_SWIG/Makefile.am index af94b1895..b42bc694e 100644 --- a/src/SMESH_SWIG/Makefile.am +++ b/src/SMESH_SWIG/Makefile.am @@ -28,9 +28,6 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am # Scripts to be installed. dist_salomescript_PYTHON = \ smesh.py \ - smeshDC.py \ - smesh_algorithm.py \ - StdMeshersDC.py \ batchmode_smesh.py \ batchmode_mefisto.py \ ex00_all.py \ @@ -99,5 +96,15 @@ dist_salomescript_PYTHON = \ PAL_MESH_043_3D.py \ SMESH_reg.py +mypkgpythondir = $(salomepythondir)/salome/smesh +mypkgpython_PYTHON = \ + smeshBuilder.py \ + smesh_algorithm.py + +stdpkgpythondir = $(salomepythondir)/salome/StdMeshers +stdpkgpython_PYTHON = \ + __init__.py \ + StdMeshersBuilder.py + sharedpkgpython_PYTHON = \ SMESH_shared_modules.py diff --git a/src/SMESH_SWIG/PAL_MESH_041_mesh.py b/src/SMESH_SWIG/PAL_MESH_041_mesh.py index fe38452f0..12c5b8837 100755 --- a/src/SMESH_SWIG/PAL_MESH_041_mesh.py +++ b/src/SMESH_SWIG/PAL_MESH_041_mesh.py @@ -22,8 +22,14 @@ # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) #-----------------------------GEOM---------------------------------------- @@ -55,7 +61,6 @@ Id_face1 = geompy.addToStudy(face1,"Face1") #-----------------------------SMESH------------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) # -- Init mesh -- plane_mesh = salome.IDToObject( Id_face1) diff --git a/src/SMESH_SWIG/PAL_MESH_043_2D.py b/src/SMESH_SWIG/PAL_MESH_043_2D.py index 15eb20e40..a51bf5b00 100755 --- a/src/SMESH_SWIG/PAL_MESH_043_2D.py +++ b/src/SMESH_SWIG/PAL_MESH_043_2D.py @@ -26,8 +26,14 @@ # Description : Create meshes to test extrusion of mesh elements along path # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) #----------------------------------GEOM @@ -53,7 +59,6 @@ id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2") #---------------------------------SMESH -smesh.SetCurrentStudy(salome.myStudy) # create the path mesh mesh1 = smesh.Mesh(ellipse1, "Path Mesh") diff --git a/src/SMESH_SWIG/PAL_MESH_043_3D.py b/src/SMESH_SWIG/PAL_MESH_043_3D.py index bcee8d84a..b547265bc 100755 --- a/src/SMESH_SWIG/PAL_MESH_043_3D.py +++ b/src/SMESH_SWIG/PAL_MESH_043_3D.py @@ -26,8 +26,14 @@ # Description : Create meshes to test extrusion of mesh elements along path # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # create points to build two circles @@ -51,8 +57,6 @@ idcircle = geompy.addToStudy(circle, "Circle") idface = geompy.addToStudy(face, "Circular face") -smesh.SetCurrentStudy(salome.myStudy) - # init a Mesh with the circular face mesh1 = smesh.Mesh(face, "Mesh on circular face") diff --git a/src/SMESH_SWIG/SMESH_AdvancedEditor.py b/src/SMESH_SWIG/SMESH_AdvancedEditor.py index 1ebeaa981..49062d342 100644 --- a/src/SMESH_SWIG/SMESH_AdvancedEditor.py +++ b/src/SMESH_SWIG/SMESH_AdvancedEditor.py @@ -22,10 +22,16 @@ # import salome -import smesh -import math - salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +import math def GetNewNodes(mesh,Elems,OldNodes): """ @@ -55,7 +61,6 @@ def GetNewNodes(mesh,Elems,OldNodes): pass return newnodes -smesh.SetCurrentStudy(salome.myStudy) # create empty mesh mesh = smesh.Mesh() @@ -67,13 +72,13 @@ tol = 0.001 n1 = mesh.AddNode(55,-5,0) n2 = mesh.AddNode(55,5,0) e1 = mesh.AddEdge([n1,n2]) -dir1 = smesh.DirStruct(smesh.PointStruct(-10,0,0)) +dir1 = SMESH.DirStruct(SMESH.PointStruct(-10,0,0)) mesh.ExtrusionSweep([e1],dir1,11) # 2. create second edge and make extrusion along 0y n3 = mesh.AddNode(-5,-55,0) n4 = mesh.AddNode(5,-55,0) e2 = mesh.AddEdge([n3,n4]) -dir2 = smesh.DirStruct(smesh.PointStruct(0,10,0)) +dir2 = SMESH.DirStruct(SMESH.PointStruct(0,10,0)) mesh.ExtrusionSweep([e2],dir2,11) # since result has coincident nodes and faces @@ -83,12 +88,12 @@ mesh.MergeNodes(nodes) mesh.MergeEqualElements() # make extrusion faces along 0z -faces = mesh.GetElementsByType(smesh.FACE) +faces = mesh.GetElementsByType(SMESH.FACE) nbf = len(faces) maxang = 2.0 zstep = 5 nbzsteps = 50 -dir3 = smesh.DirStruct(smesh.PointStruct(0,0,zstep)) +dir3 = SMESH.DirStruct(SMESH.PointStruct(0,0,zstep)) newfaces = [] # list for keeping created top faces # during extrusion @@ -121,7 +126,7 @@ for i in range(0,nbzsteps): pass # rotate faces from newfaces -axisr1 = smesh.AxisStruct(0,0,0,0,0,1) +axisr1 = SMESH.AxisStruct(0,0,0,0,0,1) for i in range(0,nbzsteps): ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps)) mesh.Rotate(newfaces[i],axisr1,ang,0) @@ -135,7 +140,7 @@ n6 = mesh.AddNode(67.5,0,0) n7 = mesh.AddNode(70,0,0) e56 = mesh.AddEdge([n5,n6]) e67 = mesh.AddEdge([n6,n7]) -axisr2 = smesh.AxisStruct(65,0,0,0,1,0) +axisr2 = SMESH.AxisStruct(65,0,0,0,1,0) mesh.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol) res = mesh.GetLastCreatedElems() faces1 = [] @@ -152,7 +157,7 @@ n9 = mesh.AddNode(-67.5,0,0) n10 = mesh.AddNode(-70,0,0) e8 = mesh.AddEdge([n8,n9]) e9 = mesh.AddEdge([n9,n10]) -axisr3 = smesh.AxisStruct(-65,0,0,0,-1,0) +axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0) mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol) res = mesh.GetLastCreatedElems() faces2 = [] @@ -212,4 +217,4 @@ for i in range(0,nbrs): oldnodes = newnodes pass -smesh.salome.sg.updateObjBrowser(1) +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_BelongToGeom.py b/src/SMESH_SWIG/SMESH_BelongToGeom.py index c87d78acf..4efbc01b4 100644 --- a/src/SMESH_SWIG/SMESH_BelongToGeom.py +++ b/src/SMESH_SWIG/SMESH_BelongToGeom.py @@ -25,7 +25,6 @@ from SMESH_test1 import * ## Old style def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType): - import geompy if theShape != theSubShape: aName = str(theSubShape) geompy.addToStudyInFather(theShape,theSubShape,aName) @@ -45,25 +44,23 @@ def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theEl ## Current style def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType): - import geompy - import smesh if theShape != theSubShape: aName = str(theSubShape) geompy.addToStudyInFather(theShape,theSubShape,aName) theMesh.Compute() - aFilter = smesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape) + aFilter = smesh.GetFilter(theElemType, SMESH.FT_BelongToGeom, theSubShape) return aFilter.GetElementsId(theMesh.GetMesh()) -anElemType = smesh.FACE; +anElemType = SMESH.FACE; print "anElemType =", anElemType #anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType) anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType) print "Number of ids = ", len(anIds) print "anIds = ", anIds ## Check old version -#anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType) +#anIds = CheckBelongToGeomFilterOld(smesh,mesh.GetMesh(),box,box,anElemType) #print "anIds = ", anIds salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_BuildCompound.py b/src/SMESH_SWIG/SMESH_BuildCompound.py index 7f205fecb..599b09dd0 100644 --- a/src/SMESH_SWIG/SMESH_BuildCompound.py +++ b/src/SMESH_SWIG/SMESH_BuildCompound.py @@ -28,8 +28,14 @@ # ! documentation generation to identify certain places of this file # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) ## create a bottom box Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.) @@ -60,7 +66,6 @@ geompy.addToStudy(Box_sup, "Box_sup") geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup") geompy.addToStudyInFather(Box_sup, Finf2, "Finf") -smesh.SetCurrentStudy(salome.myStudy) ## create a bottom mesh Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf") @@ -91,10 +96,10 @@ Ginf2=Mesh_sup.Group(Finf2, "Inf") ## create compounds # create a compound of two meshes with renaming groups with the same names and # merging of elements with the given tolerance -Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) +Compound1 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05) smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems') # create a compound of two meshes with uniting groups with the same names and # creating groups of all elements -Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) +Compound2 = smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True) smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems') #end diff --git a/src/SMESH_SWIG/SMESH_GroupFromGeom.py b/src/SMESH_SWIG/SMESH_GroupFromGeom.py index a062fba6e..2631388ec 100644 --- a/src/SMESH_SWIG/SMESH_GroupFromGeom.py +++ b/src/SMESH_SWIG/SMESH_GroupFromGeom.py @@ -44,7 +44,7 @@ geompy.AddObject(aGeomGroup2, 10) geompy.addToStudy(aGeomGroup1, "Group on Faces") geompy.addToStudy(aGeomGroup2, "Group on Edges") -aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE) -aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE) +aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) +aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_GroupFromGeom2.py b/src/SMESH_SWIG/SMESH_GroupFromGeom2.py index 1f6274da4..9b13c6f61 100755 --- a/src/SMESH_SWIG/SMESH_GroupFromGeom2.py +++ b/src/SMESH_SWIG/SMESH_GroupFromGeom2.py @@ -50,11 +50,11 @@ geompy.AddObject(aGeomGroup2, 10) geompy.addToStudy(aGeomGroup1, "Group on Faces") geompy.addToStudy(aGeomGroup2, "Group on Edges") -aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE) -aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE) +aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", SMESH.FACE) +aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", SMESH.EDGE) print "Create aGroupOnShell - a group linked to a shell" -aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", smesh.EDGE) +aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", SMESH.EDGE) print "aGroupOnShell type =", aGroupOnShell.GetType() print "aGroupOnShell size =", aGroupOnShell.Size() print "aGroupOnShell ids :", aGroupOnShell.GetListOfID() diff --git a/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py b/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py index 0d2ddeadc..3c55446cb 100644 --- a/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py +++ b/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py @@ -21,13 +21,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import salome -import smesh - -smesh.SetCurrentStudy(salome.myStudy) - def BuildGroupLyingOn(theMesh, theElemType, theName, theShape): - aFilterMgr = smesh.smesh.CreateFilterManager() + aFilterMgr = smesh.CreateFilterManager() aFilter = aFilterMgr.CreateFilter() aLyingOnGeom = aFilterMgr.CreateLyingOnGeom() @@ -47,9 +42,9 @@ from SMESH_test1 import * mesh.Compute() # First way -BuildGroupLyingOn(mesh.GetMesh(), smesh.FACE, "Group of faces lying on edge #1", edge ) +BuildGroupLyingOn(mesh.GetMesh(), SMESH.FACE, "Group of faces lying on edge #1", edge ) # Second way -mesh.MakeGroup("Group of faces lying on edge #2", smesh.FACE, smesh.FT_LyingOnGeom, edge) +mesh.MakeGroup("Group of faces lying on edge #2", SMESH.FACE, SMESH.FT_LyingOnGeom, edge) salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_Nut.py b/src/SMESH_SWIG/SMESH_Nut.py index a4730817e..fdbeb489c 100755 --- a/src/SMESH_SWIG/SMESH_Nut.py +++ b/src/SMESH_SWIG/SMESH_Nut.py @@ -26,9 +26,16 @@ #Auhtor :MASLOV Eugeny, KOVALTCHUK Alexey ##################################################################### # -import geompy import salome -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + import os import math @@ -98,8 +105,6 @@ Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1") #Mesh creation -smesh.SetCurrentStudy(salome.myStudy) - # -- Init -- shape_mesh = salome.IDToObject( Cut_1_ID ) @@ -117,7 +122,7 @@ smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength)) print "-------------------------- MaxElementArea" theMaxElementArea = 20 -algoMef = mesh.Triangle(smesh.MEFISTO) +algoMef = mesh.Triangle(smeshBuilder.MEFISTO) hArea = algoMef.MaxElementArea( theMaxElementArea ) print hArea.GetName() print hArea.GetId() @@ -126,7 +131,7 @@ smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea)) print "-------------------------- MaxElementVolume" theMaxElementVolume = 150 -algoNg = mesh.Tetrahedron(smesh.NETGEN) +algoNg = mesh.Tetrahedron(smeshBuilder.NETGEN) hVolume = algoNg.MaxElementVolume( theMaxElementVolume ) print hVolume.GetName() print hVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_Partition1_tetra.py b/src/SMESH_SWIG/SMESH_Partition1_tetra.py index ef53fd353..5a85f26ff 100644 --- a/src/SMESH_SWIG/SMESH_Partition1_tetra.py +++ b/src/SMESH_SWIG/SMESH_Partition1_tetra.py @@ -26,8 +26,15 @@ # -- Rayon de la bariere # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + from math import sqrt @@ -119,8 +126,6 @@ print "number of Edges in alveole : ", len(subEdgeList) status = geompy.CheckShape(alveole) print " check status ", status -# ---- launch SMESH -smesh.SetCurrentStudy(salome.myStudy) # ---- init a Mesh with the alveole shape_mesh = salome.IDToObject( idalveole ) @@ -155,7 +160,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 0.5 -netgen3D = mesh.Tetrahedron(smesh.NETGEN) +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) hypVolume = netgen3D.MaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_Sphere.py b/src/SMESH_SWIG/SMESH_Sphere.py index 36767fdbe..58d2aadd3 100644 --- a/src/SMESH_SWIG/SMESH_Sphere.py +++ b/src/SMESH_SWIG/SMESH_Sphere.py @@ -27,10 +27,17 @@ # Module : GEOM # $Header: # -from geompy import * -from math import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +import math # It is an example of creating a hexahedrical mesh on a sphere. # @@ -42,20 +49,20 @@ import smesh Radius = 100. Dist = Radius / 2. Factor = 2.5 -Angle90 = pi / 2. +Angle90 = math.pi / 2. NbSeg = 10 PointsList = [] ShapesList = [] #Basic Elements -P0 = MakeVertex(0., 0., 0.) -P1 = MakeVertex(-Dist, -Dist, -Dist) -P2 = MakeVertex(-Dist, -Dist, Dist) -P3 = MakeVertex(-Dist, Dist, Dist) -P4 = MakeVertex(-Dist, Dist, -Dist) +P0 = geompy.MakeVertex(0., 0., 0.) +P1 = geompy.MakeVertex(-Dist, -Dist, -Dist) +P2 = geompy.MakeVertex(-Dist, -Dist, Dist) +P3 = geompy.MakeVertex(-Dist, Dist, Dist) +P4 = geompy.MakeVertex(-Dist, Dist, -Dist) -VZ = MakeVectorDXDYDZ(0., 0., 1.) +VZ = geompy.MakeVectorDXDYDZ(0., 0., 1.) #Construction Elements PointsList.append(P1) @@ -64,47 +71,46 @@ PointsList.append(P3) PointsList.append(P4) PointsList.append(P1) -PolyLine = MakePolyline(PointsList) +PolyLine = geompy.MakePolyline(PointsList) -Face1 = MakeFace(PolyLine, 1) -Face2 = MakeScaleTransform(Face1, P0, Factor) -Face3 = MakeScaleTransform(Face1, P0, -1.) +Face1 = geompy.MakeFace(PolyLine, 1) +Face2 = geompy.MakeScaleTransform(Face1, P0, Factor) +Face3 = geompy.MakeScaleTransform(Face1, P0, -1.) #Models -Sphere = MakeSphereR(Radius) +Sphere = geompy.MakeSphereR(Radius) -Block = MakeHexa2Faces(Face1, Face2) -Cube = MakeHexa2Faces(Face1, Face3) +Block = geompy.MakeHexa2Faces(Face1, Face2) +Cube = geompy.MakeHexa2Faces(Face1, Face3) -Common1 = MakeBoolean(Sphere, Block, 1) -Common2 = MakeRotation(Common1, VZ, Angle90) +Common1 = geompy.MakeBoolean(Sphere, Block, 1) +Common2 = geompy.MakeRotation(Common1, VZ, Angle90) -MultiBlock1 = MakeMultiTransformation1D(Common1, 20, -1, 3) -MultiBlock2 = MakeMultiTransformation1D(Common2, 30, -1, 3) +MultiBlock1 = geompy.MakeMultiTransformation1D(Common1, 20, -1, 3) +MultiBlock2 = geompy.MakeMultiTransformation1D(Common2, 30, -1, 3) #Reconstruct sphere from several blocks ShapesList.append(Cube) ShapesList.append(MultiBlock1) ShapesList.append(MultiBlock2) -Compound = MakeCompound(ShapesList) +Compound = geompy.MakeCompound(ShapesList) -Result = MakeGlueFaces(Compound, 0.1) +Result = geompy.MakeGlueFaces(Compound, 0.1) #addToStudy -Id_Sphere = addToStudy(Sphere, "Sphere") -Id_Cube = addToStudy(Cube, "Cube") +Id_Sphere = geompy.addToStudy(Sphere, "Sphere") +Id_Cube = geompy.addToStudy(Cube, "Cube") -Id_Common1 = addToStudy(Common1, "Common1") -Id_Common2 = addToStudy(Common2, "Common2") +Id_Common1 = geompy.addToStudy(Common1, "Common1") +Id_Common2 = geompy.addToStudy(Common2, "Common2") -Id_MultiBlock1 = addToStudy(MultiBlock1, "MultiBlock1") -Id_MultiBlock2 = addToStudy(MultiBlock2, "MultiBlock2") +Id_MultiBlock1 = geompy.addToStudy(MultiBlock1, "MultiBlock1") +Id_MultiBlock2 = geompy.addToStudy(MultiBlock2, "MultiBlock2") -Id_Result = addToStudy(Result, "Result") +Id_Result = geompy.addToStudy(Result, "Result") #----------------------------------------------------------------------- #Meshing -smesh.SetCurrentStudy(salome.myStudy) my_hexa = smesh.Mesh(Result, "Sphere_Mesh") algo = my_hexa.Segment() algo.NumberOfSegments(NbSeg) diff --git a/src/SMESH_SWIG/SMESH_blocks.py b/src/SMESH_SWIG/SMESH_blocks.py index 12c68d4f0..c5a5e17e6 100644 --- a/src/SMESH_SWIG/SMESH_blocks.py +++ b/src/SMESH_SWIG/SMESH_blocks.py @@ -28,17 +28,22 @@ # $Header$ # import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + import math -import smesh import GEOM_Spanner isBlocksTest = 0 # False isMeshTest = 1 # True -smesh.SetCurrentStudy(salome.myStudy) - GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh) salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_box.py b/src/SMESH_SWIG/SMESH_box.py index 1ec31ed47..c38c5292f 100755 --- a/src/SMESH_SWIG/SMESH_box.py +++ b/src/SMESH_SWIG/SMESH_box.py @@ -31,16 +31,16 @@ # Salome geometry and meshing for a box # import salome -from salome import sg -import geompy -import smesh - +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -# ---- launch GEOM +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") - -###geom.GetCurrentStudy(salome.myStudy._get_StudyId()) +from salome import sg # Plate @@ -48,7 +48,6 @@ box = geompy.MakeBox(0.,0.,0.,1.,1.,1.) boxId = geompy.addToStudy(box,"box") # ---- SMESH -smesh.SetCurrentStudy(salome.myStudy) # ---- init a Mesh diff --git a/src/SMESH_SWIG/SMESH_box2_tetra.py b/src/SMESH_SWIG/SMESH_box2_tetra.py index b1bc06801..850df8e66 100644 --- a/src/SMESH_SWIG/SMESH_box2_tetra.py +++ b/src/SMESH_SWIG/SMESH_box2_tetra.py @@ -25,8 +25,14 @@ # Hypothesis and algorithms for the mesh generation are global # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define 2 boxes box1 and box2 @@ -74,7 +80,6 @@ print "number of Edges in shell : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) # ---- init a Mesh with the shell @@ -109,7 +114,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -netgen3D = mesh.Tetrahedron(smesh.NETGEN) +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) hypVolume = netgen3D.MaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_box3_tetra.py b/src/SMESH_SWIG/SMESH_box3_tetra.py index a10965880..1e4963d4a 100644 --- a/src/SMESH_SWIG/SMESH_box3_tetra.py +++ b/src/SMESH_SWIG/SMESH_box3_tetra.py @@ -26,9 +26,14 @@ # Hypothesis and algorithms for the mesh generation are global # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define 3 boxes box1, box2 and box3 @@ -85,7 +90,6 @@ print "number of Edges in shell : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) # ---- init a Mesh with the shell @@ -120,7 +124,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -netgen3D = mesh.Tetrahedron(smesh.NETGEN) +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) hypVolume = netgen3D.MaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_box_tetra.py b/src/SMESH_SWIG/SMESH_box_tetra.py index 4ebd38dc7..f6edcf762 100644 --- a/src/SMESH_SWIG/SMESH_box_tetra.py +++ b/src/SMESH_SWIG/SMESH_box_tetra.py @@ -25,9 +25,14 @@ # the mesh generation are global # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define a boxe @@ -46,7 +51,6 @@ print "number of Edges in box : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) # ---- init a Mesh with the boxe @@ -79,7 +83,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -netgen3D = mesh.Tetrahedron(smesh.NETGEN) +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) hypVolume = netgen3D.MaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_controls.py b/src/SMESH_SWIG/SMESH_controls.py index dc8b4ff35..e2ff1be23 100644 --- a/src/SMESH_SWIG/SMESH_controls.py +++ b/src/SMESH_SWIG/SMESH_controls.py @@ -25,17 +25,16 @@ # Author : Sergey LITONIN # Module : SMESH # -import smesh import SMESH_mechanic -salome = smesh.salome -mesh = SMESH_mechanic.mesh - +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- Criterion : AREA > 100 # create group -aGroup = mesh.MakeGroup("Area > 100", smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100) +aGroup = mesh.MakeGroup("Area > 100", SMESH.FACE, SMESH.FT_Area, SMESH.FT_MoreThan, 100) # print result anIds = aGroup.GetIDs() @@ -47,7 +46,7 @@ print "Criterion: Area > 100 Nb = ", len( anIds ) # ---- Criterion : Taper > 3e-15 # create group -aGroup = mesh.MakeGroup("Taper > 3e-15", smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, 3e-15) +aGroup = mesh.MakeGroup("Taper > 3e-15", SMESH.FACE, SMESH.FT_Taper, SMESH.FT_MoreThan, 3e-15) # print result anIds = aGroup.GetIDs() @@ -59,7 +58,7 @@ print "Criterion: Taper > 3e-15 Nb = ", len( anIds ) # ---- Criterion : ASPECT RATIO > 1.3 # create group -aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 1.3) +aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", SMESH.FACE, SMESH.FT_AspectRatio, SMESH.FT_MoreThan, 1.3) # print result anIds = aGroup.GetIDs() @@ -71,7 +70,7 @@ print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds ) # ---- Criterion : MINIMUM ANGLE < 30 # create group -aGroup = mesh.MakeGroup("Minimum Angle < 30", smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, 30) +aGroup = mesh.MakeGroup("Minimum Angle < 30", SMESH.FACE, SMESH.FT_MinimumAngle, SMESH.FT_LessThan, 30) # print result anIds = aGroup.GetIDs() @@ -83,7 +82,7 @@ print "Criterion: Minimum Angle < 30 Nb = ", len( anIds ) # ---- Criterion : Warp > 2e-13 # create group -aGroup = mesh.MakeGroup("Warp > 2e-13", smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, 2e-13 ) +aGroup = mesh.MakeGroup("Warp > 2e-13", SMESH.FACE, SMESH.FT_Warping, SMESH.FT_MoreThan, 2e-13 ) # print result anIds = aGroup.GetIDs() @@ -95,7 +94,7 @@ print "Criterion: Warp > 2e-13 Nb = ", len( anIds ) # ---- Criterion : Skew > 18 # create group -aGroup = mesh.MakeGroup("Skew > 18", smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 18 ) +aGroup = mesh.MakeGroup("Skew > 18", SMESH.FACE, SMESH.FT_Skew, SMESH.FT_MoreThan, 18 ) # print result anIds = aGroup.GetIDs() @@ -107,7 +106,7 @@ print "Criterion: Skew > 18 Nb = ", len( anIds ) # Criterion : Length > 10 # create group -aGroup = mesh.MakeGroup("Length > 10", smesh.FACE, smesh.FT_Length, smesh.FT_MoreThan, 10 ) +aGroup = mesh.MakeGroup("Length > 10", SMESH.FACE, SMESH.FT_Length, SMESH.FT_MoreThan, 10 ) # print result anIds = aGroup.GetIDs() @@ -119,7 +118,7 @@ print "Criterion: Length > 10 Nb = ", len( anIds ) # Criterion : Borders at multi-connections = 2 # create group -aGroup = mesh.MakeGroup("Borders at multi-connections = 2", smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, 2) +aGroup = mesh.MakeGroup("Borders at multi-connections = 2", SMESH.EDGE, SMESH.FT_MultiConnection, SMESH.FT_EqualTo, 2) # print result anIds = aGroup.GetIDs() @@ -131,7 +130,7 @@ print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds ) # Criterion : Element Diameter 2D > 10 # create group -aGroup = mesh.MakeGroup("Element Diameter 2D > 10", smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, 10 ) +aGroup = mesh.MakeGroup("Element Diameter 2D > 10", SMESH.FACE, SMESH.FT_MaxElementLength2D, SMESH.FT_MoreThan, 10 ) # print result anIds = aGroup.GetIDs() diff --git a/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py b/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py index f99c9201b..6e6837816 100755 --- a/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py +++ b/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py @@ -33,8 +33,14 @@ # the mesh of some edges is thinner # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import math diff --git a/src/SMESH_SWIG/SMESH_fixation.py b/src/SMESH_SWIG/SMESH_fixation.py index 948c867fa..8a327def5 100644 --- a/src/SMESH_SWIG/SMESH_fixation.py +++ b/src/SMESH_SWIG/SMESH_fixation.py @@ -27,7 +27,11 @@ # $Header$ # import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + import math # ----------------------------------------------------------------------------- diff --git a/src/SMESH_SWIG/SMESH_fixation_hexa.py b/src/SMESH_SWIG/SMESH_fixation_hexa.py index 7bd194163..edcfef821 100644 --- a/src/SMESH_SWIG/SMESH_fixation_hexa.py +++ b/src/SMESH_SWIG/SMESH_fixation_hexa.py @@ -26,7 +26,10 @@ # Hypothesis and algorithms for the mesh generation are global # import SMESH_fixation -import smesh + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) compshell = SMESH_fixation.compshell idcomp = SMESH_fixation.idcomp diff --git a/src/SMESH_SWIG/SMESH_fixation_netgen.py b/src/SMESH_SWIG/SMESH_fixation_netgen.py index fd644d519..d6f38cbc0 100644 --- a/src/SMESH_SWIG/SMESH_fixation_netgen.py +++ b/src/SMESH_SWIG/SMESH_fixation_netgen.py @@ -26,7 +26,10 @@ # The new Netgen algorithm is used that discretizes baoundaries itself # import SMESH_fixation -import smesh + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) compshell = SMESH_fixation.compshell idcomp = SMESH_fixation.idcomp @@ -51,10 +54,10 @@ smesh.SetCurrentStudy(salome.myStudy) print "-------------------------- create Mesh, algorithm, hypothesis" mesh = smesh.Mesh(compshell, "MeshcompShel"); -netgen = mesh.Tetrahedron(smesh.FULL_NETGEN) +netgen = mesh.Tetrahedron(smeshBuilder.FULL_NETGEN) netgen.SetMaxSize( 50 ) #netgen.SetSecondOrder( 0 ) -netgen.SetFineness( smesh.Fine ) +netgen.SetFineness( smeshBuilder.Fine ) #netgen.SetOptimize( 1 ) salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_fixation_tetra.py b/src/SMESH_SWIG/SMESH_fixation_tetra.py index 5a4e2f3f5..9896da034 100644 --- a/src/SMESH_SWIG/SMESH_fixation_tetra.py +++ b/src/SMESH_SWIG/SMESH_fixation_tetra.py @@ -25,8 +25,12 @@ # SMESH_fixation.py # Hypothesis and algorithms for the mesh generation are global # + import SMESH_fixation -import smesh + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) compshell = SMESH_fixation.compshell idcomp = SMESH_fixation.idcomp @@ -93,7 +97,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 1000 -netgen3D = mesh.Tetrahedron(smesh.NETGEN) +netgen3D = mesh.Tetrahedron(smeshBuilder.NETGEN) netgen3D.SetName("NETGEN_3D") hypVolume = netgen3D.MaxElementVolume(maxElementVolume) print hypVolume.GetName() diff --git a/src/SMESH_SWIG/SMESH_flight_skin.py b/src/SMESH_SWIG/SMESH_flight_skin.py index 5c57e002e..fce24d749 100644 --- a/src/SMESH_SWIG/SMESH_flight_skin.py +++ b/src/SMESH_SWIG/SMESH_flight_skin.py @@ -26,8 +26,14 @@ # import os import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---------------------------- GEOM -------------------------------------- diff --git a/src/SMESH_SWIG/SMESH_freebord.py b/src/SMESH_SWIG/SMESH_freebord.py index 2bc4f5538..809fbff8d 100644 --- a/src/SMESH_SWIG/SMESH_freebord.py +++ b/src/SMESH_SWIG/SMESH_freebord.py @@ -22,8 +22,14 @@ # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Create box without one plane @@ -58,7 +64,7 @@ mesh.Compute() # Criterion : Free edges. Create group. -aCriterion = smesh.GetCriterion(smesh.EDGE, smesh.FT_FreeEdges) +aCriterion = smesh.GetCriterion(SMESH.EDGE, SMESH.FT_FreeEdges) aGroup = mesh.MakeGroupByCriterion("Free edges", aCriterion) diff --git a/src/SMESH_SWIG/SMESH_hexaedre.py b/src/SMESH_SWIG/SMESH_hexaedre.py index 66ba9c824..8fd527f8f 100755 --- a/src/SMESH_SWIG/SMESH_hexaedre.py +++ b/src/SMESH_SWIG/SMESH_hexaedre.py @@ -21,12 +21,16 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -# ----------------------------------------------------------------------------- +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") +# ----------------------------------------------------------------------------- p0 = geompy.MakeVertex(0., 0., 0.) px = geompy.MakeVertex(100., 0., 0.) diff --git a/src/SMESH_SWIG/SMESH_mechanic.py b/src/SMESH_SWIG/SMESH_mechanic.py index 9f306f154..d7835f437 100644 --- a/src/SMESH_SWIG/SMESH_mechanic.py +++ b/src/SMESH_SWIG/SMESH_mechanic.py @@ -28,8 +28,14 @@ #------------------------------------------------------------------------- # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import StdMeshers diff --git a/src/SMESH_SWIG/SMESH_mechanic_editor.py b/src/SMESH_SWIG/SMESH_mechanic_editor.py index 4563dd476..c973d4b44 100644 --- a/src/SMESH_SWIG/SMESH_mechanic_editor.py +++ b/src/SMESH_SWIG/SMESH_mechanic_editor.py @@ -28,10 +28,15 @@ #------------------------------------------------------------------------- # import salome -import geompy -import smesh - salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + # ---------------------------- GEOM -------------------------------------- # ---- define contigous arcs and segment to define a closed wire @@ -120,7 +125,6 @@ name = geompy.SubShapeName( sub_face4, mechanic ) Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) # ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) # -- Init -- shape_mesh = salome.IDToObject( Id_mechanic ) @@ -194,37 +198,37 @@ mesh.SplitQuadObject(submesh2, 1) #2 cutting of triangles of the group FacesTriToQuad = [ 2391, 2824, 2825, 2826, 2827, 2828, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2841, 2844, 2845, 2847, 2854, 2861, 2863, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2946, 2951, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985 ] -GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad) -mesh.TriToQuadObject(GroupTriToQuad, smesh.FT_AspectRatio , 1.57) +GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", SMESH.FACE, FacesTriToQuad) +mesh.TriToQuadObject(GroupTriToQuad, SMESH.FT_AspectRatio , 1.57) #3 extrusion of the group -point = smesh.PointStruct(0, 0, 5) -vector = smesh.DirStruct(point) +point = SMESH.PointStruct(0, 0, 5) +vector = SMESH.DirStruct(point) mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5) #4 mirror object -mesh.Mirror([], smesh.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0) +mesh.Mirror([], SMESH.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0) #5 mesh translation -point = smesh.PointStruct(10, 10, 10) -vector = smesh.DirStruct(point) +point = SMESH.PointStruct(10, 10, 10) +vector = SMESH.DirStruct(point) mesh.Translate([], vector, 0) #6 mesh rotation -axisXYZ = smesh.AxisStruct(0, 0, 0, 10, 10, 10) +axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10) angle180 = 180*3.141/180 mesh.Rotate([], axisXYZ, angle180, 0) #7 group smoothing FacesSmooth = [864, 933, 941, 950, 1005, 1013] -GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", smesh.FACE, FacesSmooth) +GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", SMESH.FACE, FacesSmooth) mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH) #8 rotation sweep object FacesRotate = [492, 493, 502, 503] -GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", smesh.FACE, FacesRotate) +GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", SMESH.FACE, FacesRotate) angle45 = 45*3.141/180 -axisXYZ = smesh.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632) +axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632) mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) #9 reorientation of the submesh1 diff --git a/src/SMESH_SWIG/SMESH_mechanic_netgen.py b/src/SMESH_SWIG/SMESH_mechanic_netgen.py index 653a61c6e..280975e64 100644 --- a/src/SMESH_SWIG/SMESH_mechanic_netgen.py +++ b/src/SMESH_SWIG/SMESH_mechanic_netgen.py @@ -26,11 +26,14 @@ # The new Netgen algorithm is used that discretizes baoundaries itself # import salome -import geompy +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -geom = geompy.geom - -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---------------------------- GEOM -------------------------------------- @@ -105,15 +108,14 @@ print "number of Faces in mechanic : ",len(subFaceList) print "number of Edges in mechanic : ",len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) print "-------------------------- create Mesh, algorithm, hypothesis" mesh = smesh.Mesh(mechanic, "Mesh_mechanic"); -netgen = mesh.Triangle(smesh.NETGEN) +netgen = mesh.Triangle(smeshBuilder.NETGEN) netgen.SetMaxSize( 50 ) #netgen.SetSecondOrder( 0 ) -netgen.SetFineness( smesh.Fine ) +netgen.SetFineness( smeshBuilder.Fine ) netgen.SetQuadAllowed( 1 ) #netgen.SetOptimize( 1 ) diff --git a/src/SMESH_SWIG/SMESH_mechanic_tetra.py b/src/SMESH_SWIG/SMESH_mechanic_tetra.py index e1893b685..68996d81c 100644 --- a/src/SMESH_SWIG/SMESH_mechanic_tetra.py +++ b/src/SMESH_SWIG/SMESH_mechanic_tetra.py @@ -27,10 +27,14 @@ # $Header$ # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -geom = geompy.geom +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---------------------------- GEOM -------------------------------------- @@ -105,7 +109,6 @@ print "number of Faces in mechanic : ",len(subFaceList) print "number of Edges in mechanic : ",len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -smesh.SetCurrentStudy(salome.myStudy) shape_mesh = salome.IDToObject( Id_mechanic ) @@ -125,7 +128,7 @@ smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) maxElementArea = 20 -algo2 = mesh.Triangle(smesh.MEFISTO) +algo2 = mesh.Triangle(smeshBuilder.MEFISTO) hypArea = algo2.MaxElementArea(maxElementArea) print hypArea.GetName() print hypArea.GetId() @@ -135,7 +138,7 @@ smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea)) maxElementVolume = 20 -algo3 = mesh.Tetrahedron(smesh.NETGEN) +algo3 = mesh.Tetrahedron(smeshBuilder.NETGEN) hypVolume = algo3.MaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() diff --git a/src/SMESH_SWIG/SMESH_reg.py b/src/SMESH_SWIG/SMESH_reg.py index 77439c83e..36fc4b897 100644 --- a/src/SMESH_SWIG/SMESH_reg.py +++ b/src/SMESH_SWIG/SMESH_reg.py @@ -25,8 +25,14 @@ # Module : SMESH # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import StdMeshers diff --git a/src/SMESH_SWIG/SMESH_test.py b/src/SMESH_SWIG/SMESH_test.py index bd467564d..c296df6fd 100644 --- a/src/SMESH_SWIG/SMESH_test.py +++ b/src/SMESH_SWIG/SMESH_test.py @@ -26,8 +26,14 @@ # Module : SMESH # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define a box @@ -69,7 +75,7 @@ print hyp.GetName() print hyp.GetId() print hyp.GetLength() -algo_2 = mesh.Triangle(smesh.MEFISTO, box) +algo_2 = mesh.Triangle(smeshBuilder.MEFISTO, box) hyp = algo_2.MaxElementArea(5000) print hyp.GetName() print hyp.GetId() diff --git a/src/SMESH_SWIG/SMESH_test0.py b/src/SMESH_SWIG/SMESH_test0.py index 40ce96c58..0ddb6f3c6 100644 --- a/src/SMESH_SWIG/SMESH_test0.py +++ b/src/SMESH_SWIG/SMESH_test0.py @@ -25,11 +25,14 @@ # Module : SMESH # import salome -import geompy -from geompy import geom +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) - -myBuilder = salome.myStudy.NewBuilder() +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define a box diff --git a/src/SMESH_SWIG/SMESH_test1.py b/src/SMESH_SWIG/SMESH_test1.py index 58fa45091..2a34cec6c 100644 --- a/src/SMESH_SWIG/SMESH_test1.py +++ b/src/SMESH_SWIG/SMESH_test1.py @@ -25,8 +25,14 @@ # Module : SMESH # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define a box @@ -60,8 +66,6 @@ idedge = geompy.addToStudyInFather(face, edge, name) # ---- SMESH -smesh.SetCurrentStudy(salome.myStudy) - # ---- Init a Mesh with the box mesh = smesh.Mesh(box, "Meshbox") diff --git a/src/SMESH_SWIG/SMESH_test1_AndDisplay.py b/src/SMESH_SWIG/SMESH_test1_AndDisplay.py index 9d70e9478..c3a09133d 100644 --- a/src/SMESH_SWIG/SMESH_test1_AndDisplay.py +++ b/src/SMESH_SWIG/SMESH_test1_AndDisplay.py @@ -25,9 +25,14 @@ # Module : SMESH # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- define a box @@ -61,8 +66,6 @@ idedge = geompy.addToStudyInFather(face, edge, name) # ---- SMESH -smesh.SetCurrentStudy(salome.myStudy) - # ---- Init a Mesh with the box mesh = smesh.Mesh(box, "Meshbox") diff --git a/src/SMESH_SWIG/SMESH_test3.py b/src/SMESH_SWIG/SMESH_test3.py index be051600e..5a967a42e 100644 --- a/src/SMESH_SWIG/SMESH_test3.py +++ b/src/SMESH_SWIG/SMESH_test3.py @@ -25,8 +25,16 @@ # Module : SMESH #import salome # +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import math -import geompy pi = math.pi diff --git a/src/SMESH_SWIG/SMESH_test4.py b/src/SMESH_SWIG/SMESH_test4.py index 67dc29895..ea8bc3c8c 100755 --- a/src/SMESH_SWIG/SMESH_test4.py +++ b/src/SMESH_SWIG/SMESH_test4.py @@ -22,8 +22,14 @@ # import salome -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ---- GEOM @@ -49,13 +55,13 @@ algo1 = mesh.Segment() algo1.NumberOfSegments(10) # Set 2D algorithm/hypotheses to mesh -algo2 = mesh.Triangle(smesh.MEFISTO) +algo2 = mesh.Triangle(smeshBuilder.MEFISTO) algo2.MaxElementArea(10) # Create submesh on face algo3 = mesh.Segment(face) algo3.NumberOfSegments(10) -algo4 = mesh.Triangle(smesh.MEFISTO, face) +algo4 = mesh.Triangle(smeshBuilder.MEFISTO, face) algo4.MaxElementArea(100) submesh = algo4.GetSubMesh() smesh.SetName(submesh, "SubMeshFace") @@ -63,11 +69,11 @@ smesh.SetName(submesh, "SubMeshFace") mesh.Compute() -faces = submesh.GetElementsByType(smesh.FACE) +faces = submesh.GetElementsByType(SMESH.FACE) if len(faces) > 1: print len(faces), len(faces)/2 - group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces") - group2 = mesh.CreateEmptyGroup(smesh.FACE,"Another group of faces") + group1 = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces") + group2 = mesh.CreateEmptyGroup(SMESH.FACE,"Another group of faces") group1.Add(faces[:int(len(faces)/2)]) group2.Add(faces[int(len(faces)/2):]) diff --git a/src/SMESH_SWIG/SMESH_test5.py b/src/SMESH_SWIG/SMESH_test5.py index b2fc9a8e1..625a82f9e 100644 --- a/src/SMESH_SWIG/SMESH_test5.py +++ b/src/SMESH_SWIG/SMESH_test5.py @@ -25,14 +25,19 @@ # Module : SMESH # import salome -import smesh -import SALOMEDS +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + import CORBA import os import os.path -smesh.SetCurrentStudy(salome.myStudy) - def SetSObjName(theSObj,theName) : ok, anAttr = theSObj.FindAttribute("AttributeName") if ok: diff --git a/src/SMESH_SWIG/StdMeshersBuilder.py b/src/SMESH_SWIG/StdMeshersBuilder.py new file mode 100644 index 000000000..bf79aeb03 --- /dev/null +++ b/src/SMESH_SWIG/StdMeshersBuilder.py @@ -0,0 +1,1361 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +## +# @package StdMeshersBuilder +# Python API for the standard meshing plug-in module. + +from salome.smesh.smesh_algorithm import Mesh_Algorithm +from salome.smesh.smeshBuilder import AssureGeomPublished, IsEqual, ParseParameters +from salome.smesh.smeshBuilder import GetName, TreatHypoStatus +from salome.smesh.smeshBuilder import Mesh + +import StdMeshers + +#---------------------------- +# Mesh algo type identifiers +#---------------------------- + +## Algorithm type: Regular 1D algorithm, see StdMeshersBuilder_Segment +REGULAR = "Regular_1D" +## Algorithm type: Python 1D algorithm, see StdMeshersBuilder_Segment_Python +PYTHON = "Python_1D" +## Algorithm type: Composite segment 1D algorithm, see StdMeshersBuilder_CompositeSegment +COMPOSITE = "CompositeSegment_1D" +## Algorithm type: Triangle MEFISTO 2D algorithm, see StdMeshersBuilder_Triangle_MEFISTO +MEFISTO = "MEFISTO_2D" +## Algorithm type: Hexahedron 3D (i-j-k) algorithm, see StdMeshersBuilder_Hexahedron +Hexa = "Hexa_3D" +## Algorithm type: Quadrangle 2D algorithm, see StdMeshersBuilder_Quadrangle +QUADRANGLE = "Quadrangle_2D" +## Algorithm type: Radial Quadrangle 1D-2D algorithm, see StdMeshersBuilder_RadialQuadrangle1D2D +RADIAL_QUAD = "RadialQuadrangle_1D2D" + +# import items of enum QuadType +for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e)) + +#---------------------- +# Algorithms +#---------------------- + +## Defines segment 1D algorithm for edges discretization. +# +# It can be created by calling smesh.Mesh.Segment(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Segment(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Segment" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = REGULAR + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates segment 1D algorithm for edges" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length + # @param l for the length of segments that cut an edge + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @param p precision, used for calculation of the number of segments. + # The precision should be a positive, meaningful value within the range [0,1]. + # In general, the number of segments is calculated with the formula: + # nb = ceil((edge_length / l) - p) + # Function ceil rounds its argument to the higher integer. + # So, p=0 means rounding of (edge_length / l) to the higher integer, + # p=0.5 means rounding of (edge_length / l) to the nearest integer, + # p=1 means rounding of (edge_length / l) to the lower integer. + # Default value is 1e-07. + # @return an instance of StdMeshers_LocalLength hypothesis + # @ingroup l3_hypos_1dhyps + def LocalLength(self, l, UseExisting=0, p=1e-07): + comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1]) + hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun) + hyp.SetLength(l) + hyp.SetPrecision(p) + return hyp + + ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value + # @param length is optional maximal allowed length of segment, if it is omitted + # the preestimated length is used that depends on geometry size + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @return an instance of StdMeshers_MaxLength hypothesis + # @ingroup l3_hypos_1dhyps + def MaxSize(self, length=0.0, UseExisting=0): + hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting) + if length > 0.0: + # set given length + hyp.SetLength(length) + if not UseExisting: + # set preestimated length + gen = self.mesh.smeshpyD + initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so", + self.mesh.GetMesh(), self.mesh.GetShape(), + False) # <- byMesh + preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength) + if preHyp: + hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() ) + pass + pass + hyp.SetUsePreestimatedLength( length == 0.0 ) + return hyp + + ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments + # @param n for the number of segments that cut an edge + # @param s for the scale factor (optional) + # @param reversedEdges is a list of edges to mesh using reversed orientation. + # A list item can also be a tuple (edge, 1st_vertex_of_edge) + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - create a new one + # @return an instance of StdMeshers_NumberOfSegments hypothesis + # @ingroup l3_hypos_1dhyps + def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0): + if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges + reversedEdges, UseExisting = [], reversedEdges + entry = self.MainShapeEntry() + reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) + if s == []: + hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry], + UseExisting=UseExisting, + CompareMethod=self._compareNumberOfSegments) + else: + hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry], + UseExisting=UseExisting, + CompareMethod=self._compareNumberOfSegments) + hyp.SetDistrType( 1 ) + hyp.SetScaleFactor(s) + hyp.SetNumberOfSegments(n) + hyp.SetReversedEdges( reversedEdgeInd ) + hyp.SetObjectEntry( entry ) + return hyp + + ## Private method + # + # Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments + def _compareNumberOfSegments(self, hyp, args): + if hyp.GetNumberOfSegments() == args[0]: + if len(args) == 3: + if hyp.GetReversedEdges() == args[1]: + if not args[1] or hyp.GetObjectEntry() == args[2]: + return True + else: + if hyp.GetReversedEdges() == args[2]: + if not args[2] or hyp.GetObjectEntry() == args[3]: + if hyp.GetDistrType() == 1: + if IsEqual(hyp.GetScaleFactor(), args[1]): + return True + return False + + ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length + # @param start defines the length of the first segment + # @param end defines the length of the last segment + # @param reversedEdges is a list of edges to mesh using reversed orientation. + # A list item can also be a tuple (edge, 1st_vertex_of_edge) + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @return an instance of StdMeshers_Arithmetic1D hypothesis + # @ingroup l3_hypos_1dhyps + def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0): + if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges + reversedEdges, UseExisting = [], reversedEdges + reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) + entry = self.MainShapeEntry() + compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \ + IsEqual(hyp.GetLength(0), args[1]) and \ + hyp.GetReversedEdges() == args[2] and \ + (not args[2] or hyp.GetObjectEntry() == args[3])) + hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry], + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetStartLength(start) + hyp.SetEndLength(end) + hyp.SetReversedEdges( reversedEdgeInd ) + hyp.SetObjectEntry( entry ) + return hyp + + ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter + # on curve from 0 to 1 (additionally it is neecessary to check + # orientation of edges and create list of reversed edges if it is + # needed) and sets numbers of segments between given points (default + # values are equals 1 + # @param points defines the list of parameters on curve + # @param nbSegs defines the list of numbers of segments + # @param reversedEdges is a list of edges to mesh using reversed orientation. + # A list item can also be a tuple (edge, 1st_vertex_of_edge) + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @return an instance of StdMeshers_Arithmetic1D hypothesis + # @ingroup l3_hypos_1dhyps + def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0): + if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges + reversedEdges, UseExisting = [], reversedEdges + reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) + entry = self.MainShapeEntry() + compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \ + hyp.GetNbSegments() == args[1] and \ + hyp.GetReversedEdges() == args[2] and \ + (not args[2] or hyp.GetObjectEntry() == args[3])) + hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry], + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetPoints(points) + hyp.SetNbSegments(nbSegs) + hyp.SetReversedEdges(reversedEdgeInd) + hyp.SetObjectEntry(entry) + return hyp + + ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length + # @param start defines the length of the first segment + # @param end defines the length of the last segment + # @param reversedEdges is a list of edges to mesh using reversed orientation. + # A list item can also be a tuple (edge, 1st_vertex_of_edge) + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @return an instance of StdMeshers_StartEndLength hypothesis + # @ingroup l3_hypos_1dhyps + def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0): + if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges + reversedEdges, UseExisting = [], reversedEdges + reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) + entry = self.MainShapeEntry() + compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \ + IsEqual(hyp.GetLength(0), args[1]) and \ + hyp.GetReversedEdges() == args[2] and \ + (not args[2] or hyp.GetObjectEntry() == args[3])) + hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry], + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetStartLength(start) + hyp.SetEndLength(end) + hyp.SetReversedEdges( reversedEdgeInd ) + hyp.SetObjectEntry( entry ) + return hyp + + ## Defines "Deflection1D" hypothesis + # @param d for the deflection + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - create a new one + # @ingroup l3_hypos_1dhyps + def Deflection1D(self, d, UseExisting=0): + compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0]) + hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetDeflection(d) + return hyp + + ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at + # the opposite side in case of quadrangular faces + # @ingroup l3_hypos_additi + def Propagation(self): + return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp) + + ## Defines "AutomaticLength" hypothesis + # @param fineness for the fineness [0-1] + # @param UseExisting if ==true - searches for an existing hypothesis created with the + # same parameters, else (default) - create a new one + # @ingroup l3_hypos_1dhyps + def AutomaticLength(self, fineness=0, UseExisting=0): + compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0]) + hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting, + CompareMethod=compFun) + hyp.SetFineness( fineness ) + return hyp + + ## Defines "SegmentLengthAroundVertex" hypothesis + # @param length for the segment length + # @param vertex for the length localization: the vertex index [0,1] | vertex object. + # Any other integer value means that the hypothesis will be set on the + # whole 1D shape, where Mesh_Segment algorithm is assigned. + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_algos_segmarv + def LengthNearVertex(self, length, vertex=0, UseExisting=0): + import types + store_geom = self.geom + if type(vertex) is types.IntType: + if vertex == 0 or vertex == 1: + from salome.geom import geomBuilder + vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.ShapeType["VERTEX"],True)[vertex] + self.geom = vertex + pass + pass + else: + self.geom = vertex + pass + # 0D algorithm + if self.geom is None: + raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape" + AssureGeomPublished( self.mesh, self.geom ) + name = GetName(self.geom) + + algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD) + if algo is None: + algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so") + pass + status = self.mesh.mesh.AddHypothesis(self.geom, algo) + TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True) + # + comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) + hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting, + CompareMethod=comFun) + self.geom = store_geom + hyp.SetLength( length ) + return hyp + + ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges. + # If the 2D mesher sees that all boundary edges are quadratic, + # it generates quadratic faces, else it generates linear faces using + # medium nodes as if they are vertices. + # The 3D mesher generates quadratic volumes only if all boundary faces + # are quadratic, else it fails. + # + # @ingroup l3_hypos_additi + def QuadraticMesh(self): + hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp) + return hyp + + pass # end of StdMeshersBuilder_Segment class + +## Segment 1D algorithm for discretization of a set of adjacent edges as one edge. +# +# It is created by calling smesh.Mesh.Segment(smesh.COMPOSITE,geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_CompositeSegment(StdMeshersBuilder_Segment): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Segment" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = COMPOSITE + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = False + ## doc string of the method + # @internal + docHelper = "Creates segment 1D algorithm for edges" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + self.Create(mesh, geom, self.algoType) + pass + + pass # end of StdMeshersBuilder_CompositeSegment class + +## Defines a segment 1D algorithm for discretization of edges with Python function +# +# It is created by calling smesh.Mesh.Segment(smesh.PYTHON,geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Segment_Python(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Segment" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = PYTHON + ## doc string of the method + # @internal + docHelper = "Creates tetrahedron 3D algorithm for solids" + ## doc string of the method + # @internal + docHelper = "Creates segment 1D algorithm for edges" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + import Python1dPlugin + self.Create(mesh, geom, self.algoType, "libPython1dEngine.so") + pass + + ## Defines "PythonSplit1D" hypothesis + # @param n for the number of segments that cut an edge + # @param func for the python function that calculates the length of all segments + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_1dhyps + def PythonSplit1D(self, n, func, UseExisting=0): + compFun = lambda hyp, args: False + hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so", + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetNumberOfSegments(n) + hyp.SetPythonLog10RatioFunction(func) + return hyp + + pass # end of StdMeshersBuilder_Segment_Python class + +## Triangle MEFISTO 2D algorithm +# +# It is created by calling smesh.Mesh.Triangle(smesh.MEFISTO,geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Triangle_MEFISTO(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Triangle" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = MEFISTO + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates triangle 2D algorithm for faces" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle + # @param area for the maximum area of each triangle + # @param UseExisting if ==true - searches for an existing hypothesis created with the + # same parameters, else (default) - creates a new one + # + # @ingroup l3_hypos_2dhyps + def MaxElementArea(self, area, UseExisting=0): + comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0]) + hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting, + CompareMethod=comparator) + hyp.SetMaxElementArea(area) + return hyp + + ## Defines "LengthFromEdges" hypothesis to build triangles + # based on the length of the edges taken from the wire + # + # @ingroup l3_hypos_2dhyps + def LengthFromEdges(self): + hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) + return hyp + + pass # end of StdMeshersBuilder_Triangle_MEFISTO class + +## Defines a quadrangle 2D algorithm +# +# It is created by calling smesh.Mesh.Quadrangle(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Quadrangle" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = QUADRANGLE + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates quadrangle 2D algorithm for faces" + ## hypothesis associated with algorithm + # @internal + params = 0 + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "QuadrangleParameters" hypothesis + # @param quadType defines the algorithm of transition between differently descretized + # sides of a geometrical face: + # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition + # area along the finer meshed sides. + # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the + # finer meshed sides. + # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along + # the finer meshed sides, iff the total quantity of segments on + # all four sides of the face is even (divisible by 2). + # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition + # area is located along the coarser meshed sides. + # - QUAD_REDUCED - only quadrangles are built and the transition between the sides + # is made gradually, layer by layer. This type has a limitation on + # the number of segments: one pair of opposite sides must have the + # same number of segments, the other pair must have an even difference + # between the numbers of segments on the sides. + # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles + # will be created while other elements will be quadrangles. + # Vertex can be either a GEOM_Object or a vertex ID within the + # shape to mesh + # @param UseExisting: if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_quad + def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0): + import GEOM + vertexID = triangleVertex + if isinstance( triangleVertex, GEOM._objref_GEOM_Object ): + vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex ) + if not self.params: + compFun = lambda hyp,args: \ + hyp.GetQuadType() == args[0] and \ + ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1)) + self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID], + UseExisting = UseExisting, CompareMethod=compFun) + pass + if self.params.GetQuadType() != quadType: + self.params.SetQuadType(quadType) + if vertexID > 0: + self.params.SetTriaVertex( vertexID ) + return self.params + + ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only + # quadrangles are built in the transition area along the finer meshed sides, + # iff the total quantity of segments on all four sides of the face is even. + # @param reversed if True, transition area is located along the coarser meshed sides. + # @param UseExisting: if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_quad + def QuadranglePreference(self, reversed=False, UseExisting=0): + if reversed: + return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting) + return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting) + + ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only + # triangles are built in the transition area along the finer meshed sides. + # @param UseExisting: if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_quad + def TrianglePreference(self, UseExisting=0): + return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting) + + ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only + # quadrangles are built and the transition between the sides is made gradually, + # layer by layer. This type has a limitation on the number of segments: one pair + # of opposite sides must have the same number of segments, the other pair must + # have an even difference between the numbers of segments on the sides. + # @param UseExisting: if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_quad + def Reduced(self, UseExisting=0): + return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting) + + ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation + # @param vertex: vertex of a trilateral geometrical face, around which triangles + # will be created while other elements will be quadrangles. + # Vertex can be either a GEOM_Object or a vertex ID within the + # shape to mesh + # @param UseExisting: if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # @ingroup l3_hypos_quad + def TriangleVertex(self, vertex, UseExisting=0): + return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting) + + pass # end of StdMeshersBuilder_Quadrangle class + +## Defines a hexahedron 3D algorithm +# +# It is created by calling smesh.Mesh.Hexahedron(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Hexahedron(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Hexahedron" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = Hexa + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates hexahedron 3D algorithm for volumes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, Hexa) + pass + + pass # end of StdMeshersBuilder_Hexahedron class + +## Defines a projection 1D algorithm +# +# It is created by calling smesh.Mesh.Projection1D(geom=0) +# +# @ingroup l3_algos_proj +class StdMeshersBuilder_Projection1D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Projection1D" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Projection_1D" + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates projection 1D algorithm for edges" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where + # a mesh pattern is taken, and, optionally, the association of vertices + # between the source edge and a target edge (to which a hypothesis is assigned) + # @param edge from which nodes distribution is taken + # @param mesh from which nodes distribution is taken (optional) + # @param srcV a vertex of \a edge to associate with \a tgtV (optional) + # @param tgtV a vertex of \a the edge to which the algorithm is assigned, + # to associate with \a srcV (optional) + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0): + AssureGeomPublished( self.mesh, edge ) + AssureGeomPublished( self.mesh, srcV ) + AssureGeomPublished( self.mesh, tgtV ) + hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV], + UseExisting=0) + # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis + #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge) + hyp.SetSourceEdge( edge ) + if not mesh is None and isinstance(mesh, Mesh): + mesh = mesh.GetMesh() + hyp.SetSourceMesh( mesh ) + hyp.SetVertexAssociation( srcV, tgtV ) + return hyp + + pass # end of StdMeshersBuilder_Projection1D class + +## Defines a projection 2D algorithm +# +# It is created by calling smesh.Mesh.Projection2D(geom=0) +# +# @ingroup l3_algos_proj +class StdMeshersBuilder_Projection2D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Projection2D" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Projection_2D" + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates projection 2D algorithm for faces" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "Source Face" hypothesis, specifying a meshed face, from where + # a mesh pattern is taken, and, optionally, the association of vertices + # between the source face and the target face (to which a hypothesis is assigned) + # @param face from which the mesh pattern is taken + # @param mesh from which the mesh pattern is taken (optional) + # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional) + # @param tgtV1 a vertex of \a the face to which the algorithm is assigned, + # to associate with \a srcV1 (optional) + # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional) + # @param tgtV2 a vertex of \a the face to which the algorithm is assigned, + # to associate with \a srcV2 (optional) + # @param UseExisting if ==true - forces the search for the existing hypothesis created with + # the same parameters, else (default) - forces the creation a new one + # + # Note: all association vertices must belong to one edge of a face + def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None, + srcV2=None, tgtV2=None, UseExisting=0): + from salome.smesh.smeshBuilder import Mesh + if isinstance(mesh, Mesh): + mesh = mesh.GetMesh() + for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]: + AssureGeomPublished( self.mesh, geom ) + hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2], + UseExisting=0) + # it does not seem to be useful to reuse the existing "SourceFace" hypothesis + #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace) + hyp.SetSourceFace( face ) + hyp.SetSourceMesh( mesh ) + hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 ) + return hyp + + pass # end of StdMeshersBuilder_Projection2D class + +## Defines a projection 1D-2D algorithm +# +# It is created by calling smesh.Mesh.Projection1D2D(geom=0) +# +# @ingroup l3_algos_proj +class StdMeshersBuilder_Projection1D2D(StdMeshersBuilder_Projection2D): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Projection1D2D" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Projection_1D2D" + ## doc string of the method + # @internal + docHelper = "Creates projection 1D-2D algorithm for edges and faces" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + StdMeshersBuilder_Projection2D.__init__(self, mesh, geom) + pass + + pass # end of StdMeshersBuilder_Projection1D2D class + +## Defines a projection 3D algorithm +# +# It is created by calling smesh.Mesh.Projection3D(geom=0) +# +# @ingroup l3_algos_proj +class StdMeshersBuilder_Projection3D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Projection3D" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Projection_3D" + ## doc string of the method + # @internal + docHelper = "Creates projection 3D algorithm for volumes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where + # the mesh pattern is taken, and, optionally, the association of vertices + # between the source and the target solid (to which a hipothesis is assigned) + # @param solid from where the mesh pattern is taken + # @param mesh from where the mesh pattern is taken (optional) + # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional) + # @param tgtV1 a vertex of \a the solid where the algorithm is assigned, + # to associate with \a srcV1 (optional) + # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional) + # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned, + # to associate with \a srcV2 (optional) + # @param UseExisting - if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + # + # Note: association vertices must belong to one edge of a solid + def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0, + srcV2=0, tgtV2=0, UseExisting=0): + for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]: + AssureGeomPublished( self.mesh, geom ) + hyp = self.Hypothesis("ProjectionSource3D", + [solid,mesh,srcV1,tgtV1,srcV2,tgtV2], + UseExisting=0) + # seems to be not really useful to reuse existing "SourceShape3D" hypothesis + #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D) + hyp.SetSource3DShape( solid ) + if isinstance(mesh, Mesh): + mesh = mesh.GetMesh() + if mesh: + hyp.SetSourceMesh( mesh ) + if srcV1 and srcV2 and tgtV1 and tgtV2: + hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 ) + #elif srcV1 or srcV2 or tgtV1 or tgtV2: + return hyp + + pass # end of StdMeshersBuilder_Projection3D class + +## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" +# depending on geometry +# +# It is created by calling smesh.Mesh.Prism(geom=0) +# +# @ingroup l3_algos_3dextr +class StdMeshersBuilder_Prism3D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Prism" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Prism_3D" + ## doc string of the method + # @internal + docHelper = "Creates prism 3D algorithm for volumes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + + shape = geom + if not shape: + shape = mesh.geom + from geompy import SubShapeAll, ShapeType + nbSolids = len( SubShapeAll( shape, ShapeType["SOLID"] )) + nbShells = len( SubShapeAll( shape, ShapeType["SHELL"] )) + if nbSolids == 0 or nbSolids == nbShells: + self.Create(mesh, geom, "Prism_3D") + pass + else: + self.algoType = "RadialPrism_3D" + self.Create(mesh, geom, "RadialPrism_3D") + self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0) + self.nbLayers = None + pass + pass + + ## Return 3D hypothesis holding the 1D one + def Get3DHypothesis(self): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + return self.distribHyp + + ## Private method creating a 1D hypothesis and storing it in the LayerDistribution + # hypothesis. Returns the created hypothesis + def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + if not self.nbLayers is None: + self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers ) + self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp ) + study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis + self.mesh.smeshpyD.SetCurrentStudy( None ) + hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so) + self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing + if not self.distribHyp: + self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0) + self.distribHyp.SetLayerDistribution( hyp ) + return hyp + + ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of + # prisms to build between the inner and outer shells + # @param n number of layers + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def NumberOfLayers(self, n, UseExisting=0): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + self.mesh.RemoveHypothesis( self.distribHyp, self.geom ) + compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0]) + self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting, + CompareMethod=compFun) + self.nbLayers.SetNumberOfLayers( n ) + return self.nbLayers + + ## Defines "LocalLength" hypothesis, specifying the segment length + # to build between the inner and the outer shells + # @param l the length of segments + # @param p the precision of rounding + def LocalLength(self, l, p=1e-07): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + hyp = self.OwnHypothesis("LocalLength", [l,p]) + hyp.SetLength(l) + hyp.SetPrecision(p) + return hyp + + ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of + # prisms to build between the inner and the outer shells. + # @param n the number of layers + # @param s the scale factor (optional) + def NumberOfSegments(self, n, s=[]): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + if s == []: + hyp = self.OwnHypothesis("NumberOfSegments", [n]) + else: + hyp = self.OwnHypothesis("NumberOfSegments", [n,s]) + hyp.SetDistrType( 1 ) + hyp.SetScaleFactor(s) + hyp.SetNumberOfSegments(n) + return hyp + + ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments + # to build between the inner and the outer shells with a length that changes in arithmetic progression + # @param start the length of the first segment + # @param end the length of the last segment + def Arithmetic1D(self, start, end ): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + hyp = self.OwnHypothesis("Arithmetic1D", [start, end]) + hyp.SetLength(start, 1) + hyp.SetLength(end , 0) + return hyp + + ## Defines "StartEndLength" hypothesis, specifying distribution of segments + # to build between the inner and the outer shells as geometric length increasing + # @param start for the length of the first segment + # @param end for the length of the last segment + def StartEndLength(self, start, end): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + hyp = self.OwnHypothesis("StartEndLength", [start, end]) + hyp.SetLength(start, 1) + hyp.SetLength(end , 0) + return hyp + + ## Defines "AutomaticLength" hypothesis, specifying the number of segments + # to build between the inner and outer shells + # @param fineness defines the quality of the mesh within the range [0-1] + def AutomaticLength(self, fineness=0): + if self.algoType != "RadialPrism_3D": + print "Prism_3D algorith doesn't support any hyposesis" + return None + hyp = self.OwnHypothesis("AutomaticLength") + hyp.SetFineness( fineness ) + return hyp + + pass # end of StdMeshersBuilder_Prism3D class + +## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" +# depending on geometry +# +# It is created by calling smesh.Mesh.Prism(geom=0) +# +# @ingroup l3_algos_3dextr +class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Prism" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "RadialPrism_3D" + ## doc string of the method + # @internal + docHelper = "Creates prism 3D algorithm for volumes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + + shape = geom + if not shape: + shape = mesh.geom + self.Create(mesh, geom, "RadialPrism_3D") + self.distribHyp = None + self.nbLayers = None + return + +## Defines a Radial Quadrangle 1D-2D algorithm +# +# It is created by calling smesh.Mesh.Quadrangle(smesh.RADIAL_QUAD,geom=0) +# +# @ingroup l2_algos_radialq +class StdMeshersBuilder_RadialQuadrangle1D2D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "Quadrangle" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = RADIAL_QUAD + ## doc string of the method + # @internal + docHelper = "Creates quadrangle 1D-2D algorithm for triangular faces" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + + self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0) + self.nbLayers = None + pass + + ## Return 2D hypothesis holding the 1D one + def Get2DHypothesis(self): + if not self.distribHyp: + self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0) + return self.distribHyp + + ## Private method creating a 1D hypothesis and storing it in the LayerDistribution + # hypothesis. Returns the created hypothesis + def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"): + if self.nbLayers: + self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers ) + if self.distribHyp is None: + self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0) + else: + self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp ) + study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis + self.mesh.smeshpyD.SetCurrentStudy( None ) + hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so) + self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing + self.distribHyp.SetLayerDistribution( hyp ) + return hyp + + ## Defines "NumberOfLayers" hypothesis, specifying the number of layers + # @param n number of layers + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def NumberOfLayers(self, n, UseExisting=0): + if self.distribHyp: + self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp ) + compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0]) + self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting, + CompareMethod=compFun) + self.nbLayers.SetNumberOfLayers( n ) + return self.nbLayers + + ## Defines "LocalLength" hypothesis, specifying the segment length + # @param l the length of segments + # @param p the precision of rounding + def LocalLength(self, l, p=1e-07): + hyp = self.OwnHypothesis("LocalLength", [l,p]) + hyp.SetLength(l) + hyp.SetPrecision(p) + return hyp + + ## Defines "NumberOfSegments" hypothesis, specifying the number of layers + # @param n the number of layers + # @param s the scale factor (optional) + def NumberOfSegments(self, n, s=[]): + if s == []: + hyp = self.OwnHypothesis("NumberOfSegments", [n]) + else: + hyp = self.OwnHypothesis("NumberOfSegments", [n,s]) + hyp.SetDistrType( 1 ) + hyp.SetScaleFactor(s) + hyp.SetNumberOfSegments(n) + return hyp + + ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments + # with a length that changes in arithmetic progression + # @param start the length of the first segment + # @param end the length of the last segment + def Arithmetic1D(self, start, end ): + hyp = self.OwnHypothesis("Arithmetic1D", [start, end]) + hyp.SetLength(start, 1) + hyp.SetLength(end , 0) + return hyp + + ## Defines "StartEndLength" hypothesis, specifying distribution of segments + # as geometric length increasing + # @param start for the length of the first segment + # @param end for the length of the last segment + def StartEndLength(self, start, end): + hyp = self.OwnHypothesis("StartEndLength", [start, end]) + hyp.SetLength(start, 1) + hyp.SetLength(end , 0) + return hyp + + ## Defines "AutomaticLength" hypothesis, specifying the number of segments + # @param fineness defines the quality of the mesh within the range [0-1] + def AutomaticLength(self, fineness=0): + hyp = self.OwnHypothesis("AutomaticLength") + hyp.SetFineness( fineness ) + return hyp + + pass # end of StdMeshersBuilder_RadialQuadrangle1D2D class + +## Defines a Use Existing Elements 1D algorithm +# +# It is created by calling smesh.Mesh.UseExisting1DElements(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_UseExistingElements_1D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "UseExisting1DElements" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Import_1D" + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "Source edges" hypothesis, specifying groups of edges to import + # @param groups list of groups of edges + # @param toCopyMesh if True, the whole mesh \a groups belong to is imported + # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False): + for group in groups: + AssureGeomPublished( self.mesh, group ) + compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \ + hyp.GetCopySourceMesh() == args[1], args[2] ) + hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups], + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetSourceEdges(groups) + hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups) + return hyp + + pass # end of StdMeshersBuilder_UseExistingElements_1D class + +## Defines a Use Existing Elements 1D-2D algorithm +# +# It is created by calling smesh.Mesh.UseExisting2DElements(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_UseExistingElements_1D2D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "UseExisting2DElements" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Import_1D2D" + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + self.Create(mesh, geom, self.algoType) + pass + + ## Defines "Source faces" hypothesis, specifying groups of faces to import + # @param groups list of groups of faces + # @param toCopyMesh if True, the whole mesh \a groups belong to is imported + # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False): + for group in groups: + AssureGeomPublished( self.mesh, group ) + compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \ + hyp.GetCopySourceMesh() == args[1], args[2] ) + hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups], + UseExisting=UseExisting, CompareMethod=compFun) + hyp.SetSourceFaces(groups) + hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups) + return hyp + + pass # end of StdMeshersBuilder_UseExistingElements_1D2D class + +## Defines a Body Fitting 3D algorithm +# +# It is created by calling smesh.Mesh.BodyFitted(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_Cartesian_3D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "BodyFitted" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "Cartesian_3D" + ## flag pointing either this algorithm should be used by default in dynamic method + # of smesh.Mesh class + # @internal + isDefault = True + ## doc string of the method + # @internal + docHelper = "Creates body fitting 3D algorithm for volumes" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + self.Create(mesh, geom, self.algoType) + self.hyp = None + pass + + ## Defines "Body Fitting parameters" hypothesis + # @param xGridDef is definition of the grid along the X asix. + # It can be in either of two following forms: + # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10) + # - Functions f(t) defining grid spacing at each point on grid axis. If there are + # several functions, they must be accompanied by relative coordinates of + # points dividing the whole shape into ranges where the functions apply; points + # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing + # function f(t) varies from 0.0 to 1.0 witin a shape range. + # Examples: + # - "10.5" - defines a grid with a constant spacing + # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges. + # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does + # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does + # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that + # a polyhedron of size less than hexSize/sizeThreshold is not created + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False): + if not self.hyp: + compFun = lambda hyp, args: False + self.hyp = self.Hypothesis("CartesianParameters3D", + [xGridDef, yGridDef, zGridDef, sizeThreshold], + UseExisting=UseExisting, CompareMethod=compFun) + if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ): + self.mesh.AddHypothesis( self.hyp, self.geom ) + + for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]): + if not gridDef: raise ValueError, "Empty grid definition" + if isinstance( gridDef, str ): + self.hyp.SetGridSpacing( [gridDef], [], axis ) + elif isinstance( gridDef[0], str ): + self.hyp.SetGridSpacing( gridDef, [], axis ) + elif isinstance( gridDef[0], int ) or \ + isinstance( gridDef[0], float ): + self.hyp.SetGrid(gridDef, axis ) + else: + self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis ) + self.hyp.SetSizeThreshold( sizeThreshold ) + return self.hyp + + pass # end of StdMeshersBuilder_Cartesian_3D class + +## Defines a stub 1D algorithm, which enables "manual" creation of nodes and +# segments usable by 2D algoritms +# +# It is created by calling smesh.Mesh.UseExistingSegments(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_UseExisting_1D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "UseExistingSegments" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "UseExisting_1D" + ## doc string of the method + # @internal + docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + self.Create(mesh, geom, self.algoType) + pass + + pass # end of StdMeshersBuilder_UseExisting_1D class + +## Defines a stub 2D algorithm, which enables "manual" creation of nodes and +# faces usable by 3D algoritms +# +# It is created by calling smesh.Mesh.UseExistingFaces(geom=0) +# +# @ingroup l3_algos_basic +class StdMeshersBuilder_UseExisting_2D(Mesh_Algorithm): + + ## name of the dynamic method in smesh.Mesh class + # @internal + meshMethod = "UseExistingFaces" + ## type of algorithm used with helper function in smesh.Mesh class + # @internal + algoType = "UseExisting_2D" + ## doc string of the method + # @internal + docHelper = "Creates 2D algorithm for faces with reusing of existing mesh elements" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + self.Create(mesh, geom, self.algoType) + pass + + pass # end of StdMeshersBuilder_UseExisting_2D class diff --git a/src/SMESH_SWIG/StdMeshersDC.py b/src/SMESH_SWIG/StdMeshersDC.py deleted file mode 100644 index 3e1abf1d3..000000000 --- a/src/SMESH_SWIG/StdMeshersDC.py +++ /dev/null @@ -1,1361 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -## -# @package StdMeshersDC -# Python API for the standard meshing plug-in module. - -from smesh_algorithm import Mesh_Algorithm -from smesh import AssureGeomPublished, IsEqual, ParseParameters -from smesh import GetName, TreatHypoStatus -from smeshDC import Mesh - -import StdMeshers - -#---------------------------- -# Mesh algo type identifiers -#---------------------------- - -## Algorithm type: Regular 1D algorithm, see StdMeshersDC_Segment -REGULAR = "Regular_1D" -## Algorithm type: Python 1D algorithm, see StdMeshersDC_Segment_Python -PYTHON = "Python_1D" -## Algorithm type: Composite segment 1D algorithm, see StdMeshersDC_CompositeSegment -COMPOSITE = "CompositeSegment_1D" -## Algorithm type: Triangle MEFISTO 2D algorithm, see StdMeshersDC_Triangle_MEFISTO -MEFISTO = "MEFISTO_2D" -## Algorithm type: Hexahedron 3D (i-j-k) algorithm, see StdMeshersDC_Hexahedron -Hexa = "Hexa_3D" -## Algorithm type: Quadrangle 2D algorithm, see StdMeshersDC_Quadrangle -QUADRANGLE = "Quadrangle_2D" -## Algorithm type: Radial Quadrangle 1D-2D algorithm, see StdMeshersDC_RadialQuadrangle1D2D -RADIAL_QUAD = "RadialQuadrangle_1D2D" - -# import items of enum QuadType -for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e)) - -#---------------------- -# Algorithms -#---------------------- - -## Defines segment 1D algorithm for edges discretization. -# -# It can be created by calling smesh.Mesh.Segment(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Segment(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Segment" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = REGULAR - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates segment 1D algorithm for edges" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length - # @param l for the length of segments that cut an edge - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @param p precision, used for calculation of the number of segments. - # The precision should be a positive, meaningful value within the range [0,1]. - # In general, the number of segments is calculated with the formula: - # nb = ceil((edge_length / l) - p) - # Function ceil rounds its argument to the higher integer. - # So, p=0 means rounding of (edge_length / l) to the higher integer, - # p=0.5 means rounding of (edge_length / l) to the nearest integer, - # p=1 means rounding of (edge_length / l) to the lower integer. - # Default value is 1e-07. - # @return an instance of StdMeshers_LocalLength hypothesis - # @ingroup l3_hypos_1dhyps - def LocalLength(self, l, UseExisting=0, p=1e-07): - comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1]) - hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun) - hyp.SetLength(l) - hyp.SetPrecision(p) - return hyp - - ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value - # @param length is optional maximal allowed length of segment, if it is omitted - # the preestimated length is used that depends on geometry size - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @return an instance of StdMeshers_MaxLength hypothesis - # @ingroup l3_hypos_1dhyps - def MaxSize(self, length=0.0, UseExisting=0): - hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting) - if length > 0.0: - # set given length - hyp.SetLength(length) - if not UseExisting: - # set preestimated length - gen = self.mesh.smeshpyD - initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so", - self.mesh.GetMesh(), self.mesh.GetShape(), - False) # <- byMesh - preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength) - if preHyp: - hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() ) - pass - pass - hyp.SetUsePreestimatedLength( length == 0.0 ) - return hyp - - ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments - # @param n for the number of segments that cut an edge - # @param s for the scale factor (optional) - # @param reversedEdges is a list of edges to mesh using reversed orientation. - # A list item can also be a tuple (edge, 1st_vertex_of_edge) - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - create a new one - # @return an instance of StdMeshers_NumberOfSegments hypothesis - # @ingroup l3_hypos_1dhyps - def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0): - if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges - reversedEdges, UseExisting = [], reversedEdges - entry = self.MainShapeEntry() - reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) - if s == []: - hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry], - UseExisting=UseExisting, - CompareMethod=self._compareNumberOfSegments) - else: - hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry], - UseExisting=UseExisting, - CompareMethod=self._compareNumberOfSegments) - hyp.SetDistrType( 1 ) - hyp.SetScaleFactor(s) - hyp.SetNumberOfSegments(n) - hyp.SetReversedEdges( reversedEdgeInd ) - hyp.SetObjectEntry( entry ) - return hyp - - ## Private method - # - # Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments - def _compareNumberOfSegments(self, hyp, args): - if hyp.GetNumberOfSegments() == args[0]: - if len(args) == 3: - if hyp.GetReversedEdges() == args[1]: - if not args[1] or hyp.GetObjectEntry() == args[2]: - return True - else: - if hyp.GetReversedEdges() == args[2]: - if not args[2] or hyp.GetObjectEntry() == args[3]: - if hyp.GetDistrType() == 1: - if IsEqual(hyp.GetScaleFactor(), args[1]): - return True - return False - - ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length - # @param start defines the length of the first segment - # @param end defines the length of the last segment - # @param reversedEdges is a list of edges to mesh using reversed orientation. - # A list item can also be a tuple (edge, 1st_vertex_of_edge) - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @return an instance of StdMeshers_Arithmetic1D hypothesis - # @ingroup l3_hypos_1dhyps - def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0): - if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges - reversedEdges, UseExisting = [], reversedEdges - reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) - entry = self.MainShapeEntry() - compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \ - IsEqual(hyp.GetLength(0), args[1]) and \ - hyp.GetReversedEdges() == args[2] and \ - (not args[2] or hyp.GetObjectEntry() == args[3])) - hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry], - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetStartLength(start) - hyp.SetEndLength(end) - hyp.SetReversedEdges( reversedEdgeInd ) - hyp.SetObjectEntry( entry ) - return hyp - - ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter - # on curve from 0 to 1 (additionally it is neecessary to check - # orientation of edges and create list of reversed edges if it is - # needed) and sets numbers of segments between given points (default - # values are equals 1 - # @param points defines the list of parameters on curve - # @param nbSegs defines the list of numbers of segments - # @param reversedEdges is a list of edges to mesh using reversed orientation. - # A list item can also be a tuple (edge, 1st_vertex_of_edge) - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @return an instance of StdMeshers_Arithmetic1D hypothesis - # @ingroup l3_hypos_1dhyps - def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0): - if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges - reversedEdges, UseExisting = [], reversedEdges - reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) - entry = self.MainShapeEntry() - compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \ - hyp.GetNbSegments() == args[1] and \ - hyp.GetReversedEdges() == args[2] and \ - (not args[2] or hyp.GetObjectEntry() == args[3])) - hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry], - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetPoints(points) - hyp.SetNbSegments(nbSegs) - hyp.SetReversedEdges(reversedEdgeInd) - hyp.SetObjectEntry(entry) - return hyp - - ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length - # @param start defines the length of the first segment - # @param end defines the length of the last segment - # @param reversedEdges is a list of edges to mesh using reversed orientation. - # A list item can also be a tuple (edge, 1st_vertex_of_edge) - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @return an instance of StdMeshers_StartEndLength hypothesis - # @ingroup l3_hypos_1dhyps - def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0): - if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges - reversedEdges, UseExisting = [], reversedEdges - reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges) - entry = self.MainShapeEntry() - compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \ - IsEqual(hyp.GetLength(0), args[1]) and \ - hyp.GetReversedEdges() == args[2] and \ - (not args[2] or hyp.GetObjectEntry() == args[3])) - hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry], - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetStartLength(start) - hyp.SetEndLength(end) - hyp.SetReversedEdges( reversedEdgeInd ) - hyp.SetObjectEntry( entry ) - return hyp - - ## Defines "Deflection1D" hypothesis - # @param d for the deflection - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - create a new one - # @ingroup l3_hypos_1dhyps - def Deflection1D(self, d, UseExisting=0): - compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0]) - hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetDeflection(d) - return hyp - - ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at - # the opposite side in case of quadrangular faces - # @ingroup l3_hypos_additi - def Propagation(self): - return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp) - - ## Defines "AutomaticLength" hypothesis - # @param fineness for the fineness [0-1] - # @param UseExisting if ==true - searches for an existing hypothesis created with the - # same parameters, else (default) - create a new one - # @ingroup l3_hypos_1dhyps - def AutomaticLength(self, fineness=0, UseExisting=0): - compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0]) - hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting, - CompareMethod=compFun) - hyp.SetFineness( fineness ) - return hyp - - ## Defines "SegmentLengthAroundVertex" hypothesis - # @param length for the segment length - # @param vertex for the length localization: the vertex index [0,1] | vertex object. - # Any other integer value means that the hypothesis will be set on the - # whole 1D shape, where Mesh_Segment algorithm is assigned. - # @param UseExisting if ==true - searches for an existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_algos_segmarv - def LengthNearVertex(self, length, vertex=0, UseExisting=0): - import types - store_geom = self.geom - if type(vertex) is types.IntType: - if vertex == 0 or vertex == 1: - import geompyDC - vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex] - self.geom = vertex - pass - pass - else: - self.geom = vertex - pass - # 0D algorithm - if self.geom is None: - raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape" - AssureGeomPublished( self.mesh, self.geom ) - name = GetName(self.geom) - - algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD) - if algo is None: - algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so") - pass - status = self.mesh.mesh.AddHypothesis(self.geom, algo) - TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True) - # - comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) - hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting, - CompareMethod=comFun) - self.geom = store_geom - hyp.SetLength( length ) - return hyp - - ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges. - # If the 2D mesher sees that all boundary edges are quadratic, - # it generates quadratic faces, else it generates linear faces using - # medium nodes as if they are vertices. - # The 3D mesher generates quadratic volumes only if all boundary faces - # are quadratic, else it fails. - # - # @ingroup l3_hypos_additi - def QuadraticMesh(self): - hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp) - return hyp - - pass # end of StdMeshersDC_Segment class - -## Segment 1D algorithm for discretization of a set of adjacent edges as one edge. -# -# It is created by calling smesh.Mesh.Segment(smesh.COMPOSITE,geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_CompositeSegment(StdMeshersDC_Segment): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Segment" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = COMPOSITE - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = False - ## doc string of the method - # @internal - docHelper = "Creates segment 1D algorithm for edges" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - self.Create(mesh, geom, self.algoType) - pass - - pass # end of StdMeshersDC_CompositeSegment class - -## Defines a segment 1D algorithm for discretization of edges with Python function -# -# It is created by calling smesh.Mesh.Segment(smesh.PYTHON,geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Segment_Python(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Segment" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = PYTHON - ## doc string of the method - # @internal - docHelper = "Creates tetrahedron 3D algorithm for solids" - ## doc string of the method - # @internal - docHelper = "Creates segment 1D algorithm for edges" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - import Python1dPlugin - self.Create(mesh, geom, self.algoType, "libPython1dEngine.so") - pass - - ## Defines "PythonSplit1D" hypothesis - # @param n for the number of segments that cut an edge - # @param func for the python function that calculates the length of all segments - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_1dhyps - def PythonSplit1D(self, n, func, UseExisting=0): - compFun = lambda hyp, args: False - hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so", - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetNumberOfSegments(n) - hyp.SetPythonLog10RatioFunction(func) - return hyp - - pass # end of StdMeshersDC_Segment_Python class - -## Triangle MEFISTO 2D algorithm -# -# It is created by calling smesh.Mesh.Triangle(smesh.MEFISTO,geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Triangle_MEFISTO(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Triangle" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = MEFISTO - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates triangle 2D algorithm for faces" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle - # @param area for the maximum area of each triangle - # @param UseExisting if ==true - searches for an existing hypothesis created with the - # same parameters, else (default) - creates a new one - # - # @ingroup l3_hypos_2dhyps - def MaxElementArea(self, area, UseExisting=0): - comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0]) - hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting, - CompareMethod=comparator) - hyp.SetMaxElementArea(area) - return hyp - - ## Defines "LengthFromEdges" hypothesis to build triangles - # based on the length of the edges taken from the wire - # - # @ingroup l3_hypos_2dhyps - def LengthFromEdges(self): - hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) - return hyp - - pass # end of StdMeshersDC_Triangle_MEFISTO class - -## Defines a quadrangle 2D algorithm -# -# It is created by calling smesh.Mesh.Quadrangle(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Quadrangle(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Quadrangle" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = QUADRANGLE - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates quadrangle 2D algorithm for faces" - ## hypothesis associated with algorithm - # @internal - params = 0 - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "QuadrangleParameters" hypothesis - # @param quadType defines the algorithm of transition between differently descretized - # sides of a geometrical face: - # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition - # area along the finer meshed sides. - # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the - # finer meshed sides. - # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along - # the finer meshed sides, iff the total quantity of segments on - # all four sides of the face is even (divisible by 2). - # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition - # area is located along the coarser meshed sides. - # - QUAD_REDUCED - only quadrangles are built and the transition between the sides - # is made gradually, layer by layer. This type has a limitation on - # the number of segments: one pair of opposite sides must have the - # same number of segments, the other pair must have an even difference - # between the numbers of segments on the sides. - # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles - # will be created while other elements will be quadrangles. - # Vertex can be either a GEOM_Object or a vertex ID within the - # shape to mesh - # @param UseExisting: if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_quad - def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0): - import GEOM - vertexID = triangleVertex - if isinstance( triangleVertex, GEOM._objref_GEOM_Object ): - vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex ) - if not self.params: - compFun = lambda hyp,args: \ - hyp.GetQuadType() == args[0] and \ - ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1)) - self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID], - UseExisting = UseExisting, CompareMethod=compFun) - pass - if self.params.GetQuadType() != quadType: - self.params.SetQuadType(quadType) - if vertexID > 0: - self.params.SetTriaVertex( vertexID ) - return self.params - - ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only - # quadrangles are built in the transition area along the finer meshed sides, - # iff the total quantity of segments on all four sides of the face is even. - # @param reversed if True, transition area is located along the coarser meshed sides. - # @param UseExisting: if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_quad - def QuadranglePreference(self, reversed=False, UseExisting=0): - if reversed: - return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting) - return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting) - - ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only - # triangles are built in the transition area along the finer meshed sides. - # @param UseExisting: if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_quad - def TrianglePreference(self, UseExisting=0): - return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting) - - ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only - # quadrangles are built and the transition between the sides is made gradually, - # layer by layer. This type has a limitation on the number of segments: one pair - # of opposite sides must have the same number of segments, the other pair must - # have an even difference between the numbers of segments on the sides. - # @param UseExisting: if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_quad - def Reduced(self, UseExisting=0): - return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting) - - ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation - # @param vertex: vertex of a trilateral geometrical face, around which triangles - # will be created while other elements will be quadrangles. - # Vertex can be either a GEOM_Object or a vertex ID within the - # shape to mesh - # @param UseExisting: if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # @ingroup l3_hypos_quad - def TriangleVertex(self, vertex, UseExisting=0): - return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting) - - pass # end of StdMeshersDC_Quadrangle class - -## Defines a hexahedron 3D algorithm -# -# It is created by calling smesh.Mesh.Hexahedron(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Hexahedron(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Hexahedron" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = Hexa - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates hexahedron 3D algorithm for volumes" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, Hexa) - pass - - pass # end of StdMeshersDC_Hexahedron class - -## Defines a projection 1D algorithm -# -# It is created by calling smesh.Mesh.Projection1D(geom=0) -# -# @ingroup l3_algos_proj -class StdMeshersDC_Projection1D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Projection1D" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Projection_1D" - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates projection 1D algorithm for edges" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where - # a mesh pattern is taken, and, optionally, the association of vertices - # between the source edge and a target edge (to which a hypothesis is assigned) - # @param edge from which nodes distribution is taken - # @param mesh from which nodes distribution is taken (optional) - # @param srcV a vertex of \a edge to associate with \a tgtV (optional) - # @param tgtV a vertex of \a the edge to which the algorithm is assigned, - # to associate with \a srcV (optional) - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0): - AssureGeomPublished( self.mesh, edge ) - AssureGeomPublished( self.mesh, srcV ) - AssureGeomPublished( self.mesh, tgtV ) - hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV], - UseExisting=0) - # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis - #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge) - hyp.SetSourceEdge( edge ) - if not mesh is None and isinstance(mesh, Mesh): - mesh = mesh.GetMesh() - hyp.SetSourceMesh( mesh ) - hyp.SetVertexAssociation( srcV, tgtV ) - return hyp - - pass # end of StdMeshersDC_Projection1D class - -## Defines a projection 2D algorithm -# -# It is created by calling smesh.Mesh.Projection2D(geom=0) -# -# @ingroup l3_algos_proj -class StdMeshersDC_Projection2D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Projection2D" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Projection_2D" - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates projection 2D algorithm for faces" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "Source Face" hypothesis, specifying a meshed face, from where - # a mesh pattern is taken, and, optionally, the association of vertices - # between the source face and the target face (to which a hypothesis is assigned) - # @param face from which the mesh pattern is taken - # @param mesh from which the mesh pattern is taken (optional) - # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional) - # @param tgtV1 a vertex of \a the face to which the algorithm is assigned, - # to associate with \a srcV1 (optional) - # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional) - # @param tgtV2 a vertex of \a the face to which the algorithm is assigned, - # to associate with \a srcV2 (optional) - # @param UseExisting if ==true - forces the search for the existing hypothesis created with - # the same parameters, else (default) - forces the creation a new one - # - # Note: all association vertices must belong to one edge of a face - def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None, - srcV2=None, tgtV2=None, UseExisting=0): - from smeshDC import Mesh - if isinstance(mesh, Mesh): - mesh = mesh.GetMesh() - for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]: - AssureGeomPublished( self.mesh, geom ) - hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2], - UseExisting=0) - # it does not seem to be useful to reuse the existing "SourceFace" hypothesis - #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace) - hyp.SetSourceFace( face ) - hyp.SetSourceMesh( mesh ) - hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 ) - return hyp - - pass # end of StdMeshersDC_Projection2D class - -## Defines a projection 1D-2D algorithm -# -# It is created by calling smesh.Mesh.Projection1D2D(geom=0) -# -# @ingroup l3_algos_proj -class StdMeshersDC_Projection1D2D(StdMeshersDC_Projection2D): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Projection1D2D" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Projection_1D2D" - ## doc string of the method - # @internal - docHelper = "Creates projection 1D-2D algorithm for edges and faces" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - StdMeshersDC_Projection2D.__init__(self, mesh, geom) - pass - - pass # end of StdMeshersDC_Projection1D2D class - -## Defines a projection 3D algorithm -# -# It is created by calling smesh.Mesh.Projection3D(geom=0) -# -# @ingroup l3_algos_proj -class StdMeshersDC_Projection3D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Projection3D" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Projection_3D" - ## doc string of the method - # @internal - docHelper = "Creates projection 3D algorithm for volumes" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where - # the mesh pattern is taken, and, optionally, the association of vertices - # between the source and the target solid (to which a hipothesis is assigned) - # @param solid from where the mesh pattern is taken - # @param mesh from where the mesh pattern is taken (optional) - # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional) - # @param tgtV1 a vertex of \a the solid where the algorithm is assigned, - # to associate with \a srcV1 (optional) - # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional) - # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned, - # to associate with \a srcV2 (optional) - # @param UseExisting - if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - # - # Note: association vertices must belong to one edge of a solid - def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0, - srcV2=0, tgtV2=0, UseExisting=0): - for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]: - AssureGeomPublished( self.mesh, geom ) - hyp = self.Hypothesis("ProjectionSource3D", - [solid,mesh,srcV1,tgtV1,srcV2,tgtV2], - UseExisting=0) - # seems to be not really useful to reuse existing "SourceShape3D" hypothesis - #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D) - hyp.SetSource3DShape( solid ) - if isinstance(mesh, Mesh): - mesh = mesh.GetMesh() - if mesh: - hyp.SetSourceMesh( mesh ) - if srcV1 and srcV2 and tgtV1 and tgtV2: - hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 ) - #elif srcV1 or srcV2 or tgtV1 or tgtV2: - return hyp - - pass # end of StdMeshersDC_Projection3D class - -## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" -# depending on geometry -# -# It is created by calling smesh.Mesh.Prism(geom=0) -# -# @ingroup l3_algos_3dextr -class StdMeshersDC_Prism3D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Prism" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Prism_3D" - ## doc string of the method - # @internal - docHelper = "Creates prism 3D algorithm for volumes" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - - shape = geom - if not shape: - shape = mesh.geom - from geompy import SubShapeAll, ShapeType - nbSolids = len( SubShapeAll( shape, ShapeType["SOLID"] )) - nbShells = len( SubShapeAll( shape, ShapeType["SHELL"] )) - if nbSolids == 0 or nbSolids == nbShells: - self.Create(mesh, geom, "Prism_3D") - pass - else: - self.algoType = "RadialPrism_3D" - self.Create(mesh, geom, "RadialPrism_3D") - self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0) - self.nbLayers = None - pass - pass - - ## Return 3D hypothesis holding the 1D one - def Get3DHypothesis(self): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - return self.distribHyp - - ## Private method creating a 1D hypothesis and storing it in the LayerDistribution - # hypothesis. Returns the created hypothesis - def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - if not self.nbLayers is None: - self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers ) - self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp ) - study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis - self.mesh.smeshpyD.SetCurrentStudy( None ) - hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so) - self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing - if not self.distribHyp: - self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0) - self.distribHyp.SetLayerDistribution( hyp ) - return hyp - - ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of - # prisms to build between the inner and outer shells - # @param n number of layers - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def NumberOfLayers(self, n, UseExisting=0): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - self.mesh.RemoveHypothesis( self.distribHyp, self.geom ) - compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0]) - self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting, - CompareMethod=compFun) - self.nbLayers.SetNumberOfLayers( n ) - return self.nbLayers - - ## Defines "LocalLength" hypothesis, specifying the segment length - # to build between the inner and the outer shells - # @param l the length of segments - # @param p the precision of rounding - def LocalLength(self, l, p=1e-07): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - hyp = self.OwnHypothesis("LocalLength", [l,p]) - hyp.SetLength(l) - hyp.SetPrecision(p) - return hyp - - ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of - # prisms to build between the inner and the outer shells. - # @param n the number of layers - # @param s the scale factor (optional) - def NumberOfSegments(self, n, s=[]): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - if s == []: - hyp = self.OwnHypothesis("NumberOfSegments", [n]) - else: - hyp = self.OwnHypothesis("NumberOfSegments", [n,s]) - hyp.SetDistrType( 1 ) - hyp.SetScaleFactor(s) - hyp.SetNumberOfSegments(n) - return hyp - - ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments - # to build between the inner and the outer shells with a length that changes in arithmetic progression - # @param start the length of the first segment - # @param end the length of the last segment - def Arithmetic1D(self, start, end ): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - hyp = self.OwnHypothesis("Arithmetic1D", [start, end]) - hyp.SetLength(start, 1) - hyp.SetLength(end , 0) - return hyp - - ## Defines "StartEndLength" hypothesis, specifying distribution of segments - # to build between the inner and the outer shells as geometric length increasing - # @param start for the length of the first segment - # @param end for the length of the last segment - def StartEndLength(self, start, end): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - hyp = self.OwnHypothesis("StartEndLength", [start, end]) - hyp.SetLength(start, 1) - hyp.SetLength(end , 0) - return hyp - - ## Defines "AutomaticLength" hypothesis, specifying the number of segments - # to build between the inner and outer shells - # @param fineness defines the quality of the mesh within the range [0-1] - def AutomaticLength(self, fineness=0): - if self.algoType != "RadialPrism_3D": - print "Prism_3D algorith doesn't support any hyposesis" - return None - hyp = self.OwnHypothesis("AutomaticLength") - hyp.SetFineness( fineness ) - return hyp - - pass # end of StdMeshersDC_Prism3D class - -## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" -# depending on geometry -# -# It is created by calling smesh.Mesh.Prism(geom=0) -# -# @ingroup l3_algos_3dextr -class StdMeshersDC_RadialPrism3D(StdMeshersDC_Prism3D): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Prism" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "RadialPrism_3D" - ## doc string of the method - # @internal - docHelper = "Creates prism 3D algorithm for volumes" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - - shape = geom - if not shape: - shape = mesh.geom - self.Create(mesh, geom, "RadialPrism_3D") - self.distribHyp = None - self.nbLayers = None - return - -## Defines a Radial Quadrangle 1D-2D algorithm -# -# It is created by calling smesh.Mesh.Quadrangle(smesh.RADIAL_QUAD,geom=0) -# -# @ingroup l2_algos_radialq -class StdMeshersDC_RadialQuadrangle1D2D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "Quadrangle" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = RADIAL_QUAD - ## doc string of the method - # @internal - docHelper = "Creates quadrangle 1D-2D algorithm for triangular faces" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - - self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0) - self.nbLayers = None - pass - - ## Return 2D hypothesis holding the 1D one - def Get2DHypothesis(self): - if not self.distribHyp: - self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0) - return self.distribHyp - - ## Private method creating a 1D hypothesis and storing it in the LayerDistribution - # hypothesis. Returns the created hypothesis - def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"): - if self.nbLayers: - self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers ) - if self.distribHyp is None: - self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0) - else: - self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp ) - study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis - self.mesh.smeshpyD.SetCurrentStudy( None ) - hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so) - self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing - self.distribHyp.SetLayerDistribution( hyp ) - return hyp - - ## Defines "NumberOfLayers" hypothesis, specifying the number of layers - # @param n number of layers - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def NumberOfLayers(self, n, UseExisting=0): - if self.distribHyp: - self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp ) - compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0]) - self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting, - CompareMethod=compFun) - self.nbLayers.SetNumberOfLayers( n ) - return self.nbLayers - - ## Defines "LocalLength" hypothesis, specifying the segment length - # @param l the length of segments - # @param p the precision of rounding - def LocalLength(self, l, p=1e-07): - hyp = self.OwnHypothesis("LocalLength", [l,p]) - hyp.SetLength(l) - hyp.SetPrecision(p) - return hyp - - ## Defines "NumberOfSegments" hypothesis, specifying the number of layers - # @param n the number of layers - # @param s the scale factor (optional) - def NumberOfSegments(self, n, s=[]): - if s == []: - hyp = self.OwnHypothesis("NumberOfSegments", [n]) - else: - hyp = self.OwnHypothesis("NumberOfSegments", [n,s]) - hyp.SetDistrType( 1 ) - hyp.SetScaleFactor(s) - hyp.SetNumberOfSegments(n) - return hyp - - ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments - # with a length that changes in arithmetic progression - # @param start the length of the first segment - # @param end the length of the last segment - def Arithmetic1D(self, start, end ): - hyp = self.OwnHypothesis("Arithmetic1D", [start, end]) - hyp.SetLength(start, 1) - hyp.SetLength(end , 0) - return hyp - - ## Defines "StartEndLength" hypothesis, specifying distribution of segments - # as geometric length increasing - # @param start for the length of the first segment - # @param end for the length of the last segment - def StartEndLength(self, start, end): - hyp = self.OwnHypothesis("StartEndLength", [start, end]) - hyp.SetLength(start, 1) - hyp.SetLength(end , 0) - return hyp - - ## Defines "AutomaticLength" hypothesis, specifying the number of segments - # @param fineness defines the quality of the mesh within the range [0-1] - def AutomaticLength(self, fineness=0): - hyp = self.OwnHypothesis("AutomaticLength") - hyp.SetFineness( fineness ) - return hyp - - pass # end of StdMeshersDC_RadialQuadrangle1D2D class - -## Defines a Use Existing Elements 1D algorithm -# -# It is created by calling smesh.Mesh.UseExisting1DElements(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_UseExistingElements_1D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "UseExisting1DElements" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Import_1D" - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "Source edges" hypothesis, specifying groups of edges to import - # @param groups list of groups of edges - # @param toCopyMesh if True, the whole mesh \a groups belong to is imported - # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False): - for group in groups: - AssureGeomPublished( self.mesh, group ) - compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \ - hyp.GetCopySourceMesh() == args[1], args[2] ) - hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups], - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetSourceEdges(groups) - hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups) - return hyp - - pass # end of StdMeshersDC_UseExistingElements_1D class - -## Defines a Use Existing Elements 1D-2D algorithm -# -# It is created by calling smesh.Mesh.UseExisting2DElements(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_UseExistingElements_1D2D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "UseExisting2DElements" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Import_1D2D" - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - Mesh_Algorithm.__init__(self) - self.Create(mesh, geom, self.algoType) - pass - - ## Defines "Source faces" hypothesis, specifying groups of faces to import - # @param groups list of groups of faces - # @param toCopyMesh if True, the whole mesh \a groups belong to is imported - # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False): - for group in groups: - AssureGeomPublished( self.mesh, group ) - compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \ - hyp.GetCopySourceMesh() == args[1], args[2] ) - hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups], - UseExisting=UseExisting, CompareMethod=compFun) - hyp.SetSourceFaces(groups) - hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups) - return hyp - - pass # end of StdMeshersDC_UseExistingElements_1D2D class - -## Defines a Body Fitting 3D algorithm -# -# It is created by calling smesh.Mesh.BodyFitted(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_Cartesian_3D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "BodyFitted" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "Cartesian_3D" - ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class - # @internal - isDefault = True - ## doc string of the method - # @internal - docHelper = "Creates body fitting 3D algorithm for volumes" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - self.Create(mesh, geom, self.algoType) - self.hyp = None - pass - - ## Defines "Body Fitting parameters" hypothesis - # @param xGridDef is definition of the grid along the X asix. - # It can be in either of two following forms: - # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10) - # - Functions f(t) defining grid spacing at each point on grid axis. If there are - # several functions, they must be accompanied by relative coordinates of - # points dividing the whole shape into ranges where the functions apply; points - # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing - # function f(t) varies from 0.0 to 1.0 witin a shape range. - # Examples: - # - "10.5" - defines a grid with a constant spacing - # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges. - # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does - # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does - # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that - # a polyhedron of size less than hexSize/sizeThreshold is not created - # @param UseExisting if ==true - searches for the existing hypothesis created with - # the same parameters, else (default) - creates a new one - def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False): - if not self.hyp: - compFun = lambda hyp, args: False - self.hyp = self.Hypothesis("CartesianParameters3D", - [xGridDef, yGridDef, zGridDef, sizeThreshold], - UseExisting=UseExisting, CompareMethod=compFun) - if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ): - self.mesh.AddHypothesis( self.hyp, self.geom ) - - for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]): - if not gridDef: raise ValueError, "Empty grid definition" - if isinstance( gridDef, str ): - self.hyp.SetGridSpacing( [gridDef], [], axis ) - elif isinstance( gridDef[0], str ): - self.hyp.SetGridSpacing( gridDef, [], axis ) - elif isinstance( gridDef[0], int ) or \ - isinstance( gridDef[0], float ): - self.hyp.SetGrid(gridDef, axis ) - else: - self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis ) - self.hyp.SetSizeThreshold( sizeThreshold ) - return self.hyp - - pass # end of StdMeshersDC_Cartesian_3D class - -## Defines a stub 1D algorithm, which enables "manual" creation of nodes and -# segments usable by 2D algoritms -# -# It is created by calling smesh.Mesh.UseExistingSegments(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_UseExisting_1D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "UseExistingSegments" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "UseExisting_1D" - ## doc string of the method - # @internal - docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - self.Create(mesh, geom, self.algoType) - pass - - pass # end of StdMeshersDC_UseExisting_1D class - -## Defines a stub 2D algorithm, which enables "manual" creation of nodes and -# faces usable by 3D algoritms -# -# It is created by calling smesh.Mesh.UseExistingFaces(geom=0) -# -# @ingroup l3_algos_basic -class StdMeshersDC_UseExisting_2D(Mesh_Algorithm): - - ## name of the dynamic method in smesh.Mesh class - # @internal - meshMethod = "UseExistingFaces" - ## type of algorithm used with helper function in smesh.Mesh class - # @internal - algoType = "UseExisting_2D" - ## doc string of the method - # @internal - docHelper = "Creates 2D algorithm for faces with reusing of existing mesh elements" - - ## Private constructor. - # @param mesh parent mesh object algorithm is assigned to - # @param geom geometry (shape/sub-shape) algorithm is assigned to; - # if it is @c 0 (default), the algorithm is assigned to the main shape - def __init__(self, mesh, geom=0): - self.Create(mesh, geom, self.algoType) - pass - - pass # end of StdMeshersDC_UseExisting_2D class diff --git a/src/SMESH_SWIG/__init__.py b/src/SMESH_SWIG/__init__.py new file mode 100644 index 000000000..630e0eda8 --- /dev/null +++ b/src/SMESH_SWIG/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : __init__.py +# Package : StdMeshers \ No newline at end of file diff --git a/src/SMESH_SWIG/ex01_cube2build.py b/src/SMESH_SWIG/ex01_cube2build.py index 25917942e..76b3a3840 100644 --- a/src/SMESH_SWIG/ex01_cube2build.py +++ b/src/SMESH_SWIG/ex01_cube2build.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -35,233 +41,233 @@ import smesh # Points # ------ -greatPoint111 = MakeVertex( 0, 0, 0) -greatPoint211 = MakeVertex(10, 0, 0) -greatPoint311 = MakeVertex(20, 0, 0) -greatPoint411 = MakeVertex(30, 0, 0) +greatPoint111 = geompy.MakeVertex( 0, 0, 0) +greatPoint211 = geompy.MakeVertex(10, 0, 0) +greatPoint311 = geompy.MakeVertex(20, 0, 0) +greatPoint411 = geompy.MakeVertex(30, 0, 0) -greatPoint121 = MakeVertex( 0, 10, 0) -greatPoint221 = MakeVertex(10, 10, 0) -greatPoint321 = MakeVertex(20, 10, 0) -greatPoint421 = MakeVertex(30, 10, 0) +greatPoint121 = geompy.MakeVertex( 0, 10, 0) +greatPoint221 = geompy.MakeVertex(10, 10, 0) +greatPoint321 = geompy.MakeVertex(20, 10, 0) +greatPoint421 = geompy.MakeVertex(30, 10, 0) -greatPoint112 = MakeVertex( 0, 0, 10) -greatPoint212 = MakeVertex(10, 0, 10) -greatPoint312 = MakeVertex(20, 0, 10) -greatPoint412 = MakeVertex(30, 0, 10) +greatPoint112 = geompy.MakeVertex( 0, 0, 10) +greatPoint212 = geompy.MakeVertex(10, 0, 10) +greatPoint312 = geompy.MakeVertex(20, 0, 10) +greatPoint412 = geompy.MakeVertex(30, 0, 10) -greatPoint122 = MakeVertex( 0, 10, 10) -greatPoint222 = MakeVertex(10, 10, 10) -greatPoint322 = MakeVertex(20, 10, 10) -greatPoint422 = MakeVertex(30, 10, 10) +greatPoint122 = geompy.MakeVertex( 0, 10, 10) +greatPoint222 = geompy.MakeVertex(10, 10, 10) +greatPoint322 = geompy.MakeVertex(20, 10, 10) +greatPoint422 = geompy.MakeVertex(30, 10, 10) -greatPoint113 = MakeVertex( 0, 0, 20) -greatPoint213 = MakeVertex(10, 0, 20) -greatPoint313 = MakeVertex(20, 0, 20) -greatPoint413 = MakeVertex(30, 0, 20) +greatPoint113 = geompy.MakeVertex( 0, 0, 20) +greatPoint213 = geompy.MakeVertex(10, 0, 20) +greatPoint313 = geompy.MakeVertex(20, 0, 20) +greatPoint413 = geompy.MakeVertex(30, 0, 20) -greatPoint123 = MakeVertex( 0, 10, 20) -greatPoint223 = MakeVertex(10, 10, 20) -greatPoint323 = MakeVertex(20, 10, 20) -greatPoint423 = MakeVertex(30, 10, 20) +greatPoint123 = geompy.MakeVertex( 0, 10, 20) +greatPoint223 = geompy.MakeVertex(10, 10, 20) +greatPoint323 = geompy.MakeVertex(20, 10, 20) +greatPoint423 = geompy.MakeVertex(30, 10, 20) -greatPoint114 = MakeVertex( 0, 0, 30) -greatPoint214 = MakeVertex(10, 0, 30) -greatPoint314 = MakeVertex(20, 0, 30) -greatPoint414 = MakeVertex(30, 0, 30) +greatPoint114 = geompy.MakeVertex( 0, 0, 30) +greatPoint214 = geompy.MakeVertex(10, 0, 30) +greatPoint314 = geompy.MakeVertex(20, 0, 30) +greatPoint414 = geompy.MakeVertex(30, 0, 30) -greatPoint124 = MakeVertex( 0, 10, 30) -greatPoint224 = MakeVertex(10, 10, 30) -greatPoint324 = MakeVertex(20, 10, 30) -greatPoint424 = MakeVertex(30, 10, 30) +greatPoint124 = geompy.MakeVertex( 0, 10, 30) +greatPoint224 = geompy.MakeVertex(10, 10, 30) +greatPoint324 = geompy.MakeVertex(20, 10, 30) +greatPoint424 = geompy.MakeVertex(30, 10, 30) smallPoint111 = greatPoint222 smallPoint211 = greatPoint322 -smallPoint121 = MakeVertex(10, 20, 10) -smallPoint221 = MakeVertex(20, 20, 10) +smallPoint121 = geompy.MakeVertex(10, 20, 10) +smallPoint221 = geompy.MakeVertex(20, 20, 10) smallPoint112 = greatPoint223 smallPoint212 = greatPoint323 -smallPoint122 = MakeVertex(10, 20, 20) -smallPoint222 = MakeVertex(20, 20, 20) +smallPoint122 = geompy.MakeVertex(10, 20, 20) +smallPoint222 = geompy.MakeVertex(20, 20, 20) # Edges # ----- -smallEdgeX11 = MakeEdge(smallPoint111, smallPoint211) -smallEdgeX21 = MakeEdge(smallPoint121, smallPoint221) -smallEdgeX12 = MakeEdge(smallPoint112, smallPoint212) -smallEdgeX22 = MakeEdge(smallPoint122, smallPoint222) - -smallEdgeY11 = MakeEdge(smallPoint111, smallPoint121) -smallEdgeY21 = MakeEdge(smallPoint211, smallPoint221) -smallEdgeY12 = MakeEdge(smallPoint112, smallPoint122) -smallEdgeY22 = MakeEdge(smallPoint212, smallPoint222) - -smallEdgeZ11 = MakeEdge(smallPoint111, smallPoint112) -smallEdgeZ21 = MakeEdge(smallPoint211, smallPoint212) -smallEdgeZ12 = MakeEdge(smallPoint121, smallPoint122) -smallEdgeZ22 = MakeEdge(smallPoint221, smallPoint222) - - -greatEdgeX111 = MakeEdge(greatPoint111, greatPoint211) -greatEdgeX211 = MakeEdge(greatPoint211, greatPoint311) -greatEdgeX311 = MakeEdge(greatPoint311, greatPoint411) -greatEdgeX121 = MakeEdge(greatPoint121, greatPoint221) -greatEdgeX221 = MakeEdge(greatPoint221, greatPoint321) -greatEdgeX321 = MakeEdge(greatPoint321, greatPoint421) - -greatEdgeX112 = MakeEdge(greatPoint112, greatPoint212) -greatEdgeX212 = MakeEdge(greatPoint212, greatPoint312) -greatEdgeX312 = MakeEdge(greatPoint312, greatPoint412) -greatEdgeX122 = MakeEdge(greatPoint122, greatPoint222) +smallEdgeX11 = geompy.MakeEdge(smallPoint111, smallPoint211) +smallEdgeX21 = geompy.MakeEdge(smallPoint121, smallPoint221) +smallEdgeX12 = geompy.MakeEdge(smallPoint112, smallPoint212) +smallEdgeX22 = geompy.MakeEdge(smallPoint122, smallPoint222) + +smallEdgeY11 = geompy.MakeEdge(smallPoint111, smallPoint121) +smallEdgeY21 = geompy.MakeEdge(smallPoint211, smallPoint221) +smallEdgeY12 = geompy.MakeEdge(smallPoint112, smallPoint122) +smallEdgeY22 = geompy.MakeEdge(smallPoint212, smallPoint222) + +smallEdgeZ11 = geompy.MakeEdge(smallPoint111, smallPoint112) +smallEdgeZ21 = geompy.MakeEdge(smallPoint211, smallPoint212) +smallEdgeZ12 = geompy.MakeEdge(smallPoint121, smallPoint122) +smallEdgeZ22 = geompy.MakeEdge(smallPoint221, smallPoint222) + + +greatEdgeX111 = geompy.MakeEdge(greatPoint111, greatPoint211) +greatEdgeX211 = geompy.MakeEdge(greatPoint211, greatPoint311) +greatEdgeX311 = geompy.MakeEdge(greatPoint311, greatPoint411) +greatEdgeX121 = geompy.MakeEdge(greatPoint121, greatPoint221) +greatEdgeX221 = geompy.MakeEdge(greatPoint221, greatPoint321) +greatEdgeX321 = geompy.MakeEdge(greatPoint321, greatPoint421) + +greatEdgeX112 = geompy.MakeEdge(greatPoint112, greatPoint212) +greatEdgeX212 = geompy.MakeEdge(greatPoint212, greatPoint312) +greatEdgeX312 = geompy.MakeEdge(greatPoint312, greatPoint412) +greatEdgeX122 = geompy.MakeEdge(greatPoint122, greatPoint222) greatEdgeX222 = smallEdgeX11 -greatEdgeX322 = MakeEdge(greatPoint322, greatPoint422) +greatEdgeX322 = geompy.MakeEdge(greatPoint322, greatPoint422) -greatEdgeX113 = MakeEdge(greatPoint113, greatPoint213) -greatEdgeX213 = MakeEdge(greatPoint213, greatPoint313) -greatEdgeX313 = MakeEdge(greatPoint313, greatPoint413) -greatEdgeX123 = MakeEdge(greatPoint123, greatPoint223) +greatEdgeX113 = geompy.MakeEdge(greatPoint113, greatPoint213) +greatEdgeX213 = geompy.MakeEdge(greatPoint213, greatPoint313) +greatEdgeX313 = geompy.MakeEdge(greatPoint313, greatPoint413) +greatEdgeX123 = geompy.MakeEdge(greatPoint123, greatPoint223) greatEdgeX223 = smallEdgeX12 -greatEdgeX323 = MakeEdge(greatPoint323, greatPoint423) - -greatEdgeX114 = MakeEdge(greatPoint114, greatPoint214) -greatEdgeX214 = MakeEdge(greatPoint214, greatPoint314) -greatEdgeX314 = MakeEdge(greatPoint314, greatPoint414) -greatEdgeX124 = MakeEdge(greatPoint124, greatPoint224) -greatEdgeX224 = MakeEdge(greatPoint224, greatPoint324) -greatEdgeX324 = MakeEdge(greatPoint324, greatPoint424) - -greatEdgeY11 = MakeEdge(greatPoint111, greatPoint121) -greatEdgeY21 = MakeEdge(greatPoint211, greatPoint221) -greatEdgeY31 = MakeEdge(greatPoint311, greatPoint321) -greatEdgeY41 = MakeEdge(greatPoint411, greatPoint421) - -greatEdgeY12 = MakeEdge(greatPoint112, greatPoint122) -greatEdgeY22 = MakeEdge(greatPoint212, greatPoint222) -greatEdgeY32 = MakeEdge(greatPoint312, greatPoint322) -greatEdgeY42 = MakeEdge(greatPoint412, greatPoint422) - -greatEdgeY13 = MakeEdge(greatPoint113, greatPoint123) -greatEdgeY23 = MakeEdge(greatPoint213, greatPoint223) -greatEdgeY33 = MakeEdge(greatPoint313, greatPoint323) -greatEdgeY43 = MakeEdge(greatPoint413, greatPoint423) - -greatEdgeY14 = MakeEdge(greatPoint114, greatPoint124) -greatEdgeY24 = MakeEdge(greatPoint214, greatPoint224) -greatEdgeY34 = MakeEdge(greatPoint314, greatPoint324) -greatEdgeY44 = MakeEdge(greatPoint414, greatPoint424) - -greatEdgeZ111 = MakeEdge(greatPoint111, greatPoint112) -greatEdgeZ211 = MakeEdge(greatPoint211, greatPoint212) -greatEdgeZ311 = MakeEdge(greatPoint311, greatPoint312) -greatEdgeZ411 = MakeEdge(greatPoint411, greatPoint412) - -greatEdgeZ121 = MakeEdge(greatPoint121, greatPoint122) -greatEdgeZ221 = MakeEdge(greatPoint221, greatPoint222) -greatEdgeZ321 = MakeEdge(greatPoint321, greatPoint322) -greatEdgeZ421 = MakeEdge(greatPoint421, greatPoint422) - -greatEdgeZ112 = MakeEdge(greatPoint112, greatPoint113) -greatEdgeZ212 = MakeEdge(greatPoint212, greatPoint213) -greatEdgeZ312 = MakeEdge(greatPoint312, greatPoint313) -greatEdgeZ412 = MakeEdge(greatPoint412, greatPoint413) - -greatEdgeZ122 = MakeEdge(greatPoint122, greatPoint123) +greatEdgeX323 = geompy.MakeEdge(greatPoint323, greatPoint423) + +greatEdgeX114 = geompy.MakeEdge(greatPoint114, greatPoint214) +greatEdgeX214 = geompy.MakeEdge(greatPoint214, greatPoint314) +greatEdgeX314 = geompy.MakeEdge(greatPoint314, greatPoint414) +greatEdgeX124 = geompy.MakeEdge(greatPoint124, greatPoint224) +greatEdgeX224 = geompy.MakeEdge(greatPoint224, greatPoint324) +greatEdgeX324 = geompy.MakeEdge(greatPoint324, greatPoint424) + +greatEdgeY11 = geompy.MakeEdge(greatPoint111, greatPoint121) +greatEdgeY21 = geompy.MakeEdge(greatPoint211, greatPoint221) +greatEdgeY31 = geompy.MakeEdge(greatPoint311, greatPoint321) +greatEdgeY41 = geompy.MakeEdge(greatPoint411, greatPoint421) + +greatEdgeY12 = geompy.MakeEdge(greatPoint112, greatPoint122) +greatEdgeY22 = geompy.MakeEdge(greatPoint212, greatPoint222) +greatEdgeY32 = geompy.MakeEdge(greatPoint312, greatPoint322) +greatEdgeY42 = geompy.MakeEdge(greatPoint412, greatPoint422) + +greatEdgeY13 = geompy.MakeEdge(greatPoint113, greatPoint123) +greatEdgeY23 = geompy.MakeEdge(greatPoint213, greatPoint223) +greatEdgeY33 = geompy.MakeEdge(greatPoint313, greatPoint323) +greatEdgeY43 = geompy.MakeEdge(greatPoint413, greatPoint423) + +greatEdgeY14 = geompy.MakeEdge(greatPoint114, greatPoint124) +greatEdgeY24 = geompy.MakeEdge(greatPoint214, greatPoint224) +greatEdgeY34 = geompy.MakeEdge(greatPoint314, greatPoint324) +greatEdgeY44 = geompy.MakeEdge(greatPoint414, greatPoint424) + +greatEdgeZ111 = geompy.MakeEdge(greatPoint111, greatPoint112) +greatEdgeZ211 = geompy.MakeEdge(greatPoint211, greatPoint212) +greatEdgeZ311 = geompy.MakeEdge(greatPoint311, greatPoint312) +greatEdgeZ411 = geompy.MakeEdge(greatPoint411, greatPoint412) + +greatEdgeZ121 = geompy.MakeEdge(greatPoint121, greatPoint122) +greatEdgeZ221 = geompy.MakeEdge(greatPoint221, greatPoint222) +greatEdgeZ321 = geompy.MakeEdge(greatPoint321, greatPoint322) +greatEdgeZ421 = geompy.MakeEdge(greatPoint421, greatPoint422) + +greatEdgeZ112 = geompy.MakeEdge(greatPoint112, greatPoint113) +greatEdgeZ212 = geompy.MakeEdge(greatPoint212, greatPoint213) +greatEdgeZ312 = geompy.MakeEdge(greatPoint312, greatPoint313) +greatEdgeZ412 = geompy.MakeEdge(greatPoint412, greatPoint413) + +greatEdgeZ122 = geompy.MakeEdge(greatPoint122, greatPoint123) greatEdgeZ222 = smallEdgeZ11 greatEdgeZ322 = smallEdgeZ21 -greatEdgeZ422 = MakeEdge(greatPoint422, greatPoint423) +greatEdgeZ422 = geompy.MakeEdge(greatPoint422, greatPoint423) -greatEdgeZ113 = MakeEdge(greatPoint113, greatPoint114) -greatEdgeZ213 = MakeEdge(greatPoint213, greatPoint214) -greatEdgeZ313 = MakeEdge(greatPoint313, greatPoint314) -greatEdgeZ413 = MakeEdge(greatPoint413, greatPoint414) +greatEdgeZ113 = geompy.MakeEdge(greatPoint113, greatPoint114) +greatEdgeZ213 = geompy.MakeEdge(greatPoint213, greatPoint214) +greatEdgeZ313 = geompy.MakeEdge(greatPoint313, greatPoint314) +greatEdgeZ413 = geompy.MakeEdge(greatPoint413, greatPoint414) -greatEdgeZ123 = MakeEdge(greatPoint123, greatPoint124) -greatEdgeZ223 = MakeEdge(greatPoint223, greatPoint224) -greatEdgeZ323 = MakeEdge(greatPoint323, greatPoint324) -greatEdgeZ423 = MakeEdge(greatPoint423, greatPoint424) +greatEdgeZ123 = geompy.MakeEdge(greatPoint123, greatPoint124) +greatEdgeZ223 = geompy.MakeEdge(greatPoint223, greatPoint224) +greatEdgeZ323 = geompy.MakeEdge(greatPoint323, greatPoint324) +greatEdgeZ423 = geompy.MakeEdge(greatPoint423, greatPoint424) # Faces # ----- -smallFaceX1 = MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12) -smallFaceX2 = MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22) -smallFaceY1 = MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21) -smallFaceY2 = MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22) -smallFaceZ1 = MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21) -smallFaceZ2 = MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22) - - -greatFaceX11 = MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121) -greatFaceX21 = MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221) -greatFaceX31 = MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321) -greatFaceX41 = MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421) - -greatFaceX12 = MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122) -greatFaceX22 = MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222) -greatFaceX32 = MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322) -greatFaceX42 = MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422) - -greatFaceX13 = MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123) -greatFaceX23 = MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223) -greatFaceX33 = MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323) -greatFaceX43 = MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423) - -greatFaceY111 = MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211) -greatFaceY211 = MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311) -greatFaceY311 = MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411) -greatFaceY121 = MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221) -greatFaceY221 = MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321) -greatFaceY321 = MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421) - -greatFaceY112 = MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212) -greatFaceY212 = MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312) -greatFaceY312 = MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412) -greatFaceY122 = MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222) +smallFaceX1 = geompy.MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12) +smallFaceX2 = geompy.MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22) +smallFaceY1 = geompy.MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21) +smallFaceY2 = geompy.MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22) +smallFaceZ1 = geompy.MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21) +smallFaceZ2 = geompy.MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22) + + +greatFaceX11 = geompy.MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121) +greatFaceX21 = geompy.MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221) +greatFaceX31 = geompy.MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321) +greatFaceX41 = geompy.MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421) + +greatFaceX12 = geompy.MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122) +greatFaceX22 = geompy.MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222) +greatFaceX32 = geompy.MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322) +greatFaceX42 = geompy.MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422) + +greatFaceX13 = geompy.MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123) +greatFaceX23 = geompy.MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223) +greatFaceX33 = geompy.MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323) +greatFaceX43 = geompy.MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423) + +greatFaceY111 = geompy.MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211) +greatFaceY211 = geompy.MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311) +greatFaceY311 = geompy.MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411) +greatFaceY121 = geompy.MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221) +greatFaceY221 = geompy.MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321) +greatFaceY321 = geompy.MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421) + +greatFaceY112 = geompy.MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212) +greatFaceY212 = geompy.MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312) +greatFaceY312 = geompy.MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412) +greatFaceY122 = geompy.MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222) greatFaceY222 = smallFaceY1 -greatFaceY322 = MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422) +greatFaceY322 = geompy.MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422) -greatFaceY113 = MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213) -greatFaceY213 = MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313) -greatFaceY313 = MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413) -greatFaceY123 = MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223) -greatFaceY223 = MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323) -greatFaceY323 = MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423) +greatFaceY113 = geompy.MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213) +greatFaceY213 = geompy.MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313) +greatFaceY313 = geompy.MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413) +greatFaceY123 = geompy.MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223) +greatFaceY223 = geompy.MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323) +greatFaceY323 = geompy.MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423) -greatFaceZ11 = MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21) -greatFaceZ21 = MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31) -greatFaceZ31 = MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41) +greatFaceZ11 = geompy.MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21) +greatFaceZ21 = geompy.MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31) +greatFaceZ31 = geompy.MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41) -greatFaceZ12 = MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22) -greatFaceZ22 = MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32) -greatFaceZ32 = MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42) +greatFaceZ12 = geompy.MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22) +greatFaceZ22 = geompy.MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32) +greatFaceZ32 = geompy.MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42) -greatFaceZ13 = MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23) -greatFaceZ23 = MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33) -greatFaceZ33 = MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43) +greatFaceZ13 = geompy.MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23) +greatFaceZ23 = geompy.MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33) +greatFaceZ33 = geompy.MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43) -greatFaceZ14 = MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24) -greatFaceZ24 = MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34) -greatFaceZ34 = MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44) +greatFaceZ14 = geompy.MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24) +greatFaceZ24 = geompy.MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34) +greatFaceZ34 = geompy.MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44) # Solids # ------ -smallBlock = MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2) +smallBlock = geompy.MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2) -greatBlock11 = MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12) -greatBlock21 = MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22) -greatBlock31 = MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32) +greatBlock11 = geompy.MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12) +greatBlock21 = geompy.MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22) +greatBlock31 = geompy.MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32) -greatBlock12 = MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13) -greatBlock22 = MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23) -greatBlock32 = MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33) +greatBlock12 = geompy.MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13) +greatBlock22 = geompy.MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23) +greatBlock32 = geompy.MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33) -greatBlock13 = MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14) -greatBlock23 = MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24) -greatBlock33 = MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34) +greatBlock13 = geompy.MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14) +greatBlock23 = geompy.MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24) +greatBlock33 = geompy.MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34) # Compound # -------- @@ -278,18 +284,16 @@ c_l.append(greatBlock13) c_l.append(greatBlock23) c_l.append(greatBlock33) -piece = MakeCompound(c_l) +piece = geompy.MakeCompound(c_l) # Add in study # ------------ -piece_id = addToStudy(piece, "ex01_cube2build") +piece_id = geompy.addToStudy(piece, "ex01_cube2build") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create hexahedrical mesh on piece # --------------------------------- diff --git a/src/SMESH_SWIG/ex02_cube2primitive.py b/src/SMESH_SWIG/ex02_cube2primitive.py index 4f13c7f9d..e064c2ec7 100644 --- a/src/SMESH_SWIG/ex02_cube2primitive.py +++ b/src/SMESH_SWIG/ex02_cube2primitive.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -44,33 +50,33 @@ arete = 10 # Points # ------ -blockPoint111 = MakeVertex(ox , oy, oz) -blockPoint211 = MakeVertex(ox+arete, oy, oz) -blockPoint112 = MakeVertex(ox , oy, oz+arete) -blockPoint212 = MakeVertex(ox+arete, oy, oz+arete) +blockPoint111 = geompy.MakeVertex(ox , oy, oz) +blockPoint211 = geompy.MakeVertex(ox+arete, oy, oz) +blockPoint112 = geompy.MakeVertex(ox , oy, oz+arete) +blockPoint212 = geompy.MakeVertex(ox+arete, oy, oz+arete) # Face and solid # -------------- -blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) +blockFace1 = geompy.MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) -blockSolid11 = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete) +blockSolid11 = geompy.MakePrismVecH(blockFace1, geompy.MakeVectorDXDYDZ(0, 1, 0), arete) # Translations # ------------ -blockSolid21 = MakeTranslation(blockSolid11, arete, 0, 0) -blockSolid31 = MakeTranslation(blockSolid21, arete, 0, 0) +blockSolid21 = geompy.MakeTranslation(blockSolid11, arete, 0, 0) +blockSolid31 = geompy.MakeTranslation(blockSolid21, arete, 0, 0) -blockSolid12 = MakeTranslation(blockSolid11, 0, 0, arete) -blockSolid22 = MakeTranslation(blockSolid12, arete, 0, 0) -blockSolid32 = MakeTranslation(blockSolid22, arete, 0, 0) +blockSolid12 = geompy.MakeTranslation(blockSolid11, 0, 0, arete) +blockSolid22 = geompy.MakeTranslation(blockSolid12, arete, 0, 0) +blockSolid32 = geompy.MakeTranslation(blockSolid22, arete, 0, 0) -blockSolid13 = MakeTranslation(blockSolid12, 0, 0, arete) -blockSolid23 = MakeTranslation(blockSolid13, arete, 0, 0) -blockSolid33 = MakeTranslation(blockSolid23, arete, 0, 0) +blockSolid13 = geompy.MakeTranslation(blockSolid12, 0, 0, arete) +blockSolid23 = geompy.MakeTranslation(blockSolid13, arete, 0, 0) +blockSolid33 = geompy.MakeTranslation(blockSolid23, arete, 0, 0) -blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0) +blockSolid111 = geompy.MakeTranslation(blockSolid22, 0, arete, 0) # Compound and glue # ----------------- @@ -87,20 +93,18 @@ c_l.append(blockSolid23) c_l.append(blockSolid33) c_l.append(blockSolid111) -c_cpd = MakeCompound(c_l) +c_cpd = geompy.MakeCompound(c_l) -piece = MakeGlueFaces(c_cpd, 1.e-5) +piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex02_cube2primitive") +piece_id = geompy.addToStudy(piece, "ex02_cube2primitive") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create hexahedrical mesh on piece # --------------------------------- diff --git a/src/SMESH_SWIG/ex03_cube2partition.py b/src/SMESH_SWIG/ex03_cube2partition.py index 5832c2eeb..ea1c24cf4 100644 --- a/src/SMESH_SWIG/ex03_cube2partition.py +++ b/src/SMESH_SWIG/ex03_cube2partition.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -49,45 +55,43 @@ g_trim = 1000 v_arete2 = g_arete*2 v_arete3 = g_arete*3 -v_1 = MakeVertex(g_ox , g_oy , g_oz ) -v_2 = MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3) +v_1 = geompy.MakeVertex(g_ox , g_oy , g_oz ) +v_2 = geompy.MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3) -v_3 = MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete ) -v_4 = MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2) +v_3 = geompy.MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete ) +v_4 = geompy.MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2) # Solids # ------ -s_base = MakeBoxTwoPnt(v_1, v_2) -s_haut = MakeBoxTwoPnt(v_3, v_4) +s_base = geompy.MakeBoxTwoPnt(v_1, v_2) +s_haut = geompy.MakeBoxTwoPnt(v_3, v_4) # Partition # --------- -p_dir1 = MakeVectorDXDYDZ(1, 0, 0) -p_dir2 = MakeVectorDXDYDZ(0, 0, 1) -p_dir3 = MakeVectorDXDYDZ(0, 1, 0) +p_dir1 = geompy.MakeVectorDXDYDZ(1, 0, 0) +p_dir2 = geompy.MakeVectorDXDYDZ(0, 0, 1) +p_dir3 = geompy.MakeVectorDXDYDZ(0, 1, 0) p_tools = [] -p_tools.append(MakePlane(v_3, p_dir1, g_trim)) -p_tools.append(MakePlane(v_4, p_dir1, g_trim)) -p_tools.append(MakePlane(v_3, p_dir2, g_trim)) -p_tools.append(MakePlane(v_4, p_dir2, g_trim)) -p_tools.append(MakePlane(v_3, p_dir3, g_trim)) +p_tools.append(geompy.MakePlane(v_3, p_dir1, g_trim)) +p_tools.append(geompy.MakePlane(v_4, p_dir1, g_trim)) +p_tools.append(geompy.MakePlane(v_3, p_dir2, g_trim)) +p_tools.append(geompy.MakePlane(v_4, p_dir2, g_trim)) +p_tools.append(geompy.MakePlane(v_3, p_dir3, g_trim)) -piece = MakePartition([s_base, s_haut], p_tools, [], [], ShapeType["SOLID"]) +piece = geompy.MakePartition([s_base, s_haut], p_tools, [], [], geompy.ShapeType["SOLID"]) # Study # ----- -piece_id = addToStudy(piece, "ex03_cube2partition") +piece_id = geompy.addToStudy(piece, "ex03_cube2partition") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create hexahedrical mesh on piece # --------------------------------- diff --git a/src/SMESH_SWIG/ex04_cube5tetraHexa.py b/src/SMESH_SWIG/ex04_cube5tetraHexa.py index 5660692bb..fae90efe0 100644 --- a/src/SMESH_SWIG/ex04_cube5tetraHexa.py +++ b/src/SMESH_SWIG/ex04_cube5tetraHexa.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -45,30 +51,28 @@ arete3 = arete*3 # Solids # ------ -box_tetra1 = MakeBox(arete0, arete0, 0, arete1, arete1, arete) +box_tetra1 = geompy.MakeBox(arete0, arete0, 0, arete1, arete1, arete) -box_ijk1 = MakeBox(arete1, arete0, 0, arete2, arete1, arete) +box_ijk1 = geompy.MakeBox(arete1, arete0, 0, arete2, arete1, arete) -box_hexa = MakeBox(arete1, arete1, 0, arete2, arete2, arete) +box_hexa = geompy.MakeBox(arete1, arete1, 0, arete2, arete2, arete) -box_ijk2 = MakeBox(arete2, arete1, 0, arete3, arete2, arete) +box_ijk2 = geompy.MakeBox(arete2, arete1, 0, arete3, arete2, arete) -box_tetra2 = MakeBox(arete2, arete2, 0, arete3 ,arete3, arete) +box_tetra2 = geompy.MakeBox(arete2, arete2, 0, arete3 ,arete3, arete) # Piece # ----- -piece_cpd = MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2]) +piece_cpd = geompy.MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2]) -piece = MakeGlueFaces(piece_cpd, 1e-4) +piece = geompy.MakeGlueFaces(piece_cpd, 1e-4) -piece_id = addToStudy(piece, "ex04_cube5tetraHexa") +piece_id = geompy.addToStudy(piece, "ex04_cube5tetraHexa") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ @@ -86,8 +90,8 @@ mixed.Hexahedron() # ---------------------- def localMesh(b, hyp): - box = GetInPlace(piece, b) - faces = SubShapeAll(box, ShapeType["FACE"]) + box = geompy.GetInPlace(piece, b) + faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) i = 0 n = len(faces) @@ -99,7 +103,7 @@ def localMesh(b, hyp): algo.LengthFromEdges() i = i + 1 - algo = mixed.Tetrahedron(smesh.NETGEN, box) + algo = mixed.Tetrahedron(smeshBuilder.NETGEN, box) algo.MaxElementVolume(400) localMesh(box_tetra1, 1) diff --git a/src/SMESH_SWIG/ex05_hole1build.py b/src/SMESH_SWIG/ex05_hole1build.py index 89e5acc2a..1c0493df8 100644 --- a/src/SMESH_SWIG/ex05_hole1build.py +++ b/src/SMESH_SWIG/ex05_hole1build.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import math @@ -50,10 +56,10 @@ rayon = 10 # Points # ------ -basePoint111 = MakeVertex(ox , oy, oz) -basePoint211 = MakeVertex(ox+longueur, oy, oz) -basePoint112 = MakeVertex(ox , oy, oz+largeur) -basePoint212 = MakeVertex(ox+longueur, oy, oz+largeur) +basePoint111 = geompy.MakeVertex(ox , oy, oz) +basePoint211 = geompy.MakeVertex(ox+longueur, oy, oz) +basePoint112 = geompy.MakeVertex(ox , oy, oz+largeur) +basePoint212 = geompy.MakeVertex(ox+longueur, oy, oz+largeur) cx = ox+longueur/2 cy = oy @@ -64,46 +70,46 @@ ll = ll*ll dx = rayon/math.sqrt(1+ll) dz = rayon/math.sqrt(1+1/ll) -circlePoint1 = MakeVertex(cx-dx, cy, cz-dz) -circlePoint2 = MakeVertex(cx+dx, cy, cz-dz) -circlePoint3 = MakeVertex(cx+dx, cy, cz+dz) -circlePoint4 = MakeVertex(cx-dx, cy, cz+dz) +circlePoint1 = geompy.MakeVertex(cx-dx, cy, cz-dz) +circlePoint2 = geompy.MakeVertex(cx+dx, cy, cz-dz) +circlePoint3 = geompy.MakeVertex(cx+dx, cy, cz+dz) +circlePoint4 = geompy.MakeVertex(cx-dx, cy, cz+dz) # Edges # ----- -squareEdge1 = MakeEdge(basePoint111, basePoint211) -squareEdge2 = MakeEdge(basePoint211, basePoint212) -squareEdge3 = MakeEdge(basePoint212, basePoint112) -squareEdge4 = MakeEdge(basePoint112, basePoint111) +squareEdge1 = geompy.MakeEdge(basePoint111, basePoint211) +squareEdge2 = geompy.MakeEdge(basePoint211, basePoint212) +squareEdge3 = geompy.MakeEdge(basePoint212, basePoint112) +squareEdge4 = geompy.MakeEdge(basePoint112, basePoint111) -diagEdge1 = MakeEdge(basePoint111, circlePoint1) -diagEdge2 = MakeEdge(basePoint211, circlePoint2) -diagEdge3 = MakeEdge(basePoint212, circlePoint3) -diagEdge4 = MakeEdge(basePoint112, circlePoint4) +diagEdge1 = geompy.MakeEdge(basePoint111, circlePoint1) +diagEdge2 = geompy.MakeEdge(basePoint211, circlePoint2) +diagEdge3 = geompy.MakeEdge(basePoint212, circlePoint3) +diagEdge4 = geompy.MakeEdge(basePoint112, circlePoint4) -arcEdge1 = MakeArc(circlePoint1, MakeVertex(cx , cy, cz-rayon), circlePoint2) -arcEdge2 = MakeArc(circlePoint2, MakeVertex(cx+rayon, cy, cz ), circlePoint3) -arcEdge3 = MakeArc(circlePoint3, MakeVertex(cx , cy, cz+rayon), circlePoint4) -arcEdge4 = MakeArc(circlePoint4, MakeVertex(cx-rayon, cy, cz ), circlePoint1) +arcEdge1 = geompy.MakeArc(circlePoint1, geompy.MakeVertex(cx , cy, cz-rayon), circlePoint2) +arcEdge2 = geompy.MakeArc(circlePoint2, geompy.MakeVertex(cx+rayon, cy, cz ), circlePoint3) +arcEdge3 = geompy.MakeArc(circlePoint3, geompy.MakeVertex(cx , cy, cz+rayon), circlePoint4) +arcEdge4 = geompy.MakeArc(circlePoint4, geompy.MakeVertex(cx-rayon, cy, cz ), circlePoint1) # Faces # ----- -baseFace1 = MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1) -baseFace2 = MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2) -baseFace3 = MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3) -baseFace4 = MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4) +baseFace1 = geompy.MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1) +baseFace2 = geompy.MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2) +baseFace3 = geompy.MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3) +baseFace4 = geompy.MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4) # Solids # ------ -baseVector = MakeVectorDXDYDZ(0, 1, 0) +baseVector = geompy.MakeVectorDXDYDZ(0, 1, 0) -baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur) -baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur) -baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur) -baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur) +baseSolid1 = geompy.MakePrismVecH(baseFace1, baseVector, hauteur) +baseSolid2 = geompy.MakePrismVecH(baseFace2, baseVector, hauteur) +baseSolid3 = geompy.MakePrismVecH(baseFace3, baseVector, hauteur) +baseSolid4 = geompy.MakePrismVecH(baseFace4, baseVector, hauteur) # Compound # -------- @@ -114,19 +120,17 @@ c_l.append(baseSolid2) c_l.append(baseSolid3) c_l.append(baseSolid4) -c_cpd = MakeCompound(c_l) -piece = MakeGlueFaces(c_cpd, 1.e-5) +c_cpd = geompy.MakeCompound(c_l) +piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex05_hole1build") +piece_id = geompy.addToStudy(piece, "ex05_hole1build") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex06_hole1boolean.py b/src/SMESH_SWIG/ex06_hole1boolean.py index d78447641..7729e0379 100644 --- a/src/SMESH_SWIG/ex06_hole1boolean.py +++ b/src/SMESH_SWIG/ex06_hole1boolean.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -54,21 +60,21 @@ rayon = 10 def triangle(p1, p2, p3): l = [] - l.append(MakeEdge(p1, p2)) - l.append(MakeEdge(p2, p3)) - l.append(MakeEdge(p3, p1)) - w = MakeWire(l) - return MakeFace(w, 1) + l.append(geompy.MakeEdge(p1, p2)) + l.append(geompy.MakeEdge(p2, p3)) + l.append(geompy.MakeEdge(p3, p1)) + w = geompy.MakeWire(l) + return geompy.MakeFace(w, 1) # Points # ------ -basePoint111 = MakeVertex(ox-longueur1, oy, oz-largeur1) -basePoint211 = MakeVertex(ox+longueur2, oy, oz-largeur1) -basePoint112 = MakeVertex(ox-longueur1, oy, oz+largeur2) -basePoint212 = MakeVertex(ox+longueur2, oy, oz+largeur2) +basePoint111 = geompy.MakeVertex(ox-longueur1, oy, oz-largeur1) +basePoint211 = geompy.MakeVertex(ox+longueur2, oy, oz-largeur1) +basePoint112 = geompy.MakeVertex(ox-longueur1, oy, oz+largeur2) +basePoint212 = geompy.MakeVertex(ox+longueur2, oy, oz+largeur2) -holePoint = MakeVertex(ox, oy, oz) +holePoint = geompy.MakeVertex(ox, oy, oz) # Faces # ----- @@ -81,22 +87,22 @@ baseFace4 = triangle(basePoint112, basePoint111, holePoint) # Solids # ------ -baseVector = MakeVectorDXDYDZ(0, 1, 0) +baseVector = geompy.MakeVectorDXDYDZ(0, 1, 0) -baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur) -baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur) -baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur) -baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur) +baseSolid1 = geompy.MakePrismVecH(baseFace1, baseVector, hauteur) +baseSolid2 = geompy.MakePrismVecH(baseFace2, baseVector, hauteur) +baseSolid3 = geompy.MakePrismVecH(baseFace3, baseVector, hauteur) +baseSolid4 = geompy.MakePrismVecH(baseFace4, baseVector, hauteur) -holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur) +holeSolid = geompy.MakeCylinder(holePoint, baseVector, rayon, hauteur) # Boolean operations # ------------------ -baseHexa1 = MakeCut(baseSolid1, holeSolid) -baseHexa2 = MakeCut(baseSolid2, holeSolid) -baseHexa3 = MakeCut(baseSolid3, holeSolid) -baseHexa4 = MakeCut(baseSolid4, holeSolid) +baseHexa1 = geompy.MakeCut(baseSolid1, holeSolid) +baseHexa2 = geompy.MakeCut(baseSolid2, holeSolid) +baseHexa3 = geompy.MakeCut(baseSolid3, holeSolid) +baseHexa4 = geompy.MakeCut(baseSolid4, holeSolid) # Compound, glue and repair # ------------------------- @@ -107,20 +113,18 @@ c_l.append(baseHexa2) c_l.append(baseHexa3) c_l.append(baseHexa4) -c_cpd = MakeCompound(c_l) -c_glu = MakeGlueFaces(c_cpd, 1.e-5) -piece = RemoveExtraEdges(c_glu, doUnionFaces=True) +c_cpd = geompy.MakeCompound(c_l) +c_glu = geompy.MakeGlueFaces(c_cpd, 1.e-5) +piece = geompy.RemoveExtraEdges(c_glu, doUnionFaces=True) # Add in study # ------------ -piece_id = addToStudy(piece, "ex06_hole1boolean") +piece_id = geompy.addToStudy(piece, "ex06_hole1boolean") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ @@ -137,22 +141,22 @@ hexa.Hexahedron() # Create local hypothesis # ----------------------- -edge1 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz-largeur1)) +edge1 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox, oy, oz-largeur1)) algo1 = hexa.Segment(edge1) algo1.NumberOfSegments(3) algo1.Propagation() -edge2 = GetEdgeNearPoint(piece, MakeVertex(ox-longueur1, oy, oz)) +edge2 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox-longueur1, oy, oz)) algo2 = hexa.Segment(edge2) algo2.NumberOfSegments(5) algo2.Propagation() -edge3 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz+largeur2)) +edge3 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox, oy, oz+largeur2)) algo3 = hexa.Segment(edge3) algo3.NumberOfSegments(7) algo3.Propagation() -edge4 = GetEdgeNearPoint(piece, MakeVertex(ox+longueur2, oy, oz)) +edge4 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox+longueur2, oy, oz)) algo4 = hexa.Segment(edge4) algo4.NumberOfSegments(9) algo4.Propagation() diff --git a/src/SMESH_SWIG/ex07_hole1partition.py b/src/SMESH_SWIG/ex07_hole1partition.py index ae661e00b..d6ec2a23c 100644 --- a/src/SMESH_SWIG/ex07_hole1partition.py +++ b/src/SMESH_SWIG/ex07_hole1partition.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -50,41 +56,39 @@ g_trim = 1000 # Box # --- -b_boite = MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur, g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur) +b_boite = geompy.MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur, g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur) # Cylinder # -------- -c_axe = MakeVectorDXDYDZ(0, 1, 0) +c_axe = geompy.MakeVectorDXDYDZ(0, 1, 0) -c_cyl = MakeCylinder(MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2) +c_cyl = geompy.MakeCylinder(geompy.MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2) -c_piece = MakeCut(b_boite, c_cyl) +c_piece = geompy.MakeCut(b_boite, c_cyl) # Partition and reperation # ------------------------ -p_centre = MakeVertex(g_x, g_y, g_z) +p_centre = geompy.MakeVertex(g_x, g_y, g_z) p_tools = [] -p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim)) -p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim)) +p_tools.append(geompy.MakePlane(p_centre, geompy.MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim)) +p_tools.append(geompy.MakePlane(p_centre, geompy.MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim)) -p_part = MakePartition([c_piece], p_tools, [], [], ShapeType["SOLID"]) +p_part = geompy.MakePartition([c_piece], p_tools, [], [], geompy.ShapeType["SOLID"]) -p_blocs = RemoveExtraEdges(p_part, doUnionFaces=True) -piece = MakeGlueFaces(p_blocs, 1.e-5) +p_blocs = geompy.RemoveExtraEdges(p_part, doUnionFaces=True) +piece = geompy.MakeGlueFaces(p_blocs, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex07_hole1partition") +piece_id = geompy.addToStudy(piece, "ex07_hole1partition") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex08_hole2build.py b/src/SMESH_SWIG/ex08_hole2build.py index 726ca3dee..0c33f99a4 100644 --- a/src/SMESH_SWIG/ex08_hole2build.py +++ b/src/SMESH_SWIG/ex08_hole2build.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -50,74 +56,72 @@ rayon = 20 # Points # ------ -piecePoint1 = MakeVertex(ox , oy, oz) -piecePoint2 = MakeVertex(ox+longueur, oy, oz) -piecePoint3 = MakeVertex(ox+longueur, oy, oz+largeur) -piecePoint4 = MakeVertex(ox , oy, oz+largeur) +piecePoint1 = geompy.MakeVertex(ox , oy, oz) +piecePoint2 = geompy.MakeVertex(ox+longueur, oy, oz) +piecePoint3 = geompy.MakeVertex(ox+longueur, oy, oz+largeur) +piecePoint4 = geompy.MakeVertex(ox , oy, oz+largeur) cz = oz+largeur/2 -cylPoint1 = MakeVertex(ox+cylindre , oy, cz-rayon) -cylPoint2 = MakeVertex(ox+longueur-cylindre, oy, cz-rayon) -cylPoint3 = MakeVertex(ox+longueur-cylindre, oy, cz+rayon) -cylPoint4 = MakeVertex(ox+cylindre , oy, cz+rayon) +cylPoint1 = geompy.MakeVertex(ox+cylindre , oy, cz-rayon) +cylPoint2 = geompy.MakeVertex(ox+longueur-cylindre, oy, cz-rayon) +cylPoint3 = geompy.MakeVertex(ox+longueur-cylindre, oy, cz+rayon) +cylPoint4 = geompy.MakeVertex(ox+cylindre , oy, cz+rayon) # Edges # ----- -pieceEdge1 = MakeEdge(piecePoint1, piecePoint4) -pieceEdge2 = MakeEdge(piecePoint1, cylPoint1) -pieceEdge3 = MakeEdge(piecePoint4, cylPoint4) +pieceEdge1 = geompy.MakeEdge(piecePoint1, piecePoint4) +pieceEdge2 = geompy.MakeEdge(piecePoint1, cylPoint1) +pieceEdge3 = geompy.MakeEdge(piecePoint4, cylPoint4) -pieceEdge4 = MakeEdge(piecePoint2, piecePoint3) -pieceEdge5 = MakeEdge(piecePoint2, cylPoint2) -pieceEdge6 = MakeEdge(piecePoint3, cylPoint3) +pieceEdge4 = geompy.MakeEdge(piecePoint2, piecePoint3) +pieceEdge5 = geompy.MakeEdge(piecePoint2, cylPoint2) +pieceEdge6 = geompy.MakeEdge(piecePoint3, cylPoint3) -pieceEdge7 = MakeEdge(cylPoint1, cylPoint2) -pieceEdge8 = MakeEdge(cylPoint3, cylPoint4) +pieceEdge7 = geompy.MakeEdge(cylPoint1, cylPoint2) +pieceEdge8 = geompy.MakeEdge(cylPoint3, cylPoint4) -cylEdge1 = MakeArc(cylPoint1, MakeVertex(ox+cylindre-rayon , oy, cz), cylPoint4) -cylEdge2 = MakeArc(cylPoint1, MakeVertex(ox+cylindre+rayon , oy, cz), cylPoint4) -cylEdge3 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3) -cylEdge4 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3) +cylEdge1 = geompy.MakeArc(cylPoint1, geompy.MakeVertex(ox+cylindre-rayon , oy, cz), cylPoint4) +cylEdge2 = geompy.MakeArc(cylPoint1, geompy.MakeVertex(ox+cylindre+rayon , oy, cz), cylPoint4) +cylEdge3 = geompy.MakeArc(cylPoint2, geompy.MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3) +cylEdge4 = geompy.MakeArc(cylPoint2, geompy.MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3) # Faces # ----- -pieceFace1 = MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 ) -pieceFace2 = MakeQuad (pieceEdge1 , pieceEdge2 , cylEdge1 , pieceEdge3) -pieceFace3 = MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 ) -pieceFace4 = MakeQuad (pieceEdge4 , pieceEdge5 , cylEdge4 , pieceEdge6) -pieceFace5 = MakeQuad (pieceEdge7 , cylEdge3 , pieceEdge8, cylEdge2 ) +pieceFace1 = geompy.MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 ) +pieceFace2 = geompy.MakeQuad (pieceEdge1 , pieceEdge2 , cylEdge1 , pieceEdge3) +pieceFace3 = geompy.MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 ) +pieceFace4 = geompy.MakeQuad (pieceEdge4 , pieceEdge5 , cylEdge4 , pieceEdge6) +pieceFace5 = geompy.MakeQuad (pieceEdge7 , cylEdge3 , pieceEdge8, cylEdge2 ) # Solids # ------ -pieceVector = MakeVectorDXDYDZ(0, 1, 0) +pieceVector = geompy.MakeVectorDXDYDZ(0, 1, 0) -pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur) -pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur) -pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur) -pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur) -pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur) +pieceSolid1 = geompy.MakePrismVecH(pieceFace1, pieceVector, hauteur) +pieceSolid2 = geompy.MakePrismVecH(pieceFace2, pieceVector, hauteur) +pieceSolid3 = geompy.MakePrismVecH(pieceFace3, pieceVector, hauteur) +pieceSolid4 = geompy.MakePrismVecH(pieceFace4, pieceVector, hauteur) +pieceSolid5 = geompy.MakePrismVecH(pieceFace5, pieceVector, hauteur) # Compound and glue # ----------------- -c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5]) +c_cpd = geompy.MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5]) -piece = MakeGlueFaces(c_cpd, 1.e-5) +piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex08_hole2build") +piece_id = geompy.addToStudy(piece, "ex08_hole2build") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex09_grid4build.py b/src/SMESH_SWIG/ex09_grid4build.py index 04759a1d5..a015b75e2 100644 --- a/src/SMESH_SWIG/ex09_grid4build.py +++ b/src/SMESH_SWIG/ex09_grid4build.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) import math @@ -52,75 +58,73 @@ r3 = demi*math.sqrt(3) # Points # ------ -piecePoint111 = MakeVertex(ox+rayon , oy, oz) -piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz) -piecePoint112 = MakeVertex(ox , oy, oz+rayon) -piecePoint212 = MakeVertex(ox+arete , oy, oz+rayon) -piecePoint113 = MakeVertex(ox , oy, oz+arete-rayon) -piecePoint213 = MakeVertex(ox+arete , oy, oz+arete-rayon) -piecePoint114 = MakeVertex(ox+rayon , oy, oz+arete) -piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete) - -pieceCenter1 = MakeVertex(ox , oy, oz) -pieceCenter2 = MakeVertex(ox+arete , oy, oz) -pieceCenter3 = MakeVertex(ox , oy, oz+arete) -pieceCenter4 = MakeVertex(ox+arete , oy, oz+arete) - -piecePass1 = MakeVertex(ox+demi , oy, oz+r3) -piecePass2 = MakeVertex(ox+arete-demi , oy, oz+r3) -piecePass3 = MakeVertex(ox+arete-demi , oy, oz+arete-r3) -piecePass4 = MakeVertex(ox+demi , oy, oz+arete-r3) +piecePoint111 = geompy.MakeVertex(ox+rayon , oy, oz) +piecePoint211 = geompy.MakeVertex(ox+arete-rayon, oy, oz) +piecePoint112 = geompy.MakeVertex(ox , oy, oz+rayon) +piecePoint212 = geompy.MakeVertex(ox+arete , oy, oz+rayon) +piecePoint113 = geompy.MakeVertex(ox , oy, oz+arete-rayon) +piecePoint213 = geompy.MakeVertex(ox+arete , oy, oz+arete-rayon) +piecePoint114 = geompy.MakeVertex(ox+rayon , oy, oz+arete) +piecePoint214 = geompy.MakeVertex(ox+arete-rayon, oy, oz+arete) + +pieceCenter1 = geompy.MakeVertex(ox , oy, oz) +pieceCenter2 = geompy.MakeVertex(ox+arete , oy, oz) +pieceCenter3 = geompy.MakeVertex(ox , oy, oz+arete) +pieceCenter4 = geompy.MakeVertex(ox+arete , oy, oz+arete) + +piecePass1 = geompy.MakeVertex(ox+demi , oy, oz+r3) +piecePass2 = geompy.MakeVertex(ox+arete-demi , oy, oz+r3) +piecePass3 = geompy.MakeVertex(ox+arete-demi , oy, oz+arete-r3) +piecePass4 = geompy.MakeVertex(ox+demi , oy, oz+arete-r3) # Edges # ----- -pieceEdgeSquare1 = MakeEdge(piecePoint111, piecePoint211) -pieceEdgeSquare2 = MakeEdge(piecePoint114, piecePoint214) -pieceEdgeSquare3 = MakeEdge(piecePoint112, piecePoint113) -pieceEdgeSquare4 = MakeEdge(piecePoint212, piecePoint213) +pieceEdgeSquare1 = geompy.MakeEdge(piecePoint111, piecePoint211) +pieceEdgeSquare2 = geompy.MakeEdge(piecePoint114, piecePoint214) +pieceEdgeSquare3 = geompy.MakeEdge(piecePoint112, piecePoint113) +pieceEdgeSquare4 = geompy.MakeEdge(piecePoint212, piecePoint213) -pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213) -pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214) +pieceEdgeDiagonal1 = geompy.MakeEdge(piecePoint111, piecePoint213) +pieceEdgeDiagonal2 = geompy.MakeEdge(piecePoint112, piecePoint214) -pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112) -pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212) -pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214) -pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114) +pieceEdgeArc1 = geompy.MakeArc(piecePoint111, piecePass1, piecePoint112) +pieceEdgeArc2 = geompy.MakeArc(piecePoint211, piecePass2, piecePoint212) +pieceEdgeArc3 = geompy.MakeArc(piecePoint213, piecePass3, piecePoint214) +pieceEdgeArc4 = geompy.MakeArc(piecePoint113, piecePass4, piecePoint114) # Faces # ----- -pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1) -pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2) +pieceFace1 = geompy.MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1) +pieceFace2 = geompy.MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2) -pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2) +pieceFace3 = geompy.MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2) # Solids # ------ -pieceVector = MakeVectorDXDYDZ(0, 1, 0) +pieceVector = geompy.MakeVectorDXDYDZ(0, 1, 0) -pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur) -pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur) -pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur) +pieceSolid1 = geompy.MakePrismVecH(pieceFace1, pieceVector, hauteur) +pieceSolid2 = geompy.MakePrismVecH(pieceFace2, pieceVector, hauteur) +pieceSolid3 = geompy.MakePrismVecH(pieceFace3, pieceVector, hauteur) # Compound and glue # ----------------- -c_cpd = MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3]) +c_cpd = geompy.MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3]) -piece = MakeGlueFaces(c_cpd, 1.e-5) +piece = geompy.MakeGlueFaces(c_cpd, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex09_grid4build") +piece_id = geompy.addToStudy(piece, "ex09_grid4build") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex10_grid4geometry.py b/src/SMESH_SWIG/ex10_grid4geometry.py index ac9c0abf3..c743d40d4 100644 --- a/src/SMESH_SWIG/ex10_grid4geometry.py +++ b/src/SMESH_SWIG/ex10_grid4geometry.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -48,41 +54,39 @@ g_trim = 1000 # Box # --- -piecePoint = MakeVertex(ox, oy, oz) +piecePoint = geompy.MakeVertex(ox, oy, oz) -pieceBox = MakeBoxTwoPnt(piecePoint, MakeVertex(ox+arete, oy+hauteur, oz+arete)) +pieceBox = geompy.MakeBoxTwoPnt(piecePoint, geompy.MakeVertex(ox+arete, oy+hauteur, oz+arete)) # Cut by cylinders # ---------------- -dirUp = MakeVectorDXDYDZ(0, 1, 0) +dirUp = geompy.MakeVectorDXDYDZ(0, 1, 0) -pieceCut1 = MakeCut(pieceBox , MakeCylinder(piecePoint , dirUp, rayon, hauteur)) -pieceCut2 = MakeCut(pieceCut1, MakeCylinder(MakeVertex(ox+arete, oy, oz ), dirUp, rayon, hauteur)) -pieceCut3 = MakeCut(pieceCut2, MakeCylinder(MakeVertex(ox , oy, oz+arete), dirUp, rayon, hauteur)) -pieceCut4 = MakeCut(pieceCut3, MakeCylinder(MakeVertex(ox+arete, oy, oz+arete), dirUp, rayon, hauteur)) +pieceCut1 = geompy.MakeCut(pieceBox , geompy.MakeCylinder(piecePoint , dirUp, rayon, hauteur)) +pieceCut2 = geompy.MakeCut(pieceCut1, geompy.MakeCylinder(geompy.MakeVertex(ox+arete, oy, oz ), dirUp, rayon, hauteur)) +pieceCut3 = geompy.MakeCut(pieceCut2, geompy.MakeCylinder(geompy.MakeVertex(ox , oy, oz+arete), dirUp, rayon, hauteur)) +pieceCut4 = geompy.MakeCut(pieceCut3, geompy.MakeCylinder(geompy.MakeVertex(ox+arete, oy, oz+arete), dirUp, rayon, hauteur)) # Compound by make a partition of a solid # --------------------------------------- -dir = MakeVectorDXDYDZ(-1, 0, 1) +dir = geompy.MakeVectorDXDYDZ(-1, 0, 1) tools = [] -tools.append(MakePlane(MakeVertex(ox+rayon, oy, oz ), dir, g_trim)) -tools.append(MakePlane(MakeVertex(ox , oy, oz+rayon), dir, g_trim)) +tools.append(geompy.MakePlane(geompy.MakeVertex(ox+rayon, oy, oz ), dir, g_trim)) +tools.append(geompy.MakePlane(geompy.MakeVertex(ox , oy, oz+rayon), dir, g_trim)) -piece = MakePartition([pieceCut4], tools, [], [], ShapeType["SOLID"]) +piece = geompy.MakePartition([pieceCut4], tools, [], [], geompy.ShapeType["SOLID"]) # Add in study # ------------ -piece_id = addToStudy(piece, "ex10_grid4geometry") +piece_id = geompy.addToStudy(piece, "ex10_grid4geometry") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex11_grid3partition.py b/src/SMESH_SWIG/ex11_grid3partition.py index f2ae89463..3d3e336f3 100644 --- a/src/SMESH_SWIG/ex11_grid3partition.py +++ b/src/SMESH_SWIG/ex11_grid3partition.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -58,52 +64,50 @@ g_trim = 1000 # Element # ------- -e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) +e_boite = geompy.MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) e_hauteur = 2*g_hauteur -e_centre = MakeVertex(g_x, g_y-g_hauteur, g_z) -e_dir = MakeVectorDXDYDZ(0, 1, 0) +e_centre = geompy.MakeVertex(g_x, g_y-g_hauteur, g_z) +e_dir = geompy.MakeVectorDXDYDZ(0, 1, 0) -e_cyl1 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur) +e_cyl1 = geompy.MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur) -e_blo1 = MakeCut(e_boite, e_cyl1) +e_blo1 = geompy.MakeCut(e_boite, e_cyl1) -e_cyl2 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur) +e_cyl2 = geompy.MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur) -e_blo2 = MakeCut(e_cyl1, e_cyl2) +e_blo2 = geompy.MakeCut(e_cyl1, e_cyl2) -e_cyl3 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur) +e_cyl3 = geompy.MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur) -e_blo3 = MakeCut(e_cyl2, e_cyl3) +e_blo3 = geompy.MakeCut(e_cyl2, e_cyl3) # Partition and repair # -------------------- p_tools = [] -p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim)) -p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim)) +p_tools.append(geompy.MakePlane(e_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), g_trim)) +p_tools.append(geompy.MakePlane(e_centre, geompy.MakeVectorDXDYDZ(-1, 0, 1), g_trim)) -p_part = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"]) +p_part = geompy.MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], geompy.ShapeType["SOLID"]) -p_element = RemoveExtraEdges(p_part, doUnionFaces=True) +p_element = geompy.RemoveExtraEdges(p_part, doUnionFaces=True) # Grid and glue # ------------- -grid = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) +grid = geompy.MakeMultiTranslation2D(p_element, geompy.MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, geompy.MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) -piece = MakeGlueFaces(grid, 1e-5) +piece = geompy.MakeGlueFaces(grid, 1e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "ex11_grid3partition") +piece_id = geompy.addToStudy(piece, "ex11_grid3partition") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex12_grid17partition.py b/src/SMESH_SWIG/ex12_grid17partition.py index 8bc62f40e..b8f550880 100644 --- a/src/SMESH_SWIG/ex12_grid17partition.py +++ b/src/SMESH_SWIG/ex12_grid17partition.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -57,68 +63,66 @@ g_trim = 1000 # Solids and rotation to prevent repair # ------------------------------------- -s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) +s_boite = geompy.MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) s_pi4 = 3.141592653/4 s_hauteur = 2*g_hauteur -s_centre = MakeVertex(g_x, g_y-g_hauteur, g_z) -s_dir = MakeVectorDXDYDZ(0, 1, 0) +s_centre = geompy.MakeVertex(g_x, g_y-g_hauteur, g_z) +s_dir = geompy.MakeVectorDXDYDZ(0, 1, 0) -s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur) -s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4) +s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur) +s_cyl1 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4) -s_blo1 = MakeCut(s_boite, s_cyl1) +s_blo1 = geompy.MakeCut(s_boite, s_cyl1) -s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur) -s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4) +s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur) +s_cyl2 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4) -s_blo2 = MakeCut(s_cyl1, s_cyl2) +s_blo2 = geompy.MakeCut(s_cyl1, s_cyl2) -s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur) -s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4) +s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur) +s_cyl3 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4) -s_blo3 = MakeCut(s_cyl2, s_cyl3) +s_blo3 = geompy.MakeCut(s_cyl2, s_cyl3) s_arete = g_rayon1/2 -s_blo4 = MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete) +s_blo4 = geompy.MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete) -s_blo5 = MakeCut(s_cyl3, s_blo4) +s_blo5 = geompy.MakeCut(s_cyl3, s_blo4) # Partition # --------- p_tools = [] -p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim)) -p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim)) +p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), g_trim)) +p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ(-1, 0, 1), g_trim)) -p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"]) +p_partie = geompy.MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], geompy.ShapeType["SOLID"]) # Compound and glue # ----------------- -c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"]) +c_blocs = geompy.SubShapeAll(p_partie, geompy.ShapeType["SOLID"]) c_blocs.append(s_blo4) -c_cpd = MakeCompound(c_blocs) +c_cpd = geompy.MakeCompound(c_blocs) -c_element = MakeGlueFaces(c_cpd, 1e-4) +c_element = geompy.MakeGlueFaces(c_cpd, 1e-4) # Grid # ---- -piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) +piece = geompy.MakeMultiTranslation2D(c_element, geompy.MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, geompy.MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) # Add in study # ------------ -piece_id = addToStudy(piece, "ex12_grid17partition") +piece_id = geompy.addToStudy(piece, "ex12_grid17partition") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a hexahedral mesh # ------------------------ diff --git a/src/SMESH_SWIG/ex13_hole1partial.py b/src/SMESH_SWIG/ex13_hole1partial.py index a441a77f3..772df4bd3 100644 --- a/src/SMESH_SWIG/ex13_hole1partial.py +++ b/src/SMESH_SWIG/ex13_hole1partial.py @@ -23,9 +23,15 @@ # ================================== # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometry # ======== @@ -50,11 +56,11 @@ cyl_thick = 30 def triangle(p1, p2, p3): l = [] - l.append(MakeEdge(p1, p2)) - l.append(MakeEdge(p2, p3)) - l.append(MakeEdge(p3, p1)) - w = MakeWire(l) - return MakeFace(w, 1) + l.append(geompy.MakeEdge(p1, p2)) + l.append(geompy.MakeEdge(p2, p3)) + l.append(geompy.MakeEdge(p3, p1)) + w = geompy.MakeWire(l) + return geompy.MakeFace(w, 1) # The holed part # ============== @@ -62,12 +68,12 @@ def triangle(p1, p2, p3): # Vertex of the holed part # ------------------------ -hole_point_11 = MakeVertex(0 , 0 , 0) -hole_point_21 = MakeVertex(box_dx, 0 , 0) -hole_point_12 = MakeVertex(0 , box_dy, 0) -hole_point_22 = MakeVertex(box_dx, box_dy, 0) +hole_point_11 = geompy.MakeVertex(0 , 0 , 0) +hole_point_21 = geompy.MakeVertex(box_dx, 0 , 0) +hole_point_12 = geompy.MakeVertex(0 , box_dy, 0) +hole_point_22 = geompy.MakeVertex(box_dx, box_dy, 0) -hole_center = MakeVertex(cyl_x, cyl_y, 0) +hole_center = geompy.MakeVertex(cyl_x, cyl_y, 0) # Faces of the holed part # ----------------------- @@ -80,33 +86,33 @@ hole_face_4 = triangle(hole_point_11, hole_point_12, hole_center) # Solids of the holed part # ------------------------ -cyl_dir = MakeVectorDXDYDZ(0, 0, 1) +cyl_dir = geompy.MakeVectorDXDYDZ(0, 0, 1) -hole_solid_1 = MakePrismVecH(hole_face_1, cyl_dir, cyl_dz) -hole_solid_2 = MakePrismVecH(hole_face_2, cyl_dir, cyl_dz) -hole_solid_3 = MakePrismVecH(hole_face_3, cyl_dir, cyl_dz) -hole_solid_4 = MakePrismVecH(hole_face_4, cyl_dir, cyl_dz) +hole_solid_1 = geompy.MakePrismVecH(hole_face_1, cyl_dir, cyl_dz) +hole_solid_2 = geompy.MakePrismVecH(hole_face_2, cyl_dir, cyl_dz) +hole_solid_3 = geompy.MakePrismVecH(hole_face_3, cyl_dir, cyl_dz) +hole_solid_4 = geompy.MakePrismVecH(hole_face_4, cyl_dir, cyl_dz) -hole_internal = MakeCylinder(hole_center, cyl_dir, cyl_radius , cyl_dz) -hole_external = MakeCylinder(hole_center, cyl_dir, cyl_radius+cyl_thick, cyl_dz) -hole_median = MakeCut(hole_external, hole_internal) +hole_internal = geompy.MakeCylinder(hole_center, cyl_dir, cyl_radius , cyl_dz) +hole_external = geompy.MakeCylinder(hole_center, cyl_dir, cyl_radius+cyl_thick, cyl_dz) +hole_median = geompy.MakeCut(hole_external, hole_internal) # Boolean operations # ------------------ blocks = [] -blocks.append( MakeCut(hole_solid_1, hole_external)) -blocks.append(MakeCommon(hole_solid_1, hole_median )) +blocks.append( geompy.MakeCut(hole_solid_1, hole_external)) +blocks.append(geompy.MakeCommon(hole_solid_1, hole_median )) -blocks.append( MakeCut(hole_solid_2, hole_external)) -blocks.append(MakeCommon(hole_solid_2, hole_median )) +blocks.append( geompy.MakeCut(hole_solid_2, hole_external)) +blocks.append(geompy.MakeCommon(hole_solid_2, hole_median )) -blocks.append( MakeCut(hole_solid_3, hole_external)) -blocks.append(MakeCommon(hole_solid_3, hole_median )) +blocks.append( geompy.MakeCut(hole_solid_3, hole_external)) +blocks.append(geompy.MakeCommon(hole_solid_3, hole_median )) -blocks.append( MakeCut(hole_solid_4, hole_external)) -blocks.append(MakeCommon(hole_solid_4, hole_median )) +blocks.append( geompy.MakeCut(hole_solid_4, hole_external)) +blocks.append(geompy.MakeCommon(hole_solid_4, hole_median )) # The full part # ============= @@ -114,12 +120,12 @@ blocks.append(MakeCommon(hole_solid_4, hole_median )) # Vertex of the full part # ----------------------- -full_point_11 = MakeVertex(0 , 0 , cyl_dz) -full_point_21 = MakeVertex(box_dx, 0 , cyl_dz) -full_point_12 = MakeVertex(0 , box_dy, cyl_dz) -full_point_22 = MakeVertex(box_dx, box_dy, cyl_dz) +full_point_11 = geompy.MakeVertex(0 , 0 , cyl_dz) +full_point_21 = geompy.MakeVertex(box_dx, 0 , cyl_dz) +full_point_12 = geompy.MakeVertex(0 , box_dy, cyl_dz) +full_point_22 = geompy.MakeVertex(box_dx, box_dy, cyl_dz) -full_center = MakeVertex(cyl_x, cyl_y, cyl_dz) +full_center = geompy.MakeVertex(cyl_x, cyl_y, cyl_dz) # Faces of the full part # ---------------------- @@ -134,31 +140,31 @@ full_face_4 = triangle(full_point_11, full_point_12, full_center) full_dz = box_dz - cyl_dz -full_solid_1 = MakePrismVecH(full_face_1, cyl_dir, full_dz) -full_solid_2 = MakePrismVecH(full_face_2, cyl_dir, full_dz) -full_solid_3 = MakePrismVecH(full_face_3, cyl_dir, full_dz) -full_solid_4 = MakePrismVecH(full_face_4, cyl_dir, full_dz) +full_solid_1 = geompy.MakePrismVecH(full_face_1, cyl_dir, full_dz) +full_solid_2 = geompy.MakePrismVecH(full_face_2, cyl_dir, full_dz) +full_solid_3 = geompy.MakePrismVecH(full_face_3, cyl_dir, full_dz) +full_solid_4 = geompy.MakePrismVecH(full_face_4, cyl_dir, full_dz) -full_internal = MakeCylinder(full_center, cyl_dir, cyl_radius , full_dz) -full_external = MakeCylinder(full_center, cyl_dir, cyl_radius+cyl_thick, full_dz) -full_median = MakeCut(full_external, full_internal) +full_internal = geompy.MakeCylinder(full_center, cyl_dir, cyl_radius , full_dz) +full_external = geompy.MakeCylinder(full_center, cyl_dir, cyl_radius+cyl_thick, full_dz) +full_median = geompy.MakeCut(full_external, full_internal) # Boolean operations # ------------------ full = [] -full.append( MakeCut(full_solid_1, full_external)) -full.append(MakeCommon(full_solid_1, full_median)) +full.append( geompy.MakeCut(full_solid_1, full_external)) +full.append(geompy.MakeCommon(full_solid_1, full_median)) -full.append( MakeCut(full_solid_2, full_external)) -full.append(MakeCommon(full_solid_2, full_median )) +full.append( geompy.MakeCut(full_solid_2, full_external)) +full.append(geompy.MakeCommon(full_solid_2, full_median )) -full.append( MakeCut(full_solid_3, full_external)) -full.append(MakeCommon(full_solid_3, full_median)) +full.append( geompy.MakeCut(full_solid_3, full_external)) +full.append(geompy.MakeCommon(full_solid_3, full_median)) -full.append( MakeCut(full_solid_4, full_external)) -full.append(MakeCommon(full_solid_4, full_median)) +full.append( geompy.MakeCut(full_solid_4, full_external)) +full.append(geompy.MakeCommon(full_solid_4, full_median)) # Filling the hole # ---------------- @@ -167,56 +173,54 @@ box_d = cyl_radius/3 x = cyl_x-box_d y = x * cyl_y / cyl_x -box_point_11 = MakeVertex(x, y, cyl_dz) +box_point_11 = geompy.MakeVertex(x, y, cyl_dz) x = cyl_x+box_d y = (box_dx - x) * cyl_y / (box_dx - cyl_x) -box_point_12 = MakeVertex(x, y, cyl_dz) +box_point_12 = geompy.MakeVertex(x, y, cyl_dz) x = cyl_x-box_d y = box_dy - x * (box_dy - cyl_y) / cyl_x -box_point_21 = MakeVertex(x, y, cyl_dz) +box_point_21 = geompy.MakeVertex(x, y, cyl_dz) x = cyl_x+box_d y = box_dy - (box_dx - x) * (box_dy - cyl_y) / (box_dx - cyl_x) -box_point_22 = MakeVertex(x, y, cyl_dz) +box_point_22 = geompy.MakeVertex(x, y, cyl_dz) -box_face = MakeQuad4Vertices(box_point_11, box_point_12, box_point_21, box_point_22) +box_face = geompy.MakeQuad4Vertices(box_point_11, box_point_12, box_point_21, box_point_22) -box = MakePrismVecH(box_face, cyl_dir, full_dz) +box = geompy.MakePrismVecH(box_face, cyl_dir, full_dz) full.append(box) -full.append(MakeCut(MakeCommon(full_solid_1, full_internal), box)) -full.append(MakeCut(MakeCommon(full_solid_2, full_internal), box)) -full.append(MakeCut(MakeCommon(full_solid_3, full_internal), box)) -full.append(MakeCut(MakeCommon(full_solid_4, full_internal), box)) +full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_1, full_internal), box)) +full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_2, full_internal), box)) +full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_3, full_internal), box)) +full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_4, full_internal), box)) # Cut the cylinder thikness # ------------------------- -full_plan = MakePlane(MakeVertex(0, 0, cyl_dz+cyl_thick), cyl_dir, 5000) +full_plan = geompy.MakePlane(geompy.MakeVertex(0, 0, cyl_dz+cyl_thick), cyl_dir, 5000) -full_parts = MakePartition(full, [full_plan], [], [], ShapeType["SOLID"]) +full_parts = geompy.MakePartition(full, [full_plan], [], [], geompy.ShapeType["SOLID"]) # Geometry result # --------------- blocks.append(full_parts) -piece_cpd = MakeCompound(blocks) +piece_cpd = geompy.MakeCompound(blocks) -piece_ok = RemoveExtraEdges(piece_cpd, doUnionFaces=True) +piece_ok = geompy.RemoveExtraEdges(piece_cpd, doUnionFaces=True) -piece = MakeGlueFaces(piece_ok, 1.e-3) +piece = geompy.MakeGlueFaces(piece_ok, 1.e-3) -piece_id = addToStudy(piece, "ex13_hole1partial") +piece_id = geompy.addToStudy(piece, "ex13_hole1partial") # Meshing # ======= -smesh.SetCurrentStudy(salome.myStudy) - # Create a mesh # ------------- @@ -233,7 +237,7 @@ hexa.Hexahedron() # ---------------- def local(x, y, z, d): - edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z)) + edge = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(x, y, z)) algo = hexa.Segment(edge) algo.NumberOfSegments(d) algo.Propagation() diff --git a/src/SMESH_SWIG/ex14_cyl1holed.py b/src/SMESH_SWIG/ex14_cyl1holed.py index d68cc001c..02eb337af 100644 --- a/src/SMESH_SWIG/ex14_cyl1holed.py +++ b/src/SMESH_SWIG/ex14_cyl1holed.py @@ -23,9 +23,15 @@ # ======================================= # -from geompy import * +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import smesh +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # Geometrie # ========= @@ -52,19 +58,19 @@ g_trim = 15000 # Construire le cylindre # ---------------------- -c_point = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur) -c_dir = MakeVectorDXDYDZ(0, 0, 1) +c_point = geompy.MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur) +c_dir = geompy.MakeVectorDXDYDZ(0, 0, 1) c_hauteur = 2*g_cyl_demiHauteur -c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur) +c_cylindre = geompy.MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur) # Trouer le cylindre par un minuscule cylindre excentre # ----------------------------------------------------- t_hauteur = g_cyl_demiHauteur -t_point = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur) -t_trou = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur) +t_point = geompy.MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur) +t_trou = geompy.MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur) -t_piece = MakeCut(c_cylindre, t_trou) +t_piece = geompy.MakeCut(c_cylindre, t_trou) # Geometrie hexahedrique # ====================== @@ -73,10 +79,10 @@ t_piece = MakeCut(c_cylindre, t_trou) # -------- h_outils = [] -h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim)) -h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim)) +h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(1, 0, 0), g_trim)) +h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(0, 1, 0), g_trim)) -h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"]) +h_piece = geompy.MakePartition([t_piece], h_outils, [], [], geompy.ShapeType["SOLID"]) # Decouper pour les conditions locales # ------------------------------------ @@ -87,21 +93,19 @@ l_n = 12 l_hauteur = c_hauteur/l_n while l_i algo.smeshBuilder.xxxx | + | +=============================================================================== +""" diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py new file mode 100644 index 000000000..25bf8e9e0 --- /dev/null +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -0,0 +1,4463 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# File : smeshBuilder.py +# Author : Francis KLOSS, OCC +# Module : SMESH + +## @package smeshBuilder +# Python API for SALOME %Mesh module + +## @defgroup l1_auxiliary Auxiliary methods and structures +## @defgroup l1_creating Creating meshes +## @{ +## @defgroup l2_impexp Importing and exporting meshes +## @defgroup l2_construct Constructing meshes +## @defgroup l2_algorithms Defining Algorithms +## @{ +## @defgroup l3_algos_basic Basic meshing algorithms +## @defgroup l3_algos_proj Projection Algorithms +## @defgroup l3_algos_radialp Radial Prism +## @defgroup l3_algos_segmarv Segments around Vertex +## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm + +## @} +## @defgroup l2_hypotheses Defining hypotheses +## @{ +## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses +## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses +## @defgroup l3_hypos_maxvol Max Element Volume hypothesis +## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis +## @defgroup l3_hypos_additi Additional Hypotheses + +## @} +## @defgroup l2_submeshes Constructing submeshes +## @defgroup l2_compounds Building Compounds +## @defgroup l2_editing Editing Meshes + +## @} +## @defgroup l1_meshinfo Mesh Information +## @defgroup l1_controls Quality controls and Filtering +## @defgroup l1_grouping Grouping elements +## @{ +## @defgroup l2_grps_create Creating groups +## @defgroup l2_grps_edit Editing groups +## @defgroup l2_grps_operon Using operations on groups +## @defgroup l2_grps_delete Deleting Groups + +## @} +## @defgroup l1_modifying Modifying meshes +## @{ +## @defgroup l2_modif_add Adding nodes and elements +## @defgroup l2_modif_del Removing nodes and elements +## @defgroup l2_modif_edit Modifying nodes and elements +## @defgroup l2_modif_renumber Renumbering nodes and elements +## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging) +## @defgroup l2_modif_movenode Moving nodes +## @defgroup l2_modif_throughp Mesh through point +## @defgroup l2_modif_invdiag Diagonal inversion of elements +## @defgroup l2_modif_unitetri Uniting triangles +## @defgroup l2_modif_changori Changing orientation of elements +## @defgroup l2_modif_cutquadr Cutting quadrangles +## @defgroup l2_modif_smooth Smoothing +## @defgroup l2_modif_extrurev Extrusion and Revolution +## @defgroup l2_modif_patterns Pattern mapping +## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh + +## @} +## @defgroup l1_measurements Measurements + +import salome +from salome.geom import geomBuilder + +import SMESH # This is necessary for back compatibility +from SMESH import * +from salome.smesh.smesh_algorithm import Mesh_Algorithm + +import SALOME +import SALOMEDS +import os + +## @addtogroup l1_auxiliary +## @{ + +## Converts an angle from degrees to radians +def DegreesToRadians(AngleInDegrees): + from math import pi + return AngleInDegrees * pi / 180.0 + +import salome_notebook +notebook = salome_notebook.notebook +# Salome notebook variable separator +var_separator = ":" + +## Return list of variable values from salome notebook. +# The last argument, if is callable, is used to modify values got from notebook +def ParseParameters(*args): + Result = [] + Parameters = "" + hasVariables = False + varModifFun=None + if args and callable( args[-1] ): + args, varModifFun = args[:-1], args[-1] + for parameter in args: + + Parameters += str(parameter) + var_separator + + if isinstance(parameter,str): + # check if there is an inexistent variable name + if not notebook.isVariable(parameter): + raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!" + parameter = notebook.get(parameter) + hasVariables = True + if varModifFun: + parameter = varModifFun(parameter) + pass + pass + Result.append(parameter) + + pass + Parameters = Parameters[:-1] + Result.append( Parameters ) + Result.append( hasVariables ) + return Result + +# Parse parameters converting variables to radians +def ParseAngles(*args): + return ParseParameters( *( args + (DegreesToRadians, ))) + +# Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables. +# Parameters are stored in PointStruct.parameters attribute +def __initPointStruct(point,*args): + point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args) + pass +SMESH.PointStruct.__init__ = __initPointStruct + +# Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables. +# Parameters are stored in AxisStruct.parameters attribute +def __initAxisStruct(ax,*args): + ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args) + pass +SMESH.AxisStruct.__init__ = __initAxisStruct + +smeshPrecisionConfusion = 1.e-07 +def IsEqual(val1, val2, tol=smeshPrecisionConfusion): + if abs(val1 - val2) < tol: + return True + return False + +NO_NAME = "NoName" + +## Gets object name +def GetName(obj): + if obj: + # object not null + if isinstance(obj, SALOMEDS._objref_SObject): + # study object + return obj.GetName() + try: + ior = salome.orb.object_to_string(obj) + except: + ior = None + if ior: + # CORBA object + studies = salome.myStudyManager.GetOpenStudies() + for sname in studies: + s = salome.myStudyManager.GetStudyByName(sname) + if not s: continue + sobj = s.FindObjectIOR(ior) + if not sobj: continue + return sobj.GetName() + if hasattr(obj, "GetName"): + # unknown CORBA object, having GetName() method + return obj.GetName() + else: + # unknown CORBA object, no GetName() method + return NO_NAME + pass + if hasattr(obj, "GetName"): + # unknown non-CORBA object, having GetName() method + return obj.GetName() + pass + raise RuntimeError, "Null or invalid object" + +## Prints error message if a hypothesis was not assigned. +def TreatHypoStatus(status, hypName, geomName, isAlgo): + if isAlgo: + hypType = "algorithm" + else: + hypType = "hypothesis" + pass + if status == HYP_UNKNOWN_FATAL : + reason = "for unknown reason" + elif status == HYP_INCOMPATIBLE : + reason = "this hypothesis mismatches the algorithm" + elif status == HYP_NOTCONFORM : + reason = "a non-conform mesh would be built" + elif status == HYP_ALREADY_EXIST : + if isAlgo: return # it does not influence anything + reason = hypType + " of the same dimension is already assigned to this shape" + elif status == HYP_BAD_DIM : + reason = hypType + " mismatches the shape" + elif status == HYP_CONCURENT : + reason = "there are concurrent hypotheses on sub-shapes" + elif status == HYP_BAD_SUBSHAPE : + reason = "the shape is neither the main one, nor its sub-shape, nor a valid group" + elif status == HYP_BAD_GEOMETRY: + reason = "geometry mismatches the expectation of the algorithm" + elif status == HYP_HIDDEN_ALGO: + reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions" + elif status == HYP_HIDING_ALGO: + reason = "it hides algorithms of lower dimensions by generating elements of all dimensions" + elif status == HYP_NEED_SHAPE: + reason = "Algorithm can't work without shape" + else: + return + hypName = '"' + hypName + '"' + geomName= '"' + geomName+ '"' + if status < HYP_UNKNOWN_FATAL and not geomName =='""': + print hypName, "was assigned to", geomName,"but", reason + elif not geomName == '""': + print hypName, "was not assigned to",geomName,":", reason + else: + print hypName, "was not assigned:", reason + pass + +## Private method. Add geom (sub-shape of the main shape) into the study if not yet there +def AssureGeomPublished(mesh, geom, name=''): + if not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ): + return + if not geom.GetStudyEntry() and \ + mesh.smeshpyD.GetCurrentStudy(): + ## set the study + studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId() + if studyID != mesh.geompyD.myStudyId: + mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy()) + ## get a name + if not name and geom.GetShapeType() != geomBuilder.GEOM.COMPOUND: + # for all groups SubShapeName() returns "Compound_-1" + name = mesh.geompyD.SubShapeName(geom, mesh.geom) + if not name: + name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000) + ## publish + mesh.geompyD.addToStudyInFather( mesh.geom, geom, name ) + return + +## Return the first vertex of a geometrical edge by ignoring orientation +def FirstVertexOnCurve(edge): + vv = geomBuilder.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"]) + if not vv: + raise TypeError, "Given object has no vertices" + if len( vv ) == 1: return vv[0] + v0 = geomBuilder.MakeVertexOnCurve(edge,0.) + xyz = geomBuilder.PointCoordinates( v0 ) # coords of the first vertex + xyz1 = geomBuilder.PointCoordinates( vv[0] ) + xyz2 = geomBuilder.PointCoordinates( vv[1] ) + dist1, dist2 = 0,0 + for i in range(3): + dist1 += abs( xyz[i] - xyz1[i] ) + dist2 += abs( xyz[i] - xyz2[i] ) + if dist1 < dist2: + return vv[0] + else: + return vv[1] + +# end of l1_auxiliary +## @} + + +# Warning: smeshInst is a singleton +smeshInst = None +engine = None +doLcc = False + +## This class allows to create, load or manipulate meshes +# It has a set of methods to create load or copy meshes, to combine several meshes. +# It also has methods to get infos on meshes. +class smeshBuilder(object, SMESH._objref_SMESH_Gen): + + # MirrorType enumeration + POINT = SMESH_MeshEditor.POINT + AXIS = SMESH_MeshEditor.AXIS + PLANE = SMESH_MeshEditor.PLANE + + # Smooth_Method enumeration + LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH + CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH + + PrecisionConfusion = smeshPrecisionConfusion + + # TopAbs_State enumeration + [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4) + + # Methods of splitting a hexahedron into tetrahedra + Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3 + + def __new__(cls): + global engine + global smeshInst + global doLcc + #print "__new__", engine, smeshInst, doLcc + + if smeshInst is None: + # smesh engine is either retrieved from engine, or created + smeshInst = engine + # Following test avoids a recursive loop + if doLcc: + if smeshInst is not None: + # smesh engine not created: existing engine found + doLcc = False + if doLcc: + doLcc = False + # FindOrLoadComponent called: + # 1. CORBA resolution of server + # 2. the __new__ method is called again + #print "smeshInst = lcc.FindOrLoadComponent ", engine, smeshInst, doLcc + smeshInst = salome.lcc.FindOrLoadComponent( "FactoryServer", "SMESH" ) + else: + # FindOrLoadComponent not called + if smeshInst is None: + # smeshBuilder instance is created from lcc.FindOrLoadComponent + #print "smeshInst = super(smeshBuilder,cls).__new__(cls) ", engine, smeshInst, doLcc + smeshInst = super(smeshBuilder,cls).__new__(cls) + else: + # smesh engine not created: existing engine found + #print "existing ", engine, smeshInst, doLcc + pass + + return smeshInst + + return smeshInst + + def __init__(self): + #print "__init__" + SMESH._objref_SMESH_Gen.__init__(self) + + ## Dump component to the Python script + # This method overrides IDL function to allow default values for the parameters. + def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True): + return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile) + + ## Set mode of DumpPython(), \a historical or \a snapshot. + # In the \a historical mode, the Python Dump script includes all commands + # performed by SMESH engine. In the \a snapshot mode, commands + # relating to objects removed from the Study are excluded from the script + # as well as commands not influencing the current state of meshes + def SetDumpPythonHistorical(self, isHistorical): + if isHistorical: val = "true" + else: val = "false" + SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val) + + ## Sets the current study and Geometry component + # @ingroup l1_auxiliary + def init_smesh(self,theStudy,geompyD = None): + #print "init_smesh" + self.SetCurrentStudy(theStudy,geompyD) + + ## Creates an empty Mesh. This mesh can have an underlying geometry. + # @param obj the Geometrical object on which the mesh is built. If not defined, + # the mesh will have no underlying geometry. + # @param name the name for the new mesh. + # @return an instance of Mesh class. + # @ingroup l2_construct + def Mesh(self, obj=0, name=0): + if isinstance(obj,str): + obj,name = name,obj + return Mesh(self,self.geompyD,obj,name) + + ## Returns a long value from enumeration + # @ingroup l1_controls + def EnumToLong(self,theItem): + return theItem._v + + ## Returns a string representation of the color. + # To be used with filters. + # @param c color value (SALOMEDS.Color) + # @ingroup l1_controls + def ColorToString(self,c): + val = "" + if isinstance(c, SALOMEDS.Color): + val = "%s;%s;%s" % (c.R, c.G, c.B) + elif isinstance(c, str): + val = c + else: + raise ValueError, "Color value should be of string or SALOMEDS.Color type" + return val + + ## Gets PointStruct from vertex + # @param theVertex a GEOM object(vertex) + # @return SMESH.PointStruct + # @ingroup l1_auxiliary + def GetPointStruct(self,theVertex): + [x, y, z] = self.geompyD.PointCoordinates(theVertex) + return PointStruct(x,y,z) + + ## Gets DirStruct from vector + # @param theVector a GEOM object(vector) + # @return SMESH.DirStruct + # @ingroup l1_auxiliary + def GetDirStruct(self,theVector): + vertices = self.geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] ) + if(len(vertices) != 2): + print "Error: vector object is incorrect." + return None + p1 = self.geompyD.PointCoordinates(vertices[0]) + p2 = self.geompyD.PointCoordinates(vertices[1]) + pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) + dirst = DirStruct(pnt) + return dirst + + ## Makes DirStruct from a triplet + # @param x,y,z vector components + # @return SMESH.DirStruct + # @ingroup l1_auxiliary + def MakeDirStruct(self,x,y,z): + pnt = PointStruct(x,y,z) + return DirStruct(pnt) + + ## Get AxisStruct from object + # @param theObj a GEOM object (line or plane) + # @return SMESH.AxisStruct + # @ingroup l1_auxiliary + def GetAxisStruct(self,theObj): + edges = self.geompyD.SubShapeAll( theObj, geomBuilder.geomBuilder.ShapeType["EDGE"] ) + if len(edges) > 1: + vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) + vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) + vertex1 = self.geompyD.PointCoordinates(vertex1) + vertex2 = self.geompyD.PointCoordinates(vertex2) + vertex3 = self.geompyD.PointCoordinates(vertex3) + vertex4 = self.geompyD.PointCoordinates(vertex4) + v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]] + v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]] + normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ] + axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2]) + return axis + elif len(edges) == 1: + vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) + p1 = self.geompyD.PointCoordinates( vertex1 ) + p2 = self.geompyD.PointCoordinates( vertex2 ) + axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) + return axis + return None + + # From SMESH_Gen interface: + # ------------------------ + + ## Sets the given name to the object + # @param obj the object to rename + # @param name a new object name + # @ingroup l1_auxiliary + def SetName(self, obj, name): + if isinstance( obj, Mesh ): + obj = obj.GetMesh() + elif isinstance( obj, Mesh_Algorithm ): + obj = obj.GetAlgorithm() + ior = salome.orb.object_to_string(obj) + SMESH._objref_SMESH_Gen.SetName(self, ior, name) + + ## Sets the current mode + # @ingroup l1_auxiliary + def SetEmbeddedMode( self,theMode ): + #self.SetEmbeddedMode(theMode) + SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode) + + ## Gets the current mode + # @ingroup l1_auxiliary + def IsEmbeddedMode(self): + #return self.IsEmbeddedMode() + return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self) + + ## Sets the current study + # @ingroup l1_auxiliary + def SetCurrentStudy( self, theStudy, geompyD = None ): + #self.SetCurrentStudy(theStudy) + if not geompyD: + from salome.geom import geomBuilder + geompyD = geomBuilder.geom + pass + self.geompyD=geompyD + self.SetGeomEngine(geompyD) + SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy) + global notebook + if theStudy: + notebook = salome_notebook.NoteBook( theStudy ) + else: + notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() ) + + ## Gets the current study + # @ingroup l1_auxiliary + def GetCurrentStudy(self): + #return self.GetCurrentStudy() + return SMESH._objref_SMESH_Gen.GetCurrentStudy(self) + + ## Creates a Mesh object importing data from the given UNV file + # @return an instance of Mesh class + # @ingroup l2_impexp + def CreateMeshesFromUNV( self,theFileName ): + aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName) + aMesh = Mesh(self, self.geompyD, aSmeshMesh) + return aMesh + + ## Creates a Mesh object(s) importing data from the given MED file + # @return a list of Mesh class instances + # @ingroup l2_impexp + def CreateMeshesFromMED( self,theFileName ): + aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName) + aMeshes = [] + for iMesh in range(len(aSmeshMeshes)) : + aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) + aMeshes.append(aMesh) + return aMeshes, aStatus + + ## Creates a Mesh object(s) importing data from the given SAUV file + # @return a list of Mesh class instances + # @ingroup l2_impexp + def CreateMeshesFromSAUV( self,theFileName ): + aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName) + aMeshes = [] + for iMesh in range(len(aSmeshMeshes)) : + aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) + aMeshes.append(aMesh) + return aMeshes, aStatus + + ## Creates a Mesh object importing data from the given STL file + # @return an instance of Mesh class + # @ingroup l2_impexp + def CreateMeshesFromSTL( self, theFileName ): + aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName) + aMesh = Mesh(self, self.geompyD, aSmeshMesh) + return aMesh + + ## Creates Mesh objects importing data from the given CGNS file + # @return an instance of Mesh class + # @ingroup l2_impexp + def CreateMeshesFromCGNS( self, theFileName ): + aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName) + aMeshes = [] + for iMesh in range(len(aSmeshMeshes)) : + aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) + aMeshes.append(aMesh) + return aMeshes, aStatus + + ## Creates a Mesh object importing data from the given GMF file + # @return [ an instance of Mesh class, SMESH::ComputeError ] + # @ingroup l2_impexp + def CreateMeshesFromGMF( self, theFileName ): + aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self, + theFileName, + True) + if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment + return Mesh(self, self.geompyD, aSmeshMesh), error + + ## Concatenate the given meshes into one mesh. + # @return an instance of Mesh class + # @param meshes the meshes to combine into one mesh + # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed + # @param mergeNodesAndElements if true, equal nodes and elements aremerged + # @param mergeTolerance tolerance for merging nodes + # @param allGroups forces creation of groups of all elements + # @param name name of a new mesh + def Concatenate( self, meshes, uniteIdenticalGroups, + mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False, + name = ""): + if not meshes: return None + for i,m in enumerate(meshes): + if isinstance(m, Mesh): + meshes[i] = m.GetMesh() + mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance) + meshes[0].SetParameters(Parameters) + if allGroups: + aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( + self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) + else: + aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate( + self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) + aMesh = Mesh(self, self.geompyD, aSmeshMesh, name=name) + return aMesh + + ## Create a mesh by copying a part of another mesh. + # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group; + # to copy nodes or elements not contained in any mesh object, + # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart + # @param meshName a name of the new mesh + # @param toCopyGroups to create in the new mesh groups the copied elements belongs to + # @param toKeepIDs to preserve IDs of the copied elements or not + # @return an instance of Mesh class + def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False): + if (isinstance( meshPart, Mesh )): + meshPart = meshPart.GetMesh() + mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs ) + return Mesh(self, self.geompyD, mesh) + + ## From SMESH_Gen interface + # @return the list of integer values + # @ingroup l1_auxiliary + def GetSubShapesId( self, theMainObject, theListOfSubObjects ): + return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects) + + ## From SMESH_Gen interface. Creates a pattern + # @return an instance of SMESH_Pattern + # + # Example of Patterns usage + # @ingroup l2_modif_patterns + def GetPattern(self): + return SMESH._objref_SMESH_Gen.GetPattern(self) + + ## Sets number of segments per diagonal of boundary box of geometry by which + # default segment length of appropriate 1D hypotheses is defined. + # Default value is 10 + # @ingroup l1_auxiliary + def SetBoundaryBoxSegmentation(self, nbSegments): + SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments) + + # Filtering. Auxiliary functions: + # ------------------------------ + + ## Creates an empty criterion + # @return SMESH.Filter.Criterion + # @ingroup l1_controls + def GetEmptyCriterion(self): + Type = self.EnumToLong(FT_Undefined) + Compare = self.EnumToLong(FT_Undefined) + Threshold = 0 + ThresholdStr = "" + ThresholdID = "" + UnaryOp = self.EnumToLong(FT_Undefined) + BinaryOp = self.EnumToLong(FT_Undefined) + Tolerance = 1e-07 + TypeOfElement = ALL + Precision = -1 ##@1e-07 + return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID, + UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision) + + ## Creates a criterion by the given parameters + # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below) + # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME) + # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.) + # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} + # @param Threshold the threshold value (range of ids as string, shape, numeric) + # @param UnaryOp FT_LogicalNOT or FT_Undefined + # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or + # FT_Undefined (must be for the last criterion of all criteria) + # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, + # FT_LyingOnGeom, FT_CoplanarFaces criteria + # @return SMESH.Filter.Criterion + # + # Example of Criteria usage + # @ingroup l1_controls + def GetCriterion(self,elementType, + CritType, + Compare = FT_EqualTo, + Threshold="", + UnaryOp=FT_Undefined, + BinaryOp=FT_Undefined, + Tolerance=1e-07): + if not CritType in SMESH.FunctorType._items: + raise TypeError, "CritType should be of SMESH.FunctorType" + aCriterion = self.GetEmptyCriterion() + aCriterion.TypeOfElement = elementType + aCriterion.Type = self.EnumToLong(CritType) + aCriterion.Tolerance = Tolerance + + aThreshold = Threshold + + if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]: + aCriterion.Compare = self.EnumToLong(Compare) + elif Compare == "=" or Compare == "==": + aCriterion.Compare = self.EnumToLong(FT_EqualTo) + elif Compare == "<": + aCriterion.Compare = self.EnumToLong(FT_LessThan) + elif Compare == ">": + aCriterion.Compare = self.EnumToLong(FT_MoreThan) + elif Compare != FT_Undefined: + aCriterion.Compare = self.EnumToLong(FT_EqualTo) + aThreshold = Compare + + if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface, + FT_BelongToCylinder, FT_LyingOnGeom]: + # Checks that Threshold is GEOM object + if isinstance(aThreshold, geomBuilder.GEOM._objref_GEOM_Object): + aCriterion.ThresholdStr = GetName(aThreshold) + aCriterion.ThresholdID = aThreshold.GetStudyEntry() + if not aCriterion.ThresholdID: + name = aCriterion.ThresholdStr + if not name: + name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000) + aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name ) + #raise RuntimeError, "Threshold shape must be published" + else: + print "Error: The Threshold should be a shape." + return None + if isinstance(UnaryOp,float): + aCriterion.Tolerance = UnaryOp + UnaryOp = FT_Undefined + pass + elif CritType == FT_RangeOfIds: + # Checks that Threshold is string + if isinstance(aThreshold, str): + aCriterion.ThresholdStr = aThreshold + else: + print "Error: The Threshold should be a string." + return None + elif CritType == FT_CoplanarFaces: + # Checks the Threshold + if isinstance(aThreshold, int): + aCriterion.ThresholdID = str(aThreshold) + elif isinstance(aThreshold, str): + ID = int(aThreshold) + if ID < 1: + raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold + aCriterion.ThresholdID = aThreshold + else: + raise ValueError,\ + "The Threshold should be an ID of mesh face and not '%s'"%aThreshold + elif CritType == FT_ElemGeomType: + # Checks the Threshold + try: + aCriterion.Threshold = self.EnumToLong(aThreshold) + assert( aThreshold in SMESH.GeometryType._items ) + except: + if isinstance(aThreshold, int): + aCriterion.Threshold = aThreshold + else: + print "Error: The Threshold should be an integer or SMESH.GeometryType." + return None + pass + pass + elif CritType == FT_EntityType: + # Checks the Threshold + try: + aCriterion.Threshold = self.EnumToLong(aThreshold) + assert( aThreshold in SMESH.EntityType._items ) + except: + if isinstance(aThreshold, int): + aCriterion.Threshold = aThreshold + else: + print "Error: The Threshold should be an integer or SMESH.EntityType." + return None + pass + pass + + elif CritType == FT_GroupColor: + # Checks the Threshold + try: + aCriterion.ThresholdStr = self.ColorToString(aThreshold) + except: + print "Error: The threshold value should be of SALOMEDS.Color type" + return None + pass + elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces, + FT_LinearOrQuadratic, FT_BadOrientedVolume, + FT_BareBorderFace, FT_BareBorderVolume, + FT_OverConstrainedFace, FT_OverConstrainedVolume, + FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]: + # At this point the Threshold is unnecessary + if aThreshold == FT_LogicalNOT: + aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT) + elif aThreshold in [FT_LogicalAND, FT_LogicalOR]: + aCriterion.BinaryOp = aThreshold + else: + # Check Threshold + try: + aThreshold = float(aThreshold) + aCriterion.Threshold = aThreshold + except: + print "Error: The Threshold should be a number." + return None + + if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT: + aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT) + + if Threshold in [FT_LogicalAND, FT_LogicalOR]: + aCriterion.BinaryOp = self.EnumToLong(Threshold) + + if UnaryOp in [FT_LogicalAND, FT_LogicalOR]: + aCriterion.BinaryOp = self.EnumToLong(UnaryOp) + + if BinaryOp in [FT_LogicalAND, FT_LogicalOR]: + aCriterion.BinaryOp = self.EnumToLong(BinaryOp) + + return aCriterion + + ## Creates a filter with the given parameters + # @param elementType the type of elements in the group + # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) + # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} + # @param Threshold the threshold value (range of id ids as string, shape, numeric) + # @param UnaryOp FT_LogicalNOT or FT_Undefined + # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, + # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria + # @return SMESH_Filter + # + # Example of Filters usage + # @ingroup l1_controls + def GetFilter(self,elementType, + CritType=FT_Undefined, + Compare=FT_EqualTo, + Threshold="", + UnaryOp=FT_Undefined, + Tolerance=1e-07): + aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance) + aFilterMgr = self.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + aCriteria = [] + aCriteria.append(aCriterion) + aFilter.SetCriteria(aCriteria) + aFilterMgr.UnRegister() + return aFilter + + ## Creates a filter from criteria + # @param criteria a list of criteria + # @return SMESH_Filter + # + # Example of Filters usage + # @ingroup l1_controls + def GetFilterFromCriteria(self,criteria): + aFilterMgr = self.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + aFilter.SetCriteria(criteria) + aFilterMgr.UnRegister() + return aFilter + + ## Creates a numerical functor by its type + # @param theCriterion FT_...; functor type + # @return SMESH_NumericalFunctor + # @ingroup l1_controls + def GetFunctor(self,theCriterion): + if isinstance( theCriterion, SMESH._objref_NumericalFunctor ): + return theCriterion + aFilterMgr = self.CreateFilterManager() + functor = None + if theCriterion == FT_AspectRatio: + functor = aFilterMgr.CreateAspectRatio() + elif theCriterion == FT_AspectRatio3D: + functor = aFilterMgr.CreateAspectRatio3D() + elif theCriterion == FT_Warping: + functor = aFilterMgr.CreateWarping() + elif theCriterion == FT_MinimumAngle: + functor = aFilterMgr.CreateMinimumAngle() + elif theCriterion == FT_Taper: + functor = aFilterMgr.CreateTaper() + elif theCriterion == FT_Skew: + functor = aFilterMgr.CreateSkew() + elif theCriterion == FT_Area: + functor = aFilterMgr.CreateArea() + elif theCriterion == FT_Volume3D: + functor = aFilterMgr.CreateVolume3D() + elif theCriterion == FT_MaxElementLength2D: + functor = aFilterMgr.CreateMaxElementLength2D() + elif theCriterion == FT_MaxElementLength3D: + functor = aFilterMgr.CreateMaxElementLength3D() + elif theCriterion == FT_MultiConnection: + functor = aFilterMgr.CreateMultiConnection() + elif theCriterion == FT_MultiConnection2D: + functor = aFilterMgr.CreateMultiConnection2D() + elif theCriterion == FT_Length: + functor = aFilterMgr.CreateLength() + elif theCriterion == FT_Length2D: + functor = aFilterMgr.CreateLength2D() + else: + print "Error: given parameter is not numerical functor type." + aFilterMgr.UnRegister() + return functor + + ## Creates hypothesis + # @param theHType mesh hypothesis type (string) + # @param theLibName mesh plug-in library name + # @return created hypothesis instance + def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"): + hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName ) + + if isinstance( hyp, SMESH._objref_SMESH_Algo ): + return hyp + + # wrap hypothesis methods + #print "HYPOTHESIS", theHType + for meth_name in dir( hyp.__class__ ): + if not meth_name.startswith("Get") and \ + not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ): + method = getattr ( hyp.__class__, meth_name ) + if callable(method): + setattr( hyp, meth_name, hypMethodWrapper( hyp, method )) + + return hyp + + ## Gets the mesh statistic + # @return dictionary "element type" - "count of elements" + # @ingroup l1_meshinfo + def GetMeshInfo(self, obj): + if isinstance( obj, Mesh ): + obj = obj.GetMesh() + d = {} + if hasattr(obj, "GetMeshInfo"): + values = obj.GetMeshInfo() + for i in range(SMESH.Entity_Last._v): + if i < len(values): d[SMESH.EntityType._item(i)]=values[i] + pass + return d + + ## Get minimum distance between two objects + # + # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed. + # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1. + # + # @param src1 first source object + # @param src2 second source object + # @param id1 node/element id from the first source + # @param id2 node/element id from the second (or first) source + # @param isElem1 @c True if @a id1 is element id, @c False if it is node id + # @param isElem2 @c True if @a id2 is element id, @c False if it is node id + # @return minimum distance value + # @sa GetMinDistance() + # @ingroup l1_measurements + def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False): + result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2) + if result is None: + result = 0.0 + else: + result = result.value + return result + + ## Get measure structure specifying minimum distance data between two objects + # + # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed. + # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1. + # + # @param src1 first source object + # @param src2 second source object + # @param id1 node/element id from the first source + # @param id2 node/element id from the second (or first) source + # @param isElem1 @c True if @a id1 is element id, @c False if it is node id + # @param isElem2 @c True if @a id2 is element id, @c False if it is node id + # @return Measure structure or None if input data is invalid + # @sa MinDistance() + # @ingroup l1_measurements + def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False): + if isinstance(src1, Mesh): src1 = src1.mesh + if isinstance(src2, Mesh): src2 = src2.mesh + if src2 is None and id2 != 0: src2 = src1 + if not hasattr(src1, "_narrow"): return None + src1 = src1._narrow(SMESH.SMESH_IDSource) + if not src1: return None + if id1 != 0: + m = src1.GetMesh() + e = m.GetMeshEditor() + if isElem1: + src1 = e.MakeIDSource([id1], SMESH.FACE) + else: + src1 = e.MakeIDSource([id1], SMESH.NODE) + pass + if hasattr(src2, "_narrow"): + src2 = src2._narrow(SMESH.SMESH_IDSource) + if src2 and id2 != 0: + m = src2.GetMesh() + e = m.GetMeshEditor() + if isElem2: + src2 = e.MakeIDSource([id2], SMESH.FACE) + else: + src2 = e.MakeIDSource([id2], SMESH.NODE) + pass + pass + aMeasurements = self.CreateMeasurements() + result = aMeasurements.MinDistance(src1, src2) + aMeasurements.UnRegister() + return result + + ## Get bounding box of the specified object(s) + # @param objects single source object or list of source objects + # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ) + # @sa GetBoundingBox() + # @ingroup l1_measurements + def BoundingBox(self, objects): + result = self.GetBoundingBox(objects) + if result is None: + result = (0.0,)*6 + else: + result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ) + return result + + ## Get measure structure specifying bounding box data of the specified object(s) + # @param objects single source object or list of source objects + # @return Measure structure + # @sa BoundingBox() + # @ingroup l1_measurements + def GetBoundingBox(self, objects): + if isinstance(objects, tuple): + objects = list(objects) + if not isinstance(objects, list): + objects = [objects] + srclist = [] + for o in objects: + if isinstance(o, Mesh): + srclist.append(o.mesh) + elif hasattr(o, "_narrow"): + src = o._narrow(SMESH.SMESH_IDSource) + if src: srclist.append(src) + pass + pass + aMeasurements = self.CreateMeasurements() + result = aMeasurements.BoundingBox(srclist) + aMeasurements.UnRegister() + return result + +import omniORB +#Registering the new proxy for SMESH_Gen +omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshBuilder) + +## Create a new smeshBuilder instance.The smeshBuilder class provides the Python +# interface to create or load meshes. +# +# Typical use is: +# \code +# import salome +# salome.salome_init() +# from salome.smesh import smeshBuilder +# smesh = smeshBuilder.New(theStudy) +# \endcode +# @param study SALOME study, generally obtained by salome.myStudy. +# @param instance CORBA proxy of SMESH Engine. If None, the default Engine is used. +# @return smeshBuilder instance + +def New( study, instance=None): + """ + Create a new smeshBuilder instance.The smeshBuilder class provides the Python + interface to create or load meshes. + + Typical use is: + import salome + salome.salome_init() + from salome.smesh import smeshBuilder + smesh = smeshBuilder.New(theStudy) + + Parameters: + study SALOME study, generally obtained by salome.myStudy. + instance CORBA proxy of SMESH Engine. If None, the default Engine is used. + Returns: + smeshBuilder instance + """ + global engine + global smeshInst + global doLcc + engine = instance + if engine is None: + doLcc = True + smeshInst = smeshBuilder() + assert isinstance(smeshInst,smeshBuilder), "Smesh engine class is %s but should be smeshBuilder.smeshBuilder. Import salome.smesh.smeshBuilder before creating the instance."%smeshInst.__class__ + smeshInst.init_smesh(study) + return smeshInst + + +# Public class: Mesh +# ================== + +## This class allows defining and managing a mesh. +# It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes. +# It also has methods to define groups of mesh elements, to modify a mesh (by addition of +# new nodes and elements and by changing the existing entities), to get information +# about a mesh and to export a mesh into different formats. +class Mesh: + + geom = 0 + mesh = 0 + editor = 0 + + ## Constructor + # + # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and + # sets the GUI name of this mesh to \a name. + # @param smeshpyD an instance of smeshBuilder class + # @param geompyD an instance of geomBuilder class + # @param obj Shape to be meshed or SMESH_Mesh object + # @param name Study name of the mesh + # @ingroup l2_construct + def __init__(self, smeshpyD, geompyD, obj=0, name=0): + self.smeshpyD=smeshpyD + self.geompyD=geompyD + if obj is None: + obj = 0 + objHasName = False + if obj != 0: + if isinstance(obj, geomBuilder.GEOM._objref_GEOM_Object): + self.geom = obj + objHasName = True + # publish geom of mesh (issue 0021122) + if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy(): + objHasName = False + studyID = smeshpyD.GetCurrentStudy()._get_StudyId() + if studyID != geompyD.myStudyId: + geompyD.init_geom( smeshpyD.GetCurrentStudy()) + pass + if name: + geo_name = name + " shape" + else: + geo_name = "%s_%s to mesh"%(self.geom.GetShapeType(), id(self.geom)%100) + geompyD.addToStudy( self.geom, geo_name ) + self.mesh = self.smeshpyD.CreateMesh(self.geom) + + elif isinstance(obj, SMESH._objref_SMESH_Mesh): + self.SetMesh(obj) + else: + self.mesh = self.smeshpyD.CreateEmptyMesh() + if name: + self.smeshpyD.SetName(self.mesh, name) + elif objHasName: + self.smeshpyD.SetName(self.mesh, GetName(obj)) # + " mesh" + + if not self.geom: + self.geom = self.mesh.GetShapeToMesh() + + self.editor = self.mesh.GetMeshEditor() + self.functors = [None] * SMESH.FT_Undefined._v + + # set self to algoCreator's + for attrName in dir(self): + attr = getattr( self, attrName ) + if isinstance( attr, algoCreator ): + #print "algoCreator ", attrName + setattr( self, attrName, attr.copy( self )) + + ## Initializes the Mesh object from an instance of SMESH_Mesh interface + # @param theMesh a SMESH_Mesh object + # @ingroup l2_construct + def SetMesh(self, theMesh): + if self.mesh: self.mesh.UnRegister() + self.mesh = theMesh + if self.mesh: + self.mesh.Register() + self.geom = self.mesh.GetShapeToMesh() + + ## Returns the mesh, that is an instance of SMESH_Mesh interface + # @return a SMESH_Mesh object + # @ingroup l2_construct + def GetMesh(self): + return self.mesh + + ## Gets the name of the mesh + # @return the name of the mesh as a string + # @ingroup l2_construct + def GetName(self): + name = GetName(self.GetMesh()) + return name + + ## Sets a name to the mesh + # @param name a new name of the mesh + # @ingroup l2_construct + def SetName(self, name): + self.smeshpyD.SetName(self.GetMesh(), name) + + ## Gets the subMesh object associated to a \a theSubObject geometrical object. + # The subMesh object gives access to the IDs of nodes and elements. + # @param geom a geometrical object (shape) + # @param name a name for the submesh + # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape + # @ingroup l2_submeshes + def GetSubMesh(self, geom, name): + AssureGeomPublished( self, geom, name ) + submesh = self.mesh.GetSubMesh( geom, name ) + return submesh + + ## Returns the shape associated to the mesh + # @return a GEOM_Object + # @ingroup l2_construct + def GetShape(self): + return self.geom + + ## Associates the given shape to the mesh (entails the recreation of the mesh) + # @param geom the shape to be meshed (GEOM_Object) + # @ingroup l2_construct + def SetShape(self, geom): + self.mesh = self.smeshpyD.CreateMesh(geom) + + ## Loads mesh from the study after opening the study + def Load(self): + self.mesh.Load() + + ## Returns true if the hypotheses are defined well + # @param theSubObject a sub-shape of a mesh shape + # @return True or False + # @ingroup l2_construct + def IsReadyToCompute(self, theSubObject): + return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject) + + ## Returns errors of hypotheses definition. + # The list of errors is empty if everything is OK. + # @param theSubObject a sub-shape of a mesh shape + # @return a list of errors + # @ingroup l2_construct + def GetAlgoState(self, theSubObject): + return self.smeshpyD.GetAlgoState(self.mesh, theSubObject) + + ## Returns a geometrical object on which the given element was built. + # The returned geometrical object, if not nil, is either found in the + # study or published by this method with the given name + # @param theElementID the id of the mesh element + # @param theGeomName the user-defined name of the geometrical object + # @return GEOM::GEOM_Object instance + # @ingroup l2_construct + def GetGeometryByMeshElement(self, theElementID, theGeomName): + return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName ) + + ## Returns the mesh dimension depending on the dimension of the underlying shape + # or, if the mesh is not based on any shape, basing on deimension of elements + # @return mesh dimension as an integer value [0,3] + # @ingroup l1_auxiliary + def MeshDimension(self): + if self.mesh.HasShapeToMesh(): + shells = self.geompyD.SubShapeAllIDs( self.geom, self.geompyD.ShapeType["SOLID"] ) + if len( shells ) > 0 : + return 3 + elif self.geompyD.NumberOfFaces( self.geom ) > 0 : + return 2 + elif self.geompyD.NumberOfEdges( self.geom ) > 0 : + return 1 + else: + return 0; + else: + if self.NbVolumes() > 0: return 3 + if self.NbFaces() > 0: return 2 + if self.NbEdges() > 0: return 1 + return 0 + + ## Evaluates size of prospective mesh on a shape + # @return a list where i-th element is a number of elements of i-th SMESH.EntityType + # To know predicted number of e.g. edges, inquire it this way + # Evaluate()[ EnumToLong( Entity_Edge )] + def Evaluate(self, geom=0): + if geom == 0 or not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object): + if self.geom == 0: + geom = self.mesh.GetShapeToMesh() + else: + geom = self.geom + return self.smeshpyD.Evaluate(self.mesh, geom) + + + ## Computes the mesh and returns the status of the computation + # @param geom geomtrical shape on which mesh data should be computed + # @param discardModifs if True and the mesh has been edited since + # a last total re-compute and that may prevent successful partial re-compute, + # then the mesh is cleaned before Compute() + # @return True or False + # @ingroup l2_construct + def Compute(self, geom=0, discardModifs=False): + if geom == 0 or not isinstance(geom, geomBuilder.GEOM._objref_GEOM_Object): + if self.geom == 0: + geom = self.mesh.GetShapeToMesh() + else: + geom = self.geom + ok = False + try: + if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693 + self.mesh.Clear() + ok = self.smeshpyD.Compute(self.mesh, geom) + except SALOME.SALOME_Exception, ex: + print "Mesh computation failed, exception caught:" + print " ", ex.details.text + except: + import traceback + print "Mesh computation failed, exception caught:" + traceback.print_exc() + if True:#not ok: + allReasons = "" + + # Treat compute errors + computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom ) + for err in computeErrors: + shapeText = "" + if self.mesh.HasShapeToMesh(): + try: + mainIOR = salome.orb.object_to_string(geom) + for sname in salome.myStudyManager.GetOpenStudies(): + s = salome.myStudyManager.GetStudyByName(sname) + if not s: continue + mainSO = s.FindObjectIOR(mainIOR) + if not mainSO: continue + if err.subShapeID == 1: + shapeText = ' on "%s"' % mainSO.GetName() + subIt = s.NewChildIterator(mainSO) + while subIt.More(): + subSO = subIt.Value() + subIt.Next() + obj = subSO.GetObject() + if not obj: continue + go = obj._narrow( geomBuilder.GEOM._objref_GEOM_Object ) + if not go: continue + ids = go.GetSubShapeIndices() + if len(ids) == 1 and ids[0] == err.subShapeID: + shapeText = ' on "%s"' % subSO.GetName() + break + if not shapeText: + shape = self.geompyD.GetSubShape( geom, [err.subShapeID]) + if shape: + shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID) + else: + shapeText = " on subshape #%s" % (err.subShapeID) + except: + shapeText = " on subshape #%s" % (err.subShapeID) + errText = "" + stdErrors = ["OK", #COMPERR_OK + "Invalid input mesh", #COMPERR_BAD_INPUT_MESH + "std::exception", #COMPERR_STD_EXCEPTION + "OCC exception", #COMPERR_OCC_EXCEPTION + "..", #COMPERR_SLM_EXCEPTION + "Unknown exception", #COMPERR_EXCEPTION + "Memory allocation problem", #COMPERR_MEMORY_PB + "Algorithm failed", #COMPERR_ALGO_FAILED + "Unexpected geometry", #COMPERR_BAD_SHAPE + "Warning", #COMPERR_WARNING + "Computation cancelled",#COMPERR_CANCELED + "No mesh on sub-shape"] #COMPERR_NO_MESH_ON_SHAPE + if err.code > 0: + if err.code < len(stdErrors): errText = stdErrors[err.code] + else: + errText = "code %s" % -err.code + if errText: errText += ". " + errText += err.comment + if allReasons != "":allReasons += "\n" + allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText) + pass + + # Treat hyp errors + errors = self.smeshpyD.GetAlgoState( self.mesh, geom ) + for err in errors: + if err.isGlobalAlgo: + glob = "global" + else: + glob = "local" + pass + dim = err.algoDim + name = err.algoName + if len(name) == 0: + reason = '%s %sD algorithm is missing' % (glob, dim) + elif err.state == HYP_MISSING: + reason = ('%s %sD algorithm "%s" misses %sD hypothesis' + % (glob, dim, name, dim)) + elif err.state == HYP_NOTCONFORM: + reason = 'Global "Not Conform mesh allowed" hypothesis is missing' + elif err.state == HYP_BAD_PARAMETER: + reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value' + % ( glob, dim, name )) + elif err.state == HYP_BAD_GEOMETRY: + reason = ('%s %sD algorithm "%s" is assigned to mismatching' + 'geometry' % ( glob, dim, name )) + elif err.state == HYP_HIDDEN_ALGO: + reason = ('%s %sD algorithm "%s" is ignored due to presence of a %s ' + 'algorithm of upper dimension generating %sD mesh' + % ( glob, dim, name, glob, dim )) + else: + reason = ("For unknown reason. " + "Developer, revise Mesh.Compute() implementation in smeshBuilder.py!") + pass + if allReasons != "":allReasons += "\n" + allReasons += "- " + reason + pass + if not ok or allReasons != "": + msg = '"' + GetName(self.mesh) + '"' + if ok: msg += " has been computed with warnings" + else: msg += " has not been computed" + if allReasons != "": msg += ":" + else: msg += "." + print msg + print allReasons + pass + if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0: + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(self.mesh.GetStudyId()) + smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) ) + salome.sg.updateObjBrowser(1) + pass + return ok + + ## Return submesh objects list in meshing order + # @return list of list of submesh objects + # @ingroup l2_construct + def GetMeshOrder(self): + return self.mesh.GetMeshOrder() + + ## Return submesh objects list in meshing order + # @return list of list of submesh objects + # @ingroup l2_construct + def SetMeshOrder(self, submeshes): + return self.mesh.SetMeshOrder(submeshes) + + ## Removes all nodes and elements + # @ingroup l2_construct + def Clear(self): + self.mesh.Clear() + if ( salome.sg.hasDesktop() and + salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() )): + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(self.mesh.GetStudyId()) + smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) + salome.sg.updateObjBrowser(1) + + ## Removes all nodes and elements of indicated shape + # @ingroup l2_construct + def ClearSubMesh(self, geomId): + self.mesh.ClearSubMesh(geomId) + if salome.sg.hasDesktop(): + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(self.mesh.GetStudyId()) + smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) + salome.sg.updateObjBrowser(1) + + ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN + # @param fineness [0.0,1.0] defines mesh fineness + # @return True or False + # @ingroup l3_algos_basic + def AutomaticTetrahedralization(self, fineness=0): + dim = self.MeshDimension() + # assign hypotheses + self.RemoveGlobalHypotheses() + self.Segment().AutomaticLength(fineness) + if dim > 1 : + self.Triangle().LengthFromEdges() + pass + if dim > 2 : + from salome.NETGENPlugin.NETGENPluginBuilder import NETGEN + self.Tetrahedron(NETGEN) + pass + return self.Compute() + + ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron + # @param fineness [0.0, 1.0] defines mesh fineness + # @return True or False + # @ingroup l3_algos_basic + def AutomaticHexahedralization(self, fineness=0): + dim = self.MeshDimension() + # assign the hypotheses + self.RemoveGlobalHypotheses() + self.Segment().AutomaticLength(fineness) + if dim > 1 : + self.Quadrangle() + pass + if dim > 2 : + self.Hexahedron() + pass + return self.Compute() + + ## Assigns a hypothesis + # @param hyp a hypothesis to assign + # @param geom a subhape of mesh geometry + # @return SMESH.Hypothesis_Status + # @ingroup l2_hypotheses + def AddHypothesis(self, hyp, geom=0): + if isinstance( hyp, Mesh_Algorithm ): + hyp = hyp.GetAlgorithm() + pass + if not geom: + geom = self.geom + if not geom: + geom = self.mesh.GetShapeToMesh() + pass + AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName()) + status = self.mesh.AddHypothesis(geom, hyp) + isAlgo = hyp._narrow( SMESH_Algo ) + hyp_name = GetName( hyp ) + geom_name = "" + if geom: + geom_name = GetName( geom ) + TreatHypoStatus( status, hyp_name, geom_name, isAlgo ) + return status + + ## Return True if an algorithm of hypothesis is assigned to a given shape + # @param hyp a hypothesis to check + # @param geom a subhape of mesh geometry + # @return True of False + # @ingroup l2_hypotheses + def IsUsedHypothesis(self, hyp, geom): + if not hyp: # or not geom + return False + if isinstance( hyp, Mesh_Algorithm ): + hyp = hyp.GetAlgorithm() + pass + hyps = self.GetHypothesisList(geom) + for h in hyps: + if h.GetId() == hyp.GetId(): + return True + return False + + ## Unassigns a hypothesis + # @param hyp a hypothesis to unassign + # @param geom a sub-shape of mesh geometry + # @return SMESH.Hypothesis_Status + # @ingroup l2_hypotheses + def RemoveHypothesis(self, hyp, geom=0): + if isinstance( hyp, Mesh_Algorithm ): + hyp = hyp.GetAlgorithm() + pass + shape = geom + if not shape: + shape = self.geom + pass + if self.IsUsedHypothesis( hyp, shape ): + return self.mesh.RemoveHypothesis( shape, hyp ) + hypName = GetName( hyp ) + geoName = GetName( shape ) + print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName ) + return None + + ## Gets the list of hypotheses added on a geometry + # @param geom a sub-shape of mesh geometry + # @return the sequence of SMESH_Hypothesis + # @ingroup l2_hypotheses + def GetHypothesisList(self, geom): + return self.mesh.GetHypothesisList( geom ) + + ## Removes all global hypotheses + # @ingroup l2_hypotheses + def RemoveGlobalHypotheses(self): + current_hyps = self.mesh.GetHypothesisList( self.geom ) + for hyp in current_hyps: + self.mesh.RemoveHypothesis( self.geom, hyp ) + pass + pass + + ## Exports the mesh in a file in MED format and chooses the \a version of MED format + ## allowing to overwrite the file if it exists or add the exported data to its contents + # @param f is the file name + # @param auto_groups boolean parameter for creating/not creating + # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; + # the typical use is auto_groups=false. + # @param version MED format version(MED_V2_1 or MED_V2_2) + # @param overwrite boolean parameter for overwriting/not overwriting the file + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None): + if meshPart: + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite ) + else: + self.mesh.ExportToMEDX(f, auto_groups, version, overwrite) + + ## Exports the mesh in a file in SAUV format + # @param f is the file name + # @param auto_groups boolean parameter for creating/not creating + # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; + # the typical use is auto_groups=false. + # @ingroup l2_impexp + def ExportSAUV(self, f, auto_groups=0): + self.mesh.ExportSAUV(f, auto_groups) + + ## Exports the mesh in a file in DAT format + # @param f the file name + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportDAT(self, f, meshPart=None): + if meshPart: + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + self.mesh.ExportPartToDAT( meshPart, f ) + else: + self.mesh.ExportDAT(f) + + ## Exports the mesh in a file in UNV format + # @param f the file name + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportUNV(self, f, meshPart=None): + if meshPart: + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + self.mesh.ExportPartToUNV( meshPart, f ) + else: + self.mesh.ExportUNV(f) + + ## Export the mesh in a file in STL format + # @param f the file name + # @param ascii defines the file encoding + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportSTL(self, f, ascii=1, meshPart=None): + if meshPart: + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + self.mesh.ExportPartToSTL( meshPart, f, ascii ) + else: + self.mesh.ExportSTL(f, ascii) + + ## Exports the mesh in a file in CGNS format + # @param f is the file name + # @param overwrite boolean parameter for overwriting/not overwriting the file + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportCGNS(self, f, overwrite=1, meshPart=None): + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + if isinstance( meshPart, Mesh ): + meshPart = meshPart.mesh + elif not meshPart: + meshPart = self.mesh + self.mesh.ExportCGNS(meshPart, f, overwrite) + + ## Exports the mesh in a file in GMF format + # @param f is the file name + # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh + # @ingroup l2_impexp + def ExportGMF(self, f, meshPart=None): + if isinstance( meshPart, list ): + meshPart = self.GetIDSource( meshPart, SMESH.ALL ) + if isinstance( meshPart, Mesh ): + meshPart = meshPart.mesh + elif not meshPart: + meshPart = self.mesh + self.mesh.ExportGMF(meshPart, f, True) + + ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead. + # Exports the mesh in a file in MED format and chooses the \a version of MED format + ## allowing to overwrite the file if it exists or add the exported data to its contents + # @param f the file name + # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2 + # @param opt boolean parameter for creating/not creating + # the groups Group_On_All_Nodes, Group_On_All_Faces, ... + # @param overwrite boolean parameter for overwriting/not overwriting the file + # @ingroup l2_impexp + def ExportToMED(self, f, version, opt=0, overwrite=1): + self.mesh.ExportToMEDX(f, opt, version, overwrite) + + # Operations with groups: + # ---------------------- + + ## Creates an empty mesh group + # @param elementType the type of elements in the group + # @param name the name of the mesh group + # @return SMESH_Group + # @ingroup l2_grps_create + def CreateEmptyGroup(self, elementType, name): + return self.mesh.CreateGroup(elementType, name) + + ## Creates a mesh group based on the geometric object \a grp + # and gives a \a name, \n if this parameter is not defined + # the name is the same as the geometric group name \n + # Note: Works like GroupOnGeom(). + # @param grp a geometric group, a vertex, an edge, a face or a solid + # @param name the name of the mesh group + # @return SMESH_GroupOnGeom + # @ingroup l2_grps_create + def Group(self, grp, name=""): + return self.GroupOnGeom(grp, name) + + ## Creates a mesh group based on the geometrical object \a grp + # and gives a \a name, \n if this parameter is not defined + # the name is the same as the geometrical group name + # @param grp a geometrical group, a vertex, an edge, a face or a solid + # @param name the name of the mesh group + # @param typ the type of elements in the group. If not set, it is + # automatically detected by the type of the geometry + # @return SMESH_GroupOnGeom + # @ingroup l2_grps_create + def GroupOnGeom(self, grp, name="", typ=None): + AssureGeomPublished( self, grp, name ) + if name == "": + name = grp.GetName() + if not typ: + typ = self._groupTypeFromShape( grp ) + return self.mesh.CreateGroupFromGEOM(typ, name, grp) + + ## Pivate method to get a type of group on geometry + def _groupTypeFromShape( self, shape ): + tgeo = str(shape.GetShapeType()) + if tgeo == "VERTEX": + typ = NODE + elif tgeo == "EDGE": + typ = EDGE + elif tgeo == "FACE" or tgeo == "SHELL": + typ = FACE + elif tgeo == "SOLID" or tgeo == "COMPSOLID": + typ = VOLUME + elif tgeo == "COMPOUND": + sub = self.geompyD.SubShapeAll( shape, self.geompyD.ShapeType["SHAPE"]) + if not sub: + raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape) + return self._groupTypeFromShape( sub[0] ) + else: + raise ValueError, \ + "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape) + return typ + + ## Creates a mesh group with given \a name based on the \a filter which + ## is a special type of group dynamically updating it's contents during + ## mesh modification + # @param typ the type of elements in the group + # @param name the name of the mesh group + # @param filter the filter defining group contents + # @return SMESH_GroupOnFilter + # @ingroup l2_grps_create + def GroupOnFilter(self, typ, name, filter): + return self.mesh.CreateGroupFromFilter(typ, name, filter) + + ## Creates a mesh group by the given ids of elements + # @param groupName the name of the mesh group + # @param elementType the type of elements in the group + # @param elemIDs the list of ids + # @return SMESH_Group + # @ingroup l2_grps_create + def MakeGroupByIds(self, groupName, elementType, elemIDs): + group = self.mesh.CreateGroup(elementType, groupName) + group.Add(elemIDs) + return group + + ## Creates a mesh group by the given conditions + # @param groupName the name of the mesh group + # @param elementType the type of elements in the group + # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) + # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} + # @param Threshold the threshold value (range of id ids as string, shape, numeric) + # @param UnaryOp FT_LogicalNOT or FT_Undefined + # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, + # FT_LyingOnGeom, FT_CoplanarFaces criteria + # @return SMESH_Group + # @ingroup l2_grps_create + def MakeGroup(self, + groupName, + elementType, + CritType=FT_Undefined, + Compare=FT_EqualTo, + Threshold="", + UnaryOp=FT_Undefined, + Tolerance=1e-07): + aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance) + group = self.MakeGroupByCriterion(groupName, aCriterion) + return group + + ## Creates a mesh group by the given criterion + # @param groupName the name of the mesh group + # @param Criterion the instance of Criterion class + # @return SMESH_Group + # @ingroup l2_grps_create + def MakeGroupByCriterion(self, groupName, Criterion): + aFilterMgr = self.smeshpyD.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + aCriteria = [] + aCriteria.append(Criterion) + aFilter.SetCriteria(aCriteria) + group = self.MakeGroupByFilter(groupName, aFilter) + aFilterMgr.UnRegister() + return group + + ## Creates a mesh group by the given criteria (list of criteria) + # @param groupName the name of the mesh group + # @param theCriteria the list of criteria + # @return SMESH_Group + # @ingroup l2_grps_create + def MakeGroupByCriteria(self, groupName, theCriteria): + aFilterMgr = self.smeshpyD.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + aFilter.SetCriteria(theCriteria) + group = self.MakeGroupByFilter(groupName, aFilter) + aFilterMgr.UnRegister() + return group + + ## Creates a mesh group by the given filter + # @param groupName the name of the mesh group + # @param theFilter the instance of Filter class + # @return SMESH_Group + # @ingroup l2_grps_create + def MakeGroupByFilter(self, groupName, theFilter): + group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName) + theFilter.SetMesh( self.mesh ) + group.AddFrom( theFilter ) + return group + + ## Removes a group + # @ingroup l2_grps_delete + def RemoveGroup(self, group): + self.mesh.RemoveGroup(group) + + ## Removes a group with its contents + # @ingroup l2_grps_delete + def RemoveGroupWithContents(self, group): + self.mesh.RemoveGroupWithContents(group) + + ## Gets the list of groups existing in the mesh + # @return a sequence of SMESH_GroupBase + # @ingroup l2_grps_create + def GetGroups(self): + return self.mesh.GetGroups() + + ## Gets the number of groups existing in the mesh + # @return the quantity of groups as an integer value + # @ingroup l2_grps_create + def NbGroups(self): + return self.mesh.NbGroups() + + ## Gets the list of names of groups existing in the mesh + # @return list of strings + # @ingroup l2_grps_create + def GetGroupNames(self): + groups = self.GetGroups() + names = [] + for group in groups: + names.append(group.GetName()) + return names + + ## Produces a union of two groups + # A new group is created. All mesh elements that are + # present in the initial groups are added to the new one + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def UnionGroups(self, group1, group2, name): + return self.mesh.UnionGroups(group1, group2, name) + + ## Produces a union list of groups + # New group is created. All mesh elements that are present in + # initial groups are added to the new one + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def UnionListOfGroups(self, groups, name): + return self.mesh.UnionListOfGroups(groups, name) + + ## Prodices an intersection of two groups + # A new group is created. All mesh elements that are common + # for the two initial groups are added to the new one. + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def IntersectGroups(self, group1, group2, name): + return self.mesh.IntersectGroups(group1, group2, name) + + ## Produces an intersection of groups + # New group is created. All mesh elements that are present in all + # initial groups simultaneously are added to the new one + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def IntersectListOfGroups(self, groups, name): + return self.mesh.IntersectListOfGroups(groups, name) + + ## Produces a cut of two groups + # A new group is created. All mesh elements that are present in + # the main group but are not present in the tool group are added to the new one + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def CutGroups(self, main_group, tool_group, name): + return self.mesh.CutGroups(main_group, tool_group, name) + + ## Produces a cut of groups + # A new group is created. All mesh elements that are present in main groups + # but do not present in tool groups are added to the new one + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def CutListOfGroups(self, main_groups, tool_groups, name): + return self.mesh.CutListOfGroups(main_groups, tool_groups, name) + + ## Produces a group of elements of specified type using list of existing groups + # A new group is created. System + # 1) extracts all nodes on which groups elements are built + # 2) combines all elements of specified dimension laying on these nodes + # @return an instance of SMESH_Group + # @ingroup l2_grps_operon + def CreateDimGroup(self, groups, elem_type, name): + return self.mesh.CreateDimGroup(groups, elem_type, name) + + + ## Convert group on geom into standalone group + # @ingroup l2_grps_delete + def ConvertToStandalone(self, group): + return self.mesh.ConvertToStandalone(group) + + # Get some info about mesh: + # ------------------------ + + ## Returns the log of nodes and elements added or removed + # since the previous clear of the log. + # @param clearAfterGet log is emptied after Get (safe if concurrents access) + # @return list of log_block structures: + # commandType + # number + # coords + # indexes + # @ingroup l1_auxiliary + def GetLog(self, clearAfterGet): + return self.mesh.GetLog(clearAfterGet) + + ## Clears the log of nodes and elements added or removed since the previous + # clear. Must be used immediately after GetLog if clearAfterGet is false. + # @ingroup l1_auxiliary + def ClearLog(self): + self.mesh.ClearLog() + + ## Toggles auto color mode on the object. + # @param theAutoColor the flag which toggles auto color mode. + # @ingroup l1_auxiliary + def SetAutoColor(self, theAutoColor): + self.mesh.SetAutoColor(theAutoColor) + + ## Gets flag of object auto color mode. + # @return True or False + # @ingroup l1_auxiliary + def GetAutoColor(self): + return self.mesh.GetAutoColor() + + ## Gets the internal ID + # @return integer value, which is the internal Id of the mesh + # @ingroup l1_auxiliary + def GetId(self): + return self.mesh.GetId() + + ## Get the study Id + # @return integer value, which is the study Id of the mesh + # @ingroup l1_auxiliary + def GetStudyId(self): + return self.mesh.GetStudyId() + + ## Checks the group names for duplications. + # Consider the maximum group name length stored in MED file. + # @return True or False + # @ingroup l1_auxiliary + def HasDuplicatedGroupNamesMED(self): + return self.mesh.HasDuplicatedGroupNamesMED() + + ## Obtains the mesh editor tool + # @return an instance of SMESH_MeshEditor + # @ingroup l1_modifying + def GetMeshEditor(self): + return self.editor + + ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which + # can be passed as argument to a method accepting mesh, group or sub-mesh + # @return an instance of SMESH_IDSource + # @ingroup l1_auxiliary + def GetIDSource(self, ids, elemType): + return self.editor.MakeIDSource(ids, elemType) + + ## Gets MED Mesh + # @return an instance of SALOME_MED::MESH + # @ingroup l1_auxiliary + def GetMEDMesh(self): + return self.mesh.GetMEDMesh() + + + # Get informations about mesh contents: + # ------------------------------------ + + ## Gets the mesh stattistic + # @return dictionary type element - count of elements + # @ingroup l1_meshinfo + def GetMeshInfo(self, obj = None): + if not obj: obj = self.mesh + return self.smeshpyD.GetMeshInfo(obj) + + ## Returns the number of nodes in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbNodes(self): + return self.mesh.NbNodes() + + ## Returns the number of elements in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbElements(self): + return self.mesh.NbElements() + + ## Returns the number of 0d elements in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def Nb0DElements(self): + return self.mesh.Nb0DElements() + + ## Returns the number of ball discrete elements in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbBalls(self): + return self.mesh.NbBalls() + + ## Returns the number of edges in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbEdges(self): + return self.mesh.NbEdges() + + ## Returns the number of edges with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbEdgesOfOrder(self, elementOrder): + return self.mesh.NbEdgesOfOrder(elementOrder) + + ## Returns the number of faces in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbFaces(self): + return self.mesh.NbFaces() + + ## Returns the number of faces with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbFacesOfOrder(self, elementOrder): + return self.mesh.NbFacesOfOrder(elementOrder) + + ## Returns the number of triangles in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbTriangles(self): + return self.mesh.NbTriangles() + + ## Returns the number of triangles with the given order in the mesh + # @param elementOrder is the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbTrianglesOfOrder(self, elementOrder): + return self.mesh.NbTrianglesOfOrder(elementOrder) + + ## Returns the number of quadrangles in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbQuadrangles(self): + return self.mesh.NbQuadrangles() + + ## Returns the number of quadrangles with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbQuadranglesOfOrder(self, elementOrder): + return self.mesh.NbQuadranglesOfOrder(elementOrder) + + ## Returns the number of biquadratic quadrangles in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbBiQuadQuadrangles(self): + return self.mesh.NbBiQuadQuadrangles() + + ## Returns the number of polygons in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbPolygons(self): + return self.mesh.NbPolygons() + + ## Returns the number of volumes in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbVolumes(self): + return self.mesh.NbVolumes() + + ## Returns the number of volumes with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbVolumesOfOrder(self, elementOrder): + return self.mesh.NbVolumesOfOrder(elementOrder) + + ## Returns the number of tetrahedrons in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbTetras(self): + return self.mesh.NbTetras() + + ## Returns the number of tetrahedrons with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbTetrasOfOrder(self, elementOrder): + return self.mesh.NbTetrasOfOrder(elementOrder) + + ## Returns the number of hexahedrons in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbHexas(self): + return self.mesh.NbHexas() + + ## Returns the number of hexahedrons with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbHexasOfOrder(self, elementOrder): + return self.mesh.NbHexasOfOrder(elementOrder) + + ## Returns the number of triquadratic hexahedrons in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbTriQuadraticHexas(self): + return self.mesh.NbTriQuadraticHexas() + + ## Returns the number of pyramids in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbPyramids(self): + return self.mesh.NbPyramids() + + ## Returns the number of pyramids with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbPyramidsOfOrder(self, elementOrder): + return self.mesh.NbPyramidsOfOrder(elementOrder) + + ## Returns the number of prisms in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbPrisms(self): + return self.mesh.NbPrisms() + + ## Returns the number of prisms with the given order in the mesh + # @param elementOrder the order of elements: + # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC + # @return an integer value + # @ingroup l1_meshinfo + def NbPrismsOfOrder(self, elementOrder): + return self.mesh.NbPrismsOfOrder(elementOrder) + + ## Returns the number of hexagonal prisms in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbHexagonalPrisms(self): + return self.mesh.NbHexagonalPrisms() + + ## Returns the number of polyhedrons in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbPolyhedrons(self): + return self.mesh.NbPolyhedrons() + + ## Returns the number of submeshes in the mesh + # @return an integer value + # @ingroup l1_meshinfo + def NbSubMesh(self): + return self.mesh.NbSubMesh() + + ## Returns the list of mesh elements IDs + # @return the list of integer values + # @ingroup l1_meshinfo + def GetElementsId(self): + return self.mesh.GetElementsId() + + ## Returns the list of IDs of mesh elements with the given type + # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME) + # @return list of integer values + # @ingroup l1_meshinfo + def GetElementsByType(self, elementType): + return self.mesh.GetElementsByType(elementType) + + ## Returns the list of mesh nodes IDs + # @return the list of integer values + # @ingroup l1_meshinfo + def GetNodesId(self): + return self.mesh.GetNodesId() + + # Get the information about mesh elements: + # ------------------------------------ + + ## Returns the type of mesh element + # @return the value from SMESH::ElementType enumeration + # @ingroup l1_meshinfo + def GetElementType(self, id, iselem): + return self.mesh.GetElementType(id, iselem) + + ## Returns the geometric type of mesh element + # @return the value from SMESH::EntityType enumeration + # @ingroup l1_meshinfo + def GetElementGeomType(self, id): + return self.mesh.GetElementGeomType(id) + + ## Returns the list of submesh elements IDs + # @param Shape a geom object(sub-shape) IOR + # Shape must be the sub-shape of a ShapeToMesh() + # @return the list of integer values + # @ingroup l1_meshinfo + def GetSubMeshElementsId(self, Shape): + if ( isinstance( Shape, geomBuilder.GEOM._objref_GEOM_Object)): + ShapeID = Shape.GetSubShapeIndices()[0] + else: + ShapeID = Shape + return self.mesh.GetSubMeshElementsId(ShapeID) + + ## Returns the list of submesh nodes IDs + # @param Shape a geom object(sub-shape) IOR + # Shape must be the sub-shape of a ShapeToMesh() + # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes + # @return the list of integer values + # @ingroup l1_meshinfo + def GetSubMeshNodesId(self, Shape, all): + if ( isinstance( Shape, geomBuilder.GEOM._objref_GEOM_Object)): + ShapeID = self.geompyD.GetSubShapeID( self.geom, Shape ) + else: + ShapeID = Shape + return self.mesh.GetSubMeshNodesId(ShapeID, all) + + ## Returns type of elements on given shape + # @param Shape a geom object(sub-shape) IOR + # Shape must be a sub-shape of a ShapeToMesh() + # @return element type + # @ingroup l1_meshinfo + def GetSubMeshElementType(self, Shape): + if ( isinstance( Shape, geomBuilder.GEOM._objref_GEOM_Object)): + ShapeID = Shape.GetSubShapeIndices()[0] + else: + ShapeID = Shape + return self.mesh.GetSubMeshElementType(ShapeID) + + ## Gets the mesh description + # @return string value + # @ingroup l1_meshinfo + def Dump(self): + return self.mesh.Dump() + + + # Get the information about nodes and elements of a mesh by its IDs: + # ----------------------------------------------------------- + + ## Gets XYZ coordinates of a node + # \n If there is no nodes for the given ID - returns an empty list + # @return a list of double precision values + # @ingroup l1_meshinfo + def GetNodeXYZ(self, id): + return self.mesh.GetNodeXYZ(id) + + ## Returns list of IDs of inverse elements for the given node + # \n If there is no node for the given ID - returns an empty list + # @return a list of integer values + # @ingroup l1_meshinfo + def GetNodeInverseElements(self, id): + return self.mesh.GetNodeInverseElements(id) + + ## @brief Returns the position of a node on the shape + # @return SMESH::NodePosition + # @ingroup l1_meshinfo + def GetNodePosition(self,NodeID): + return self.mesh.GetNodePosition(NodeID) + + ## @brief Returns the position of an element on the shape + # @return SMESH::ElementPosition + # @ingroup l1_meshinfo + def GetElementPosition(self,ElemID): + return self.mesh.GetElementPosition(ElemID) + + ## If the given element is a node, returns the ID of shape + # \n If there is no node for the given ID - returns -1 + # @return an integer value + # @ingroup l1_meshinfo + def GetShapeID(self, id): + return self.mesh.GetShapeID(id) + + ## Returns the ID of the result shape after + # FindShape() from SMESH_MeshEditor for the given element + # \n If there is no element for the given ID - returns -1 + # @return an integer value + # @ingroup l1_meshinfo + def GetShapeIDForElem(self,id): + return self.mesh.GetShapeIDForElem(id) + + ## Returns the number of nodes for the given element + # \n If there is no element for the given ID - returns -1 + # @return an integer value + # @ingroup l1_meshinfo + def GetElemNbNodes(self, id): + return self.mesh.GetElemNbNodes(id) + + ## Returns the node ID the given (zero based) index for the given element + # \n If there is no element for the given ID - returns -1 + # \n If there is no node for the given index - returns -2 + # @return an integer value + # @ingroup l1_meshinfo + def GetElemNode(self, id, index): + return self.mesh.GetElemNode(id, index) + + ## Returns the IDs of nodes of the given element + # @return a list of integer values + # @ingroup l1_meshinfo + def GetElemNodes(self, id): + return self.mesh.GetElemNodes(id) + + ## Returns true if the given node is the medium node in the given quadratic element + # @ingroup l1_meshinfo + def IsMediumNode(self, elementID, nodeID): + return self.mesh.IsMediumNode(elementID, nodeID) + + ## Returns true if the given node is the medium node in one of quadratic elements + # @ingroup l1_meshinfo + def IsMediumNodeOfAnyElem(self, nodeID, elementType): + return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType) + + ## Returns the number of edges for the given element + # @ingroup l1_meshinfo + def ElemNbEdges(self, id): + return self.mesh.ElemNbEdges(id) + + ## Returns the number of faces for the given element + # @ingroup l1_meshinfo + def ElemNbFaces(self, id): + return self.mesh.ElemNbFaces(id) + + ## Returns nodes of given face (counted from zero) for given volumic element. + # @ingroup l1_meshinfo + def GetElemFaceNodes(self,elemId, faceIndex): + return self.mesh.GetElemFaceNodes(elemId, faceIndex) + + ## Returns an element based on all given nodes. + # @ingroup l1_meshinfo + def FindElementByNodes(self,nodes): + return self.mesh.FindElementByNodes(nodes) + + ## Returns true if the given element is a polygon + # @ingroup l1_meshinfo + def IsPoly(self, id): + return self.mesh.IsPoly(id) + + ## Returns true if the given element is quadratic + # @ingroup l1_meshinfo + def IsQuadratic(self, id): + return self.mesh.IsQuadratic(id) + + ## Returns diameter of a ball discrete element or zero in case of an invalid \a id + # @ingroup l1_meshinfo + def GetBallDiameter(self, id): + return self.mesh.GetBallDiameter(id) + + ## Returns XYZ coordinates of the barycenter of the given element + # \n If there is no element for the given ID - returns an empty list + # @return a list of three double values + # @ingroup l1_meshinfo + def BaryCenter(self, id): + return self.mesh.BaryCenter(id) + + ## Passes mesh elements through the given filter and return IDs of fitting elements + # @param theFilter SMESH_Filter + # @return a list of ids + # @ingroup l1_controls + def GetIdsFromFilter(self, theFilter): + theFilter.SetMesh( self.mesh ) + return theFilter.GetIDs() + + ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n + # Returns a list of special structures (borders). + # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes. + # @ingroup l1_controls + def GetFreeBorders(self): + aFilterMgr = self.smeshpyD.CreateFilterManager() + aPredicate = aFilterMgr.CreateFreeEdges() + aPredicate.SetMesh(self.mesh) + aBorders = aPredicate.GetBorders() + aFilterMgr.UnRegister() + return aBorders + + + # Get mesh measurements information: + # ------------------------------------ + + ## Get minimum distance between two nodes, elements or distance to the origin + # @param id1 first node/element id + # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed) + # @param isElem1 @c True if @a id1 is element id, @c False if it is node id + # @param isElem2 @c True if @a id2 is element id, @c False if it is node id + # @return minimum distance value + # @sa GetMinDistance() + def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False): + aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2) + return aMeasure.value + + ## Get measure structure specifying minimum distance data between two objects + # @param id1 first node/element id + # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed) + # @param isElem1 @c True if @a id1 is element id, @c False if it is node id + # @param isElem2 @c True if @a id2 is element id, @c False if it is node id + # @return Measure structure + # @sa MinDistance() + def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False): + if isElem1: + id1 = self.editor.MakeIDSource([id1], SMESH.FACE) + else: + id1 = self.editor.MakeIDSource([id1], SMESH.NODE) + if id2 != 0: + if isElem2: + id2 = self.editor.MakeIDSource([id2], SMESH.FACE) + else: + id2 = self.editor.MakeIDSource([id2], SMESH.NODE) + pass + else: + id2 = None + + aMeasurements = self.smeshpyD.CreateMeasurements() + aMeasure = aMeasurements.MinDistance(id1, id2) + aMeasurements.UnRegister() + return aMeasure + + ## Get bounding box of the specified object(s) + # @param objects single source object or list of source objects or list of nodes/elements IDs + # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements, + # @c False specifies that @a objects are nodes + # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ) + # @sa GetBoundingBox() + def BoundingBox(self, objects=None, isElem=False): + result = self.GetBoundingBox(objects, isElem) + if result is None: + result = (0.0,)*6 + else: + result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ) + return result + + ## Get measure structure specifying bounding box data of the specified object(s) + # @param IDs single source object or list of source objects or list of nodes/elements IDs + # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements, + # @c False specifies that @a objects are nodes + # @return Measure structure + # @sa BoundingBox() + def GetBoundingBox(self, IDs=None, isElem=False): + if IDs is None: + IDs = [self.mesh] + elif isinstance(IDs, tuple): + IDs = list(IDs) + if not isinstance(IDs, list): + IDs = [IDs] + if len(IDs) > 0 and isinstance(IDs[0], int): + IDs = [IDs] + srclist = [] + for o in IDs: + if isinstance(o, Mesh): + srclist.append(o.mesh) + elif hasattr(o, "_narrow"): + src = o._narrow(SMESH.SMESH_IDSource) + if src: srclist.append(src) + pass + elif isinstance(o, list): + if isElem: + srclist.append(self.editor.MakeIDSource(o, SMESH.FACE)) + else: + srclist.append(self.editor.MakeIDSource(o, SMESH.NODE)) + pass + pass + aMeasurements = self.smeshpyD.CreateMeasurements() + aMeasure = aMeasurements.BoundingBox(srclist) + aMeasurements.UnRegister() + return aMeasure + + # Mesh edition (SMESH_MeshEditor functionality): + # --------------------------------------------- + + ## Removes the elements from the mesh by ids + # @param IDsOfElements is a list of ids of elements to remove + # @return True or False + # @ingroup l2_modif_del + def RemoveElements(self, IDsOfElements): + return self.editor.RemoveElements(IDsOfElements) + + ## Removes nodes from mesh by ids + # @param IDsOfNodes is a list of ids of nodes to remove + # @return True or False + # @ingroup l2_modif_del + def RemoveNodes(self, IDsOfNodes): + return self.editor.RemoveNodes(IDsOfNodes) + + ## Removes all orphan (free) nodes from mesh + # @return number of the removed nodes + # @ingroup l2_modif_del + def RemoveOrphanNodes(self): + return self.editor.RemoveOrphanNodes() + + ## Add a node to the mesh by coordinates + # @return Id of the new node + # @ingroup l2_modif_add + def AddNode(self, x, y, z): + x,y,z,Parameters,hasVars = ParseParameters(x,y,z) + if hasVars: self.mesh.SetParameters(Parameters) + return self.editor.AddNode( x, y, z) + + ## Creates a 0D element on a node with given number. + # @param IDOfNode the ID of node for creation of the element. + # @return the Id of the new 0D element + # @ingroup l2_modif_add + def Add0DElement(self, IDOfNode): + return self.editor.Add0DElement(IDOfNode) + + ## Create 0D elements on all nodes of the given elements except those + # nodes on which a 0D element already exists. + # @param theObject an object on whose nodes 0D elements will be created. + # It can be mesh, sub-mesh, group, list of element IDs or a holder + # of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE ) + # @param theGroupName optional name of a group to add 0D elements created + # and/or found on nodes of \a theObject. + # @return an object (a new group or a temporary SMESH_IDSource) holding + # IDs of new and/or found 0D elements. IDs of 0D elements + # can be retrieved from the returned object by calling GetIDs() + # @ingroup l2_modif_add + def Add0DElementsToAllNodes(self, theObject, theGroupName=""): + if isinstance( theObject, Mesh ): + theObject = theObject.GetMesh() + if isinstance( theObject, list ): + theObject = self.GetIDSource( theObject, SMESH.ALL ) + return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName ) + + ## Creates a ball element on a node with given ID. + # @param IDOfNode the ID of node for creation of the element. + # @param diameter the bal diameter. + # @return the Id of the new ball element + # @ingroup l2_modif_add + def AddBall(self, IDOfNode, diameter): + return self.editor.AddBall( IDOfNode, diameter ) + + ## Creates a linear or quadratic edge (this is determined + # by the number of given nodes). + # @param IDsOfNodes the list of node IDs for creation of the element. + # The order of nodes in this list should correspond to the description + # of MED. \n This description is located by the following link: + # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. + # @return the Id of the new edge + # @ingroup l2_modif_add + def AddEdge(self, IDsOfNodes): + return self.editor.AddEdge(IDsOfNodes) + + ## Creates a linear or quadratic face (this is determined + # by the number of given nodes). + # @param IDsOfNodes the list of node IDs for creation of the element. + # The order of nodes in this list should correspond to the description + # of MED. \n This description is located by the following link: + # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. + # @return the Id of the new face + # @ingroup l2_modif_add + def AddFace(self, IDsOfNodes): + return self.editor.AddFace(IDsOfNodes) + + ## Adds a polygonal face to the mesh by the list of node IDs + # @param IdsOfNodes the list of node IDs for creation of the element. + # @return the Id of the new face + # @ingroup l2_modif_add + def AddPolygonalFace(self, IdsOfNodes): + return self.editor.AddPolygonalFace(IdsOfNodes) + + ## Creates both simple and quadratic volume (this is determined + # by the number of given nodes). + # @param IDsOfNodes the list of node IDs for creation of the element. + # The order of nodes in this list should correspond to the description + # of MED. \n This description is located by the following link: + # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. + # @return the Id of the new volumic element + # @ingroup l2_modif_add + def AddVolume(self, IDsOfNodes): + return self.editor.AddVolume(IDsOfNodes) + + ## Creates a volume of many faces, giving nodes for each face. + # @param IdsOfNodes the list of node IDs for volume creation face by face. + # @param Quantities the list of integer values, Quantities[i] + # gives the quantity of nodes in face number i. + # @return the Id of the new volumic element + # @ingroup l2_modif_add + def AddPolyhedralVolume (self, IdsOfNodes, Quantities): + return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities) + + ## Creates a volume of many faces, giving the IDs of the existing faces. + # @param IdsOfFaces the list of face IDs for volume creation. + # + # Note: The created volume will refer only to the nodes + # of the given faces, not to the faces themselves. + # @return the Id of the new volumic element + # @ingroup l2_modif_add + def AddPolyhedralVolumeByFaces (self, IdsOfFaces): + return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces) + + + ## @brief Binds a node to a vertex + # @param NodeID a node ID + # @param Vertex a vertex or vertex ID + # @return True if succeed else raises an exception + # @ingroup l2_modif_add + def SetNodeOnVertex(self, NodeID, Vertex): + if ( isinstance( Vertex, geomBuilder.GEOM._objref_GEOM_Object)): + VertexID = Vertex.GetSubShapeIndices()[0] + else: + VertexID = Vertex + try: + self.editor.SetNodeOnVertex(NodeID, VertexID) + except SALOME.SALOME_Exception, inst: + raise ValueError, inst.details.text + return True + + + ## @brief Stores the node position on an edge + # @param NodeID a node ID + # @param Edge an edge or edge ID + # @param paramOnEdge a parameter on the edge where the node is located + # @return True if succeed else raises an exception + # @ingroup l2_modif_add + def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge): + if ( isinstance( Edge, geomBuilder.GEOM._objref_GEOM_Object)): + EdgeID = Edge.GetSubShapeIndices()[0] + else: + EdgeID = Edge + try: + self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge) + except SALOME.SALOME_Exception, inst: + raise ValueError, inst.details.text + return True + + ## @brief Stores node position on a face + # @param NodeID a node ID + # @param Face a face or face ID + # @param u U parameter on the face where the node is located + # @param v V parameter on the face where the node is located + # @return True if succeed else raises an exception + # @ingroup l2_modif_add + def SetNodeOnFace(self, NodeID, Face, u, v): + if ( isinstance( Face, geomBuilder.GEOM._objref_GEOM_Object)): + FaceID = Face.GetSubShapeIndices()[0] + else: + FaceID = Face + try: + self.editor.SetNodeOnFace(NodeID, FaceID, u, v) + except SALOME.SALOME_Exception, inst: + raise ValueError, inst.details.text + return True + + ## @brief Binds a node to a solid + # @param NodeID a node ID + # @param Solid a solid or solid ID + # @return True if succeed else raises an exception + # @ingroup l2_modif_add + def SetNodeInVolume(self, NodeID, Solid): + if ( isinstance( Solid, geomBuilder.GEOM._objref_GEOM_Object)): + SolidID = Solid.GetSubShapeIndices()[0] + else: + SolidID = Solid + try: + self.editor.SetNodeInVolume(NodeID, SolidID) + except SALOME.SALOME_Exception, inst: + raise ValueError, inst.details.text + return True + + ## @brief Bind an element to a shape + # @param ElementID an element ID + # @param Shape a shape or shape ID + # @return True if succeed else raises an exception + # @ingroup l2_modif_add + def SetMeshElementOnShape(self, ElementID, Shape): + if ( isinstance( Shape, geomBuilder.GEOM._objref_GEOM_Object)): + ShapeID = Shape.GetSubShapeIndices()[0] + else: + ShapeID = Shape + try: + self.editor.SetMeshElementOnShape(ElementID, ShapeID) + except SALOME.SALOME_Exception, inst: + raise ValueError, inst.details.text + return True + + + ## Moves the node with the given id + # @param NodeID the id of the node + # @param x a new X coordinate + # @param y a new Y coordinate + # @param z a new Z coordinate + # @return True if succeed else False + # @ingroup l2_modif_movenode + def MoveNode(self, NodeID, x, y, z): + x,y,z,Parameters,hasVars = ParseParameters(x,y,z) + if hasVars: self.mesh.SetParameters(Parameters) + return self.editor.MoveNode(NodeID, x, y, z) + + ## Finds the node closest to a point and moves it to a point location + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @param NodeID if specified (>0), the node with this ID is moved, + # otherwise, the node closest to point (@a x,@a y,@a z) is moved + # @return the ID of a node + # @ingroup l2_modif_throughp + def MoveClosestNodeToPoint(self, x, y, z, NodeID): + x,y,z,Parameters,hasVars = ParseParameters(x,y,z) + if hasVars: self.mesh.SetParameters(Parameters) + return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID) + + ## Finds the node closest to a point + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @return the ID of a node + # @ingroup l2_modif_throughp + def FindNodeClosestTo(self, x, y, z): + #preview = self.mesh.GetMeshEditPreviewer() + #return preview.MoveClosestNodeToPoint(x, y, z, -1) + return self.editor.FindNodeClosestTo(x, y, z) + + ## Finds the elements where a point lays IN or ON + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @param elementType type of elements to find (SMESH.ALL type + # means elements of any type excluding nodes, discrete and 0D elements) + # @param meshPart a part of mesh (group, sub-mesh) to search within + # @return list of IDs of found elements + # @ingroup l2_modif_throughp + def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None): + if meshPart: + return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType ); + else: + return self.editor.FindElementsByPoint(x, y, z, elementType) + + # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration: + # 0-IN, 1-OUT, 2-ON, 3-UNKNOWN + # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails. + + def GetPointState(self, x, y, z): + return self.editor.GetPointState(x, y, z) + + ## Finds the node closest to a point and moves it to a point location + # @param x the X coordinate of a point + # @param y the Y coordinate of a point + # @param z the Z coordinate of a point + # @return the ID of a moved node + # @ingroup l2_modif_throughp + def MeshToPassThroughAPoint(self, x, y, z): + return self.editor.MoveClosestNodeToPoint(x, y, z, -1) + + ## Replaces two neighbour triangles sharing Node1-Node2 link + # with the triangles built on the same 4 nodes but having other common link. + # @param NodeID1 the ID of the first node + # @param NodeID2 the ID of the second node + # @return false if proper faces were not found + # @ingroup l2_modif_invdiag + def InverseDiag(self, NodeID1, NodeID2): + return self.editor.InverseDiag(NodeID1, NodeID2) + + ## Replaces two neighbour triangles sharing Node1-Node2 link + # with a quadrangle built on the same 4 nodes. + # @param NodeID1 the ID of the first node + # @param NodeID2 the ID of the second node + # @return false if proper faces were not found + # @ingroup l2_modif_unitetri + def DeleteDiag(self, NodeID1, NodeID2): + return self.editor.DeleteDiag(NodeID1, NodeID2) + + ## Reorients elements by ids + # @param IDsOfElements if undefined reorients all mesh elements + # @return True if succeed else False + # @ingroup l2_modif_changori + def Reorient(self, IDsOfElements=None): + if IDsOfElements == None: + IDsOfElements = self.GetElementsId() + return self.editor.Reorient(IDsOfElements) + + ## Reorients all elements of the object + # @param theObject mesh, submesh or group + # @return True if succeed else False + # @ingroup l2_modif_changori + def ReorientObject(self, theObject): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + return self.editor.ReorientObject(theObject) + + ## Reorient faces contained in \a the2DObject. + # @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements + # @param theDirection is a desired direction of normal of \a theFace. + # It can be either a GEOM vector or a list of coordinates [x,y,z]. + # @param theFaceOrPoint defines a face of \a the2DObject whose normal will be + # compared with theDirection. It can be either ID of face or a point + # by which the face will be found. The point can be given as either + # a GEOM vertex or a list of point coordinates. + # @return number of reoriented faces + # @ingroup l2_modif_changori + def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ): + # check the2DObject + if isinstance( the2DObject, Mesh ): + the2DObject = the2DObject.GetMesh() + if isinstance( the2DObject, list ): + the2DObject = self.GetIDSource( the2DObject, SMESH.FACE ) + # check theDirection + if isinstance( theDirection, geomBuilder.GEOM._objref_GEOM_Object): + theDirection = self.smeshpyD.GetDirStruct( theDirection ) + if isinstance( theDirection, list ): + theDirection = self.smeshpyD.MakeDirStruct( *theDirection ) + # prepare theFace and thePoint + theFace = theFaceOrPoint + thePoint = PointStruct(0,0,0) + if isinstance( theFaceOrPoint, geomBuilder.GEOM._objref_GEOM_Object): + thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint ) + theFace = -1 + if isinstance( theFaceOrPoint, list ): + thePoint = PointStruct( *theFaceOrPoint ) + theFace = -1 + if isinstance( theFaceOrPoint, PointStruct ): + thePoint = theFaceOrPoint + theFace = -1 + return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint ) + + ## Fuses the neighbouring triangles into quadrangles. + # @param IDsOfElements The triangles to be fused, + # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to + # choose a neighbour to fuse with. + # @param MaxAngle is the maximum angle between element normals at which the fusion + # is still performed; theMaxAngle is mesured in radians. + # Also it could be a name of variable which defines angle in degrees. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_unitetri + def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle): + MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle) + self.mesh.SetParameters(Parameters) + if not IDsOfElements: + IDsOfElements = self.GetElementsId() + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle) + + ## Fuses the neighbouring triangles of the object into quadrangles + # @param theObject is mesh, submesh or group + # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to + # choose a neighbour to fuse with. + # @param MaxAngle a max angle between element normals at which the fusion + # is still performed; theMaxAngle is mesured in radians. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_unitetri + def TriToQuadObject (self, theObject, theCriterion, MaxAngle): + MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle) + self.mesh.SetParameters(Parameters) + if isinstance( theObject, Mesh ): + theObject = theObject.GetMesh() + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.TriToQuadObject(theObject, Functor, MaxAngle) + + ## Splits quadrangles into triangles. + # + # @param IDsOfElements the faces to be splitted. + # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to + # choose a diagonal for splitting. If @a theCriterion is None, which is a default + # value, then quadrangles will be split by the smallest diagonal. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_cutquadr + def QuadToTri (self, IDsOfElements, theCriterion = None): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if theCriterion is None: + theCriterion = FT_MaxElementLength2D + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.QuadToTri(IDsOfElements, Functor) + + ## Splits quadrangles into triangles. + # @param theObject the object from which the list of elements is taken, + # this is mesh, submesh or group + # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to + # choose a diagonal for splitting. If @a theCriterion is None, which is a default + # value, then quadrangles will be split by the smallest diagonal. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_cutquadr + def QuadToTriObject (self, theObject, theCriterion = None): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if theCriterion is None: + theCriterion = FT_MaxElementLength2D + Functor = self.smeshpyD.GetFunctor(theCriterion) + return self.editor.QuadToTriObject(theObject, Functor) + + ## Splits quadrangles into triangles. + # @param IDsOfElements the faces to be splitted + # @param Diag13 is used to choose a diagonal for splitting. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_cutquadr + def SplitQuad (self, IDsOfElements, Diag13): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + return self.editor.SplitQuad(IDsOfElements, Diag13) + + ## Splits quadrangles into triangles. + # @param theObject the object from which the list of elements is taken, + # this is mesh, submesh or group + # @param Diag13 is used to choose a diagonal for splitting. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_cutquadr + def SplitQuadObject (self, theObject, Diag13): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + return self.editor.SplitQuadObject(theObject, Diag13) + + ## Finds a better splitting of the given quadrangle. + # @param IDOfQuad the ID of the quadrangle to be splitted. + # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to + # choose a diagonal for splitting. + # @return 1 if 1-3 diagonal is better, 2 if 2-4 + # diagonal is better, 0 if error occurs. + # @ingroup l2_modif_cutquadr + def BestSplit (self, IDOfQuad, theCriterion): + return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion)) + + ## Splits volumic elements into tetrahedrons + # @param elemIDs either list of elements or mesh or group or submesh + # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet + # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc + # @ingroup l2_modif_cutquadr + def SplitVolumesIntoTetra(self, elemIDs, method=smeshBuilder.Hex_5Tet ): + if isinstance( elemIDs, Mesh ): + elemIDs = elemIDs.GetMesh() + if ( isinstance( elemIDs, list )): + elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME) + self.editor.SplitVolumesIntoTetra(elemIDs, method) + + ## Splits quadrangle faces near triangular facets of volumes + # + # @ingroup l1_auxiliary + def SplitQuadsNearTriangularFacets(self): + faces_array = self.GetElementsByType(SMESH.FACE) + for face_id in faces_array: + if self.GetElemNbNodes(face_id) == 4: # quadrangle + quad_nodes = self.mesh.GetElemNodes(face_id) + node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1]) + isVolumeFound = False + for node1_elem in node1_elems: + if not isVolumeFound: + if self.GetElementType(node1_elem, True) == SMESH.VOLUME: + nb_nodes = self.GetElemNbNodes(node1_elem) + if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism + volume_elem = node1_elem + volume_nodes = self.mesh.GetElemNodes(volume_elem) + if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2 + if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4 + isVolumeFound = True + if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3 + self.SplitQuad([face_id], False) # diagonal 2-4 + elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4 + isVolumeFound = True + self.SplitQuad([face_id], True) # diagonal 1-3 + elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2 + if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2 + isVolumeFound = True + self.SplitQuad([face_id], True) # diagonal 1-3 + + ## @brief Splits hexahedrons into tetrahedrons. + # + # This operation uses pattern mapping functionality for splitting. + # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group. + # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the + # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern + # will be mapped into theNode000-th node of each volume, the (0,0,1) + # key-point will be mapped into theNode001-th node of each volume. + # The (0,0,0) key-point of the used pattern corresponds to a non-split corner. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l1_auxiliary + def SplitHexaToTetras (self, theObject, theNode000, theNode001): + # Pattern: 5.---------.6 + # /|#* /| + # / | #* / | + # / | # * / | + # / | # /* | + # (0,0,1) 4.---------.7 * | + # |#* |1 | # *| + # | # *.----|---#.2 + # | #/ * | / + # | /# * | / + # | / # * | / + # |/ #*|/ + # (0,0,0) 0.---------.3 + pattern_tetra = "!!! Nb of points: \n 8 \n\ + !!! Points: \n\ + 0 0 0 !- 0 \n\ + 0 1 0 !- 1 \n\ + 1 1 0 !- 2 \n\ + 1 0 0 !- 3 \n\ + 0 0 1 !- 4 \n\ + 0 1 1 !- 5 \n\ + 1 1 1 !- 6 \n\ + 1 0 1 !- 7 \n\ + !!! Indices of points of 6 tetras: \n\ + 0 3 4 1 \n\ + 7 4 3 1 \n\ + 4 7 5 1 \n\ + 6 2 5 7 \n\ + 1 5 2 7 \n\ + 2 3 1 7 \n" + + pattern = self.smeshpyD.GetPattern() + isDone = pattern.LoadFromFile(pattern_tetra) + if not isDone: + print 'Pattern.LoadFromFile :', pattern.GetErrorCode() + return isDone + + pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001) + isDone = pattern.MakeMesh(self.mesh, False, False) + if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode() + + # split quafrangle faces near triangular facets of volumes + self.SplitQuadsNearTriangularFacets() + + return isDone + + ## @brief Split hexahedrons into prisms. + # + # Uses the pattern mapping functionality for splitting. + # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken; + # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the + # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern + # will be mapped into the theNode000-th node of each volume, keypoint (0,0,1) + # will be mapped into the theNode001-th node of each volume. + # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners. + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l1_auxiliary + def SplitHexaToPrisms (self, theObject, theNode000, theNode001): + # Pattern: 5.---------.6 + # /|# /| + # / | # / | + # / | # / | + # / | # / | + # (0,0,1) 4.---------.7 | + # | | | | + # | 1.----|----.2 + # | / * | / + # | / * | / + # | / * | / + # |/ *|/ + # (0,0,0) 0.---------.3 + pattern_prism = "!!! Nb of points: \n 8 \n\ + !!! Points: \n\ + 0 0 0 !- 0 \n\ + 0 1 0 !- 1 \n\ + 1 1 0 !- 2 \n\ + 1 0 0 !- 3 \n\ + 0 0 1 !- 4 \n\ + 0 1 1 !- 5 \n\ + 1 1 1 !- 6 \n\ + 1 0 1 !- 7 \n\ + !!! Indices of points of 2 prisms: \n\ + 0 1 3 4 5 7 \n\ + 2 3 1 6 7 5 \n" + + pattern = self.smeshpyD.GetPattern() + isDone = pattern.LoadFromFile(pattern_prism) + if not isDone: + print 'Pattern.LoadFromFile :', pattern.GetErrorCode() + return isDone + + pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001) + isDone = pattern.MakeMesh(self.mesh, False, False) + if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode() + + # Splits quafrangle faces near triangular facets of volumes + self.SplitQuadsNearTriangularFacets() + + return isDone + + ## Smoothes elements + # @param IDsOfElements the list if ids of elements to smooth + # @param IDsOfFixedNodes the list of ids of fixed nodes. + # Note that nodes built on edges and boundary nodes are always fixed. + # @param MaxNbOfIterations the maximum number of iterations + # @param MaxAspectRatio varies in range [1.0, inf] + # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_smooth + def Smooth(self, IDsOfElements, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) + return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method) + + ## Smoothes elements which belong to the given object + # @param theObject the object to smooth + # @param IDsOfFixedNodes the list of ids of fixed nodes. + # Note that nodes built on edges and boundary nodes are always fixed. + # @param MaxNbOfIterations the maximum number of iterations + # @param MaxAspectRatio varies in range [1.0, inf] + # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_smooth + def SmoothObject(self, theObject, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + return self.editor.SmoothObject(theObject, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method) + + ## Parametrically smoothes the given elements + # @param IDsOfElements the list if ids of elements to smooth + # @param IDsOfFixedNodes the list of ids of fixed nodes. + # Note that nodes built on edges and boundary nodes are always fixed. + # @param MaxNbOfIterations the maximum number of iterations + # @param MaxAspectRatio varies in range [1.0, inf] + # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_smooth + def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio) + self.mesh.SetParameters(Parameters) + return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method) + + ## Parametrically smoothes the elements which belong to the given object + # @param theObject the object to smooth + # @param IDsOfFixedNodes the list of ids of fixed nodes. + # Note that nodes built on edges and boundary nodes are always fixed. + # @param MaxNbOfIterations the maximum number of iterations + # @param MaxAspectRatio varies in range [1.0, inf] + # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @return TRUE in case of success, FALSE otherwise. + # @ingroup l2_modif_smooth + def SmoothParametricObject(self, theObject, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes, + MaxNbOfIterations, MaxAspectRatio, Method) + + ## Converts the mesh to quadratic or bi-quadratic, deletes old elements, replacing + # them with quadratic with the same id. + # @param theForce3d new node creation method: + # 0 - the medium node lies at the geometrical entity from which the mesh element is built + # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element + # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal + # @param theToBiQuad If True, converts the mesh to bi-quadratic + # @ingroup l2_modif_tofromqu + def ConvertToQuadratic(self, theForce3d, theSubMesh=None, theToBiQuad=False): + if theToBiQuad: + self.editor.ConvertToBiQuadratic(theForce3d,theSubMesh) + else: + if theSubMesh: + self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh) + else: + self.editor.ConvertToQuadratic(theForce3d) + + ## Converts the mesh from quadratic to ordinary, + # deletes old quadratic elements, \n replacing + # them with ordinary mesh elements with the same id. + # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal + # @ingroup l2_modif_tofromqu + def ConvertFromQuadratic(self, theSubMesh=None): + if theSubMesh: + self.editor.ConvertFromQuadraticObject(theSubMesh) + else: + return self.editor.ConvertFromQuadratic() + + ## Creates 2D mesh as skin on boundary faces of a 3D mesh + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def Make2DMeshFrom3D(self): + return self.editor. Make2DMeshFrom3D() + + ## Creates missing boundary elements + # @param elements - elements whose boundary is to be checked: + # mesh, group, sub-mesh or list of elements + # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called + # @param dimension - defines type of boundary elements to create: + # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D + # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells + # @param groupName - a name of group to store created boundary elements in, + # "" means not to create the group + # @param meshName - a name of new mesh to store created boundary elements in, + # "" means not to create the new mesh + # @param toCopyElements - if true, the checked elements will be copied into + # the new mesh else only boundary elements will be copied into the new mesh + # @param toCopyExistingBondary - if true, not only new but also pre-existing + # boundary elements will be copied into the new mesh + # @return tuple (mesh, group) where bondary elements were added to + # @ingroup l2_modif_edit + def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="", + toCopyElements=False, toCopyExistingBondary=False): + if isinstance( elements, Mesh ): + elements = elements.GetMesh() + if ( isinstance( elements, list )): + elemType = SMESH.ALL + if elements: elemType = self.GetElementType( elements[0], iselem=True) + elements = self.editor.MakeIDSource(elements, elemType) + mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName, + toCopyElements,toCopyExistingBondary) + if mesh: mesh = self.smeshpyD.Mesh(mesh) + return mesh, group + + ## + # @brief Creates missing boundary elements around either the whole mesh or + # groups of 2D elements + # @param dimension - defines type of boundary elements to create + # @param groupName - a name of group to store all boundary elements in, + # "" means not to create the group + # @param meshName - a name of a new mesh, which is a copy of the initial + # mesh + created boundary elements; "" means not to create the new mesh + # @param toCopyAll - if true, the whole initial mesh will be copied into + # the new mesh else only boundary elements will be copied into the new mesh + # @param groups - groups of 2D elements to make boundary around + # @retval tuple( long, mesh, groups ) + # long - number of added boundary elements + # mesh - the mesh where elements were added to + # group - the group of boundary elements or None + # + def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="", + toCopyAll=False, groups=[]): + nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName, + toCopyAll,groups) + if mesh: mesh = self.smeshpyD.Mesh(mesh) + return nb, mesh, group + + ## Renumber mesh nodes + # @ingroup l2_modif_renumber + def RenumberNodes(self): + self.editor.RenumberNodes() + + ## Renumber mesh elements + # @ingroup l2_modif_renumber + def RenumberElements(self): + self.editor.RenumberElements() + + ## Generates new elements by rotation of the elements around the axis + # @param IDsOfElements the list of ids of elements to sweep + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees + # @param NbOfSteps the number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) + NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) + Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + if MakeGroups: + return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis, + AngleInRadians, NbOfSteps, Tolerance) + self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped. + # It can be a mesh, a sub mesh or a group. + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) + NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) + Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + if MakeGroups: + return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped. + # It can be a mesh, a sub mesh or a group. + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) + NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) + Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + if MakeGroups: + return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by rotation of the elements of object around the axis + # @param theObject object which elements should be sweeped. + # It can be a mesh, a sub mesh or a group. + # @param Axis the axis of rotation, AxisStruct or line(geom object) + # @param AngleInRadians the angle of Rotation + # @param NbOfSteps number of steps + # @param Tolerance tolerance + # @param MakeGroups forces the generation of new groups from existing ones + # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size + # of all steps, else - size of each step + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, + MakeGroups=False, TotalAngle=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) + NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) + Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if TotalAngle and NbOfSteps: + AngleInRadians /= NbOfSteps + if MakeGroups: + return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians, + NbOfSteps, Tolerance) + self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) + return [] + + ## Generates new elements by extrusion of the elements with given ids + # @param IDsOfElements the list of elements ids for extrusion + # @param StepVector vector or DirStruct or 3 vector components, defining + # the direction and value of extrusion for one step (the total extrusion + # length will be NbOfSteps * ||StepVector||) + # @param NbOfSteps the number of steps + # @param MakeGroups forces the generation of new groups from existing ones + # @param IsNodes is True if elements with given ids are nodes + # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object): + StepVector = self.smeshpyD.GetDirStruct(StepVector) + if isinstance( StepVector, list ): + StepVector = self.smeshpyD.MakeDirStruct(*StepVector) + NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) + Parameters = StepVector.PS.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + if(IsNodes): + return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps) + else: + return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) + if(IsNodes): + self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps) + else: + self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) + return [] + + ## Generates new elements by extrusion of the elements with given ids + # @param IDsOfElements is ids of elements + # @param StepVector vector or DirStruct or 3 vector components, defining + # the direction and value of extrusion for one step (the total extrusion + # length will be NbOfSteps * ||StepVector||) + # @param NbOfSteps the number of steps + # @param ExtrFlags sets flags for extrusion + # @param SewTolerance uses for comparing locations of nodes if flag + # EXTRUSION_FLAG_SEW is set + # @param MakeGroups forces the generation of new groups from existing ones + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, + ExtrFlags, SewTolerance, MakeGroups=False): + if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): + StepVector = self.smeshpyD.GetDirStruct(StepVector) + if isinstance( StepVector, list ): + StepVector = self.smeshpyD.MakeDirStruct(*StepVector) + if MakeGroups: + return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps, + ExtrFlags, SewTolerance) + self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, + ExtrFlags, SewTolerance) + return [] + + ## Generates new elements by extrusion of the elements which belong to the object + # @param theObject the object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param StepVector vector or DirStruct or 3 vector components, defining + # the direction and value of extrusion for one step (the total extrusion + # length will be NbOfSteps * ||StepVector||) + # @param NbOfSteps the number of steps + # @param MakeGroups forces the generation of new groups from existing ones + # @param IsNodes is True if elements which belong to the object are nodes + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): + StepVector = self.smeshpyD.GetDirStruct(StepVector) + if isinstance( StepVector, list ): + StepVector = self.smeshpyD.MakeDirStruct(*StepVector) + NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) + Parameters = StepVector.PS.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + if(IsNodes): + return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps) + else: + return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps) + if(IsNodes): + self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps) + else: + self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) + return [] + + ## Generates new elements by extrusion of the elements which belong to the object + # @param theObject object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param StepVector vector or DirStruct or 3 vector components, defining + # the direction and value of extrusion for one step (the total extrusion + # length will be NbOfSteps * ||StepVector||) + # @param NbOfSteps the number of steps + # @param MakeGroups to generate new groups from existing ones + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): + StepVector = self.smeshpyD.GetDirStruct(StepVector) + if isinstance( StepVector, list ): + StepVector = self.smeshpyD.MakeDirStruct(*StepVector) + NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) + Parameters = StepVector.PS.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps) + self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) + return [] + + ## Generates new elements by extrusion of the elements which belong to the object + # @param theObject object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param StepVector vector or DirStruct or 3 vector components, defining + # the direction and value of extrusion for one step (the total extrusion + # length will be NbOfSteps * ||StepVector||) + # @param NbOfSteps the number of steps + # @param MakeGroups forces the generation of new groups from existing ones + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_extrurev + def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( StepVector, geomBuilder.GEOM._objref_GEOM_Object)): + StepVector = self.smeshpyD.GetDirStruct(StepVector) + if isinstance( StepVector, list ): + StepVector = self.smeshpyD.MakeDirStruct(*StepVector) + NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) + Parameters = StepVector.PS.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if MakeGroups: + return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps) + self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) + return [] + + + + ## Generates new elements by extrusion of the given elements + # The path of extrusion must be a meshed edge. + # @param Base mesh or group, or submesh, or list of ids of elements for extrusion + # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion + # @param NodeStart the start node from Path. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles in radians + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param ElemType type of elements for extrusion (if param Base is a mesh) + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathX(self, Base, Path, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups, ElemType): + if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + pass + Angles,AnglesParameters,hasVars = ParseAngles(Angles) + Parameters = AnglesParameters + var_separator + RefPoint.parameters + self.mesh.SetParameters(Parameters) + + if (isinstance(Path, Mesh)): Path = Path.GetMesh() + + if isinstance(Base, list): + IDsOfElements = [] + if Base == []: IDsOfElements = self.GetElementsId() + else: IDsOfElements = Base + return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups, ElemType) + else: + if isinstance(Base, Mesh): Base = Base.GetMesh() + if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh): + return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart, + HasAngles, Angles, LinearVariation, + HasRefPoint, RefPoint, MakeGroups, ElemType) + else: + raise RuntimeError, "Invalid Base for ExtrusionAlongPathX" + + + ## Generates new elements by extrusion of the given elements + # The path of extrusion must be a meshed edge. + # @param IDsOfElements ids of elements + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles in radians + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + pass + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + Angles,AnglesParameters,hasVars = ParseAngles(Angles) + Parameters = AnglesParameters + var_separator + RefPoint.parameters + self.mesh.SetParameters(Parameters) + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + if MakeGroups: + return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, RefPoint) + + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + Angles,AnglesParameters,hasVars = ParseAngles(Angles) + Parameters = AnglesParameters + var_separator + RefPoint.parameters + self.mesh.SetParameters(Parameters) + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + if MakeGroups: + return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + Angles,AnglesParameters,hasVars = ParseAngles(Angles) + Parameters = AnglesParameters + var_separator + RefPoint.parameters + self.mesh.SetParameters(Parameters) + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + if MakeGroups: + return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + + ## Generates new elements by extrusion of the elements which belong to the object + # The path of extrusion must be a meshed edge. + # @param theObject the object which elements should be processed. + # It can be a mesh, a sub mesh or a group. + # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds + # @param PathShape shape(edge) defines the sub-mesh for the path + # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion + # @param HasAngles allows the shape to be rotated around the path + # to get the resulting mesh in a helical fashion + # @param Angles list of angles + # @param HasRefPoint allows using the reference point + # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). + # The User can specify any point as the Reference Point. + # @param MakeGroups forces the generation of new groups from existing ones + # @param LinearVariation forces the computation of rotation angles as linear + # variation of the given Angles along path steps + # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, + # only SMESH::Extrusion_Error otherwise + # @ingroup l2_modif_extrurev + def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart, + HasAngles, Angles, HasRefPoint, RefPoint, + MakeGroups=False, LinearVariation=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( RefPoint, geomBuilder.GEOM._objref_GEOM_Object)): + RefPoint = self.smeshpyD.GetPointStruct(RefPoint) + if ( isinstance( PathMesh, Mesh )): + PathMesh = PathMesh.GetMesh() + Angles,AnglesParameters,hasVars = ParseAngles(Angles) + Parameters = AnglesParameters + var_separator + RefPoint.parameters + self.mesh.SetParameters(Parameters) + if HasAngles and Angles and LinearVariation: + Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) + pass + if MakeGroups: + return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh, + PathShape, NodeStart, HasAngles, + Angles, HasRefPoint, RefPoint) + return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape, + NodeStart, HasAngles, Angles, HasRefPoint, + RefPoint) + + ## Creates a symmetrical copy of mesh elements + # @param IDsOfElements list of elements ids + # @param Mirror is AxisStruct or geom object(point, line, plane) + # @param theMirrorType is POINT, AXIS or PLANE + # If the Mirror is a geom object this parameter is unnecessary + # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0) + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Mirror, geomBuilder.GEOM._objref_GEOM_Object)): + Mirror = self.smeshpyD.GetAxisStruct(Mirror) + self.mesh.SetParameters(Mirror.parameters) + if Copy and MakeGroups: + return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) + self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) + return [] + + ## Creates a new mesh by a symmetrical copy of mesh elements + # @param IDsOfElements the list of elements ids + # @param Mirror is AxisStruct or geom object (point, line, plane) + # @param theMirrorType is POINT, AXIS or PLANE + # If the Mirror is a geom object this parameter is unnecessary + # @param MakeGroups to generate new groups from existing ones + # @param NewMeshName a name of the new mesh to create + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Mirror, geomBuilder.GEOM._objref_GEOM_Object)): + Mirror = self.smeshpyD.GetAxisStruct(Mirror) + self.mesh.SetParameters(Mirror.parameters) + mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType, + MakeGroups, NewMeshName) + return Mesh(self.smeshpyD,self.geompyD,mesh) + + ## Creates a symmetrical copy of the object + # @param theObject mesh, submesh or group + # @param Mirror AxisStruct or geom object (point, line, plane) + # @param theMirrorType is POINT, AXIS or PLANE + # If the Mirror is a geom object this parameter is unnecessary + # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0) + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Mirror, geomBuilder.GEOM._objref_GEOM_Object)): + Mirror = self.smeshpyD.GetAxisStruct(Mirror) + self.mesh.SetParameters(Mirror.parameters) + if Copy and MakeGroups: + return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType) + self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) + return [] + + ## Creates a new mesh by a symmetrical copy of the object + # @param theObject mesh, submesh or group + # @param Mirror AxisStruct or geom object (point, line, plane) + # @param theMirrorType POINT, AXIS or PLANE + # If the Mirror is a geom object this parameter is unnecessary + # @param MakeGroups forces the generation of new groups from existing ones + # @param NewMeshName the name of the new mesh to create + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if (isinstance(Mirror, geomBuilder.GEOM._objref_GEOM_Object)): + Mirror = self.smeshpyD.GetAxisStruct(Mirror) + self.mesh.SetParameters(Mirror.parameters) + mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType, + MakeGroups, NewMeshName) + return Mesh( self.smeshpyD,self.geompyD,mesh ) + + ## Translates the elements + # @param IDsOfElements list of elements ids + # @param Vector the direction of translation (DirStruct or vector or 3 vector components) + # @param Copy allows copying the translated elements + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Vector, geomBuilder.GEOM._objref_GEOM_Object)): + Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) + self.mesh.SetParameters(Vector.PS.parameters) + if Copy and MakeGroups: + return self.editor.TranslateMakeGroups(IDsOfElements, Vector) + self.editor.Translate(IDsOfElements, Vector, Copy) + return [] + + ## Creates a new mesh of translated elements + # @param IDsOfElements list of elements ids + # @param Vector the direction of translation (DirStruct or vector or 3 vector components) + # @param MakeGroups forces the generation of new groups from existing ones + # @param NewMeshName the name of the newly created mesh + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Vector, geomBuilder.GEOM._objref_GEOM_Object)): + Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) + self.mesh.SetParameters(Vector.PS.parameters) + mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName) + return Mesh ( self.smeshpyD, self.geompyD, mesh ) + + ## Translates the object + # @param theObject the object to translate (mesh, submesh, or group) + # @param Vector direction of translation (DirStruct or geom vector or 3 vector components) + # @param Copy allows copying the translated elements + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( Vector, geomBuilder.GEOM._objref_GEOM_Object)): + Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) + self.mesh.SetParameters(Vector.PS.parameters) + if Copy and MakeGroups: + return self.editor.TranslateObjectMakeGroups(theObject, Vector) + self.editor.TranslateObject(theObject, Vector, Copy) + return [] + + ## Creates a new mesh from the translated object + # @param theObject the object to translate (mesh, submesh, or group) + # @param Vector the direction of translation (DirStruct or geom vector or 3 vector components) + # @param MakeGroups forces the generation of new groups from existing ones + # @param NewMeshName the name of the newly created mesh + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""): + if isinstance( theObject, Mesh ): + theObject = theObject.GetMesh() + if isinstance( Vector, geomBuilder.GEOM._objref_GEOM_Object ): + Vector = self.smeshpyD.GetDirStruct(Vector) + if isinstance( Vector, list ): + Vector = self.smeshpyD.MakeDirStruct(*Vector) + self.mesh.SetParameters(Vector.PS.parameters) + mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName) + return Mesh( self.smeshpyD, self.geompyD, mesh ) + + + + ## Scales the object + # @param theObject - the object to translate (mesh, submesh, or group) + # @param thePoint - base point for scale + # @param theScaleFact - list of 1-3 scale factors for axises + # @param Copy - allows copying the translated elements + # @param MakeGroups - forces the generation of new groups from existing + # ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, + # empty list otherwise + def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False): + if ( isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if ( isinstance( theObject, list )): + theObject = self.GetIDSource(theObject, SMESH.ALL) + if ( isinstance( theScaleFact, float )): + theScaleFact = [theScaleFact] + if ( isinstance( theScaleFact, int )): + theScaleFact = [ float(theScaleFact)] + + self.mesh.SetParameters(thePoint.parameters) + + if Copy and MakeGroups: + return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact) + self.editor.Scale(theObject, thePoint, theScaleFact, Copy) + return [] + + ## Creates a new mesh from the translated object + # @param theObject - the object to translate (mesh, submesh, or group) + # @param thePoint - base point for scale + # @param theScaleFact - list of 1-3 scale factors for axises + # @param MakeGroups - forces the generation of new groups from existing ones + # @param NewMeshName - the name of the newly created mesh + # @return instance of Mesh class + def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""): + if (isinstance(theObject, Mesh)): + theObject = theObject.GetMesh() + if ( isinstance( theObject, list )): + theObject = self.GetIDSource(theObject,SMESH.ALL) + if ( isinstance( theScaleFact, float )): + theScaleFact = [theScaleFact] + if ( isinstance( theScaleFact, int )): + theScaleFact = [ float(theScaleFact)] + + self.mesh.SetParameters(thePoint.parameters) + mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact, + MakeGroups, NewMeshName) + return Mesh( self.smeshpyD, self.geompyD, mesh ) + + + + ## Rotates the elements + # @param IDsOfElements list of elements ids + # @param Axis the axis of rotation (AxisStruct or geom line) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees + # @param Copy allows copying the rotated elements + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) + Parameters = Axis.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + if Copy and MakeGroups: + return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) + self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) + return [] + + ## Creates a new mesh of rotated elements + # @param IDsOfElements list of element ids + # @param Axis the axis of rotation (AxisStruct or geom line) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees + # @param MakeGroups forces the generation of new groups from existing ones + # @param NewMeshName the name of the newly created mesh + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""): + if IDsOfElements == []: + IDsOfElements = self.GetElementsId() + if ( isinstance( Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) + Parameters = Axis.parameters + var_separator + Parameters + self.mesh.SetParameters(Parameters) + mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, + MakeGroups, NewMeshName) + return Mesh( self.smeshpyD, self.geompyD, mesh ) + + ## Rotates the object + # @param theObject the object to rotate( mesh, submesh, or group) + # @param Axis the axis of rotation (AxisStruct or geom line) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees + # @param Copy allows copying the rotated elements + # @param MakeGroups forces the generation of new groups from existing ones (if Copy) + # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise + # @ingroup l2_modif_trsf + def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False): + if (isinstance(theObject, Mesh)): + theObject = theObject.GetMesh() + if (isinstance(Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) + Parameters = Axis.parameters + ":" + Parameters + self.mesh.SetParameters(Parameters) + if Copy and MakeGroups: + return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians) + self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy) + return [] + + ## Creates a new mesh from the rotated object + # @param theObject the object to rotate (mesh, submesh, or group) + # @param Axis the axis of rotation (AxisStruct or geom line) + # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees + # @param MakeGroups forces the generation of new groups from existing ones + # @param NewMeshName the name of the newly created mesh + # @return instance of Mesh class + # @ingroup l2_modif_trsf + def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""): + if (isinstance( theObject, Mesh )): + theObject = theObject.GetMesh() + if (isinstance(Axis, geomBuilder.GEOM._objref_GEOM_Object)): + Axis = self.smeshpyD.GetAxisStruct(Axis) + AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) + Parameters = Axis.parameters + ":" + Parameters + mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians, + MakeGroups, NewMeshName) + self.mesh.SetParameters(Parameters) + return Mesh( self.smeshpyD, self.geompyD, mesh ) + + ## Finds groups of ajacent nodes within Tolerance. + # @param Tolerance the value of tolerance + # @return the list of groups of nodes + # @ingroup l2_modif_trsf + def FindCoincidentNodes (self, Tolerance): + return self.editor.FindCoincidentNodes(Tolerance) + + ## Finds groups of ajacent nodes within Tolerance. + # @param Tolerance the value of tolerance + # @param SubMeshOrGroup SubMesh or Group + # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search + # @return the list of groups of nodes + # @ingroup l2_modif_trsf + def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]): + if (isinstance( SubMeshOrGroup, Mesh )): + SubMeshOrGroup = SubMeshOrGroup.GetMesh() + if not isinstance( exceptNodes, list): + exceptNodes = [ exceptNodes ] + if exceptNodes and isinstance( exceptNodes[0], int): + exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)] + return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes) + + ## Merges nodes + # @param GroupsOfNodes the list of groups of nodes + # @ingroup l2_modif_trsf + def MergeNodes (self, GroupsOfNodes): + self.editor.MergeNodes(GroupsOfNodes) + + ## Finds the elements built on the same nodes. + # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching + # @return a list of groups of equal elements + # @ingroup l2_modif_trsf + def FindEqualElements (self, MeshOrSubMeshOrGroup): + if ( isinstance( MeshOrSubMeshOrGroup, Mesh )): + MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh() + return self.editor.FindEqualElements(MeshOrSubMeshOrGroup) + + ## Merges elements in each given group. + # @param GroupsOfElementsID groups of elements for merging + # @ingroup l2_modif_trsf + def MergeElements(self, GroupsOfElementsID): + self.editor.MergeElements(GroupsOfElementsID) + + ## Leaves one element and removes all other elements built on the same nodes. + # @ingroup l2_modif_trsf + def MergeEqualElements(self): + self.editor.MergeEqualElements() + + ## Sews free borders + # @return SMESH::Sew_Error + # @ingroup l2_modif_trsf + def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, + FirstNodeID2, SecondNodeID2, LastNodeID2, + CreatePolygons, CreatePolyedrs): + return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, + FirstNodeID2, SecondNodeID2, LastNodeID2, + CreatePolygons, CreatePolyedrs) + + ## Sews conform free borders + # @return SMESH::Sew_Error + # @ingroup l2_modif_trsf + def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, + FirstNodeID2, SecondNodeID2): + return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, + FirstNodeID2, SecondNodeID2) + + ## Sews border to side + # @return SMESH::Sew_Error + # @ingroup l2_modif_trsf + def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, + FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs): + return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, + FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs) + + ## Sews two sides of a mesh. The nodes belonging to Side1 are + # merged with the nodes of elements of Side2. + # The number of elements in theSide1 and in theSide2 must be + # equal and they should have similar nodal connectivity. + # The nodes to merge should belong to side borders and + # the first node should be linked to the second. + # @return SMESH::Sew_Error + # @ingroup l2_modif_trsf + def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements, + NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, + NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge): + return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements, + NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, + NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge) + + ## Sets new nodes for the given element. + # @param ide the element id + # @param newIDs nodes ids + # @return If the number of nodes does not correspond to the type of element - returns false + # @ingroup l2_modif_edit + def ChangeElemNodes(self, ide, newIDs): + return self.editor.ChangeElemNodes(ide, newIDs) + + ## If during the last operation of MeshEditor some nodes were + # created, this method returns the list of their IDs, \n + # if new nodes were not created - returns empty list + # @return the list of integer values (can be empty) + # @ingroup l1_auxiliary + def GetLastCreatedNodes(self): + return self.editor.GetLastCreatedNodes() + + ## If during the last operation of MeshEditor some elements were + # created this method returns the list of their IDs, \n + # if new elements were not created - returns empty list + # @return the list of integer values (can be empty) + # @ingroup l1_auxiliary + def GetLastCreatedElems(self): + return self.editor.GetLastCreatedElems() + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # @param theNodes identifiers of nodes to be doubled + # @param theModifiedElems identifiers of elements to be updated by the new (doubled) + # nodes. If list of element identifiers is empty then nodes are doubled but + # they not assigned to elements + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNodes(self, theNodes, theModifiedElems): + return self.editor.DoubleNodes(theNodes, theModifiedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theNodeId identifiers of node to be doubled + # @param theModifiedElems identifiers of elements to be updated + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNode(self, theNodeId, theModifiedElems): + return self.editor.DoubleNode(theNodeId, theModifiedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theNodes group of nodes to be doubled + # @param theModifiedElems group of elements to be updated. + # @param theMakeGroup forces the generation of a group containing new nodes. + # @return TRUE or a created group if operation has been completed successfully, + # FALSE or None otherwise + # @ingroup l2_modif_edit + def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False): + if theMakeGroup: + return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems) + return self.editor.DoubleNodeGroup(theNodes, theModifiedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theNodes list of groups of nodes to be doubled + # @param theModifiedElems list of groups of elements to be updated. + # @param theMakeGroup forces the generation of a group containing new nodes. + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False): + if theMakeGroup: + return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems) + return self.editor.DoubleNodeGroups(theNodes, theModifiedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # @param theElems - the list of elements (edges or faces) to be replicated + # The nodes for duplication could be found from these elements + # @param theNodesNot - list of nodes to NOT replicate + # @param theAffectedElems - the list of elements (cells and edges) to which the + # replicated nodes should be associated to. + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems): + return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # @param theElems - the list of elements (edges or faces) to be replicated + # The nodes for duplication could be found from these elements + # @param theNodesNot - list of nodes to NOT replicate + # @param theShape - shape to detect affected elements (element which geometric center + # located on or inside shape). + # The replicated nodes should be associated to affected elements. + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape): + return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theElems - group of of elements (edges or faces) to be replicated + # @param theNodesNot - group of nodes not to replicated + # @param theAffectedElems - group of elements to which the replicated nodes + # should be associated to. + # @param theMakeGroup forces the generation of a group containing new elements. + # @param theMakeNodeGroup forces the generation of a group containing new nodes. + # @return TRUE or created groups (one or two) if operation has been completed successfully, + # FALSE or None otherwise + # @ingroup l2_modif_edit + def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, + theMakeGroup=False, theMakeNodeGroup=False): + if theMakeGroup or theMakeNodeGroup: + twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot, + theAffectedElems, + theMakeGroup, theMakeNodeGroup) + if theMakeGroup and theMakeNodeGroup: + return twoGroups + else: + return twoGroups[ int(theMakeNodeGroup) ] + return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theElems - group of of elements (edges or faces) to be replicated + # @param theNodesNot - group of nodes not to replicated + # @param theShape - shape to detect affected elements (element which geometric center + # located on or inside shape). + # The replicated nodes should be associated to affected elements. + # @ingroup l2_modif_edit + def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape): + return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theElems - list of groups of elements (edges or faces) to be replicated + # @param theNodesNot - list of groups of nodes not to replicated + # @param theAffectedElems - group of elements to which the replicated nodes + # should be associated to. + # @param theMakeGroup forces the generation of a group containing new elements. + # @param theMakeNodeGroup forces the generation of a group containing new nodes. + # @return TRUE or created groups (one or two) if operation has been completed successfully, + # FALSE or None otherwise + # @ingroup l2_modif_edit + def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, + theMakeGroup=False, theMakeNodeGroup=False): + if theMakeGroup or theMakeNodeGroup: + twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot, + theAffectedElems, + theMakeGroup, theMakeNodeGroup) + if theMakeGroup and theMakeNodeGroup: + return twoGroups + else: + return twoGroups[ int(theMakeNodeGroup) ] + return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems) + + ## Creates a hole in a mesh by doubling the nodes of some particular elements + # This method provided for convenience works as DoubleNodes() described above. + # @param theElems - list of groups of elements (edges or faces) to be replicated + # @param theNodesNot - list of groups of nodes not to replicated + # @param theShape - shape to detect affected elements (element which geometric center + # located on or inside shape). + # The replicated nodes should be associated to affected elements. + # @return TRUE if operation has been completed successfully, FALSE otherwise + # @ingroup l2_modif_edit + def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape): + return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape) + + ## Identify the elements that will be affected by node duplication (actual duplication is not performed. + # This method is the first step of DoubleNodeElemGroupsInRegion. + # @param theElems - list of groups of elements (edges or faces) to be replicated + # @param theNodesNot - list of groups of nodes not to replicated + # @param theShape - shape to detect affected elements (element which geometric center + # located on or inside shape). + # The replicated nodes should be associated to affected elements. + # @return groups of affected elements + # @ingroup l2_modif_edit + def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape): + return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape) + + ## Double nodes on shared faces between groups of volumes and create flat elements on demand. + # The list of groups must describe a partition of the mesh volumes. + # The nodes of the internal faces at the boundaries of the groups are doubled. + # In option, the internal faces are replaced by flat elements. + # Triangles are transformed in prisms, and quadrangles in hexahedrons. + # @param theDomains - list of groups of volumes + # @param createJointElems - if TRUE, create the elements + # @return TRUE if operation has been completed successfully, FALSE otherwise + def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ): + return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems ) + + ## Double nodes on some external faces and create flat elements. + # Flat elements are mainly used by some types of mechanic calculations. + # + # Each group of the list must be constituted of faces. + # Triangles are transformed in prisms, and quadrangles in hexahedrons. + # @param theGroupsOfFaces - list of groups of faces + # @return TRUE if operation has been completed successfully, FALSE otherwise + def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ): + return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces ) + + ## identify all the elements around a geom shape, get the faces delimiting the hole + # + def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords): + return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords ) + + def _getFunctor(self, funcType ): + fn = self.functors[ funcType._v ] + if not fn: + fn = self.smeshpyD.GetFunctor(funcType) + fn.SetMesh(self.mesh) + self.functors[ funcType._v ] = fn + return fn + + def _valueFromFunctor(self, funcType, elemId): + fn = self._getFunctor( funcType ) + if fn.GetElementType() == self.GetElementType(elemId, True): + val = fn.GetValue(elemId) + else: + val = 0 + return val + + ## Get length of 1D element. + # @param elemId mesh element ID + # @return element's length value + # @ingroup l1_measurements + def GetLength(self, elemId): + return self._valueFromFunctor(SMESH.FT_Length, elemId) + + ## Get area of 2D element. + # @param elemId mesh element ID + # @return element's area value + # @ingroup l1_measurements + def GetArea(self, elemId): + return self._valueFromFunctor(SMESH.FT_Area, elemId) + + ## Get volume of 3D element. + # @param elemId mesh element ID + # @return element's volume value + # @ingroup l1_measurements + def GetVolume(self, elemId): + return self._valueFromFunctor(SMESH.FT_Volume3D, elemId) + + ## Get maximum element length. + # @param elemId mesh element ID + # @return element's maximum length value + # @ingroup l1_measurements + def GetMaxElementLength(self, elemId): + if self.GetElementType(elemId, True) == SMESH.VOLUME: + ftype = SMESH.FT_MaxElementLength3D + else: + ftype = SMESH.FT_MaxElementLength2D + return self._valueFromFunctor(ftype, elemId) + + ## Get aspect ratio of 2D or 3D element. + # @param elemId mesh element ID + # @return element's aspect ratio value + # @ingroup l1_measurements + def GetAspectRatio(self, elemId): + if self.GetElementType(elemId, True) == SMESH.VOLUME: + ftype = SMESH.FT_AspectRatio3D + else: + ftype = SMESH.FT_AspectRatio + return self._valueFromFunctor(ftype, elemId) + + ## Get warping angle of 2D element. + # @param elemId mesh element ID + # @return element's warping angle value + # @ingroup l1_measurements + def GetWarping(self, elemId): + return self._valueFromFunctor(SMESH.FT_Warping, elemId) + + ## Get minimum angle of 2D element. + # @param elemId mesh element ID + # @return element's minimum angle value + # @ingroup l1_measurements + def GetMinimumAngle(self, elemId): + return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId) + + ## Get taper of 2D element. + # @param elemId mesh element ID + # @return element's taper value + # @ingroup l1_measurements + def GetTaper(self, elemId): + return self._valueFromFunctor(SMESH.FT_Taper, elemId) + + ## Get skew of 2D element. + # @param elemId mesh element ID + # @return element's skew value + # @ingroup l1_measurements + def GetSkew(self, elemId): + return self._valueFromFunctor(SMESH.FT_Skew, elemId) + + pass # end of Mesh class + +## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class +# +class Pattern(SMESH._objref_SMESH_Pattern): + + def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse): + decrFun = lambda i: i-1 + theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun) + theMesh.SetParameters(Parameters) + return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse ) + + def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index): + decrFun = lambda i: i-1 + theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun) + theMesh.SetParameters(Parameters) + return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index ) + +# Registering the new proxy for Pattern +omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern) + +## Private class used to bind methods creating algorithms to the class Mesh +# +class algoCreator: + def __init__(self): + self.mesh = None + self.defaultAlgoType = "" + self.algoTypeToClass = {} + + # Stores a python class of algorithm + def add(self, algoClass): + if type( algoClass ).__name__ == 'classobj' and \ + hasattr( algoClass, "algoType"): + self.algoTypeToClass[ algoClass.algoType ] = algoClass + if not self.defaultAlgoType and \ + hasattr( algoClass, "isDefault") and algoClass.isDefault: + self.defaultAlgoType = algoClass.algoType + #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType + + # creates a copy of self and assign mesh to the copy + def copy(self, mesh): + other = algoCreator() + other.defaultAlgoType = self.defaultAlgoType + other.algoTypeToClass = self.algoTypeToClass + other.mesh = mesh + return other + + # creates an instance of algorithm + def __call__(self,algo="",geom=0,*args): + algoType = self.defaultAlgoType + for arg in args + (algo,geom): + if isinstance( arg, geomBuilder.GEOM._objref_GEOM_Object ): + geom = arg + if isinstance( arg, str ) and arg: + algoType = arg + if not algoType and self.algoTypeToClass: + algoType = self.algoTypeToClass.keys()[0] + if self.algoTypeToClass.has_key( algoType ): + #print "Create algo",algoType + return self.algoTypeToClass[ algoType ]( self.mesh, geom ) + raise RuntimeError, "No class found for algo type %s" % algoType + return None + +# Private class used to substitute and store variable parameters of hypotheses. +# +class hypMethodWrapper: + def __init__(self, hyp, method): + self.hyp = hyp + self.method = method + #print "REBIND:", method.__name__ + return + + # call a method of hypothesis with calling SetVarParameter() before + def __call__(self,*args): + if not args: + return self.method( self.hyp, *args ) # hypothesis method with no args + + #print "MethWrapper.__call__",self.method.__name__, args + try: + parsed = ParseParameters(*args) # replace variables with their values + self.hyp.SetVarParameter( parsed[-2], self.method.__name__ ) + result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method + except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call + # maybe there is a replaced string arg which is not variable + result = self.method( self.hyp, *args ) + except ValueError, detail: # raised by ParseParameters() + try: + result = self.method( self.hyp, *args ) + except omniORB.CORBA.BAD_PARAM: + raise ValueError, detail # wrong variable name + + return result + +for pluginName in os.environ[ "SMESH_MeshersList" ].split( ":" ): + # + #print "pluginName: ", pluginName + pluginBuilderName = pluginName + "Builder" + try: + exec( "from salome.%s.%s import *" % (pluginName, pluginBuilderName)) + except Exception, e: + print "Exception while loading %s: %s" % ( pluginBuilderName, e ) + continue + exec( "from salome.%s import %s" % (pluginName, pluginBuilderName)) + plugin = eval( pluginBuilderName ) + #print " plugin:" , str(plugin) + + # add methods creating algorithms to Mesh + for k in dir( plugin ): + if k[0] == '_': continue + algo = getattr( plugin, k ) + #print " algo:", str(algo) + if type( algo ).__name__ == 'classobj' and hasattr( algo, "meshMethod" ): + #print " meshMethod:" , str(algo.meshMethod) + if not hasattr( Mesh, algo.meshMethod ): + setattr( Mesh, algo.meshMethod, algoCreator() ) + pass + getattr( Mesh, algo.meshMethod ).add( algo ) + pass + pass + pass +del pluginName diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py deleted file mode 100644 index 49235f848..000000000 --- a/src/SMESH_SWIG/smeshDC.py +++ /dev/null @@ -1,4342 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# File : smesh.py -# Author : Francis KLOSS, OCC -# Module : SMESH - -## @package smesh -# Python API for SALOME %Mesh module - -## @defgroup l1_auxiliary Auxiliary methods and structures -## @defgroup l1_creating Creating meshes -## @{ -## @defgroup l2_impexp Importing and exporting meshes -## @defgroup l2_construct Constructing meshes -## @defgroup l2_algorithms Defining Algorithms -## @{ -## @defgroup l3_algos_basic Basic meshing algorithms -## @defgroup l3_algos_proj Projection Algorithms -## @defgroup l3_algos_radialp Radial Prism -## @defgroup l3_algos_segmarv Segments around Vertex -## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm - -## @} -## @defgroup l2_hypotheses Defining hypotheses -## @{ -## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses -## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses -## @defgroup l3_hypos_maxvol Max Element Volume hypothesis -## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis -## @defgroup l3_hypos_additi Additional Hypotheses - -## @} -## @defgroup l2_submeshes Constructing submeshes -## @defgroup l2_compounds Building Compounds -## @defgroup l2_editing Editing Meshes - -## @} -## @defgroup l1_meshinfo Mesh Information -## @defgroup l1_controls Quality controls and Filtering -## @defgroup l1_grouping Grouping elements -## @{ -## @defgroup l2_grps_create Creating groups -## @defgroup l2_grps_edit Editing groups -## @defgroup l2_grps_operon Using operations on groups -## @defgroup l2_grps_delete Deleting Groups - -## @} -## @defgroup l1_modifying Modifying meshes -## @{ -## @defgroup l2_modif_add Adding nodes and elements -## @defgroup l2_modif_del Removing nodes and elements -## @defgroup l2_modif_edit Modifying nodes and elements -## @defgroup l2_modif_renumber Renumbering nodes and elements -## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging) -## @defgroup l2_modif_movenode Moving nodes -## @defgroup l2_modif_throughp Mesh through point -## @defgroup l2_modif_invdiag Diagonal inversion of elements -## @defgroup l2_modif_unitetri Uniting triangles -## @defgroup l2_modif_changori Changing orientation of elements -## @defgroup l2_modif_cutquadr Cutting quadrangles -## @defgroup l2_modif_smooth Smoothing -## @defgroup l2_modif_extrurev Extrusion and Revolution -## @defgroup l2_modif_patterns Pattern mapping -## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh - -## @} -## @defgroup l1_measurements Measurements - -import salome -import geompyDC - -import SMESH # This is necessary for back compatibility -from SMESH import * -from smesh_algorithm import Mesh_Algorithm - -import SALOME -import SALOMEDS - -## @addtogroup l1_auxiliary -## @{ - -# MirrorType enumeration -POINT = SMESH_MeshEditor.POINT -AXIS = SMESH_MeshEditor.AXIS -PLANE = SMESH_MeshEditor.PLANE - -# Smooth_Method enumeration -LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH -CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH - -PrecisionConfusion = 1e-07 - -# TopAbs_State enumeration -[TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4) - -# Methods of splitting a hexahedron into tetrahedra -Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3 - -## Converts an angle from degrees to radians -def DegreesToRadians(AngleInDegrees): - from math import pi - return AngleInDegrees * pi / 180.0 - -import salome_notebook -notebook = salome_notebook.notebook -# Salome notebook variable separator -var_separator = ":" - -## Return list of variable values from salome notebook. -# The last argument, if is callable, is used to modify values got from notebook -def ParseParameters(*args): - Result = [] - Parameters = "" - hasVariables = False - varModifFun=None - if args and callable( args[-1] ): - args, varModifFun = args[:-1], args[-1] - for parameter in args: - - Parameters += str(parameter) + var_separator - - if isinstance(parameter,str): - # check if there is an inexistent variable name - if not notebook.isVariable(parameter): - raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!" - parameter = notebook.get(parameter) - hasVariables = True - if varModifFun: - parameter = varModifFun(parameter) - pass - pass - Result.append(parameter) - - pass - Parameters = Parameters[:-1] - Result.append( Parameters ) - Result.append( hasVariables ) - return Result - -# Parse parameters converting variables to radians -def ParseAngles(*args): - return ParseParameters( *( args + (DegreesToRadians, ))) - -# Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables. -# Parameters are stored in PointStruct.parameters attribute -def __initPointStruct(point,*args): - point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args) - pass -SMESH.PointStruct.__init__ = __initPointStruct - -# Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables. -# Parameters are stored in AxisStruct.parameters attribute -def __initAxisStruct(ax,*args): - ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args) - pass -SMESH.AxisStruct.__init__ = __initAxisStruct - - -def IsEqual(val1, val2, tol=PrecisionConfusion): - if abs(val1 - val2) < tol: - return True - return False - -NO_NAME = "NoName" - -## Gets object name -def GetName(obj): - if obj: - # object not null - if isinstance(obj, SALOMEDS._objref_SObject): - # study object - return obj.GetName() - try: - ior = salome.orb.object_to_string(obj) - except: - ior = None - if ior: - # CORBA object - studies = salome.myStudyManager.GetOpenStudies() - for sname in studies: - s = salome.myStudyManager.GetStudyByName(sname) - if not s: continue - sobj = s.FindObjectIOR(ior) - if not sobj: continue - return sobj.GetName() - if hasattr(obj, "GetName"): - # unknown CORBA object, having GetName() method - return obj.GetName() - else: - # unknown CORBA object, no GetName() method - return NO_NAME - pass - if hasattr(obj, "GetName"): - # unknown non-CORBA object, having GetName() method - return obj.GetName() - pass - raise RuntimeError, "Null or invalid object" - -## Prints error message if a hypothesis was not assigned. -def TreatHypoStatus(status, hypName, geomName, isAlgo): - if isAlgo: - hypType = "algorithm" - else: - hypType = "hypothesis" - pass - if status == HYP_UNKNOWN_FATAL : - reason = "for unknown reason" - elif status == HYP_INCOMPATIBLE : - reason = "this hypothesis mismatches the algorithm" - elif status == HYP_NOTCONFORM : - reason = "a non-conform mesh would be built" - elif status == HYP_ALREADY_EXIST : - if isAlgo: return # it does not influence anything - reason = hypType + " of the same dimension is already assigned to this shape" - elif status == HYP_BAD_DIM : - reason = hypType + " mismatches the shape" - elif status == HYP_CONCURENT : - reason = "there are concurrent hypotheses on sub-shapes" - elif status == HYP_BAD_SUBSHAPE : - reason = "the shape is neither the main one, nor its sub-shape, nor a valid group" - elif status == HYP_BAD_GEOMETRY: - reason = "geometry mismatches the expectation of the algorithm" - elif status == HYP_HIDDEN_ALGO: - reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions" - elif status == HYP_HIDING_ALGO: - reason = "it hides algorithms of lower dimensions by generating elements of all dimensions" - elif status == HYP_NEED_SHAPE: - reason = "Algorithm can't work without shape" - else: - return - hypName = '"' + hypName + '"' - geomName= '"' + geomName+ '"' - if status < HYP_UNKNOWN_FATAL and not geomName =='""': - print hypName, "was assigned to", geomName,"but", reason - elif not geomName == '""': - print hypName, "was not assigned to",geomName,":", reason - else: - print hypName, "was not assigned:", reason - pass - -## Private method. Add geom (sub-shape of the main shape) into the study if not yet there -def AssureGeomPublished(mesh, geom, name=''): - if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ): - return - if not geom.GetStudyEntry() and \ - mesh.smeshpyD.GetCurrentStudy(): - ## set the study - studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId() - if studyID != mesh.geompyD.myStudyId: - mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy()) - ## get a name - if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND: - # for all groups SubShapeName() returns "Compound_-1" - name = mesh.geompyD.SubShapeName(geom, mesh.geom) - if not name: - name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000) - ## publish - mesh.geompyD.addToStudyInFather( mesh.geom, geom, name ) - return - -## Return the first vertex of a geomertical edge by ignoring orienation -def FirstVertexOnCurve(edge): - from geompy import SubShapeAll, ShapeType, MakeVertexOnCurve, PointCoordinates - vv = SubShapeAll( edge, ShapeType["VERTEX"]) - if not vv: - raise TypeError, "Given object has no vertices" - if len( vv ) == 1: return vv[0] - v0 = MakeVertexOnCurve(edge,0.) - xyz = PointCoordinates( v0 ) # coords of the first vertex - xyz1 = PointCoordinates( vv[0] ) - xyz2 = PointCoordinates( vv[1] ) - dist1, dist2 = 0,0 - for i in range(3): - dist1 += abs( xyz[i] - xyz1[i] ) - dist2 += abs( xyz[i] - xyz2[i] ) - if dist1 < dist2: - return vv[0] - else: - return vv[1] - -# end of l1_auxiliary -## @} - -# All methods of this class are accessible directly from the smesh.py package. -class smeshDC(SMESH._objref_SMESH_Gen): - - ## Dump component to the Python script - # This method overrides IDL function to allow default values for the parameters. - def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True): - return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile) - - ## Set mode of DumpPython(), \a historical or \a snapshot. - # In the \a historical mode, the Python Dump script includes all commands - # performed by SMESH engine. In the \a snapshot mode, commands - # relating to objects removed from the Study are excluded from the script - # as well as commands not influencing the current state of meshes - def SetDumpPythonHistorical(self, isHistorical): - if isHistorical: val = "true" - else: val = "false" - SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val) - - ## Sets the current study and Geometry component - # @ingroup l1_auxiliary - def init_smesh(self,theStudy,geompyD): - self.SetCurrentStudy(theStudy,geompyD) - - ## Creates an empty Mesh. This mesh can have an underlying geometry. - # @param obj the Geometrical object on which the mesh is built. If not defined, - # the mesh will have no underlying geometry. - # @param name the name for the new mesh. - # @return an instance of Mesh class. - # @ingroup l2_construct - def Mesh(self, obj=0, name=0): - if isinstance(obj,str): - obj,name = name,obj - return Mesh(self,self.geompyD,obj,name) - - ## Returns a long value from enumeration - # @ingroup l1_controls - def EnumToLong(self,theItem): - return theItem._v - - ## Returns a string representation of the color. - # To be used with filters. - # @param c color value (SALOMEDS.Color) - # @ingroup l1_controls - def ColorToString(self,c): - val = "" - if isinstance(c, SALOMEDS.Color): - val = "%s;%s;%s" % (c.R, c.G, c.B) - elif isinstance(c, str): - val = c - else: - raise ValueError, "Color value should be of string or SALOMEDS.Color type" - return val - - ## Gets PointStruct from vertex - # @param theVertex a GEOM object(vertex) - # @return SMESH.PointStruct - # @ingroup l1_auxiliary - def GetPointStruct(self,theVertex): - [x, y, z] = self.geompyD.PointCoordinates(theVertex) - return PointStruct(x,y,z) - - ## Gets DirStruct from vector - # @param theVector a GEOM object(vector) - # @return SMESH.DirStruct - # @ingroup l1_auxiliary - def GetDirStruct(self,theVector): - vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] ) - if(len(vertices) != 2): - print "Error: vector object is incorrect." - return None - p1 = self.geompyD.PointCoordinates(vertices[0]) - p2 = self.geompyD.PointCoordinates(vertices[1]) - pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) - dirst = DirStruct(pnt) - return dirst - - ## Makes DirStruct from a triplet - # @param x,y,z vector components - # @return SMESH.DirStruct - # @ingroup l1_auxiliary - def MakeDirStruct(self,x,y,z): - pnt = PointStruct(x,y,z) - return DirStruct(pnt) - - ## Get AxisStruct from object - # @param theObj a GEOM object (line or plane) - # @return SMESH.AxisStruct - # @ingroup l1_auxiliary - def GetAxisStruct(self,theObj): - edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] ) - if len(edges) > 1: - vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] ) - vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] ) - vertex1 = self.geompyD.PointCoordinates(vertex1) - vertex2 = self.geompyD.PointCoordinates(vertex2) - vertex3 = self.geompyD.PointCoordinates(vertex3) - vertex4 = self.geompyD.PointCoordinates(vertex4) - v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]] - v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]] - normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ] - axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2]) - return axis - elif len(edges) == 1: - vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] ) - p1 = self.geompyD.PointCoordinates( vertex1 ) - p2 = self.geompyD.PointCoordinates( vertex2 ) - axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) - return axis - return None - - # From SMESH_Gen interface: - # ------------------------ - - ## Sets the given name to the object - # @param obj the object to rename - # @param name a new object name - # @ingroup l1_auxiliary - def SetName(self, obj, name): - if isinstance( obj, Mesh ): - obj = obj.GetMesh() - elif isinstance( obj, Mesh_Algorithm ): - obj = obj.GetAlgorithm() - ior = salome.orb.object_to_string(obj) - SMESH._objref_SMESH_Gen.SetName(self, ior, name) - - ## Sets the current mode - # @ingroup l1_auxiliary - def SetEmbeddedMode( self,theMode ): - #self.SetEmbeddedMode(theMode) - SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode) - - ## Gets the current mode - # @ingroup l1_auxiliary - def IsEmbeddedMode(self): - #return self.IsEmbeddedMode() - return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self) - - ## Sets the current study - # @ingroup l1_auxiliary - def SetCurrentStudy( self, theStudy, geompyD = None ): - #self.SetCurrentStudy(theStudy) - if not geompyD: - import geompy - geompyD = geompy.geom - pass - self.geompyD=geompyD - self.SetGeomEngine(geompyD) - SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy) - global notebook - if theStudy: - notebook = salome_notebook.NoteBook( theStudy ) - else: - notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() ) - - ## Gets the current study - # @ingroup l1_auxiliary - def GetCurrentStudy(self): - #return self.GetCurrentStudy() - return SMESH._objref_SMESH_Gen.GetCurrentStudy(self) - - ## Creates a Mesh object importing data from the given UNV file - # @return an instance of Mesh class - # @ingroup l2_impexp - def CreateMeshesFromUNV( self,theFileName ): - aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName) - aMesh = Mesh(self, self.geompyD, aSmeshMesh) - return aMesh - - ## Creates a Mesh object(s) importing data from the given MED file - # @return a list of Mesh class instances - # @ingroup l2_impexp - def CreateMeshesFromMED( self,theFileName ): - aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName) - aMeshes = [] - for iMesh in range(len(aSmeshMeshes)) : - aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) - aMeshes.append(aMesh) - return aMeshes, aStatus - - ## Creates a Mesh object(s) importing data from the given SAUV file - # @return a list of Mesh class instances - # @ingroup l2_impexp - def CreateMeshesFromSAUV( self,theFileName ): - aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName) - aMeshes = [] - for iMesh in range(len(aSmeshMeshes)) : - aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) - aMeshes.append(aMesh) - return aMeshes, aStatus - - ## Creates a Mesh object importing data from the given STL file - # @return an instance of Mesh class - # @ingroup l2_impexp - def CreateMeshesFromSTL( self, theFileName ): - aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName) - aMesh = Mesh(self, self.geompyD, aSmeshMesh) - return aMesh - - ## Creates Mesh objects importing data from the given CGNS file - # @return an instance of Mesh class - # @ingroup l2_impexp - def CreateMeshesFromCGNS( self, theFileName ): - aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName) - aMeshes = [] - for iMesh in range(len(aSmeshMeshes)) : - aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh]) - aMeshes.append(aMesh) - return aMeshes, aStatus - - ## Creates a Mesh object importing data from the given GMF file - # @return [ an instance of Mesh class, SMESH::ComputeError ] - # @ingroup l2_impexp - def CreateMeshesFromGMF( self, theFileName ): - aSmeshMesh, error = SMESH._objref_SMESH_Gen.CreateMeshesFromGMF(self, - theFileName, - True) - if error.comment: print "*** CreateMeshesFromGMF() errors:\n", error.comment - return Mesh(self, self.geompyD, aSmeshMesh), error - - ## Concatenate the given meshes into one mesh. - # @return an instance of Mesh class - # @param meshes the meshes to combine into one mesh - # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed - # @param mergeNodesAndElements if true, equal nodes and elements aremerged - # @param mergeTolerance tolerance for merging nodes - # @param allGroups forces creation of groups of all elements - # @param name name of a new mesh - def Concatenate( self, meshes, uniteIdenticalGroups, - mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False, - name = ""): - if not meshes: return None - for i,m in enumerate(meshes): - if isinstance(m, Mesh): - meshes[i] = m.GetMesh() - mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance) - meshes[0].SetParameters(Parameters) - if allGroups: - aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( - self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) - else: - aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate( - self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance) - aMesh = Mesh(self, self.geompyD, aSmeshMesh, name=name) - return aMesh - - ## Create a mesh by copying a part of another mesh. - # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group; - # to copy nodes or elements not contained in any mesh object, - # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart - # @param meshName a name of the new mesh - # @param toCopyGroups to create in the new mesh groups the copied elements belongs to - # @param toKeepIDs to preserve IDs of the copied elements or not - # @return an instance of Mesh class - def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False): - if (isinstance( meshPart, Mesh )): - meshPart = meshPart.GetMesh() - mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs ) - return Mesh(self, self.geompyD, mesh) - - ## From SMESH_Gen interface - # @return the list of integer values - # @ingroup l1_auxiliary - def GetSubShapesId( self, theMainObject, theListOfSubObjects ): - return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects) - - ## From SMESH_Gen interface. Creates a pattern - # @return an instance of SMESH_Pattern - # - # Example of Patterns usage - # @ingroup l2_modif_patterns - def GetPattern(self): - return SMESH._objref_SMESH_Gen.GetPattern(self) - - ## Sets number of segments per diagonal of boundary box of geometry by which - # default segment length of appropriate 1D hypotheses is defined. - # Default value is 10 - # @ingroup l1_auxiliary - def SetBoundaryBoxSegmentation(self, nbSegments): - SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments) - - # Filtering. Auxiliary functions: - # ------------------------------ - - ## Creates an empty criterion - # @return SMESH.Filter.Criterion - # @ingroup l1_controls - def GetEmptyCriterion(self): - Type = self.EnumToLong(FT_Undefined) - Compare = self.EnumToLong(FT_Undefined) - Threshold = 0 - ThresholdStr = "" - ThresholdID = "" - UnaryOp = self.EnumToLong(FT_Undefined) - BinaryOp = self.EnumToLong(FT_Undefined) - Tolerance = 1e-07 - TypeOfElement = ALL - Precision = -1 ##@1e-07 - return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID, - UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision) - - ## Creates a criterion by the given parameters - # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below) - # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME) - # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.) - # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} - # @param Threshold the threshold value (range of ids as string, shape, numeric) - # @param UnaryOp FT_LogicalNOT or FT_Undefined - # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or - # FT_Undefined (must be for the last criterion of all criteria) - # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, - # FT_LyingOnGeom, FT_CoplanarFaces criteria - # @return SMESH.Filter.Criterion - # - # Example of Criteria usage - # @ingroup l1_controls - def GetCriterion(self,elementType, - CritType, - Compare = FT_EqualTo, - Threshold="", - UnaryOp=FT_Undefined, - BinaryOp=FT_Undefined, - Tolerance=1e-07): - if not CritType in SMESH.FunctorType._items: - raise TypeError, "CritType should be of SMESH.FunctorType" - aCriterion = self.GetEmptyCriterion() - aCriterion.TypeOfElement = elementType - aCriterion.Type = self.EnumToLong(CritType) - aCriterion.Tolerance = Tolerance - - aThreshold = Threshold - - if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]: - aCriterion.Compare = self.EnumToLong(Compare) - elif Compare == "=" or Compare == "==": - aCriterion.Compare = self.EnumToLong(FT_EqualTo) - elif Compare == "<": - aCriterion.Compare = self.EnumToLong(FT_LessThan) - elif Compare == ">": - aCriterion.Compare = self.EnumToLong(FT_MoreThan) - elif Compare != FT_Undefined: - aCriterion.Compare = self.EnumToLong(FT_EqualTo) - aThreshold = Compare - - if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface, - FT_BelongToCylinder, FT_LyingOnGeom]: - # Checks that Threshold is GEOM object - if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object): - aCriterion.ThresholdStr = GetName(aThreshold) - aCriterion.ThresholdID = aThreshold.GetStudyEntry() - if not aCriterion.ThresholdID: - name = aCriterion.ThresholdStr - if not name: - name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000) - aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name ) - #raise RuntimeError, "Threshold shape must be published" - else: - print "Error: The Threshold should be a shape." - return None - if isinstance(UnaryOp,float): - aCriterion.Tolerance = UnaryOp - UnaryOp = FT_Undefined - pass - elif CritType == FT_RangeOfIds: - # Checks that Threshold is string - if isinstance(aThreshold, str): - aCriterion.ThresholdStr = aThreshold - else: - print "Error: The Threshold should be a string." - return None - elif CritType == FT_CoplanarFaces: - # Checks the Threshold - if isinstance(aThreshold, int): - aCriterion.ThresholdID = str(aThreshold) - elif isinstance(aThreshold, str): - ID = int(aThreshold) - if ID < 1: - raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold - aCriterion.ThresholdID = aThreshold - else: - raise ValueError,\ - "The Threshold should be an ID of mesh face and not '%s'"%aThreshold - elif CritType == FT_ElemGeomType: - # Checks the Threshold - try: - aCriterion.Threshold = self.EnumToLong(aThreshold) - assert( aThreshold in SMESH.GeometryType._items ) - except: - if isinstance(aThreshold, int): - aCriterion.Threshold = aThreshold - else: - print "Error: The Threshold should be an integer or SMESH.GeometryType." - return None - pass - pass - elif CritType == FT_EntityType: - # Checks the Threshold - try: - aCriterion.Threshold = self.EnumToLong(aThreshold) - assert( aThreshold in SMESH.EntityType._items ) - except: - if isinstance(aThreshold, int): - aCriterion.Threshold = aThreshold - else: - print "Error: The Threshold should be an integer or SMESH.EntityType." - return None - pass - pass - - elif CritType == FT_GroupColor: - # Checks the Threshold - try: - aCriterion.ThresholdStr = self.ColorToString(aThreshold) - except: - print "Error: The threshold value should be of SALOMEDS.Color type" - return None - pass - elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces, - FT_LinearOrQuadratic, FT_BadOrientedVolume, - FT_BareBorderFace, FT_BareBorderVolume, - FT_OverConstrainedFace, FT_OverConstrainedVolume, - FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]: - # At this point the Threshold is unnecessary - if aThreshold == FT_LogicalNOT: - aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT) - elif aThreshold in [FT_LogicalAND, FT_LogicalOR]: - aCriterion.BinaryOp = aThreshold - else: - # Check Threshold - try: - aThreshold = float(aThreshold) - aCriterion.Threshold = aThreshold - except: - print "Error: The Threshold should be a number." - return None - - if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT: - aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT) - - if Threshold in [FT_LogicalAND, FT_LogicalOR]: - aCriterion.BinaryOp = self.EnumToLong(Threshold) - - if UnaryOp in [FT_LogicalAND, FT_LogicalOR]: - aCriterion.BinaryOp = self.EnumToLong(UnaryOp) - - if BinaryOp in [FT_LogicalAND, FT_LogicalOR]: - aCriterion.BinaryOp = self.EnumToLong(BinaryOp) - - return aCriterion - - ## Creates a filter with the given parameters - # @param elementType the type of elements in the group - # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) - # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} - # @param Threshold the threshold value (range of id ids as string, shape, numeric) - # @param UnaryOp FT_LogicalNOT or FT_Undefined - # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, - # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria - # @return SMESH_Filter - # - # Example of Filters usage - # @ingroup l1_controls - def GetFilter(self,elementType, - CritType=FT_Undefined, - Compare=FT_EqualTo, - Threshold="", - UnaryOp=FT_Undefined, - Tolerance=1e-07): - aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance) - aFilterMgr = self.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - aCriteria = [] - aCriteria.append(aCriterion) - aFilter.SetCriteria(aCriteria) - aFilterMgr.UnRegister() - return aFilter - - ## Creates a filter from criteria - # @param criteria a list of criteria - # @return SMESH_Filter - # - # Example of Filters usage - # @ingroup l1_controls - def GetFilterFromCriteria(self,criteria): - aFilterMgr = self.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - aFilter.SetCriteria(criteria) - aFilterMgr.UnRegister() - return aFilter - - ## Creates a numerical functor by its type - # @param theCriterion FT_...; functor type - # @return SMESH_NumericalFunctor - # @ingroup l1_controls - def GetFunctor(self,theCriterion): - if isinstance( theCriterion, SMESH._objref_NumericalFunctor ): - return theCriterion - aFilterMgr = self.CreateFilterManager() - functor = None - if theCriterion == FT_AspectRatio: - functor = aFilterMgr.CreateAspectRatio() - elif theCriterion == FT_AspectRatio3D: - functor = aFilterMgr.CreateAspectRatio3D() - elif theCriterion == FT_Warping: - functor = aFilterMgr.CreateWarping() - elif theCriterion == FT_MinimumAngle: - functor = aFilterMgr.CreateMinimumAngle() - elif theCriterion == FT_Taper: - functor = aFilterMgr.CreateTaper() - elif theCriterion == FT_Skew: - functor = aFilterMgr.CreateSkew() - elif theCriterion == FT_Area: - functor = aFilterMgr.CreateArea() - elif theCriterion == FT_Volume3D: - functor = aFilterMgr.CreateVolume3D() - elif theCriterion == FT_MaxElementLength2D: - functor = aFilterMgr.CreateMaxElementLength2D() - elif theCriterion == FT_MaxElementLength3D: - functor = aFilterMgr.CreateMaxElementLength3D() - elif theCriterion == FT_MultiConnection: - functor = aFilterMgr.CreateMultiConnection() - elif theCriterion == FT_MultiConnection2D: - functor = aFilterMgr.CreateMultiConnection2D() - elif theCriterion == FT_Length: - functor = aFilterMgr.CreateLength() - elif theCriterion == FT_Length2D: - functor = aFilterMgr.CreateLength2D() - else: - print "Error: given parameter is not numerical functor type." - aFilterMgr.UnRegister() - return functor - - ## Creates hypothesis - # @param theHType mesh hypothesis type (string) - # @param theLibName mesh plug-in library name - # @return created hypothesis instance - def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"): - hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName ) - - if isinstance( hyp, SMESH._objref_SMESH_Algo ): - return hyp - - # wrap hypothesis methods - #print "HYPOTHESIS", theHType - for meth_name in dir( hyp.__class__ ): - if not meth_name.startswith("Get") and \ - not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ): - method = getattr ( hyp.__class__, meth_name ) - if callable(method): - setattr( hyp, meth_name, hypMethodWrapper( hyp, method )) - - return hyp - - ## Gets the mesh statistic - # @return dictionary "element type" - "count of elements" - # @ingroup l1_meshinfo - def GetMeshInfo(self, obj): - if isinstance( obj, Mesh ): - obj = obj.GetMesh() - d = {} - if hasattr(obj, "GetMeshInfo"): - values = obj.GetMeshInfo() - for i in range(SMESH.Entity_Last._v): - if i < len(values): d[SMESH.EntityType._item(i)]=values[i] - pass - return d - - ## Get minimum distance between two objects - # - # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed. - # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1. - # - # @param src1 first source object - # @param src2 second source object - # @param id1 node/element id from the first source - # @param id2 node/element id from the second (or first) source - # @param isElem1 @c True if @a id1 is element id, @c False if it is node id - # @param isElem2 @c True if @a id2 is element id, @c False if it is node id - # @return minimum distance value - # @sa GetMinDistance() - # @ingroup l1_measurements - def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False): - result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2) - if result is None: - result = 0.0 - else: - result = result.value - return result - - ## Get measure structure specifying minimum distance data between two objects - # - # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed. - # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1. - # - # @param src1 first source object - # @param src2 second source object - # @param id1 node/element id from the first source - # @param id2 node/element id from the second (or first) source - # @param isElem1 @c True if @a id1 is element id, @c False if it is node id - # @param isElem2 @c True if @a id2 is element id, @c False if it is node id - # @return Measure structure or None if input data is invalid - # @sa MinDistance() - # @ingroup l1_measurements - def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False): - if isinstance(src1, Mesh): src1 = src1.mesh - if isinstance(src2, Mesh): src2 = src2.mesh - if src2 is None and id2 != 0: src2 = src1 - if not hasattr(src1, "_narrow"): return None - src1 = src1._narrow(SMESH.SMESH_IDSource) - if not src1: return None - if id1 != 0: - m = src1.GetMesh() - e = m.GetMeshEditor() - if isElem1: - src1 = e.MakeIDSource([id1], SMESH.FACE) - else: - src1 = e.MakeIDSource([id1], SMESH.NODE) - pass - if hasattr(src2, "_narrow"): - src2 = src2._narrow(SMESH.SMESH_IDSource) - if src2 and id2 != 0: - m = src2.GetMesh() - e = m.GetMeshEditor() - if isElem2: - src2 = e.MakeIDSource([id2], SMESH.FACE) - else: - src2 = e.MakeIDSource([id2], SMESH.NODE) - pass - pass - aMeasurements = self.CreateMeasurements() - result = aMeasurements.MinDistance(src1, src2) - aMeasurements.UnRegister() - return result - - ## Get bounding box of the specified object(s) - # @param objects single source object or list of source objects - # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ) - # @sa GetBoundingBox() - # @ingroup l1_measurements - def BoundingBox(self, objects): - result = self.GetBoundingBox(objects) - if result is None: - result = (0.0,)*6 - else: - result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ) - return result - - ## Get measure structure specifying bounding box data of the specified object(s) - # @param objects single source object or list of source objects - # @return Measure structure - # @sa BoundingBox() - # @ingroup l1_measurements - def GetBoundingBox(self, objects): - if isinstance(objects, tuple): - objects = list(objects) - if not isinstance(objects, list): - objects = [objects] - srclist = [] - for o in objects: - if isinstance(o, Mesh): - srclist.append(o.mesh) - elif hasattr(o, "_narrow"): - src = o._narrow(SMESH.SMESH_IDSource) - if src: srclist.append(src) - pass - pass - aMeasurements = self.CreateMeasurements() - result = aMeasurements.BoundingBox(srclist) - aMeasurements.UnRegister() - return result - -import omniORB -#Registering the new proxy for SMESH_Gen -omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC) - - -# Public class: Mesh -# ================== - -## This class allows defining and managing a mesh. -# It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes. -# It also has methods to define groups of mesh elements, to modify a mesh (by addition of -# new nodes and elements and by changing the existing entities), to get information -# about a mesh and to export a mesh into different formats. -class Mesh: - - geom = 0 - mesh = 0 - editor = 0 - - ## Constructor - # - # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and - # sets the GUI name of this mesh to \a name. - # @param smeshpyD an instance of smeshDC class - # @param geompyD an instance of geompyDC class - # @param obj Shape to be meshed or SMESH_Mesh object - # @param name Study name of the mesh - # @ingroup l2_construct - def __init__(self, smeshpyD, geompyD, obj=0, name=0): - self.smeshpyD=smeshpyD - self.geompyD=geompyD - if obj is None: - obj = 0 - objHasName = False - if obj != 0: - if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object): - self.geom = obj - objHasName = True - # publish geom of mesh (issue 0021122) - if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy(): - objHasName = False - studyID = smeshpyD.GetCurrentStudy()._get_StudyId() - if studyID != geompyD.myStudyId: - geompyD.init_geom( smeshpyD.GetCurrentStudy()) - pass - if name: - geo_name = name + " shape" - else: - geo_name = "%s_%s to mesh"%(self.geom.GetShapeType(), id(self.geom)%100) - geompyD.addToStudy( self.geom, geo_name ) - self.mesh = self.smeshpyD.CreateMesh(self.geom) - - elif isinstance(obj, SMESH._objref_SMESH_Mesh): - self.SetMesh(obj) - else: - self.mesh = self.smeshpyD.CreateEmptyMesh() - if name: - self.smeshpyD.SetName(self.mesh, name) - elif objHasName: - self.smeshpyD.SetName(self.mesh, GetName(obj)) # + " mesh" - - if not self.geom: - self.geom = self.mesh.GetShapeToMesh() - - self.editor = self.mesh.GetMeshEditor() - self.functors = [None] * SMESH.FT_Undefined._v - - # set self to algoCreator's - for attrName in dir(self): - attr = getattr( self, attrName ) - if isinstance( attr, algoCreator ): - setattr( self, attrName, attr.copy( self )) - - ## Initializes the Mesh object from an instance of SMESH_Mesh interface - # @param theMesh a SMESH_Mesh object - # @ingroup l2_construct - def SetMesh(self, theMesh): - if self.mesh: self.mesh.UnRegister() - self.mesh = theMesh - if self.mesh: - self.mesh.Register() - self.geom = self.mesh.GetShapeToMesh() - - ## Returns the mesh, that is an instance of SMESH_Mesh interface - # @return a SMESH_Mesh object - # @ingroup l2_construct - def GetMesh(self): - return self.mesh - - ## Gets the name of the mesh - # @return the name of the mesh as a string - # @ingroup l2_construct - def GetName(self): - name = GetName(self.GetMesh()) - return name - - ## Sets a name to the mesh - # @param name a new name of the mesh - # @ingroup l2_construct - def SetName(self, name): - self.smeshpyD.SetName(self.GetMesh(), name) - - ## Gets the subMesh object associated to a \a theSubObject geometrical object. - # The subMesh object gives access to the IDs of nodes and elements. - # @param geom a geometrical object (shape) - # @param name a name for the submesh - # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape - # @ingroup l2_submeshes - def GetSubMesh(self, geom, name): - AssureGeomPublished( self, geom, name ) - submesh = self.mesh.GetSubMesh( geom, name ) - return submesh - - ## Returns the shape associated to the mesh - # @return a GEOM_Object - # @ingroup l2_construct - def GetShape(self): - return self.geom - - ## Associates the given shape to the mesh (entails the recreation of the mesh) - # @param geom the shape to be meshed (GEOM_Object) - # @ingroup l2_construct - def SetShape(self, geom): - self.mesh = self.smeshpyD.CreateMesh(geom) - - ## Loads mesh from the study after opening the study - def Load(self): - self.mesh.Load() - - ## Returns true if the hypotheses are defined well - # @param theSubObject a sub-shape of a mesh shape - # @return True or False - # @ingroup l2_construct - def IsReadyToCompute(self, theSubObject): - return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject) - - ## Returns errors of hypotheses definition. - # The list of errors is empty if everything is OK. - # @param theSubObject a sub-shape of a mesh shape - # @return a list of errors - # @ingroup l2_construct - def GetAlgoState(self, theSubObject): - return self.smeshpyD.GetAlgoState(self.mesh, theSubObject) - - ## Returns a geometrical object on which the given element was built. - # The returned geometrical object, if not nil, is either found in the - # study or published by this method with the given name - # @param theElementID the id of the mesh element - # @param theGeomName the user-defined name of the geometrical object - # @return GEOM::GEOM_Object instance - # @ingroup l2_construct - def GetGeometryByMeshElement(self, theElementID, theGeomName): - return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName ) - - ## Returns the mesh dimension depending on the dimension of the underlying shape - # or, if the mesh is not based on any shape, basing on deimension of elements - # @return mesh dimension as an integer value [0,3] - # @ingroup l1_auxiliary - def MeshDimension(self): - if self.mesh.HasShapeToMesh(): - shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SOLID"] ) - if len( shells ) > 0 : - return 3 - elif self.geompyD.NumberOfFaces( self.geom ) > 0 : - return 2 - elif self.geompyD.NumberOfEdges( self.geom ) > 0 : - return 1 - else: - return 0; - else: - if self.NbVolumes() > 0: return 3 - if self.NbFaces() > 0: return 2 - if self.NbEdges() > 0: return 1 - return 0 - - ## Evaluates size of prospective mesh on a shape - # @return a list where i-th element is a number of elements of i-th SMESH.EntityType - # To know predicted number of e.g. edges, inquire it this way - # Evaluate()[ EnumToLong( Entity_Edge )] - def Evaluate(self, geom=0): - if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object): - if self.geom == 0: - geom = self.mesh.GetShapeToMesh() - else: - geom = self.geom - return self.smeshpyD.Evaluate(self.mesh, geom) - - - ## Computes the mesh and returns the status of the computation - # @param geom geomtrical shape on which mesh data should be computed - # @param discardModifs if True and the mesh has been edited since - # a last total re-compute and that may prevent successful partial re-compute, - # then the mesh is cleaned before Compute() - # @return True or False - # @ingroup l2_construct - def Compute(self, geom=0, discardModifs=False): - if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object): - if self.geom == 0: - geom = self.mesh.GetShapeToMesh() - else: - geom = self.geom - ok = False - try: - if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693 - self.mesh.Clear() - ok = self.smeshpyD.Compute(self.mesh, geom) - except SALOME.SALOME_Exception, ex: - print "Mesh computation failed, exception caught:" - print " ", ex.details.text - except: - import traceback - print "Mesh computation failed, exception caught:" - traceback.print_exc() - if True:#not ok: - allReasons = "" - - # Treat compute errors - computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom ) - for err in computeErrors: - shapeText = "" - if self.mesh.HasShapeToMesh(): - try: - mainIOR = salome.orb.object_to_string(geom) - for sname in salome.myStudyManager.GetOpenStudies(): - s = salome.myStudyManager.GetStudyByName(sname) - if not s: continue - mainSO = s.FindObjectIOR(mainIOR) - if not mainSO: continue - if err.subShapeID == 1: - shapeText = ' on "%s"' % mainSO.GetName() - subIt = s.NewChildIterator(mainSO) - while subIt.More(): - subSO = subIt.Value() - subIt.Next() - obj = subSO.GetObject() - if not obj: continue - go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object ) - if not go: continue - ids = go.GetSubShapeIndices() - if len(ids) == 1 and ids[0] == err.subShapeID: - shapeText = ' on "%s"' % subSO.GetName() - break - if not shapeText: - shape = self.geompyD.GetSubShape( geom, [err.subShapeID]) - if shape: - shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID) - else: - shapeText = " on subshape #%s" % (err.subShapeID) - except: - shapeText = " on subshape #%s" % (err.subShapeID) - errText = "" - stdErrors = ["OK", #COMPERR_OK - "Invalid input mesh", #COMPERR_BAD_INPUT_MESH - "std::exception", #COMPERR_STD_EXCEPTION - "OCC exception", #COMPERR_OCC_EXCEPTION - "..", #COMPERR_SLM_EXCEPTION - "Unknown exception", #COMPERR_EXCEPTION - "Memory allocation problem", #COMPERR_MEMORY_PB - "Algorithm failed", #COMPERR_ALGO_FAILED - "Unexpected geometry", #COMPERR_BAD_SHAPE - "Warning", #COMPERR_WARNING - "Computation cancelled",#COMPERR_CANCELED - "No mesh on sub-shape"] #COMPERR_NO_MESH_ON_SHAPE - if err.code > 0: - if err.code < len(stdErrors): errText = stdErrors[err.code] - else: - errText = "code %s" % -err.code - if errText: errText += ". " - errText += err.comment - if allReasons != "":allReasons += "\n" - allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText) - pass - - # Treat hyp errors - errors = self.smeshpyD.GetAlgoState( self.mesh, geom ) - for err in errors: - if err.isGlobalAlgo: - glob = "global" - else: - glob = "local" - pass - dim = err.algoDim - name = err.algoName - if len(name) == 0: - reason = '%s %sD algorithm is missing' % (glob, dim) - elif err.state == HYP_MISSING: - reason = ('%s %sD algorithm "%s" misses %sD hypothesis' - % (glob, dim, name, dim)) - elif err.state == HYP_NOTCONFORM: - reason = 'Global "Not Conform mesh allowed" hypothesis is missing' - elif err.state == HYP_BAD_PARAMETER: - reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value' - % ( glob, dim, name )) - elif err.state == HYP_BAD_GEOMETRY: - reason = ('%s %sD algorithm "%s" is assigned to mismatching' - 'geometry' % ( glob, dim, name )) - elif err.state == HYP_HIDDEN_ALGO: - reason = ('%s %sD algorithm "%s" is ignored due to presence of a %s ' - 'algorithm of upper dimension generating %sD mesh' - % ( glob, dim, name, glob, dim )) - else: - reason = ("For unknown reason. " - "Developer, revise Mesh.Compute() implementation in smeshDC.py!") - pass - if allReasons != "":allReasons += "\n" - allReasons += "- " + reason - pass - if not ok or allReasons != "": - msg = '"' + GetName(self.mesh) + '"' - if ok: msg += " has been computed with warnings" - else: msg += " has not been computed" - if allReasons != "": msg += ":" - else: msg += "." - print msg - print allReasons - pass - if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0: - smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(self.mesh.GetStudyId()) - smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) ) - salome.sg.updateObjBrowser(1) - pass - return ok - - ## Return submesh objects list in meshing order - # @return list of list of submesh objects - # @ingroup l2_construct - def GetMeshOrder(self): - return self.mesh.GetMeshOrder() - - ## Return submesh objects list in meshing order - # @return list of list of submesh objects - # @ingroup l2_construct - def SetMeshOrder(self, submeshes): - return self.mesh.SetMeshOrder(submeshes) - - ## Removes all nodes and elements - # @ingroup l2_construct - def Clear(self): - self.mesh.Clear() - if ( salome.sg.hasDesktop() and - salome.myStudyManager.GetStudyByID( self.mesh.GetStudyId() )): - smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(self.mesh.GetStudyId()) - smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - salome.sg.updateObjBrowser(1) - - ## Removes all nodes and elements of indicated shape - # @ingroup l2_construct - def ClearSubMesh(self, geomId): - self.mesh.ClearSubMesh(geomId) - if salome.sg.hasDesktop(): - smeshgui = salome.ImportComponentGUI("SMESH") - smeshgui.Init(self.mesh.GetStudyId()) - smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) - salome.sg.updateObjBrowser(1) - - ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN - # @param fineness [0.0,1.0] defines mesh fineness - # @return True or False - # @ingroup l3_algos_basic - def AutomaticTetrahedralization(self, fineness=0): - dim = self.MeshDimension() - # assign hypotheses - self.RemoveGlobalHypotheses() - self.Segment().AutomaticLength(fineness) - if dim > 1 : - self.Triangle().LengthFromEdges() - pass - if dim > 2 : - from NETGENPluginDC import NETGEN - self.Tetrahedron(NETGEN) - pass - return self.Compute() - - ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron - # @param fineness [0.0, 1.0] defines mesh fineness - # @return True or False - # @ingroup l3_algos_basic - def AutomaticHexahedralization(self, fineness=0): - dim = self.MeshDimension() - # assign the hypotheses - self.RemoveGlobalHypotheses() - self.Segment().AutomaticLength(fineness) - if dim > 1 : - self.Quadrangle() - pass - if dim > 2 : - self.Hexahedron() - pass - return self.Compute() - - ## Assigns a hypothesis - # @param hyp a hypothesis to assign - # @param geom a subhape of mesh geometry - # @return SMESH.Hypothesis_Status - # @ingroup l2_hypotheses - def AddHypothesis(self, hyp, geom=0): - if isinstance( hyp, Mesh_Algorithm ): - hyp = hyp.GetAlgorithm() - pass - if not geom: - geom = self.geom - if not geom: - geom = self.mesh.GetShapeToMesh() - pass - AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName()) - status = self.mesh.AddHypothesis(geom, hyp) - isAlgo = hyp._narrow( SMESH_Algo ) - hyp_name = GetName( hyp ) - geom_name = "" - if geom: - geom_name = GetName( geom ) - TreatHypoStatus( status, hyp_name, geom_name, isAlgo ) - return status - - ## Return True if an algorithm of hypothesis is assigned to a given shape - # @param hyp a hypothesis to check - # @param geom a subhape of mesh geometry - # @return True of False - # @ingroup l2_hypotheses - def IsUsedHypothesis(self, hyp, geom): - if not hyp: # or not geom - return False - if isinstance( hyp, Mesh_Algorithm ): - hyp = hyp.GetAlgorithm() - pass - hyps = self.GetHypothesisList(geom) - for h in hyps: - if h.GetId() == hyp.GetId(): - return True - return False - - ## Unassigns a hypothesis - # @param hyp a hypothesis to unassign - # @param geom a sub-shape of mesh geometry - # @return SMESH.Hypothesis_Status - # @ingroup l2_hypotheses - def RemoveHypothesis(self, hyp, geom=0): - if isinstance( hyp, Mesh_Algorithm ): - hyp = hyp.GetAlgorithm() - pass - shape = geom - if not shape: - shape = self.geom - pass - if self.IsUsedHypothesis( hyp, shape ): - return self.mesh.RemoveHypothesis( shape, hyp ) - hypName = GetName( hyp ) - geoName = GetName( shape ) - print "WARNING: RemoveHypothesis() failed as '%s' is not assigned to '%s' shape" % ( hypName, geoName ) - return None - - ## Gets the list of hypotheses added on a geometry - # @param geom a sub-shape of mesh geometry - # @return the sequence of SMESH_Hypothesis - # @ingroup l2_hypotheses - def GetHypothesisList(self, geom): - return self.mesh.GetHypothesisList( geom ) - - ## Removes all global hypotheses - # @ingroup l2_hypotheses - def RemoveGlobalHypotheses(self): - current_hyps = self.mesh.GetHypothesisList( self.geom ) - for hyp in current_hyps: - self.mesh.RemoveHypothesis( self.geom, hyp ) - pass - pass - - ## Exports the mesh in a file in MED format and chooses the \a version of MED format - ## allowing to overwrite the file if it exists or add the exported data to its contents - # @param f is the file name - # @param auto_groups boolean parameter for creating/not creating - # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; - # the typical use is auto_groups=false. - # @param version MED format version(MED_V2_1 or MED_V2_2) - # @param overwrite boolean parameter for overwriting/not overwriting the file - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None): - if meshPart: - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite ) - else: - self.mesh.ExportToMEDX(f, auto_groups, version, overwrite) - - ## Exports the mesh in a file in SAUV format - # @param f is the file name - # @param auto_groups boolean parameter for creating/not creating - # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; - # the typical use is auto_groups=false. - # @ingroup l2_impexp - def ExportSAUV(self, f, auto_groups=0): - self.mesh.ExportSAUV(f, auto_groups) - - ## Exports the mesh in a file in DAT format - # @param f the file name - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportDAT(self, f, meshPart=None): - if meshPart: - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - self.mesh.ExportPartToDAT( meshPart, f ) - else: - self.mesh.ExportDAT(f) - - ## Exports the mesh in a file in UNV format - # @param f the file name - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportUNV(self, f, meshPart=None): - if meshPart: - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - self.mesh.ExportPartToUNV( meshPart, f ) - else: - self.mesh.ExportUNV(f) - - ## Export the mesh in a file in STL format - # @param f the file name - # @param ascii defines the file encoding - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportSTL(self, f, ascii=1, meshPart=None): - if meshPart: - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - self.mesh.ExportPartToSTL( meshPart, f, ascii ) - else: - self.mesh.ExportSTL(f, ascii) - - ## Exports the mesh in a file in CGNS format - # @param f is the file name - # @param overwrite boolean parameter for overwriting/not overwriting the file - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportCGNS(self, f, overwrite=1, meshPart=None): - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - if isinstance( meshPart, Mesh ): - meshPart = meshPart.mesh - elif not meshPart: - meshPart = self.mesh - self.mesh.ExportCGNS(meshPart, f, overwrite) - - ## Exports the mesh in a file in GMF format - # @param f is the file name - # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh - # @ingroup l2_impexp - def ExportGMF(self, f, meshPart=None): - if isinstance( meshPart, list ): - meshPart = self.GetIDSource( meshPart, SMESH.ALL ) - if isinstance( meshPart, Mesh ): - meshPart = meshPart.mesh - elif not meshPart: - meshPart = self.mesh - self.mesh.ExportGMF(meshPart, f, True) - - ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead. - # Exports the mesh in a file in MED format and chooses the \a version of MED format - ## allowing to overwrite the file if it exists or add the exported data to its contents - # @param f the file name - # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2 - # @param opt boolean parameter for creating/not creating - # the groups Group_On_All_Nodes, Group_On_All_Faces, ... - # @param overwrite boolean parameter for overwriting/not overwriting the file - # @ingroup l2_impexp - def ExportToMED(self, f, version, opt=0, overwrite=1): - self.mesh.ExportToMEDX(f, opt, version, overwrite) - - # Operations with groups: - # ---------------------- - - ## Creates an empty mesh group - # @param elementType the type of elements in the group - # @param name the name of the mesh group - # @return SMESH_Group - # @ingroup l2_grps_create - def CreateEmptyGroup(self, elementType, name): - return self.mesh.CreateGroup(elementType, name) - - ## Creates a mesh group based on the geometric object \a grp - # and gives a \a name, \n if this parameter is not defined - # the name is the same as the geometric group name \n - # Note: Works like GroupOnGeom(). - # @param grp a geometric group, a vertex, an edge, a face or a solid - # @param name the name of the mesh group - # @return SMESH_GroupOnGeom - # @ingroup l2_grps_create - def Group(self, grp, name=""): - return self.GroupOnGeom(grp, name) - - ## Creates a mesh group based on the geometrical object \a grp - # and gives a \a name, \n if this parameter is not defined - # the name is the same as the geometrical group name - # @param grp a geometrical group, a vertex, an edge, a face or a solid - # @param name the name of the mesh group - # @param typ the type of elements in the group. If not set, it is - # automatically detected by the type of the geometry - # @return SMESH_GroupOnGeom - # @ingroup l2_grps_create - def GroupOnGeom(self, grp, name="", typ=None): - AssureGeomPublished( self, grp, name ) - if name == "": - name = grp.GetName() - if not typ: - typ = self._groupTypeFromShape( grp ) - return self.mesh.CreateGroupFromGEOM(typ, name, grp) - - ## Pivate method to get a type of group on geometry - def _groupTypeFromShape( self, shape ): - tgeo = str(shape.GetShapeType()) - if tgeo == "VERTEX": - typ = NODE - elif tgeo == "EDGE": - typ = EDGE - elif tgeo == "FACE" or tgeo == "SHELL": - typ = FACE - elif tgeo == "SOLID" or tgeo == "COMPSOLID": - typ = VOLUME - elif tgeo == "COMPOUND": - sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"]) - if not sub: - raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape) - return self._groupTypeFromShape( sub[0] ) - else: - raise ValueError, \ - "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape) - return typ - - ## Creates a mesh group with given \a name based on the \a filter which - ## is a special type of group dynamically updating it's contents during - ## mesh modification - # @param typ the type of elements in the group - # @param name the name of the mesh group - # @param filter the filter defining group contents - # @return SMESH_GroupOnFilter - # @ingroup l2_grps_create - def GroupOnFilter(self, typ, name, filter): - return self.mesh.CreateGroupFromFilter(typ, name, filter) - - ## Creates a mesh group by the given ids of elements - # @param groupName the name of the mesh group - # @param elementType the type of elements in the group - # @param elemIDs the list of ids - # @return SMESH_Group - # @ingroup l2_grps_create - def MakeGroupByIds(self, groupName, elementType, elemIDs): - group = self.mesh.CreateGroup(elementType, groupName) - group.Add(elemIDs) - return group - - ## Creates a mesh group by the given conditions - # @param groupName the name of the mesh group - # @param elementType the type of elements in the group - # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. ) - # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo} - # @param Threshold the threshold value (range of id ids as string, shape, numeric) - # @param UnaryOp FT_LogicalNOT or FT_Undefined - # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface, - # FT_LyingOnGeom, FT_CoplanarFaces criteria - # @return SMESH_Group - # @ingroup l2_grps_create - def MakeGroup(self, - groupName, - elementType, - CritType=FT_Undefined, - Compare=FT_EqualTo, - Threshold="", - UnaryOp=FT_Undefined, - Tolerance=1e-07): - aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance) - group = self.MakeGroupByCriterion(groupName, aCriterion) - return group - - ## Creates a mesh group by the given criterion - # @param groupName the name of the mesh group - # @param Criterion the instance of Criterion class - # @return SMESH_Group - # @ingroup l2_grps_create - def MakeGroupByCriterion(self, groupName, Criterion): - aFilterMgr = self.smeshpyD.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - aCriteria = [] - aCriteria.append(Criterion) - aFilter.SetCriteria(aCriteria) - group = self.MakeGroupByFilter(groupName, aFilter) - aFilterMgr.UnRegister() - return group - - ## Creates a mesh group by the given criteria (list of criteria) - # @param groupName the name of the mesh group - # @param theCriteria the list of criteria - # @return SMESH_Group - # @ingroup l2_grps_create - def MakeGroupByCriteria(self, groupName, theCriteria): - aFilterMgr = self.smeshpyD.CreateFilterManager() - aFilter = aFilterMgr.CreateFilter() - aFilter.SetCriteria(theCriteria) - group = self.MakeGroupByFilter(groupName, aFilter) - aFilterMgr.UnRegister() - return group - - ## Creates a mesh group by the given filter - # @param groupName the name of the mesh group - # @param theFilter the instance of Filter class - # @return SMESH_Group - # @ingroup l2_grps_create - def MakeGroupByFilter(self, groupName, theFilter): - group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName) - theFilter.SetMesh( self.mesh ) - group.AddFrom( theFilter ) - return group - - ## Removes a group - # @ingroup l2_grps_delete - def RemoveGroup(self, group): - self.mesh.RemoveGroup(group) - - ## Removes a group with its contents - # @ingroup l2_grps_delete - def RemoveGroupWithContents(self, group): - self.mesh.RemoveGroupWithContents(group) - - ## Gets the list of groups existing in the mesh - # @return a sequence of SMESH_GroupBase - # @ingroup l2_grps_create - def GetGroups(self): - return self.mesh.GetGroups() - - ## Gets the number of groups existing in the mesh - # @return the quantity of groups as an integer value - # @ingroup l2_grps_create - def NbGroups(self): - return self.mesh.NbGroups() - - ## Gets the list of names of groups existing in the mesh - # @return list of strings - # @ingroup l2_grps_create - def GetGroupNames(self): - groups = self.GetGroups() - names = [] - for group in groups: - names.append(group.GetName()) - return names - - ## Produces a union of two groups - # A new group is created. All mesh elements that are - # present in the initial groups are added to the new one - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def UnionGroups(self, group1, group2, name): - return self.mesh.UnionGroups(group1, group2, name) - - ## Produces a union list of groups - # New group is created. All mesh elements that are present in - # initial groups are added to the new one - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def UnionListOfGroups(self, groups, name): - return self.mesh.UnionListOfGroups(groups, name) - - ## Prodices an intersection of two groups - # A new group is created. All mesh elements that are common - # for the two initial groups are added to the new one. - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def IntersectGroups(self, group1, group2, name): - return self.mesh.IntersectGroups(group1, group2, name) - - ## Produces an intersection of groups - # New group is created. All mesh elements that are present in all - # initial groups simultaneously are added to the new one - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def IntersectListOfGroups(self, groups, name): - return self.mesh.IntersectListOfGroups(groups, name) - - ## Produces a cut of two groups - # A new group is created. All mesh elements that are present in - # the main group but are not present in the tool group are added to the new one - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def CutGroups(self, main_group, tool_group, name): - return self.mesh.CutGroups(main_group, tool_group, name) - - ## Produces a cut of groups - # A new group is created. All mesh elements that are present in main groups - # but do not present in tool groups are added to the new one - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def CutListOfGroups(self, main_groups, tool_groups, name): - return self.mesh.CutListOfGroups(main_groups, tool_groups, name) - - ## Produces a group of elements of specified type using list of existing groups - # A new group is created. System - # 1) extracts all nodes on which groups elements are built - # 2) combines all elements of specified dimension laying on these nodes - # @return an instance of SMESH_Group - # @ingroup l2_grps_operon - def CreateDimGroup(self, groups, elem_type, name): - return self.mesh.CreateDimGroup(groups, elem_type, name) - - - ## Convert group on geom into standalone group - # @ingroup l2_grps_delete - def ConvertToStandalone(self, group): - return self.mesh.ConvertToStandalone(group) - - # Get some info about mesh: - # ------------------------ - - ## Returns the log of nodes and elements added or removed - # since the previous clear of the log. - # @param clearAfterGet log is emptied after Get (safe if concurrents access) - # @return list of log_block structures: - # commandType - # number - # coords - # indexes - # @ingroup l1_auxiliary - def GetLog(self, clearAfterGet): - return self.mesh.GetLog(clearAfterGet) - - ## Clears the log of nodes and elements added or removed since the previous - # clear. Must be used immediately after GetLog if clearAfterGet is false. - # @ingroup l1_auxiliary - def ClearLog(self): - self.mesh.ClearLog() - - ## Toggles auto color mode on the object. - # @param theAutoColor the flag which toggles auto color mode. - # @ingroup l1_auxiliary - def SetAutoColor(self, theAutoColor): - self.mesh.SetAutoColor(theAutoColor) - - ## Gets flag of object auto color mode. - # @return True or False - # @ingroup l1_auxiliary - def GetAutoColor(self): - return self.mesh.GetAutoColor() - - ## Gets the internal ID - # @return integer value, which is the internal Id of the mesh - # @ingroup l1_auxiliary - def GetId(self): - return self.mesh.GetId() - - ## Get the study Id - # @return integer value, which is the study Id of the mesh - # @ingroup l1_auxiliary - def GetStudyId(self): - return self.mesh.GetStudyId() - - ## Checks the group names for duplications. - # Consider the maximum group name length stored in MED file. - # @return True or False - # @ingroup l1_auxiliary - def HasDuplicatedGroupNamesMED(self): - return self.mesh.HasDuplicatedGroupNamesMED() - - ## Obtains the mesh editor tool - # @return an instance of SMESH_MeshEditor - # @ingroup l1_modifying - def GetMeshEditor(self): - return self.editor - - ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which - # can be passed as argument to a method accepting mesh, group or sub-mesh - # @return an instance of SMESH_IDSource - # @ingroup l1_auxiliary - def GetIDSource(self, ids, elemType): - return self.editor.MakeIDSource(ids, elemType) - - ## Gets MED Mesh - # @return an instance of SALOME_MED::MESH - # @ingroup l1_auxiliary - def GetMEDMesh(self): - return self.mesh.GetMEDMesh() - - - # Get informations about mesh contents: - # ------------------------------------ - - ## Gets the mesh stattistic - # @return dictionary type element - count of elements - # @ingroup l1_meshinfo - def GetMeshInfo(self, obj = None): - if not obj: obj = self.mesh - return self.smeshpyD.GetMeshInfo(obj) - - ## Returns the number of nodes in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbNodes(self): - return self.mesh.NbNodes() - - ## Returns the number of elements in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbElements(self): - return self.mesh.NbElements() - - ## Returns the number of 0d elements in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def Nb0DElements(self): - return self.mesh.Nb0DElements() - - ## Returns the number of ball discrete elements in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbBalls(self): - return self.mesh.NbBalls() - - ## Returns the number of edges in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbEdges(self): - return self.mesh.NbEdges() - - ## Returns the number of edges with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbEdgesOfOrder(self, elementOrder): - return self.mesh.NbEdgesOfOrder(elementOrder) - - ## Returns the number of faces in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbFaces(self): - return self.mesh.NbFaces() - - ## Returns the number of faces with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbFacesOfOrder(self, elementOrder): - return self.mesh.NbFacesOfOrder(elementOrder) - - ## Returns the number of triangles in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbTriangles(self): - return self.mesh.NbTriangles() - - ## Returns the number of triangles with the given order in the mesh - # @param elementOrder is the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbTrianglesOfOrder(self, elementOrder): - return self.mesh.NbTrianglesOfOrder(elementOrder) - - ## Returns the number of quadrangles in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbQuadrangles(self): - return self.mesh.NbQuadrangles() - - ## Returns the number of quadrangles with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbQuadranglesOfOrder(self, elementOrder): - return self.mesh.NbQuadranglesOfOrder(elementOrder) - - ## Returns the number of biquadratic quadrangles in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbBiQuadQuadrangles(self): - return self.mesh.NbBiQuadQuadrangles() - - ## Returns the number of polygons in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbPolygons(self): - return self.mesh.NbPolygons() - - ## Returns the number of volumes in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbVolumes(self): - return self.mesh.NbVolumes() - - ## Returns the number of volumes with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbVolumesOfOrder(self, elementOrder): - return self.mesh.NbVolumesOfOrder(elementOrder) - - ## Returns the number of tetrahedrons in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbTetras(self): - return self.mesh.NbTetras() - - ## Returns the number of tetrahedrons with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbTetrasOfOrder(self, elementOrder): - return self.mesh.NbTetrasOfOrder(elementOrder) - - ## Returns the number of hexahedrons in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbHexas(self): - return self.mesh.NbHexas() - - ## Returns the number of hexahedrons with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbHexasOfOrder(self, elementOrder): - return self.mesh.NbHexasOfOrder(elementOrder) - - ## Returns the number of triquadratic hexahedrons in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbTriQuadraticHexas(self): - return self.mesh.NbTriQuadraticHexas() - - ## Returns the number of pyramids in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbPyramids(self): - return self.mesh.NbPyramids() - - ## Returns the number of pyramids with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbPyramidsOfOrder(self, elementOrder): - return self.mesh.NbPyramidsOfOrder(elementOrder) - - ## Returns the number of prisms in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbPrisms(self): - return self.mesh.NbPrisms() - - ## Returns the number of prisms with the given order in the mesh - # @param elementOrder the order of elements: - # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC - # @return an integer value - # @ingroup l1_meshinfo - def NbPrismsOfOrder(self, elementOrder): - return self.mesh.NbPrismsOfOrder(elementOrder) - - ## Returns the number of hexagonal prisms in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbHexagonalPrisms(self): - return self.mesh.NbHexagonalPrisms() - - ## Returns the number of polyhedrons in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbPolyhedrons(self): - return self.mesh.NbPolyhedrons() - - ## Returns the number of submeshes in the mesh - # @return an integer value - # @ingroup l1_meshinfo - def NbSubMesh(self): - return self.mesh.NbSubMesh() - - ## Returns the list of mesh elements IDs - # @return the list of integer values - # @ingroup l1_meshinfo - def GetElementsId(self): - return self.mesh.GetElementsId() - - ## Returns the list of IDs of mesh elements with the given type - # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME) - # @return list of integer values - # @ingroup l1_meshinfo - def GetElementsByType(self, elementType): - return self.mesh.GetElementsByType(elementType) - - ## Returns the list of mesh nodes IDs - # @return the list of integer values - # @ingroup l1_meshinfo - def GetNodesId(self): - return self.mesh.GetNodesId() - - # Get the information about mesh elements: - # ------------------------------------ - - ## Returns the type of mesh element - # @return the value from SMESH::ElementType enumeration - # @ingroup l1_meshinfo - def GetElementType(self, id, iselem): - return self.mesh.GetElementType(id, iselem) - - ## Returns the geometric type of mesh element - # @return the value from SMESH::EntityType enumeration - # @ingroup l1_meshinfo - def GetElementGeomType(self, id): - return self.mesh.GetElementGeomType(id) - - ## Returns the list of submesh elements IDs - # @param Shape a geom object(sub-shape) IOR - # Shape must be the sub-shape of a ShapeToMesh() - # @return the list of integer values - # @ingroup l1_meshinfo - def GetSubMeshElementsId(self, Shape): - if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)): - ShapeID = Shape.GetSubShapeIndices()[0] - else: - ShapeID = Shape - return self.mesh.GetSubMeshElementsId(ShapeID) - - ## Returns the list of submesh nodes IDs - # @param Shape a geom object(sub-shape) IOR - # Shape must be the sub-shape of a ShapeToMesh() - # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes - # @return the list of integer values - # @ingroup l1_meshinfo - def GetSubMeshNodesId(self, Shape, all): - if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)): - ShapeID = self.geompyD.GetSubShapeID( self.geom, Shape ) - else: - ShapeID = Shape - return self.mesh.GetSubMeshNodesId(ShapeID, all) - - ## Returns type of elements on given shape - # @param Shape a geom object(sub-shape) IOR - # Shape must be a sub-shape of a ShapeToMesh() - # @return element type - # @ingroup l1_meshinfo - def GetSubMeshElementType(self, Shape): - if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)): - ShapeID = Shape.GetSubShapeIndices()[0] - else: - ShapeID = Shape - return self.mesh.GetSubMeshElementType(ShapeID) - - ## Gets the mesh description - # @return string value - # @ingroup l1_meshinfo - def Dump(self): - return self.mesh.Dump() - - - # Get the information about nodes and elements of a mesh by its IDs: - # ----------------------------------------------------------- - - ## Gets XYZ coordinates of a node - # \n If there is no nodes for the given ID - returns an empty list - # @return a list of double precision values - # @ingroup l1_meshinfo - def GetNodeXYZ(self, id): - return self.mesh.GetNodeXYZ(id) - - ## Returns list of IDs of inverse elements for the given node - # \n If there is no node for the given ID - returns an empty list - # @return a list of integer values - # @ingroup l1_meshinfo - def GetNodeInverseElements(self, id): - return self.mesh.GetNodeInverseElements(id) - - ## @brief Returns the position of a node on the shape - # @return SMESH::NodePosition - # @ingroup l1_meshinfo - def GetNodePosition(self,NodeID): - return self.mesh.GetNodePosition(NodeID) - - ## @brief Returns the position of an element on the shape - # @return SMESH::ElementPosition - # @ingroup l1_meshinfo - def GetElementPosition(self,ElemID): - return self.mesh.GetElementPosition(ElemID) - - ## If the given element is a node, returns the ID of shape - # \n If there is no node for the given ID - returns -1 - # @return an integer value - # @ingroup l1_meshinfo - def GetShapeID(self, id): - return self.mesh.GetShapeID(id) - - ## Returns the ID of the result shape after - # FindShape() from SMESH_MeshEditor for the given element - # \n If there is no element for the given ID - returns -1 - # @return an integer value - # @ingroup l1_meshinfo - def GetShapeIDForElem(self,id): - return self.mesh.GetShapeIDForElem(id) - - ## Returns the number of nodes for the given element - # \n If there is no element for the given ID - returns -1 - # @return an integer value - # @ingroup l1_meshinfo - def GetElemNbNodes(self, id): - return self.mesh.GetElemNbNodes(id) - - ## Returns the node ID the given (zero based) index for the given element - # \n If there is no element for the given ID - returns -1 - # \n If there is no node for the given index - returns -2 - # @return an integer value - # @ingroup l1_meshinfo - def GetElemNode(self, id, index): - return self.mesh.GetElemNode(id, index) - - ## Returns the IDs of nodes of the given element - # @return a list of integer values - # @ingroup l1_meshinfo - def GetElemNodes(self, id): - return self.mesh.GetElemNodes(id) - - ## Returns true if the given node is the medium node in the given quadratic element - # @ingroup l1_meshinfo - def IsMediumNode(self, elementID, nodeID): - return self.mesh.IsMediumNode(elementID, nodeID) - - ## Returns true if the given node is the medium node in one of quadratic elements - # @ingroup l1_meshinfo - def IsMediumNodeOfAnyElem(self, nodeID, elementType): - return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType) - - ## Returns the number of edges for the given element - # @ingroup l1_meshinfo - def ElemNbEdges(self, id): - return self.mesh.ElemNbEdges(id) - - ## Returns the number of faces for the given element - # @ingroup l1_meshinfo - def ElemNbFaces(self, id): - return self.mesh.ElemNbFaces(id) - - ## Returns nodes of given face (counted from zero) for given volumic element. - # @ingroup l1_meshinfo - def GetElemFaceNodes(self,elemId, faceIndex): - return self.mesh.GetElemFaceNodes(elemId, faceIndex) - - ## Returns an element based on all given nodes. - # @ingroup l1_meshinfo - def FindElementByNodes(self,nodes): - return self.mesh.FindElementByNodes(nodes) - - ## Returns true if the given element is a polygon - # @ingroup l1_meshinfo - def IsPoly(self, id): - return self.mesh.IsPoly(id) - - ## Returns true if the given element is quadratic - # @ingroup l1_meshinfo - def IsQuadratic(self, id): - return self.mesh.IsQuadratic(id) - - ## Returns diameter of a ball discrete element or zero in case of an invalid \a id - # @ingroup l1_meshinfo - def GetBallDiameter(self, id): - return self.mesh.GetBallDiameter(id) - - ## Returns XYZ coordinates of the barycenter of the given element - # \n If there is no element for the given ID - returns an empty list - # @return a list of three double values - # @ingroup l1_meshinfo - def BaryCenter(self, id): - return self.mesh.BaryCenter(id) - - ## Passes mesh elements through the given filter and return IDs of fitting elements - # @param theFilter SMESH_Filter - # @return a list of ids - # @ingroup l1_controls - def GetIdsFromFilter(self, theFilter): - theFilter.SetMesh( self.mesh ) - return theFilter.GetIDs() - - ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n - # Returns a list of special structures (borders). - # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes. - # @ingroup l1_controls - def GetFreeBorders(self): - aFilterMgr = self.smeshpyD.CreateFilterManager() - aPredicate = aFilterMgr.CreateFreeEdges() - aPredicate.SetMesh(self.mesh) - aBorders = aPredicate.GetBorders() - aFilterMgr.UnRegister() - return aBorders - - - # Get mesh measurements information: - # ------------------------------------ - - ## Get minimum distance between two nodes, elements or distance to the origin - # @param id1 first node/element id - # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed) - # @param isElem1 @c True if @a id1 is element id, @c False if it is node id - # @param isElem2 @c True if @a id2 is element id, @c False if it is node id - # @return minimum distance value - # @sa GetMinDistance() - def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False): - aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2) - return aMeasure.value - - ## Get measure structure specifying minimum distance data between two objects - # @param id1 first node/element id - # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed) - # @param isElem1 @c True if @a id1 is element id, @c False if it is node id - # @param isElem2 @c True if @a id2 is element id, @c False if it is node id - # @return Measure structure - # @sa MinDistance() - def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False): - if isElem1: - id1 = self.editor.MakeIDSource([id1], SMESH.FACE) - else: - id1 = self.editor.MakeIDSource([id1], SMESH.NODE) - if id2 != 0: - if isElem2: - id2 = self.editor.MakeIDSource([id2], SMESH.FACE) - else: - id2 = self.editor.MakeIDSource([id2], SMESH.NODE) - pass - else: - id2 = None - - aMeasurements = self.smeshpyD.CreateMeasurements() - aMeasure = aMeasurements.MinDistance(id1, id2) - aMeasurements.UnRegister() - return aMeasure - - ## Get bounding box of the specified object(s) - # @param objects single source object or list of source objects or list of nodes/elements IDs - # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements, - # @c False specifies that @a objects are nodes - # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ) - # @sa GetBoundingBox() - def BoundingBox(self, objects=None, isElem=False): - result = self.GetBoundingBox(objects, isElem) - if result is None: - result = (0.0,)*6 - else: - result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ) - return result - - ## Get measure structure specifying bounding box data of the specified object(s) - # @param IDs single source object or list of source objects or list of nodes/elements IDs - # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements, - # @c False specifies that @a objects are nodes - # @return Measure structure - # @sa BoundingBox() - def GetBoundingBox(self, IDs=None, isElem=False): - if IDs is None: - IDs = [self.mesh] - elif isinstance(IDs, tuple): - IDs = list(IDs) - if not isinstance(IDs, list): - IDs = [IDs] - if len(IDs) > 0 and isinstance(IDs[0], int): - IDs = [IDs] - srclist = [] - for o in IDs: - if isinstance(o, Mesh): - srclist.append(o.mesh) - elif hasattr(o, "_narrow"): - src = o._narrow(SMESH.SMESH_IDSource) - if src: srclist.append(src) - pass - elif isinstance(o, list): - if isElem: - srclist.append(self.editor.MakeIDSource(o, SMESH.FACE)) - else: - srclist.append(self.editor.MakeIDSource(o, SMESH.NODE)) - pass - pass - aMeasurements = self.smeshpyD.CreateMeasurements() - aMeasure = aMeasurements.BoundingBox(srclist) - aMeasurements.UnRegister() - return aMeasure - - # Mesh edition (SMESH_MeshEditor functionality): - # --------------------------------------------- - - ## Removes the elements from the mesh by ids - # @param IDsOfElements is a list of ids of elements to remove - # @return True or False - # @ingroup l2_modif_del - def RemoveElements(self, IDsOfElements): - return self.editor.RemoveElements(IDsOfElements) - - ## Removes nodes from mesh by ids - # @param IDsOfNodes is a list of ids of nodes to remove - # @return True or False - # @ingroup l2_modif_del - def RemoveNodes(self, IDsOfNodes): - return self.editor.RemoveNodes(IDsOfNodes) - - ## Removes all orphan (free) nodes from mesh - # @return number of the removed nodes - # @ingroup l2_modif_del - def RemoveOrphanNodes(self): - return self.editor.RemoveOrphanNodes() - - ## Add a node to the mesh by coordinates - # @return Id of the new node - # @ingroup l2_modif_add - def AddNode(self, x, y, z): - x,y,z,Parameters,hasVars = ParseParameters(x,y,z) - if hasVars: self.mesh.SetParameters(Parameters) - return self.editor.AddNode( x, y, z) - - ## Creates a 0D element on a node with given number. - # @param IDOfNode the ID of node for creation of the element. - # @return the Id of the new 0D element - # @ingroup l2_modif_add - def Add0DElement(self, IDOfNode): - return self.editor.Add0DElement(IDOfNode) - - ## Create 0D elements on all nodes of the given elements except those - # nodes on which a 0D element already exists. - # @param theObject an object on whose nodes 0D elements will be created. - # It can be mesh, sub-mesh, group, list of element IDs or a holder - # of nodes IDs created by calling mesh.GetIDSource( nodes, SMESH.NODE ) - # @param theGroupName optional name of a group to add 0D elements created - # and/or found on nodes of \a theObject. - # @return an object (a new group or a temporary SMESH_IDSource) holding - # IDs of new and/or found 0D elements. IDs of 0D elements - # can be retrieved from the returned object by calling GetIDs() - # @ingroup l2_modif_add - def Add0DElementsToAllNodes(self, theObject, theGroupName=""): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( theObject, list ): - theObject = self.GetIDSource( theObject, SMESH.ALL ) - return self.editor.Create0DElementsOnAllNodes( theObject, theGroupName ) - - ## Creates a ball element on a node with given ID. - # @param IDOfNode the ID of node for creation of the element. - # @param diameter the bal diameter. - # @return the Id of the new ball element - # @ingroup l2_modif_add - def AddBall(self, IDOfNode, diameter): - return self.editor.AddBall( IDOfNode, diameter ) - - ## Creates a linear or quadratic edge (this is determined - # by the number of given nodes). - # @param IDsOfNodes the list of node IDs for creation of the element. - # The order of nodes in this list should correspond to the description - # of MED. \n This description is located by the following link: - # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. - # @return the Id of the new edge - # @ingroup l2_modif_add - def AddEdge(self, IDsOfNodes): - return self.editor.AddEdge(IDsOfNodes) - - ## Creates a linear or quadratic face (this is determined - # by the number of given nodes). - # @param IDsOfNodes the list of node IDs for creation of the element. - # The order of nodes in this list should correspond to the description - # of MED. \n This description is located by the following link: - # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. - # @return the Id of the new face - # @ingroup l2_modif_add - def AddFace(self, IDsOfNodes): - return self.editor.AddFace(IDsOfNodes) - - ## Adds a polygonal face to the mesh by the list of node IDs - # @param IdsOfNodes the list of node IDs for creation of the element. - # @return the Id of the new face - # @ingroup l2_modif_add - def AddPolygonalFace(self, IdsOfNodes): - return self.editor.AddPolygonalFace(IdsOfNodes) - - ## Creates both simple and quadratic volume (this is determined - # by the number of given nodes). - # @param IDsOfNodes the list of node IDs for creation of the element. - # The order of nodes in this list should correspond to the description - # of MED. \n This description is located by the following link: - # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3. - # @return the Id of the new volumic element - # @ingroup l2_modif_add - def AddVolume(self, IDsOfNodes): - return self.editor.AddVolume(IDsOfNodes) - - ## Creates a volume of many faces, giving nodes for each face. - # @param IdsOfNodes the list of node IDs for volume creation face by face. - # @param Quantities the list of integer values, Quantities[i] - # gives the quantity of nodes in face number i. - # @return the Id of the new volumic element - # @ingroup l2_modif_add - def AddPolyhedralVolume (self, IdsOfNodes, Quantities): - return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities) - - ## Creates a volume of many faces, giving the IDs of the existing faces. - # @param IdsOfFaces the list of face IDs for volume creation. - # - # Note: The created volume will refer only to the nodes - # of the given faces, not to the faces themselves. - # @return the Id of the new volumic element - # @ingroup l2_modif_add - def AddPolyhedralVolumeByFaces (self, IdsOfFaces): - return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces) - - - ## @brief Binds a node to a vertex - # @param NodeID a node ID - # @param Vertex a vertex or vertex ID - # @return True if succeed else raises an exception - # @ingroup l2_modif_add - def SetNodeOnVertex(self, NodeID, Vertex): - if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)): - VertexID = Vertex.GetSubShapeIndices()[0] - else: - VertexID = Vertex - try: - self.editor.SetNodeOnVertex(NodeID, VertexID) - except SALOME.SALOME_Exception, inst: - raise ValueError, inst.details.text - return True - - - ## @brief Stores the node position on an edge - # @param NodeID a node ID - # @param Edge an edge or edge ID - # @param paramOnEdge a parameter on the edge where the node is located - # @return True if succeed else raises an exception - # @ingroup l2_modif_add - def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge): - if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)): - EdgeID = Edge.GetSubShapeIndices()[0] - else: - EdgeID = Edge - try: - self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge) - except SALOME.SALOME_Exception, inst: - raise ValueError, inst.details.text - return True - - ## @brief Stores node position on a face - # @param NodeID a node ID - # @param Face a face or face ID - # @param u U parameter on the face where the node is located - # @param v V parameter on the face where the node is located - # @return True if succeed else raises an exception - # @ingroup l2_modif_add - def SetNodeOnFace(self, NodeID, Face, u, v): - if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)): - FaceID = Face.GetSubShapeIndices()[0] - else: - FaceID = Face - try: - self.editor.SetNodeOnFace(NodeID, FaceID, u, v) - except SALOME.SALOME_Exception, inst: - raise ValueError, inst.details.text - return True - - ## @brief Binds a node to a solid - # @param NodeID a node ID - # @param Solid a solid or solid ID - # @return True if succeed else raises an exception - # @ingroup l2_modif_add - def SetNodeInVolume(self, NodeID, Solid): - if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)): - SolidID = Solid.GetSubShapeIndices()[0] - else: - SolidID = Solid - try: - self.editor.SetNodeInVolume(NodeID, SolidID) - except SALOME.SALOME_Exception, inst: - raise ValueError, inst.details.text - return True - - ## @brief Bind an element to a shape - # @param ElementID an element ID - # @param Shape a shape or shape ID - # @return True if succeed else raises an exception - # @ingroup l2_modif_add - def SetMeshElementOnShape(self, ElementID, Shape): - if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)): - ShapeID = Shape.GetSubShapeIndices()[0] - else: - ShapeID = Shape - try: - self.editor.SetMeshElementOnShape(ElementID, ShapeID) - except SALOME.SALOME_Exception, inst: - raise ValueError, inst.details.text - return True - - - ## Moves the node with the given id - # @param NodeID the id of the node - # @param x a new X coordinate - # @param y a new Y coordinate - # @param z a new Z coordinate - # @return True if succeed else False - # @ingroup l2_modif_movenode - def MoveNode(self, NodeID, x, y, z): - x,y,z,Parameters,hasVars = ParseParameters(x,y,z) - if hasVars: self.mesh.SetParameters(Parameters) - return self.editor.MoveNode(NodeID, x, y, z) - - ## Finds the node closest to a point and moves it to a point location - # @param x the X coordinate of a point - # @param y the Y coordinate of a point - # @param z the Z coordinate of a point - # @param NodeID if specified (>0), the node with this ID is moved, - # otherwise, the node closest to point (@a x,@a y,@a z) is moved - # @return the ID of a node - # @ingroup l2_modif_throughp - def MoveClosestNodeToPoint(self, x, y, z, NodeID): - x,y,z,Parameters,hasVars = ParseParameters(x,y,z) - if hasVars: self.mesh.SetParameters(Parameters) - return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID) - - ## Finds the node closest to a point - # @param x the X coordinate of a point - # @param y the Y coordinate of a point - # @param z the Z coordinate of a point - # @return the ID of a node - # @ingroup l2_modif_throughp - def FindNodeClosestTo(self, x, y, z): - #preview = self.mesh.GetMeshEditPreviewer() - #return preview.MoveClosestNodeToPoint(x, y, z, -1) - return self.editor.FindNodeClosestTo(x, y, z) - - ## Finds the elements where a point lays IN or ON - # @param x the X coordinate of a point - # @param y the Y coordinate of a point - # @param z the Z coordinate of a point - # @param elementType type of elements to find (SMESH.ALL type - # means elements of any type excluding nodes, discrete and 0D elements) - # @param meshPart a part of mesh (group, sub-mesh) to search within - # @return list of IDs of found elements - # @ingroup l2_modif_throughp - def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None): - if meshPart: - return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType ); - else: - return self.editor.FindElementsByPoint(x, y, z, elementType) - - # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration: - # 0-IN, 1-OUT, 2-ON, 3-UNKNOWN - # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails. - - def GetPointState(self, x, y, z): - return self.editor.GetPointState(x, y, z) - - ## Finds the node closest to a point and moves it to a point location - # @param x the X coordinate of a point - # @param y the Y coordinate of a point - # @param z the Z coordinate of a point - # @return the ID of a moved node - # @ingroup l2_modif_throughp - def MeshToPassThroughAPoint(self, x, y, z): - return self.editor.MoveClosestNodeToPoint(x, y, z, -1) - - ## Replaces two neighbour triangles sharing Node1-Node2 link - # with the triangles built on the same 4 nodes but having other common link. - # @param NodeID1 the ID of the first node - # @param NodeID2 the ID of the second node - # @return false if proper faces were not found - # @ingroup l2_modif_invdiag - def InverseDiag(self, NodeID1, NodeID2): - return self.editor.InverseDiag(NodeID1, NodeID2) - - ## Replaces two neighbour triangles sharing Node1-Node2 link - # with a quadrangle built on the same 4 nodes. - # @param NodeID1 the ID of the first node - # @param NodeID2 the ID of the second node - # @return false if proper faces were not found - # @ingroup l2_modif_unitetri - def DeleteDiag(self, NodeID1, NodeID2): - return self.editor.DeleteDiag(NodeID1, NodeID2) - - ## Reorients elements by ids - # @param IDsOfElements if undefined reorients all mesh elements - # @return True if succeed else False - # @ingroup l2_modif_changori - def Reorient(self, IDsOfElements=None): - if IDsOfElements == None: - IDsOfElements = self.GetElementsId() - return self.editor.Reorient(IDsOfElements) - - ## Reorients all elements of the object - # @param theObject mesh, submesh or group - # @return True if succeed else False - # @ingroup l2_modif_changori - def ReorientObject(self, theObject): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - return self.editor.ReorientObject(theObject) - - ## Reorient faces contained in \a the2DObject. - # @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements - # @param theDirection is a desired direction of normal of \a theFace. - # It can be either a GEOM vector or a list of coordinates [x,y,z]. - # @param theFaceOrPoint defines a face of \a the2DObject whose normal will be - # compared with theDirection. It can be either ID of face or a point - # by which the face will be found. The point can be given as either - # a GEOM vertex or a list of point coordinates. - # @return number of reoriented faces - # @ingroup l2_modif_changori - def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ): - # check the2DObject - if isinstance( the2DObject, Mesh ): - the2DObject = the2DObject.GetMesh() - if isinstance( the2DObject, list ): - the2DObject = self.GetIDSource( the2DObject, SMESH.FACE ) - # check theDirection - if isinstance( theDirection, geompyDC.GEOM._objref_GEOM_Object): - theDirection = self.smeshpyD.GetDirStruct( theDirection ) - if isinstance( theDirection, list ): - theDirection = self.smeshpyD.MakeDirStruct( *theDirection ) - # prepare theFace and thePoint - theFace = theFaceOrPoint - thePoint = PointStruct(0,0,0) - if isinstance( theFaceOrPoint, geompyDC.GEOM._objref_GEOM_Object): - thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint ) - theFace = -1 - if isinstance( theFaceOrPoint, list ): - thePoint = PointStruct( *theFaceOrPoint ) - theFace = -1 - if isinstance( theFaceOrPoint, PointStruct ): - thePoint = theFaceOrPoint - theFace = -1 - return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint ) - - ## Fuses the neighbouring triangles into quadrangles. - # @param IDsOfElements The triangles to be fused, - # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to - # choose a neighbour to fuse with. - # @param MaxAngle is the maximum angle between element normals at which the fusion - # is still performed; theMaxAngle is mesured in radians. - # Also it could be a name of variable which defines angle in degrees. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_unitetri - def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle): - MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle) - self.mesh.SetParameters(Parameters) - if not IDsOfElements: - IDsOfElements = self.GetElementsId() - Functor = self.smeshpyD.GetFunctor(theCriterion) - return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle) - - ## Fuses the neighbouring triangles of the object into quadrangles - # @param theObject is mesh, submesh or group - # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to - # choose a neighbour to fuse with. - # @param MaxAngle a max angle between element normals at which the fusion - # is still performed; theMaxAngle is mesured in radians. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_unitetri - def TriToQuadObject (self, theObject, theCriterion, MaxAngle): - MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle) - self.mesh.SetParameters(Parameters) - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - Functor = self.smeshpyD.GetFunctor(theCriterion) - return self.editor.TriToQuadObject(theObject, Functor, MaxAngle) - - ## Splits quadrangles into triangles. - # - # @param IDsOfElements the faces to be splitted. - # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to - # choose a diagonal for splitting. If @a theCriterion is None, which is a default - # value, then quadrangles will be split by the smallest diagonal. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_cutquadr - def QuadToTri (self, IDsOfElements, theCriterion = None): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if theCriterion is None: - theCriterion = FT_MaxElementLength2D - Functor = self.smeshpyD.GetFunctor(theCriterion) - return self.editor.QuadToTri(IDsOfElements, Functor) - - ## Splits quadrangles into triangles. - # @param theObject the object from which the list of elements is taken, - # this is mesh, submesh or group - # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to - # choose a diagonal for splitting. If @a theCriterion is None, which is a default - # value, then quadrangles will be split by the smallest diagonal. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_cutquadr - def QuadToTriObject (self, theObject, theCriterion = None): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if theCriterion is None: - theCriterion = FT_MaxElementLength2D - Functor = self.smeshpyD.GetFunctor(theCriterion) - return self.editor.QuadToTriObject(theObject, Functor) - - ## Splits quadrangles into triangles. - # @param IDsOfElements the faces to be splitted - # @param Diag13 is used to choose a diagonal for splitting. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_cutquadr - def SplitQuad (self, IDsOfElements, Diag13): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - return self.editor.SplitQuad(IDsOfElements, Diag13) - - ## Splits quadrangles into triangles. - # @param theObject the object from which the list of elements is taken, - # this is mesh, submesh or group - # @param Diag13 is used to choose a diagonal for splitting. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_cutquadr - def SplitQuadObject (self, theObject, Diag13): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - return self.editor.SplitQuadObject(theObject, Diag13) - - ## Finds a better splitting of the given quadrangle. - # @param IDOfQuad the ID of the quadrangle to be splitted. - # @param theCriterion is a numerical functor, in terms of enum SMESH.FunctorType, used to - # choose a diagonal for splitting. - # @return 1 if 1-3 diagonal is better, 2 if 2-4 - # diagonal is better, 0 if error occurs. - # @ingroup l2_modif_cutquadr - def BestSplit (self, IDOfQuad, theCriterion): - return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion)) - - ## Splits volumic elements into tetrahedrons - # @param elemIDs either list of elements or mesh or group or submesh - # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet - # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc - # @ingroup l2_modif_cutquadr - def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ): - if isinstance( elemIDs, Mesh ): - elemIDs = elemIDs.GetMesh() - if ( isinstance( elemIDs, list )): - elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME) - self.editor.SplitVolumesIntoTetra(elemIDs, method) - - ## Splits quadrangle faces near triangular facets of volumes - # - # @ingroup l1_auxiliary - def SplitQuadsNearTriangularFacets(self): - faces_array = self.GetElementsByType(SMESH.FACE) - for face_id in faces_array: - if self.GetElemNbNodes(face_id) == 4: # quadrangle - quad_nodes = self.mesh.GetElemNodes(face_id) - node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1]) - isVolumeFound = False - for node1_elem in node1_elems: - if not isVolumeFound: - if self.GetElementType(node1_elem, True) == SMESH.VOLUME: - nb_nodes = self.GetElemNbNodes(node1_elem) - if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism - volume_elem = node1_elem - volume_nodes = self.mesh.GetElemNodes(volume_elem) - if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2 - if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4 - isVolumeFound = True - if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3 - self.SplitQuad([face_id], False) # diagonal 2-4 - elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4 - isVolumeFound = True - self.SplitQuad([face_id], True) # diagonal 1-3 - elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2 - if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2 - isVolumeFound = True - self.SplitQuad([face_id], True) # diagonal 1-3 - - ## @brief Splits hexahedrons into tetrahedrons. - # - # This operation uses pattern mapping functionality for splitting. - # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group. - # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the - # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern - # will be mapped into theNode000-th node of each volume, the (0,0,1) - # key-point will be mapped into theNode001-th node of each volume. - # The (0,0,0) key-point of the used pattern corresponds to a non-split corner. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l1_auxiliary - def SplitHexaToTetras (self, theObject, theNode000, theNode001): - # Pattern: 5.---------.6 - # /|#* /| - # / | #* / | - # / | # * / | - # / | # /* | - # (0,0,1) 4.---------.7 * | - # |#* |1 | # *| - # | # *.----|---#.2 - # | #/ * | / - # | /# * | / - # | / # * | / - # |/ #*|/ - # (0,0,0) 0.---------.3 - pattern_tetra = "!!! Nb of points: \n 8 \n\ - !!! Points: \n\ - 0 0 0 !- 0 \n\ - 0 1 0 !- 1 \n\ - 1 1 0 !- 2 \n\ - 1 0 0 !- 3 \n\ - 0 0 1 !- 4 \n\ - 0 1 1 !- 5 \n\ - 1 1 1 !- 6 \n\ - 1 0 1 !- 7 \n\ - !!! Indices of points of 6 tetras: \n\ - 0 3 4 1 \n\ - 7 4 3 1 \n\ - 4 7 5 1 \n\ - 6 2 5 7 \n\ - 1 5 2 7 \n\ - 2 3 1 7 \n" - - pattern = self.smeshpyD.GetPattern() - isDone = pattern.LoadFromFile(pattern_tetra) - if not isDone: - print 'Pattern.LoadFromFile :', pattern.GetErrorCode() - return isDone - - pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001) - isDone = pattern.MakeMesh(self.mesh, False, False) - if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode() - - # split quafrangle faces near triangular facets of volumes - self.SplitQuadsNearTriangularFacets() - - return isDone - - ## @brief Split hexahedrons into prisms. - # - # Uses the pattern mapping functionality for splitting. - # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken; - # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the - # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern - # will be mapped into the theNode000-th node of each volume, keypoint (0,0,1) - # will be mapped into the theNode001-th node of each volume. - # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners. - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l1_auxiliary - def SplitHexaToPrisms (self, theObject, theNode000, theNode001): - # Pattern: 5.---------.6 - # /|# /| - # / | # / | - # / | # / | - # / | # / | - # (0,0,1) 4.---------.7 | - # | | | | - # | 1.----|----.2 - # | / * | / - # | / * | / - # | / * | / - # |/ *|/ - # (0,0,0) 0.---------.3 - pattern_prism = "!!! Nb of points: \n 8 \n\ - !!! Points: \n\ - 0 0 0 !- 0 \n\ - 0 1 0 !- 1 \n\ - 1 1 0 !- 2 \n\ - 1 0 0 !- 3 \n\ - 0 0 1 !- 4 \n\ - 0 1 1 !- 5 \n\ - 1 1 1 !- 6 \n\ - 1 0 1 !- 7 \n\ - !!! Indices of points of 2 prisms: \n\ - 0 1 3 4 5 7 \n\ - 2 3 1 6 7 5 \n" - - pattern = self.smeshpyD.GetPattern() - isDone = pattern.LoadFromFile(pattern_prism) - if not isDone: - print 'Pattern.LoadFromFile :', pattern.GetErrorCode() - return isDone - - pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001) - isDone = pattern.MakeMesh(self.mesh, False, False) - if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode() - - # Splits quafrangle faces near triangular facets of volumes - self.SplitQuadsNearTriangularFacets() - - return isDone - - ## Smoothes elements - # @param IDsOfElements the list if ids of elements to smooth - # @param IDsOfFixedNodes the list of ids of fixed nodes. - # Note that nodes built on edges and boundary nodes are always fixed. - # @param MaxNbOfIterations the maximum number of iterations - # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_smooth - def Smooth(self, IDsOfElements, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio) - self.mesh.SetParameters(Parameters) - return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method) - - ## Smoothes elements which belong to the given object - # @param theObject the object to smooth - # @param IDsOfFixedNodes the list of ids of fixed nodes. - # Note that nodes built on edges and boundary nodes are always fixed. - # @param MaxNbOfIterations the maximum number of iterations - # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_smooth - def SmoothObject(self, theObject, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - return self.editor.SmoothObject(theObject, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method) - - ## Parametrically smoothes the given elements - # @param IDsOfElements the list if ids of elements to smooth - # @param IDsOfFixedNodes the list of ids of fixed nodes. - # Note that nodes built on edges and boundary nodes are always fixed. - # @param MaxNbOfIterations the maximum number of iterations - # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_smooth - def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio) - self.mesh.SetParameters(Parameters) - return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method) - - ## Parametrically smoothes the elements which belong to the given object - # @param theObject the object to smooth - # @param IDsOfFixedNodes the list of ids of fixed nodes. - # Note that nodes built on edges and boundary nodes are always fixed. - # @param MaxNbOfIterations the maximum number of iterations - # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) - # @return TRUE in case of success, FALSE otherwise. - # @ingroup l2_modif_smooth - def SmoothParametricObject(self, theObject, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes, - MaxNbOfIterations, MaxAspectRatio, Method) - - ## Converts the mesh to quadratic or bi-quadratic, deletes old elements, replacing - # them with quadratic with the same id. - # @param theForce3d new node creation method: - # 0 - the medium node lies at the geometrical entity from which the mesh element is built - # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element - # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal - # @param theToBiQuad If True, converts the mesh to bi-quadratic - # @ingroup l2_modif_tofromqu - def ConvertToQuadratic(self, theForce3d, theSubMesh=None, theToBiQuad=False): - if theToBiQuad: - self.editor.ConvertToBiQuadratic(theForce3d,theSubMesh) - else: - if theSubMesh: - self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh) - else: - self.editor.ConvertToQuadratic(theForce3d) - - ## Converts the mesh from quadratic to ordinary, - # deletes old quadratic elements, \n replacing - # them with ordinary mesh elements with the same id. - # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal - # @ingroup l2_modif_tofromqu - def ConvertFromQuadratic(self, theSubMesh=None): - if theSubMesh: - self.editor.ConvertFromQuadraticObject(theSubMesh) - else: - return self.editor.ConvertFromQuadratic() - - ## Creates 2D mesh as skin on boundary faces of a 3D mesh - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def Make2DMeshFrom3D(self): - return self.editor. Make2DMeshFrom3D() - - ## Creates missing boundary elements - # @param elements - elements whose boundary is to be checked: - # mesh, group, sub-mesh or list of elements - # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called - # @param dimension - defines type of boundary elements to create: - # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D - # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells - # @param groupName - a name of group to store created boundary elements in, - # "" means not to create the group - # @param meshName - a name of new mesh to store created boundary elements in, - # "" means not to create the new mesh - # @param toCopyElements - if true, the checked elements will be copied into - # the new mesh else only boundary elements will be copied into the new mesh - # @param toCopyExistingBondary - if true, not only new but also pre-existing - # boundary elements will be copied into the new mesh - # @return tuple (mesh, group) where bondary elements were added to - # @ingroup l2_modif_edit - def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="", - toCopyElements=False, toCopyExistingBondary=False): - if isinstance( elements, Mesh ): - elements = elements.GetMesh() - if ( isinstance( elements, list )): - elemType = SMESH.ALL - if elements: elemType = self.GetElementType( elements[0], iselem=True) - elements = self.editor.MakeIDSource(elements, elemType) - mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName, - toCopyElements,toCopyExistingBondary) - if mesh: mesh = self.smeshpyD.Mesh(mesh) - return mesh, group - - ## - # @brief Creates missing boundary elements around either the whole mesh or - # groups of 2D elements - # @param dimension - defines type of boundary elements to create - # @param groupName - a name of group to store all boundary elements in, - # "" means not to create the group - # @param meshName - a name of a new mesh, which is a copy of the initial - # mesh + created boundary elements; "" means not to create the new mesh - # @param toCopyAll - if true, the whole initial mesh will be copied into - # the new mesh else only boundary elements will be copied into the new mesh - # @param groups - groups of 2D elements to make boundary around - # @retval tuple( long, mesh, groups ) - # long - number of added boundary elements - # mesh - the mesh where elements were added to - # group - the group of boundary elements or None - # - def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="", - toCopyAll=False, groups=[]): - nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName, - toCopyAll,groups) - if mesh: mesh = self.smeshpyD.Mesh(mesh) - return nb, mesh, group - - ## Renumber mesh nodes - # @ingroup l2_modif_renumber - def RenumberNodes(self): - self.editor.RenumberNodes() - - ## Renumber mesh elements - # @ingroup l2_modif_renumber - def RenumberElements(self): - self.editor.RenumberElements() - - ## Generates new elements by rotation of the elements around the axis - # @param IDsOfElements the list of ids of elements to sweep - # @param Axis the axis of rotation, AxisStruct or line(geom object) - # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees - # @param NbOfSteps the number of steps - # @param Tolerance tolerance - # @param MakeGroups forces the generation of new groups from existing ones - # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size - # of all steps, else - size of each step - # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance, - MakeGroups=False, TotalAngle=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - if MakeGroups: - return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis, - AngleInRadians, NbOfSteps, Tolerance) - self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance) - return [] - - ## Generates new elements by rotation of the elements of object around the axis - # @param theObject object which elements should be sweeped. - # It can be a mesh, a sub mesh or a group. - # @param Axis the axis of rotation, AxisStruct or line(geom object) - # @param AngleInRadians the angle of Rotation - # @param NbOfSteps number of steps - # @param Tolerance tolerance - # @param MakeGroups forces the generation of new groups from existing ones - # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size - # of all steps, else - size of each step - # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, - MakeGroups=False, TotalAngle=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - if MakeGroups: - return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians, - NbOfSteps, Tolerance) - self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) - return [] - - ## Generates new elements by rotation of the elements of object around the axis - # @param theObject object which elements should be sweeped. - # It can be a mesh, a sub mesh or a group. - # @param Axis the axis of rotation, AxisStruct or line(geom object) - # @param AngleInRadians the angle of Rotation - # @param NbOfSteps number of steps - # @param Tolerance tolerance - # @param MakeGroups forces the generation of new groups from existing ones - # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size - # of all steps, else - size of each step - # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, - MakeGroups=False, TotalAngle=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - if MakeGroups: - return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians, - NbOfSteps, Tolerance) - self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) - return [] - - ## Generates new elements by rotation of the elements of object around the axis - # @param theObject object which elements should be sweeped. - # It can be a mesh, a sub mesh or a group. - # @param Axis the axis of rotation, AxisStruct or line(geom object) - # @param AngleInRadians the angle of Rotation - # @param NbOfSteps number of steps - # @param Tolerance tolerance - # @param MakeGroups forces the generation of new groups from existing ones - # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size - # of all steps, else - size of each step - # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance, - MakeGroups=False, TotalAngle=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians) - NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance) - Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if TotalAngle and NbOfSteps: - AngleInRadians /= NbOfSteps - if MakeGroups: - return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians, - NbOfSteps, Tolerance) - self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance) - return [] - - ## Generates new elements by extrusion of the elements with given ids - # @param IDsOfElements the list of elements ids for extrusion - # @param StepVector vector or DirStruct or 3 vector components, defining - # the direction and value of extrusion for one step (the total extrusion - # length will be NbOfSteps * ||StepVector||) - # @param NbOfSteps the number of steps - # @param MakeGroups forces the generation of new groups from existing ones - # @param IsNodes is True if elements with given ids are nodes - # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if MakeGroups: - if(IsNodes): - return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps) - else: - return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps) - if(IsNodes): - self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps) - else: - self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps) - return [] - - ## Generates new elements by extrusion of the elements with given ids - # @param IDsOfElements is ids of elements - # @param StepVector vector or DirStruct or 3 vector components, defining - # the direction and value of extrusion for one step (the total extrusion - # length will be NbOfSteps * ||StepVector||) - # @param NbOfSteps the number of steps - # @param ExtrFlags sets flags for extrusion - # @param SewTolerance uses for comparing locations of nodes if flag - # EXTRUSION_FLAG_SEW is set - # @param MakeGroups forces the generation of new groups from existing ones - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, - ExtrFlags, SewTolerance, MakeGroups=False): - if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - if MakeGroups: - return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps, - ExtrFlags, SewTolerance) - self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, - ExtrFlags, SewTolerance) - return [] - - ## Generates new elements by extrusion of the elements which belong to the object - # @param theObject the object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param StepVector vector or DirStruct or 3 vector components, defining - # the direction and value of extrusion for one step (the total extrusion - # length will be NbOfSteps * ||StepVector||) - # @param NbOfSteps the number of steps - # @param MakeGroups forces the generation of new groups from existing ones - # @param IsNodes is True if elements which belong to the object are nodes - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if MakeGroups: - if(IsNodes): - return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps) - else: - return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps) - if(IsNodes): - self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps) - else: - self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps) - return [] - - ## Generates new elements by extrusion of the elements which belong to the object - # @param theObject object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param StepVector vector or DirStruct or 3 vector components, defining - # the direction and value of extrusion for one step (the total extrusion - # length will be NbOfSteps * ||StepVector||) - # @param NbOfSteps the number of steps - # @param MakeGroups to generate new groups from existing ones - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if MakeGroups: - return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps) - self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps) - return [] - - ## Generates new elements by extrusion of the elements which belong to the object - # @param theObject object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param StepVector vector or DirStruct or 3 vector components, defining - # the direction and value of extrusion for one step (the total extrusion - # length will be NbOfSteps * ||StepVector||) - # @param NbOfSteps the number of steps - # @param MakeGroups forces the generation of new groups from existing ones - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_extrurev - def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)): - StepVector = self.smeshpyD.GetDirStruct(StepVector) - if isinstance( StepVector, list ): - StepVector = self.smeshpyD.MakeDirStruct(*StepVector) - NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps) - Parameters = StepVector.PS.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if MakeGroups: - return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps) - self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps) - return [] - - - - ## Generates new elements by extrusion of the given elements - # The path of extrusion must be a meshed edge. - # @param Base mesh or group, or submesh, or list of ids of elements for extrusion - # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion - # @param NodeStart the start node from Path. Defines the direction of extrusion - # @param HasAngles allows the shape to be rotated around the path - # to get the resulting mesh in a helical fashion - # @param Angles list of angles in radians - # @param LinearVariation forces the computation of rotation angles as linear - # variation of the given Angles along path steps - # @param HasRefPoint allows using the reference point - # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). - # The User can specify any point as the Reference Point. - # @param MakeGroups forces the generation of new groups from existing ones - # @param ElemType type of elements for extrusion (if param Base is a mesh) - # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, - # only SMESH::Extrusion_Error otherwise - # @ingroup l2_modif_extrurev - def ExtrusionAlongPathX(self, Base, Path, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups, ElemType): - if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - pass - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - - if (isinstance(Path, Mesh)): Path = Path.GetMesh() - - if isinstance(Base, list): - IDsOfElements = [] - if Base == []: IDsOfElements = self.GetElementsId() - else: IDsOfElements = Base - return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups, ElemType) - else: - if isinstance(Base, Mesh): Base = Base.GetMesh() - if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh): - return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart, - HasAngles, Angles, LinearVariation, - HasRefPoint, RefPoint, MakeGroups, ElemType) - else: - raise RuntimeError, "Invalid Base for ExtrusionAlongPathX" - - - ## Generates new elements by extrusion of the given elements - # The path of extrusion must be a meshed edge. - # @param IDsOfElements ids of elements - # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion - # @param PathShape shape(edge) defines the sub-mesh for the path - # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion - # @param HasAngles allows the shape to be rotated around the path - # to get the resulting mesh in a helical fashion - # @param Angles list of angles in radians - # @param HasRefPoint allows using the reference point - # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). - # The User can specify any point as the Reference Point. - # @param MakeGroups forces the generation of new groups from existing ones - # @param LinearVariation forces the computation of rotation angles as linear - # variation of the given Angles along path steps - # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, - # only SMESH::Extrusion_Error otherwise - # @ingroup l2_modif_extrurev - def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, - MakeGroups=False, LinearVariation=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - pass - if ( isinstance( PathMesh, Mesh )): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - if HasAngles and Angles and LinearVariation: - Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) - pass - if MakeGroups: - return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh, - PathShape, NodeStart, HasAngles, - Angles, HasRefPoint, RefPoint) - return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape, - NodeStart, HasAngles, Angles, HasRefPoint, RefPoint) - - ## Generates new elements by extrusion of the elements which belong to the object - # The path of extrusion must be a meshed edge. - # @param theObject the object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds - # @param PathShape shape(edge) defines the sub-mesh for the path - # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion - # @param HasAngles allows the shape to be rotated around the path - # to get the resulting mesh in a helical fashion - # @param Angles list of angles - # @param HasRefPoint allows using the reference point - # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). - # The User can specify any point as the Reference Point. - # @param MakeGroups forces the generation of new groups from existing ones - # @param LinearVariation forces the computation of rotation angles as linear - # variation of the given Angles along path steps - # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, - # only SMESH::Extrusion_Error otherwise - # @ingroup l2_modif_extrurev - def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, - MakeGroups=False, LinearVariation=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if ( isinstance( PathMesh, Mesh )): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - if HasAngles and Angles and LinearVariation: - Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) - pass - if MakeGroups: - return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh, - PathShape, NodeStart, HasAngles, - Angles, HasRefPoint, RefPoint) - return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape, - NodeStart, HasAngles, Angles, HasRefPoint, - RefPoint) - - ## Generates new elements by extrusion of the elements which belong to the object - # The path of extrusion must be a meshed edge. - # @param theObject the object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds - # @param PathShape shape(edge) defines the sub-mesh for the path - # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion - # @param HasAngles allows the shape to be rotated around the path - # to get the resulting mesh in a helical fashion - # @param Angles list of angles - # @param HasRefPoint allows using the reference point - # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). - # The User can specify any point as the Reference Point. - # @param MakeGroups forces the generation of new groups from existing ones - # @param LinearVariation forces the computation of rotation angles as linear - # variation of the given Angles along path steps - # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, - # only SMESH::Extrusion_Error otherwise - # @ingroup l2_modif_extrurev - def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, - MakeGroups=False, LinearVariation=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if ( isinstance( PathMesh, Mesh )): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - if HasAngles and Angles and LinearVariation: - Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) - pass - if MakeGroups: - return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh, - PathShape, NodeStart, HasAngles, - Angles, HasRefPoint, RefPoint) - return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape, - NodeStart, HasAngles, Angles, HasRefPoint, - RefPoint) - - ## Generates new elements by extrusion of the elements which belong to the object - # The path of extrusion must be a meshed edge. - # @param theObject the object which elements should be processed. - # It can be a mesh, a sub mesh or a group. - # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds - # @param PathShape shape(edge) defines the sub-mesh for the path - # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion - # @param HasAngles allows the shape to be rotated around the path - # to get the resulting mesh in a helical fashion - # @param Angles list of angles - # @param HasRefPoint allows using the reference point - # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default). - # The User can specify any point as the Reference Point. - # @param MakeGroups forces the generation of new groups from existing ones - # @param LinearVariation forces the computation of rotation angles as linear - # variation of the given Angles along path steps - # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True, - # only SMESH::Extrusion_Error otherwise - # @ingroup l2_modif_extrurev - def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart, - HasAngles, Angles, HasRefPoint, RefPoint, - MakeGroups=False, LinearVariation=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)): - RefPoint = self.smeshpyD.GetPointStruct(RefPoint) - if ( isinstance( PathMesh, Mesh )): - PathMesh = PathMesh.GetMesh() - Angles,AnglesParameters,hasVars = ParseAngles(Angles) - Parameters = AnglesParameters + var_separator + RefPoint.parameters - self.mesh.SetParameters(Parameters) - if HasAngles and Angles and LinearVariation: - Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles ) - pass - if MakeGroups: - return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh, - PathShape, NodeStart, HasAngles, - Angles, HasRefPoint, RefPoint) - return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape, - NodeStart, HasAngles, Angles, HasRefPoint, - RefPoint) - - ## Creates a symmetrical copy of mesh elements - # @param IDsOfElements list of elements ids - # @param Mirror is AxisStruct or geom object(point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary - # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0) - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): - Mirror = self.smeshpyD.GetAxisStruct(Mirror) - self.mesh.SetParameters(Mirror.parameters) - if Copy and MakeGroups: - return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType) - self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy) - return [] - - ## Creates a new mesh by a symmetrical copy of mesh elements - # @param IDsOfElements the list of elements ids - # @param Mirror is AxisStruct or geom object (point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary - # @param MakeGroups to generate new groups from existing ones - # @param NewMeshName a name of the new mesh to create - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): - Mirror = self.smeshpyD.GetAxisStruct(Mirror) - self.mesh.SetParameters(Mirror.parameters) - mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType, - MakeGroups, NewMeshName) - return Mesh(self.smeshpyD,self.geompyD,mesh) - - ## Creates a symmetrical copy of the object - # @param theObject mesh, submesh or group - # @param Mirror AxisStruct or geom object (point, line, plane) - # @param theMirrorType is POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary - # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0) - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)): - Mirror = self.smeshpyD.GetAxisStruct(Mirror) - self.mesh.SetParameters(Mirror.parameters) - if Copy and MakeGroups: - return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType) - self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy) - return [] - - ## Creates a new mesh by a symmetrical copy of the object - # @param theObject mesh, submesh or group - # @param Mirror AxisStruct or geom object (point, line, plane) - # @param theMirrorType POINT, AXIS or PLANE - # If the Mirror is a geom object this parameter is unnecessary - # @param MakeGroups forces the generation of new groups from existing ones - # @param NewMeshName the name of the new mesh to create - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)): - Mirror = self.smeshpyD.GetAxisStruct(Mirror) - self.mesh.SetParameters(Mirror.parameters) - mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType, - MakeGroups, NewMeshName) - return Mesh( self.smeshpyD,self.geompyD,mesh ) - - ## Translates the elements - # @param IDsOfElements list of elements ids - # @param Vector the direction of translation (DirStruct or vector or 3 vector components) - # @param Copy allows copying the translated elements - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): - Vector = self.smeshpyD.GetDirStruct(Vector) - if isinstance( Vector, list ): - Vector = self.smeshpyD.MakeDirStruct(*Vector) - self.mesh.SetParameters(Vector.PS.parameters) - if Copy and MakeGroups: - return self.editor.TranslateMakeGroups(IDsOfElements, Vector) - self.editor.Translate(IDsOfElements, Vector, Copy) - return [] - - ## Creates a new mesh of translated elements - # @param IDsOfElements list of elements ids - # @param Vector the direction of translation (DirStruct or vector or 3 vector components) - # @param MakeGroups forces the generation of new groups from existing ones - # @param NewMeshName the name of the newly created mesh - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): - Vector = self.smeshpyD.GetDirStruct(Vector) - if isinstance( Vector, list ): - Vector = self.smeshpyD.MakeDirStruct(*Vector) - self.mesh.SetParameters(Vector.PS.parameters) - mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName) - return Mesh ( self.smeshpyD, self.geompyD, mesh ) - - ## Translates the object - # @param theObject the object to translate (mesh, submesh, or group) - # @param Vector direction of translation (DirStruct or geom vector or 3 vector components) - # @param Copy allows copying the translated elements - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)): - Vector = self.smeshpyD.GetDirStruct(Vector) - if isinstance( Vector, list ): - Vector = self.smeshpyD.MakeDirStruct(*Vector) - self.mesh.SetParameters(Vector.PS.parameters) - if Copy and MakeGroups: - return self.editor.TranslateObjectMakeGroups(theObject, Vector) - self.editor.TranslateObject(theObject, Vector, Copy) - return [] - - ## Creates a new mesh from the translated object - # @param theObject the object to translate (mesh, submesh, or group) - # @param Vector the direction of translation (DirStruct or geom vector or 3 vector components) - # @param MakeGroups forces the generation of new groups from existing ones - # @param NewMeshName the name of the newly created mesh - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""): - if isinstance( theObject, Mesh ): - theObject = theObject.GetMesh() - if isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object ): - Vector = self.smeshpyD.GetDirStruct(Vector) - if isinstance( Vector, list ): - Vector = self.smeshpyD.MakeDirStruct(*Vector) - self.mesh.SetParameters(Vector.PS.parameters) - mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName) - return Mesh( self.smeshpyD, self.geompyD, mesh ) - - - - ## Scales the object - # @param theObject - the object to translate (mesh, submesh, or group) - # @param thePoint - base point for scale - # @param theScaleFact - list of 1-3 scale factors for axises - # @param Copy - allows copying the translated elements - # @param MakeGroups - forces the generation of new groups from existing - # ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, - # empty list otherwise - def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False): - if ( isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if ( isinstance( theObject, list )): - theObject = self.GetIDSource(theObject, SMESH.ALL) - if ( isinstance( theScaleFact, float )): - theScaleFact = [theScaleFact] - if ( isinstance( theScaleFact, int )): - theScaleFact = [ float(theScaleFact)] - - self.mesh.SetParameters(thePoint.parameters) - - if Copy and MakeGroups: - return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact) - self.editor.Scale(theObject, thePoint, theScaleFact, Copy) - return [] - - ## Creates a new mesh from the translated object - # @param theObject - the object to translate (mesh, submesh, or group) - # @param thePoint - base point for scale - # @param theScaleFact - list of 1-3 scale factors for axises - # @param MakeGroups - forces the generation of new groups from existing ones - # @param NewMeshName - the name of the newly created mesh - # @return instance of Mesh class - def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""): - if (isinstance(theObject, Mesh)): - theObject = theObject.GetMesh() - if ( isinstance( theObject, list )): - theObject = self.GetIDSource(theObject,SMESH.ALL) - if ( isinstance( theScaleFact, float )): - theScaleFact = [theScaleFact] - if ( isinstance( theScaleFact, int )): - theScaleFact = [ float(theScaleFact)] - - self.mesh.SetParameters(thePoint.parameters) - mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact, - MakeGroups, NewMeshName) - return Mesh( self.smeshpyD, self.geompyD, mesh ) - - - - ## Rotates the elements - # @param IDsOfElements list of elements ids - # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees - # @param Copy allows copying the rotated elements - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) - Parameters = Axis.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - if Copy and MakeGroups: - return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians) - self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy) - return [] - - ## Creates a new mesh of rotated elements - # @param IDsOfElements list of element ids - # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees - # @param MakeGroups forces the generation of new groups from existing ones - # @param NewMeshName the name of the newly created mesh - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""): - if IDsOfElements == []: - IDsOfElements = self.GetElementsId() - if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) - Parameters = Axis.parameters + var_separator + Parameters - self.mesh.SetParameters(Parameters) - mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians, - MakeGroups, NewMeshName) - return Mesh( self.smeshpyD, self.geompyD, mesh ) - - ## Rotates the object - # @param theObject the object to rotate( mesh, submesh, or group) - # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees - # @param Copy allows copying the rotated elements - # @param MakeGroups forces the generation of new groups from existing ones (if Copy) - # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise - # @ingroup l2_modif_trsf - def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False): - if (isinstance(theObject, Mesh)): - theObject = theObject.GetMesh() - if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) - Parameters = Axis.parameters + ":" + Parameters - self.mesh.SetParameters(Parameters) - if Copy and MakeGroups: - return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians) - self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy) - return [] - - ## Creates a new mesh from the rotated object - # @param theObject the object to rotate (mesh, submesh, or group) - # @param Axis the axis of rotation (AxisStruct or geom line) - # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees - # @param MakeGroups forces the generation of new groups from existing ones - # @param NewMeshName the name of the newly created mesh - # @return instance of Mesh class - # @ingroup l2_modif_trsf - def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""): - if (isinstance( theObject, Mesh )): - theObject = theObject.GetMesh() - if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)): - Axis = self.smeshpyD.GetAxisStruct(Axis) - AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians) - Parameters = Axis.parameters + ":" + Parameters - mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians, - MakeGroups, NewMeshName) - self.mesh.SetParameters(Parameters) - return Mesh( self.smeshpyD, self.geompyD, mesh ) - - ## Finds groups of ajacent nodes within Tolerance. - # @param Tolerance the value of tolerance - # @return the list of groups of nodes - # @ingroup l2_modif_trsf - def FindCoincidentNodes (self, Tolerance): - return self.editor.FindCoincidentNodes(Tolerance) - - ## Finds groups of ajacent nodes within Tolerance. - # @param Tolerance the value of tolerance - # @param SubMeshOrGroup SubMesh or Group - # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search - # @return the list of groups of nodes - # @ingroup l2_modif_trsf - def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]): - if (isinstance( SubMeshOrGroup, Mesh )): - SubMeshOrGroup = SubMeshOrGroup.GetMesh() - if not isinstance( exceptNodes, list): - exceptNodes = [ exceptNodes ] - if exceptNodes and isinstance( exceptNodes[0], int): - exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)] - return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes) - - ## Merges nodes - # @param GroupsOfNodes the list of groups of nodes - # @ingroup l2_modif_trsf - def MergeNodes (self, GroupsOfNodes): - self.editor.MergeNodes(GroupsOfNodes) - - ## Finds the elements built on the same nodes. - # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching - # @return a list of groups of equal elements - # @ingroup l2_modif_trsf - def FindEqualElements (self, MeshOrSubMeshOrGroup): - if ( isinstance( MeshOrSubMeshOrGroup, Mesh )): - MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh() - return self.editor.FindEqualElements(MeshOrSubMeshOrGroup) - - ## Merges elements in each given group. - # @param GroupsOfElementsID groups of elements for merging - # @ingroup l2_modif_trsf - def MergeElements(self, GroupsOfElementsID): - self.editor.MergeElements(GroupsOfElementsID) - - ## Leaves one element and removes all other elements built on the same nodes. - # @ingroup l2_modif_trsf - def MergeEqualElements(self): - self.editor.MergeEqualElements() - - ## Sews free borders - # @return SMESH::Sew_Error - # @ingroup l2_modif_trsf - def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, - FirstNodeID2, SecondNodeID2, LastNodeID2, - CreatePolygons, CreatePolyedrs): - return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, - FirstNodeID2, SecondNodeID2, LastNodeID2, - CreatePolygons, CreatePolyedrs) - - ## Sews conform free borders - # @return SMESH::Sew_Error - # @ingroup l2_modif_trsf - def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1, - FirstNodeID2, SecondNodeID2): - return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1, - FirstNodeID2, SecondNodeID2) - - ## Sews border to side - # @return SMESH::Sew_Error - # @ingroup l2_modif_trsf - def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, - FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs): - return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, - FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs) - - ## Sews two sides of a mesh. The nodes belonging to Side1 are - # merged with the nodes of elements of Side2. - # The number of elements in theSide1 and in theSide2 must be - # equal and they should have similar nodal connectivity. - # The nodes to merge should belong to side borders and - # the first node should be linked to the second. - # @return SMESH::Sew_Error - # @ingroup l2_modif_trsf - def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements, - NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, - NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge): - return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements, - NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, - NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge) - - ## Sets new nodes for the given element. - # @param ide the element id - # @param newIDs nodes ids - # @return If the number of nodes does not correspond to the type of element - returns false - # @ingroup l2_modif_edit - def ChangeElemNodes(self, ide, newIDs): - return self.editor.ChangeElemNodes(ide, newIDs) - - ## If during the last operation of MeshEditor some nodes were - # created, this method returns the list of their IDs, \n - # if new nodes were not created - returns empty list - # @return the list of integer values (can be empty) - # @ingroup l1_auxiliary - def GetLastCreatedNodes(self): - return self.editor.GetLastCreatedNodes() - - ## If during the last operation of MeshEditor some elements were - # created this method returns the list of their IDs, \n - # if new elements were not created - returns empty list - # @return the list of integer values (can be empty) - # @ingroup l1_auxiliary - def GetLastCreatedElems(self): - return self.editor.GetLastCreatedElems() - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # @param theNodes identifiers of nodes to be doubled - # @param theModifiedElems identifiers of elements to be updated by the new (doubled) - # nodes. If list of element identifiers is empty then nodes are doubled but - # they not assigned to elements - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNodes(self, theNodes, theModifiedElems): - return self.editor.DoubleNodes(theNodes, theModifiedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theNodeId identifiers of node to be doubled - # @param theModifiedElems identifiers of elements to be updated - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNode(self, theNodeId, theModifiedElems): - return self.editor.DoubleNode(theNodeId, theModifiedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theNodes group of nodes to be doubled - # @param theModifiedElems group of elements to be updated. - # @param theMakeGroup forces the generation of a group containing new nodes. - # @return TRUE or a created group if operation has been completed successfully, - # FALSE or None otherwise - # @ingroup l2_modif_edit - def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False): - if theMakeGroup: - return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems) - return self.editor.DoubleNodeGroup(theNodes, theModifiedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theNodes list of groups of nodes to be doubled - # @param theModifiedElems list of groups of elements to be updated. - # @param theMakeGroup forces the generation of a group containing new nodes. - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False): - if theMakeGroup: - return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems) - return self.editor.DoubleNodeGroups(theNodes, theModifiedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # @param theElems - the list of elements (edges or faces) to be replicated - # The nodes for duplication could be found from these elements - # @param theNodesNot - list of nodes to NOT replicate - # @param theAffectedElems - the list of elements (cells and edges) to which the - # replicated nodes should be associated to. - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems): - return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # @param theElems - the list of elements (edges or faces) to be replicated - # The nodes for duplication could be found from these elements - # @param theNodesNot - list of nodes to NOT replicate - # @param theShape - shape to detect affected elements (element which geometric center - # located on or inside shape). - # The replicated nodes should be associated to affected elements. - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape): - return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theElems - group of of elements (edges or faces) to be replicated - # @param theNodesNot - group of nodes not to replicated - # @param theAffectedElems - group of elements to which the replicated nodes - # should be associated to. - # @param theMakeGroup forces the generation of a group containing new elements. - # @param theMakeNodeGroup forces the generation of a group containing new nodes. - # @return TRUE or created groups (one or two) if operation has been completed successfully, - # FALSE or None otherwise - # @ingroup l2_modif_edit - def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, - theMakeGroup=False, theMakeNodeGroup=False): - if theMakeGroup or theMakeNodeGroup: - twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot, - theAffectedElems, - theMakeGroup, theMakeNodeGroup) - if theMakeGroup and theMakeNodeGroup: - return twoGroups - else: - return twoGroups[ int(theMakeNodeGroup) ] - return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theElems - group of of elements (edges or faces) to be replicated - # @param theNodesNot - group of nodes not to replicated - # @param theShape - shape to detect affected elements (element which geometric center - # located on or inside shape). - # The replicated nodes should be associated to affected elements. - # @ingroup l2_modif_edit - def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape): - return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theElems - list of groups of elements (edges or faces) to be replicated - # @param theNodesNot - list of groups of nodes not to replicated - # @param theAffectedElems - group of elements to which the replicated nodes - # should be associated to. - # @param theMakeGroup forces the generation of a group containing new elements. - # @param theMakeNodeGroup forces the generation of a group containing new nodes. - # @return TRUE or created groups (one or two) if operation has been completed successfully, - # FALSE or None otherwise - # @ingroup l2_modif_edit - def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, - theMakeGroup=False, theMakeNodeGroup=False): - if theMakeGroup or theMakeNodeGroup: - twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot, - theAffectedElems, - theMakeGroup, theMakeNodeGroup) - if theMakeGroup and theMakeNodeGroup: - return twoGroups - else: - return twoGroups[ int(theMakeNodeGroup) ] - return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems) - - ## Creates a hole in a mesh by doubling the nodes of some particular elements - # This method provided for convenience works as DoubleNodes() described above. - # @param theElems - list of groups of elements (edges or faces) to be replicated - # @param theNodesNot - list of groups of nodes not to replicated - # @param theShape - shape to detect affected elements (element which geometric center - # located on or inside shape). - # The replicated nodes should be associated to affected elements. - # @return TRUE if operation has been completed successfully, FALSE otherwise - # @ingroup l2_modif_edit - def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape): - return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape) - - ## Identify the elements that will be affected by node duplication (actual duplication is not performed. - # This method is the first step of DoubleNodeElemGroupsInRegion. - # @param theElems - list of groups of elements (edges or faces) to be replicated - # @param theNodesNot - list of groups of nodes not to replicated - # @param theShape - shape to detect affected elements (element which geometric center - # located on or inside shape). - # The replicated nodes should be associated to affected elements. - # @return groups of affected elements - # @ingroup l2_modif_edit - def AffectedElemGroupsInRegion(self, theElems, theNodesNot, theShape): - return self.editor.AffectedElemGroupsInRegion(theElems, theNodesNot, theShape) - - ## Double nodes on shared faces between groups of volumes and create flat elements on demand. - # The list of groups must describe a partition of the mesh volumes. - # The nodes of the internal faces at the boundaries of the groups are doubled. - # In option, the internal faces are replaced by flat elements. - # Triangles are transformed in prisms, and quadrangles in hexahedrons. - # @param theDomains - list of groups of volumes - # @param createJointElems - if TRUE, create the elements - # @return TRUE if operation has been completed successfully, FALSE otherwise - def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ): - return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems ) - - ## Double nodes on some external faces and create flat elements. - # Flat elements are mainly used by some types of mechanic calculations. - # - # Each group of the list must be constituted of faces. - # Triangles are transformed in prisms, and quadrangles in hexahedrons. - # @param theGroupsOfFaces - list of groups of faces - # @return TRUE if operation has been completed successfully, FALSE otherwise - def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ): - return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces ) - - ## identify all the elements around a geom shape, get the faces delimiting the hole - # - def CreateHoleSkin(self, radius, theShape, groupName, theNodesCoords): - return self.editor.CreateHoleSkin( radius, theShape, groupName, theNodesCoords ) - - def _getFunctor(self, funcType ): - fn = self.functors[ funcType._v ] - if not fn: - fn = self.smeshpyD.GetFunctor(funcType) - fn.SetMesh(self.mesh) - self.functors[ funcType._v ] = fn - return fn - - def _valueFromFunctor(self, funcType, elemId): - fn = self._getFunctor( funcType ) - if fn.GetElementType() == self.GetElementType(elemId, True): - val = fn.GetValue(elemId) - else: - val = 0 - return val - - ## Get length of 1D element. - # @param elemId mesh element ID - # @return element's length value - # @ingroup l1_measurements - def GetLength(self, elemId): - return self._valueFromFunctor(SMESH.FT_Length, elemId) - - ## Get area of 2D element. - # @param elemId mesh element ID - # @return element's area value - # @ingroup l1_measurements - def GetArea(self, elemId): - return self._valueFromFunctor(SMESH.FT_Area, elemId) - - ## Get volume of 3D element. - # @param elemId mesh element ID - # @return element's volume value - # @ingroup l1_measurements - def GetVolume(self, elemId): - return self._valueFromFunctor(SMESH.FT_Volume3D, elemId) - - ## Get maximum element length. - # @param elemId mesh element ID - # @return element's maximum length value - # @ingroup l1_measurements - def GetMaxElementLength(self, elemId): - if self.GetElementType(elemId, True) == SMESH.VOLUME: - ftype = SMESH.FT_MaxElementLength3D - else: - ftype = SMESH.FT_MaxElementLength2D - return self._valueFromFunctor(ftype, elemId) - - ## Get aspect ratio of 2D or 3D element. - # @param elemId mesh element ID - # @return element's aspect ratio value - # @ingroup l1_measurements - def GetAspectRatio(self, elemId): - if self.GetElementType(elemId, True) == SMESH.VOLUME: - ftype = SMESH.FT_AspectRatio3D - else: - ftype = SMESH.FT_AspectRatio - return self._valueFromFunctor(ftype, elemId) - - ## Get warping angle of 2D element. - # @param elemId mesh element ID - # @return element's warping angle value - # @ingroup l1_measurements - def GetWarping(self, elemId): - return self._valueFromFunctor(SMESH.FT_Warping, elemId) - - ## Get minimum angle of 2D element. - # @param elemId mesh element ID - # @return element's minimum angle value - # @ingroup l1_measurements - def GetMinimumAngle(self, elemId): - return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId) - - ## Get taper of 2D element. - # @param elemId mesh element ID - # @return element's taper value - # @ingroup l1_measurements - def GetTaper(self, elemId): - return self._valueFromFunctor(SMESH.FT_Taper, elemId) - - ## Get skew of 2D element. - # @param elemId mesh element ID - # @return element's skew value - # @ingroup l1_measurements - def GetSkew(self, elemId): - return self._valueFromFunctor(SMESH.FT_Skew, elemId) - - pass # end of Mesh class - -## Helper class for wrapping of SMESH.SMESH_Pattern CORBA class -# -class Pattern(SMESH._objref_SMESH_Pattern): - - def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse): - decrFun = lambda i: i-1 - theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun) - theMesh.SetParameters(Parameters) - return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse ) - - def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index): - decrFun = lambda i: i-1 - theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun) - theMesh.SetParameters(Parameters) - return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index ) - -# Registering the new proxy for Pattern -omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern) - -## Private class used to bind methods creating algorithms to the class Mesh -# -class algoCreator: - def __init__(self): - self.mesh = None - self.defaultAlgoType = "" - self.algoTypeToClass = {} - - # Stores a python class of algorithm - def add(self, algoClass): - if type( algoClass ).__name__ == 'classobj' and \ - hasattr( algoClass, "algoType"): - self.algoTypeToClass[ algoClass.algoType ] = algoClass - if not self.defaultAlgoType and \ - hasattr( algoClass, "isDefault") and algoClass.isDefault: - self.defaultAlgoType = algoClass.algoType - #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType - - # creates a copy of self and assign mesh to the copy - def copy(self, mesh): - other = algoCreator() - other.defaultAlgoType = self.defaultAlgoType - other.algoTypeToClass = self.algoTypeToClass - other.mesh = mesh - return other - - # creates an instance of algorithm - def __call__(self,algo="",geom=0,*args): - algoType = self.defaultAlgoType - for arg in args + (algo,geom): - if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ): - geom = arg - if isinstance( arg, str ) and arg: - algoType = arg - if not algoType and self.algoTypeToClass: - algoType = self.algoTypeToClass.keys()[0] - if self.algoTypeToClass.has_key( algoType ): - #print "Create algo",algoType - return self.algoTypeToClass[ algoType ]( self.mesh, geom ) - raise RuntimeError, "No class found for algo type %s" % algoType - return None - -# Private class used to substitute and store variable parameters of hypotheses. -# -class hypMethodWrapper: - def __init__(self, hyp, method): - self.hyp = hyp - self.method = method - #print "REBIND:", method.__name__ - return - - # call a method of hypothesis with calling SetVarParameter() before - def __call__(self,*args): - if not args: - return self.method( self.hyp, *args ) # hypothesis method with no args - - #print "MethWrapper.__call__",self.method.__name__, args - try: - parsed = ParseParameters(*args) # replace variables with their values - self.hyp.SetVarParameter( parsed[-2], self.method.__name__ ) - result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method - except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call - # maybe there is a replaced string arg which is not variable - result = self.method( self.hyp, *args ) - except ValueError, detail: # raised by ParseParameters() - try: - result = self.method( self.hyp, *args ) - except omniORB.CORBA.BAD_PARAM: - raise ValueError, detail # wrong variable name - - return result diff --git a/src/SMESH_SWIG/smesh_algorithm.py b/src/SMESH_SWIG/smesh_algorithm.py index eda19fea4..e72a81f8e 100644 --- a/src/SMESH_SWIG/smesh_algorithm.py +++ b/src/SMESH_SWIG/smesh_algorithm.py @@ -22,7 +22,7 @@ # This package is a part of SALOME %Mesh module Python API import salome -import geompyDC +from salome.geom import geomBuilder import SMESH ## The base class to define meshing algorithms @@ -32,8 +32,8 @@ import SMESH # # For each meshing algorithm, a python class inheriting from class %Mesh_Algorithm # should be defined. This descendant class should have two attributes defining the way -# it is created by class Mesh (see e.g. class @ref StdMeshersDC.StdMeshersDC_Segment "StdMeshersDC_Segment" -# in StdMeshersDC package): +# it is created by class Mesh (see e.g. class @ref StdMeshersBuilder.StdMeshersBuilder_Segment "StdMeshersBuilder_Segment" +# in StdMeshersBuilder package): # - @c meshMethod attribute defines name of method of class smesh.Mesh by calling which the # python class of algorithm is created; this method is dynamically added to the smesh.Mesh class # in runtime. For example, if in @c class MyPlugin_Algorithm this attribute is defined as @@ -167,7 +167,7 @@ class Mesh_Algorithm: ## Gets the name of the algorithm def GetName(self): - from smesh import GetName + from salome.smesh.smeshBuilder import GetName return GetName(self.algo) ## Sets the name to the algorithm @@ -191,7 +191,7 @@ class Mesh_Algorithm: ## Private method def Assign(self, algo, mesh, geom): - from smesh import AssureGeomPublished, TreatHypoStatus, GetName + from salome.smesh.smeshBuilder import AssureGeomPublished, TreatHypoStatus, GetName if geom is None: raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape" self.mesh = mesh @@ -222,7 +222,7 @@ class Mesh_Algorithm: ## Private method def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so", UseExisting=0, CompareMethod=""): - from smesh import TreatHypoStatus, GetName + from salome.smesh.smeshBuilder import TreatHypoStatus, GetName hypo = None if UseExisting: if CompareMethod == "": CompareMethod = self.CompareHyp @@ -234,7 +234,7 @@ class Mesh_Algorithm: s = "=" for arg in args: argStr = str(arg) - if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ): + if isinstance( arg, geomBuilder.GEOM._objref_GEOM_Object ): argStr = arg.GetStudyEntry() if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry() if len( argStr ) > 10: @@ -274,7 +274,7 @@ class Mesh_Algorithm: raise TypeError, "ViscousLayers are supported by 3D algorithms only" if not "ViscousLayers" in self.GetCompatibleHypothesis(): raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName() - if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ): + if ignoreFaces and isinstance( ignoreFaces[0], geomBuilder.GEOM._objref_GEOM_Object ): ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ] hyp = self.Hypothesis("ViscousLayers", [thickness, numberOfLayers, stretchFactor, ignoreFaces]) @@ -297,7 +297,7 @@ class Mesh_Algorithm: raise TypeError, "ViscousLayers2D are supported by 2D algorithms only" if not "ViscousLayers2D" in self.GetCompatibleHypothesis(): raise TypeError, "ViscousLayers2D are not supported by %s"%self.algo.GetName() - if ignoreEdges and isinstance( ignoreEdges[0], geompyDC.GEOM._objref_GEOM_Object ): + if ignoreEdges and isinstance( ignoreEdges[0], geomBuilder.GEOM._objref_GEOM_Object ): ignoreEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreEdges ] hyp = self.Hypothesis("ViscousLayers2D", [thickness, numberOfLayers, stretchFactor, ignoreEdges]) @@ -311,30 +311,30 @@ class Mesh_Algorithm: # into a list acceptable to SetReversedEdges() of some 1D hypotheses # @ingroup l3_hypos_1dhyps def ReversedEdgeIndices(self, reverseList): - from smesh import FirstVertexOnCurve + from salome.smesh.smeshBuilder import FirstVertexOnCurve resList = [] geompy = self.mesh.geompyD for i in reverseList: if isinstance( i, int ): s = geompy.SubShapes(self.mesh.geom, [i])[0] - if s.GetShapeType() != geompyDC.GEOM.EDGE: + if s.GetShapeType() != geomBuilder.GEOM.EDGE: raise TypeError, "Not EDGE index given" resList.append( i ) - elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ): - if i.GetShapeType() != geompyDC.GEOM.EDGE: + elif isinstance( i, geomBuilder.GEOM._objref_GEOM_Object ): + if i.GetShapeType() != geomBuilder.GEOM.EDGE: raise TypeError, "Not an EDGE given" resList.append( geompy.GetSubShapeID(self.mesh.geom, i )) elif len( i ) > 1: e = i[0] v = i[1] - if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \ - not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ): + if not isinstance( e, geomBuilder.GEOM._objref_GEOM_Object ) or \ + not isinstance( v, geomBuilder.GEOM._objref_GEOM_Object ): raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)" - if v.GetShapeType() == geompyDC.GEOM.EDGE and \ - e.GetShapeType() == geompyDC.GEOM.VERTEX: + if v.GetShapeType() == geomBuilder.GEOM.EDGE and \ + e.GetShapeType() == geomBuilder.GEOM.VERTEX: v,e = e,v - if e.GetShapeType() != geompyDC.GEOM.EDGE or \ - v.GetShapeType() != geompyDC.GEOM.VERTEX: + if e.GetShapeType() != geomBuilder.GEOM.EDGE or \ + v.GetShapeType() != geomBuilder.GEOM.VERTEX: raise TypeError, "A list item must be a tuple (edge, 1st_vertex_of_edge)" vFirst = FirstVertexOnCurve( e ) tol = geompy.Tolerance( vFirst )[-1]