|
// 取得选择集包围盒
static bool GetSSExtents(ads_name ss, ads_point &maxpt, ads_point &minpt)
{
long len;
int ret = acedSSLength(ss, &len);
if(ret != RTNORM || len < 1) return FALSE;
AcDbObjectId objId;
ads_name ename;
AcDbEntity *pEnt;
AcDbExtents extent;
AcGePoint3d pt1, pt2;
acedSSName(ss, 0, ename);
acdbGetObjectId(objId, ename);
acdbOpenObject(pEnt, objId, AcDb::kForRead);
pEnt->getGeomExtents(extent);
pt1 = extent.maxPoint();
pt2 = extent.minPoint();
pEnt->close();
for(int i = 0; i < len; i++)
{
acedSSName(ss, i, ename);
acdbGetObjectId(objId, ename);
acdbOpenObject(pEnt, objId, AcDb::kForRead);
pEnt->getGeomExtents(extent);
if(pt1[X] < extent.maxPoint()[X] || pt1[Y] < extent.maxPoint()[Y])
pt1 = extent.maxPoint();
if(pt2[X] > extent.minPoint()[X] || pt2[Y] > extent.minPoint()[Y])
pt2 = extent.minPoint();
pEnt->close();
}
maxpt[X] = pt1[X];
maxpt[Y] = pt1[Y];
maxpt[Z] = pt1[Z];
minpt[X] = pt2[X];
minpt[Y] = pt2[Y];
minpt[Z] = pt2[Z];
return TRUE;
} |
|