- UID
- 359661
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-12-1
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
问题:构造选择集,获取选择集里的特征点并充放在数组中,然后在比较特征点在数组中的位置。以下是代码,但结果总是不正确,虽然调试是通了。
请各位帮忙,谢谢!
void zhao_rank()
{
// TODO: Implement the command
int i,cod_number;
int j;
long ilast;
ads_name ent[256];
float coordinate[256][3];
acedSSLength(ssname,&ilast);
AcDbEntity *pEntity;
AcDbObjectId objId;
//*********以下程序是将选择集中实体坐标储存在二维数组***********//
for(i=1;i<ilast+1;i++)
{
acedSSName(ssname,ilast-i,ent);
acdbGetObjectId(objId,ent);
acdbOpenObject(pEntity,objId,AcDb::kForRead);//打开点实体
if(pEntity->isKindOf(AcDbCircle::desc()))
{
// 显示圆的圆心
AcDbCircle *pCircle = AcDbCircle::cast(pEntity);
AcGePoint3d ptCenter;
ptCenter = pCircle->center();
coordinate[0]=ptCenter[X];
coordinate[1]=ptCenter[Y];
coordinate[2]=ptCenter[Z];
}
if(pEntity->isKindOf(AcDbPoint::desc()))
{
// 显示点的坐标
AcDbPoint *pPoint = AcDbPoint::cast(pEntity);
AcGePoint3d ptPoint;
ptPoint = pPoint->position();
coordinate[0]=ptPoint[X];
coordinate[1]=ptPoint[Y];
coordinate[2]=ptPoint[Z];
}
pEntity->close();
}
//*********以下程序是为实体标号***********//
for(i=1;i<ilast+1;i++)
{
cod_number=1;
acedSSName(ssname,ilast-i,ent);
acdbGetObjectId(objId,ent);
acdbOpenObject(pEntity,objId,AcDb::kForRead);//打开点实体
if(pEntity->isKindOf(AcDbCircle::desc()))
{
AcDbCircle *pCircle = AcDbCircle::cast(pEntity);
AcGePoint3d ptCenter;
ptCenter = pCircle->center();
for(j=1;j<ilast+1;j++)
if(ptCenter[Y]<coordinate[j][1]||(ptCenter[Y]==coordinate[j][1]&&ptCenter[X]<coordinate[j][0]))
cod_number=cod_number+1;
acutPrintf("\n %d",cod_number);
}
if(pEntity->isKindOf(AcDbPoint::desc()))
{
AcDbPoint *pPoint = AcDbPoint::cast(pEntity);
AcGePoint3d ptPoint;
ptPoint = pPoint->position();
for(j=1;j<ilast+1;j++)
if(ptPoint[Y]<coordinate[j][1]||(ptPoint[Y]==coordinate[j][1]&&ptPoint[X]<coordinate[j][0]))
cod_number=cod_number+1;
acutPrintf("\n %d",cod_number);
}
}
acedSSFree(ssname);
} |
|