Skip to content

Commit

Permalink
+ fixes #1247
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 7, 2013
1 parent 8446f70 commit d5757b7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
10 changes: 8 additions & 2 deletions src/Mod/Part/App/PrimitiveFeature.cpp
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -690,6 +693,8 @@ short Helix::mustExecute() const
return 1;
if (LocalCoord.isTouched())
return 1;
if (Style.isTouched())
return 1;
return Primitive::mustExecute();
}

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/App/PrimitiveFeature.h
Expand Up @@ -281,6 +281,7 @@ class PartExport Helix : public Primitive
App::PropertyFloatConstraint Radius;
App::PropertyFloatConstraint Angle;
App::PropertyEnumeration LocalCoord;
App::PropertyEnumeration Style;

/** @name methods override feature */
//@{
Expand All @@ -298,6 +299,7 @@ class PartExport Helix : public Primitive

private:
static const char* LocalCSEnums[];
static const char* StyleEnums[];
};

class PartExport Spiral : public Primitive
Expand Down
22 changes: 13 additions & 9 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Part/App/TopoShape.h
Expand Up @@ -161,7 +161,8 @@ class PartExport TopoShape : public Data::ComplexGeoData
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,
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Part/Gui/DlgPrimitives.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit d5757b7

Please sign in to comment.