|
int isPointOnRegion( bool& bIsOn, AcGePoint3d pt,AcDbObjectId regionId,double dMinDist )
{
Acad::ErrorStatus es;
bIsOn = false ;
AcDbRegion* pRegion ;
es = acdbOpenObject( pRegion, regionId, AcDb::kForRead );
if( es ) return 1;
AcDbVoidPtrArray entitySet;
es = pRegion->explode( entitySet );
pRegion->close();
if ( es )
{
return 2;
}
for ( int i = 0; i < entitySet.length() ; i ++ )
{
if(!((AcDbEntity*)entitySet[i])->isKindOf(AcDbCurve::desc())) continue;
AcDbCurve *pCurve = ((AcDbCurve*&)entitySet[i]);
if ( pCurve == NULL )
{
continue;
}
// 清空
if( bIsOn )
{
delete pCurve;
continue;
}
AcGePoint3d ptOn;
es = pCurve->getClosestPointTo( pt, ptOn );
if ( es )
{
delete pCurve ;
return 3 ;
}
delete pCurve ;
pt.z = ptOn.z = 0;
if ( pt.distanceTo( ptOn ) <= dMinDist )
{
bIsOn = true ;
break ;
}
}
return 0;
} |
|