1 #==============================================================================
2 # File : GEOM_usinggeom.py
3 # Created : mon apr 22 11:55:00 CET 2002
4 # Author : Damien COQUERET, Open CASCADE
6 # Copyright : Open CASCADE, 2002
8 #==============================================================================
14 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
15 myBuilder = salome.myStudy.NewBuilder()
19 #Create base Variables
27 WantPlanarFace = 1 #True
38 angle1 = angle * math.pi / 180
45 meshingdeflection = 0.01
50 p0 = geom.MakePointStruct(0., 0., 0.) #(Double, Double, Double)->PointStruct
51 px = geom.MakePointStruct(100., 0., 0.)
52 py = geom.MakePointStruct(0., 100., 0.)
53 pz = geom.MakePointStruct(0., 0., 100.)
54 pxyz = geom.MakePointStruct(100., 100., 100.)
56 #Create base directions
57 vx = geom.MakeDirection(px) #(PointStruct)->DirStruct
58 vy = geom.MakeDirection(py)
59 vz = geom.MakeDirection(pz)
60 vxyz = geom.MakeDirection(pxyz)
61 ax = geom.MakeAxisStruct(0., 0., 0., 100., 0., 0.) #(Double, Double, Double, Double, Double, Double)->AxisStruct
62 axy = geom.MakeAxisStruct(100., 0., 0., -100., 100., 0.)
63 ay = geom.MakeAxisStruct(0., 0., 0., 0., 100., 0.)
64 az = geom.MakeAxisStruct(0., 0., 0., 0., 0., 100.)
66 #Create base geometry 2D
67 Vertex = geom.MakeVertex(100., 50., 200.) #(Double, Double, Double)->GEOM_Shape_ptr
68 Vector = geom.MakeVector(px, py) #(PointStruct, PointStruct)->GEOM_Shape_ptr
69 Line = geom.MakeLine(p0, vxyz) #(PointStruct, DirStruct)->GEOM_Shape_ptr
70 Arc = geom.MakeArc(py, pz, px) #(PointStruct, PointStruct, PointStruct)->GEOM_Shape_ptr
71 Circle = geom.MakeCircle(p0, vz, radius1) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr
72 Plane = geom.MakePlane(pz, vxyz, trimsize) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr
74 #Create base geometry 3D
75 Box = geompy.MakeBox(0., 0., 0., 200., 200., 200.) #(Double, Double, Double)->GEOM_Shape_ptr
76 Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(Double, Double, Double)->GEOM_Shape_ptr
77 Sphere = geompy.MakeSphere(0., 0., 0., radius1) #(Double, Double, Double)->GEOM_Shape_ptr
78 Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(PointStruct)->DirStruct
79 Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(Double, Double, Double)->GEOM_Shape_ptr
81 #Boolean (Common, Cut, Fuse, Section)
82 Common = geompy.MakeBoolean(Box, Sphere, 1) #(GEOM_Shape_ptr, GEOM_Shape_ptr, Short)->GEOM_Shape_ptr
83 Cut = geompy.MakeBoolean(Box, Sphere, 2)
84 Fuse = geompy.MakeBoolean(Box, Sphere, 3)
85 Section = geompy.MakeBoolean(Box, Sphere, 4)
90 ShapeListWire.append(Vector)
91 ShapeListWire.append(Arc)
92 for Shape in ShapeListWire :
93 IORListWire.append(Shape._get_Name())
96 ShapeListCompound = []
100 S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.)
101 ShapeListCompound.append(S)
103 for Shape in ShapeListCompound :
104 IORListCompound.append(Shape._get_Name())
107 Edge = geompy.MakeEdge(p0, pxyz) #(PointStruct, PointStruct)->GEOM_Shape_ptr
108 Wire = geompy.MakeWire(IORListWire) #(ListOfIOR)->GEOM_Shape_ptr
109 Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Shape_ptr, Boolean)->GEOM_Shape_ptr
110 Compound = geompy.MakeCompound(IORListCompound) #(ListOfIOR)->GEOM_Shape_ptr
115 ShapeListSewing.append(Face)
116 S = geompy.MakeRotation(Face, axy, angle1)
117 ShapeListSewing.append(S)
118 for Shape in ShapeListSewing :
119 IORListSewing.append(Shape._get_Name())
121 #Create advanced objects
122 Copy = geompy.MakeCopy(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
123 Prism = geompy.MakePrism(Face, p0, pz) #(GEOM_Shape_ptr, PointStruct, PointStruct)->GEOM_Shape_ptr
124 Revolution = geompy.MakeRevolution(Face, az, angle2) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr
125 Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, tol3d, tol2d, nbiter) #(GEOM_Shape_ptr, Short, Short, Double, Double, Short)->GEOM_Shape_ptr
126 Pipe = geompy.MakePipe(Edge, Wire) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr
127 Sewing = geompy.MakeSewing(IORListSewing, precision) #(ListOfIOR, Double)->GEOM_Shape_ptr
129 #IDList for Fillet/Chamfer
137 Translation = geompy.MakeTranslation(Box, 300., 300., 300.) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr
138 Rotation = geompy.MakeRotation(Box, az, angle1) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr
139 Scale = geompy.MakeScaleTransform(Box, p0, factor) #(GEOM_Shape_ptr, PointStruct, Double)->GEOM_Shape_ptr
140 Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr
141 Orientation = geompy.OrientationChange(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
142 Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr
143 Chamfer = geompy.MakeChamfer(Prism, d1, d2, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr
146 MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) #(GEOM_Shape_ptr, DirStruct, Double, Short)->GEOM_Shape_ptr
147 MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2) #(GEOM_Shape_ptr, DirStruct, Double, Short, DirStruct, Double, Short)->GEOM_Shape_ptr
148 #!!!!Angle In Degree!!!!
149 MultiRot1D = geompy.MakeMultiRotation1D(Chamfer, vx, px, nbtimes1) #(GEOM_Shape_ptr, DirStruct, PointStruct, Short)->GEOM_Shape_ptr
150 MultiRot2D = geompy.MakeMultiRotation2D(Chamfer, vx, px, angle, nbtimes1, step1, nbtimes2) #(GEOM_Shape_ptr, DirStruct, PointStruct, Double, Short, Double, Short)->GEOM_Shape_ptr
152 #IDList for Partition
153 ShapeListPartition1 = []
154 ShapeListPartition1.append(Box)
155 IORListPartition1 = []
156 for Shape in ShapeListPartition1 :
157 IORListPartition1.append(Shape._get_Name())
158 ShapeListPartition2 = []
159 ShapeListPartition2.append(Plane)
160 IORListPartition2 = []
161 for Shape in ShapeListPartition2 :
162 IORListPartition2.append(Shape._get_Name())
166 IDlistSubShape.append(3)
168 #Create Informations objects
169 CDG = geompy.MakeCDG(Prism) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
170 Archimede = geompy.Archimede(Box, weight, waterdensity, meshingdeflection) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr
171 CheckShape = geompy.CheckShape(Prism) #(GEOM_Shape_ptr)->Boolean
174 Partition = geompy.Partition(IORListPartition1, IORListPartition2) #(ListOfIOR, ListOfIOR)->GEOM_Shape_ptr
177 id_Vertex = geompy.addToStudy(Vertex, "Vertex")
178 id_Vector = geompy.addToStudy(Vector, "Vector")
179 id_Line = geompy.addToStudy(Line, "Line")
180 id_Arc = geompy.addToStudy(Arc, "Arc")
181 id_Circle = geompy.addToStudy(Circle, "Circle")
182 id_Plane = geompy.addToStudy(Plane, "Plane")
184 id_Box = geompy.addToStudy(Box, "Box")
185 id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder")
186 id_Sphere = geompy.addToStudy(Sphere, "Sphere")
187 id_Cone = geompy.addToStudy(Cone, "Cone")
188 id_Torus = geompy.addToStudy(Torus, "Torus")
190 id_Edge = geompy.addToStudy(Edge, "Edge")
191 id_Wire = geompy.addToStudy(Wire, "Wire")
192 id_Face = geompy.addToStudy(Face, "Face")
193 id_Compound = geompy.addToStudy(Compound, "Compound")
195 id_Common = geompy.addToStudy(Common, "Common")
196 id_Cut = geompy.addToStudy(Cut, "Cut")
197 id_Fuse = geompy.addToStudy(Fuse, "Fuse")
198 id_Section = geompy.addToStudy(Section, "Section")
200 id_Copy = geompy.addToStudy(Copy, "Copy")
201 id_Prism = geompy.addToStudy(Prism, "Prism")
202 id_Revolution = geompy.addToStudy(Revolution, "Revolution")
203 id_Filling = geompy.addToStudy(Filling, "Filling")
204 id_Pipe = geompy.addToStudy(Pipe, "Pipe")
205 id_Sewing = geompy.addToStudy(Sewing, "Sewing")
207 Id_Translation = geompy.addToStudy(Translation, "Translation")
208 Id_Rotation = geompy.addToStudy(Rotation, "Rotation")
209 Id_Scale = geompy.addToStudy(Scale, "Scale")
210 Id_Mirror = geompy.addToStudy(Mirror, "Mirror")
211 Id_Orientation = geompy.addToStudy(Orientation, "Orientation")
212 Id_Fillet = geompy.addToStudy(Fillet, "Fillet")
213 Id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer")
215 Id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D")
216 Id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D")
217 Id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MultiRot1D")
218 Id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MultiRot2D")
220 Id_Partition = geompy.addToStudy(Partition, "Partition")
221 Id_CDG = geompy.addToStudy(CDG, "CDG")
222 Id_Archimede = geompy.addToStudy(Archimede, "Archimede")
225 SubShape = geompy.SubShape(Box, ShapeTypeFace, IDlistSubShape) #(GEOM_Shape_ptr, Short, ListOfSubShapeID)->GEOM_Shape_ptr
226 name = geompy.SubShapeName( SubShape._get_Name(), Box._get_Name() )
227 Id_SubShape = geompy.addToStudyInFather(Box, SubShape, name)
230 SubShapeAllList = geompy.SubShapeAll(SubShape, ShapeTypeEdge) #(GEOM_Shape_ptr, Short)->ListOfGeomShapes
231 for Shape in SubShapeAllList :
232 name = geompy.SubShapeName( Shape._get_Name(), Box._get_Name() )
233 Id_SubShapeAll = geompy.addToStudyInFather(SubShape, Shape, name)