- UID
- 544
- 积分
- 99
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-14
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
程序思路:在lisp中用该函数,参数一为一面域句柄,参数二为一三维点,程序目的是以三维点作一半径为1的圆,获得该圆的面域,再求圆的面域和参数一面域的交集,若交集为圆的面域,则判断出点在面域内,返回T,否则返回nil,但为什么无论传入的点是否在面域内都返回nil呢?
int isinregion(struct resbuf *rb)
{
ads_name objName;
AcDbObjectId objId;
AcDbCircle *circle;
AcGeVector3d normal(0.0, 0.0, 1.0);
AcDbRegion *region;
AcDbRegion *circleregion;
AcDbRegion *newregion;
AcDbVoidPtrArray crarray;
AcDbVoidPtrArray rearray;
AcGePoint3d point;
struct resbuf *rb1;
if (rb == NULL)
{
return RTERROR;
}
if (rb->restype == RTSTR) {
if(acdbHandEnt(rb->resval.rstring, objName) != RTNORM)
{
acdbFail("No entity with that handle exists\n");
return RTERROR;
}
} else {
acdbFail(/*MSG3*/"Argument1 should be an Handle String.");
return RTERROR;
}
rb1 = rb->rbnext;
if (rb1 == NULL)
return RTERROR;
if (rb1->restype == RT3DPOINT) {
point.set(rb1->resval.rpoint[X], rb1->resval.rpoint[Y], rb1->resval.rpoint[Z]);
} else {
acdbFail(/*MSG3*/"Argument2 should be an 3DPOINT.");
return RTERROR;
}
if(acdbGetObjectId(objId, objName) == Acad::eInvalidAdsName)
{
acedRetNil();
return RTNORM;
}
if(acdbOpenObject(region, objId , AcDb::kForWrite) != Acad::eOk)
{
acedRetNil();
return RTNORM;
}
circle = new AcDbCircle(point, normal, 1);
crarray.append(circle);
if(AcDbRegion::createFromCurves(crarray,
rearray) == Acad::eInvalidInput)
{
acedAlert("InvalidInput.");
acedRetNil();
return RTNORM;
}
circleregion = AcDbRegion::cast((AcRxObject*)rearray[0]);
if(region->booleanOper(AcDb::kBoolIntersect, circleregion) == Acad::eOk)
{
acedRetT();
}
else
{
//acedAlert("NULL.");
acedRetNil();
}
for (int i = 0; i < rearray.length(); i++) {
delete (AcRxObject*)rearray;
}
region->close();
return RTNORM;
} |
|