+ fixes #0001247
This commit is contained in:
parent
8446f70d13
commit
d5757b7089
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user