void
ArxDbgUtils::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);
    }
}
Acad::ErrorStatus 
rx_scanPline(AcDb3dPolyline* pline, AcGePoint3dArray& points)
{
    Acad::ErrorStatus es = Acad::eOk;

    AcDb3dPolylineVertex*  vert   = NULL;
    AcDbObjectId           vId;

    AcDbObjectIterator *vIter;
    vIter = pline->vertexIterator();

    for (; !vIter->done(); vIter->step()) {
		vId = vIter->objectId();

		if ( (es =pline->openVertex(vert, vId, AcDb::kForRead)) != Acad::eOk )
			return es;

		points.append(vert->position());
    }

    delete vIter;
    
    return es;
}
Пример #3
0
void extractVertexCoords(const AcDbObjectId& objID, std::map<std::wstring, AcGePoint3d>& m_3dPoints)
{
	AcDbEntity* pEnt = nullptr;
	acdbOpenObject(pEnt, objID, AcDb::kForRead);

	             /*****Pline****/
	if (pEnt->isA() == AcDbPolyline::desc())
	{
		AcDbPolyline* pLine = static_cast<AcDbPolyline*>(pEnt);
		pEnt->close();
		acdbOpenObject(pLine, objID, AcDb::kForRead);
		AcGePoint3d vertex;
		for (LONGLONG i = 0; i < pLine->numVerts(); i++)
		{
			pLine->getPointAt(i, vertex);
			std::wstring w_nrPunct = std::to_wstring(i + 1);
			m_3dPoints.insert(std::pair<std::wstring, AcGePoint3d>(w_nrPunct, vertex));
		}

		pLine->close();	
	}

	            /******P2dLine****/
	else if (pEnt->isA() == AcDb2dPolyline::desc())
	{
		AcGePoint3d point;
		AcDbObjectId vertexID;
		AcDb3dPolylineVertex* pVertex = nullptr;

		AcDb2dPolyline* p2dline = static_cast<AcDb2dPolyline*>(pEnt);
		pEnt->close();

		acdbOpenObject(p2dline, objID, AcDb::kForRead);
		AcDbObjectIterator* pIterator = p2dline->vertexIterator();
		for (pIterator->start(); !pIterator->done(); pIterator->step())
		{
			LONGLONG contor = 1;
			vertexID = pIterator->objectId();
			acdbOpenObject(pVertex, vertexID, AcDb::kForRead);
			point = pVertex->position();

			std::wstring w_nrPunct = std::to_wstring(contor);
			contor++;
			m_3dPoints.insert(std::pair<std::wstring, AcGePoint3d>(w_nrPunct, point));

			pVertex->close();
		}
		delete pIterator;
		p2dline->close();
	}

	         /***********P3dLine**************/
	else if (pEnt->isA() == AcDb3dPolyline::desc())
	{
		AcGePoint3d point;
		AcDbObjectId vertexID;
		AcDb3dPolylineVertex* pVertex = nullptr;

		AcDb3dPolyline* p3dline = static_cast<AcDb3dPolyline*>(pEnt);
		pEnt->close();

		acdbOpenObject(p3dline, objID, AcDb::kForRead);
		AcDbObjectIterator* pIterator = p3dline->vertexIterator();

		for (pIterator->start(); !pIterator->done(); pIterator->step())
		{
			LONGLONG contor = 1;
			vertexID = pIterator->objectId();
			acdbOpenObject(pVertex, vertexID, AcDb::kForRead);
			point = pVertex->position();

			std::wstring w_nrPunct = std::to_wstring(contor);

			m_3dPoints.insert(std::pair<std::wstring, AcGePoint3d>(w_nrPunct, point));
			pVertex->close();
		}
		delete pIterator;
		p3dline->close();
	}
	else
	{
		pEnt->close();
		acutPrintf(_T("\nObiectul selectat nu este o polilinie"));
	}

}