X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_SWIG%2FGEOM_TestOthers.py;h=73d91287d3483359cbffd71b065950ad8e772493;hb=c31446905814a9a2f97f24aed67df3e69f68031b;hp=fb8c18bf8af5c028e2b6a20cd80a5570a7cf9bc8;hpb=cb234e246225d575d6682ca4587e54b5f6f30497;p=modules%2Fgeom.git diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index fb8c18bf8..73d91287d 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -1,35 +1,35 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# GEOM GEOM_SWIG : binding of C++ implementaion with Python # File : GEOM_TestOthers.py # Author : Julia DOROVSKIKH # Module : GEOM # $Header$ +# # ! Please, if you edit this example file, update also # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_others.doc # ! as some sequences of symbols from this example are used during # ! documentation generation to identify certain places of this file -# + import os def TestExportImport (geompy, shape): @@ -76,7 +76,7 @@ def TestExportImport (geompy, shape): geompy.ExportSTEP(shape, fileExportImportSTEP) # Import - Import = geompy.Import(fileExportImport, "BREP") + Import = geompy.ImportFile(fileExportImport, "BREP") id_Import = geompy.addToStudy(Import, "Import") @@ -180,7 +180,7 @@ def TestOtherOperations (geompy, math): # MakeFilletAll radius_fillet = 10. - face5 = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5]) + face5 = geompy.SubShapeSortedCentres(Box, geompy.ShapeType["FACE"], [5]) f_glob_id = geompy.GetSubShapeID(Box, face5) SuppFace = geompy.SuppressFaces(Box, [f_glob_id]) @@ -195,7 +195,7 @@ def TestOtherOperations (geompy, math): # MakeChamfer d1 = 13. d2 = 7. - box_faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + box_faces = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0]) f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1]) f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2]) @@ -243,6 +243,11 @@ def TestOtherOperations (geompy, math): IsValid = geompy.CheckCompoundOfBlocks(Compound1) if IsValid == 0: print "The Blocks Compound is NOT VALID" + (NonBlocks, NonQuads) = geompy.GetNonBlocks(Compound1) + if NonBlocks is not None: + geompy.addToStudyInFather(Compound1, NonBlocks, "Group of non-hexahedral solids") + if NonQuads is not None: + geompy.addToStudyInFather(Compound1, NonQuads, "Group of non-quadrangular faces") else: print "The Blocks Compound is VALID" @@ -425,7 +430,7 @@ def TestOtherOperations (geompy, math): Partition_1 = geompy.MakePartition([Sphere], tools, [], [], geompy.ShapeType["SOLID"], 0, []) geompy.addToStudy(Partition_1, "Partition_1") - faces = geompy.SubShapeAllSorted(Partition_1, geompy.ShapeType["FACE"]) + faces = geompy.SubShapeAllSortedCentres(Partition_1, geompy.ShapeType["FACE"]) Face_1 = faces[0] Face_2 = faces[39] @@ -468,11 +473,21 @@ def TestOtherOperations (geompy, math): geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra") # GetSharedShapes - sharedFaces = geompy.GetSharedShapes(part, freeFacesWithoutExtra, + sharedFaces = geompy.GetSharedShapes(part, freeFaces, geompy.ShapeType["FACE"]) - + ind = 1 for shFace in sharedFaces: - geompy.addToStudy(shFace, "sharedFace") + geompy.addToStudy(shFace, "sharedFace_" + `ind`) + ind = ind + 1 + pass + + sharedEdges = geompy.GetSharedShapesMulti([part, freeFaces], + geompy.ShapeType["EDGE"]) + ind = 1 + for shEdge in sharedEdges: + geompy.addToStudy(shEdge, "sharedEdge_" + `ind`) + ind = ind + 1 + pass # CheckAndImprove blocksComp = geompy.CheckAndImprove(part) @@ -499,6 +514,17 @@ def TestOtherOperations (geompy, math): geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50, 50, 50)") geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)") + # GetVertexNearPoint(theShape, thePoint) + pb0_top_2_near = geompy.MakeVertex(40, 40, 40) + pb0_top_2 = geompy.GetVertexNearPoint(blocksComp, pb0_top_2_near) + + geompy.addToStudyInFather(blocksComp, pb0_top_2, "point from blocksComp near (40, 40, 40)") + + # GetEdge(theShape, thePoint1, thePoint2) + edge_top_y50 = geompy.GetEdge(blocksComp, pb0_top_1, pb0_top_2) + + geompy.addToStudyInFather(blocksComp, edge_top_y50, "edge from blocksComp by two points") + # GetEdgeNearPoint(theShape, thePoint) pmidle = geompy.MakeVertex(50, 0, 50) edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle) @@ -510,6 +536,11 @@ def TestOtherOperations (geompy, math): geompy.addToStudyInFather(blocksComp, b0_image, "b0 image") + # GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance) + b0_faces_plus = geompy.GetShapesNearPoint(blocksComp, pb0_top_2_near, geompy.ShapeType["FACE"], 0.01) + + geompy.addToStudyInFather(blocksComp, b0_faces_plus, "faces near point (40, 40, 40)") + # GetShapesOnPlane faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"], v_0pp, geompy.GEOM.ST_ONIN) @@ -551,6 +582,19 @@ def TestOtherOperations (geompy, math): geompy.UnionIDs(edges_in, edges_in_cyl_ids) geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)") + # GetShapesOnCylinderWithLocation + edges_out_cyl = geompy.GetShapesOnCylinderWithLocation(blocksComp, geompy.ShapeType["EDGE"], + vy, p11, 55, geompy.GEOM.ST_OUT) + for edge_i in edges_out_cyl: + geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), loc = (0, 0, 0), r = 55)") + + # GetShapesOnCylinderWithLocationIDs + edges_in_cyl_ids = geompy.GetShapesOnCylinderWithLocationIDs(blocksComp, geompy.ShapeType["EDGE"], + vy, p11, 80, geompy.GEOM.ST_IN) + edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"]) + geompy.UnionIDs(edges_in, edges_in_cyl_ids) + geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), loc = (0, 0, 0), r = 80)") + # GetShapesOnSphere vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"], p0, 100, geompy.GEOM.ST_ON) @@ -614,10 +658,10 @@ def TestOtherOperations (geompy, math): pcyl = geompy.MakeVertex(50, 50, -50) cyli = geompy.MakeCylinder(pcyl, vz, 40, 100) fuse = geompy.MakeFuse(sph1, cyli) - fuse = geompy.MakeFuse(fuse, sph2) + sh_1 = geompy.MakeFuse(fuse, sph2) # As after Fuse we have a compound, we need to obtain a solid from it - shsh = geompy.SubShapeAll(fuse, geompy.ShapeType["SOLID"]) - sh_1 = shsh[0] + #shsh = geompy.SubShapeAll(fuse, geompy.ShapeType["SOLID"]) + #sh_1 = shsh[0] geompy.addToStudy(sh_1, "sh_1") # GetShapesOnShape