Merge pull request #1128 from realthunder/PathArcFix
libarea: fix arc fitting
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
((double,accuracy,Accuracy,0.01,"Arc fitting accuracy",App::PropertyPrecision))\
|
||||
((double,units,Unit,1.0,"Scaling factor for conversion to inch",App::PropertyFloat))\
|
||||
((short,min_arc_points,MinArcPoints,4,"Minimum segments for arc discretization"))\
|
||||
((short,max_arc_points,MaxArcPoints,100,"Maximum segments for arc discretization"))\
|
||||
((short,max_arc_points,MaxArcPoints,100,"Maximum segments for arc discretization (ignored currently)"))\
|
||||
((double,clipper_scale,ClipperScale,1e7,\
|
||||
"ClipperLib operate on intergers. This is the scale factor to convert\n"\
|
||||
"floating points.",App::PropertyFloat))
|
||||
|
||||
@@ -83,8 +83,8 @@ static void AddVertex(const CVertex& vertex, const CVertex* prev_vertex)
|
||||
|
||||
if (Segments < CArea::m_min_arc_points)
|
||||
Segments = CArea::m_min_arc_points;
|
||||
if (Segments > CArea::m_max_arc_points)
|
||||
Segments=CArea::m_max_arc_points;
|
||||
// if (Segments > CArea::m_max_arc_points)
|
||||
// Segments=CArea::m_max_arc_points;
|
||||
|
||||
dphi=phit/(Segments);
|
||||
|
||||
@@ -521,8 +521,8 @@ void CArea::OffsetWithClipper(double offset,
|
||||
int Segments=(int)ceil(PI/dphi);
|
||||
if (Segments < 2*CArea::m_min_arc_points)
|
||||
Segments = 2*CArea::m_min_arc_points;
|
||||
if (Segments > CArea::m_max_arc_points)
|
||||
Segments=CArea::m_max_arc_points;
|
||||
// if (Segments > CArea::m_max_arc_points)
|
||||
// Segments=CArea::m_max_arc_points;
|
||||
dphi = PI/Segments;
|
||||
roundPrecision = (1.0-cos(dphi))*fabs(offset);
|
||||
}else
|
||||
|
||||
@@ -88,7 +88,11 @@ bool CCurve::CheckForArc(const CVertex& prev_vt, std::list<const CVertex*>& migh
|
||||
Circle c(p0, p1, p2);
|
||||
|
||||
const CVertex* current_vt = &prev_vt;
|
||||
double accuracy = CArea::m_accuracy * 1.4 / CArea::m_units;
|
||||
// It seems that ClipperLib's offset ArcTolerance (same as m_accuracy here)
|
||||
// is not exactly what's documented at https://goo.gl/4odfQh. Test shows the
|
||||
// maximum arc distance deviate at about 2.2*ArcTolerance units. The maximum
|
||||
// deviance seems to always occur at the end of arc.
|
||||
double accuracy = CArea::m_accuracy * 2.3 / CArea::m_units;
|
||||
for(std::list<const CVertex*>::iterator It = might_be_an_arc.begin(); It != might_be_an_arc.end(); It++)
|
||||
{
|
||||
const CVertex* vt = *It;
|
||||
|
||||
Reference in New Issue
Block a user