+ fix non-parametric makeHelix() function in Part module

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5143 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2011-11-17 10:02:26 +00:00
parent ef9275ce4d
commit a512879ba1
4 changed files with 53 additions and 66 deletions

View File

@ -760,38 +760,8 @@ static PyObject * makeHelix(PyObject *self, PyObject *args)
return 0;
try {
if (pitch < Precision::Confusion())
Standard_Failure::Raise("Pitch of helix too small");
if (height < Precision::Confusion())
Standard_Failure::Raise("Height of helix too small");
gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
Handle_Geom_Surface surf;
if (angle < 0) {
if (radius < Precision::Confusion())
Standard_Failure::Raise("Radius of helix too small");
surf = new Geom_CylindricalSurface(cylAx2, radius);
}
else {
angle = angle*(M_PI/180);
if (angle < Precision::Confusion())
Standard_Failure::Raise("Angle of helix too small");
surf = new Geom_ConicalSurface(gp_Ax3(cylAx2), angle, radius);
}
gp_Pnt2d aPnt(0, 0);
gp_Dir2d aDir(2. * PI, pitch);
gp_Ax2d aAx2d(aPnt, aDir);
Handle_Geom2d_Line line = new Geom2d_Line(aAx2d);
gp_Pnt2d beg = line->Value(0);
gp_Pnt2d end = line->Value(2.0*PI*(height/pitch));
Handle_Geom2d_TrimmedCurve segm = GCE2d_MakeSegment(beg , end);
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
BRepLib::BuildCurves3d(wire);
TopoShape helix;
TopoDS_Shape wire = helix.makeHelix(pitch, height, radius, angle);
return new TopoShapeWirePy(new TopoShape(wire));
}
catch (Standard_Failure) {

View File

@ -547,39 +547,8 @@ App::DocumentObjectExecReturn *Helix::execute(void)
Standard_Real myHeight = Height.getValue();
Standard_Real myRadius = Radius.getValue();
Standard_Real myAngle = Angle.getValue();
if (myPitch < Precision::Confusion())
return new App::DocumentObjectExecReturn("Pitch of helix too small");
if (myHeight < Precision::Confusion())
return new App::DocumentObjectExecReturn("Height of helix too small");
if (myRadius < Precision::Confusion())
return new App::DocumentObjectExecReturn("Radius of helix too small");
gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
Handle_Geom_Surface surf;
if (myAngle < Precision::Confusion()) {
surf = new Geom_CylindricalSurface(cylAx2, myRadius);
}
else {
myAngle = Base::toRadians(myAngle);
surf = new Geom_ConicalSurface(gp_Ax3(cylAx2), myAngle, myRadius);
}
gp_Pnt2d aPnt(0, 0);
gp_Dir2d aDir(2. * PI, myPitch);
gp_Ax2d aAx2d(aPnt, aDir);
Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d);
gp_Pnt2d beg = line->Value(0);
gp_Pnt2d end = line->Value(sqrt(4.0*PI*PI+myPitch*myPitch)*(myHeight/myPitch));
Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end);
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
BRepLib::BuildCurves3d(wire);
this->Shape.setValue(wire);
TopoShape helix;
this->Shape.setValue(helix.makeHelix(myPitch, myHeight, myRadius, myAngle));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();

View File

@ -26,6 +26,7 @@
#ifndef _PreComp_
# include <cstdlib>
# include <sstream>
# include <BRepLib.hxx>
# include <BSplCLib.hxx>
# include <Bnd_Box.hxx>
# include <BRep_Builder.hxx>
@ -40,9 +41,11 @@
# include <BRepAlgoAPI_Section.hxx>
# include <BRepBndLib.hxx>
# include <BRepBuilderAPI_GTransform.hxx>
# include <BRepBuilderAPI_MakeEdge.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <BRepBuilderAPI_MakePolygon.hxx>
# include <BRepBuilderAPI_MakeVertex.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <BRepBuilderAPI_NurbsConvert.hxx>
# include <BRepBuilderAPI_FaceError.hxx>
# include <BRepBuilderAPI_Copy.hxx>
@ -66,6 +69,9 @@
# include <BRepTools.hxx>
# include <BRepTools_ReShape.hxx>
# include <BRepTools_ShapeSet.hxx>
# include <GCE2d_MakeSegment.hxx>
# include <Geom2d_Line.hxx>
# include <Geom2d_TrimmedCurve.hxx>
# include <GeomLProp_SLProps.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
# include <GeomFill_CorrectedFrenet.hxx>
@ -1438,6 +1444,45 @@ TopoDS_Shape TopoShape::makeSweep(const TopoDS_Shape& profile, double tol, int f
return mkBuilder.Face();
}
TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
Standard_Real radius, Standard_Real angle) const
{
if (pitch < Precision::Confusion())
Standard_Failure::Raise("Pitch of helix too small");
if (height < Precision::Confusion())
Standard_Failure::Raise("Height of helix too small");
if (radius < Precision::Confusion())
Standard_Failure::Raise("Radius of helix too small");
gp_Ax2 cylAx2(gp_Pnt(0.0,0.0,0.0) , gp::DZ());
Handle_Geom_Surface surf;
if (angle < Precision::Confusion()) {
surf = new Geom_CylindricalSurface(cylAx2, radius);
}
else {
angle = Base::toRadians(angle);
if (angle < Precision::Confusion())
Standard_Failure::Raise("Angle of helix too small");
surf = new Geom_ConicalSurface(gp_Ax3(cylAx2), angle, radius);
}
gp_Pnt2d aPnt(0, 0);
gp_Dir2d aDir(2. * PI, pitch);
gp_Ax2d aAx2d(aPnt, aDir);
Handle(Geom2d_Line) line = new Geom2d_Line(aAx2d);
gp_Pnt2d beg = line->Value(0);
gp_Pnt2d end = line->Value(sqrt(4.0*PI*PI+pitch*pitch)*(height/pitch));
Handle(Geom2d_TrimmedCurve) segm = GCE2d_MakeSegment(beg , end);
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
BRepLib::BuildCurves3d(wire);
return wire;
}
TopoDS_Shape TopoShape::makeLoft(const TopTools_ListOfShape& profiles,
Standard_Boolean isSolid,
Standard_Boolean isRuled) const

View File

@ -198,7 +198,10 @@ public:
TopoDS_Shape makeSweep(const TopoDS_Shape& profile, double, int) const;
TopoDS_Shape makeTube(double radius, double tol) const;
TopoDS_Shape makeTube() const;
TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid, Standard_Boolean isRuled) const;
TopoDS_Shape makeHelix(Standard_Real pitch, Standard_Real height,
Standard_Real radius, Standard_Real angle=0) const;
TopoDS_Shape makeLoft(const TopTools_ListOfShape& profiles, Standard_Boolean isSolid,
Standard_Boolean isRuled) const;
TopoDS_Shape makeOffset(double offset, double tol,
bool intersection = false, bool selfInter = false,
short offsetMode = 0, short join = 0);