From a82d355c2258c589b3f22473962f69e69e645f7b Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 18 Dec 2018 15:29:45 +0300 Subject: [PATCH] [Code coverage FeaturesAPI]: Improve coverage of ExtrusionBoolean feature --- .../FeaturesAPI_ExtrusionBoolean.cpp | 24 ++++--------------- .../TestExtrusionCut_ByPlanesAndOffsets.py | 2 +- .../Test/TestExtrusionCut_BySize.py | 14 +++++++++++ .../TestExtrusionFuse_ByPlanesAndOffsets.py | 2 +- .../Test/TestExtrusionFuse_BySize.py | 14 +++++++++++ 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp index c78fe3a47..90f99e306 100644 --- a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp @@ -263,11 +263,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut( { if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); - fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod); - fillAttribute(theToObject, mytoObject); - fillAttribute(theToOffset, mytoOffset); - fillAttribute(theFromObject, myfromObject); - fillAttribute(theFromOffset, myfromOffset); + setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); setBooleanObjects(theBooleanObjects); } } @@ -287,11 +283,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut( if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theDirection, mydirection); - fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod); - fillAttribute(theToObject, mytoObject); - fillAttribute(theToOffset, mytoOffset); - fillAttribute(theFromObject, myfromObject); - fillAttribute(theFromOffset, myfromOffset); + setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); setBooleanObjects(theBooleanObjects); } } @@ -482,11 +474,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse( { if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); - fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod); - fillAttribute(theToObject, mytoObject); - fillAttribute(theToOffset, mytoOffset); - fillAttribute(theFromObject, myfromObject); - fillAttribute(theFromOffset, myfromOffset); + setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); setBooleanObjects(theBooleanObjects); } } @@ -506,11 +494,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse( if(initialize()) { fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theDirection, mydirection); - fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod); - fillAttribute(theToObject, mytoObject); - fillAttribute(theToOffset, mytoOffset); - fillAttribute(theFromObject, myfromObject); - fillAttribute(theFromOffset, myfromOffset); + setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); setBooleanObjects(theBooleanObjects); } } diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py b/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py index 6c118349a..579be45ca 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut_ByPlanesAndOffsets.py @@ -38,7 +38,7 @@ Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Axis_4 = model.addAxis(Part_1_doc, 10, 10, 10) -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Box_1_1/Right"), 0, model.selection(), 0, [model.selection("SOLID", "Box_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection("FACE", "Box_1_1/Right"), 0, model.selection(), 0, [model.selection("SOLID", "Box_1_1")]) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Left")) SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False) SketchLine_1 = SketchProjection_1.createdFeature() diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut_BySize.py b/src/FeaturesPlugin/Test/TestExtrusionCut_BySize.py index 907d22b0a..fb8bd45d3 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut_BySize.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut_BySize.py @@ -53,6 +53,20 @@ model.do() Shape = ExtrusionCut_1.results()[0].resultSubShapePair()[0].shape() checkMiddlePoint(Shape, 5.00027719467643, 4.861055360637628, 5.101882685002874) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], -5, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) +SketchCircle_2 = Sketch_2.addCircle(2, 7, 1.5) +ExtrusionCut_2.setNestedSketch(Sketch_2) +model.do() + +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], 0, 7, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modified_Face&Box_1_1/Front")) +SketchCircle_3 = Sketch_3.addCircle(7, 2, 1.5) +ExtrusionCut_3.setNestedSketch(Sketch_3) +model.do() +Shape = ExtrusionCut_3.results()[0].resultSubShapePair()[0].shape() +checkMiddlePoint(Shape, 5.15104587473, 4.96021, 4.86946) + model.end() assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse_ByPlanesAndOffsets.py b/src/FeaturesPlugin/Test/TestExtrusionFuse_ByPlanesAndOffsets.py index 941f6bacf..aeda3c26f 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionFuse_ByPlanesAndOffsets.py +++ b/src/FeaturesPlugin/Test/TestExtrusionFuse_ByPlanesAndOffsets.py @@ -38,7 +38,7 @@ Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Axis_4 = model.addAxis(Part_1_doc, 10, 10, 10) -ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [], model.selection(), model.selection("FACE", "Box_1_1/Right"), 0, model.selection(), 0, [model.selection("SOLID", "Box_1_1")]) +ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [], model.selection("FACE", "Box_1_1/Right"), 0, model.selection(), 0, [model.selection("SOLID", "Box_1_1")]) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Left")) SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False) SketchLine_1 = SketchProjection_1.createdFeature() diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse_BySize.py b/src/FeaturesPlugin/Test/TestExtrusionFuse_BySize.py index 3d7ce1a85..705971438 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionFuse_BySize.py +++ b/src/FeaturesPlugin/Test/TestExtrusionFuse_BySize.py @@ -53,6 +53,20 @@ model.do() Shape = ExtrusionFuse_1.results()[0].resultSubShapePair()[0].shape() checkMiddlePoint(Shape, 5, 4.299736969, 5.70604613) +ExtrusionFuse_2 = model.addExtrusionFuse(Part_1_doc, [], 3, [model.selection("SOLID", "ExtrusionFuse_1_1")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) +SketchCircle_2 = Sketch_2.addCircle(4, 7, 2) +ExtrusionFuse_2.setNestedSketch(Sketch_2) +model.do() + +ExtrusionFuse_3 = model.addExtrusionFuse(Part_1_doc, [], 10, 0, [model.selection("SOLID", "ExtrusionFuse_2_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Right")) +SketchCircle_3 = Sketch_3.addCircle(5, -6, 3) +ExtrusionFuse_3.setNestedSketch(Sketch_3) +model.do() +Shape = ExtrusionFuse_3.results()[0].resultSubShapePair()[0].shape() +checkMiddlePoint(Shape, 5.31705479, 6.86583379, 5.82287969) + model.end() assert(model.checkPythonDump()) -- 2.39.2