Salome HOME
3c879fd83a93e174d6fa63d7634204d6bc9cce58
[modules/geom.git] / src / GEOM_SWIG / GEOM_moteur.py
1 #==============================================================================
2 #  File      : GEOM_moteur.py
3 #  Created   : mon feb 18 11:55:00 CET 2002
4 #  Author    : Damien COQUERET, Open CASCADE
5 #  Project   : SALOME
6 #  Copyright : Open CASCADE, 2002
7 #  $Header$
8 #==============================================================================
9
10 import salome
11 import geompy
12 import math
13
14 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
15 myBuilder = salome.myStudy.NewBuilder()
16
17 #Variables modifiables
18 PosX = 0          #Position du cylindre dans l'espace
19 PosY = 0          #Il est oriente suivant Z
20 PosZ = 0
21 NbBranches = 7    #>2
22 HauteurT = 70     #Hauteur total du stator
23
24 #Varaibles
25 Angle1 = 2 * math.pi / NbBranches
26 Angle2 = Angle1 / 2
27 HauteurR = HauteurT / 3
28 Ep = HauteurT / 10
29 DExtExt = HauteurT * 6 / 7
30 DExtInt = DExtExt - Ep
31 DIntExt = DExtExt / 3
32 DIntInt = DExtExt / 4
33 EpRot = DIntExt * math.sin(Angle2)
34 Pos1C = PosX + DIntExt * math.cos(Angle2)
35 Pos1S = PosY + DIntExt * math.sin(Angle2)
36 PosCour = PosZ + HauteurT * 4 / 7
37 PosRot = PosZ + 0.9 * HauteurT
38
39 #Points
40 P0 = geom.MakePointStruct(0, 0, 1)
41 P1 = geom.MakePointStruct(PosX, PosY, PosZ)
42 P2 = geom.MakePointStruct(PosX, PosY, PosZ + Ep)
43 P3 = geom.MakePointStruct(PosX, PosY, PosCour)
44 P4 = geom.MakePointStruct(PosX, PosY, PosCour + Ep)
45 P5 = geom.MakePointStruct(PosX, PosY, PosRot)
46 P6 = geom.MakePointStruct(Pos1C, Pos1S, PosZ)
47 P7 = geom.MakePointStruct(PosX + DExtExt, Pos1S, PosZ)
48 P8 = geom.MakePointStruct(Pos1C, Pos1S, PosZ + HauteurT)
49
50 #Vecteurs
51 V1 = geom.MakeDirection(P0)
52 V2 = geom.MakeAxisStruct(PosX, PosY, PosZ, 0, 0, 1)
53 V3 = geom.MakeAxisStruct(Pos1C, Pos1S, PosZ, 0, 0, 1)
54
55 #Cylindre central
56 C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
57 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
58 Cylindre = geompy.MakeBoolean(C01, C0, 2)
59 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
60
61 #Camemberts de coupe
62 B1 = geompy.MakeVector(P6, P7)
63 B2 = geompy.MakePrism(B1, P6, P8)
64 S0 = geompy.MakeRevolution(B2, V3, Angle1)
65 CoupeList = []
66 CoupeList.append(S0)
67 Ind = 1
68 while Ind < NbBranches :
69       S = geompy.MakeRotation(S0, V2, Ind * Angle1)
70       CoupeList.append(S)
71       Ind = Ind + 1
72 IorCoupeList = []
73 for CoupeShape in CoupeList :
74     IorCoupeList.append(CoupeShape._get_Name())
75 Coupe1 = geompy.MakeCompound(IorCoupeList)
76 #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
77
78 #Couronne1
79 C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
80 C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
81 C3 = geompy.MakeBoolean(C1, C2, 2)
82 C31 = geompy.MakeBoolean(C3, C0, 2)
83 Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
84 #Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
85
86 #Couronne2
87 C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
88 C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
89 Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
90 C6 = geompy.MakeBoolean(C4, C5, 2)
91 C61 = geompy.MakeBoolean(C6, C0, 2)
92 Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
93 #Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
94
95 #Rotor1
96 C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
97 C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
98 Rotor1List = []
99 Rotor1List.append(C9)
100 Rotor1List.append(C10)
101 IorRotor1List = []
102 for Rotor1Shape in Rotor1List :
103     IorRotor1List.append(Rotor1Shape._get_Name())
104 Rotor1 = geompy.MakeCompound(IorRotor1List)
105 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
106
107 #Rotor2
108 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
109 Rotor2List = []
110 Rotor2List.append(D0)
111 Ind = 1
112 while Ind < NbBranches :
113       R = geompy.MakeRotation(D0, V2, Ind * Angle1)
114       Rotor2List.append(R)
115       Ind = Ind + 1
116 IorRotor2List = []
117 for Rotor2Shape in Rotor2List :
118     IorRotor2List.append(Rotor2Shape._get_Name())
119 Rotor2 = geompy.MakeCompound(IorRotor2List)
120 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
121
122 #Rotor3
123 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
124 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
125
126 #Stator
127 StatorList = []
128 StatorList.append(Cylindre)
129 StatorList.append(Couronne1)
130 StatorList.append(Couronne2)
131 IorStatorList = []
132 for StatorShape in StatorList :
133     IorStatorList.append(StatorShape._get_Name())
134 Stator = geompy.MakeCompound(IorStatorList)
135 Id_Stator = geompy.addToStudy(Stator, "Stator")