马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- static void convertPolylineToGeCurve(AcDbPolyline* pPoly, AcGeCurve2d*& out_pGeCurve)
- {
- AcGeVoidPointerArray geCurves;
- AcGeVector3d normal = pPoly->normal();
- // Is the polyline closed or open
- int nSegs = -1;
- if (pPoly->isClosed())
- nSegs = pPoly->numVerts();
- else
- nSegs = pPoly->numVerts() - 1;
- for (int i = 0; i < nSegs; i++)
- {
- if (pPoly->segType(i) == AcDbPolyline::kLine)
- {
- AcGeLineSeg2d line;
- pPoly->getLineSegAt(i, line);
- AcGeLineSeg2d *pLine = new AcGeLineSeg2d(line);
- geCurves.append(pLine);
- }
- else if (pPoly->segType(i) == AcDbPolyline::kArc)
- {
- AcGeCircArc2d arc;
- pPoly->getArcSegAt(i, arc);
- AcGeCircArc2d *pArc = new AcGeCircArc2d(arc);
- geCurves.append(pArc);
- }
- }// for
- if (geCurves.length() == 1)
- out_pGeCurve = (AcGeCurve2d*)(geCurves[0]);
- else
- out_pGeCurve = new AcGeCompositeCurve2d(geCurves);
- } // End of convertPolylineToGeCurve()
- //------------------------------------------------------------------------
- static void convertGeCurveToPolyline(AcGeCurve2d* pCurve, AcDbPolyline*& pResultPoly)
- {
- AcGeVoidPointerArray resultCurves;
- AcGeCompositeCurve2d* pResultCurve;
- if (pCurve->isKindOf(AcGe::kCompositeCrv2d))
- {
- pResultCurve = (AcGeCompositeCurve2d*)pCurve;
- pResultCurve->getCurveList(resultCurves);
- }
- else
- resultCurves.append(pCurve);
- int nCurves = resultCurves.length();
- pResultPoly = new AcDbPolyline(nCurves);
- AcGeCurve2d *pThisCurve = NULL;
- int i = 0;
- for (i = 0; i < nCurves; i++)
- {
- pThisCurve = (AcGeCurve2d*)(resultCurves);
- if (pThisCurve->isKindOf(AcGe::kCircArc2d))
- {
- AcGeCircArc2d *pArc = (AcGeCircArc2d*)pThisCurve;
- double ang = 0.25 * (pArc->endAng() - pArc->startAng());
- double bulge = tan(ang);
- if (pArc->isClockWise())
- bulge = -bulge;
- pResultPoly->addVertexAt(i, pArc->startPoint(), bulge);
- }
- else if (pThisCurve->isKindOf(AcGe::kLineSeg2d))
- {
- AcGeLineSeg2d *pLine = (AcGeLineSeg2d*)pThisCurve;
- pResultPoly->addVertexAt(i, pLine->startPoint(), 0);
- }
- }// for
- AcGePoint2d endPt;
- if (pThisCurve->hasEndPoint(endPt))
- pResultPoly->addVertexAt(i, endPt, 0);
- } // End of convertGeCurveToPolyline()
|