From d5757b7089b6929f90f361b842f9a6d8d8bb977b Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 7 Nov 2013 14:17:41 +0100 Subject: [PATCH] + fixes #0001247 --- src/Mod/Part/App/PrimitiveFeature.cpp | 10 ++++++++-- src/Mod/Part/App/PrimitiveFeature.h | 2 ++ src/Mod/Part/App/TopoShape.cpp | 22 +++++++++++++--------- src/Mod/Part/App/TopoShape.h | 3 ++- src/Mod/Part/Gui/DlgPrimitives.cpp | 1 + 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 88292dab5..bbb0b8223 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -647,6 +647,7 @@ App::DocumentObjectExecReturn *Torus::execute(void) PROPERTY_SOURCE(Part::Helix, Part::Primitive) const char* Part::Helix::LocalCSEnums[]= {"Right-handed","Left-handed",NULL}; +const char* Part::Helix::StyleEnums []= {"Old style","New style",NULL}; Helix::Helix(void) { @@ -660,13 +661,15 @@ Helix::Helix(void) Angle.setConstraints(&apexRange); ADD_PROPERTY_TYPE(LocalCoord,(long(0)),"Coordinate System",App::Prop_None,"Orientation of the local coordinate system of the helix"); LocalCoord.setEnums(LocalCSEnums); + ADD_PROPERTY_TYPE(Style,(long(0)),"Helix style",App::Prop_Hidden,"Old style creates incorrect and new style create correct helices"); + Style.setEnums(StyleEnums); } void Helix::onChanged(const App::Property* prop) { if (!isRestoring()) { if (prop == &Pitch || prop == &Height || prop == &Radius || - prop == &Angle || prop == &LocalCoord) { + prop == &Angle || prop == &LocalCoord || prop == &Style) { try { App::DocumentObjectExecReturn *ret = recompute(); delete ret; @@ -690,6 +693,8 @@ short Helix::mustExecute() const return 1; if (LocalCoord.isTouched()) return 1; + if (Style.isTouched()) + return 1; return Primitive::mustExecute(); } @@ -701,8 +706,9 @@ App::DocumentObjectExecReturn *Helix::execute(void) Standard_Real myRadius = Radius.getValue(); Standard_Real myAngle = Angle.getValue(); Standard_Boolean myLocalCS = LocalCoord.getValue() ? Standard_True : Standard_False; + Standard_Boolean myStyle = Style.getValue() ? Standard_True : Standard_False; TopoShape helix; - this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS)); + this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS, myStyle)); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); diff --git a/src/Mod/Part/App/PrimitiveFeature.h b/src/Mod/Part/App/PrimitiveFeature.h index 652943aed..7a1f60397 100644 --- a/src/Mod/Part/App/PrimitiveFeature.h +++ b/src/Mod/Part/App/PrimitiveFeature.h @@ -281,6 +281,7 @@ public: App::PropertyFloatConstraint Radius; App::PropertyFloatConstraint Angle; App::PropertyEnumeration LocalCoord; + App::PropertyEnumeration Style; /** @name methods override feature */ //@{ @@ -298,6 +299,7 @@ protected: private: static const char* LocalCSEnums[]; + static const char* StyleEnums[]; }; class PartExport Spiral : public Primitive diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index f482fd70c..5fac6d70a 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1543,7 +1543,8 @@ TopoDS_Shape TopoShape::makeSweep(const TopoDS_Shape& profile, double tol, int f TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, Standard_Real radius, Standard_Real angle, - Standard_Boolean leftHanded) const + Standard_Boolean leftHanded, + Standard_Boolean newStyle) const { if (pitch < Precision::Confusion()) Standard_Failure::Raise("Pitch of helix too small"); @@ -1578,15 +1579,18 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height, Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d); gp_Pnt2d beg = line->Value(0); gp_Pnt2d end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*(height/pitch)); -#if 0 // See discussion at 0001247: Part Conical Helix Height/Pitch Incorrect - if (angle >= Precision::Confusion()) { - // calculate end point for conical helix - Standard_Real v = height / cos(angle); - Standard_Real u = (height/pitch) * 2.0 * M_PI; - gp_Pnt2d cend(u, v); - end = cend; + + if (newStyle) { + // See discussion at 0001247: Part Conical Helix Height/Pitch Incorrect + if (angle >= Precision::Confusion()) { + // calculate end point for conical helix + Standard_Real v = height / cos(angle); + Standard_Real u = (height/pitch) * 2.0 * M_PI; + gp_Pnt2d cend(u, v); + end = cend; + } } -#endif + Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end); TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf); diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index dcd94d53a..86cd4b269 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -161,7 +161,8 @@ public: TopoDS_Shape makeSweep(const TopoDS_Shape& profile, double, int) const; TopoDS_Shape makeTube(double radius, double tol, int cont, int maxdeg, int maxsegm) const; TopoDS_Shape makeHelix(Standard_Real pitch, Standard_Real height, - Standard_Real radius, Standard_Real angle=0, Standard_Boolean left=Standard_False) const; + Standard_Real radius, Standard_Real angle=0, + Standard_Boolean left=Standard_False, Standard_Boolean style=Standard_False) const; TopoDS_Shape makeThread(Standard_Real pitch, Standard_Real depth, Standard_Real height, Standard_Real radius) const; TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index 3cc4dc0a6..b4351b194 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -505,6 +505,7 @@ void DlgPrimitives::createPrimitive(const QString& placement) "App.ActiveDocument.%1.Radius=%4\n" "App.ActiveDocument.%1.Angle=%5\n" "App.ActiveDocument.%1.LocalCoord=%6\n" + "App.ActiveDocument.%1.Style=1\n" "App.ActiveDocument.%1.Placement=%7\n") .arg(name) .arg(ui.helixPitch->value(),0,'f',2)