From: jfa Date: Tue, 6 Sep 2022 13:06:18 +0000 (+0300) Subject: Correct test X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e738a9e72b5a9005c27520ee108cfbfcb5ad07c0;p=modules%2Fgeom.git Correct test --- diff --git a/src/GEOM_SWIG/CMakeLists.txt b/src/GEOM_SWIG/CMakeLists.txt index 0aae52841..39f3ac6af 100644 --- a/src/GEOM_SWIG/CMakeLists.txt +++ b/src/GEOM_SWIG/CMakeLists.txt @@ -59,7 +59,6 @@ SET(_other_SCRIPTS GEOM_Nut.py GEOM_Sketcher.py GEOM_ObjectInfo.py - GEOM_TestCR.py PAL_MESH_019_020_geometry.py PAL_MESH_028_geometry.py PAL_MESH_030_geometry.py diff --git a/src/GEOM_SWIG/GEOM_TestCR.py b/src/GEOM_SWIG/GEOM_TestCR.py deleted file mode 100644 index 1bf0b2a09..000000000 --- a/src/GEOM_SWIG/GEOM_TestCR.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2022 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 -# -# 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, or (at your option) any later version. -# -# 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 -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import salome - -salome.salome_init() - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - -geompy = geomBuilder.New() - -def GetShapeType(theShape): - CR = geompy.CanonicalRecognition() - if CR.isLine(theShape, 0.1)[0]: - return "Line" - if CR.isPlane(theShape, 0.1)[0]: - if CR.isCircle(theShape, 0.1)[0]: - return ("Plane","Circle") - if CR.isEllipse(theShape, 0.1)[0]: - return ("Plane","Ellipse") - return "Plane" - if CR.isSphere(theShape, 0.1)[0]: - return "Sphere" - if CR.isCone(theShape, 0.1)[0]: - return "Cone" - if CR.isCylinder(theShape, 0.1)[0]: - return "Cylinder" - return "Not defined" - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(100, 300) -[Face_1,Face_2,Face_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["FACE"], True) -[Edge_1,Edge_2,Edge_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["EDGE"], True) -Sphere_1 = geompy.MakeSphereR(100) -[Shell_1] = geompy.ExtractShapes(Sphere_1, geompy.ShapeType["SHELL"], True) -Cone_1 = geompy.MakeConeR1R2H(100, 0, 300) -[Shell_2] = geompy.ExtractShapes(Cone_1, geompy.ShapeType["SHELL"], True) -[Face_4,Face_5] = geompy.ExtractShapes(Shell_2, geompy.ShapeType["FACE"], True) - -## Create ellips -Cylinder_2 = geompy.MakeCylinderRH(100, 300) -Plane_1 = geompy.MakePlaneLCS(None, 350, 1) -Translation_1 = geompy.MakeTranslation(Plane_1, 0, 0, 150) -Rotation_1 = geompy.MakeRotation(Translation_1, OX, 20*math.pi/180.0) -Partition_1 = geompy.MakePartition([Cylinder_2], [Rotation_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) -[Edge_4,Edge_5,Edge_6,Edge_7,Edge_8] = geompy.ExtractShapes(Partition_1, geompy.ShapeType["EDGE"], True) - -assert GetShapeType(Face_1) == "Plane" -assert GetShapeType(Face_2) == "Cylinder" -assert GetShapeType(Edge_3) == "Line" -assert GetShapeType(Edge_2)[1] == "Circle" -assert GetShapeType(Shell_1) == "Sphere" -assert GetShapeType(Shell_2) == "Cone" -assert GetShapeType(Edge_5)[1] == "Ellipse" diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index 827a257e7..5d6a516a2 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -2787,21 +2787,6 @@ class geomBuilder(GEOM._objref_GEOM_Gen): pl = Polyline2D (self) return pl - ## Obtain a 2D polyline creation interface - # @return An instance of @ref gsketcher.Polyline2D "Polyline2D" interface - # - # @ref tui_3dsketcher_page "Example" - def CanonicalRecognition (self): - """ - Obtain a canonical recognition interface. - - Example of usage: - cr = geompy.CanonicalRecognition() - cr.isLine(aLine, tolerance) - """ - cr = CanonicalRecognition (self) - return cr - # end of l3_sketcher ## @} @@ -11771,6 +11756,22 @@ class geomBuilder(GEOM._objref_GEOM_Gen): aDescr = self.MeasuOp.IsGoodForSolid(theShell) return aDescr + ## Obtain a canonical recognition interface. + # @return An instance of + # @ref canonicalrecognition.CanonicalRecognition "CanonicalRecognition" interface + # + # @ref tui_3dsketcher_page "Example" + def CanonicalRecognition (self): + """ + Obtain a canonical recognition interface. + + Example of usage: + cr = geompy.CanonicalRecognition() + cr.isLine(aLine, tolerance) + """ + cr = CanonicalRecognition (self) + return cr + # end of l2_measure ## @} diff --git a/test/test_CR.py b/test/test_CR.py new file mode 100644 index 000000000..1bf0b2a09 --- /dev/null +++ b/test/test_CR.py @@ -0,0 +1,80 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2022 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 +# +# 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, or (at your option) any later version. +# +# 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 +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import salome + +salome.salome_init() + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +geompy = geomBuilder.New() + +def GetShapeType(theShape): + CR = geompy.CanonicalRecognition() + if CR.isLine(theShape, 0.1)[0]: + return "Line" + if CR.isPlane(theShape, 0.1)[0]: + if CR.isCircle(theShape, 0.1)[0]: + return ("Plane","Circle") + if CR.isEllipse(theShape, 0.1)[0]: + return ("Plane","Ellipse") + return "Plane" + if CR.isSphere(theShape, 0.1)[0]: + return "Sphere" + if CR.isCone(theShape, 0.1)[0]: + return "Cone" + if CR.isCylinder(theShape, 0.1)[0]: + return "Cylinder" + return "Not defined" + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(100, 300) +[Face_1,Face_2,Face_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["FACE"], True) +[Edge_1,Edge_2,Edge_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["EDGE"], True) +Sphere_1 = geompy.MakeSphereR(100) +[Shell_1] = geompy.ExtractShapes(Sphere_1, geompy.ShapeType["SHELL"], True) +Cone_1 = geompy.MakeConeR1R2H(100, 0, 300) +[Shell_2] = geompy.ExtractShapes(Cone_1, geompy.ShapeType["SHELL"], True) +[Face_4,Face_5] = geompy.ExtractShapes(Shell_2, geompy.ShapeType["FACE"], True) + +## Create ellips +Cylinder_2 = geompy.MakeCylinderRH(100, 300) +Plane_1 = geompy.MakePlaneLCS(None, 350, 1) +Translation_1 = geompy.MakeTranslation(Plane_1, 0, 0, 150) +Rotation_1 = geompy.MakeRotation(Translation_1, OX, 20*math.pi/180.0) +Partition_1 = geompy.MakePartition([Cylinder_2], [Rotation_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) +[Edge_4,Edge_5,Edge_6,Edge_7,Edge_8] = geompy.ExtractShapes(Partition_1, geompy.ShapeType["EDGE"], True) + +assert GetShapeType(Face_1) == "Plane" +assert GetShapeType(Face_2) == "Cylinder" +assert GetShapeType(Edge_3) == "Line" +assert GetShapeType(Edge_2)[1] == "Circle" +assert GetShapeType(Shell_1) == "Sphere" +assert GetShapeType(Shell_2) == "Cone" +assert GetShapeType(Edge_5)[1] == "Ellipse" diff --git a/test/tests.set b/test/tests.set index f9d399eff..8b5c4e5a6 100644 --- a/test/tests.set +++ b/test/tests.set @@ -19,4 +19,5 @@ SET(ALL_TESTS test_perf_01.py + test_CR.py )