From 729cd4a7c033dac53b44896ecc621274573ea9f2 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 30 Jan 2022 19:37:41 +0100 Subject: [PATCH] [Part] Extrusion: code simplification and documentation - in order for the pending PR to add tapered padding/pocketing --- src/Mod/Part/App/FeatureExtrusion.cpp | 12 ++++++------ src/Mod/Part/App/FeatureExtrusion.h | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp index 6903f26065..6ef9d11f47 100644 --- a/src/Mod/Part/App/FeatureExtrusion.cpp +++ b/src/Mod/Part/App/FeatureExtrusion.cpp @@ -53,8 +53,8 @@ #include "FeatureExtrusion.h" #include -#include #include +#include #include "Part2DObject.h" using namespace Part; @@ -406,7 +406,7 @@ void Extrusion::makeDraft(const ExtrusionParameters& params, const TopoDS_Shape& std::vector isInnerWire(resultPrisms.size(), false); std::vector checklist(resultPrisms.size(), true); // finally check reecursively for inner wires - checkInnerWires(isInnerWire, params, checklist, false, resultPrisms); + checkInnerWires(isInnerWire, params.dir, checklist, false, resultPrisms); // count the number of inner wires int numInnerWires = 0; @@ -575,7 +575,7 @@ void Extrusion::makeDraft(const ExtrusionParameters& params, const TopoDS_Shape& } } -void Extrusion::checkInnerWires(std::vector& isInnerWire, const ExtrusionParameters& params, +void Extrusion::checkInnerWires(std::vector& isInnerWire, const gp_Dir direction, std::vector& checklist, bool forInner, std::vector prisms) { // store the number of wires to be checked @@ -611,12 +611,12 @@ void Extrusion::checkInnerWires(std::vector& isInnerWire, const ExtrusionP } // get MomentOfInertia of first shape BRepGProp::VolumeProperties(*itInner, tempProperties); - momentOfInertiaInitial = tempProperties.MomentOfInertia(gp_Ax1(gp_Pnt(), params.dir)); + momentOfInertiaInitial = tempProperties.MomentOfInertia(gp_Ax1(gp_Pnt(), direction)); BRepAlgoAPI_Cut mkCut(*itInner, *itOuter); if (!mkCut.IsDone()) Standard_Failure::Raise("Extrusion: Cut out failed"); BRepGProp::VolumeProperties(mkCut.Shape(), tempProperties); - momentOfInertiaFinal = tempProperties.MomentOfInertia(gp_Ax1(gp_Pnt(), params.dir)); + momentOfInertiaFinal = tempProperties.MomentOfInertia(gp_Ax1(gp_Pnt(), direction)); // if the whole shape was cut away the resulting shape is not Null but its MomentOfInertia is 0.0 // therefore we have an inner wire if the MomentOfInertia is not zero and changed if ((momentOfInertiaInitial != momentOfInertiaFinal) @@ -673,7 +673,7 @@ void Extrusion::checkInnerWires(std::vector& isInnerWire, const ExtrusionP // recursively call the function until all wires are checked if (numCheckWires > 1) - checkInnerWires(isInnerWire, params, checklist, !forInner, prisms); + checkInnerWires(isInnerWire, direction, checklist, !forInner, prisms); }; void Extrusion::createTaperedPrismOffset(TopoDS_Wire sourceWire, diff --git a/src/Mod/Part/App/FeatureExtrusion.h b/src/Mod/Part/App/FeatureExtrusion.h index 2c159d722c..12d9819f2c 100644 --- a/src/Mod/Part/App/FeatureExtrusion.h +++ b/src/Mod/Part/App/FeatureExtrusion.h @@ -129,9 +129,13 @@ protected: * Inner wires can have nested inner wires that are then in fact outer wires. * Therefore checkInnerWires is called recursively until all wires are checked. */ - static void checkInnerWires(std::vector& isInnerWire, const ExtrusionParameters& params, + static void checkInnerWires(std::vector& isInnerWire, const gp_Dir direction, std::vector& checklist, bool forInner, std::vector prisms); + /** + * @brief createTaperedPrismOffset: creates an offset wire from the sourceWire in the specified + * translation. isSecond determines if the wire is used for the 2nd extrusion direction. + */ static void createTaperedPrismOffset(TopoDS_Wire sourceWire, const gp_Vec& translation, double offset,