moab
smoab::Interface Class Reference

#include <SimpleMoab.h>

List of all members.

Public Member Functions

 Interface (const std::string &file)
 ~Interface ()
moab::Tag getMoabTag (const smoab::Tag &simpleTag) const
std::string name (const smoab::EntityHandle &entity) const
smoab::EntityHandle getRoot () const
smoab::Range findEntities (const smoab::EntityHandle root, moab::EntityType type) const
smoab::Range findEntitiesWithTag (const smoab::Tag &tag, smoab::EntityHandle root, moab::EntityType type=moab::MBENTITYSET) const
smoab::Range findEntitiesWithDimension (const smoab::EntityHandle root, int dimension) const
smoab::Range findAdjacentEntities (const smoab::EntityHandle &entity, int dimension) const
smoab::Range findAdjacentEntities (const smoab::Range &range, int dimension, const smoab::adjacency_type type=smoab::UNION) const
smoab::Range findEntityRootParents (smoab::EntityHandle const &root) const
smoab::Range findDetachedEntities (moab::EntityHandle const &root) const
smoab::Range findEntitiesWithMultipleParents (smoab::EntityHandle const &root)
void printRange (smoab::Range const &range)

Private Attributes

moab::InterfaceMoab

Friends

class smoab::DataSetConverter

Detailed Description

Definition at line 75 of file SimpleMoab.h.


Constructor & Destructor Documentation

smoab::Interface::Interface ( const std::string &  file) [inline]

Definition at line 78 of file SimpleMoab.h.

    {
    this->Moab = new moab::Core();
    this->Moab->load_file(file.c_str());
    }

Definition at line 84 of file SimpleMoab.h.

    {
    if(this->Moab)
      {
      delete this->Moab;
      this->Moab = NULL;
      }
    }

Member Function Documentation

smoab::Range smoab::Interface::findAdjacentEntities ( const smoab::EntityHandle entity,
int  dimension 
) const [inline]

Definition at line 200 of file SimpleMoab.h.

    {
    const int adjType = static_cast<int>(smoab::INTERSECT);
    smoab::Range result;
    const bool create_if_missing = false;
    this->Moab->get_adjacencies(&entity,
                                1,
                                dimension,
                                create_if_missing,
                                result,
                                adjType);
    return result;
    }
smoab::Range smoab::Interface::findAdjacentEntities ( const smoab::Range range,
int  dimension,
const smoab::adjacency_type  type = smoab::UNION 
) const [inline]

Definition at line 216 of file SimpleMoab.h.

    {
    //the smoab and moab adjacent intersection enums are in the same order
    const int adjType = static_cast<int>(type);
    smoab::Range result;
    const bool create_if_missing = false;
    this->Moab->get_adjacencies(range,dimension,
                                create_if_missing,
                                result,
                                adjType);

    return result;
    }

Definition at line 261 of file SimpleMoab.h.

    {
    smoab::Range detached;

    typedef moab::Range::const_iterator iterator;
    moab::Range sets;

    this->Moab->get_entities_by_type(root, moab::MBENTITYSET, sets);
    for(iterator i=sets.begin(); i!=sets.end();++i)
      {
      int numParents=0,numChildren=0;
      this->Moab->num_parent_meshsets(*i,&numParents);
      if(numParents==0)
        {
        this->Moab->num_child_meshsets(*i,&numChildren);
        if(numChildren==0)
          {
          detached.insert(*i);
          }
        }
      }
    return detached;
    }
smoab::Range smoab::Interface::findEntities ( const smoab::EntityHandle  root,
moab::EntityType  type 
) const [inline]

Definition at line 127 of file SimpleMoab.h.

    {
    smoab::Range result;
    // get all the sets of that type in the mesh
    this->Moab->get_entities_by_type(root, type, result);
    return result;
    }
smoab::Range smoab::Interface::findEntitiesWithDimension ( const smoab::EntityHandle  root,
int  dimension 
) const [inline]

Definition at line 181 of file SimpleMoab.h.

    {
    typedef smoab::Range::const_iterator iterator;

    smoab::Range result;
    this->Moab->get_entities_by_dimension(root,dimension,result);


    smoab::Range children;
    this->Moab->get_child_meshsets(root,children,0);
    for(iterator i=children.begin(); i !=children.end();++i)
      {
      this->Moab->get_entities_by_dimension(*i,dimension,result);
      }
    return result;
    }

Definition at line 287 of file SimpleMoab.h.

    {
    smoab::Range multipleParents;
    typedef moab::Range::const_iterator iterator;

    //for all the elements in the range, find all items with multiple parents
    moab::Range children;
    this->Moab->get_child_meshsets(root,children,0);
    for(iterator i=children.begin(); i!=children.end();++i)
      {
      int numParents=0;
      this->Moab->num_parent_meshsets(*i,&numParents);
      if(numParents>1)
        {
        multipleParents.insert(*i);
        }
      }
    return multipleParents;
    }
smoab::Range smoab::Interface::findEntitiesWithTag ( const smoab::Tag tag,
smoab::EntityHandle  root,
moab::EntityType  type = moab::MBENTITYSET 
) const [inline]

Definition at line 140 of file SimpleMoab.h.

    {
    smoab::Range result;

    moab::Tag t = this->getMoabTag(tag);

    // get all the entities of that type in the mesh
    this->Moab->get_entities_by_type_and_tag(root, type, &t, NULL, 1,result);


    if(tag.isComparable())
      {
      int value=0;
      //now we have to remove any that doesn't match the tag value
      smoab::Range resultMatchingTag;
      typedef moab::Range::const_iterator iterator;
      for(iterator i=result.begin();
          i != result.end();
          ++i)
        {
        value = 0;
        moab::EntityHandle handle = *i;
        this->Moab->tag_get_data(t, &handle, 1, &value);
        if(value == tag.value())
          {
          resultMatchingTag.insert(*i);
          }
        }

      return resultMatchingTag;
      }
    else
      {
      //we return all the items we found
      return result;
      }
    }

Definition at line 235 of file SimpleMoab.h.

    {
    smoab::Range parents;

    typedef moab::Range::const_iterator iterator;
    moab::Range sets;

    this->Moab->get_entities_by_type(root, moab::MBENTITYSET, sets);
    for(iterator i=sets.begin(); i!=sets.end();++i)
      {
      int numParents=0,numChildren=0;
      this->Moab->num_parent_meshsets(*i,&numParents);
      if(numParents==0)
        {
        this->Moab->num_child_meshsets(*i,&numChildren);
        if(numChildren>=0)
          {
          parents.insert(*i);
          }
        }
      }
    return parents;
    }
moab::Tag smoab::Interface::getMoabTag ( const smoab::Tag simpleTag) const [inline]

Definition at line 94 of file SimpleMoab.h.

    {
    moab::Tag tag;
    this->Moab->tag_get_handle(simpleTag.name(),
                               1,
                               simpleTag.dataType(),
                               tag);
    return tag;
    }

Definition at line 124 of file SimpleMoab.h.

{ return this->Moab->get_root_set(); }
std::string smoab::Interface::name ( const smoab::EntityHandle entity) const [inline]

Definition at line 106 of file SimpleMoab.h.

    {
    moab::Tag nameTag;
    moab::ErrorCode rval = this->Moab->tag_get_handle(NAME_TAG_NAME,
                                                      NAME_TAG_SIZE,
                                                      moab::MB_TYPE_OPAQUE,
                                                      nameTag);
    if(rval != moab::MB_SUCCESS) { return std::string(); }

    char name[NAME_TAG_SIZE];
    rval = this->Moab->tag_get_data(nameTag,&entity,1,&name);
    if(rval != moab::MB_SUCCESS) { return std::string(); }

    return std::string(name);
    }
void smoab::Interface::printRange ( smoab::Range const &  range) [inline]

Definition at line 309 of file SimpleMoab.h.

    {
    typedef Range::const_iterator iterator;
    for(iterator i=range.begin(); i!=range.end(); ++i)
      {
      std::cout << "entity id: " << *i << std::endl;
      this->Moab->list_entity(*i);
      }
    }

Friends And Related Function Documentation

friend class smoab::DataSetConverter [friend]

Definition at line 319 of file SimpleMoab.h.


Member Data Documentation

Definition at line 321 of file SimpleMoab.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines