Salome HOME
Mantis issues 0021432 and 0021404: MakeFace[Wires] should generate exception on attem...
[modules/geom.git] / src / GEOM_SWIG / GEOM_moteur.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2011  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.
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++ omplementaion with Python
25 #  File   : GEOM_moteur.py
26 #  Author : Damien COQUERET, Open CASCADE
27 #  Module : GEOM
28 #  $Header$
29 #
30 import salome
31 import geompy
32 import math
33
34 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
35 myBuilder = salome.myStudy.NewBuilder()
36
37 #Variables modifiables
38 PosX = 0          #Position du cylindre dans l'espace
39 PosY = 0          #Il est oriente suivant Z
40 PosZ = 0
41 NbBranches = 7    #>2
42 HauteurT = 70     #Hauteur total du stator
43
44 #Variables
45 Angle1 = 2 * math.pi / NbBranches
46 Angle2 = Angle1 / 2
47 HauteurR = HauteurT / 3
48 Ep = HauteurT / 10
49 DExtExt = HauteurT * 6 / 7
50 DExtInt = DExtExt - Ep
51 DIntExt = DExtExt / 3
52 DIntInt = DExtExt / 4
53 EpRot = DIntExt * math.sin(Angle2)
54 Pos1C = PosX + DIntExt * math.cos(Angle2)
55 Pos1S = PosY + DIntExt * math.sin(Angle2)
56 PosCour = PosZ + HauteurT * 4 / 7
57 PosRot = PosZ + 0.9 * HauteurT
58
59 #Points
60 BasicOp = geom.GetIBasicOperations(salome.myStudyId)
61 OO = BasicOp.MakePointXYZ(0, 0, 0)
62 P0 = BasicOp.MakePointXYZ(0, 0, 1)
63 P1 = BasicOp.MakePointXYZ(PosX, PosY, PosZ)
64 P2 = BasicOp.MakePointXYZ(PosX, PosY, PosZ + Ep)
65 P3 = BasicOp.MakePointXYZ(PosX, PosY, PosCour)
66 P4 = BasicOp.MakePointXYZ(PosX, PosY, PosCour + Ep)
67 P5 = BasicOp.MakePointXYZ(PosX, PosY, PosRot)
68 P6 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ)
69 P7 = BasicOp.MakePointXYZ(PosX + DExtExt, Pos1S, PosZ)
70 P8 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ + HauteurT)
71
72 #Vecteurs
73 V1 = BasicOp.MakeVectorTwoPnt(OO,P0)
74 V2 = BasicOp.MakeVectorTwoPnt(P1,P2)
75 V3 = BasicOp.MakeVectorTwoPnt(P6,P8)
76
77 #Cylindre central
78 C0  = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
79 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
80 Cylindre = geompy.MakeBoolean(C01, C0, 2)
81 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
82
83 #Camemberts de coupe
84 B1 = BasicOp.MakeVectorTwoPnt(P6, P7)
85 B2 = geompy.MakePrismVecH(B1, V1, HauteurT)
86 S0 = geompy.MakeRevolution(B2, V3, Angle1)
87 CoupeList = []
88 CoupeList.append(S0)
89 Ind = 1
90 while Ind < NbBranches :
91       S = geompy.MakeRotation(S0, V2, Ind * Angle1)
92       CoupeList.append(S)
93       Ind = Ind + 1
94 Coupe1 = geompy.MakeCompound(CoupeList)
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 Rotor1 = geompy.MakeCompound(Rotor1List)
121 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
122
123 #Rotor2
124 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
125 Rotor2List = []
126 Rotor2List.append(D0)
127 Ind = 1
128 while Ind < NbBranches :
129       R = geompy.MakeRotation(D0, V2, Ind * Angle1)
130       Rotor2List.append(R)
131       Ind = Ind + 1
132 Rotor2 = geompy.MakeCompound(Rotor2List)
133 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
134
135 #Rotor3
136 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
137 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
138
139 #Stator
140 StatorList = []
141 StatorList.append(Cylindre)
142 StatorList.append(Couronne1)
143 StatorList.append(Couronne2)
144 Stator = geompy.MakeCompound(StatorList)
145 Id_Stator = geompy.addToStudy(Stator, "Stator")