Salome HOME
23368: [CEA 1865] Possibility to define faces to mesh as a single one: transpatch...
[modules/smesh.git] / src / SMESH_SWIG / SMESH_mechanic_editor.py
index 80780ca63c8fe64f781829757b0d37bb69280591..bb340bc9530e72ffa26c1cbe75f5b1150ef7cdcd 100644 (file)
@@ -1,24 +1,26 @@
-#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+# -*- coding: utf-8 -*-
+# 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
+# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
+# This library is 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, 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
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+
 #  File   : SMESH_withHole.py
 #  Author : Lucien PIGNOLONI
 #  Module : SMESH
 #-------------------------------------------------------------------------
 #
 import salome
-import geompy
-import smesh
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+smesh =  smeshBuilder.New(salome.myStudy)
 
 # ---------------------------- GEOM --------------------------------------
 
@@ -92,25 +100,25 @@ Id_mechanic = geompy.addToStudy( mechanic, "mechanic" )
 # ---- explode on faces
 SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"])
 
-# ---- add a face sub shape in study to be meshed different
+# ---- add a face sub-shape in study to be meshed different
 sub_face1 = SubFaceL[0]
 name      = geompy.SubShapeName( sub_face1, mechanic )
 
 Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name )
 
-# ---- add a face sub shape in study to be meshed different
+# ---- add a face sub-shape in study to be meshed different
 sub_face2 = SubFaceL[4]
 name      = geompy.SubShapeName( sub_face2, mechanic )
 
 Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name )
 
-# ---- add a face sub shape in study to be meshed different
+# ---- add a face sub-shape in study to be meshed different
 sub_face3 = SubFaceL[5]
 name      = geompy.SubShapeName( sub_face3, mechanic )
 
 Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name )
 
-# ---- add a face sub shape in study to be meshed different
+# ---- add a face sub-shape in study to be meshed different
 sub_face4 = SubFaceL[10]
 name      = geompy.SubShapeName( sub_face4, mechanic )
 
@@ -189,41 +197,41 @@ print "Number of tetrahedrons: ", mesh.NbTetras()
 mesh.SplitQuadObject(submesh2, 1)
 
 #2 cutting of triangles of the group
-FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422]
-GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad)
-mesh.TriToQuadObject(GroupTriToQuad, None , 1.57)
+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)
 
 #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)