1 # GEOM GEOM_SWIG : binding of C++ implementaion with Python
3 # Copyright (C) 2003 CEA
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # File : GEOM_TestOthers.py
23 # Author : Julia DOROVSKIKH
29 def TestExportImport (geompy, shape):
31 print "Test Export/Import ...",
33 tmpDir = os.getenv("TEMP")
37 # Files for Export/Import testing
38 fileExportImport = tmpDir + "/testExportImport.brep"
39 fileExportImportBREP = tmpDir + "/testExportImportBREP.brep"
40 fileExportImportIGES = tmpDir + "/testExportImportIGES.iges"
41 fileExportImportSTEP = tmpDir + "/testExportImportSTEP.step"
43 if os.access(fileExportImport, os.F_OK):
44 if os.access(fileExportImport, os.W_OK):
45 os.remove(fileExportImport)
47 fileExportImport = tmpDir + "/testExportImport1.brep"
49 if os.access(fileExportImportBREP, os.W_OK):
50 os.remove(fileExportImportBREP)
52 fileExportImportBREP = tmpDir + "/testExportImportBREP1.brep"
54 if os.access(fileExportImportIGES, os.W_OK):
55 os.remove(fileExportImportIGES)
57 fileExportImportIGES = tmpDir + "/testExportImportIGES1.iges"
59 if os.access(fileExportImportSTEP, os.W_OK):
60 os.remove(fileExportImportSTEP)
62 fileExportImportSTEP = tmpDir + "/testExportImportSTEP1.step"
65 geompy.Export(shape, fileExportImport, "BREP")
67 # ExportBREP, ExportIGES, ExportSTEP
68 geompy.ExportBREP(shape, fileExportImportBREP)
69 geompy.ExportIGES(shape, fileExportImportIGES)
70 geompy.ExportSTEP(shape, fileExportImportSTEP)
73 Import = geompy.Import(fileExportImport, "BREP")
75 id_Import = geompy.addToStudy(Import, "Import")
77 # ImportBREP, ImportIGES, ImportSTEP
78 ImportBREP = geompy.ImportBREP(fileExportImportBREP)
79 ImportIGES = geompy.ImportIGES(fileExportImportIGES)
80 ImportSTEP = geompy.ImportSTEP(fileExportImportSTEP)
82 id_ImportBREP = geompy.addToStudy(ImportBREP, "ImportBREP")
83 id_ImportIGES = geompy.addToStudy(ImportIGES, "ImportIGES")
84 id_ImportSTEP = geompy.addToStudy(ImportSTEP, "ImportSTEP")
86 # Remove files for Export/Import testing
87 os.remove(fileExportImport)
88 os.remove(fileExportImportBREP)
89 os.remove(fileExportImportIGES)
90 os.remove(fileExportImportSTEP)
95 def TestOtherOperations (geompy, math):
98 p11 = geompy.MakeVertex( 0, 0, 0)
99 p12 = geompy.MakeVertex(30, 0, 0)
100 p13 = geompy.MakeVertex(30, 30, 0)
101 p14 = geompy.MakeVertex( 0, 30, 0)
103 p21 = geompy.MakeVertex(10, 10, 0)
104 p22 = geompy.MakeVertex(20, 10, 0)
105 p23 = geompy.MakeVertex(20, 20, 0)
106 p24 = geompy.MakeVertex(10, 20, 0)
108 e11 = geompy.MakeEdge(p11, p12)
109 e12 = geompy.MakeEdge(p12, p13)
110 e13 = geompy.MakeEdge(p13, p14)
111 e14 = geompy.MakeEdge(p14, p11)
113 e21 = geompy.MakeEdge(p21, p22)
114 e22 = geompy.MakeEdge(p22, p23)
115 e23 = geompy.MakeEdge(p23, p24)
116 e24 = geompy.MakeEdge(p24, p21)
118 w1 = geompy.MakeWire([e11, e12, e13, e14])
119 w2 = geompy.MakeWire([e21, e22, e23, e24])
120 w3 = geompy.MakeTranslation(w2, 0, 0, 10)
122 id_w1 = geompy.addToStudy(w1, "Outside Wire")
123 id_w2 = geompy.addToStudy(w2, "Inside Wire")
124 id_w3 = geompy.addToStudy(w3, "Inside Wire, translated along OZ")
126 f12 = geompy.MakeFaces([w1, w2], 0)
127 id_f12 = geompy.addToStudy(f12, "MakeFaces WO + WI")
130 TestExportImport(geompy, f12)
133 Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
134 Orientation = geompy.OrientationChange(Box)
135 id_Orientation = geompy.addToStudy(Orientation, "OrientationChange")
137 # MakeCommon, MakeCut, MakeFuse, MakeSection
138 Sphere = geompy.MakeSphereR(100)
140 Common = geompy.MakeCommon (Box, Sphere)
141 Cut = geompy.MakeCut (Box, Sphere)
142 Fuse = geompy.MakeFuse (Box, Sphere)
143 Section = geompy.MakeSection(Box, Sphere)
145 id_Common = geompy.addToStudy(Common, "Common")
146 id_Cut = geompy.addToStudy(Cut, "Cut")
147 id_Fuse = geompy.addToStudy(Fuse, "Fuse")
148 id_Section = geompy.addToStudy(Section, "Section")
151 p100 = geompy.MakeVertex(100, 100, 100)
152 p300 = geompy.MakeVertex(300, 300, 300)
153 Box1 = geompy.MakeBoxTwoPnt(p100, p300)
154 #Partition = geompy.Partition([Box], [Box1], [], [Box])
155 Partition = geompy.Partition([Box], [Box1])
156 id_Partition = geompy.addToStudy(Partition, "Partition of Box by Box1")
158 # MakeMultiRotation1D, MakeMultiRotation2D
159 pz = geompy.MakeVertex(0, 0, 100)
160 vy = geompy.MakeVectorDXDYDZ(0, 100, 0)
162 MultiRot1D = geompy.MakeMultiRotation1D(f12, vy, pz, 6)
163 MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3)
165 id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MakeMultiRotation1D")
166 id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MakeMultiRotation2D")
170 face5 = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5])
171 f_glob_id = geompy.GetSubShapeID(Box, face5)
172 SuppFace = geompy.SuppressFaces(Box, [f_glob_id])
174 MakeFilletAll = geompy.MakeFilletAll(SuppFace, radius_fillet)
175 id_MakeFilletAll = geompy.addToStudy(MakeFilletAll, "MakeFilletAll")
178 dimension_chamfer = 10.
179 MakeChamferAll = geompy.MakeChamferAll(SuppFace, dimension_chamfer)
180 id_MakeChamferAll = geompy.addToStudy(MakeChamferAll, "MakeChamferAll")
185 box_faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])
186 f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0])
187 f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1])
188 f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2])
190 MakeChamfer = geompy.MakeChamfer(Box, d1, d2, geompy.ShapeType["FACE"],
191 [f_ind_1, f_ind_2, f_ind_3])
192 id_MakeChamfer = geompy.addToStudy(MakeChamfer, "MakeChamfer")
195 NumberOfFaces = geompy.NumberOfFaces(Box)
196 if NumberOfFaces != 6:
197 print "Bad number of faces in BOX!"
200 NumberOfEdges = geompy.NumberOfEdges(Box)
201 if NumberOfEdges != 12:
202 print "Bad number of edges in BOX!"
205 Compound = geompy.MakeCompound([Box, Sphere])
206 MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6)
208 id_MakeBlockExplode = geompy.addToStudy(MakeBlockExplode[0], "MakeBlockExplode")
210 # CheckCompoundOfBlocks
211 p1 = geompy.MakeVertex(200, 0, 0)
212 p2 = geompy.MakeVertex(400, 200, 200)
213 p3 = geompy.MakeVertex(400, 50, 50)
214 p4 = geompy.MakeVertex(600, 250, 250)
216 Box2 = geompy.MakeBoxTwoPnt(p1, p2)
217 Box3 = geompy.MakeBoxTwoPnt(p3, p4)
218 Cyl = geompy.MakeCylinderRH(50, 300)
219 Cone = geompy.MakeConeR1R2H(150, 10, 400)
221 Compound1 = geompy.MakeCompound([Box, Cyl, Cone, Box3, Box2])
223 IsValid = geompy.CheckCompoundOfBlocks(Compound1)
225 print "The Blocks Compound is NOT VALID"
227 print "The Blocks Compound is VALID"
229 IsValid = geompy.CheckCompoundOfBlocks(Box)
231 print "The Box is NOT VALID"
233 print "The Box is VALID"
235 # test geometrical groups
238 CreateGroup = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
240 id_CreateGroup = geompy.addToStudy(CreateGroup, "CreateGroup")
243 f_ind_4 = geompy.GetSubShapeID(Box, box_faces[3])
244 f_ind_5 = geompy.GetSubShapeID(Box, box_faces[4])
245 f_ind_6 = geompy.GetSubShapeID(Box, box_faces[5])
247 geompy.AddObject(CreateGroup, f_ind_6) # box_faces[5]
248 geompy.AddObject(CreateGroup, f_ind_1) # box_faces[0]
249 geompy.AddObject(CreateGroup, f_ind_4) # box_faces[3]
250 # Now contains f_ind_6, f_ind_1, f_ind_4
253 geompy.UnionList(CreateGroup, [box_faces[2], box_faces[4], box_faces[5]])
254 # Now contains f_ind_6, f_ind_1, f_ind_4, f_ind_3, f_ind_5
256 # RemoveObject(theGroup, theSubShapeID)
257 geompy.RemoveObject(CreateGroup, f_ind_1) # box_faces[0]
258 # Now contains f_ind_6, f_ind_4, f_ind_3, f_ind_5
261 geompy.DifferenceList(CreateGroup, [box_faces[1], box_faces[0], box_faces[3]])
262 # Now contains f_ind_6, f_ind_3, f_ind_5
265 GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
267 print "Group of Box's faces includes the following IDs:"
268 print "(must be ", f_ind_6, ", ", f_ind_3, " and ", f_ind_5, ")"
269 for ObjectID in GetObjectIDs:
272 BoxCopy = geompy.GetMainShape(CreateGroup)
275 geompy.DifferenceIDs(CreateGroup, [f_ind_3, f_ind_5])
276 # Now contains f_ind_6
279 geompy.UnionIDs(CreateGroup, [f_ind_1, f_ind_2, f_ind_6])
280 # Now contains f_ind_6, f_ind_1, f_ind_2
283 GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
284 print "Group of Box's faces includes the following IDs:"
285 print "(must be ", f_ind_6, ", ", f_ind_1, " and ", f_ind_2, ")"
286 for ObjectID in GetObjectIDs:
289 # -----------------------------------------------------------------------------
290 # enumeration ShapeTypeString as a dictionary
291 # -----------------------------------------------------------------------------
292 ShapeTypeString = {'0':"COMPOUND", '1':"COMPSOLID", '2':"SOLID", '3':"SHELL", '4':"FACE", '5':"WIRE", '6':"EDGE", '7':"VERTEX", '8':"SHAPE"}
294 GroupType = geompy.GetType(CreateGroup)
295 print "Type of elements of the created group is ", ShapeTypeString[`GroupType`]
297 # Prepare data for the following operations
298 p0 = geompy.MakeVertex(0, 0, 0)
299 b0 = geompy.MakeBox(-50, -50, -50, 50, 50, 50)
300 s0 = geompy.MakeSphereR(100)
302 id_b0 = geompy.addToStudy(b0, "b0")
303 id_s0 = geompy.addToStudy(s0, "s0")
305 v_0pp = geompy.MakeVectorDXDYDZ( 0, 1, 1)
306 v_0np = geompy.MakeVectorDXDYDZ( 0, -1, 1)
307 v_p0p = geompy.MakeVectorDXDYDZ( 1, 0, 1)
308 v_n0p = geompy.MakeVectorDXDYDZ(-1, 0, 1)
309 v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0)
310 v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0)
311 v_0n0 = geompy.MakeVectorDXDYDZ( 0, -1, 0)
313 pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
314 pln_0np = geompy.MakePlane(p0, v_0np, 300)
315 pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
316 pln_n0p = geompy.MakePlane(p0, v_n0p, 300)
317 pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
318 pln_np0 = geompy.MakePlane(p0, v_np0, 300)
320 #part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0],
324 part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0])
326 id_part_tool_1 = geompy.addToStudy(part_tool_1, "part_tool_1")
328 pt_pnt_1 = geompy.MakeVertex( 55, 0, 55)
329 pt_pnt_2 = geompy.MakeVertex( 0, 55, 55)
330 pt_pnt_3 = geompy.MakeVertex(-55, 0, 55)
331 pt_pnt_4 = geompy.MakeVertex( 0, -55, 55)
332 pt_pnt_5 = geompy.MakeVertex( 55, 55, 0)
333 pt_pnt_6 = geompy.MakeVertex( 55, -55, 0)
334 pt_pnt_7 = geompy.MakeVertex(-55, 55, 0)
335 pt_pnt_8 = geompy.MakeVertex(-55, -55, 0)
336 pt_pnt_9 = geompy.MakeVertex( 55, 0, -55)
337 pt_pnt_10 = geompy.MakeVertex( 0, 55, -55)
338 pt_pnt_11 = geompy.MakeVertex(-55, 0, -55)
339 pt_pnt_12 = geompy.MakeVertex( 0, -55, -55)
341 pt_face_1 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_1)
342 pt_face_2 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_2)
343 pt_face_3 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_3)
344 pt_face_4 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_4)
345 pt_face_5 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_5)
346 pt_face_6 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_6)
347 pt_face_7 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_7)
348 pt_face_8 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_8)
349 pt_face_9 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_9)
350 pt_face_10 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_10)
351 pt_face_11 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_11)
352 pt_face_12 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_12)
354 #pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
356 #part_tool = geompy.MakeCompound([pt_face_1, pt_face_4, pt_face_7, pt_face_10,
357 # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
358 # #pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box])
359 # pt_face_3, pt_face_6, pt_face_9, pt_face_12)
360 #id_part_tool = geompy.addToStudy(part_tool, "part_tool")
362 #part = geompy.MakePartition([s0], [part_tool])
363 #part = geompy.MakePartition([s0], [ pt_face_1, pt_face_4, pt_face_7, pt_face_10,
364 # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
365 # pt_face_3, pt_face_6, pt_face_9, pt_face_12, b0] )
367 p1 = geompy.MakeVertex(50, 0, 0)
368 p2 = geompy.MakeVertex(-50, 0, 0)
369 p3 = geompy.MakeVertex(0, 50, 0)
370 p4 = geompy.MakeVertex(0, -50, 0)
371 p5 = geompy.MakeVertex(0, 0, 50)
372 p6 = geompy.MakeVertex(0, 0, -50)
374 vx = geompy.MakeVectorDXDYDZ( 1, 0, 0)
375 vy = geompy.MakeVectorDXDYDZ( 0, 1, 0)
376 vz = geompy.MakeVectorDXDYDZ( 0, 0, 1)
378 plnX1 = geompy.MakePlane(p1, vx, 300)
379 plnX2 = geompy.MakePlane(p2, vx, 300)
380 plnY1 = geompy.MakePlane(p3, vy, 300)
381 plnY2 = geompy.MakePlane(p4, vy, 300)
382 plnZ1 = geompy.MakePlane(p5, vz, 300)
383 plnZ2 = geompy.MakePlane(p6, vz, 300)
385 #part = geompy.MakePartition([s0], [plnX1,plnX2,plnY1,plnY2,plnZ1,plnZ2])
386 part = geompy.MakePartition([s0], [plnX1])
387 part = geompy.MakePartition([part], [plnX2])
388 part = geompy.MakePartition([part], [plnY1])
389 part = geompy.MakePartition([part], [plnY2])
390 part = geompy.MakePartition([part], [plnZ1])
391 part = geompy.MakePartition([part], [plnZ2])
392 geompy.addToStudy(part, "part")
395 anIDs = geompy.GetFreeFacesIDs(part)
396 freeFaces = geompy.GetSubShape(part, anIDs)
398 geompy.addToStudy(freeFaces, "freeFaces")
401 freeFacesWithoutExtra = geompy.RemoveExtraEdges(freeFaces)
403 geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra")
406 sharedFaces = geompy.GetSharedShapes(part, freeFacesWithoutExtra, geompy.ShapeType["FACE"])
408 for shFace in sharedFaces:
409 geompy.addToStudy(shFace, "sharedFace")
412 blocksComp = geompy.CheckAndImprove(part)
414 geompy.addToStudy(blocksComp, "blocksComp")
417 listChains = geompy.Propagate(blocksComp)
419 for chain in listChains:
420 geompy.addToStudyInFather(blocksComp, chain, "propagation chain")
422 # GetPoint(theShape, theX, theY, theZ, theEpsilon)
424 # (-50, 50, 50) .-----. (50, 50, 50)
428 # (-50, -50, 50) '-----' (50, -50, 50)
430 pb0_top_1 = geompy.GetPoint(blocksComp, -50, 50, 50, 0.01)
431 pb0_bot_1 = geompy.GetPoint(blocksComp, -50, -50, -50, 0.01)
433 geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50, 50, 50)")
434 geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)")
436 # GetEdgeNearPoint(theShape, thePoint)
437 pmidle = geompy.MakeVertex(50, 0, 50)
438 edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle)
440 geompy.addToStudyInFather(blocksComp, edge1, "edge near point (50, 0, 50)")
442 # GetBlockByParts(theCompound, theParts)
443 b0_image = geompy.GetBlockByParts(blocksComp, [pb0_top_1, pb0_bot_1, edge1])
445 geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
448 faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
449 v_0pp, geompy.GEOM.ST_ONIN)
450 for face_i in faces_on_pln:
451 geompy.addToStudy(face_i, "Face on Plane (N = (0, 1, 1)) or below it")
453 # GetShapesOnPlaneIDs
454 faces_above_pln_ids = geompy.GetShapesOnPlaneIDs(blocksComp, geompy.ShapeType["FACE"],
455 v_0pp, geompy.GEOM.ST_OUT)
456 faces_above = geompy.CreateGroup(blocksComp, geompy.ShapeType["FACE"])
457 geompy.UnionIDs(faces_above, faces_above_pln_ids)
458 geompy.addToStudy(faces_above, "Group of faces above Plane (N = (0, 1, 1))")
460 # GetShapesOnPlaneWithLocation
461 Loc = geompy.MakeVertex(0, -50, 0)
462 edges_on_pln = geompy.GetShapesOnPlaneWithLocation(blocksComp, geompy.ShapeType["EDGE"],
463 v_0n0, Loc, geompy.GEOM.ST_ON)
464 for edge_i in edges_on_pln:
465 geompy.addToStudy(edge_i, "Edge on Plane (N = (0, -1, 0) & Location = (0, -50, 0)")
467 # GetShapesOnPlaneWithLocationIDs
468 edges_on_pln_ids = geompy.GetShapesOnPlaneWithLocationIDs(blocksComp, geompy.ShapeType["EDGE"],
469 v_0n0, Loc, geompy.GEOM.ST_ON)
470 group_edges_on_pln = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
471 geompy.UnionIDs(group_edges_on_pln, edges_on_pln_ids)
472 geompy.addToStudy(group_edges_on_pln, "Group of edges on Plane (N = (0, -1, 0) & Location = (0, -50, 0))")
474 # GetShapesOnCylinder
475 edges_out_cyl = geompy.GetShapesOnCylinder(blocksComp, geompy.ShapeType["EDGE"],
476 vy, 55, geompy.GEOM.ST_OUT)
477 for edge_i in edges_out_cyl:
478 geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), r = 55)")
480 # GetShapesOnCylinderIDs
481 edges_in_cyl_ids = geompy.GetShapesOnCylinderIDs(blocksComp, geompy.ShapeType["EDGE"],
482 vy, 80, geompy.GEOM.ST_IN)
483 edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
484 geompy.UnionIDs(edges_in, edges_in_cyl_ids)
485 geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)")
488 vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"],
489 p0, 100, geompy.GEOM.ST_ON)
490 for vertex_i in vertices_on_sph:
491 geompy.addToStudy(vertex_i, "Vertex on Sphere (center = (0, 0, 0), r = 100)")
494 # GetShapesOnSphereIDs
495 vertices_on_sph_ids = geompy.GetShapesOnSphereIDs(blocksComp, geompy.ShapeType["VERTEX"],
496 p0, 100, geompy.GEOM.ST_ON)
497 vertices_on = geompy.CreateGroup(blocksComp, geompy.ShapeType["VERTEX"])
498 geompy.UnionIDs(vertices_on, vertices_on_sph_ids)
499 geompy.addToStudy(vertices_on, "Group of vertices on Sphere (center = (0, 0, 0), r = 100)")
501 # GetShapesOnQuadrangle
503 geompy.addToStudy(f12, "F12" )
505 bl = geompy.MakeVertex(10,-10, 0)
506 br = geompy.MakeVertex(40,-10, 0)
507 tr = geompy.MakeVertex(40, 20, 0)
508 tl = geompy.MakeVertex(10, 20, 0)
509 qe1 = geompy.MakeEdge(bl, br)
510 qe2 = geompy.MakeEdge(br, tr)
511 qe3 = geompy.MakeEdge(tr, tl)
512 qe4 = geompy.MakeEdge(tl, bl)
513 quadrangle = geompy.MakeWire([qe1, qe2, qe3, qe4])
514 geompy.addToStudy(quadrangle, "Quadrangle")
516 edges_onin_quad = geompy.GetShapesOnQuadrangle( f12, geompy.ShapeType["EDGE"],
517 tl, tr, bl, br, geompy.GEOM.ST_ONIN)
518 comp = geompy.MakeCompound(edges_onin_quad)
519 geompy.addToStudy(comp, "Edges of F12 ONIN Quadrangle")
520 if len( edges_onin_quad ) != 4:
521 print "Error in GetShapesOnQuadrangle()"
524 # GetShapesOnQuadrangleIDs
525 vertices_on_quad_ids = geompy.GetShapesOnQuadrangleIDs(f12, geompy.ShapeType["VERTEX"],
526 tl, tr, bl, br, geompy.GEOM.ST_ON)
527 vertices_on_quad = geompy.CreateGroup(f12, geompy.ShapeType["VERTEX"])
528 geompy.UnionIDs(vertices_on_quad, vertices_on_quad_ids)
529 geompy.addToStudy(vertices_on_quad, "Group of vertices on Quadrangle F12")
531 # Prepare arguments for GetInPlace and GetInPlaceByHistory
532 box5 = geompy.MakeBoxDXDYDZ(100, 100, 100)
533 box6 = geompy.MakeTranslation(box5, 50, 50, 0)
535 geompy.addToStudy(box5, "Box 5")
536 geompy.addToStudy(box6, "Box 6")
538 part = geompy.MakePartition([box5], [box6])
539 geompy.addToStudy(part, "Partitioned")
541 box5_faces = geompy.SubShapeAll(box5, geompy.ShapeType["FACE"])
542 box6_faces = geompy.SubShapeAll(box6, geompy.ShapeType["FACE"])
545 for aface in box5_faces:
546 geompy.addToStudyInFather(box5, aface, "Face" + `ifa`)
550 for aface in box6_faces:
551 geompy.addToStudyInFather(box6, aface, "Face" + `ifa`)
554 # GetInPlace(theShapeWhere, theShapeWhat)
556 faces_list = [box5_faces, box6_faces]
557 for afaces in faces_list:
560 if ibb == 6 and (ifa == 2 or ifa == 4):
561 # use IDL interface directly to avoid error message appearence in Python console
562 refl_box_face = geompy.ShapesOp.GetInPlace(part, aface)
563 if refl_box_face is not None:
564 geompy.addToStudyInFather(part, refl_box_face,
565 "Reflection of face " + `ifa` + " of box " + `ibb`)
566 error = "Result of GetInPlace must be NULL for face " + `ifa` + " of box " + `ibb`
567 raise RuntimeError, error
569 # use geompy interface
570 refl_box_face = geompy.GetInPlace(part, aface)
571 geompy.addToStudyInFather(part, refl_box_face,
572 "Reflection of face " + `ifa` + " of box " + `ibb`)
576 # GetInPlaceByHistory(theShapeWhere, theShapeWhat)
577 part = geompy.MakePartition([box5], [box6])
578 geompy.addToStudy(part, "Partitioned")
581 faces_list = [box5_faces, box6_faces]
582 for afaces in faces_list:
585 if ibb == 6 and (ifa == 2 or ifa == 4):
586 # use IDL interface directly to avoid error message appearence in Python console
587 refl_box_face = geompy.ShapesOp.GetInPlaceByHistory(part, aface)
588 if refl_box_face is not None:
589 geompy.addToStudyInFather(part, refl_box_face,
590 "Reflection of face " + `ifa` + " of box " + `ibb` + " (by history)")
591 error = "Result of GetInPlaceByHistory must be NULL for face " + `ifa` + " of box " + `ibb`
592 raise RuntimeError, error
594 # use geompy interface
595 refl_box_face = geompy.GetInPlaceByHistory(part, aface)
596 geompy.addToStudyInFather(part, refl_box_face,
597 "Reflection of face " + `ifa` + " of box " + `ibb` + " (by history)")