Skip to content

Commit

Permalink
+ fixes #1912: Drawing Workbench Not Displaying Views of Cylindrical …
Browse files Browse the repository at this point in the history
…Parts.
  • Loading branch information
wwmayer committed Jan 12, 2015
1 parent e16305c commit b437dfd
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions src/Mod/Drawing/App/DrawingExport.cpp
Expand Up @@ -74,6 +74,7 @@
#include <GeomConvert_BSplineCurveKnotSplitting.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <BRepLProp_CLProps.hxx>
#include <Standard_Failure.hxx>

#include "DrawingExport.h"
#include <Base/Tools.h>
Expand All @@ -86,24 +87,31 @@ TopoDS_Edge DrawingOutput::asCircle(const BRepAdaptor_Curve& c) const
double curv=0;
gp_Pnt pnt, center;

// approximate the circle center from three positions
BRepLProp_CLProps prop(c,c.FirstParameter(),2,Precision::Confusion());
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

prop.SetParameter(0.5*(c.FirstParameter()+c.LastParameter()));
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

prop.SetParameter(c.LastParameter());
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

center.ChangeCoord().Divide(3);
curv /= 3;
try {
// approximate the circle center from three positions
BRepLProp_CLProps prop(c,c.FirstParameter(),2,Precision::Confusion());
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

prop.SetParameter(0.5*(c.FirstParameter()+c.LastParameter()));
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

prop.SetParameter(c.LastParameter());
curv += prop.Curvature();
prop.CentreOfCurvature(pnt);
center.ChangeCoord().Add(pnt.Coord());

center.ChangeCoord().Divide(3);
curv /= 3;
}
catch (Standard_Failure) {
// if getting center of curvature fails, e.g.
// for straight lines it raises LProp_NotDefined
return TopoDS_Edge();
}

// get circle from curvature information
double radius = 1 / curv;
Expand Down

0 comments on commit b437dfd

Please sign in to comment.