From 31a11bcc6eb89d2f4eab7b6b782f16bb0b6f754b Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 20 Dec 2018 07:50:33 +0300 Subject: [PATCH] [Code coverage GeomAPI]: Unit test for lines (2D and 3D) --- src/GeomAPI/CMakeLists.txt | 1 + src/GeomAPI/Test/TestCone.py | 14 +++++++++++++ src/GeomAPI/Test/TestLine.py | 39 ++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/GeomAPI/Test/TestLine.py diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index 918fe8308..28088abb4 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -165,6 +165,7 @@ ADD_UNIT_TESTS( TestCone.py TestCylinder.py TestEllipse2d.py + TestLine.py TestPlanarEdge.py TestPolygon.py TestSphere.py diff --git a/src/GeomAPI/Test/TestCone.py b/src/GeomAPI/Test/TestCone.py index e82be0d97..474a6285c 100644 --- a/src/GeomAPI/Test/TestCone.py +++ b/src/GeomAPI/Test/TestCone.py @@ -289,5 +289,19 @@ anEdge = model.addEdge(Part_1_doc, [model.selection("EDGE", "[Partition_1_1_2/Mo aShape = anEdge.result().resultSubShapePair()[0].shape() assert(aShape.isEdge()) assert(aShape.edge().circle() is None) +assert(aShape.isSelfIntersected() == False) + +# Test 10. Test cone constructors +apex = GeomAPI_Pnt(10, 0, 0) +dir = GeomAPI_Dir(1, 0, 0) +semiAngle = math.pi / 4 +cone = GeomAPI_Cone(apex, dir, semiAngle) +assert(cone.location().distance(apex) < TOLERANCE) + +radius = 5 +cone = GeomAPI_Cone(apex, dir, semiAngle, radius) +assert(cone.location().distance(apex) < TOLERANCE) + + model.end() diff --git a/src/GeomAPI/Test/TestLine.py b/src/GeomAPI/Test/TestLine.py new file mode 100644 index 000000000..ba9b24700 --- /dev/null +++ b/src/GeomAPI/Test/TestLine.py @@ -0,0 +1,39 @@ +## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## +## 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 math + +from GeomAPI import * + +TOLERANCE = 1.e-7 + +loc = GeomAPI_Pnt2d(10, 0) +axis = GeomAPI_Dir2d(1, 0) + +# Test 1. GeomAPI_Lin2d +line2d = GeomAPI_Lin2d(loc, axis) +assert(line2d.location().distance(loc) < TOLERANCE) +assert(line2d.isRight(GeomAPI_Pnt2d(15, 5))) + +# Test 2. GeomAPI_Lin +ln1 = GeomAPI_Lin(10, 0, 0, 20, 0, 0) +ln2 = GeomAPI_Lin(15, -1, 1, 15, 1, 1) +assert(ln1.isCoplanar(ln2) == False) +assert(ln1.contains(None, TOLERANCE) == False) -- 2.30.2