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 # Files for Export/Import testing
34 fileExportImport = "/tmp/testExportImport.brep"
35 fileExportImportBREP = "/tmp/testExportImportBREP.brep"
36 fileExportImportIGES = "/tmp/testExportImportIGES.iges"
37 fileExportImportSTEP = "/tmp/testExportImportSTEP.step"
39 if os.access(fileExportImport, os.F_OK):
40 if os.access(fileExportImport, os.W_OK):
41 os.remove(fileExportImport)
43 fileExportImport = "/tmp/testExportImport1.brep"
45 if os.access(fileExportImportBREP, os.W_OK):
46 os.remove(fileExportImportBREP)
48 fileExportImportBREP = "/tmp/testExportImportBREP1.brep"
50 if os.access(fileExportImportIGES, os.W_OK):
51 os.remove(fileExportImportIGES)
53 fileExportImportIGES = "/tmp/testExportImportIGES1.iges"
55 if os.access(fileExportImportSTEP, os.W_OK):
56 os.remove(fileExportImportSTEP)
58 fileExportImportSTEP = "/tmp/testExportImportSTEP1.step"
61 geompy.Export(shape, fileExportImport, "BREP")
63 # ExportBREP, ExportIGES, ExportSTEP
64 geompy.ExportBREP(shape, fileExportImportBREP)
65 geompy.ExportIGES(shape, fileExportImportIGES)
66 geompy.ExportSTEP(shape, fileExportImportSTEP)
69 Import = geompy.Import(fileExportImport, "BREP")
71 id_Import = geompy.addToStudy(Import, "Import")
73 # ImportBREP, ImportIGES, ImportSTEP
74 ImportBREP = geompy.ImportBREP(fileExportImportBREP)
75 ImportIGES = geompy.ImportIGES(fileExportImportIGES)
76 ImportSTEP = geompy.ImportSTEP(fileExportImportSTEP)
78 id_ImportBREP = geompy.addToStudy(ImportBREP, "ImportBREP")
79 id_ImportIGES = geompy.addToStudy(ImportIGES, "ImportIGES")
80 id_ImportSTEP = geompy.addToStudy(ImportSTEP, "ImportSTEP")
82 # Remove files for Export/Import testing
83 os.remove(fileExportImport)
84 os.remove(fileExportImportBREP)
85 os.remove(fileExportImportIGES)
86 os.remove(fileExportImportSTEP)
91 def TestOtherOperations (geompy, math):
94 p11 = geompy.MakeVertex( 0, 0, 0)
95 p12 = geompy.MakeVertex(30, 0, 0)
96 p13 = geompy.MakeVertex(30, 30, 0)
97 p14 = geompy.MakeVertex( 0, 30, 0)
99 p21 = geompy.MakeVertex(10, 10, 0)
100 p22 = geompy.MakeVertex(20, 10, 0)
101 p23 = geompy.MakeVertex(20, 20, 0)
102 p24 = geompy.MakeVertex(10, 20, 0)
104 e11 = geompy.MakeEdge(p11, p12)
105 e12 = geompy.MakeEdge(p12, p13)
106 e13 = geompy.MakeEdge(p13, p14)
107 e14 = geompy.MakeEdge(p14, p11)
109 e21 = geompy.MakeEdge(p21, p22)
110 e22 = geompy.MakeEdge(p22, p23)
111 e23 = geompy.MakeEdge(p23, p24)
112 e24 = geompy.MakeEdge(p24, p21)
114 w1 = geompy.MakeWire([e11, e12, e13, e14])
115 w2 = geompy.MakeWire([e21, e22, e23, e24])
116 w3 = geompy.MakeTranslation(w2, 0, 0, 10)
118 id_w1 = geompy.addToStudy(w1, "Outside Wire")
119 id_w2 = geompy.addToStudy(w2, "Inside Wire")
120 id_w3 = geompy.addToStudy(w3, "Inside Wire, translated along OZ")
122 f12 = geompy.MakeFaces([w1, w2], 0)
123 id_f12 = geompy.addToStudy(f12, "MakeFaces WO + WI")
126 TestExportImport(geompy, f12)
129 Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
130 Orientation = geompy.OrientationChange(Box)
131 id_Orientation = geompy.addToStudy(Orientation, "OrientationChange")
133 # MakeCommon, MakeCut, MakeFuse, MakeSection
134 Sphere = geompy.MakeSphereR(100)
136 Common = geompy.MakeCommon (Box, Sphere)
137 Cut = geompy.MakeCut (Box, Sphere)
138 Fuse = geompy.MakeFuse (Box, Sphere)
139 Section = geompy.MakeSection(Box, Sphere)
141 id_Common = geompy.addToStudy(Common, "Common")
142 id_Cut = geompy.addToStudy(Cut, "Cut")
143 id_Fuse = geompy.addToStudy(Fuse, "Fuse")
144 id_Section = geompy.addToStudy(Section, "Section")
147 p100 = geompy.MakeVertex(100, 100, 100)
148 p300 = geompy.MakeVertex(300, 300, 300)
149 Box1 = geompy.MakeBoxTwoPnt(p100, p300)
150 #Partition = geompy.Partition([Box], [Box1], [], [Box])
151 Partition = geompy.Partition([Box], [Box1])
152 id_Partition = geompy.addToStudy(Partition, "Partition of Box by Box1")
154 # MakeMultiRotation1D, MakeMultiRotation2D
155 pz = geompy.MakeVertex(0, 0, 100)
156 vy = geompy.MakeVectorDXDYDZ(0, 100, 0)
158 MultiRot1D = geompy.MakeMultiRotation1D(f12, vy, pz, 6)
159 MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3)
161 id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MakeMultiRotation1D")
162 id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MakeMultiRotation2D")
166 face5 = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5])
167 f_glob_id = geompy.GetSubShapeID(Box, face5)
168 SuppFace = geompy.SuppressFaces(Box, [f_glob_id])
170 MakeFilletAll = geompy.MakeFilletAll(SuppFace, radius_fillet)
171 id_MakeFilletAll = geompy.addToStudy(MakeFilletAll, "MakeFilletAll")
174 dimension_chamfer = 10.
175 MakeChamferAll = geompy.MakeChamferAll(SuppFace, dimension_chamfer)
176 id_MakeChamferAll = geompy.addToStudy(MakeChamferAll, "MakeChamferAll")
181 box_faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])
182 f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0])
183 f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1])
184 f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2])
186 MakeChamfer = geompy.MakeChamfer(Box, d1, d2, geompy.ShapeType["FACE"],
187 [f_ind_1, f_ind_2, f_ind_3])
188 id_MakeChamfer = geompy.addToStudy(MakeChamfer, "MakeChamfer")
191 NumberOfFaces = geompy.NumberOfFaces(Box)
192 if NumberOfFaces != 6:
193 print "Bad number of faces in BOX!"
196 NumberOfEdges = geompy.NumberOfEdges(Box)
197 if NumberOfEdges != 12:
198 print "Bad number of edges in BOX!"
201 Compound = geompy.MakeCompound([Box, Sphere])
202 MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6)
204 id_MakeBlockExplode = geompy.addToStudy(MakeBlockExplode[0], "MakeBlockExplode")
206 # CheckCompoundOfBlocks
207 p1 = geompy.MakeVertex(200, 0, 0)
208 p2 = geompy.MakeVertex(400, 200, 200)
209 p3 = geompy.MakeVertex(400, 50, 50)
210 p4 = geompy.MakeVertex(600, 250, 250)
212 Box2 = geompy.MakeBoxTwoPnt(p1, p2)
213 Box3 = geompy.MakeBoxTwoPnt(p3, p4)
214 Cyl = geompy.MakeCylinderRH(50, 300)
215 Cone = geompy.MakeConeR1R2H(150, 10, 400)
217 Compound1 = geompy.MakeCompound([Box, Cyl, Cone, Box3, Box2])
219 IsValid = geompy.CheckCompoundOfBlocks(Compound1)
221 print "The Blocks Compound is NOT VALID"
223 print "The Blocks Compound is VALID"
225 IsValid = geompy.CheckCompoundOfBlocks(Box)
227 print "The Box is NOT VALID"
229 print "The Box is VALID"
231 # test geometrical groups
234 CreateGroup = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
236 id_CreateGroup = geompy.addToStudy(CreateGroup, "CreateGroup")
239 f_ind_4 = geompy.GetSubShapeID(Box, box_faces[3])
240 f_ind_5 = geompy.GetSubShapeID(Box, box_faces[4])
241 f_ind_6 = geompy.GetSubShapeID(Box, box_faces[5])
243 geompy.AddObject(CreateGroup, f_ind_6) # box_faces[5]
244 geompy.AddObject(CreateGroup, f_ind_1) # box_faces[0]
245 geompy.AddObject(CreateGroup, f_ind_4) # box_faces[3]
246 # Now contains f_ind_6, f_ind_1, f_ind_4
249 geompy.UnionList(CreateGroup, [box_faces[2], box_faces[4], box_faces[5]])
250 # Now contains f_ind_6, f_ind_1, f_ind_4, f_ind_3, f_ind_5
252 # RemoveObject(theGroup, theSubShapeID)
253 geompy.RemoveObject(CreateGroup, f_ind_1) # box_faces[0]
254 # Now contains f_ind_6, f_ind_4, f_ind_3, f_ind_5
257 geompy.DifferenceList(CreateGroup, [box_faces[1], box_faces[0], box_faces[3]])
258 # Now contains f_ind_6, f_ind_3, f_ind_5
261 GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
263 print "Group of Box's faces includes the following IDs:"
264 print "(must be ", f_ind_6, ", ", f_ind_3, " and ", f_ind_5, ")"
265 for ObjectID in GetObjectIDs:
268 BoxCopy = geompy.GetMainShape(CreateGroup)
271 geompy.DifferenceIDs(CreateGroup, [f_ind_3, f_ind_5])
272 # Now contains f_ind_6
275 geompy.UnionIDs(CreateGroup, [f_ind_1, f_ind_2, f_ind_6])
276 # Now contains f_ind_6, f_ind_1, f_ind_2
279 GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
280 print "Group of Box's faces includes the following IDs:"
281 print "(must be ", f_ind_6, ", ", f_ind_1, " and ", f_ind_2, ")"
282 for ObjectID in GetObjectIDs:
285 # -----------------------------------------------------------------------------
286 # enumeration ShapeTypeString as a dictionary
287 # -----------------------------------------------------------------------------
288 ShapeTypeString = {'0':"COMPOUND", '1':"COMPSOLID", '2':"SOLID", '3':"SHELL", '4':"FACE", '5':"WIRE", '6':"EDGE", '7':"VERTEX", '8':"SHAPE"}
290 GroupType = geompy.GetType(CreateGroup)
291 print "Type of elements of the created group is ", ShapeTypeString[`GroupType`]
293 # Prepare data for the following operations
294 p0 = geompy.MakeVertex(0, 0, 0)
295 b0 = geompy.MakeBox(-50, -50, -50, 50, 50, 50)
296 s0 = geompy.MakeSphereR(100)
298 id_b0 = geompy.addToStudy(b0, "b0")
299 id_s0 = geompy.addToStudy(s0, "s0")
301 v_0pp = geompy.MakeVectorDXDYDZ( 0, 1, 1)
302 v_0np = geompy.MakeVectorDXDYDZ( 0, -1, 1)
303 v_p0p = geompy.MakeVectorDXDYDZ( 1, 0, 1)
304 v_n0p = geompy.MakeVectorDXDYDZ(-1, 0, 1)
305 v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0)
306 v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0)
307 v_0n0 = geompy.MakeVectorDXDYDZ( 0, -1, 0)
309 pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
310 pln_0np = geompy.MakePlane(p0, v_0np, 300)
311 pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
312 pln_n0p = geompy.MakePlane(p0, v_n0p, 300)
313 pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
314 pln_np0 = geompy.MakePlane(p0, v_np0, 300)
316 #part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0],
320 part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0])
322 id_part_tool_1 = geompy.addToStudy(part_tool_1, "part_tool_1")
324 pt_pnt_1 = geompy.MakeVertex( 55, 0, 55)
325 pt_pnt_2 = geompy.MakeVertex( 0, 55, 55)
326 pt_pnt_3 = geompy.MakeVertex(-55, 0, 55)
327 pt_pnt_4 = geompy.MakeVertex( 0, -55, 55)
328 pt_pnt_5 = geompy.MakeVertex( 55, 55, 0)
329 pt_pnt_6 = geompy.MakeVertex( 55, -55, 0)
330 pt_pnt_7 = geompy.MakeVertex(-55, 55, 0)
331 pt_pnt_8 = geompy.MakeVertex(-55, -55, 0)
332 pt_pnt_9 = geompy.MakeVertex( 55, 0, -55)
333 pt_pnt_10 = geompy.MakeVertex( 0, 55, -55)
334 pt_pnt_11 = geompy.MakeVertex(-55, 0, -55)
335 pt_pnt_12 = geompy.MakeVertex( 0, -55, -55)
337 pt_face_1 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_1)
338 pt_face_2 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_2)
339 pt_face_3 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_3)
340 pt_face_4 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_4)
341 pt_face_5 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_5)
342 pt_face_6 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_6)
343 pt_face_7 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_7)
344 pt_face_8 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_8)
345 pt_face_9 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_9)
346 pt_face_10 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_10)
347 pt_face_11 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_11)
348 pt_face_12 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_12)
350 #pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
352 #part_tool = geompy.MakeCompound([pt_face_1, pt_face_4, pt_face_7, pt_face_10,
353 # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
354 # #pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box])
355 # pt_face_3, pt_face_6, pt_face_9, pt_face_12)
356 #id_part_tool = geompy.addToStudy(part_tool, "part_tool")
358 #part = geompy.MakePartition([s0], [part_tool])
359 #part = geompy.MakePartition([s0], [ pt_face_1, pt_face_4, pt_face_7, pt_face_10,
360 # pt_face_2, pt_face_5, pt_face_8, pt_face_11,
361 # pt_face_3, pt_face_6, pt_face_9, pt_face_12, b0] )
363 p1 = geompy.MakeVertex(50, 0, 0)
364 p2 = geompy.MakeVertex(-50, 0, 0)
365 p3 = geompy.MakeVertex(0, 50, 0)
366 p4 = geompy.MakeVertex(0, -50, 0)
367 p5 = geompy.MakeVertex(0, 0, 50)
368 p6 = geompy.MakeVertex(0, 0, -50)
370 vx = geompy.MakeVectorDXDYDZ( 1, 0, 0)
371 vy = geompy.MakeVectorDXDYDZ( 0, 1, 0)
372 vz = geompy.MakeVectorDXDYDZ( 0, 0, 1)
374 plnX1 = geompy.MakePlane(p1, vx, 300)
375 plnX2 = geompy.MakePlane(p2, vx, 300)
376 plnY1 = geompy.MakePlane(p3, vy, 300)
377 plnY2 = geompy.MakePlane(p4, vy, 300)
378 plnZ1 = geompy.MakePlane(p5, vz, 300)
379 plnZ2 = geompy.MakePlane(p6, vz, 300)
381 #part = geompy.MakePartition([s0], [plnX1,plnX2,plnY1,plnY2,plnZ1,plnZ2])
382 part = geompy.MakePartition([s0], [plnX1])
383 part = geompy.MakePartition([part], [plnX2])
384 part = geompy.MakePartition([part], [plnY1])
385 part = geompy.MakePartition([part], [plnY2])
386 part = geompy.MakePartition([part], [plnZ1])
387 part = geompy.MakePartition([part], [plnZ2])
388 geompy.addToStudy(part, "part")
391 anIDs = geompy.GetFreeFacesIDs(part)
392 freeFaces = geompy.GetSubShape(part, anIDs)
394 geompy.addToStudy(freeFaces, "freeFaces")
397 freeFacesWithoutExtra = geompy.RemoveExtraEdges(freeFaces)
399 geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra")
402 sharedFaces = geompy.GetSharedShapes(part, freeFacesWithoutExtra, geompy.ShapeType["FACE"])
404 for shFace in sharedFaces:
405 geompy.addToStudy(shFace, "sharedFace")
408 blocksComp = geompy.CheckAndImprove(part)
410 geompy.addToStudy(blocksComp, "blocksComp")
413 listChains = geompy.Propagate(blocksComp)
415 for chain in listChains:
416 geompy.addToStudyInFather(blocksComp, chain, "propagation chain")
418 # GetPoint(theShape, theX, theY, theZ, theEpsilon)
420 # (-50, 50, 50) .-----. (50, 50, 50)
424 # (-50, -50, 50) '-----' (50, -50, 50)
426 pb0_top_1 = geompy.GetPoint(blocksComp, -50, 50, 50, 0.01)
427 pb0_bot_1 = geompy.GetPoint(blocksComp, -50, -50, -50, 0.01)
429 geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50, 50, 50)")
430 geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)")
432 # GetEdgeNearPoint(theShape, thePoint)
433 pmidle = geompy.MakeVertex(50, 0, 50)
434 edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle)
436 geompy.addToStudyInFather(blocksComp, edge1, "edge near point (50, 0, 50)")
438 # GetBlockByParts(theCompound, theParts)
439 b0_image = geompy.GetBlockByParts(blocksComp, [pb0_top_1, pb0_bot_1, edge1])
441 geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
444 faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
445 v_0pp, geompy.GEOM.ST_ONIN)
446 for face_i in faces_on_pln:
447 geompy.addToStudy(face_i, "Face on Plane (N = (0, 1, 1)) or below it")
449 # GetShapesOnPlaneIDs
450 faces_above_pln_ids = geompy.GetShapesOnPlaneIDs(blocksComp, geompy.ShapeType["FACE"],
451 v_0pp, geompy.GEOM.ST_OUT)
452 faces_above = geompy.CreateGroup(blocksComp, geompy.ShapeType["FACE"])
453 geompy.UnionIDs(faces_above, faces_above_pln_ids)
454 geompy.addToStudy(faces_above, "Group of faces above Plane (N = (0, 1, 1))")
456 # GetShapesOnPlaneWithLocation
457 Loc = geompy.MakeVertex(0, -50, 0)
458 edges_on_pln = geompy.GetShapesOnPlaneWithLocation(blocksComp, geompy.ShapeType["EDGE"],
459 v_0n0, Loc, geompy.GEOM.ST_ON)
460 for edge_i in edges_on_pln:
461 geompy.addToStudy(edge_i, "Edge on Plane (N = (0, -1, 0) & Location = (0, -50, 0)")
463 # GetShapesOnPlaneWithLocationIDs
464 edges_on_pln_ids = geompy.GetShapesOnPlaneWithLocationIDs(blocksComp, geompy.ShapeType["EDGE"],
465 v_0n0, Loc, geompy.GEOM.ST_ON)
466 group_edges_on_pln = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
467 geompy.UnionIDs(group_edges_on_pln, edges_on_pln_ids)
468 geompy.addToStudy(group_edges_on_pln, "Group of edges on Plane (N = (0, -1, 0) & Location = (0, -50, 0))")
470 # GetShapesOnCylinder
471 edges_out_cyl = geompy.GetShapesOnCylinder(blocksComp, geompy.ShapeType["EDGE"],
472 vy, 55, geompy.GEOM.ST_OUT)
473 for edge_i in edges_out_cyl:
474 geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), r = 55)")
476 # GetShapesOnCylinderIDs
477 edges_in_cyl_ids = geompy.GetShapesOnCylinderIDs(blocksComp, geompy.ShapeType["EDGE"],
478 vy, 80, geompy.GEOM.ST_IN)
479 edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
480 geompy.UnionIDs(edges_in, edges_in_cyl_ids)
481 geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)")
484 vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"],
485 p0, 100, geompy.GEOM.ST_ON)
486 for vertex_i in vertices_on_sph:
487 geompy.addToStudy(vertex_i, "Vertex on Sphere (center = (0, 0, 0), r = 100)")
490 # GetShapesOnSphereIDs
491 vertices_on_sph_ids = geompy.GetShapesOnSphereIDs(blocksComp, geompy.ShapeType["VERTEX"],
492 p0, 100, geompy.GEOM.ST_ON)
493 vertices_on = geompy.CreateGroup(blocksComp, geompy.ShapeType["VERTEX"])
494 geompy.UnionIDs(vertices_on, vertices_on_sph_ids)
495 geompy.addToStudy(vertices_on, "Group of vertices on Sphere (center = (0, 0, 0), r = 100)")
497 # GetShapesOnQuadrangle
499 geompy.addToStudy(f12, "F12" )
501 bl = geompy.MakeVertex(10,-10, 0)
502 br = geompy.MakeVertex(40,-10, 0)
503 tr = geompy.MakeVertex(40, 20, 0)
504 tl = geompy.MakeVertex(10, 20, 0)
505 qe1 = geompy.MakeEdge(bl, br)
506 qe2 = geompy.MakeEdge(br, tr)
507 qe3 = geompy.MakeEdge(tr, tl)
508 qe4 = geompy.MakeEdge(tl, bl)
509 quadrangle = geompy.MakeWire([qe1, qe2, qe3, qe4])
510 geompy.addToStudy(quadrangle, "Quadrangle")
512 edges_onin_quad = geompy.GetShapesOnQuadrangle( f12, geompy.ShapeType["EDGE"],
513 tl, tr, bl, br, geompy.GEOM.ST_ONIN)
514 comp = geompy.MakeCompound(edges_onin_quad)
515 geompy.addToStudy(comp, "Edges of F12 ONIN Quadrangle")
516 if len( edges_onin_quad ) != 4:
517 print "Error in GetShapesOnQuadrangle()"
520 # GetShapesOnQuadrangleIDs
521 vertices_on_quad_ids = geompy.GetShapesOnQuadrangleIDs(f12, geompy.ShapeType["VERTEX"],
522 tl, tr, bl, br, geompy.GEOM.ST_ON)
523 vertices_on_quad = geompy.CreateGroup(f12, geompy.ShapeType["VERTEX"])
524 geompy.UnionIDs(vertices_on_quad, vertices_on_quad_ids)
525 geompy.addToStudy(vertices_on_quad, "Group of vertices on Quadrangle F12")
527 # GetInPlace(theShapeWhere, theShapeWhat)
528 box5 = geompy.MakeBoxDXDYDZ(100, 100, 100)
529 box6 = geompy.MakeTranslation(box5, 50, 50, 0)
531 part = geompy.MakePartition([box5], [box6])
532 geompy.addToStudy(part, "Partitioned")
535 box_list = [box5, box6]
536 for abox in box_list:
537 geompy.addToStudy(abox, "Box " + `ibb`)
538 box_faces = geompy.SubShapeAll(abox, geompy.ShapeType["FACE"])
540 for aface in box_faces:
541 geompy.addToStudyInFather(abox, aface, "Face" + `ifa`)
542 refl_box_face = geompy.GetInPlace(part, aface)
543 if refl_box_face is not None:
544 geompy.addToStudyInFather(part, refl_box_face,
545 "Reflection of Face " + `ifa` + " of box " + `ibb`)