From 23519bfc50b00c08d700b1935e23664bf1fadade Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 21 Mar 2013 22:35:39 +0000 Subject: [PATCH] PR: examples adaptation to geomBuilder and smeshBuilder --- doc/salome/examples/filters_ex16.py | 10 +++++----- doc/salome/examples/filters_ex17.py | 6 +++--- doc/salome/examples/filters_ex36.py | 2 +- doc/salome/examples/grouping_elements_ex03.py | 14 +++++++------- doc/salome/examples/modifying_meshes_ex15.py | 6 +++--- doc/salome/examples/quality_controls_ex07.py | 4 ++-- doc/salome/examples/quality_controls_ex08.py | 4 ++-- doc/salome/examples/quality_controls_ex09.py | 6 +++--- doc/salome/examples/quality_controls_ex10.py | 8 ++++---- doc/salome/examples/transforming_meshes_ex12.py | 12 ++++++------ 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/doc/salome/examples/filters_ex16.py b/doc/salome/examples/filters_ex16.py index b7d8b2b1c..bdca2d86a 100644 --- a/doc/salome/examples/filters_ex16.py +++ b/doc/salome/examples/filters_ex16.py @@ -14,18 +14,18 @@ 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, SMESH.FT_EqualEdges) -equalFacesFilter = GetFilter(SMESH.FACE, SMESH.FT_EqualFaces) -equalVolumesFilter = GetFilter(SMESH.VOLUME, SMESH.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 716feef50..c3f80d65a 100644 --- a/doc/salome/examples/filters_ex17.py +++ b/doc/salome/examples/filters_ex17.py @@ -14,14 +14,14 @@ 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_ex36.py b/doc/salome/examples/filters_ex36.py index 9e3e1dd77..3dc8e4fc6 100644 --- a/doc/salome/examples/filters_ex36.py +++ b/doc/salome/examples/filters_ex36.py @@ -3,7 +3,7 @@ # 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) filter = smesh.CreateFilterManager().CreateFilter() diff --git a/doc/salome/examples/grouping_elements_ex03.py b/doc/salome/examples/grouping_elements_ex03.py index b6e536a35..375749cb4 100644 --- a/doc/salome/examples/grouping_elements_ex03.py +++ b/doc/salome/examples/grouping_elements_ex03.py @@ -16,18 +16,18 @@ 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 @@ -37,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/modifying_meshes_ex15.py b/doc/salome/examples/modifying_meshes_ex15.py index 7fd1e8681..ae6d5eae7 100644 --- a/doc/salome/examples/modifying_meshes_ex15.py +++ b/doc/salome/examples/modifying_meshes_ex15.py @@ -13,16 +13,16 @@ smesh = smeshBuilder.New(salome.myStudy) import salome_notebook -box = MakeBoxDXDYDZ(200, 200, 200) +box = geompy.MakeBoxDXDYDZ(200, 200, 200) -mesh = Mesh( box ) +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/quality_controls_ex07.py b/doc/salome/examples/quality_controls_ex07.py index e8ef561a4..5e84f2bfc 100644 --- a/doc/salome/examples/quality_controls_ex07.py +++ b/doc/salome/examples/quality_controls_ex07.py @@ -22,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 4835135b6..541af64a3 100644 --- a/doc/salome/examples/quality_controls_ex08.py +++ b/doc/salome/examples/quality_controls_ex08.py @@ -20,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 @@ -29,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 3bacd93ed..aca903ae0 100644 --- a/doc/salome/examples/quality_controls_ex09.py +++ b/doc/salome/examples/quality_controls_ex09.py @@ -13,8 +13,8 @@ smesh = smeshBuilder.New(salome.myStudy) import salome_notebook -mesh = Mesh() -faceFilter = GetFilter(FACE,FT_OverConstrainedFace) +mesh = smesh.Mesh() +faceFilter = smesh.GetFilter(SMESH.FACE,SMESH.FT_OverConstrainedFace) #make an edge n1 = mesh.AddNode(0,0,0) @@ -23,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 7896b83e7..041183224 100644 --- a/doc/salome/examples/quality_controls_ex10.py +++ b/doc/salome/examples/quality_controls_ex10.py @@ -13,13 +13,13 @@ smesh = smeshBuilder.New(salome.myStudy) import salome_notebook -mesh = Mesh() -volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume) +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/transforming_meshes_ex12.py b/doc/salome/examples/transforming_meshes_ex12.py index c25a2d033..e1d850ec6 100644 --- a/doc/salome/examples/transforming_meshes_ex12.py +++ b/doc/salome/examples/transforming_meshes_ex12.py @@ -29,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 @@ -39,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) @@ -59,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 @@ -70,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) @@ -91,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 ) @@ -102,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) -- 2.39.2