]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage GeomAlgoAPI]: Additional tests for Revolution and Extrusion
authorazv <azv@opencascade.com>
Wed, 19 Dec 2018 09:36:49 +0000 (12:36 +0300)
committerazv <azv@opencascade.com>
Wed, 19 Dec 2018 09:36:49 +0000 (12:36 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/TestExtrusionOfCompound.py
src/FeaturesPlugin/Test/TestRevolutionOfCompound.py [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp

index 532e40e009fc55421a93df1140ac73dd3f46c67f..5e5b11f0a7d0817e225c480880ebedecff16509a 100644 (file)
@@ -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
index 27c1a74ed4113384bc04a35ae0e85837cbd6b5bb..ed3258b5d3b76cc8e8ed8dc6ba0626eb6a5c2411 100644 (file)
@@ -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 (file)
index 0000000..76d70a8
--- /dev/null
@@ -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<mailto: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
index 3e46fe132a41360815e9a0481f98203851e26909..d7d6e5b7a69be37bcd2d1aafe843718e2a603140 100644 (file)
@@ -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<GeomAlgoAPI_MakeShape>(
       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<GeomAlgoAPI_MakeShape>(
       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<GeomAlgoAPI_MakeShape>(
       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<GeomAlgoAPI_MakeShape>(
       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: