|
- 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<i>);
- 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()
复制代码 |
|