Salome HOME
a886735af71eba701d833dd535f6b9e2340c4779
[modules/geom.git] / src / GEOM_SWIG / GEOM_moteur.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 #  GEOM GEOM_SWIG : binding of C++ implementation with Python
25 #  File   : GEOM_moteur.py
26 #  Author : Damien COQUERET, Open CASCADE
27 #  Module : GEOM
28 #
29 import salome
30 salome.salome_init()
31 import GEOM
32 from salome.geom import geomBuilder
33 geompy = geomBuilder.New()
34 import math
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 #Variables
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 BasicOp = geompy.GetIBasicOperations()
60 OO = BasicOp.MakePointXYZ(0, 0, 0)
61 P0 = BasicOp.MakePointXYZ(0, 0, 1)
62 P1 = BasicOp.MakePointXYZ(PosX, PosY, PosZ)
63 P2 = BasicOp.MakePointXYZ(PosX, PosY, PosZ + Ep)
64 P3 = BasicOp.MakePointXYZ(PosX, PosY, PosCour)
65 P4 = BasicOp.MakePointXYZ(PosX, PosY, PosCour + Ep)
66 P5 = BasicOp.MakePointXYZ(PosX, PosY, PosRot)
67 P6 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ)
68 P7 = BasicOp.MakePointXYZ(PosX + DExtExt, Pos1S, PosZ)
69 P8 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ + HauteurT)
70
71 #Vecteurs
72 V1 = BasicOp.MakeVectorTwoPnt(OO,P0)
73 V2 = BasicOp.MakeVectorTwoPnt(P1,P2)
74 V3 = BasicOp.MakeVectorTwoPnt(P6,P8)
75
76 #Cylindre central
77 C0  = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
78 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
79 Cylindre = geompy.MakeBoolean(C01, C0, 2)
80 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
81
82 #Camemberts de coupe
83 B1 = BasicOp.MakeVectorTwoPnt(P6, P7)
84 B2 = geompy.MakePrismVecH(B1, V1, HauteurT)
85 S0 = geompy.MakeRevolution(B2, V3, Angle1)
86 CoupeList = []
87 CoupeList.append(S0)
88 Ind = 1
89 while Ind < NbBranches :
90       S = geompy.MakeRotation(S0, V2, Ind * Angle1)
91       CoupeList.append(S)
92       Ind = Ind + 1
93 Coupe1 = geompy.MakeCompound(CoupeList)
94 #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
95
96 #Couronne1
97 C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
98 C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
99 C3 = geompy.MakeBoolean(C1, C2, 2)
100 C31 = geompy.MakeBoolean(C3, C0, 2)
101 Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
102 #Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
103
104 #Couronne2
105 C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
106 C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
107 Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
108 C6 = geompy.MakeBoolean(C4, C5, 2)
109 C61 = geompy.MakeBoolean(C6, C0, 2)
110 Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
111 #Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
112
113 #Rotor1
114 C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
115 C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
116 Rotor1List = []
117 Rotor1List.append(C9)
118 Rotor1List.append(C10)
119 Rotor1 = geompy.MakeCompound(Rotor1List)
120 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
121
122 #Rotor2
123 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
124 Rotor2List = []
125 Rotor2List.append(D0)
126 Ind = 1
127 while Ind < NbBranches :
128       R = geompy.MakeRotation(D0, V2, Ind * Angle1)
129       Rotor2List.append(R)
130       Ind = Ind + 1
131 Rotor2 = geompy.MakeCompound(Rotor2List)
132 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
133
134 #Rotor3
135 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
136 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
137
138 #Stator
139 StatorList = []
140 StatorList.append(Cylindre)
141 StatorList.append(Couronne1)
142 StatorList.append(Couronne2)
143 Stator = geompy.MakeCompound(StatorList)
144 Id_Stator = geompy.addToStudy(Stator, "Stator")