From 35683883cbd2def30aed25864ed0cbe59ae0d96b Mon Sep 17 00:00:00 2001 From: Uwe Date: Mon, 29 Nov 2021 00:53:19 +0100 Subject: [PATCH] [PD] allow negative helix growth Helices that become smaller with every turn are geometrically perfectly valid. Therefore we cannot forbid this. (For example when creating a helix from a face you often cannot move it so that you can apply a positive growth.) --- src/Mod/PartDesign/App/FeatureHelix.cpp | 12 +++++++++--- src/Mod/PartDesign/App/FeatureHelix.h | 2 +- src/Mod/PartDesign/Gui/TaskHelixParameters.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHelix.cpp b/src/Mod/PartDesign/App/FeatureHelix.cpp index d10c1bd01c..11de1bf859 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.cpp +++ b/src/Mod/PartDesign/App/FeatureHelix.cpp @@ -134,14 +134,13 @@ App::DocumentObjectExecReturn *Helix::execute(void) if (Turns.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Error: turns too small!"); if ((Height.getValue() < Precision::Confusion()) - && (Growth.getValue() < Precision::Confusion())) + && (abs(Growth.getValue()) < Precision::Confusion())) return new App::DocumentObjectExecReturn("Error: either height or growth must not be zero!"); Pitch.setValue(Height.getValue()/Turns.getValue()); } else { return new App::DocumentObjectExecReturn("Error: unsupported mode"); } - TopoDS_Shape sketchshape; try { sketchshape = getVerifiedFace(); @@ -407,7 +406,7 @@ TopoDS_Shape Helix::generateHelixPath(void) bool growthMode = std::string(Mode.getValueAsString()).find("growth") != std::string::npos; double radiusTop; if (growthMode) - radiusTop = radius + turns*growth; + radiusTop = radius + turns * growth; else radiusTop = radius + height * tan(Base::toRadians(angle)); @@ -534,6 +533,13 @@ void Helix::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeN TurnsProperty.Restore(reader); Turns.setValue(TurnsProperty.getValue()); } + // property Growth had the App::PropertyLength and was changed to App::PropertyDistance + else if (prop == &Growth && strcmp(TypeName, "App::PropertyLength") == 0) { + App::PropertyLength GrowthProperty; + // restore the PropertyLength to be able to set its value + GrowthProperty.Restore(reader); + Growth.setValue(GrowthProperty.getValue()); + } else { ProfileBased::handleChangedPropertyType(reader, TypeName, prop); } diff --git a/src/Mod/PartDesign/App/FeatureHelix.h b/src/Mod/PartDesign/App/FeatureHelix.h index 7e9823a0ef..f834f08be0 100644 --- a/src/Mod/PartDesign/App/FeatureHelix.h +++ b/src/Mod/PartDesign/App/FeatureHelix.h @@ -52,7 +52,7 @@ public: App::PropertyFloatConstraint Turns; App::PropertyBool LeftHanded; App::PropertyAngle Angle; - App::PropertyLength Growth; + App::PropertyDistance Growth; App::PropertyEnumeration Mode; App::PropertyBool Outside; App::PropertyBool HasBeenEdited; diff --git a/src/Mod/PartDesign/Gui/TaskHelixParameters.h b/src/Mod/PartDesign/Gui/TaskHelixParameters.h index 8b9b017299..110cad5444 100644 --- a/src/Mod/PartDesign/Gui/TaskHelixParameters.h +++ b/src/Mod/PartDesign/Gui/TaskHelixParameters.h @@ -95,7 +95,7 @@ protected: App::PropertyBool* propReversed; App::PropertyLinkSub* propReferenceAxis; App::PropertyAngle* propAngle; - App::PropertyLength* propGrowth; + App::PropertyDistance* propGrowth; App::PropertyEnumeration* propMode; App::PropertyBool* propOutside;