Back to index

salome-geom  6.5.0
Functions
GEOM_TestOthers Namespace Reference

Functions

def TestExportImport
def TestOtherOperations

Function Documentation

def GEOM_TestOthers.TestExportImport (   geompy,
  shape 
)

Definition at line 35 of file GEOM_TestOthers.py.

00035 
00036 def TestExportImport (geompy, shape):
00037 
00038   print "Test Export/Import ...",
00039 
00040   tmpDir = os.getenv("TEMP")
00041   if tmpDir == None:
00042     tmpDir = "/tmp"
00043 
00044   # Files for Export/Import testing
00045   fileExportImport = tmpDir + "/testExportImport.brep"
00046   fileExportImportBREP = tmpDir + "/testExportImportBREP.brep"
00047   fileExportImportIGES = tmpDir + "/testExportImportIGES.iges"
00048   fileExportImportSTEP = tmpDir + "/testExportImportSTEP.step"
00049 
00050   if os.access(fileExportImport, os.F_OK):
00051     if os.access(fileExportImport, os.W_OK):
00052       os.remove(fileExportImport)
00053     else:
00054       fileExportImport = tmpDir + "/testExportImport1.brep"
00055 
00056     if os.access(fileExportImportBREP, os.W_OK):
00057       os.remove(fileExportImportBREP)
00058     else:
00059       fileExportImportBREP = tmpDir + "/testExportImportBREP1.brep"
00060 
00061     if os.access(fileExportImportIGES, os.W_OK):
00062       os.remove(fileExportImportIGES)
00063     else:
00064       fileExportImportIGES = tmpDir + "/testExportImportIGES1.iges"
00065 
00066     if os.access(fileExportImportSTEP, os.W_OK):
00067       os.remove(fileExportImportSTEP)
00068     else:
00069       fileExportImportSTEP = tmpDir + "/testExportImportSTEP1.step"
00070 
00071   # Export
00072   geompy.Export(shape, fileExportImport, "BREP")
00073 
00074   # ExportBREP, ExportIGES, ExportSTEP
00075   geompy.ExportBREP(shape, fileExportImportBREP)
00076   geompy.ExportIGES(shape, fileExportImportIGES)
00077   geompy.ExportSTEP(shape, fileExportImportSTEP)
00078 
00079   # Import
00080   Import = geompy.ImportFile(fileExportImport, "BREP")
00081 
00082   id_Import = geompy.addToStudy(Import, "Import")
00083 
00084   # ImportBREP, ImportIGES, ImportSTEP
00085   ImportBREP = geompy.ImportBREP(fileExportImportBREP)
00086   ImportIGES = geompy.ImportIGES(fileExportImportIGES)
00087   ImportSTEP = geompy.ImportSTEP(fileExportImportSTEP)
00088 
00089   id_ImportBREP = geompy.addToStudy(ImportBREP, "ImportBREP")
00090   id_ImportIGES = geompy.addToStudy(ImportIGES, "ImportIGES")
00091   id_ImportSTEP = geompy.addToStudy(ImportSTEP, "ImportSTEP")
00092 
00093   # Remove files for Export/Import testing
00094   os.remove(fileExportImport)
00095   os.remove(fileExportImportBREP)
00096   os.remove(fileExportImportIGES)
00097   os.remove(fileExportImportSTEP)
00098 
00099   print "OK"
00100 

Here is the caller graph for this function:

def GEOM_TestOthers.TestOtherOperations (   geompy,
  math 
)

Definition at line 101 of file GEOM_TestOthers.py.

00101 
00102 def TestOtherOperations (geompy, math):
00103 
00104   # prepare data for further operations
00105   vx = geompy.MakeVectorDXDYDZ( 1,  0,  0)
00106   vy = geompy.MakeVectorDXDYDZ( 0,  1,  0)
00107   vz = geompy.MakeVectorDXDYDZ( 0,  0,  1)
00108 
00109   v_y = geompy.MakeVectorDXDYDZ( 0, -1,  0)
00110 
00111   p11 = geompy.MakeVertex( 0,  0, 0)
00112   p12 = geompy.MakeVertex(30,  0, 0)
00113   p13 = geompy.MakeVertex(30, 30, 0)
00114   p14 = geompy.MakeVertex( 0, 30, 0)
00115 
00116   p21 = geompy.MakeVertex(10, 10, 0)
00117   p22 = geompy.MakeVertex(20, 10, 0)
00118   p23 = geompy.MakeVertex(20, 20, 0)
00119   p24 = geompy.MakeVertex(10, 20, 0)
00120 
00121   e11 = geompy.MakeEdge(p11, p12)
00122   e12 = geompy.MakeEdge(p12, p13)
00123   e13 = geompy.MakeEdge(p13, p14)
00124   e14 = geompy.MakeEdge(p14, p11)
00125 
00126   e21 = geompy.MakeEdge(p21, p22)
00127   e22 = geompy.MakeEdge(p22, p23)
00128   e23 = geompy.MakeEdge(p23, p24)
00129   e24 = geompy.MakeEdge(p24, p21)
00130 
00131   w1 = geompy.MakeWire([e11, e12, e13, e14])
00132   w2 = geompy.MakeWire([e21, e22, e23, e24])
00133   w3 = geompy.MakeTranslation(w2, 0, 0, 10)
00134 
00135   id_w1 = geompy.addToStudy(w1, "Outside Wire")
00136   id_w2 = geompy.addToStudy(w2, "Inside Wire")
00137   id_w3 = geompy.addToStudy(w3, "Inside Wire, translated along OZ")
00138 
00139   # MakeFaces
00140   f12 = geompy.MakeFaces([w1, w2], 0)
00141   id_f12 = geompy.addToStudy(f12, "MakeFaces WO + WI")
00142 
00143   # Export/Import
00144   TestExportImport(geompy, f12)
00145 
00146   # OrientationChange
00147   Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
00148   Orientation = geompy.OrientationChange(Box)
00149   id_Orientation = geompy.addToStudy(Orientation, "OrientationChange")
00150 
00151   # MakeCommon, MakeCut, MakeFuse, MakeSection
00152   Sphere = geompy.MakeSphereR(100)
00153 
00154   Common  = geompy.MakeCommon (Box, Sphere)
00155   Cut     = geompy.MakeCut    (Box, Sphere)
00156   Fuse    = geompy.MakeFuse   (Box, Sphere)
00157   Section = geompy.MakeSection(Box, Sphere)
00158 
00159   id_Common  = geompy.addToStudy(Common,  "Common")
00160   id_Cut     = geompy.addToStudy(Cut,     "Cut")
00161   id_Fuse    = geompy.addToStudy(Fuse,    "Fuse")
00162   id_Section = geompy.addToStudy(Section, "Section")
00163 
00164   # Partition
00165   p100 = geompy.MakeVertex(100, 100, 100)
00166   p300 = geompy.MakeVertex(300, 300, 300)
00167   Box1 = geompy.MakeBoxTwoPnt(p100, p300)
00168   #Partition = geompy.Partition([Box], [Box1], [], [Box])
00169   Partition = geompy.Partition([Box], [Box1])
00170   id_Partition = geompy.addToStudy(Partition, "Partition of Box by Box1")
00171 
00172   # MakeMultiRotation1D, MakeMultiRotation2D
00173   pz = geompy.MakeVertex(0, 0, 100)
00174   vy = geompy.MakeVectorDXDYDZ(0, 100, 0)
00175 
00176   MultiRot1D = geompy.MakeMultiRotation1D(f12, vy, pz, 6)
00177   MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3)
00178 
00179   id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MakeMultiRotation1D")
00180   id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MakeMultiRotation2D")
00181 
00182   # MakeFilletAll
00183   radius_fillet = 10.
00184   face5 = geompy.SubShapeSortedCentres(Box, geompy.ShapeType["FACE"], [5])
00185   f_glob_id = geompy.GetSubShapeID(Box, face5)
00186   SuppFace = geompy.SuppressFaces(Box, [f_glob_id])
00187 
00188   MakeFilletAll = geompy.MakeFilletAll(SuppFace, radius_fillet)
00189   id_MakeFilletAll = geompy.addToStudy(MakeFilletAll, "MakeFilletAll")
00190 
00191   # MakeChamferAll
00192   dimension_chamfer = 10.
00193   MakeChamferAll = geompy.MakeChamferAll(SuppFace, dimension_chamfer)
00194   id_MakeChamferAll = geompy.addToStudy(MakeChamferAll, "MakeChamferAll")
00195 
00196   # MakeChamfer
00197   d1 = 13.
00198   d2 = 7.
00199   box_faces = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"])
00200   f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0])
00201   f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1])
00202   f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2])
00203 
00204   MakeChamfer = geompy.MakeChamfer(Box, d1, d2, geompy.ShapeType["FACE"],
00205                                    [f_ind_1, f_ind_2, f_ind_3])
00206   id_MakeChamfer = geompy.addToStudy(MakeChamfer, "MakeChamfer")
00207 
00208   # NumberOf
00209   NumberOfFaces = geompy.NumberOfFaces(Box)
00210   if NumberOfFaces != 6:
00211     print "Bad number of faces in BOX!"
00212 
00213   NumberOfEdges = geompy.NumberOfEdges(Box)
00214   if NumberOfEdges != 12:
00215     print "Bad number of edges in BOX!"
00216 
00217   NumberOfSolids = geompy.NumberOfSolids(Box)
00218   if NumberOfSolids != 1:
00219     print "Bad number of solids in BOX!"
00220 
00221   NumberOfShapes = geompy.NumberOfSubShapes(Box, geompy.ShapeType["SHAPE"])
00222   if NumberOfShapes != 34:
00223     print "Bad number of shapes in BOX!"
00224 
00225   # MakeBlockExplode
00226   Compound = geompy.MakeCompound([Box, Sphere])
00227   MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6)
00228 
00229   id_MakeBlockExplode = geompy.addToStudy(MakeBlockExplode[0], "MakeBlockExplode")
00230 
00231   # CheckCompoundOfBlocks
00232   p1 = geompy.MakeVertex(200, 0, 0)
00233   p2 = geompy.MakeVertex(400, 200, 200)
00234   p3 = geompy.MakeVertex(400, 50, 50)
00235   p4 = geompy.MakeVertex(600, 250, 250)
00236 
00237   Box2 = geompy.MakeBoxTwoPnt(p1, p2)
00238   Box3 = geompy.MakeBoxTwoPnt(p3, p4)
00239   Cyl  = geompy.MakeCylinderRH(50, 300)
00240   Cone = geompy.MakeConeR1R2H(150, 10, 400)
00241 
00242   Compound1 = geompy.MakeCompound([Box, Cyl, Cone, Box3, Box2])
00243 
00244   IsValid = geompy.CheckCompoundOfBlocks(Compound1)
00245   if IsValid == 0:
00246     print "The Blocks Compound is NOT VALID"
00247   else:
00248     print "The Blocks Compound is VALID"
00249 
00250   IsValid = geompy.CheckCompoundOfBlocks(Box)
00251   if IsValid == 0:
00252     print "The Box is NOT VALID"
00253   else:
00254     print "The Box is VALID"
00255 
00256   # GetSame
00257   Cone_ss = geompy.GetSame(Compound1, Cone)
00258   id_Cone_ss = geompy.addToStudyInFather(Compound1, Cone_ss, "Cone subshape")
00259 
00260   # test geometrical groups
00261 
00262   # CreateGroup
00263   CreateGroup = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
00264 
00265   id_CreateGroup = geompy.addToStudy(CreateGroup, "CreateGroup")
00266 
00267   # AddObject
00268   f_ind_4 = geompy.GetSubShapeID(Box, box_faces[3])
00269   f_ind_5 = geompy.GetSubShapeID(Box, box_faces[4])
00270   f_ind_6 = geompy.GetSubShapeID(Box, box_faces[5])
00271 
00272   geompy.AddObject(CreateGroup, f_ind_6) # box_faces[5]
00273   geompy.AddObject(CreateGroup, f_ind_1) # box_faces[0]
00274   geompy.AddObject(CreateGroup, f_ind_4) # box_faces[3]
00275   # Now contains f_ind_6, f_ind_1, f_ind_4
00276 
00277   # UnionList
00278   geompy.UnionList(CreateGroup, [box_faces[2], box_faces[4], box_faces[5]])
00279   # Now contains f_ind_6, f_ind_1, f_ind_4, f_ind_3, f_ind_5
00280 
00281   # RemoveObject(theGroup, theSubShapeID)
00282   geompy.RemoveObject(CreateGroup, f_ind_1) # box_faces[0]
00283   # Now contains f_ind_6, f_ind_4, f_ind_3, f_ind_5
00284 
00285   # DifferenceList
00286   geompy.DifferenceList(CreateGroup, [box_faces[1], box_faces[0], box_faces[3]])
00287   # Now contains f_ind_6, f_ind_3, f_ind_5
00288 
00289   # GetObjectIDs
00290   GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
00291 
00292   print "Group of Box's faces includes the following IDs:"
00293   print "(must be ", f_ind_6, ", ", f_ind_3, " and ", f_ind_5, ")"
00294   for ObjectID in GetObjectIDs:
00295     print " ", ObjectID
00296 
00297   # GetMainShape
00298   BoxCopy = geompy.GetMainShape(CreateGroup)
00299 
00300   # DifferenceIDs
00301   geompy.DifferenceIDs(CreateGroup, [f_ind_3, f_ind_5])
00302   # Now contains f_ind_6
00303 
00304   # UnionIDs
00305   geompy.UnionIDs(CreateGroup, [f_ind_1, f_ind_2, f_ind_6])
00306   # Now contains f_ind_6, f_ind_1, f_ind_2
00307 
00308   # Check
00309   GetObjectIDs = geompy.GetObjectIDs(CreateGroup)
00310   print "Group of Box's faces includes the following IDs:"
00311   print "(must be ", f_ind_6, ", ", f_ind_1, " and ", f_ind_2, ")"
00312   for ObjectID in GetObjectIDs:
00313     print " ", ObjectID
00314 
00315   # -----------------------------------------------------------------------------
00316   # enumeration ShapeTypeString as a dictionary
00317   # -----------------------------------------------------------------------------
00318   ShapeTypeString = {'0':"COMPOUND", '1':"COMPSOLID", '2':"SOLID", '3':"SHELL",
00319                      '4':"FACE", '5':"WIRE", '6':"EDGE", '7':"VERTEX", '8':"SHAPE"}
00320 
00321   GroupType = geompy.GetType(CreateGroup)
00322   print "Type of elements of the created group is ", ShapeTypeString[`GroupType`]
00323 
00324   # Prepare data for the following operations
00325   p0 = geompy.MakeVertex(0, 0, 0)
00326   b0 = geompy.MakeBox(-50, -50, -50, 50, 50, 50)
00327   s0 = geompy.MakeSphereR(100)
00328 
00329   id_b0 = geompy.addToStudy(b0, "b0")
00330   id_s0 = geompy.addToStudy(s0, "s0")
00331 
00332   v_0pp = geompy.MakeVectorDXDYDZ( 0,  1,  1)
00333   #v_0np = geompy.MakeVectorDXDYDZ( 0, -1,  1)
00334   v_p0p = geompy.MakeVectorDXDYDZ( 1,  0,  1)
00335   v_p0n = geompy.MakeVectorDXDYDZ(1,  0,  -1)
00336   v_pp0 = geompy.MakeVectorDXDYDZ( 1,  1,  0)
00337   v_pn0 = geompy.MakeVectorDXDYDZ(1,  -1,  0)
00338 
00339   #pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
00340   #pln_0np = geompy.MakePlane(p0, v_0np, 300)
00341   pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
00342   pln_p0n = geompy.MakePlane(p0, v_p0n, 300)
00343   pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
00344   pln_pn0 = geompy.MakePlane(p0, v_pn0, 300)
00345   #
00346   #part_objs = [b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0]
00347   #part_tool_1 = geompy.MakePartition(part_objs, [], [], [b0])
00348   #part_tool_1 = geompy.MakePartition(part_objs)
00349   #
00350   #id_part_tool_1 = geompy.addToStudy(part_tool_1, "part_tool_1")
00351   #
00352   #pt_pnt_1  = geompy.MakeVertex( 55,   0,  55)
00353   #pt_pnt_2  = geompy.MakeVertex(  0,  55,  55)
00354   #pt_pnt_3  = geompy.MakeVertex(-55,   0,  55)
00355   #pt_pnt_4  = geompy.MakeVertex(  0, -55,  55)
00356   #pt_pnt_5  = geompy.MakeVertex( 55,  55,   0)
00357   #pt_pnt_6  = geompy.MakeVertex( 55, -55,   0)
00358   #pt_pnt_7  = geompy.MakeVertex(-55,  55,   0)
00359   #pt_pnt_8  = geompy.MakeVertex(-55, -55,   0)
00360   #pt_pnt_9  = geompy.MakeVertex( 55,   0, -55)
00361   #pt_pnt_10 = geompy.MakeVertex(  0,  55, -55)
00362   #pt_pnt_11 = geompy.MakeVertex(-55,   0, -55)
00363   #pt_pnt_12 = geompy.MakeVertex(  0, -55, -55)
00364   #
00365   #pt_face_1  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_1)
00366   #pt_face_2  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_2)
00367   #pt_face_3  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_3)
00368   #pt_face_4  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_4)
00369   #pt_face_5  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_5)
00370   #pt_face_6  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_6)
00371   #pt_face_7  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_7)
00372   #pt_face_8  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_8)
00373   #pt_face_9  = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_9)
00374   #pt_face_10 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_10)
00375   #pt_face_11 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_11)
00376   #pt_face_12 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_12)
00377   #
00378   #pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
00379   #
00380   #comp_parts = [pt_face_1, pt_face_4, pt_face_7, pt_face_10,
00381   #              pt_face_2, pt_face_5, pt_face_8, pt_face_11,
00382   #              #pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box]
00383   #              pt_face_3, pt_face_6, pt_face_9, pt_face_12]
00384   #part_tool = geompy.MakeCompound(comp_parts)
00385   #id_part_tool = geompy.addToStudy(part_tool, "part_tool")
00386   #
00387   #part = geompy.MakePartition([s0], [part_tool])
00388   #
00389   #part_tools = [pt_face_1, pt_face_4, pt_face_7, pt_face_10,
00390   #              pt_face_2, pt_face_5, pt_face_8, pt_face_11,
00391   #              pt_face_3, pt_face_6, pt_face_9, pt_face_12, b0]
00392   #part = geompy.MakePartition([s0], part_tools)
00393 
00394   p1 = geompy.MakeVertex(50, 0, 0)
00395   p2 = geompy.MakeVertex(-50, 0, 0)
00396   p3 = geompy.MakeVertex(0, 50, 0)
00397   p4 = geompy.MakeVertex(0, -50, 0)
00398   p5 = geompy.MakeVertex(0, 0, 50)
00399   p6 = geompy.MakeVertex(0, 0, -50)
00400 
00401   plnX1 = geompy.MakePlane(p1, vx, 300)
00402   plnX2 = geompy.MakePlane(p2, vx, 300)
00403   plnY1 = geompy.MakePlane(p3, vy, 300)
00404   plnY2 = geompy.MakePlane(p4, vy, 300)
00405   plnZ1 = geompy.MakePlane(p5, vz, 300)
00406   plnZ2 = geompy.MakePlane(p6, vz, 300)
00407 
00408   #part = geompy.MakePartition([s0], [plnX1,plnX2,plnY1,plnY2,plnZ1,plnZ2])
00409   part = geompy.MakePartition([s0], [plnX1])
00410   part = geompy.MakePartition([part], [plnX2])
00411   part = geompy.MakePartition([part], [plnY1])
00412   part = geompy.MakePartition([part], [plnY2])
00413   part = geompy.MakePartition([part], [plnZ1])
00414   part = geompy.MakePartition([part], [plnZ2])
00415   geompy.addToStudy(part, "part")
00416 
00417   # GetFreeFacesIDs
00418   anIDs = geompy.GetFreeFacesIDs(part)
00419   freeFaces = geompy.GetSubShape(part, anIDs)
00420 
00421   geompy.addToStudy(freeFaces, "freeFaces")
00422 
00423   # RemoveExtraEdges with union of all faces, sharing common surfaces
00424   tools = [pln_pp0, pln_pn0, pln_p0p, pln_p0n]
00425 
00426   Partition_1 = geompy.MakePartition([Sphere], tools, [], [], geompy.ShapeType["SOLID"], 0, [])
00427   geompy.addToStudy(Partition_1, "Partition_1")
00428 
00429   faces = geompy.SubShapeAllSortedCentres(Partition_1, geompy.ShapeType["FACE"])
00430 
00431   Face_1 = faces[0]
00432   Face_2 = faces[39]
00433   Face_3 = faces[40]
00434 
00435   geompy.addToStudyInFather(Partition_1, Face_1, "Face_1")
00436   geompy.addToStudyInFather(Partition_1, Face_2, "Face_2")
00437   geompy.addToStudyInFather(Partition_1, Face_3, "Face_3")
00438 
00439   Vector_5 = geompy.MakeVectorDXDYDZ(0, 20, 0)
00440   geompy.addToStudy(Vector_5, "Vector_5")
00441 
00442   Rotation_1 = geompy.MakeRotation(Face_1, Vector_5, 90*math.pi/180.0)
00443   Rotation_2 = geompy.MakeRotation(Face_1, Vector_5, 180*math.pi/180.0)
00444   Rotation_3 = geompy.MakeRotation(Face_1, Vector_5, 270*math.pi/180.0)
00445 
00446   geompy.addToStudy(Rotation_1, "Rotation_1")
00447   geompy.addToStudy(Rotation_2, "Rotation_2")
00448   geompy.addToStudy(Rotation_3, "Rotation_3")
00449 
00450   Vector_6 = geompy.MakeVectorDXDYDZ(0, 0, 20)
00451   geompy.addToStudy(Vector_6, "Vector_6")
00452 
00453   Rotation_4 = geompy.MakeRotation(Face_1, Vector_6, 90*math.pi/180.0)
00454   Rotation_5 = geompy.MakeRotation(Face_1, Vector_6, -90*math.pi/180.0)
00455   geompy.addToStudy(Rotation_4, "Rotation_4")
00456   geompy.addToStudy(Rotation_5, "Rotation_5")
00457 
00458   Shell_1 = geompy.MakeShell([Face_1, Rotation_1, Rotation_2, Rotation_3, Rotation_4, Rotation_5])
00459   Solid_1 = geompy.MakeSolid([Shell_1])
00460   NoExtraEdges_1 = geompy.RemoveExtraEdges(Solid_1, True) # doUnionFaces = True
00461 
00462   geompy.addToStudy(Shell_1, "Shell_1")
00463   geompy.addToStudy(Solid_1, "Solid_1")
00464   geompy.addToStudy(NoExtraEdges_1, "NoExtraEdges_1")
00465 
00466   # RemoveExtraEdges (by default, doUnionFaces = False)
00467   freeFacesWithoutExtra = geompy.RemoveExtraEdges(freeFaces)
00468 
00469   geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra")
00470 
00471   # GetSharedShapes
00472   sharedFaces = geompy.GetSharedShapes(part, freeFaces,
00473                                        geompy.ShapeType["FACE"])
00474   ind = 1
00475   for shFace in sharedFaces:
00476     geompy.addToStudy(shFace, "sharedFace_" + `ind`)
00477     ind = ind + 1
00478     pass
00479 
00480   sharedEdges = geompy.GetSharedShapesMulti([part, freeFaces],
00481                                              geompy.ShapeType["EDGE"])
00482   ind = 1
00483   for shEdge in sharedEdges:
00484     geompy.addToStudy(shEdge, "sharedEdge_" + `ind`)
00485     ind = ind + 1
00486     pass
00487 
00488   # CheckAndImprove
00489   blocksComp = geompy.CheckAndImprove(part)
00490 
00491   geompy.addToStudy(blocksComp, "blocksComp")
00492 
00493   # Propagate
00494   listChains = geompy.Propagate(blocksComp)
00495 
00496   for chain in listChains:
00497     geompy.addToStudyInFather(blocksComp, chain, "propagation chain")
00498 
00499   # GetPoint(theShape, theX, theY, theZ, theEpsilon)
00500   #
00501   # (-50,  50, 50) .-----. (50,  50, 50)
00502   #      pb0_top_1 |     |
00503   #                |     . pmidle
00504   #                |     |
00505   # (-50, -50, 50) '-----' (50, -50, 50)
00506   #
00507   pb0_top_1 = geompy.GetPoint(blocksComp, -50,  50,  50, 0.01)
00508   pb0_bot_1 = geompy.GetPoint(blocksComp, -50, -50, -50, 0.01)
00509 
00510   geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50,  50,  50)")
00511   geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)")
00512 
00513   # GetVertexNearPoint(theShape, thePoint)
00514   pb0_top_2_near = geompy.MakeVertex(40, 40, 40)
00515   pb0_top_2      = geompy.GetVertexNearPoint(blocksComp, pb0_top_2_near)
00516 
00517   geompy.addToStudyInFather(blocksComp, pb0_top_2, "point from blocksComp near (40,  40,  40)")
00518 
00519   # GetEdge(theShape, thePoint1, thePoint2)
00520   edge_top_y50 = geompy.GetEdge(blocksComp, pb0_top_1, pb0_top_2)
00521 
00522   geompy.addToStudyInFather(blocksComp, edge_top_y50, "edge from blocksComp by two points")
00523 
00524   # GetEdgeNearPoint(theShape, thePoint)
00525   pmidle = geompy.MakeVertex(50, 0, 50)
00526   edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle)
00527 
00528   geompy.addToStudyInFather(blocksComp, edge1, "edge near point (50, 0, 50)")
00529 
00530   # GetBlockByParts(theCompound, theParts)
00531   b0_image = geompy.GetBlockByParts(blocksComp, [pb0_top_1, pb0_bot_1, edge1])
00532 
00533   geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
00534 
00535   # GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance)
00536   b0_faces_plus = geompy.GetShapesNearPoint(blocksComp, pb0_top_2_near, geompy.ShapeType["FACE"], 0.01)
00537 
00538   geompy.addToStudyInFather(blocksComp, b0_faces_plus, "faces near point (40,  40,  40)")
00539 
00540   # GetShapesOnPlane
00541   faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
00542                                          v_0pp, geompy.GEOM.ST_ONIN)
00543   for face_i in faces_on_pln:
00544     geompy.addToStudy(face_i, "Face on Plane (N = (0, 1, 1)) or below it")
00545 
00546   # GetShapesOnPlaneIDs
00547   faces_above_pln_ids = geompy.GetShapesOnPlaneIDs(blocksComp, geompy.ShapeType["FACE"],
00548                                                    v_0pp, geompy.GEOM.ST_OUT)
00549   faces_above = geompy.CreateGroup(blocksComp, geompy.ShapeType["FACE"])
00550   geompy.UnionIDs(faces_above, faces_above_pln_ids)
00551   geompy.addToStudy(faces_above, "Group of faces above Plane (N = (0, 1, 1))")
00552 
00553   # GetShapesOnPlaneWithLocation
00554   Loc = geompy.MakeVertex(0, -50, 0)
00555   edges_on_pln = geompy.GetShapesOnPlaneWithLocation(blocksComp, geompy.ShapeType["EDGE"],
00556                                                      v_y, Loc, geompy.GEOM.ST_ON)
00557   for edge_i in edges_on_pln:
00558     geompy.addToStudy(edge_i, "Edge on Plane (N = (0, -1, 0) & Location = (0, -50, 0)")
00559 
00560   # GetShapesOnPlaneWithLocationIDs
00561   edges_on_pln_ids = geompy.GetShapesOnPlaneWithLocationIDs(
00562            blocksComp, geompy.ShapeType["EDGE"], v_y, Loc, geompy.GEOM.ST_ON)
00563   group_edges_on_pln = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
00564   geompy.UnionIDs(group_edges_on_pln, edges_on_pln_ids)
00565   grname = "Group of edges on Plane (N = (0, -1, 0) & Location = (0, -50, 0))"
00566   geompy.addToStudy(group_edges_on_pln, grname)
00567 
00568   # GetShapesOnCylinder
00569   edges_out_cyl = geompy.GetShapesOnCylinder(blocksComp, geompy.ShapeType["EDGE"],
00570                                              vy, 55, geompy.GEOM.ST_OUT)
00571   for edge_i in edges_out_cyl:
00572     geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), r = 55)")
00573 
00574   # GetShapesOnCylinderIDs
00575   edges_in_cyl_ids = geompy.GetShapesOnCylinderIDs(blocksComp, geompy.ShapeType["EDGE"],
00576                                                    vy, 80, geompy.GEOM.ST_IN)
00577   edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
00578   geompy.UnionIDs(edges_in, edges_in_cyl_ids)
00579   geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)")
00580 
00581   # GetShapesOnCylinderWithLocation
00582   edges_out_cyl = geompy.GetShapesOnCylinderWithLocation(blocksComp, geompy.ShapeType["EDGE"],
00583                                                          vy, p11, 55, geompy.GEOM.ST_OUT)
00584   for edge_i in edges_out_cyl:
00585     geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0),  loc = (0, 0, 0), r = 55)")
00586 
00587   # GetShapesOnCylinderWithLocationIDs
00588   edges_in_cyl_ids = geompy.GetShapesOnCylinderWithLocationIDs(blocksComp, geompy.ShapeType["EDGE"],
00589                                                                vy, p11, 80, geompy.GEOM.ST_IN)
00590   edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
00591   geompy.UnionIDs(edges_in, edges_in_cyl_ids)
00592   geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), loc = (0, 0, 0), r = 80)")
00593 
00594   # GetShapesOnSphere
00595   vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"],
00596                                              p0, 100, geompy.GEOM.ST_ON)
00597   for vertex_i in vertices_on_sph:
00598     geompy.addToStudy(vertex_i, "Vertex on Sphere (center = (0, 0, 0), r = 100)")
00599 
00600   # GetShapesOnSphereIDs
00601   vertices_on_sph_ids = geompy.GetShapesOnSphereIDs(blocksComp, geompy.ShapeType["VERTEX"],
00602                                                     p0, 100, geompy.GEOM.ST_ON)
00603   vertices_on = geompy.CreateGroup(blocksComp, geompy.ShapeType["VERTEX"])
00604   geompy.UnionIDs(vertices_on, vertices_on_sph_ids)
00605   geompy.addToStudy(vertices_on, "Group of vertices on Sphere (center = (0, 0, 0), r = 100)")
00606 
00607   # GetShapesOnQuadrangle
00608 
00609   geompy.addToStudy(f12, "F12" )
00610 
00611   bl = geompy.MakeVertex(10,-10, 0)
00612   br = geompy.MakeVertex(40,-10, 0)
00613   tr = geompy.MakeVertex(40, 20, 0)
00614   tl = geompy.MakeVertex(10, 20, 0)
00615   qe1 = geompy.MakeEdge(bl, br)
00616   qe2 = geompy.MakeEdge(br, tr)
00617   qe3 = geompy.MakeEdge(tr, tl)
00618   qe4 = geompy.MakeEdge(tl, bl)
00619   quadrangle = geompy.MakeWire([qe1, qe2, qe3, qe4])
00620   geompy.addToStudy(quadrangle, "Quadrangle")
00621 
00622   edges_onin_quad = geompy.GetShapesOnQuadrangle(f12, geompy.ShapeType["EDGE"],
00623                                                  tl, tr, bl, br, geompy.GEOM.ST_ONIN)
00624   comp = geompy.MakeCompound(edges_onin_quad)
00625   geompy.addToStudy(comp, "Edges of F12 ONIN Quadrangle")
00626   if len( edges_onin_quad ) != 4:
00627     print "Error in GetShapesOnQuadrangle()"
00628 
00629   # GetShapesOnQuadrangleIDs
00630   vertices_on_quad_ids = geompy.GetShapesOnQuadrangleIDs(f12, geompy.ShapeType["VERTEX"],
00631                                                          tl, tr, bl, br, geompy.GEOM.ST_ON)
00632   vertices_on_quad = geompy.CreateGroup(f12, geompy.ShapeType["VERTEX"])
00633   geompy.UnionIDs(vertices_on_quad, vertices_on_quad_ids)
00634   geompy.addToStudy(vertices_on_quad, "Group of vertices on Quadrangle F12")
00635 
00636   # GetShapesOnBox
00637   edges_on_box = geompy.GetShapesOnBox(b0, part, geompy.ShapeType["EDGE"],
00638                                        geompy.GEOM.ST_ON)
00639   comp = geompy.MakeCompound(edges_on_box)
00640   geompy.addToStudy(comp, "Edges of part ON box b0")
00641   if len( edges_on_box ) != 12:
00642     print "Error in GetShapesOnBox()"
00643 
00644   # GetShapesOnBoxIDs
00645   faces_on_box_ids = geompy.GetShapesOnBoxIDs(b0, part, geompy.ShapeType["FACE"],
00646                                               geompy.GEOM.ST_ON)
00647   faces_on_box = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
00648   geompy.UnionIDs(faces_on_box, faces_on_box_ids)
00649   geompy.addToStudyInFather(part, faces_on_box, "Group of faces on box b0")
00650 
00651   # Prepare arguments for GetShapesOnShape
00652   sph1 = geompy.MakeSphere(50, 50,  50, 40)
00653   sph2 = geompy.MakeSphere(50, 50, -50, 40)
00654   pcyl = geompy.MakeVertex(50, 50, -50)
00655   cyli = geompy.MakeCylinder(pcyl, vz, 40, 100)
00656   fuse = geompy.MakeFuse(sph1, cyli)
00657   sh_1 = geompy.MakeFuse(fuse, sph2)
00658   # As after Fuse we have a compound, we need to obtain a solid from it
00659   #shsh = geompy.SubShapeAll(fuse, geompy.ShapeType["SOLID"])
00660   #sh_1 = shsh[0]
00661   geompy.addToStudy(sh_1, "sh_1")
00662 
00663   # GetShapesOnShape
00664   faces_in_sh = geompy.GetShapesOnShape(sh_1, part, geompy.ShapeType["FACE"],
00665                                         geompy.GEOM.ST_IN)
00666   comp = geompy.MakeCompound(faces_in_sh)
00667   geompy.addToStudy(comp, "Faces of part IN shape sh_1")
00668   if len(faces_in_sh) != 11:
00669     print "Error in GetShapesOnShape()"
00670 
00671   # GetShapesOnShapeAsCompound
00672   faces_in_sh_c = geompy.GetShapesOnShapeAsCompound(sh_1, part, geompy.ShapeType["FACE"],
00673                                                     geompy.GEOM.ST_IN)
00674   geompy.addToStudy(faces_in_sh_c, "Faces of part IN shape sh_1 (as compound)")
00675 
00676   # GetShapesOnShapeIDs
00677   edges_in_sh_ids = geompy.GetShapesOnShapeIDs(sh_1, part, geompy.ShapeType["EDGE"],
00678                                                geompy.GEOM.ST_IN)
00679   edges_in_sh = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
00680   geompy.UnionIDs(edges_in_sh, edges_in_sh_ids)
00681   geompy.addToStudyInFather(part, edges_in_sh, "Group of edges in shape sh_1")
00682   if len(edges_in_sh_ids) != 15:
00683     print "Error in GetShapesOnShapeIDs()"
00684 
00685   # Prepare arguments for GetInPlace and GetInPlaceByHistory
00686   box5 = geompy.MakeBoxDXDYDZ(100, 100, 100)
00687   box6 = geompy.MakeTranslation(box5, 50, 50, 0)
00688 
00689   geompy.addToStudy(box5, "Box 5")
00690   geompy.addToStudy(box6, "Box 6")
00691 
00692   part = geompy.MakePartition([box5], [box6])
00693   geompy.addToStudy(part, "Partitioned")
00694 
00695   box5_faces = geompy.SubShapeAll(box5, geompy.ShapeType["FACE"])
00696   box6_faces = geompy.SubShapeAll(box6, geompy.ShapeType["FACE"])
00697 
00698   for ifa in range(6):
00699     geompy.addToStudyInFather(box5, box5_faces[ifa], "Face" + `ifa + 1`)
00700     geompy.addToStudyInFather(box6, box6_faces[ifa], "Face" + `ifa + 1`)
00701 
00702   # GetInPlace(theShapeWhere, theShapeWhat)
00703   ibb = 5
00704   faces_list = [box5_faces, box6_faces]
00705   for afaces in faces_list:
00706     ifa = 1
00707     for aface in afaces:
00708       refl_box_face = geompy.GetInPlace(part, aface)
00709       if ibb == 6 and (ifa == 2 or ifa == 4):
00710         # For two faces of the tool box
00711         # there is no reflection in the result.
00712         if refl_box_face is not None:
00713           error = "Result of GetInPlace must be NULL for face "
00714           error += `ifa` + " of box " + `ibb`
00715           raise RuntimeError, error
00716       else:
00717         ssname = "Reflection of face " + `ifa` + " of box " + `ibb`
00718         geompy.addToStudyInFather(part, refl_box_face, ssname)
00719       ifa = ifa + 1
00720     ibb = ibb + 1
00721 
00722   # GetInPlaceByHistory(theShapeWhere, theShapeWhat)
00723   part = geompy.MakePartition([box5], [box6])
00724   geompy.addToStudy(part, "Partitioned")
00725 
00726   ibb = 5
00727   faces_list = [box5_faces, box6_faces]
00728   for afaces in faces_list:
00729     ifa = 1
00730     for aface in afaces:
00731       ssname = "Reflection of face " + `ifa` + " of box " + `ibb` + " (by history)"
00732       if ibb == 6 and (ifa == 2 or ifa == 4):
00733         # use IDL interface directly to avoid error message appearence in Python console
00734         refl_box_face = geompy.ShapesOp.GetInPlaceByHistory(part, aface)
00735         if refl_box_face is not None:
00736           geompy.addToStudyInFather(part, refl_box_face, ssname)
00737           error = "Result of GetInPlaceByHistory must be NULL for face "
00738           error += `ifa` + " of box " + `ibb`
00739           raise RuntimeError, error
00740       else:
00741         # use geompy interface
00742         refl_box_face = geompy.GetInPlaceByHistory(part, aface)
00743         geompy.addToStudyInFather(part, refl_box_face, ssname)
00744       ifa = ifa + 1
00745     ibb = ibb + 1
00746 
00747 #END

Here is the call graph for this function: