void CBTapParser::convertToLine(CBPoint startPt, CBCurveTo* pCurve, CBObList* pLineList)
{
CBObList curveList;
CBPoint midPt;
bool bBreak = false;
CBCurveTo *pCv1, *pCv2;
curveList.AddTail(pCurve->duplicate());
while (!curveList.IsEmpty())
{
CBCurveTo *pCv = (CBCurveTo *)curveList.RemoveHead();
pCv1 = new CBCurveTo();
pCv2 = new CBCurveTo();
pCv->subDivide(startPt, 0.5, *pCv1, *pCv2);
midPt.setAsMidPt(startPt, pCv->getEndPt());
double dDelta = midPt.distanceSqr(pCv1->getEndPt());
if (dDelta <= 0.002)
{
pLineList->AddTail(new CBLineTo(pCv->getEndPt()));
startPt = pCv->getEndPt();
delete pCv1;
delete pCv2;
delete pCv;
}
else
{
curveList.AddHead(pCv2);
curveList.AddHead(pCv1);
delete pCv;
}
}
}
通过二分法将曲线转换为直线
最新推荐文章于 2023-08-08 10:08:05 发布