Back to index

salome-geom  6.5.0
PAL_MESH_028_geometry.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #####################################################################
00025 #Created                :17/02/2005
00026 #Auhtor                 :KOVALTCHUK Alexey 
00027 #GUI test scenario      :PAL-MESH-028 (geometry part)
00028 #####################################################################
00029 #
00030 import geompy
00031 import salome
00032 import os
00033 
00034 #Initialization
00035 salome.salome_init(1)
00036 
00037 #Points construction (2.1)
00038 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)]
00039 for i in range(0, len(Vertices)):
00040     name = "Vertex_" + str(i+1)
00041     geompy.addToStudy(Vertices[i], name)
00042 
00043 #Edges construction (3.1)
00044 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])]
00045 for i in range(0, len(Edges)):
00046     name = "Edge_" + str(i+1)
00047     geompy.addToStudy(Edges[i], name)
00048 
00049 #Wires construction (4.1)
00050 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]])]
00051 for i in range(0, len(Wires)):
00052     name = "Wire_" + str(i+1)
00053     geompy.addToStudy(Wires[i], name)
00054 
00055 #Faces construction (5.1)
00056 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)]
00057 for i in range(0, len(Faces)):
00058     name = "Face_" + str(i+1)
00059     geompy.addToStudy(Faces[i], name)
00060 
00061 #Shell construction (6.1)
00062 Shell_1 = geompy.MakeShell(Faces)
00063 geompy.addToStudy(Shell_1, "Shell_1")
00064 Shells = [Shell_1]
00065 
00066 #Solid construction (7.1)
00067 Solid_1 = geompy.MakeSolid(Shells)
00068 geompy.addToStudy(Solid_1, "Solid_1")
00069 
00070 #Prism construction (8.1)
00071 Prism_1 = geompy.MakePrismVecH(Faces[4], Edges[1], 100)
00072 geompy.addToStudy(Prism_1, "Prism_1")
00073 
00074 #Save Study (9.1)
00075 theHomePath = os.getenv("HOME")
00076 theFilenameToSave = theHomePath + "/Pyramid.hdf"
00077 if os.access(theFilenameToSave, os.F_OK):
00078     if os.access(theFilenameToSave, os.W_OK):
00079         os.remove(theFilenameToSave)
00080         salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
00081     else:
00082         print "You have no enough permissions to overwrite HDF file: ",theFilenameToSave
00083 else:
00084     salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0)
00085     
00086 
00087 salome.sg.updateObjBrowser(1)