|
objectarx之获得LWPolyLine节点坐标
static AcGePoint2dArray ToLWPolyLine(AcDbObjectId &pCurverId, double segs)
{
AcGePoint2dArray pts;
AcDbEntity *pEnt = NULL;
Acad::ErrorStatus es = acdbOpenAcDbEntity(pEnt, pCurverId, AcDb::kForRead);
if (pEnt->isKindOf(AcDbPolyline::desc()))
{
AcDbPolyline *pPolyLine = AcDbPolyline::cast(pEnt);
int plineNum;
AcGePoint2d pt;
for(size_t j = 0; j < pPolyLine->numVerts(); j++)
{
pPolyLine->getPointAt(j, pt);
pts.append(pt);
}
pPolyLine->close();
}
else
{
AcDbCurve *pCurve = AcDbCurve::cast(pEnt);
double dEndParam;
pCurve->getEndParam(dEndParam);
double dDist;
pCurve->getDistAtParam(dEndParam, dDist);
int iIntdex = (int)(dDist / segs) + 1;
for (int i = 0; i < iIntdex; i++)
{
double len = i * segs;
AcGePoint3d pt;
pCurve->getPointAtDist(len, pt);
pt = UcsToWcsPoint(pt);
pts.append(AcGePoint2d(pt.x, pt.y));
}
if (pCurve->isClosed())
{
AcGePoint3d startPt;
pCurve->getStartPoint(startPt);
pts.append(AcGePoint2d(startPt.x, startPt.y));
}
else
{
AcGePoint3d endPt;
pCurve->getEndPoint(endPt);
pts.append(AcGePoint2d(endPt.x, endPt.y));
}
}
pEnt->close();
return pts;
} |
|