[MOAB-dev] Get all entities with a particular tag and check if entity is tagged

Tim Tautges tautges at mcs.anl.gov
Mon Oct 22 14:32:14 CDT 2012



On 10/22/2012 01:20 PM, Milad Fatenejad wrote:
> Hello:
>
> I have two questions:
>
> 1. Is there a general way to get all entities with a particular tag applied? I've seen get_entities_by_type_and_tag, so
> I guess one could repeatedly call this function with each entity type. I've also seen get_entities_by_handle which would
> give all entities in a range. Is there a way to filter the range by tag?
>

Use get_entities_by_type_and_tag with MBMAXTYPE as the type to get entities with arbitrary type and a specified tag (and 
leave tag_value NULL to get any regardless of the value).  Beware of dense tags with default values, since any entities 
without that tag set will look like they have that tag/value.

>
> 2. Is there a way to check if an entity has a particular tag applied? Right now, I am calling tag_get_data then checking
> if moab::MB_TAG_NOT_FOUND is returned. Is this the proper thing to do? My understanding is the same error code is
> returned if the tag itself does not exist (i.e. an invalid tag handle is passed in)...
>

tag_get_tags_on_entity then search for the tag; or, tag_get_data (see above regarding dense tags with default value). 
If using tag_get_data, add sparse tags to that beware.

- tim

> Thanks
> Milad

-- 
================================================================
"You will keep in perfect peace him whose mind is
   steadfast, because he trusts in you."               Isaiah 26:3

              Tim Tautges            Argonne National Laboratory
          (tautges at mcs.anl.gov)      (telecommuting from UW-Madison)
  phone (gvoice): (608) 354-1459      1500 Engineering Dr.
             fax: (608) 263-4499      Madison, WI 53706



More information about the moab-dev mailing list