高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】请教遍历的问题
请教遍历的问题
请教遍历的问题
问题:构造选择集,获取选择集里的特征点并充放在数组中,然后在比较特征点在数组中的位置。以下是代码,但结果总是不正确,虽然调试是通了。
请各位帮忙,谢谢!
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[i]);
acdbgetobjectid(objid,ent[i]);
acdbopenobject(pentity,objid,acdb::kforread);//打开点实体
if(pentity->iskindof(acdbcircle::desc()))
{
// 显示圆的圆心
acdbcircle *pcircle = acdbcircle::cast(pentity);
acgepoint3d ptcenter;
ptcenter = pcircle->center();
coordinate[i][0]=ptcenter[x];
coordinate[i][1]=ptcenter[y];
coordinate[i][2]=ptcenter[z];
}
if(pentity->iskindof(acdbpoint::desc()))
{
// 显示点的坐标
acdbpoint *ppoint = acdbpoint::cast(pentity);
acgepoint3d ptpoint;
ptpoint = ppoint->position();
coordinate[i][0]=ptpoint[x];
coordinate[i][1]=ptpoint[y];
coordinate[i][2]=ptpoint[z];
}
pentity->close();
}
//*********以下程序是为实体标号***********//
for(i=1;i<ilast+1;i++)
{
cod_number=1;
acedssname(ssname,ilast-i,ent[i]);
acdbgetobjectid(objid,ent[i]);
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);
}
用acdbobjectidarray
qq group:13107070
|