Back to index

salome-geom  6.5.0
GEOM_example4.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 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
00025 #  File   : GEOM_example4.py
00026 #  Module : GEOM
00027 #import SMESH
00028 #import smeshpy
00029 #
00030 import salome
00031 from salome import sg
00032 import math
00033 
00034 import geompy
00035 
00036 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
00037 myBuilder = salome.myStudy.NewBuilder()
00038 #from geompy import gg
00039 
00040 #smeshgui = salome.ImportComponentGUI("SMESH")
00041 #smeshgui.Init(salome.myStudyId);
00042 
00043 ShapeTypeCompSolid = 1
00044 ShapeTypeSolid = 2
00045 ShapeTypeShell = 3
00046 ShapeTypeFace = 4
00047 ShapeTypeWire = 5
00048 ShapeTypeEdge = 6
00049 ShapeTypeVertex = 7
00050 
00051 pi=math.pi
00052 
00053 # ---------------------------------------------
00054 xa=math.sin(pi/12)
00055 ya=0
00056 za=math.cos(pi/12)
00057 
00058 xb=0
00059 yb=math.sin(pi/18)
00060 zb=math.cos(pi/18)
00061 
00062 xc=math.cos(-pi/18)
00063 yc=0
00064 zc=math.sin(-pi/18)
00065 
00066 rc1=150
00067 hc1=300
00068 rc2=150
00069 rc3=150
00070 rc4=300
00071 # ---------------------------------------------
00072 point_0 = geompy.MakeVertex(0, 0, 0)
00073 point_z = geompy.MakeVertex(0, 0, 1)
00074 
00075 point_a = geompy.MakeVertex(xa, ya, za)
00076 point_b = geompy.MakeVertex(xb, yb, zb)
00077 point_c = geompy.MakeVertex(xc, yc, zc)
00078 
00079 dir_z = geompy.MakeVector(point_0,point_z)
00080 dir_a = geompy.MakeVector(point_0,point_a)
00081 dir_b = geompy.MakeVector(point_0,point_b)
00082 dir_c = geompy.MakeVector(point_0,point_c)
00083 
00084 cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1)
00085 
00086 hc2=2*hc1
00087 cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2)
00088 cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1)
00089 
00090 hc3=2*hc1
00091 cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3)
00092 cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1)
00093 
00094 hc4=2*hc1
00095 cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4)
00096 cyl_t = geompy.MakeRotation(cyl_t, dir_c, pi/2)
00097 cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0)
00098 cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4)
00099 
00100 inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common
00101 
00102 blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut
00103 blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2)
00104 
00105 blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common
00106 
00107 idblob = geompy.addToStudy(blob,"blob")
00108 #idc = geompy.addToStudy(cyl_c,"cyl_c")
00109 #idd = geompy.addToStudy(cyl_d,"cyl_d")