How to facet AcDbSubDMesh objects?

How to facet AcDbSubDMesh objects?

Anonymous
Not applicable
1,999 Views
4 Replies
Message 1 of 5

How to facet AcDbSubDMesh objects?

Anonymous
Not applicable

AcDbSubDMesh objects are produced by the MESH command in autocad 2010 upwards. I wonder if anyone can let me know how to get at the underlying geometry of the object, to produce an array of triangles or polygons representing the object?

 

Thanks

 

Malcolm

 

0 Likes
2,000 Views
4 Replies
Replies (4)
Message 2 of 5

Alexander.Rivilis
Mentor
Mentor

What about using method explode of class AcDbSubDMesh?

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 5

adam.nagy
Autodesk Support
Autodesk Support

Hi there,

 

I have just written a blog post that also might be of help:

http://adndevblog.typepad.com/autocad/2012/05/facet-subd-mesh.html

 

Cheers,

 

Adam Nagy

Autodesk Developer Network



Adam Nagy
Autodesk Platform Services
0 Likes
Message 4 of 5

Anonymous
Not applicable

Ah

 

I think I can answer my own question.  There seem to be a couple of ways to go.  The first is pretty direct:

 

Given an AcDbEntity *pEnt pointer:

 

AcDbSubDMesh *pMesh=(AcDbSubDMesh *)pEnt;

AcGePoint3dArray vertexArray;
AcArray<Adesk::Int32> faceArray;

Acad::ErrorStatus es = pMesh->getFaceArray(faceArray);
if(es==Acad::eOk){
es=pMesh->getVertices(vertexArray);
}

 

And then walk through the faceArray and Vertex array to extract the geometry.  The above however doesn't do any smoothing, so that you end up with a large number of elements even for simple geometry.  For example, for a simple default cube, this gives 54 (or 56 can't quite remember) faces.  I don't know if someone has any suggestions on this.

 

In order to reduce the face count, all I can come up with is to go via a solid, and choosing the appropriate  bConvertAsSmooth and optimize flags:

:

 

AcDbSubDMesh *pMesh=(AcDbSubDMesh *)pEnt;

 

AcDb3dSolid *pSolid=NULL;
pMesh->convertToSolid(false,true,pSolid);

if(pMesh!=NULL){

  AcDbFaceterSettings faceter;
  AcGePoint3dArray vertexArray;

  AcArray<Adesk::Int32> faceArray;
  AcGiFaceData* faceData=NULL;

  Acad::ErrorStatus es=acdbGetObjectMesh(pSolid,&faceter,vertexArray,faceArray,faceData);

}

 

 

Going via a solid seems to be clumsy and so I'd be interested in any comments!

 

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

Adam

 

Thanks for that - very helpful - saw it just after I'd posted.

 

Can you offer anything on the smoothing/welding issue to reduce the face count for simple geometry? 

 

Malcolm

 

0 Likes