|
int xx_get3dsolid()
{
struct resbuf *rb = acedGetArgs();
if ((rb != NULL))
{
AcDbObjectId id=AcDbObjectId::kNull;
bool ok=false;
AcGePoint3d decale;
decale.x=decale.y=decale.z=0;
if ((rb->restype==RT3DPOINT)||(rb->restype==RTPOINT))
{
decale.x=rb->resval.rpoint[0];
decale.y=rb->resval.rpoint[1];
decale.z=rb->resval.rpoint[2];
}
rb=rb->rbnext;
if(rb==NULL)
return RTREJ;
if (rb->restype==RTENAME)
{
acdbGetObjectId( id, rb->resval.rlname );
ok=true;
}
if (rb->restype==RTSTR)
{
ads_name en;
acdbHandEnt(rb->resval.rstring,en);
acdbGetObjectId(id,en);
ok=true;
}
if (ok==false)
{
return RTREJ;
}
AcDbEntity *entity=NULL;
Acad::ErrorStatus es=acdbOpenObject(entity, id, AcDb::kForRead );
if( entity == NULL )
return RSERR;
AcDb3dSolid *solid = AcDb3dSolid::cast(entity);
if (solid != NULL)
{
struct resbuf *_rbo = NULL, *rbo = NULL;
_rbo = acutNewRb(RTLB);
rbo = _rbo;
AcBrBrep pBrep;
pBrep.setSubentPath(
AcDbFullSubentPath(id, kNullSubentId));
AcBr::ErrorStatus returnValue = AcBr::eOk;
AcBrBrepFaceTraverser brepFaceTrav;
if (brepFaceTrav.setBrep(pBrep) != AcBr::eOk)
{
acutPrintf(ACRX_T(
"\\n Error in AcBrBrepFaceTraverser::setBrep:"));
return RTREJ;
}
int faceCount = 0;
while (!brepFaceTrav.done() && (returnValue == AcBr::eOk))
{
faceCount++;
AcBrFace face;
if (brepFaceTrav.getFace(face)
!= AcBr::ErrorStatus::eOk)
{
continue;
}
AcGeSurface *pGeSurface = NULL;
face.getSurface(pGeSurface);
AcGeInterval intervalU, intervalV;
pGeSurface->getEnvelope(intervalU, intervalV);
AcBrFaceLoopTraverser faLoTrav;
for (faLoTrav.setFace(face);
!faLoTrav.done(); faLoTrav.next())
{
AcBrLoop lp;
faLoTrav.getLoop(lp);
AcBr::LoopType type;
//acutPrintf(ACRX_T("\\nFACE : %d"), faceCount);
AcBrLoopVertexTraverser loEdTrav;
if (loEdTrav.setLoop(faLoTrav) == AcBr::eOk)
{
int edgeCount = 0;
AcGePoint2dArray verts;
AcGeVoidPointerArray edgeArray;
rbo->rbnext = acutNewRb(RTLB);
rbo = rbo->rbnext;
for (;!loEdTrav.done(); loEdTrav.next())
{
edgeCount++;
//AcBrEdge edge;
AcBrVertex vtx;
loEdTrav.getVertex(vtx);
//vtx.getVertex1(start);
AcGePoint3d stPt3d;
vtx.getPoint(stPt3d);
/*AcBrVertex end;
edge.getVertex2(end);
AcGePoint3d endPt3d;
end.getPoint(endPt3d);*/
AcGePoint3d pt;
pt = stPt3d;
pt.x -= decale.x;
pt.y -= decale.y;
pt.z -= decale.z;
rbo->rbnext = acutNewRb(RT3DPOINT);
rbo = rbo->rbnext;
rbo->resval.rpoint[0] = pt.x;
rbo->resval.rpoint[1] = pt.y;
rbo->resval.rpoint[2] = pt.z;
}
rbo->rbnext = acutNewRb(RTLE);
rbo = rbo->rbnext;
}
}
returnValue = brepFaceTrav.next();
}
rbo->rbnext = acutNewRb(RTLE);
acedRetList(_rbo);
}
entity->close();
}
return RSRSLT;
} |
|