moab
moab::MeshSet Class Reference

Class to implement entity set functionality. More...

#include <MeshSet.hpp>

List of all members.

Classes

union  CompactList
struct  dim_test
struct  hdl_iter
struct  not_dim_test
struct  not_type_test
struct  type_test

Public Types

enum  Count { ZERO = 0, ONE = 1, TWO = 2, MANY = 3 }
 Possible values of mParentCount and mChildCount. More...

Public Member Functions

 MeshSet ()
 create an empty meshset
 MeshSet (unsigned flags)
 create an empty meshset
 ~MeshSet ()
 destructor
ErrorCode set_flags (unsigned flags, EntityHandle my_handle, AEntityFactory *adjacencies)
const EntityHandleget_children (int &count_out) const
 get all children pointed to by this meshset
const EntityHandleget_parents (int &count_out) const
 get all parents pointed to by this meshset
int num_children () const
 return the number of children pointed to by this meshset
int num_parents () const
 return the number of parents pointed to by this meshset
int add_parent (EntityHandle parent)
int add_child (EntityHandle child)
int remove_parent (EntityHandle parent)
int remove_child (EntityHandle child)
unsigned flags () const
int tracking () const
 returns whether entities of meshsets know this meshset
int set () const
int ordered () const
int vector_based () const
ErrorCode replace_entities (EntityHandle my_handle, const EntityHandle *old_entities, const EntityHandle *new_entities, size_t num_entities, AEntityFactory *mAdjFact)
ErrorCode clear (EntityHandle myhandle, AEntityFactory *adjacencies)
ErrorCode clear_all (EntityHandle myhandle, AEntityFactory *adjacencies)
const EntityHandleget_contents (size_t &count_out) const
EntityHandleget_contents (size_t &count_out)
ErrorCode get_entities (std::vector< EntityHandle > &entities) const
ErrorCode get_entities (Range &entities) const
ErrorCode get_entities_by_type (EntityType entity_type, std::vector< EntityHandle > &entity_list) const
 get all entities in this MeshSet with the specified type
ErrorCode get_entities_by_type (EntityType type, Range &entity_list) const
unsigned int num_entities_by_type (EntityType type) const
 return the number of entities with the given type contained in this meshset
ErrorCode get_entities_by_dimension (int dimension, std::vector< EntityHandle > &entity_list) const
ErrorCode get_entities_by_dimension (int dimension, Range &entity_list) const
unsigned int num_entities_by_dimension (int dimension) const
 return the number of entities with the given type contained in this meshset
ErrorCode get_non_set_entities (Range &range) const
bool contains_entities (const EntityHandle *entities, int num_entities, const int op) const
ErrorCode subtract (const MeshSet *meshset_2, EntityHandle my_handle, AEntityFactory *adjacencies)
 subtract/intersect/unite meshset_2 from/with/into meshset_1; modifies meshset_1
ErrorCode intersect (const MeshSet *meshset_2, EntityHandle my_handle, AEntityFactory *adjacencies)
ErrorCode unite (const MeshSet *meshset_2, EntityHandle my_handle, AEntityFactory *adjacencies)
ErrorCode add_entities (const EntityHandle *entity_handles, const int num_entities, EntityHandle my_handle, AEntityFactory *adjacencies)
 add these entities to this meshset
ErrorCode add_entities (const Range &entities, EntityHandle my_handle, AEntityFactory *adjacencies)
 add these entities to this meshset
ErrorCode remove_entities (const Range &entities, EntityHandle my_handle, AEntityFactory *adjacencies)
 add these entities to this meshset
ErrorCode remove_entities (const EntityHandle *entities, const int num_entities, EntityHandle my_handle, AEntityFactory *adjacencies)
 remove these entities from this meshset
unsigned int num_entities () const
 return the number of entities contained in this meshset
bool empty () const
unsigned long get_memory_use () const

Static Public Member Functions

static int DIM_FROM_HANDLE (EntityHandle h)
static EntityHandle FIRST_OF_DIM (int dim)
static EntityHandle LAST_OF_DIM (int dim)

Protected Member Functions

ErrorCode convert (unsigned flags, EntityHandle my_handle, AEntityFactory *adj)
ErrorCode create_adjacencies (EntityHandle myhandle, AEntityFactory *adjacencies)
ErrorCode remove_adjacencies (EntityHandle myhandle, AEntityFactory *adjacencies)
ErrorCode insert_entity_vector (const EntityHandle *vect, size_t len, EntityHandle my_h, AEntityFactory *adj)
ErrorCode insert_entity_ranges (const EntityHandle *range_vect, size_t len, EntityHandle my_h, AEntityFactory *adj)
ErrorCode insert_entity_ranges (const Range &range, EntityHandle my_h, AEntityFactory *adj)
ErrorCode remove_entity_vector (const EntityHandle *vect, size_t len, EntityHandle my_h, AEntityFactory *adj)
ErrorCode remove_entity_ranges (const EntityHandle *range_vect, size_t len, EntityHandle my_h, AEntityFactory *adj)
ErrorCode remove_entity_ranges (const Range &range, EntityHandle my_h, AEntityFactory *adj)

Private Attributes

unsigned char mFlags
 Meshset propery flags.
unsigned mParentCount: 2
unsigned mChildCount: 2
unsigned mContentCount: 2
CompactList parentMeshSets
 Storage for data lists.
CompactList childMeshSets
CompactList contentList

Detailed Description

Class to implement entity set functionality.

Author:
Jason Kraftcheck <[email protected]>

Definition at line 25 of file MeshSet.hpp.


Member Enumeration Documentation

Possible values of mParentCount and mChildCount.

Enumerator:
ZERO 
ONE 
TWO 
MANY 

Definition at line 200 of file MeshSet.hpp.

{ ZERO=0, ONE=1, TWO=2, MANY=3 };

Constructor & Destructor Documentation

moab::MeshSet::MeshSet ( ) [inline]

create an empty meshset

Definition at line 311 of file MeshSet.hpp.

moab::MeshSet::MeshSet ( unsigned  flags) [inline]

create an empty meshset

Definition at line 316 of file MeshSet.hpp.

        : mFlags((unsigned char)flg), mParentCount(ZERO), mChildCount(ZERO), mContentCount(ZERO)
{ }

destructor

Definition at line 321 of file MeshSet.hpp.


Member Function Documentation

add a child to this meshset; returns true if child was added, 0 if it was already a child of this meshset

Definition at line 236 of file MeshSet.cpp.

ErrorCode moab::MeshSet::add_entities ( const EntityHandle entity_handles,
const int  num_entities,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

add these entities to this meshset

Definition at line 757 of file MeshSet.hpp.

{
  return insert_entity_vector( entity_handles, num_ents, my_handle, adjacencies );
}
ErrorCode moab::MeshSet::add_entities ( const Range entities,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

add these entities to this meshset

Definition at line 766 of file MeshSet.hpp.

{
  return insert_entity_ranges( entities, my_handle, adjacencies );
}

add a parent to this meshset; returns true if parent was added, 0 if it was already a parent of this meshset

Definition at line 230 of file MeshSet.cpp.

{ 
  int result = 0;
  mParentCount = insert_in_vector( (Count)mParentCount, parentMeshSets, parent, result );
  return result;
}
ErrorCode moab::MeshSet::clear ( EntityHandle  myhandle,
AEntityFactory adjacencies 
) [inline]

Clear *contents* of set (not parents or children)

Definition at line 383 of file MeshSet.hpp.

{ 
  if (tracking())
    remove_adjacencies( myhandle, adjacencies );
  if (mContentCount == MANY)
    free( contentList.ptr[0] );
  mContentCount = ZERO;
  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::clear_all ( EntityHandle  myhandle,
AEntityFactory adjacencies 
) [inline]

Clear all set lists (contents, parents, and children)

Definition at line 393 of file MeshSet.hpp.

{ 
  ErrorCode rval = clear( myhandle, adjacencies );
  if (mChildCount == MANY)
    free( childMeshSets.ptr[0] );
  mChildCount = ZERO;
  if (mParentCount == MANY)
    free( parentMeshSets.ptr[0] );
  mParentCount = ZERO;
  return rval;
}
bool moab::MeshSet::contains_entities ( const EntityHandle entities,
int  num_entities,
const int  op 
) const [inline]

Test of meshset contains some or all of passed entities

Parameters:
entitiesArray of entities
num_entitiesLength of array of entities.
op- Interface::UNION : Test if set contains any of the input entities

Definition at line 704 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* const ptr = get_contents( count );
  const EntityHandle* const end = ptr + count;
  size_t found_count = 0;
  if (vector_based()) {
    for (int i = 0; i < num_ents; ++i)
      if (std::find( ptr, end, entities[i] ) < end)
        ++found_count; 
  }
  else {
    assert(0 == count % 2);
    for (int i = 0; i < num_ents; ++i) {
      const unsigned long idx = std::lower_bound( ptr, end, entities[i] ) - ptr;
      if (idx < count && (idx%2 != 0 || ptr[idx] == entities[i]))
        ++found_count;
    }
  }

  return found_count >= ((Interface::INTERSECT == op) ? (unsigned)num_ents : 1u);
}
ErrorCode moab::MeshSet::convert ( unsigned  flags,
EntityHandle  my_handle,
AEntityFactory adj 
) [protected]

Convert for changing flag values

Definition at line 261 of file MeshSet.cpp.

{
  ErrorCode rval = MB_SUCCESS;
  if ((mFlags & MESHSET_TRACK_OWNER) && !(flg & MESHSET_TRACK_OWNER))
    rval = remove_adjacencies( my_handle, adj );
  else if (!(mFlags & MESHSET_TRACK_OWNER) && (flg & MESHSET_TRACK_OWNER))
    rval = create_adjacencies( my_handle, adj );
  if (MB_SUCCESS != rval)
    return rval;

  if (!(mFlags & MESHSET_ORDERED) && (flg & MESHSET_ORDERED)) {
    size_t datalen;
    EntityHandle* data = get_contents(datalen);
    if (datalen) {
      std::vector<EntityHandle> list( datalen );
      memcpy( &list[0], data, datalen*sizeof(EntityHandle) );
      int num_ents = num_entities();
      Count count = (Count)mContentCount;
      data = resize_compact_list( count, contentList, num_ents );
      mContentCount = count;
      assert( list.size() % 2 == 0 );
      std::vector<EntityHandle>::iterator i = list.begin();
      while (i != list.end()) {
        EntityHandle h = *i; ++i;
        EntityHandle e = *i; ++i;
        for (; h <= e; ++h) {
          *data = h; 
          ++data;
        }
      }
    }
  }
  else if ((mFlags & MESHSET_ORDERED) && !(flg & MESHSET_ORDERED)) {
    size_t datalen;
    EntityHandle* data = get_contents(datalen);
    if (datalen) {
      std::vector<EntityHandle> ranges;
      convert_to_ranges( data, datalen, ranges );
      Count count = (Count)mContentCount;
      data = resize_compact_list( count, contentList, ranges.size() );
      mContentCount = count;
      memcpy( data, &ranges[0], ranges.size()*sizeof(EntityHandle) );
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::create_adjacencies ( EntityHandle  myhandle,
AEntityFactory adjacencies 
) [protected]

Add explicit adjacencies from all contained entities to this (i.e. convert to tracking)

Definition at line 309 of file MeshSet.cpp.

{
  ErrorCode rval = MB_SUCCESS;;
  size_t count;
  const EntityHandle *const ptr = get_contents( count );
  const EntityHandle *const end = ptr + count;
  if (vector_based()) {
    for (const EntityHandle* i = ptr; i != end; ++i) {
      rval = adj->add_adjacency( *i, my_handle, false );
      if (MB_SUCCESS != rval) {
        for (const EntityHandle* j = ptr; j != i; ++j) 
          adj->remove_adjacency( *j, my_handle );
        return rval;
      }
    }
  }
  else {
    assert( 0 == count % 2 );
    for (const EntityHandle* i = ptr; i != end; i += 2) {
      for (EntityHandle h = i[0]; h <= i[1]; ++h) {
        rval = adj->add_adjacency( h, my_handle, false );
        if (MB_SUCCESS != rval) {
          for (EntityHandle j = i[0]; j < h; ++j)
            adj->remove_adjacency( j, my_handle );
          for (const EntityHandle* j = ptr; j != i; j += 2)
            for (EntityHandle k = j[0]; k <= j[1]; ++k)
              adj->remove_adjacency( k, my_handle );
          return rval;
        }
      }
    }
  }
  return MB_SUCCESS;
}
static int moab::MeshSet::DIM_FROM_HANDLE ( EntityHandle  h) [inline, static]

get dimension of enity

Definition at line 232 of file MeshSet.hpp.

    { return CN::Dimension( TYPE_FROM_HANDLE( h ) ); }
bool moab::MeshSet::empty ( ) const [inline]

Definition at line 165 of file MeshSet.hpp.

{ return mContentCount == ZERO; }
static EntityHandle moab::MeshSet::FIRST_OF_DIM ( int  dim) [inline, static]

Get smallest possible handle with specified dimension (first handle for first type of dimension)

Definition at line 236 of file MeshSet.hpp.

unsigned moab::MeshSet::flags ( ) const [inline]

Definition at line 67 of file MeshSet.hpp.

{ return mFlags; }
const EntityHandle * moab::MeshSet::get_children ( int &  count_out) const [inline]

get all children pointed to by this meshset

Definition at line 344 of file MeshSet.hpp.

{ 
  count_out = mChildCount;
  if (count_out < MANY)
    return childMeshSets.hnd;

  count_out = childMeshSets.ptr[1] - childMeshSets.ptr[0];
  return childMeshSets.ptr[0];
}
const EntityHandle * moab::MeshSet::get_contents ( size_t &  count_out) const [inline]

Get contents data array. NOTE: this may not contain what you expect if not vector_based

Definition at line 405 of file MeshSet.hpp.

{
  if (mContentCount == MANY) {
    count_out = contentList.ptr[1] - contentList.ptr[0];
    return contentList.ptr[0];
  }
  else {
    count_out = mContentCount;
    return contentList.hnd;
  }
}
EntityHandle * moab::MeshSet::get_contents ( size_t &  count_out) [inline]

Get contents data array. NOTE: this may not contain what you expect if not vector_based

Definition at line 417 of file MeshSet.hpp.

{
  if (mContentCount == MANY) {
    count_out = contentList.ptr[1] - contentList.ptr[0];
    return contentList.ptr[0];
  }
  else {
    count_out = mContentCount;
    return contentList.hnd;
  }
}
ErrorCode moab::MeshSet::get_entities ( std::vector< EntityHandle > &  entities) const [inline]

Get entities contained in set

Definition at line 429 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    size_t old_size = entities.size();
    entities.resize( count+old_size );
    std::copy( ptr, ptr+count, entities.begin()+old_size );
  }
  else {
    assert(count%2 == 0);
    for (size_t i = 0; i < count; i += 2) 
      std::copy( hdl_iter(ptr[i]), hdl_iter(ptr[i+1]+1), std::back_inserter(entities) );
  }
  return MB_SUCCESS;
} 
ErrorCode moab::MeshSet::get_entities ( Range entities) const [inline]

Get entities contained in set

Definition at line 446 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    std::copy( ptr, ptr+count, range_inserter(entities) );
  }
  else {
    assert(count%2 == 0);
    Range::iterator in = entities.begin();
    for (size_t i = 0; i < count; i += 2) 
      in = entities.insert( in, ptr[i], ptr[i+1] );
  }
  return MB_SUCCESS;
} 
ErrorCode moab::MeshSet::get_entities_by_dimension ( int  dimension,
std::vector< EntityHandle > &  entity_list 
) const [inline]

Definition at line 576 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    std::remove_copy_if( ptr, ptr+count, 
                         std::back_inserter( entity_list ),
                         not_dim_test(dimension) );
  }
  else {
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_OF_DIM(dimension) ) - ptr;
    if (idx < count && DIM_FROM_HANDLE(ptr[idx]) == dimension) {
      if (idx % 2) { // only part of first block is of type
        std::copy( hdl_iter(FIRST_OF_DIM(dimension)), hdl_iter(ptr[idx]+1), std::back_inserter( entity_list ) );
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (DIM_FROM_HANDLE(ptr[idx+1]) == dimension) // whole block is of type
          std::copy( hdl_iter(ptr[idx]), hdl_iter(ptr[idx+1]+1), std::back_inserter( entity_list ) );
        else {
          if (DIM_FROM_HANDLE(ptr[idx]) == dimension) // part of last block is of type
            std::copy( hdl_iter(ptr[idx]), hdl_iter(LAST_OF_DIM(dimension)), std::back_inserter( entity_list ) );
          break;
        }
      }
    }
  }

  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::get_entities_by_dimension ( int  dimension,
Range entity_list 
) const [inline]

Definition at line 610 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    std::remove_copy_if( ptr, ptr+count, 
                         range_inserter( entity_list ),
                         not_dim_test(dimension) );
  }
  else {
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_OF_DIM(dimension) ) - ptr;
    Range::iterator in = entity_list.begin();
    if (idx < count && DIM_FROM_HANDLE(ptr[idx]) == dimension) {
      if (idx % 2) { // only part of first block is of type
        in = entity_list.insert( in, FIRST_OF_DIM(dimension), ptr[idx] );
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (DIM_FROM_HANDLE(ptr[idx+1]) == dimension) // whole block is of type
          in = entity_list.insert( in, ptr[idx], ptr[idx+1] );
        else {
          if (DIM_FROM_HANDLE(ptr[idx]) == dimension) // part of last block is of type
            entity_list.insert( in, ptr[idx], LAST_OF_DIM(dimension) );
          break;
        }
      }
    }
  }

  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::get_entities_by_type ( EntityType  entity_type,
std::vector< EntityHandle > &  entity_list 
) const [inline]

get all entities in this MeshSet with the specified type

Definition at line 464 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (MBMAXTYPE == type) {
    return get_entities( entity_list);
  }
  else if (vector_based()) {
    std::remove_copy_if( ptr, ptr+count, 
                         std::back_inserter( entity_list ),
                         not_type_test(type) );
  }
  else {
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_HANDLE(type) ) - ptr;
    if (idx < count && TYPE_FROM_HANDLE(ptr[idx]) == type) {
      if (idx % 2) { // only part of first block is of type
        std::copy( hdl_iter(FIRST_HANDLE(type)), hdl_iter(ptr[idx]+1), std::back_inserter( entity_list ) );
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (TYPE_FROM_HANDLE(ptr[idx+1]) == type) // whole block is of type
          std::copy( hdl_iter(ptr[idx]), hdl_iter(ptr[idx+1]+1), std::back_inserter( entity_list ) );
        else {
          if (TYPE_FROM_HANDLE(ptr[idx]) == type) // part of last block is of type
            std::copy( hdl_iter(ptr[idx]), hdl_iter(LAST_HANDLE(type)), std::back_inserter( entity_list ) );
          break;
        }
      }
    }
  }

  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::get_entities_by_type ( EntityType  type,
Range entity_list 
) const [inline]

Definition at line 501 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (MBMAXTYPE == type) {
    return get_entities( entity_list );
  }
  else if (vector_based()) {
    std::remove_copy_if( ptr, ptr+count, 
                         range_inserter( entity_list ),
                         not_type_test(type) );
  }
  else {
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_HANDLE(type) ) - ptr;
    Range::iterator in = entity_list.begin();
    if (idx < count && TYPE_FROM_HANDLE(ptr[idx]) == type) {
      if (idx % 2) { // only part of first block is of type
        in = entity_list.insert( in, FIRST_HANDLE(type), ptr[idx] );
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (TYPE_FROM_HANDLE(ptr[idx+1]) == type) // whole block is of type
          in = entity_list.insert( in, ptr[idx], ptr[idx+1] );
        else {
          if (TYPE_FROM_HANDLE(ptr[idx]) == type) // part of last block is of type
            entity_list.insert( in, ptr[idx], LAST_HANDLE(type) );
          break;
        }
      }
    }
  }

  return MB_SUCCESS;
}
unsigned long moab::MeshSet::get_memory_use ( ) const

Definition at line 1176 of file MeshSet.cpp.

{
  unsigned long result = 0;
  if (mParentCount == MANY)
    result += parentMeshSets.ptr[1] - parentMeshSets.ptr[0];
  if (mChildCount == MANY)
    result += childMeshSets.ptr[1] - childMeshSets.ptr[0];
  if (mContentCount == MANY)
    result += contentList.ptr[1] - contentList.ptr[0];
  return sizeof(EntityHandle)*result;
}

Definition at line 679 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    std::remove_copy_if( ptr, ptr+count, 
                         range_inserter( range ),
                         type_test(MBENTITYSET) );
  }
  else {
    Range::iterator in = range.begin();
    for (size_t idx = 0; idx < count; idx += 2) {
      if (TYPE_FROM_HANDLE(ptr[idx+1]) != MBENTITYSET)
        in = range.insert( in, ptr[idx], ptr[idx+1] );
      else {
        if (TYPE_FROM_HANDLE(ptr[idx]) != MBENTITYSET)
          in = range.insert( in, ptr[idx], LAST_HANDLE( MBENTITYSET - 1 ) );
        break;
      }
    }
  }

  return MB_SUCCESS;
}
const EntityHandle * moab::MeshSet::get_parents ( int &  count_out) const [inline]

get all parents pointed to by this meshset

Definition at line 355 of file MeshSet.hpp.

{ 
  count_out = mParentCount;
  if (count_out < MANY)
    return parentMeshSets.hnd;

  count_out = parentMeshSets.ptr[1] - parentMeshSets.ptr[0];
  return parentMeshSets.ptr[0];
}
ErrorCode moab::MeshSet::insert_entity_ranges ( const EntityHandle range_vect,
size_t  len,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Insert vector of handle range pairs into MeshSet

Definition at line 961 of file MeshSet.cpp.

{
  typedef const std::pair<EntityHandle,EntityHandle>* pair_vect_t;
  pair_vect_t pair_vect = reinterpret_cast<pair_vect_t>(range_vect);
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  ErrorCode rval;
  if (!vector_based())
    rval = range_tool<pair_vect_t>::ranged_insert_entities( count, contentList,  pair_vect, 
                                             pair_vect + len/2, my_h, tracking() ? adj : 0 );
  else
    rval = range_tool<pair_vect_t>::vector_insert_entities( count, contentList,  pair_vect, 
                                             pair_vect + len/2, my_h, tracking() ? adj : 0 );
  mContentCount = count;
  return rval;
}
ErrorCode moab::MeshSet::insert_entity_ranges ( const Range range,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Insert Range of handles into MeshSet

Definition at line 977 of file MeshSet.cpp.

{
  ErrorCode rval;
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  if (!vector_based())
    rval = range_tool<Range::const_pair_iterator>::ranged_insert_entities( count, 
                             contentList, range.const_pair_begin(), range.const_pair_end(), 
                             my_h, tracking() ? adj : 0 );
  else
    rval = range_tool<Range::const_pair_iterator>::vector_insert_entities( count, 
                             contentList, range.const_pair_begin(), range.const_pair_end(), 
                             my_h, tracking() ? adj : 0 );
  mContentCount = count;
  return rval;
}
ErrorCode moab::MeshSet::insert_entity_vector ( const EntityHandle vect,
size_t  len,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Insert vector of handles into MeshSet

Definition at line 1099 of file MeshSet.cpp.

{
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  ErrorCode rval;
  if (vector_based())
    rval = vector_insert_vector( count, contentList, vect, len, my_h, tracking() ? adj : 0 );
  else {
    std::vector<EntityHandle> rangevect;
    convert_to_ranges( vect, len, rangevect );
    typedef const std::pair<EntityHandle,EntityHandle>* pair_vect_t;
    pair_vect_t pair_vect = reinterpret_cast<pair_vect_t>(&rangevect[0]);
    rval = range_tool<pair_vect_t>::ranged_insert_entities( count, contentList, pair_vect, 
                                 pair_vect + rangevect.size()/2, my_h, tracking() ? adj : 0 );
  }
  mContentCount = count;
  return rval;
}
ErrorCode moab::MeshSet::intersect ( const MeshSet meshset_2,
EntityHandle  my_handle,
AEntityFactory adjacencies 
)

Definition at line 1025 of file MeshSet.cpp.

{
  ErrorCode rval;
  if (!vector_based() && !other->vector_based()) {
    size_t other_count = 0;
    const EntityHandle* other_vect = other->get_contents( other_count );
    if (!other_count)
      return clear( my_handle, adj );
    assert(0 == other_count%2);
    
    std::vector<EntityHandle> compliment;
    compliment.reserve( other_count + 4 );
    if (*other_vect > 0) {
      compliment.push_back( 0 );
      compliment.push_back( *other_vect - 1 );
    }
    ++other_vect;
    const EntityHandle *const other_end = other_vect + other_count - 2;
    for (; other_vect < other_end; other_vect += 2) {
      compliment.push_back( other_vect[0] + 1 );
      compliment.push_back( other_vect[1] - 1 );
    }
    if (*other_vect < ~(EntityHandle)0) {
      compliment.push_back( *other_vect + 1 );
      compliment.push_back( ~(EntityHandle)0 );
    }
    
    return remove_entity_ranges( &compliment[0], compliment.size(), my_handle, adj );
  }
  else {
    Range my_ents, other_ents;
    rval = get_entities(my_ents);
    if (MB_SUCCESS != rval)
      return rval;
    rval = other->get_entities(other_ents);
    return remove_entities( moab::subtract(my_ents, other_ents), my_handle, adj );
  }
}
static EntityHandle moab::MeshSet::LAST_OF_DIM ( int  dim) [inline, static]

Get largest possible handle with specified dimension (largest handle for last type of dimension)

Definition at line 240 of file MeshSet.hpp.

    { return LAST_HANDLE( CN::TypeDimensionMap[dim].second ); }
int moab::MeshSet::num_children ( ) const [inline]

return the number of children pointed to by this meshset

Definition at line 366 of file MeshSet.hpp.

{
  if (mChildCount < MANY)
    return mChildCount;
  else
    return childMeshSets.ptr[1] - childMeshSets.ptr[0];
}
unsigned int moab::MeshSet::num_entities ( ) const [inline]

return the number of entities contained in this meshset

Definition at line 792 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* list = get_contents( count );
  if (vector_based())
    return count;
  
  int result = 0;
  const EntityHandle *const end = list + count;
  for (; list < end; list += 2)
    result += list[1] - list[0] + 1;
  return result;
}
unsigned int moab::MeshSet::num_entities_by_dimension ( int  dimension) const [inline]

return the number of entities with the given type contained in this meshset

Definition at line 644 of file MeshSet.hpp.

{
  unsigned int result;
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (vector_based()) {
    #ifndef __SUNPRO_CC
      result = std::count_if( ptr, ptr+count, dim_test(dimension) );
    #else
      std::count_if( ptr, ptr+count, dim_test(dimension), result );
    #endif
  }
  else {
    result = 0;
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_OF_DIM(dimension) ) - ptr;
    if (idx < count && DIM_FROM_HANDLE(ptr[idx]) == dimension) {
      if (idx % 2) { // only part of first block is of type
        result += ptr[idx] - FIRST_OF_DIM(dimension) + 1;
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (DIM_FROM_HANDLE(ptr[idx+1]) == dimension) // whole block is of type
          result += ptr[idx+1] - ptr[idx] + 1;
        else {
          if (DIM_FROM_HANDLE(ptr[idx]) == dimension) // part of last block is of type
            result += LAST_OF_DIM(dimension) - ptr[idx] + 1;
          break;
        }
      }
    }
  }

  return result;
}
unsigned int moab::MeshSet::num_entities_by_type ( EntityType  type) const [inline]

return the number of entities with the given type contained in this meshset

Definition at line 538 of file MeshSet.hpp.

{
  unsigned int result;
  size_t count;
  const EntityHandle* ptr = get_contents( count );
  if (MBMAXTYPE == type) {
    return num_entities( );
  }
  else if (vector_based()) {
    #ifndef __SUNPRO_CC
      result = std::count_if( ptr, ptr+count, type_test(type) );
    #else
      std::count_if( ptr, ptr+count, type_test(type), result );
    #endif
  }
  else {
    result = 0;
    size_t idx = std::lower_bound( ptr, ptr+count, FIRST_HANDLE(type) ) - ptr;
    if (idx < count && TYPE_FROM_HANDLE(ptr[idx]) == type) {
      if (idx % 2) { // only part of first block is of type
        result += ptr[idx] - FIRST_HANDLE(type) + 1;
        ++idx;
      }
      for (; idx < count; idx += 2) {
        if (TYPE_FROM_HANDLE(ptr[idx+1]) == type) // whole block is of type
          result += ptr[idx+1] - ptr[idx] + 1;
        else {
          if (TYPE_FROM_HANDLE(ptr[idx]) == type) // part of last block is of type
            result += LAST_HANDLE(type) - ptr[idx] + 1;
          break;
        }
      }
    }
  }

  return result;
}
int moab::MeshSet::num_parents ( ) const [inline]

return the number of parents pointed to by this meshset

Definition at line 375 of file MeshSet.hpp.

{
  if (mParentCount < MANY)
    return mParentCount;
  else
    return parentMeshSets.ptr[1] - parentMeshSets.ptr[0];
}
int moab::MeshSet::ordered ( ) const [inline]

Definition at line 71 of file MeshSet.hpp.

{ return mFlags & MESHSET_ORDERED; }
ErrorCode moab::MeshSet::remove_adjacencies ( EntityHandle  myhandle,
AEntityFactory adjacencies 
) [protected]

Remvoe explicit adjacencies from all contained entities to this (i.e. convert from tracking)

Definition at line 344 of file MeshSet.cpp.

{
  size_t count;
  const EntityHandle *const ptr = get_contents( count );
  const EntityHandle *const end = ptr + count;
  if (vector_based()) {
    for (const EntityHandle* i = ptr; i != end; ++i)
      adj->remove_adjacency( *i, my_handle );
  }
  else {
    assert( 0 == count % 2 );
    for (const EntityHandle* i = ptr; i != end; i += 2)
      for (EntityHandle h = i[0]; h <= i[1]; ++h)
        adj->remove_adjacency( h, my_handle );
  }
  return MB_SUCCESS;
}

remove a child from this meshset; returns true if child was removed, 0 if it was not a child of this meshset

Definition at line 249 of file MeshSet.cpp.

ErrorCode moab::MeshSet::remove_entities ( const Range entities,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

add these entities to this meshset

Definition at line 774 of file MeshSet.hpp.

{
  return remove_entity_ranges(  entities, my_handle, adjacencies );
}
ErrorCode moab::MeshSet::remove_entities ( const EntityHandle entities,
const int  num_entities,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

remove these entities from this meshset

Definition at line 783 of file MeshSet.hpp.

{
  return remove_entity_vector( entities, num_ents, my_handle, adjacencies );
}
ErrorCode moab::MeshSet::remove_entity_ranges ( const EntityHandle range_vect,
size_t  len,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Remove vector of handle range pairs from MeshSet

Definition at line 993 of file MeshSet.cpp.

{
  ErrorCode rval;
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  if (vector_based()) 
    rval = vector_remove_ranges( count, contentList, range_vect, len/2, my_h, 
                                 tracking() ? adj : 0 );
  else {
    typedef const std::pair<EntityHandle,EntityHandle>* pair_vect_t;
    pair_vect_t pair_vect = reinterpret_cast<pair_vect_t>(range_vect);
    rval = range_tool<pair_vect_t>::ranged_remove_entities( count, contentList, pair_vect, 
                                           pair_vect + len/2, my_h, tracking() ? adj : 0 );
  }
  mContentCount = count;
  return rval;
}
ErrorCode moab::MeshSet::remove_entity_ranges ( const Range range,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Remove Range of handles from MeshSet

Definition at line 1010 of file MeshSet.cpp.

{
  ErrorCode rval;
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  if (vector_based()) 
    rval = vector_remove_range( count, contentList, range, my_h, tracking() ? adj : 0 );
  else 
    rval = range_tool<Range::const_pair_iterator>::ranged_remove_entities( count, 
                         contentList, range.const_pair_begin(), range.const_pair_end(), 
                         my_h, tracking() ? adj : 0 );
  mContentCount = count;
  return rval;
}
ErrorCode moab::MeshSet::remove_entity_vector ( const EntityHandle vect,
size_t  len,
EntityHandle  my_h,
AEntityFactory adj 
) [protected]

Remove vector of handles from MeshSet

Definition at line 1117 of file MeshSet.cpp.

{
  MeshSet::Count count = static_cast<MeshSet::Count>(mContentCount);
  ErrorCode rval;
  if (vector_based())
    rval = vector_remove_vector( count, contentList, vect, len, my_h, tracking() ? adj : 0 );
  else {
    std::vector<EntityHandle> rangevect;
    convert_to_ranges( vect, len, rangevect );
    typedef const std::pair<EntityHandle,EntityHandle>* pair_vect_t;
    pair_vect_t pair_vect = reinterpret_cast<pair_vect_t>(&rangevect[0]);
    rval = range_tool<pair_vect_t>::ranged_remove_entities( count, contentList, pair_vect, 
                                pair_vect + rangevect.size()/2, my_h, tracking() ? adj : 0 );
  }
  mContentCount = count;
  return rval;
}

remove a parent from this meshset; returns true if parent was removed, 0 if it was not a parent of this meshset

Definition at line 243 of file MeshSet.cpp.

{ 
  int result = 0;
  mParentCount = remove_from_vector( (Count)mParentCount, parentMeshSets, parent, result );
  return result;
}
ErrorCode moab::MeshSet::replace_entities ( EntityHandle  my_handle,
const EntityHandle old_entities,
const EntityHandle new_entities,
size_t  num_entities,
AEntityFactory mAdjFact 
)

replace one entity with another in the set (contents and parent/child lists); returns whether it was replaced or not

Definition at line 1137 of file MeshSet.cpp.

{
  if (vector_based()) {
    ErrorCode result = MB_SUCCESS;
    size_t count;
    EntityHandle* vect = get_contents( count );
    EntityHandle* const vect_end = vect+count;
    for (size_t i = 0; i < num_ents; ++i) {
      EntityHandle* p = std::find( vect, vect_end, old_entities[i] );
      if (p == vect_end) {
        result = MB_ENTITY_NOT_FOUND;
      }
      else do {
        if (tracking()) {
          adjfact->remove_adjacency( *p, my_handle );
          adjfact->add_adjacency( new_entities[i], my_handle, false );
        }
        *p = new_entities[i];
        p = std::find( p+1, vect_end, old_entities[i] );
      } while (p != vect_end);
    }
    return result;
  }
  else {
    ErrorCode r1 = remove_entities( old_entities, num_ents, my_handle, adjfact );
    ErrorCode r2 = add_entities( new_entities, num_ents, my_handle, adjfact );
    return (MB_SUCCESS == r2) ? r1 : r2;
  }
}
int moab::MeshSet::set ( ) const [inline]

Definition at line 70 of file MeshSet.hpp.

{ return mFlags & MESHSET_SET; }
ErrorCode moab::MeshSet::set_flags ( unsigned  flags,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

Definition at line 332 of file MeshSet.hpp.

{
  if(ZERO != mContentCount) {
    ErrorCode result = convert(flg, my_handle, adjacencies);
    if(MB_SUCCESS != result) return result;
  }
  mFlags = (unsigned char)flg;
  return MB_SUCCESS;
}
ErrorCode moab::MeshSet::subtract ( const MeshSet meshset_2,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

subtract/intersect/unite meshset_2 from/with/into meshset_1; modifies meshset_1

Definition at line 732 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* const ptr = meshset_2->get_contents( count );
  if (meshset_2->vector_based()) 
    return remove_entity_vector( ptr, count, my_handle, adjacencies );
  else
    return remove_entity_ranges( ptr, count, my_handle, adjacencies );
}
int moab::MeshSet::tracking ( ) const [inline]

returns whether entities of meshsets know this meshset

Definition at line 69 of file MeshSet.hpp.

ErrorCode moab::MeshSet::unite ( const MeshSet meshset_2,
EntityHandle  my_handle,
AEntityFactory adjacencies 
) [inline]

Definition at line 744 of file MeshSet.hpp.

{
  size_t count;
  const EntityHandle* const ptr = meshset_2->get_contents( count );
  if (meshset_2->vector_based()) 
    return insert_entity_vector( ptr, count, my_handle, adjacencies );
  else
    return insert_entity_ranges( ptr, count, my_handle, adjacencies );
}
int moab::MeshSet::vector_based ( ) const [inline]

Definition at line 72 of file MeshSet.hpp.

{ return ordered(); }

Member Data Documentation

Definition at line 228 of file MeshSet.hpp.

Definition at line 228 of file MeshSet.hpp.

unsigned moab::MeshSet::mChildCount [private]

If less than MANY, the number of children stored inline in childMeshSets.hnd. If MANY, then childMeshSets.ptr contains array begin and end pointers for a dynamically allocated array of child handles.

Definition at line 222 of file MeshSet.hpp.

unsigned moab::MeshSet::mContentCount [private]

If less than MANY, the number of children stored inline in contentList.hnd. If MANY, then contentList.ptr contains array begin and end pointers for a dynamically allocated array..

Definition at line 226 of file MeshSet.hpp.

unsigned char moab::MeshSet::mFlags [private]

Meshset propery flags.

Definition at line 212 of file MeshSet.hpp.

unsigned moab::MeshSet::mParentCount [private]

If less than MANY, the number of parents stored inline in parentMeshSets.hnd. If MANY, then parentMeshSets.ptr contains array begin and end pointers for a dynamically allocated array of parent handles.

Definition at line 217 of file MeshSet.hpp.

Storage for data lists.

Definition at line 228 of file MeshSet.hpp.


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