In the official documentation stated that AcDbPolygonMesh::openVertex provides access to the PolyMesh's vertices and FaceRecords. I need to get an information about about how many faces there are in AcDbPolygonMesh and which vertices belong to specific face.
So how to access FaceRecords in an AcDbPolygonMesh and examine the connectivity between vertices to identify the faces they form? Is it even possible using C++?
An AcDbPolygonMesh is a simple MxN mesh. So any inner vertex with indices (i,j) is connected with (i+1,j), (i-1,j), (i,j+1) and (i,j-1). For the outer vertices:
You can query the vertices using an iterator like this:
struct MyPolygonVertexData {
AcDbObjectId objId;
AcGePoint3d pt;
};
void cmdPolygonMesh()
{
ads_point pt;
ads_name ent;
AcDbObjectId objId;
if (acedEntSel(_T("\nSelect PolygonMesh: "), ent, pt) != RTNORM)
return;
if (acdbGetObjectId(objId, ent) != Acad::eOk)
return;
Acad::ErrorStatus es;
AcDbPolygonMesh *mesh;
Adesk::Int16 mSize, nSize, n=0;
std::vector< std::vector<MyPolygonVertexData> > verticesMN;
if ((es = acdbOpenObject(mesh, objId, AcDb::kForRead)) == Acad::eOk)
{
mSize = mesh->mSize();
nSize = mesh->nSize();
AcDbObjectIterator *it = mesh->vertexIterator();
if (it)
{
AcDbPolygonMeshVertex *vert;
MyPolygonVertexData vertex;
std::vector<MyPolygonVertexData> verticesN;
for (it->start(); !it->done(); it->step())
{
vertex.objId = it->objectId();
if ((es = acdbOpenObject(vert, vertex.objId, AcDb::kForRead)) == Acad::eOk)
{
vertex.pt = vert->position();
verticesN.push_back(vertex);
if (++n == nSize)
{
verticesMN.push_back(std::move(verticesN));
verticesN.clear();
n=0;
}
vert->close();
}
}
delete it;
}
mesh->close();
}
}
.
Can't find what you're looking for? Ask the community or share your knowledge.