Salome HOME
0c52a7e9427cf5310aa520c255f01e0eac2ed6ee
[modules/geom.git] / src / GEOM_SWIG / PAL_MESH_028_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                :17/02/2005
24 #Auhtor                 :KOVALTCHUK Alexey 
25 #GUI test scenario      :PAL-MESH-028 (geometry part)
26 #####################################################################
27 #
28 import geompy
29 import salome
30 import os
31
32 #Initialization
33 salome.salome_init(1)
34
35 #Points construction (2.1)
36 Vertices = [geompy.MakeVertex(0, 0, 0), geompy.MakeVertex(200, 0, 0), geompy.MakeVertex(200, 200, 0), geompy.MakeVertex(0, 200, 0), geompy.MakeVertex(50, 50, 200), geompy.MakeVertex(150, 50, 200), geompy.MakeVertex(150, 150, 200), geompy.MakeVertex(50, 150, 200)]
37 for i in range(0, len(Vertices)):
38     name = "Vertex_" + str(i+1)
39     geompy.addToStudy(Vertices[i], name)
40
41 #Edges construction (3.1)
42 Edges = [geompy.MakeEdge(Vertices[0], Vertices[1]), geompy.MakeEdge(Vertices[1], Vertices[5]), geompy.MakeEdge(Vertices[5], Vertices[4]), geompy.MakeEdge(Vertices[4], Vertices[0]), geompy.MakeEdge(Vertices[1], Vertices[2]), geompy.MakeEdge(Vertices[2], Vertices[6]), geompy.MakeEdge(Vertices[6], Vertices[5]), geompy.MakeEdge(Vertices[2], Vertices[3]), geompy.MakeEdge(Vertices[3], Vertices[7]), geompy.MakeEdge(Vertices[7], Vertices[6]), geompy.MakeEdge(Vertices[3], Vertices[0]), geompy.MakeEdge(Vertices[4], Vertices[7])]
43 for i in range(0, len(Edges)):
44     name = "Edge_" + str(i+1)
45     geompy.addToStudy(Edges[i], name)
46
47 #Wires construction (4.1)
48 Wires = [geompy.MakeWire([Edges[0], Edges[1], Edges[2], Edges[3]]), geompy.MakeWire([Edges[1], Edges[4], Edges[5], Edges[6]]), geompy.MakeWire([Edges[5], Edges[7], Edges[8], Edges[9]]), geompy.MakeWire([Edges[3], Edges[10], Edges[8], Edges[11]]), geompy.MakeWire([Edges[2], Edges[6], Edges[9], Edges[11]]), geompy.MakeWire([Edges[0], Edges[4], Edges[7], Edges[10]])]
49 for i in range(0, len(Wires)):
50     name = "Wire_" + str(i+1)
51     geompy.addToStudy(Wires[i], name)
52
53 #Faces construction (5.1)
54 Faces = [geompy.MakeFace(Wires[0], 1), geompy.MakeFace(Wires[1], 1), geompy.MakeFace(Wires[2], 1), geompy.MakeFace(Wires[3], 1), geompy.MakeFace(Wires[4], 1), geompy.MakeFace(Wires[5], 1)]
55 for i in range(0, len(Faces)):
56     name = "Face_" + str(i+1)
57     geompy.addToStudy(Faces[i], name)
58
59 #Shell construction (6.1)
60 Shell_1 = geompy.MakeShell(Faces)
61 geompy.addToStudy(Shell_1, "Shell_1")
62 Shells = [Shell_1]
63
64 #Solid construction (7.1)
65 Solid_1 = geompy.MakeSolid(Shells)
66 geompy.addToStudy(Solid_1, "Solid_1")
67
68 #Prism construction (8.1)
69 Prism_1 = geompy.MakePrismVecH(Faces[4], Edges[1], 100)
70 geompy.addToStudy(Prism_1, "Prism_1")
71
72 #Save Study (9.1)
73 theHomePath = os.getenv("HOME")
74 theFilenameToSave = theHomePath + "/Pyramid.hdf"
75 if os.access(theFilenameToSave, os.F_OK):
76     if os.access(theFilenameToSave, os.W_OK):
77         os.remove(theFilenameToSave)
78         salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
79     else:
80         print "You have no enough permissions to overwrite HDF file: ",theFilenameToSave
81 else:
82     salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
83     
84
85 salome.sg.updateObjBrowser(1)