- UID
- 51118
- 积分
- 8
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-5-21
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
目的:通过封闭的线生成一个AcDbRegion 再生成AcDbBrep
再检测点或者线与它的相对位置,但返回值总是0 unknowed?
如下:
AcDbObjectIdArray ids;
if( selectEntitys( ids )!=RTNORM )
return;
Acad::ErrorStatus es;
AcDbVoidPtrArray curves;
AcDbVoidPtrArray regions;
AcDbRegion *pRegion=NULL;
AcDbObject* pObj;
AcDbObjectId regionId;
for( int iii=0; iii<ids.logicalLength(); iii++ ) {
if( acdbOpenObject( pObj,ids[iii],AcDb::kForRead ) ) {
acutPrintf("\nacdbOpenObject failed");
continue;
}
curves.append( (void*)pObj );
}
if( (es = AcDbRegion::createFromCurves(curves, regions)) != Acad::eOk ) {
acutPrintf("\ncreateFromCurves failed ");
AfxMessageBox(" not ok ");
}
else{
AfxMessageBox(" ok ");
int nums=regions.length();
acutPrintf(" num==%d ",nums );
if( nums<=0 ){
acutPrintf(" 0regions ");
es=Acad::eInvalidInput;
}
else if( nums>1 ){
acutPrintf(" %d-regions ",nums);
for( iii=0; iii<nums; iii++ ){
delete ((AcDbObject*)regions[iii]);
}
es=Acad::eInvalidInput;
}
else if( (pRegion = AcDbRegion::cast((AcRxObject*)regions[0])) == NULL){
acutPrintf("\nCouldn't generate region\n");
es=Acad::eInvalidInput;
}
}
AfxMessageBox(" === ");
if( es==Acad::eOk )
postToDb( pRegion, regionId );
for( iii=0; iii<curves.length(); iii++ )
((AcDbObject*)curves[iii])->close();
AcGePoint3d pt;
//AcBrBrep *pBrep=NULL;
AcBr::Relation relation;
int retcode;
if( es==Acad::eOk ){
AfxMessageBox("brep---start");
acdbOpenAcDbEntity( (AcDbEntity*&) pRegion, regionId, AcDb::kForRead );
AcBrBrep*pBrep = new AcBrBrep;
pBrep->setSubentPath( AcDbFullSubentPath( regionId, AcDbSubentId()));
AcGe::PointContainment containment;
AcBrEntity* container;
//或者如下生成也同样
//pBrep= (AcBrBrep*) pRegion->body();
//pBrep = new AcBrBrep;
//pBrep->set( (AcDbEntity&) pRegion );
AfxMessageBox("brep");
if( pBrep==NULL ){
AfxMessageBox("null");
}
else{
while(1){
if( acedGetPoint( NULL,"pt ",asDblArray(pt ))==RTNORM ){
//pBrep->getPointRelationToBrep(pt, relation);
pBrep->getPointContainment( pt, containment,container);
acutPrintf(" AcBr=%d ",containment );
//返回值总是0 为什么???
if( containment==AcGe::kInside ){
retcode=1;
}
else if( containment==AcGe::kOnBoundary){
retcode=0;
}
else if( containment==AcGe::kOutside){
retcode=-1;
}
else{
retcode=-20;
}
//}
//else
// retcode=-10;
acutPrintf(" %d ", retcode );
//if( container!=NULL )
// delete container;
}
else
break;
}
}
delete pBrep;
pRegion->close();
}
//for( iii=0; iii<curves.length(); iii++ )
// ((AcDbObject*)curves[iii])->close();
//if( pRegion!=NULL )
// delete pRegion; |
|