From: prascle Date: Fri, 15 Mar 2013 10:57:18 +0000 (+0000) Subject: PR: examples adaptation to geomBuilder X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9343acc3c829cd2d2ce06e94d0f80affaefa647;p=modules%2Fsmesh.git PR: examples adaptation to geomBuilder --- diff --git a/src/SMESH_SWIG/PAL_MESH_041_mesh.py b/src/SMESH_SWIG/PAL_MESH_041_mesh.py index bbfdd1abf..de705bffd 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 8db9bf12f..77aaea752 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 9607f9bb7..1c74ac303 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 958dba283..c415f32b3 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 d1ef60872..14e9bd3a8 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 0c1a9126d..0dcf2d330 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_GroupFromGeom2.py b/src/SMESH_SWIG/SMESH_GroupFromGeom2.py index 02ec044fe..b6ab673ff 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 03978e0d5..c5090a0fa 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 e292cbc2a..59c0bc198 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 ddd5bb16e..ab7ddf276 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 64a390752..58a247f16 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 2de2a408f..f3715f612 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 8680208cb..7a4512f4c 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 0aaa8cbab..304adec63 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 503ff4f87..bf2a61353 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 4aff58411..810ec768b 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_test1.py b/src/SMESH_SWIG/SMESH_test1.py index 24047c411..61cee75be 100644 --- a/src/SMESH_SWIG/SMESH_test1.py +++ b/src/SMESH_SWIG/SMESH_test1.py @@ -66,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/StdMeshersDC.py b/src/SMESH_SWIG/StdMeshersDC.py deleted file mode 100644 index b032e204c..000000000 --- a/src/SMESH_SWIG/StdMeshersDC.py +++ /dev/null @@ -1,1326 +0,0 @@ -# Copyright (C) 2007-2012 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 smeshDC import AssureGeomPublished, IsEqual, ParseParameters -from smeshDC 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 = 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 - 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 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