From: azv Date: Wed, 19 Dec 2018 09:36:49 +0000 (+0300) Subject: [Code coverage GeomAlgoAPI]: Additional tests for Revolution and Extrusion X-Git-Tag: End2018~36 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9499654d176cf811426e1ef3a6fba86cd78d200e;p=modules%2Fshaper.git [Code coverage GeomAlgoAPI]: Additional tests for Revolution and Extrusion --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 532e40e00..5e5b11f0a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -182,6 +182,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestRevolution_ByAngle.py TestRevolutionOfPoint.py TestRevolutionOfEdge.py + TestRevolutionOfCompound.py TestRevolutionCut.py TestRevolutionCut_ByAngle.py TestRevolutionCut_ByPlanesAndOffsets.py diff --git a/src/FeaturesPlugin/Test/TestExtrusionOfCompound.py b/src/FeaturesPlugin/Test/TestExtrusionOfCompound.py index 27c1a74ed..ed3258b5d 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionOfCompound.py +++ b/src/FeaturesPlugin/Test/TestExtrusionOfCompound.py @@ -22,6 +22,7 @@ from salome.shaper import model model.begin() partSet = model.moduleDocument() + Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) @@ -31,6 +32,17 @@ model.do() Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection(), model.selection(), 0, model.selection("FACE", "PartSet/XOY"), 10) model.do() + +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Sketch_2 = model.addSketch(Part_2_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(15, -20, 8) +SketchCircle_4 = Sketch_2.addCircle(35, -5, 15) +model.do() +Compound_2 = model.addCompound(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) +Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection(), 10, 0) +model.do() + model.end() from GeomAPI import GeomAPI_Shape @@ -43,4 +55,12 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [12]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [24]) model.testResultsVolumes(Extrusion_1, [9079.2027688745]) +model.testNbResults(Extrusion_2, 1) +model.testNbSubResults(Extrusion_2, [2]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.FACE, [6]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.EDGE, [12]) +model.testNbSubShapes(Extrusion_2, GeomAPI_Shape.VERTEX, [24]) +model.testResultsVolumes(Extrusion_2, [9079.2027688745]) + assert(model.checkPythonDump()) \ No newline at end of file diff --git a/src/FeaturesPlugin/Test/TestRevolutionOfCompound.py b/src/FeaturesPlugin/Test/TestRevolutionOfCompound.py new file mode 100644 index 000000000..76d70a82a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRevolutionOfCompound.py @@ -0,0 +1,84 @@ +## 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 +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() + +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(15, -20, 8) +SketchCircle_2 = Sketch_1.addCircle(35, -35, 15) +model.do() +Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection("EDGE", "PartSet/OX"), model.selection(), 0, model.selection("FACE", "PartSet/XOZ"), 0) +model.do() + +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Sketch_2 = model.addSketch(Part_2_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(15, -20, 8) +SketchCircle_4 = Sketch_2.addCircle(35, -35, 15) +model.do() +Compound_2 = model.addCompound(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) +Revolution_2 = model.addRevolution(Part_2_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection("EDGE", "PartSet/OX"), 90, 0) +model.do() + +Part_3 = model.addPart(partSet) +Part_3_doc = Part_3.document() +Sketch_3 = model.addSketch(Part_3_doc, model.defaultPlane("XOY")) +SketchCircle_5 = Sketch_3.addCircle(15, -20, 8) +SketchCircle_6 = Sketch_3.addCircle(35, -35, 15) +model.do() +Compound_3 = model.addCompound(Part_3_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) +Revolution_3 = model.addRevolution(Part_3_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection("EDGE", "PartSet/OX"), model.selection("FACE", "PartSet/XOY"), 0, model.selection("FACE", "PartSet/XOZ"), 0) +model.do() + +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Revolution_1, 1) +model.testNbSubResults(Revolution_1, [0]) +model.testNbSubShapes(Revolution_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Revolution_1, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Revolution_1, GeomAPI_Shape.EDGE, [8]) +model.testNbSubShapes(Revolution_1, GeomAPI_Shape.VERTEX, [16]) +model.testResultsVolumes(Revolution_1, [38861.56734363]) + +model.testNbResults(Revolution_2, 1) +model.testNbSubResults(Revolution_2, [2]) +model.testNbSubShapes(Revolution_2, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Revolution_2, GeomAPI_Shape.FACE, [6]) +model.testNbSubShapes(Revolution_2, GeomAPI_Shape.EDGE, [12]) +model.testNbSubShapes(Revolution_2, GeomAPI_Shape.VERTEX, [24]) +model.testResultsVolumes(Revolution_2, [45178.11414513]) + +model.testNbResults(Revolution_3, 1) +model.testNbSubResults(Revolution_3, [0]) +model.testNbSubShapes(Revolution_3, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Revolution_3, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Revolution_3, GeomAPI_Shape.EDGE, [6]) +model.testNbSubShapes(Revolution_3, GeomAPI_Shape.VERTEX, [12]) +model.testResultsVolumes(Revolution_3, [38861.56733864]) + +assert(model.checkPythonDump()) \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 3e46fe132..d7d6e5b7a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -193,27 +193,21 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, aTrsf.SetTranslation(anExtVec * -theFromSize); BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf); - if(!aTransformBuilder) { + if(!aTransformBuilder || !aTransformBuilder->IsDone()) { return; } this->appendAlgo(std::shared_ptr( new GeomAlgoAPI_MakeShape(aTransformBuilder))); - if(!aTransformBuilder->IsDone()) { - return; - } TopoDS_Shape aMovedBase = aTransformBuilder->Shape(); // Making prism. BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, anExtVec * (theFromSize + theToSize)); - if(!aPrismBuilder) { + if(!aPrismBuilder || !aPrismBuilder->IsDone()) { return; } this->appendAlgo(std::shared_ptr( new GeomAlgoAPI_MakeShape(aPrismBuilder))); - if(!aPrismBuilder->IsDone()) { - return; - } aResult = aPrismBuilder->Shape(); // Setting naming. @@ -293,27 +287,21 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, gp_Trsf aTrsf; aTrsf.SetTranslation(anExtVec * -aPrismLength); BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf); - if(!aTransformBuilder) { + if(!aTransformBuilder || !aTransformBuilder->IsDone()) { return; } this->appendAlgo(std::shared_ptr( new GeomAlgoAPI_MakeShape(aTransformBuilder))); - if(!aTransformBuilder->IsDone()) { - return; - } TopoDS_Shape aMovedBase = aTransformBuilder->Shape(); // Making prism. BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, anExtVec * 2 * aPrismLength); - if(!aPrismBuilder) { + if(!aPrismBuilder || !aPrismBuilder->IsDone()) { return; } this->appendAlgo(std::shared_ptr( new GeomAlgoAPI_MakeShape(aPrismBuilder))); - if(!aPrismBuilder->IsDone()) { - return; - } aResult = aPrismBuilder->Shape(); // Orienting bounding planes. @@ -434,14 +422,13 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, } // Setting result. - if(aResult.IsNull()) { - return; + if (!aResult.IsNull()) { + aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); + GeomShapePtr aGeomSh(new GeomAPI_Shape()); + aGeomSh->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aGeomSh); + this->setDone(true); } - aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); - GeomShapePtr aGeomSh(new GeomAPI_Shape()); - aGeomSh->setImpl(new TopoDS_Shape(aResult)); - this->setShape(aGeomSh); - this->setDone(true); } // Auxilary functions: