Back to index

salome-smesh  6.5.0
SMESH_test3.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 #  File   : SMESH_test3.py
00025 #  Module : SMESH
00026 #import salome
00027 #
00028 import math
00029 import geompy
00030 
00031 pi = math.pi
00032 
00033 # ---------------------------------------------
00034 xa = math.sin(pi/12)
00035 ya = 0
00036 za = math.cos(pi/12)
00037 
00038 xb = 0
00039 yb = math.sin(pi/18)
00040 zb = math.cos(pi/18)
00041 
00042 xc = math.cos(-pi/18)
00043 yc = 0
00044 zc = math.sin(-pi/18)
00045 
00046 rc1 = 150
00047 rc2 = 150
00048 rc3 = 150
00049 rc4 = 300
00050 
00051 hc1 = 300
00052 hc2 = 2*hc1
00053 hc3 = 2*hc1
00054 hc4 = 2*hc1
00055 
00056 # ---------------------------------------------
00057 point_0 = geompy.MakeVertex(0, 0, 0)
00058 point_z = geompy.MakeVertex(0, 0, 1)
00059 
00060 point_a = geompy.MakeVertex(xa, ya, za)
00061 point_b = geompy.MakeVertex(xb, yb, zb)
00062 point_c = geompy.MakeVertex(xc, yc, zc)
00063 
00064 dir_z = geompy.MakeVector(point_0, point_z)
00065 dir_a = geompy.MakeVector(point_0, point_a)
00066 dir_b = geompy.MakeVector(point_0, point_b)
00067 dir_c = geompy.MakeVector(point_0, point_c)
00068 
00069 axe_z = dir_z
00070 axe_a = dir_a
00071 axe_b = dir_b
00072 axe_c = dir_c
00073 
00074 cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1)
00075 
00076 cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2)
00077 cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1)
00078 
00079 cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3)
00080 cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1)
00081 
00082 cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4)
00083 cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2)
00084 cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0)
00085 cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4)
00086 
00087 inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common
00088 
00089 blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut
00090 blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2)
00091 
00092 blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common
00093 
00094 idblob = geompy.addToStudy(blob,"blob")
00095 #idc = geompy.addToStudy(cyl_c,"cyl_c")
00096 #idd = geompy.addToStudy(cyl_d,"cyl_d")