|
【c++】ObjectARX获取多段线的节点
void collectVertices(const AcDb3dPolyline* pline, AcGePoint3dArray& pts)
{
ASSERT(pline != NULL);
ASSERT(pts.isEmpty());
AcDbObjectIterator* vertexIter = pline->vertexIterator();
ASSERT(vertexIter != NULL);
if (vertexIter == NULL)
return;
AcDb3dPolylineVertex* vertex;
for (; !vertexIter->done(); vertexIter->step()) {
if (acdbOpenObject(vertex, vertexIter->objectId(), AcDb::kForRead) == Acad::eOk) {
if (vertex->vertexType() != AcDb::k3dControlVertex)
pts.append(vertex->position());
vertex->close();
}
}
delete vertexIter;
ASSERT(pts.isEmpty() == false);
if (pline->isClosed()) {
AcGePoint3d tmpPt = pts[0]; // used to be a bug in dynamic arrays (not sure if its still there??)
pts.append(tmpPt);
}
} |
|