Salome HOME
sources v1.2
[modules/geom.git] / src / GEOM_SWIG / GEOM_moteur.py
1 #  GEOM GEOM_SWIG : binding of C++ omplementaion with Python
2 #
3 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5
6 #  This library is free software; you can redistribute it and/or 
7 #  modify it under the terms of the GNU Lesser General Public 
8 #  License as published by the Free Software Foundation; either 
9 #  version 2.1 of the License. 
10
11 #  This library is distributed in the hope that it will be useful, 
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 #  Lesser General Public License for more details. 
15
16 #  You should have received a copy of the GNU Lesser General Public 
17 #  License along with this library; if not, write to the Free Software 
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19
20 #  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 #
22 #
23 #
24 #  File   : GEOM_moteur.py
25 #  Author : Damien COQUERET, Open CASCADE
26 #  Module : GEOM
27 #  $Header$
28
29 import salome
30 import geompy
31 import math
32
33 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
34 myBuilder = salome.myStudy.NewBuilder()
35
36 #Variables modifiables
37 PosX = 0          #Position du cylindre dans l'espace
38 PosY = 0          #Il est oriente suivant Z
39 PosZ = 0
40 NbBranches = 7    #>2
41 HauteurT = 70     #Hauteur total du stator
42
43 #Varaibles
44 Angle1 = 2 * math.pi / NbBranches
45 Angle2 = Angle1 / 2
46 HauteurR = HauteurT / 3
47 Ep = HauteurT / 10
48 DExtExt = HauteurT * 6 / 7
49 DExtInt = DExtExt - Ep
50 DIntExt = DExtExt / 3
51 DIntInt = DExtExt / 4
52 EpRot = DIntExt * math.sin(Angle2)
53 Pos1C = PosX + DIntExt * math.cos(Angle2)
54 Pos1S = PosY + DIntExt * math.sin(Angle2)
55 PosCour = PosZ + HauteurT * 4 / 7
56 PosRot = PosZ + 0.9 * HauteurT
57
58 #Points
59 P0 = geom.MakePointStruct(0, 0, 1)
60 P1 = geom.MakePointStruct(PosX, PosY, PosZ)
61 P2 = geom.MakePointStruct(PosX, PosY, PosZ + Ep)
62 P3 = geom.MakePointStruct(PosX, PosY, PosCour)
63 P4 = geom.MakePointStruct(PosX, PosY, PosCour + Ep)
64 P5 = geom.MakePointStruct(PosX, PosY, PosRot)
65 P6 = geom.MakePointStruct(Pos1C, Pos1S, PosZ)
66 P7 = geom.MakePointStruct(PosX + DExtExt, Pos1S, PosZ)
67 P8 = geom.MakePointStruct(Pos1C, Pos1S, PosZ + HauteurT)
68
69 #Vecteurs
70 V1 = geom.MakeDirection(P0)
71 V2 = geom.MakeAxisStruct(PosX, PosY, PosZ, 0, 0, 1)
72 V3 = geom.MakeAxisStruct(Pos1C, Pos1S, PosZ, 0, 0, 1)
73
74 #Cylindre central
75 C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
76 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
77 Cylindre = geompy.MakeBoolean(C01, C0, 2)
78 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
79
80 #Camemberts de coupe
81 B1 = geompy.MakeVector(P6, P7)
82 B2 = geompy.MakePrism(B1, P6, P8)
83 S0 = geompy.MakeRevolution(B2, V3, Angle1)
84 CoupeList = []
85 CoupeList.append(S0)
86 Ind = 1
87 while Ind < NbBranches :
88       S = geompy.MakeRotation(S0, V2, Ind * Angle1)
89       CoupeList.append(S)
90       Ind = Ind + 1
91 IorCoupeList = []
92 for CoupeShape in CoupeList :
93     IorCoupeList.append(CoupeShape._get_Name())
94 Coupe1 = geompy.MakeCompound(IorCoupeList)
95 #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
96
97 #Couronne1
98 C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
99 C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
100 C3 = geompy.MakeBoolean(C1, C2, 2)
101 C31 = geompy.MakeBoolean(C3, C0, 2)
102 Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
103 #Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
104
105 #Couronne2
106 C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
107 C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
108 Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
109 C6 = geompy.MakeBoolean(C4, C5, 2)
110 C61 = geompy.MakeBoolean(C6, C0, 2)
111 Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
112 #Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
113
114 #Rotor1
115 C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
116 C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
117 Rotor1List = []
118 Rotor1List.append(C9)
119 Rotor1List.append(C10)
120 IorRotor1List = []
121 for Rotor1Shape in Rotor1List :
122     IorRotor1List.append(Rotor1Shape._get_Name())
123 Rotor1 = geompy.MakeCompound(IorRotor1List)
124 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
125
126 #Rotor2
127 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
128 Rotor2List = []
129 Rotor2List.append(D0)
130 Ind = 1
131 while Ind < NbBranches :
132       R = geompy.MakeRotation(D0, V2, Ind * Angle1)
133       Rotor2List.append(R)
134       Ind = Ind + 1
135 IorRotor2List = []
136 for Rotor2Shape in Rotor2List :
137     IorRotor2List.append(Rotor2Shape._get_Name())
138 Rotor2 = geompy.MakeCompound(IorRotor2List)
139 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
140
141 #Rotor3
142 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
143 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
144
145 #Stator
146 StatorList = []
147 StatorList.append(Cylindre)
148 StatorList.append(Couronne1)
149 StatorList.append(Couronne2)
150 IorStatorList = []
151 for StatorShape in StatorList :
152     IorStatorList.append(StatorShape._get_Name())
153 Stator = geompy.MakeCompound(IorStatorList)
154 Id_Stator = geompy.addToStudy(Stator, "Stator")