Part: fixes and check input values for spiral and helix primitives
This commit is contained in:
@@ -853,14 +853,15 @@ 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_Real nbTurns = myHeight / myPitch;
|
||||
Standard_Real mySegLen = SegmentLength.getValue();
|
||||
|
||||
Standard_Real myRadiusTop = myRadius + myHeight * tan(Base::toRadians(myAngle));
|
||||
TopoShape spirhelix;
|
||||
if (myPitch < Precision::Confusion())
|
||||
Standard_Failure::Raise("Pitch too small");
|
||||
Standard_Real nbTurns = myHeight / myPitch;
|
||||
if (nbTurns > 1e4)
|
||||
Standard_Failure::Raise("Number of turns too high (> 1e4)");
|
||||
Standard_Real myRadiusTop = myRadius + myHeight * tan(myAngle/180.0f*M_PI);
|
||||
|
||||
TopoDS_Shape myHelix = spirhelix.makeSpiralHelix(myRadius, myRadiusTop, myHeight, nbTurns, mySegLen, myLocalCS);
|
||||
this->Shape.setValue(myHelix);
|
||||
this->Shape.setValue(TopoShape().makeSpiralHelix(myRadius, myRadiusTop, myHeight, nbTurns, mySegLen, myLocalCS));
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
@@ -919,15 +920,11 @@ App::DocumentObjectExecReturn *Spiral::execute(void)
|
||||
Standard_Real myGrowth = Growth.getValue();
|
||||
Standard_Real myRadiusTop = myRadius + myGrowth * myNumRot;
|
||||
Standard_Real mySegLen = SegmentLength.getValue();
|
||||
TopoShape spirhelix;
|
||||
|
||||
if (myGrowth < Precision::Confusion())
|
||||
Standard_Failure::Raise("Growth too small");
|
||||
if (myNumRot < Precision::Confusion())
|
||||
Standard_Failure::Raise("Number of rotations too small");
|
||||
|
||||
TopoDS_Shape mySpiral = spirhelix.makeSpiralHelix(myRadius, myRadiusTop, 0, myNumRot, mySegLen, Standard_False);
|
||||
this->Shape.setValue(mySpiral);
|
||||
|
||||
this->Shape.setValue(TopoShape().makeSpiralHelix(myRadius, myRadiusTop, 0, myNumRot, mySegLen, Standard_False));
|
||||
return Primitive::execute();
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
@@ -2508,7 +2508,7 @@ TopoDS_Shape TopoShape::makeSpiralHelix(Standard_Real radiusbottom, Standard_Rea
|
||||
Standard_Real breakperiod, Standard_Boolean leftHanded) const
|
||||
{
|
||||
// 1000 periods is an OCCT limit. The 3D curve gets truncated
|
||||
// if he 2D curve spans beyond this limit.
|
||||
// if the 2D curve spans beyond this limit.
|
||||
if ((breakperiod < 0) || (breakperiod > 1000))
|
||||
Standard_Failure::Raise("Break period must be in [0, 1000]");
|
||||
if (breakperiod == 0)
|
||||
@@ -2522,14 +2522,12 @@ TopoDS_Shape TopoShape::makeSpiralHelix(Standard_Real radiusbottom, Standard_Rea
|
||||
|
||||
// A Bezier curve is used below, to get a periodic surface also for spirals.
|
||||
TColgp_Array1OfPnt poles(1,2);
|
||||
poles(1) = gp_Pnt(fabs(radiusbottom), 0, 0);
|
||||
poles(2) = gp_Pnt(fabs(radiustop), 0, height);
|
||||
Handle(Geom_BezierCurve) meridian;
|
||||
meridian = new Geom_BezierCurve(poles);
|
||||
poles(1) = gp_Pnt(radiusbottom, 0, 0);
|
||||
poles(2) = gp_Pnt(radiustop, 0, height);
|
||||
Handle(Geom_BezierCurve) meridian = new Geom_BezierCurve(poles);
|
||||
|
||||
gp_Ax1 axis(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
|
||||
Handle(Geom_Surface) surf;
|
||||
surf = new Geom_SurfaceOfRevolution(meridian, axis);
|
||||
Handle(Geom_Surface) surf = new Geom_SurfaceOfRevolution(meridian, axis);
|
||||
|
||||
gp_Pnt2d beg(0, 0);
|
||||
gp_Pnt2d end(0, 0);
|
||||
|
||||
Reference in New Issue
Block a user