X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH_SWIG%2FSMESH_mechanic_editor.py;h=7398542300993a02fe000ec5bd787c0490bed44c;hb=42c70284400c5b73aca9b9b8ffd91a035da25bf8;hp=4563dd4764581a1d5ee65a7431cd1661e30beee6;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce;p=modules%2Fsmesh.git diff --git a/src/SMESH_SWIG/SMESH_mechanic_editor.py b/src/SMESH_SWIG/SMESH_mechanic_editor.py index 4563dd476..739854230 100644 --- a/src/SMESH_SWIG/SMESH_mechanic_editor.py +++ b/src/SMESH_SWIG/SMESH_mechanic_editor.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 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 @@ -7,7 +7,7 @@ # 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. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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,34 +125,33 @@ 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 ) mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic") -print "-------------------------- NumberOfSegments" +print("-------------------------- NumberOfSegments") numberOfSegment = 10 algo = mesh.Segment() hypNbSeg = algo.NumberOfSegments(numberOfSegment) -print hypNbSeg.GetName() -print hypNbSeg.GetId() -print hypNbSeg.GetNumberOfSegments() +print(hypNbSeg.GetName()) +print(hypNbSeg.GetId()) +print(hypNbSeg.GetNumberOfSegments()) smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment)) -print "-------------------------- MaxElementArea" +print("-------------------------- MaxElementArea") maxElementArea = 25 algo = mesh.Triangle() hypArea25 = algo.MaxElementArea(maxElementArea) -print hypArea25.GetName() -print hypArea25.GetId() -print hypArea25.GetMaxElementArea() +print(hypArea25.GetName()) +print(hypArea25.GetId()) +print(hypArea25.GetMaxElementArea()) smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea)) @@ -175,18 +179,18 @@ smesh.SetName(algo.GetSubMesh(), "SubMeshFace4") submesh4 = algo.GetSubMesh() -print "-------------------------- compute the mesh of the mechanic piece" +print("-------------------------- compute the mesh of the mechanic piece") mesh.Compute() -print "Information about the Mesh_mechanic:" -print "Number of nodes : ", mesh.NbNodes() -print "Number of edges : ", mesh.NbEdges() -print "Number of faces : ", mesh.NbFaces() -print "Number of triangles : ", mesh.NbTriangles() -print "Number of quadrangles : ", mesh.NbQuadrangles() -print "Number of volumes : ", mesh.NbVolumes() -print "Number of tetrahedrons: ", mesh.NbTetras() +print("Information about the Mesh_mechanic:") +print("Number of nodes : ", mesh.NbNodes()) +print("Number of edges : ", mesh.NbEdges()) +print("Number of faces : ", mesh.NbFaces()) +print("Number of triangles : ", mesh.NbTriangles()) +print("Number of quadrangles : ", mesh.NbQuadrangles()) +print("Number of volumes : ", mesh.NbVolumes()) +print("Number of tetrahedrons: ", mesh.NbTetras()) #1 cutting of quadrangles of the 'SubMeshFace2' submesh @@ -194,40 +198,40 @@ 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 mesh.ReorientObject(submesh1) -salome.sg.updateObjBrowser(1) +salome.sg.updateObjBrowser(True)