1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
23 # File : GEOM_moteur.py
24 # Author : Damien COQUERET, Open CASCADE
32 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
33 myBuilder = salome.myStudy.NewBuilder()
35 #Variables modifiables
36 PosX = 0 #Position du cylindre dans l'espace
37 PosY = 0 #Il est oriente suivant Z
40 HauteurT = 70 #Hauteur total du stator
43 Angle1 = 2 * math.pi / NbBranches
45 HauteurR = HauteurT / 3
47 DExtExt = HauteurT * 6 / 7
48 DExtInt = DExtExt - Ep
51 EpRot = DIntExt * math.sin(Angle2)
52 Pos1C = PosX + DIntExt * math.cos(Angle2)
53 Pos1S = PosY + DIntExt * math.sin(Angle2)
54 PosCour = PosZ + HauteurT * 4 / 7
55 PosRot = PosZ + 0.9 * HauteurT
58 BasicOp = geom.GetIBasicOperations(salome.myStudyId)
59 OO = BasicOp.MakePointXYZ(0, 0, 0)
60 P0 = BasicOp.MakePointXYZ(0, 0, 1)
61 P1 = BasicOp.MakePointXYZ(PosX, PosY, PosZ)
62 P2 = BasicOp.MakePointXYZ(PosX, PosY, PosZ + Ep)
63 P3 = BasicOp.MakePointXYZ(PosX, PosY, PosCour)
64 P4 = BasicOp.MakePointXYZ(PosX, PosY, PosCour + Ep)
65 P5 = BasicOp.MakePointXYZ(PosX, PosY, PosRot)
66 P6 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ)
67 P7 = BasicOp.MakePointXYZ(PosX + DExtExt, Pos1S, PosZ)
68 P8 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ + HauteurT)
71 V1 = BasicOp.MakeVectorTwoPnt(OO,P0)
72 V2 = BasicOp.MakeVectorTwoPnt(P1,P2)
73 V3 = BasicOp.MakeVectorTwoPnt(P6,P8)
76 C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
77 C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
78 Cylindre = geompy.MakeBoolean(C01, C0, 2)
79 #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
82 B1 = BasicOp.MakeVectorTwoPnt(P6, P7)
83 B2 = geompy.MakePrismVecH(B1, V1, HauteurT)
84 S0 = geompy.MakeRevolution(B2, V3, Angle1)
88 while Ind < NbBranches :
89 S = geompy.MakeRotation(S0, V2, Ind * Angle1)
92 Coupe1 = geompy.MakeCompound(CoupeList)
93 #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
96 C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
97 C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
98 C3 = geompy.MakeBoolean(C1, C2, 2)
99 C31 = geompy.MakeBoolean(C3, C0, 2)
100 Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
101 #Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
104 C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
105 C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
106 Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
107 C6 = geompy.MakeBoolean(C4, C5, 2)
108 C61 = geompy.MakeBoolean(C6, C0, 2)
109 Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
110 #Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
113 C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
114 C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
116 Rotor1List.append(C9)
117 Rotor1List.append(C10)
118 Rotor1 = geompy.MakeCompound(Rotor1List)
119 Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
122 D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
124 Rotor2List.append(D0)
126 while Ind < NbBranches :
127 R = geompy.MakeRotation(D0, V2, Ind * Angle1)
130 Rotor2 = geompy.MakeCompound(Rotor2List)
131 Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
134 Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
135 Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
139 StatorList.append(Cylindre)
140 StatorList.append(Couronne1)
141 StatorList.append(Couronne2)
142 Stator = geompy.MakeCompound(StatorList)
143 Id_Stator = geompy.addToStudy(Stator, "Stator")