1 # GEOM GEOM_SWIG : binding of C++ omplementaion with Python
3 # Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 # File : GEOM_usinggeom.py
24 # Author : Damien COQUERET, Open CASCADE
28 def TestAll (geompy, math):
30 #Create base Variables
36 ShapeTypeFace = geompy.ShapeType["FACE"]
37 ShapeTypeEdge = geompy.ShapeType["EDGE"]
38 WantPlanarFace = 1 #True
49 angle1 = angle * math.pi / 180
56 meshingdeflection = 0.01
61 p0 = geompy.MakeVertex(0. , 0. , 0. ) #(3 Doubles)->GEOM_Object_ptr
62 px = geompy.MakeVertex(100., 0. , 0. )
63 py = geompy.MakeVertex(0. , 100., 0. )
64 pz = geompy.MakeVertex(0. , 0. , 100.)
65 pxyz = geompy.MakeVertex(100., 100., 100.)
67 p200 = geompy.MakeVertexWithRef(pxyz, 100., 100., 100.) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr
69 #Create base directions
70 vx = geompy.MakeVector(p0, px) #(GEOM_Object_ptr, GEOM_Object_ptr)->GEOM_Object_ptr
71 vy = geompy.MakeVector(p0, py)
72 vz = geompy.MakeVector(p0, pz)
73 vxy = geompy.MakeVector(px, py)
75 vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) #(3 Doubles)->GEOM_Object_ptr
77 #Create local coordinate systems
78 cs1 = geompy.MakeMarker(50,50,50, 1,0,0, 0,1,0)
79 cs2 = geompy.MakeMarker(70,80,10, 1,0,1, 1,1,0)
81 #Create base geometry 2D
82 Line = geompy.MakeLine(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
83 Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
84 Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object_ptr
86 Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
87 Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
88 Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
89 Ellipse = geompy.MakeEllipse(p0, vy, radius2, radius1) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr
90 Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
91 Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
92 Interpol = geompy.MakeInterpol([px, py, p200, pxyz]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
93 Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
94 [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr
96 #Test point on curve creation
97 p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
99 #Create base geometry 3D
100 Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
101 Box1 = geompy.MakeBoxDXDYDZ(10, 20,30) #(3 Doubles)->GEOM_Object_ptr
102 Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr
103 Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object_ptr
104 Sphere = geompy.MakeSphere(p0, radius1) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
105 Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object_ptr
106 Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr
107 Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object_ptr
108 Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr
109 Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object_ptr
111 #Boolean (Common, Cut, Fuse, Section)
112 Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object_ptr, Short)->GEOM_Object_ptr
113 Cut = geompy.MakeBoolean(Box, Sphere, 2)
114 Fuse = geompy.MakeBoolean(Box, Sphere, 3)
115 Section = geompy.MakeBoolean(Box, Sphere, 4)
118 Edge = geompy.MakeEdge(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
119 Wire = geompy.MakeWire([vxy, Arc]) #(List Of GEOM_Object_ptr)->GEOM_Object_ptr
120 Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Object_ptr, Boolean)->GEOM_Object_ptr
121 Face1 = geompy.MakeFaceWires([Wire, Sketcher],
122 WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr
123 Face2 = geompy.MakeFace(Sketcher, WantPlanarFace)
124 Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
126 Prism1 = geompy.MakePrismTwoPnt(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
127 prism1_faces = geompy.SubShapeAllSorted(Prism1, ShapeTypeFace)
128 Shell1 = geompy.MakeShell([prism1_faces[0], prism1_faces[1],
129 prism1_faces[3], prism1_faces[4],
130 prism1_faces[5], prism1_faces[2]])
131 Solid = geompy.MakeSolid([Shell1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
133 ShapeListCompound = []
136 S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.)
137 ShapeListCompound.append(S)
139 Compound = geompy.MakeCompound(ShapeListCompound) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
141 # Test plane from existing face creation
142 Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
144 #ShapeList for Sewing
145 S = geompy.MakeRotation(Face, vxy, angle1)
147 #Create advanced objects
148 Copy = geompy.MakeCopy(Box) #(GEOM_Object_ptr)->GEOM_Object_ptr
149 Prism = geompy.MakePrism(Face, vz, 100.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
150 Revolution = geompy.MakeRevolution(Face, vz, angle2) #
151 Filling = geompy.MakeFilling(Compound, mindeg, maxdeg,
152 tol2d, tol3d, nbiter) #(GEOM_Object_ptr, 4 Doubles, Short)->GEOM_Object_ptr
153 Pipe = geompy.MakePipe(Wire, Edge) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
154 Sewing = geompy.MakeSewing([Face, S], precision) #(List Of GEOM_Object_ptr, Double)->GEOM_Object_ptr
157 Translation = geompy.MakeTranslationTwoPoints(Box, px, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
158 Rotation = geompy.MakeRotation(Box, vz, angle1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
159 Scale = geompy.MakeScaleTransform(Box, p0, factor) #
160 Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
161 Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
162 Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
164 #IDList for Fillet/Chamfer
165 prism_edges = geompy.SubShapeAllSorted(Prism, ShapeTypeEdge)
166 for anEdge in prism_edges:
167 name = geompy.SubShapeName(anEdge, Prism)
168 #Id_SubEdge = geompy.addToStudyInFather(Prism, anEdge, name)
169 print "Edge Id = ", geompy.GetSubShapeID(Prism, anEdge)
171 prism_faces = geompy.SubShapeAllSorted(Prism, ShapeTypeFace)
172 for aFace in prism_faces:
173 name = geompy.SubShapeName(aFace, Prism)
174 #Id_SubFace = geompy.addToStudyInFather(Prism, aFace, name)
175 print "Face Id = ", geompy.GetSubShapeID(Prism, aFace)
178 IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[0]))
179 IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[1]))
180 IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[2]))
182 f_ind_1 = geompy.GetSubShapeID(Prism, prism_faces[0])
183 f_ind_2 = geompy.GetSubShapeID(Prism, prism_faces[1])
185 IDlist_f = [f_ind_1, f_ind_2]
188 Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge,
189 IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr
190 Chamfer = geompy.MakeChamferEdge(Prism, d1, d2,
191 f_ind_1, f_ind_2) #(GEOM_Object_ptr, 2 Doubles, 2 Long)->GEOM_Object_ptr
192 Chamfer2 = geompy.MakeChamferFaces(Prism, d1, d2,
193 IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr
196 MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1)
197 MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2)
198 #!!!!Angle In Degree!!!!
199 MultiRot1D = geompy.MakeMultiRotation1D(Chamfer, vx, nbtimes1)
200 MultiRot2D = geompy.MakeMultiRotation2D(Chamfer, vx, angle, nbtimes1, step1, nbtimes2)
202 #Create Informations objects
203 CDG = geompy.MakeCDG(Prism) #(GEOM_Object_ptr)->GEOM_Object_ptr
204 Archimede = geompy.Archimede(Box, weight, waterdensity,
205 meshingdeflection) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr
206 CheckShape = geompy.CheckShape(Prism) #(GEOM_Object_ptr)->Boolean
207 print "CheckShape(Prism) = ", CheckShape
210 Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object_ptr)->GEOM_Object_ptr
214 id_p0 = geompy.addToStudy(p0, "Vertex 0")
215 id_px = geompy.addToStudy(px, "Vertex X")
216 id_py = geompy.addToStudy(py, "Vertex Y")
217 id_pz = geompy.addToStudy(pz, "Vertex Z")
218 id_pxyz = geompy.addToStudy(pxyz, "Vertex XYZ")
219 id_p200 = geompy.addToStudy(p200, "Vertex 200")
221 id_vx = geompy.addToStudy(vx, "Vector X")
222 id_vy = geompy.addToStudy(vy, "Vector Y")
223 id_vz = geompy.addToStudy(vz, "Vector Z")
224 id_vxy = geompy.addToStudy(vxy, "Vector XY")
225 id_vxyz = geompy.addToStudy(vxyz, "Vector XYZ")
227 id_cs1 = geompy.addToStudy(cs1, "CS 50,50,50, 1,0,0, 0,1,0")
228 id_cs2 = geompy.addToStudy(cs2, "CS 70,80,10, 1,0,1, 1,1,0")
230 id_Line = geompy.addToStudy(Line, "Line")
231 id_Plane = geompy.addToStudy(Plane, "Plane")
232 id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points")
234 id_Arc = geompy.addToStudy(Arc, "Arc")
235 id_Circle = geompy.addToStudy(Circle, "Circle")
236 id_Circle1 = geompy.addToStudy(Circle1, "Circle by 3 points")
237 id_Ellipse = geompy.addToStudy(Ellipse, "Ellipse")
238 id_Polyline = geompy.addToStudy(Polyline, "Polyline")
239 id_Bezier = geompy.addToStudy(Bezier, "Bezier")
240 id_Interpol = geompy.addToStudy(Interpol, "Interpol")
241 id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher")
243 id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc")
245 id_Box = geompy.addToStudy(Box, "Box")
246 id_Box1 = geompy.addToStudy(Box1, "Box 10x20x30")
247 id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder")
248 id_Cyl1 = geompy.addToStudy(Cyl1, "Cylinder RH")
249 id_Sphere = geompy.addToStudy(Sphere, "Sphere")
250 id_Sphere1 = geompy.addToStudy(Sphere1, "Sphere R")
251 id_Cone = geompy.addToStudy(Cone, "Cone")
252 id_Cone1 = geompy.addToStudy(Cone1, "Cone R1R2H")
253 id_Torus = geompy.addToStudy(Torus, "Torus")
254 id_Torus1 = geompy.addToStudy(Torus1, "Torus RR")
256 id_Common = geompy.addToStudy(Common, "Common")
257 id_Cut = geompy.addToStudy(Cut, "Cut")
258 id_Fuse = geompy.addToStudy(Fuse, "Fuse")
259 id_Section = geompy.addToStudy(Section, "Section")
261 id_Edge = geompy.addToStudy(Edge, "Edge")
262 id_Wire = geompy.addToStudy(Wire, "Wire")
263 id_Face = geompy.addToStudy(Face, "Face")
264 id_Face1 = geompy.addToStudy(Face1, "Face from two wires")
265 id_Face2 = geompy.addToStudy(Face2, "Face from Sketcher")
266 id_Shell = geompy.addToStudy(Shell, "Shell")
268 id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt")
269 id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces")
270 id_Solid = geompy.addToStudy(Solid, "Solid")
271 id_Compound = geompy.addToStudy(Compound, "Compound")
273 id_Plane2 = geompy.addToStudy(Plane2, "Plane on Face")
275 id_Copy = geompy.addToStudy(Copy, "Copy")
276 id_Prism = geompy.addToStudy(Prism, "Prism")
277 id_Revolution = geompy.addToStudy(Revolution, "Revolution")
278 id_Filling = geompy.addToStudy(Filling, "Filling")
279 id_Pipe = geompy.addToStudy(Pipe, "Pipe")
280 id_Sewing = geompy.addToStudy(Sewing, "Sewing")
282 Id_Translation = geompy.addToStudy(Translation, "Translation")
283 Id_Rotation = geompy.addToStudy(Rotation, "Rotation")
284 Id_Scale = geompy.addToStudy(Scale, "Scale")
285 Id_Mirror = geompy.addToStudy(Mirror, "Mirror")
286 Id_Position = geompy.addToStudy(Position, "Positioned box")
287 Id_Offset = geompy.addToStudy(Offset, "Offset")
289 Id_Fillet = geompy.addToStudy(Fillet, "Fillet")
290 Id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge")
291 Id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces")
293 Id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D")
294 Id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D")
295 Id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MultiRot1D")
296 Id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MultiRot2D")
298 Id_CDG = geompy.addToStudy(CDG, "CDG")
299 Id_Archimede = geompy.addToStudy(Archimede, "Archimede")
301 Id_Partition = geompy.addToStudy(Partition, "Partition")
304 SubFaceList = geompy.SubShapeAll(Box, geompy.ShapeType["FACE"])
305 SubFace = SubFaceList[2]
306 name = geompy.SubShapeName(SubFace, Box)
307 Id_SubFace = geompy.addToStudyInFather(Box, SubFace, name)
309 SubEdgeList = geompy.SubShapeAll(SubFace, geompy.ShapeType["EDGE"])
311 for SubEdge in SubEdgeList :
312 name = geompy.SubShapeName(SubEdge, SubFace)
313 Id_SubEdge = geompy.addToStudyInFather(SubFace, SubEdge, name)