Back to index

salome-geom  6.5.0
GEOM_moteur.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_moteur.py
00026 #  Author : Damien COQUERET, Open CASCADE
00027 #  Module : GEOM
00028 #  $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOM_SWIG/GEOM_moteur.py,v 1.9.2.2.10.2.14.1 2012-04-13 05:48:08 vsr Exp $
00029 #
00030 import salome
00031 import geompy
00032 import math
00033 
00034 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
00035 myBuilder = salome.myStudy.NewBuilder()
00036 
00037 #Variables modifiables
00038 PosX = 0          #Position du cylindre dans l'espace
00039 PosY = 0          #Il est oriente suivant Z
00040 PosZ = 0
00041 NbBranches = 7    #>2
00042 HauteurT = 70     #Hauteur total du stator
00043 
00044 #Variables
00045 Angle1 = 2 * math.pi / NbBranches
00046 Angle2 = Angle1 / 2
00047 HauteurR = HauteurT / 3
00048 Ep = HauteurT / 10
00049 DExtExt = HauteurT * 6 / 7
00050 DExtInt = DExtExt - Ep
00051 DIntExt = DExtExt / 3
00052 DIntInt = DExtExt / 4
00053 EpRot = DIntExt * math.sin(Angle2)
00054 Pos1C = PosX + DIntExt * math.cos(Angle2)
00055 Pos1S = PosY + DIntExt * math.sin(Angle2)
00056 PosCour = PosZ + HauteurT * 4 / 7
00057 PosRot = PosZ + 0.9 * HauteurT
00058 
00059 #Points
00060 BasicOp = geom.GetIBasicOperations(salome.myStudyId)
00061 OO = BasicOp.MakePointXYZ(0, 0, 0)
00062 P0 = BasicOp.MakePointXYZ(0, 0, 1)
00063 P1 = BasicOp.MakePointXYZ(PosX, PosY, PosZ)
00064 P2 = BasicOp.MakePointXYZ(PosX, PosY, PosZ + Ep)
00065 P3 = BasicOp.MakePointXYZ(PosX, PosY, PosCour)
00066 P4 = BasicOp.MakePointXYZ(PosX, PosY, PosCour + Ep)
00067 P5 = BasicOp.MakePointXYZ(PosX, PosY, PosRot)
00068 P6 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ)
00069 P7 = BasicOp.MakePointXYZ(PosX + DExtExt, Pos1S, PosZ)
00070 P8 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ + HauteurT)
00071 
00072 #Vecteurs
00073 V1 = BasicOp.MakeVectorTwoPnt(OO,P0)
00074 V2 = BasicOp.MakeVectorTwoPnt(P1,P2)
00075 V3 = BasicOp.MakeVectorTwoPnt(P6,P8)
00076 
00077 #Cylindre central
00078 C0  = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
00079 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
00080 Cylindre = geompy.MakeBoolean(C01, C0, 2)
00081 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
00082 
00083 #Camemberts de coupe
00084 B1 = BasicOp.MakeVectorTwoPnt(P6, P7)
00085 B2 = geompy.MakePrismVecH(B1, V1, HauteurT)
00086 S0 = geompy.MakeRevolution(B2, V3, Angle1)
00087 CoupeList = []
00088 CoupeList.append(S0)
00089 Ind = 1
00090 while Ind < NbBranches :
00091       S = geompy.MakeRotation(S0, V2, Ind * Angle1)
00092       CoupeList.append(S)
00093       Ind = Ind + 1
00094 Coupe1 = geompy.MakeCompound(CoupeList)
00095 #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
00096 
00097 #Couronne1
00098 C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
00099 C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
00100 C3 = geompy.MakeBoolean(C1, C2, 2)
00101 C31 = geompy.MakeBoolean(C3, C0, 2)
00102 Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
00103 #Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
00104 
00105 #Couronne2
00106 C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
00107 C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
00108 Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
00109 C6 = geompy.MakeBoolean(C4, C5, 2)
00110 C61 = geompy.MakeBoolean(C6, C0, 2)
00111 Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
00112 #Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
00113 
00114 #Rotor1
00115 C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
00116 C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
00117 Rotor1List = []
00118 Rotor1List.append(C9)
00119 Rotor1List.append(C10)
00120 Rotor1 = geompy.MakeCompound(Rotor1List)
00121 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
00122 
00123 #Rotor2
00124 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
00125 Rotor2List = []
00126 Rotor2List.append(D0)
00127 Ind = 1
00128 while Ind < NbBranches :
00129       R = geompy.MakeRotation(D0, V2, Ind * Angle1)
00130       Rotor2List.append(R)
00131       Ind = Ind + 1
00132 Rotor2 = geompy.MakeCompound(Rotor2List)
00133 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
00134 
00135 #Rotor3
00136 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
00137 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
00138 
00139 #Stator
00140 StatorList = []
00141 StatorList.append(Cylindre)
00142 StatorList.append(Couronne1)
00143 StatorList.append(Couronne2)
00144 Stator = geompy.MakeCompound(StatorList)
00145 Id_Stator = geompy.addToStudy(Stator, "Stator")