高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】find entity within area
find entity within area
find entity within area
hi
i'm trying to find all entities that lie within or intersect a certain area. the area is rectangular, aligned to the x- and y-axis (defined by 4 lines). z-coordinates are ignored, all entities will be projected to the xy-plane.
this is not so hard to accomplish. i came up with a solution using odgeextents2d. unfortunately my code is very slow, it seems that calculating the extents for an entity takes quite long...
code:
bool functions::lieswithinarea( oddbentityptr entityptr, odgeextents2d &inftotalextents)
{
bool lieswithin = false;
odgeextents3d entityextents;
odresult extentsresult = entityptr->getgeomextents( entityextents );
if( extentsresult == eok && entityextents.isvalidextents() && inftotalextents.isvalidextents() ){
//project extents to xy-plane
odgeextents2d entityextents2d( entityextents.minpoint().convert2d(), entityextents.maxpoint().convert2d() );
if( !entityextents2d.isdisjoint( inftotalextents ) ){
lieswithin = true;
}
}
return lieswithin;
}another attempt to solve this problem: get a position of an entity and see if it is contained in the area. drawbacks of this is, that i have to find out what entity i'm dealing with and how to get a valid position (not all entities have methods to get a wcs position of any kind). in addition to that, the position could be out of the area but some part of the entity still intersects with it.
do you have any suggestions? what classes/methods should i use?
thanks
martin
hi
mfcapp - our viewer sample - has selection by box functionality. could you check the performance of this selection tool with your sample file ? is it ok for you? i am not sure that you can use this selection functionality in your application, but as first step, please, check the performance...
we have functionality named selectionset. it used inside selection by box. in fact it should do the same comparing like yours, but may be faster.
thanks for your swift answer. i realized that i had made some unnecessary iterations calling "blockid()" instead of the "dimblockid()" on the dimension-object. now that this is corrected, the code is faster (one 3rd of the time) and i can live with that. however, i will keep your proposal in mind. thanks again.
|