Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / src / GEOM_SWIG / PAL_MESH_035_geometry.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 #####################################################################
23 #Created                :15/02/2005
24 #Auhtor                 :KOVALTCHUK Alexey 
25 #GUI test scenario      :PAL-MESH-035 (geometry part)
26 #####################################################################
27 #
28 import geompy
29 import salome
30
31 #Box creation (2.2)
32 Box_1 = geompy.MakeBoxDXDYDZ(200, 400, 300)
33 geompy.addToStudy(Box_1, "Box_1")
34
35 #Cylinder creation (2.8)
36 Cylinder_1 = geompy.MakeCylinderRH(100, 300)
37 geompy.addToStudy(Cylinder_1, "Cylinder_1")
38
39 #Cone creation (2.13)
40 Cone_1 = geompy.MakeConeR1R2H(100, 50, 200)
41 geompy.addToStudy(Cone_1, "Cone_1")
42
43 #Explode box, cone and cylinder on faces and vertices(2.18)
44 ListOfFaces_Box_1 = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
45 NbExplodedFaces_Box_1 = len(ListOfFaces_Box_1)
46 for i in range (0, NbExplodedFaces_Box_1):
47    name = "Face_" + str(i+1)
48    geompy.addToStudyInFather(Box_1, ListOfFaces_Box_1[i], name)
49
50 ListOfVertices_Box_1 = geompy.SubShapeAll(Box_1, geompy.ShapeType["VERTEX"])
51 NbExplodedVertices_Box_1 = len(ListOfVertices_Box_1)
52 for i in range (0, NbExplodedVertices_Box_1):
53    name = "Vertex_" + str(i+1)
54    geompy.addToStudyInFather(Box_1, ListOfVertices_Box_1[i], name)
55    
56 ListOfFaces_Cylinder_1 = geompy.SubShapeAll(Cylinder_1, geompy.ShapeType["FACE"])
57 NbExplodedFaces_Cylinder_1 = len(ListOfFaces_Cylinder_1)
58 for i in range (0, NbExplodedFaces_Cylinder_1):
59    name = "Face_" + str(NbExplodedFaces_Box_1+i+1)
60    geompy.addToStudyInFather(Cylinder_1, ListOfFaces_Cylinder_1[i], name)
61    
62 ListOfFaces_Cone_1 = geompy.SubShapeAll(Cone_1, geompy.ShapeType["FACE"])
63 NbExplodedFaces_Cone_1 = len(ListOfFaces_Cone_1)
64 for i in range (0, NbExplodedFaces_Cone_1):
65    name = "Face_" + str(NbExplodedFaces_Box_1+NbExplodedFaces_Cylinder_1+i+1)
66    geompy.addToStudyInFather(Cone_1, ListOfFaces_Cone_1[i], name)
67    
68 #Plane creation (2.32)
69 Plane_1 = geompy.MakePlaneThreePnt(ListOfVertices_Box_1[0], ListOfVertices_Box_1[1], ListOfVertices_Box_1[3], 600)
70 geompy.addToStudy(Plane_1, "Plane_1")
71
72 #Partition (2.32)
73 compound = geompy.MakeCompound([ListOfFaces_Cylinder_1[0], ListOfFaces_Cone_1[0]])
74 Partition_1 = geompy.MakeHalfPartition(compound, Plane_1)
75 geompy.addToStudy(Partition_1, "Partition_1")
76
77 #Explode partition on faces and vertices(2.38)
78 ListOfFaces_Partition_1 = geompy.SubShapeAll(Partition_1, geompy.ShapeType["FACE"])
79 NbExplodedFaces_Partition_1 = len(ListOfFaces_Partition_1)
80 for i in range (0, NbExplodedFaces_Partition_1):
81    name = "Face_" + str(NbExplodedFaces_Box_1+NbExplodedFaces_Cylinder_1+NbExplodedFaces_Cone_1+i+1)
82    geompy.addToStudyInFather(Partition_1, ListOfFaces_Partition_1[i], name)
83
84 #Explode faces on vertices(2.43)
85 ListOfVertices_Face_7 = geompy.SubShapeAll(ListOfFaces_Cylinder_1[0], geompy.ShapeType["VERTEX"])
86 NbExplodedVertices_Face_7 = len(ListOfVertices_Face_7)
87 for i in range (0, NbExplodedVertices_Face_7):
88    name = "Vertex_" + str(NbExplodedVertices_Box_1+i+1)
89    geompy.addToStudyInFather(ListOfFaces_Cylinder_1[0], ListOfVertices_Face_7[i], name)
90
91 ListOfVertices_Face_10 = geompy.SubShapeAll(ListOfFaces_Cone_1[0], geompy.ShapeType["VERTEX"])
92 NbExplodedVertices_Face_10 = len(ListOfVertices_Face_10)
93 for i in range (0, NbExplodedVertices_Face_10):
94    name = "Vertex_" + str(NbExplodedVertices_Box_1+NbExplodedVertices_Face_7+i+1)
95    geompy.addToStudyInFather(ListOfFaces_Cone_1[0], ListOfVertices_Face_10[i], name)
96
97 ListOfVertices_Face_15 = geompy.SubShapeAll(ListOfFaces_Partition_1[2], geompy.ShapeType["VERTEX"])
98 NbExplodedVertices_Face_15 = len(ListOfVertices_Face_15)
99 for i in range (0, NbExplodedVertices_Face_15):
100    name = "Vertex_" + str(NbExplodedVertices_Box_1+NbExplodedVertices_Face_7+NbExplodedVertices_Face_10+i+1)
101    geompy.addToStudyInFather(ListOfFaces_Partition_1[2], ListOfVertices_Face_15[i], name)
102
103 ListOfVertices_Face_18 = geompy.SubShapeAll(ListOfFaces_Partition_1[NbExplodedFaces_Partition_1-1], geompy.ShapeType["VERTEX"])
104 NbExplodedVertices_Face_18 = len(ListOfVertices_Face_18)
105 for i in range (0, NbExplodedVertices_Face_18):
106    name = "Vertex_" + str(NbExplodedVertices_Box_1+NbExplodedVertices_Face_7+NbExplodedVertices_Face_10+NbExplodedVertices_Face_15+i+1)
107    geompy.addToStudyInFather(ListOfFaces_Partition_1[NbExplodedFaces_Partition_1-1], ListOfVertices_Face_18[i], name)
108
109 salome.sg.updateObjBrowser(1)