From: cg246364 Date: Mon, 9 Nov 2020 13:20:30 +0000 (+0100) Subject: Add tests for Tube X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5189f292e242c2d2fa12afa1d1ea890f38757de9;p=modules%2Fshaper.git Add tests for Tube --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp index 9bc8a2d85..15f8bc79c 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.cpp @@ -23,6 +23,7 @@ #include #include +#include //================================================================================================= @@ -93,10 +94,15 @@ void GeomAlgoAPI_ROOTExport::buildMatAndMedium( //================================================================================================= void GeomAlgoAPI_ROOTExport::BuildVolume(const std::string theName, const std::string theGeometryName, - const std::string theMediumName) + const std::string theMediumName, + std::vector theListMedium) { - myContent += "TGeoVolume *" + theGeometryName + " = new TGeoVolume(\"" + theName; - myContent += "\"," + theGeometryName + "_tmp," + theMediumName + ");\n"; + bool aFound = (std::find(theListMedium.begin(), theListMedium.end(), theMediumName) + != theListMedium.end()); + if (aFound) { + myContent += "TGeoVolume *" + theGeometryName + " = new TGeoVolume(\"" + theName; + myContent += "\"," + theGeometryName + "_tmp," + theMediumName + ");\n"; + } } //================================================================================================= diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h index 4f0492eb3..3f0f66be6 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ROOTExport.h @@ -57,7 +57,8 @@ public: /// GEOMALGOAPI_EXPORT void BuildVolume(const std::string theName, const std::string theGeometryName, - const std::string theMediumName); + const std::string theMediumName, + std::vector theListMedium); /// Build the end of file GEOMALGOAPI_EXPORT void buildEnd(const std::string theName, const std::string theExportName); diff --git a/test.API/SHAPER/CMakeLists.txt b/test.API/SHAPER/CMakeLists.txt index f2d685503..ac521c98f 100644 --- a/test.API/SHAPER/CMakeLists.txt +++ b/test.API/SHAPER/CMakeLists.txt @@ -25,6 +25,7 @@ ADD_UNIT_TESTS_API( Primitives/TestCylinder.py Primitives/TestSphere.py Primitives/TestTorus.py + Primitives/TestTube.py Primitives/TestAPI_Box.py Primitives/TestAPI_Cone.py Primitives/TestAPI_Cylinder.py diff --git a/test.API/SHAPER/Primitives/TestTube.py b/test.API/SHAPER/Primitives/TestTube.py new file mode 100644 index 000000000..fe007e173 --- /dev/null +++ b/test.API/SHAPER/Primitives/TestTube.py @@ -0,0 +1,55 @@ +# Copyright (C) 2014-2019 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 +# + +""" +Test case for Primitive Tube feature. +Written on High API. +""" +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +# Tests +Tube_1 = model.addTube(Part_1_doc, 2, 7, 15) +Tube_2 = model.addTube(Part_1_doc, 2, 7, 15, 45, 270) +Tube_3 = model.addTube(Part_1_doc, 2, 7, -15) + +model.do() +model.end() + +# Checks +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Tube_1, 1) +model.testNbSubResults(Tube_1, [0]) +model.testNbSubShapes(Tube_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Tube_1, GeomAPI_Shape.FACE, [4]) +model.testHaveNamingFaces(Tube_1, model, Part_1_doc) + + +model.testNbResults(Tube_2, 1) +model.testNbSubResults(Tube_2, [0]) +model.testNbSubShapes(Tube_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Tube_2, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Tube_2, model, Part_1_doc) + +model.testNbResults(Tube_3, 0)