|
如何使用 AcDbRegion::getAreaProp()
该函数的前三个参数描述为
- 原点 返回区域
的原点 - xAxis 返回该区域
的 xAxis - yAxis 返回该区域的 yAxis
但考虑到这些参数
的const声明虚拟Acad::ErrorStatus getAreaProp(
const AcGePoint3d& origin,
const AcGeVector3d& xAxis,
const AcGeVector3d& yAxis, ... );
很明显,这三个参数不是输出参数,而是输入参数。使用未正确初始化的参数会导致函数返回 Acad::eInvalidInput。
以下是 AcDbRegion 的正确应用程序::getAreaProp():
[code]// note for code brevity, some error checking are omitted
//
void getRegionAreaProp()
{
ads_name eNam;
ads_point pt;
AcDbObjectId eId;
if (acedEntSel(L"\nSelect an region: ", eNam, pt) != RTNORM)
{
acutPrintf(L"\nNothing selected.");
return;
}
acdbGetObjectId(eId, eNam);
AcDbEntity* pEnt = NULL;
if(acdbOpenAcDbEntity(pEnt, eId, AcDb::kForRead) != Acad::eOk)
{
acutPrintf(L"\nError open entity.");
return;
}
AcDbRegion* pReg = AcDbRegion::cast(pEnt);
if(!pReg)
{
pEnt->close();
return;
}
double perimeter, area, momInertia[2],
prodInertia, prinMoments[2],
radiiGyration[2];
AcGePoint2d centroid, extentsLow, extentsHigh;
AcGeVector2d prinAxes[2];
AcGePoint3d origin;
AcGeVector3d xAxis;
AcGeVector3d yAxis;
// initialize the three arguments
AcGePlane plane;
pReg->getPlane(plane);
plane.getCoordSystem(origin, xAxis, yAxis);
Acad::ErrorStatus es = pReg->getAreaProp(
// these (3) are the input parameters
origin, xAxis, yAxis,
perimeter,
area,
centroid,
momInertia,
prodInertia,
prinMoments,
prinAxes,
radiiGyration,
extentsLow,
extentsHigh);
assert(es == Acad::eOk);
// you can determine what to do exactly with the results
// here I just print a message
acutPrintf(L"\nSucceded in getting an region's area prop.");
pReg->close();
}[/code] |
|