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