Salome HOME
Implementation of gluing faces by given list (for PAL13191).
[modules/geom.git] / src / GEOM_SWIG / PAL_MESH_028_geometry.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
4 #  This library is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU Lesser General Public
6 #  License as published by the Free Software Foundation; either
7 #  version 2.1 of the License.
8 #
9 #  This library is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 #  Lesser General Public License for more details.
13 #
14 #  You should have received a copy of the GNU Lesser General Public
15 #  License along with this library; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 #####################################################################
21 #Created                :17/02/2005
22 #Auhtor                 :KOVALTCHUK Alexey 
23 #GUI test scenario      :PAL-MESH-028 (geometry part)
24 #####################################################################
25
26 import geompy
27 import salome
28 import os
29
30 #Initialization
31 salome.salome_init(1)
32
33 #Points construction (2.1)
34 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)]
35 for i in range(0, len(Vertices)):
36     name = "Vertex_" + str(i+1)
37     geompy.addToStudy(Vertices[i], name)
38
39 #Edges construction (3.1)
40 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])]
41 for i in range(0, len(Edges)):
42     name = "Edge_" + str(i+1)
43     geompy.addToStudy(Edges[i], name)
44
45 #Wires construction (4.1)
46 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]])]
47 for i in range(0, len(Wires)):
48     name = "Wire_" + str(i+1)
49     geompy.addToStudy(Wires[i], name)
50
51 #Faces construction (5.1)
52 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)]
53 for i in range(0, len(Faces)):
54     name = "Face_" + str(i+1)
55     geompy.addToStudy(Faces[i], name)
56
57 #Shell construction (6.1)
58 Shell_1 = geompy.MakeShell(Faces)
59 geompy.addToStudy(Shell_1, "Shell_1")
60 Shells = [Shell_1]
61
62 #Solid construction (7.1)
63 Solid_1 = geompy.MakeSolid(Shells)
64 geompy.addToStudy(Solid_1, "Solid_1")
65
66 #Prism construction (8.1)
67 Prism_1 = geompy.MakePrismVecH(Faces[4], Edges[1], 100)
68 geompy.addToStudy(Prism_1, "Prism_1")
69
70 #Save Study (9.1)
71 theHomePath = os.getenv("HOME")
72 theFilenameToSave = theHomePath + "/Pyramid.hdf"
73 if os.access(theFilenameToSave, os.F_OK):
74     if os.access(theFilenameToSave, os.W_OK):
75         os.remove(theFilenameToSave)
76         salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
77     else:
78         print "You have no enough permissions to overwrite HDF file: ",theFilenameToSave
79 else:
80     salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
81     
82
83 salome.sg.updateObjBrowser(1)