Skip to content

Commit

Permalink
+ Use long helix function in parametric feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Dec 29, 2013
1 parent acb8210 commit 775e6eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/Mod/Part/App/PrimitiveFeature.cpp
Expand Up @@ -761,7 +761,10 @@ App::DocumentObjectExecReturn *Helix::execute(void)
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, myStyle));
if (myHeight / myPitch > 50.0)
this->Shape.setValue(helix.makeLongHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS));
else
this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle, myLocalCS, myStyle));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Expand Down
21 changes: 12 additions & 9 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"

#ifndef _PreComp_
# include <cmath>
# include <cstdlib>
# include <sstream>
# include <BRepLib.hxx>
Expand Down Expand Up @@ -1604,8 +1605,8 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
// some magic number of turns. See Mantis #0954.
//***********
TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
Standard_Real radius, Standard_Real angle,
Standard_Boolean leftHanded) const
Standard_Real radius, Standard_Real angle,
Standard_Boolean leftHanded) const
{
if (pitch < Precision::Confusion())
Standard_Failure::Raise("Pitch of helix too small");
Expand All @@ -1632,7 +1633,7 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
}

Standard_Real turns = height/pitch;
unsigned long wholeTurns = trunc(turns);
unsigned long wholeTurns = floor(turns);
Standard_Real partTurn = turns - wholeTurns;

gp_Pnt2d aPnt(0, 0);
Expand All @@ -1653,31 +1654,33 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
TopoDS_Edge edgeOnSurf;

for (unsigned long i = 0; i < wholeTurns; i++) {
if (isCylinder)
if (isCylinder) {
end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*(i+1));
}
else {
u = coneDir * (i+1) * 2.0 * M_PI;
v = ((i+1) * pitch) / cos(angle);
end = gp_Pnt2d(u, v);
}
}
segm = GCE2d_MakeSegment(beg , end);
edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
mkWire.Add(edgeOnSurf);
beg = end;
}
}

if (partTurn > Precision::Confusion()) {
if (isCylinder)
if (isCylinder) {
end = line->Value(sqrt(4.0*M_PI*M_PI+pitch*pitch)*turns);
}
else {
u = coneDir * turns * 2.0 * M_PI;
v = height / cos(angle);
end = gp_Pnt2d(u, v);
}
}
segm = GCE2d_MakeSegment(beg , end);
edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
mkWire.Add(edgeOnSurf);
}
}

TopoDS_Wire wire = mkWire.Wire();
BRepLib::BuildCurves3d(wire);
Expand Down

0 comments on commit 775e6eb

Please sign in to comment.