Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::MeshSetSequence Class Reference

#include <MeshSetSequence.hpp>

+ Inheritance diagram for moab::MeshSetSequence:
+ Collaboration diagram for moab::MeshSetSequence:

Public Member Functions

 MeshSetSequence (EntityHandle start, EntityID count, const unsigned *flags, SequenceData *data)
 
 MeshSetSequence (EntityHandle start, EntityID count, unsigned flags, SequenceData *data)
 
 MeshSetSequence (EntityHandle start, EntityID count, const unsigned *flags, EntityID sequence_size)
 
 MeshSetSequence (EntityHandle start, EntityID count, unsigned flags, EntityID sequence_size)
 
virtual ~MeshSetSequence ()
 
EntitySequencesplit (EntityHandle here)
 Split this sequence into two consecutive sequences. More...
 
SequenceDatacreate_data_subset (EntityHandle, EntityHandle) const
 Create a new SequenceData that is a copy of a subset of the one referenced by this sequence. More...
 
ErrorCode pop_back (EntityID count)
 Erase entities in range: (end_handle()-count, end_handle()]. More...
 
ErrorCode pop_front (EntityID count)
 Erase entities in range: [start_handle(), start_handle()+count) More...
 
ErrorCode push_back (EntityID count, const unsigned *flags)
 
ErrorCode push_front (EntityID count, const unsigned *flags)
 
void get_const_memory_use (unsigned long &bytes_per_entity, unsigned long &size_of_sequence) const
 Get memory characteristcs that are the same for all entities. More...
 
unsigned long get_per_entity_memory_use (EntityHandle first, EntityHandle last) const
 Get portion of memory use that varies per entity. More...
 
MeshSetget_set (EntityHandle h)
 
const MeshSetget_set (EntityHandle h) const
 
ErrorCode get_entities (EntityHandle set, std::vector< EntityHandle > &entities) const
 
ErrorCode get_entities (SequenceManager const *seqman, EntityHandle set, Range &entities, bool recursive) const
 
ErrorCode get_dimension (SequenceManager const *seqman, EntityHandle set, int dim, std::vector< EntityHandle > &entities, bool recursive) const
 
ErrorCode get_dimension (SequenceManager const *seqman, EntityHandle set, int dim, Range &entities, bool recursive) const
 
ErrorCode get_type (SequenceManager const *seqman, EntityHandle set, EntityType type, std::vector< EntityHandle > &entities, bool recursive) const
 
ErrorCode get_type (SequenceManager const *seqman, EntityHandle set, EntityType type, Range &entities, bool recursive) const
 
ErrorCode num_entities (SequenceManager const *seqman, EntityHandle set, int &count, bool recursive) const
 
ErrorCode num_dimension (SequenceManager const *seqman, EntityHandle set, int dim, int &count, bool recursive) const
 
ErrorCode num_type (SequenceManager const *seqman, EntityHandle set, EntityType type, int &count, bool recursive) const
 
ErrorCode get_parents (SequenceManager const *seqman, EntityHandle of, std::vector< EntityHandle > &parents, int num_hops) const
 
ErrorCode get_children (SequenceManager const *seqman, EntityHandle of, std::vector< EntityHandle > &children, int num_hops) const
 
ErrorCode get_contained_sets (SequenceManager const *seqman, EntityHandle of, std::vector< EntityHandle > &contents, int num_hops) const
 
ErrorCode num_parents (SequenceManager const *seqman, EntityHandle of, int &number, int num_hops) const
 
ErrorCode num_children (SequenceManager const *seqman, EntityHandle of, int &number, int num_hops) const
 
ErrorCode num_contained_sets (SequenceManager const *seqman, EntityHandle of, int &number, int num_hops) const
 
- Public Member Functions inherited from moab::EntitySequence
 EntitySequence (EntityHandle start, EntityID count, SequenceData *dat)
 
virtual ~EntitySequence ()
 
EntityType type () const
 
EntityHandle start_handle () const
 
EntityHandle end_handle () const
 
SequenceDatadata () const
 
void data (SequenceData *ptr)
 
EntityID size () const
 
bool using_entire_data () const
 True if SequenceData has no holes and is used only by this EntitySequence. More...
 
virtual int values_per_entity () const
 Integer value used in finding appropriate SequenceData. More...
 
virtual ErrorCode merge (EntitySequence &other)
 Merge this sequence with another. More...
 

Private Types

enum  SearchType { PARENTS , CHILDREN , CONTAINED }
 
enum  { SET_SIZE = sizeof( MeshSet ) }
 

Private Member Functions

 MeshSetSequence (MeshSetSequence &split_from, EntityHandle split_at)
 
void initialize (const unsigned *set_flags)
 
ErrorCode get_parent_child_meshsets (EntityHandle meshset, SequenceManager const *set_sequences, std::vector< EntityHandle > &results, int num_hops, SearchType link_type) const
 
const unsigned char * array () const
 
unsigned char * array ()
 
void allocate_set (unsigned flags, EntityID index)
 
void deallocate_set (EntityID index)
 

Static Private Member Functions

static ErrorCode recursive_get_sets (EntityHandle start_set, SequenceManager const *set_sequences, std::vector< const MeshSet * > *sets_out=0, Range *set_handles_out=0, std::vector< EntityHandle > *set_handle_vect_out=0)
 
static ErrorCode recursive_get_sets (EntityHandle start_set, SequenceManager *set_sequences, std::vector< MeshSet * > &sets_out)
 

Additional Inherited Members

- Protected Member Functions inherited from moab::EntitySequence
 EntitySequence (EntityHandle h)
 
 EntitySequence (EntitySequence &split_from, EntityHandle here)
 
SequenceDatacreate_data_subset (EntityHandle start_handle, EntityHandle end_handle, int num_sequence_arrays, unsigned const *bytes_per_element) const
 
ErrorCode prepend_entities (EntityID count)
 
ErrorCode append_entities (EntityID count)
 

Detailed Description

Definition at line 33 of file MeshSetSequence.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
SET_SIZE 

Definition at line 142 of file MeshSetSequence.hpp.

143  {
144  SET_SIZE = sizeof( MeshSet )
145  };

◆ SearchType

Enumerator
PARENTS 
CHILDREN 
CONTAINED 

Definition at line 116 of file MeshSetSequence.hpp.

117  {
118  PARENTS,
119  CHILDREN,
120  CONTAINED
121  };

Constructor & Destructor Documentation

◆ MeshSetSequence() [1/5]

moab::MeshSetSequence::MeshSetSequence ( EntityHandle  start,
EntityID  count,
const unsigned *  flags,
SequenceData data 
)

Definition at line 27 of file MeshSetSequence.cpp.

28  : EntitySequence( start, count, dat )
29 {
30  initialize( flags );
31 }

References initialize().

Referenced by split().

◆ MeshSetSequence() [2/5]

moab::MeshSetSequence::MeshSetSequence ( EntityHandle  start,
EntityID  count,
unsigned  flags,
SequenceData data 
)

Definition at line 33 of file MeshSetSequence.cpp.

34  : EntitySequence( start, count, dat )
35 {
36  std::vector< unsigned > vect( count, flags );
37  initialize( &vect[0] );
38 }

References initialize().

◆ MeshSetSequence() [3/5]

moab::MeshSetSequence::MeshSetSequence ( EntityHandle  start,
EntityID  count,
const unsigned *  flags,
EntityID  sequence_size 
)

Definition at line 40 of file MeshSetSequence.cpp.

41  : EntitySequence( start, count, new SequenceData( 1, start, start + data_size - 1 ) )
42 {
43  initialize( flags );
44 }

References initialize().

◆ MeshSetSequence() [4/5]

moab::MeshSetSequence::MeshSetSequence ( EntityHandle  start,
EntityID  count,
unsigned  flags,
EntityID  sequence_size 
)

Definition at line 46 of file MeshSetSequence.cpp.

47  : EntitySequence( start, count, new SequenceData( 1, start, start + data_size - 1 ) )
48 {
49  std::vector< unsigned > vect( count, flags );
50  initialize( &vect[0] );
51 }

References initialize().

◆ ~MeshSetSequence()

moab::MeshSetSequence::~MeshSetSequence ( )
virtual

Definition at line 62 of file MeshSetSequence.cpp.

63 {
64  EntityID offset = start_handle() - data()->start_handle();
65  EntityID count = size();
66  for( EntityID i = 0; i < count; ++i )
67  deallocate_set( i + offset );
68 }

References moab::EntitySequence::data(), deallocate_set(), moab::EntitySequence::size(), moab::EntitySequence::start_handle(), and moab::SequenceData::start_handle().

◆ MeshSetSequence() [5/5]

moab::MeshSetSequence::MeshSetSequence ( MeshSetSequence split_from,
EntityHandle  split_at 
)
inlineprivate

Definition at line 123 of file MeshSetSequence.hpp.

123 : EntitySequence( split_from, split_at ) {}

Member Function Documentation

◆ allocate_set()

void moab::MeshSetSequence::allocate_set ( unsigned  flags,
EntityID  index 
)
inlineprivate

Definition at line 157 of file MeshSetSequence.hpp.

158  {
159  unsigned char* const ptr = array() + index * SET_SIZE;
160  new( ptr ) MeshSet( flags );
161  }

References array(), and SET_SIZE.

Referenced by initialize(), push_back(), and push_front().

◆ array() [1/2]

unsigned char* moab::MeshSetSequence::array ( )
inlineprivate

Definition at line 152 of file MeshSetSequence.hpp.

153  {
154  return reinterpret_cast< unsigned char* >( data()->get_sequence_data( 0 ) );
155  }

References moab::EntitySequence::data(), and moab::SequenceData::get_sequence_data().

◆ array() [2/2]

const unsigned char* moab::MeshSetSequence::array ( ) const
inlineprivate

Definition at line 147 of file MeshSetSequence.hpp.

148  {
149  return reinterpret_cast< const unsigned char* >( data()->get_sequence_data( 0 ) );
150  }

References moab::EntitySequence::data(), and moab::SequenceData::get_sequence_data().

Referenced by allocate_set(), deallocate_set(), and get_set().

◆ create_data_subset()

SequenceData* moab::MeshSetSequence::create_data_subset ( EntityHandle  start_handle,
EntityHandle  end_handle 
) const
inlinevirtual

Create a new SequenceData that is a copy of a subset of the one referenced by this sequence.

Create a new SequenceData that is a copy of a subset of the SequenceData referenced by this EntitySequence. Do not make any changes to this EntitySequence or the current SequenceData.

Implements moab::EntitySequence.

Definition at line 48 of file MeshSetSequence.hpp.

49  {
50  return 0;
51  }

◆ deallocate_set()

void moab::MeshSetSequence::deallocate_set ( EntityID  index)
inlineprivate

Definition at line 163 of file MeshSetSequence.hpp.

164  {
165  MeshSet* set = reinterpret_cast< MeshSet* >( array() + SET_SIZE * index );
166  set->~MeshSet();
167  }

References array(), SET_SIZE, and moab::MeshSet::~MeshSet().

Referenced by pop_back(), pop_front(), and ~MeshSetSequence().

◆ get_children()

ErrorCode moab::MeshSetSequence::get_children ( SequenceManager const *  seqman,
EntityHandle  of,
std::vector< EntityHandle > &  children,
int  num_hops 
) const

Definition at line 538 of file MeshSetSequence.cpp.

542 {
543  if( num_hops == 1 )
544  {
545  int count;
546  const EntityHandle* tmp_array = get_set( handle )->get_children( count );
547  if( children.empty() )
548  {
549  children.resize( count );
550  std::copy( tmp_array, tmp_array + count, children.begin() );
551  return MB_SUCCESS;
552  }
553  else if( !count )
554  {
555  return MB_SUCCESS;
556  }
557  }
558 
559  if( num_hops > 0 )
560  return get_parent_child_meshsets( handle, seqman, children, num_hops, CHILDREN );
561  else
562  return get_parent_child_meshsets( handle, seqman, children, -1, CHILDREN );
563 }

References CHILDREN, children, moab::MeshSet::get_children(), get_parent_child_meshsets(), get_set(), and MB_SUCCESS.

Referenced by moab::Core::get_child_meshsets(), and num_children().

◆ get_const_memory_use()

void moab::MeshSetSequence::get_const_memory_use ( unsigned long &  bytes_per_entity,
unsigned long &  size_of_sequence 
) const
virtual

Get memory characteristcs that are the same for all entities.

Get charactersitic constant memory use for all entities in sequence.

Parameters
bytes_per_entityThe total bytes consumed for each entity in the underlying SequenceData. It is assumed that the same amount of memory is consumed for unused portions of the SequenceData.
size_of_sequenceThe size of the leaf subclass of this class

Implements moab::EntitySequence.

Definition at line 115 of file MeshSetSequence.cpp.

116 {
117  per_ent = SET_SIZE;
118  seq_size = sizeof( *this );
119 }

References SET_SIZE.

◆ get_contained_sets()

ErrorCode moab::MeshSetSequence::get_contained_sets ( SequenceManager const *  seqman,
EntityHandle  of,
std::vector< EntityHandle > &  contents,
int  num_hops 
) const

Definition at line 565 of file MeshSetSequence.cpp.

569 {
570  if( num_hops == 1 && contained.empty() )
571  {
572  return get_set( handle )->get_entities_by_type( MBENTITYSET, contained );
573  }
574 
575  if( num_hops > 0 )
576  return get_parent_child_meshsets( handle, seqman, contained, num_hops, CONTAINED );
577  else
578  return get_parent_child_meshsets( handle, seqman, contained, -1, CONTAINED );
579 }

References CONTAINED, moab::MeshSet::get_entities_by_type(), get_parent_child_meshsets(), get_set(), and MBENTITYSET.

Referenced by moab::Core::get_contained_meshsets(), and num_contained_sets().

◆ get_dimension() [1/2]

ErrorCode moab::MeshSetSequence::get_dimension ( SequenceManager const *  seqman,
EntityHandle  set,
int  dim,
Range entities,
bool  recursive 
) const

Definition at line 179 of file MeshSetSequence.cpp.

184 {
185  if( !recursive )
186  {
187  get_set( handle )->get_entities_by_dimension( dimension, entities );
188  return MB_SUCCESS;
189  }
190  else
191  {
192  std::vector< const MeshSet* > list;
193  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
194  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
195  ( *i )->get_entities_by_dimension( dimension, entities );
196  return rval;
197  }
198 }

References entities, ErrorCode, moab::MeshSet::get_entities_by_dimension(), get_set(), MB_SUCCESS, and recursive_get_sets().

◆ get_dimension() [2/2]

ErrorCode moab::MeshSetSequence::get_dimension ( SequenceManager const *  seqman,
EntityHandle  set,
int  dim,
std::vector< EntityHandle > &  entities,
bool  recursive 
) const

Definition at line 158 of file MeshSetSequence.cpp.

163 {
164  if( !recursive )
165  {
166  get_set( handle )->get_entities_by_dimension( dimension, entities );
167  return MB_SUCCESS;
168  }
169  else
170  {
171  std::vector< const MeshSet* > list;
172  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
173  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
174  ( *i )->get_entities_by_dimension( dimension, entities );
175  return rval;
176  }
177 }

References entities, ErrorCode, moab::MeshSet::get_entities_by_dimension(), get_set(), MB_SUCCESS, and recursive_get_sets().

Referenced by moab::Core::get_entities_by_dimension(), and num_dimension().

◆ get_entities() [1/2]

ErrorCode moab::MeshSetSequence::get_entities ( EntityHandle  set,
std::vector< EntityHandle > &  entities 
) const

Definition at line 152 of file MeshSetSequence.cpp.

153 {
154  get_set( handle )->get_entities( entities );
155  return MB_SUCCESS;
156 }

References entities, moab::MeshSet::get_entities(), get_set(), and MB_SUCCESS.

Referenced by moab::Core::get_entities_by_handle(), get_type(), and num_entities().

◆ get_entities() [2/2]

ErrorCode moab::MeshSetSequence::get_entities ( SequenceManager const *  seqman,
EntityHandle  set,
Range entities,
bool  recursive 
) const

Definition at line 132 of file MeshSetSequence.cpp.

136 {
137  if( !recursive )
138  {
139  get_set( handle )->get_entities( entities );
140  return MB_SUCCESS;
141  }
142  else
143  {
144  std::vector< const MeshSet* > list;
145  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
146  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
147  ( *i )->get_non_set_entities( entities );
148  return rval;
149  }
150 }

References entities, ErrorCode, moab::MeshSet::get_entities(), get_set(), MB_SUCCESS, and recursive_get_sets().

◆ get_parent_child_meshsets()

ErrorCode moab::MeshSetSequence::get_parent_child_meshsets ( EntityHandle  meshset,
SequenceManager const *  set_sequences,
std::vector< EntityHandle > &  results,
int  num_hops,
SearchType  link_type 
) const
private

Definition at line 413 of file MeshSetSequence.cpp.

418 {
419  ErrorCode result = MB_SUCCESS;
420  std::vector< EntityHandle >::iterator i;
421  const EntityHandle *tmp_array = 0, *end;
422  EntityHandle s, e;
423  int count = 0;
424  size_t n;
425 
426  // Skip any meshsets already in input vector (yes, don't
427  // get their children either even if num_hops would indicate
428  // that we should.) There is an exception to that if the
429  // input meshset is in the list, which is handled by the order
430  // of checks in the main loop below.
431  std::set< EntityHandle > visited;
432  for( i = results.begin(); i != results.end(); ++i )
433  visited.insert( *i );
434 
435  // Two lists for breadth-first search
436  std::vector< EntityHandle > lists[2];
437  int index = 0; // which list to read from (write to lists[1-index])
438  lists[index].push_back( meshset ); // begin with input set
439  // loop for num_hops (or until no more sets)
440  for( ; num_hops && !lists[index].empty(); --num_hops )
441  {
442  // for each set at the current num_hops
443  for( i = lists[index].begin(); i != lists[index].end(); ++i )
444  {
445  // get meshset from handle
446  const EntitySequence* seq;
447  ErrorCode rval = seq_sets->find( *i, seq );
448  if( MB_SUCCESS != rval ) return rval;
449  const MeshSet* ms_ptr = reinterpret_cast< const MeshSetSequence* >( seq )->get_set( *i );
450 
451  switch( link_type )
452  {
453  case CONTAINED:
454  tmp_array = ms_ptr->get_contents( n );
455  end = tmp_array + n;
456  if( ms_ptr->vector_based() )
457  {
458  for( ; tmp_array != end; ++tmp_array )
459  if( MBENTITYSET == TYPE_FROM_HANDLE( *tmp_array ) && visited.insert( *tmp_array ).second )
460  lists[1 - index].push_back( *tmp_array );
461  }
462  else
463  {
464  assert( n % 2 == 0 );
465  tmp_array = std::lower_bound( tmp_array, tmp_array + n, FIRST_HANDLE( MBENTITYSET ) );
466  // only part of first block is of type
467  if( ( end - tmp_array ) % 2 )
468  {
469  ++tmp_array;
470  s = FIRST_HANDLE( MBENTITYSET );
471  e = *tmp_array;
472  for( ; s <= e; ++s )
473  if( visited.insert( s ).second ) lists[1 - index].push_back( s );
474  }
475  while( tmp_array < end )
476  {
477  s = *tmp_array++;
478  e = *tmp_array++;
479  for( ; s <= e; ++s )
480  if( visited.insert( s ).second ) lists[1 - index].push_back( s );
481  }
482  }
483  continue;
484  case PARENTS:
485  tmp_array = ms_ptr->get_parents( count );
486  break;
487  case CHILDREN:
488  tmp_array = ms_ptr->get_children( count );
489  break;
490  }
491 
492  // copy any parents/children we haven't visited yet into list
493  for( end = tmp_array + count; tmp_array != end; ++tmp_array )
494  if( visited.insert( *tmp_array ).second ) lists[1 - index].push_back( *tmp_array );
495  }
496 
497  // iterate
498  lists[index].clear();
499  index = 1 - index;
500  // append each level of sets to the output list.
501  // note: to make a more useful search (e.g. get entities 3 hops away,
502  // rather than entities up to and including 3 hops) move this outside
503  // the loop, but then need to handle the get all (num_hops < 0) case
504  // specially.
505  std::copy( lists[index].begin(), lists[index].end(), std::back_inserter( results ) );
506  }
507 
508  return result;
509 }

References CHILDREN, CONTAINED, ErrorCode, moab::SequenceManager::find(), moab::FIRST_HANDLE(), moab::MeshSet::get_children(), moab::MeshSet::get_contents(), moab::MeshSet::get_parents(), get_set(), MB_SUCCESS, MBENTITYSET, PARENTS, moab::TYPE_FROM_HANDLE(), and moab::MeshSet::vector_based().

Referenced by get_children(), get_contained_sets(), and get_parents().

◆ get_parents()

ErrorCode moab::MeshSetSequence::get_parents ( SequenceManager const *  seqman,
EntityHandle  of,
std::vector< EntityHandle > &  parents,
int  num_hops 
) const

Definition at line 511 of file MeshSetSequence.cpp.

515 {
516  if( num_hops == 1 )
517  {
518  int count;
519  const EntityHandle* tmp_array = get_set( handle )->get_parents( count );
520  if( parents.empty() )
521  {
522  parents.resize( count );
523  std::copy( tmp_array, tmp_array + count, parents.begin() );
524  return MB_SUCCESS;
525  }
526  else if( !count )
527  {
528  return MB_SUCCESS;
529  }
530  }
531 
532  if( num_hops > 0 )
533  return get_parent_child_meshsets( handle, seqman, parents, num_hops, PARENTS );
534  else
535  return get_parent_child_meshsets( handle, seqman, parents, -1, PARENTS );
536 }

References get_parent_child_meshsets(), moab::MeshSet::get_parents(), get_set(), MB_SUCCESS, and PARENTS.

Referenced by moab::Core::get_parent_meshsets(), and num_parents().

◆ get_per_entity_memory_use()

unsigned long moab::MeshSetSequence::get_per_entity_memory_use ( EntityHandle  first,
EntityHandle  last 
) const
virtual

Get portion of memory use that varies per entity.

Returns
Any per-entity memory use not accounted for in the results of get_const_memory_use.

Reimplemented from moab::EntitySequence.

Definition at line 121 of file MeshSetSequence.cpp.

122 {
123  if( first < start_handle() ) first = start_handle();
124  if( last > end_handle() ) last = end_handle();
125 
126  unsigned long sum = 0;
127  for( EntityHandle h = first; h <= last; ++h )
128  sum += get_set( h )->get_memory_use();
129  return sum;
130 }

References moab::EntitySequence::end_handle(), moab::GeomUtil::first(), moab::MeshSet::get_memory_use(), get_set(), moab::EntitySequence::start_handle(), and moab::sum().

◆ get_set() [1/2]

◆ get_set() [2/2]

const MeshSet * moab::MeshSetSequence::get_set ( EntityHandle  h) const
inline

Definition at line 174 of file MeshSetSequence.hpp.

175 {
176  return reinterpret_cast< const MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
177 }

References array(), moab::EntitySequence::data(), SET_SIZE, and moab::SequenceData::start_handle().

◆ get_type() [1/2]

ErrorCode moab::MeshSetSequence::get_type ( SequenceManager const *  seqman,
EntityHandle  set,
EntityType  type,
Range entities,
bool  recursive 
) const

Definition at line 239 of file MeshSetSequence.cpp.

244 {
245  if( !recursive )
246  {
247  get_set( handle )->get_entities_by_type( tp, entities );
248  return MB_SUCCESS;
249  }
250  else if( tp == MBENTITYSET )
251  {
252  return recursive_get_sets( handle, seqman, 0, &entities );
253  }
254  else if( tp == MBMAXTYPE )
255  {
256  std::vector< const MeshSet* > list;
257  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
258  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
259  ( *i )->get_non_set_entities( entities );
260  return rval;
261  }
262  else
263  {
264  std::vector< const MeshSet* > list;
265  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
266  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
267  ( *i )->get_entities_by_type( tp, entities );
268  return rval;
269  }
270 }

References entities, ErrorCode, moab::MeshSet::get_entities_by_type(), get_set(), MB_SUCCESS, MBENTITYSET, MBMAXTYPE, and recursive_get_sets().

◆ get_type() [2/2]

ErrorCode moab::MeshSetSequence::get_type ( SequenceManager const *  seqman,
EntityHandle  set,
EntityType  type,
std::vector< EntityHandle > &  entities,
bool  recursive 
) const

Definition at line 200 of file MeshSetSequence.cpp.

205 {
206  if( !recursive )
207  {
208  get_set( handle )->get_entities_by_type( tp, entities );
209  return MB_SUCCESS;
210  }
211  else if( tp == MBENTITYSET )
212  {
213  return recursive_get_sets( handle, seqman, 0, 0, &entities );
214  }
215  else if( tp == MBMAXTYPE )
216  {
217  Range tmp;
218  ErrorCode rval = get_entities( seqman, handle, tmp, recursive );
219  if( MB_SUCCESS == rval )
220  {
221 #ifdef MOAB_NO_VECTOR_TEMPLATE_INSERT
222  std::copy( tmp.begin(), tmp.end(), std::back_inserter( entities ) );
223 #else
224  entities.insert( entities.end(), tmp.begin(), tmp.end() );
225 #endif
226  }
227  return rval;
228  }
229  else
230  {
231  std::vector< const MeshSet* > list;
232  ErrorCode rval = recursive_get_sets( handle, seqman, &list );
233  for( std::vector< const MeshSet* >::iterator i = list.begin(); i != list.end(); ++i )
234  ( *i )->get_entities_by_type( tp, entities );
235  return rval;
236  }
237 }

References moab::Range::begin(), moab::Range::end(), entities, ErrorCode, get_entities(), moab::MeshSet::get_entities_by_type(), get_set(), MB_SUCCESS, MBENTITYSET, MBMAXTYPE, and recursive_get_sets().

Referenced by moab::Core::get_entities_by_type(), and num_type().

◆ initialize()

void moab::MeshSetSequence::initialize ( const unsigned *  set_flags)
private

Definition at line 53 of file MeshSetSequence.cpp.

54 {
55  if( !data()->get_sequence_data( 0 ) ) data()->create_sequence_data( 0, SET_SIZE );
56 
57  EntityID offset = start_handle() - data()->start_handle();
58  for( EntityID i = 0; i < size(); ++i )
59  allocate_set( flags[i], i + offset );
60 }

References allocate_set(), moab::SequenceData::create_sequence_data(), moab::EntitySequence::data(), SET_SIZE, moab::EntitySequence::size(), moab::EntitySequence::start_handle(), and moab::SequenceData::start_handle().

Referenced by MeshSetSequence().

◆ num_children()

ErrorCode moab::MeshSetSequence::num_children ( SequenceManager const *  seqman,
EntityHandle  of,
int &  number,
int  num_hops 
) const

Definition at line 598 of file MeshSetSequence.cpp.

602 {
603  if( num_hops == 1 )
604  {
605  number = get_set( handle )->num_children();
606  return MB_SUCCESS;
607  }
608 
609  std::vector< EntityHandle > children;
610  ErrorCode result = get_children( seqman, handle, children, num_hops );
611  number = children.size();
612  return result;
613 }

References children, ErrorCode, get_children(), get_set(), MB_SUCCESS, and moab::MeshSet::num_children().

Referenced by moab::Core::num_child_meshsets().

◆ num_contained_sets()

ErrorCode moab::MeshSetSequence::num_contained_sets ( SequenceManager const *  seqman,
EntityHandle  of,
int &  number,
int  num_hops 
) const

Definition at line 615 of file MeshSetSequence.cpp.

619 {
620  if( num_hops == 1 )
621  {
622  number = get_set( handle )->num_entities_by_type( MBENTITYSET );
623  return MB_SUCCESS;
624  }
625 
626  std::vector< EntityHandle > contained;
627  ErrorCode result = get_contained_sets( seqman, handle, contained, num_hops );
628  number = contained.size();
629  return result;
630 }

References ErrorCode, get_contained_sets(), get_set(), MB_SUCCESS, MBENTITYSET, and moab::MeshSet::num_entities_by_type().

Referenced by moab::Core::num_contained_meshsets().

◆ num_dimension()

ErrorCode moab::MeshSetSequence::num_dimension ( SequenceManager const *  seqman,
EntityHandle  set,
int  dim,
int &  count,
bool  recursive 
) const

Definition at line 291 of file MeshSetSequence.cpp.

296 {
297  if( !recursive )
298  {
299  number = get_set( handle )->num_entities_by_dimension( dimension );
300  return MB_SUCCESS;
301  }
302  else
303  {
304  Range range;
305  ErrorCode result = get_dimension( seqman, handle, dimension, range, true );
306  number = range.size();
307  return result;
308  }
309 }

References ErrorCode, get_dimension(), get_set(), MB_SUCCESS, moab::MeshSet::num_entities_by_dimension(), and moab::Range::size().

Referenced by moab::Core::get_number_entities_by_dimension().

◆ num_entities()

ErrorCode moab::MeshSetSequence::num_entities ( SequenceManager const *  seqman,
EntityHandle  set,
int &  count,
bool  recursive 
) const

Definition at line 272 of file MeshSetSequence.cpp.

276 {
277  if( !recursive )
278  {
279  number = get_set( handle )->num_entities();
280  return MB_SUCCESS;
281  }
282  else
283  {
284  Range range;
285  ErrorCode result = get_entities( seqman, handle, range, true );
286  number = range.size();
287  return result;
288  }
289 }

References ErrorCode, get_entities(), get_set(), MB_SUCCESS, moab::MeshSet::num_entities(), and moab::Range::size().

Referenced by moab::Core::get_number_entities_by_handle().

◆ num_parents()

ErrorCode moab::MeshSetSequence::num_parents ( SequenceManager const *  seqman,
EntityHandle  of,
int &  number,
int  num_hops 
) const

Definition at line 581 of file MeshSetSequence.cpp.

585 {
586  if( num_hops == 1 )
587  {
588  number = get_set( handle )->num_parents();
589  return MB_SUCCESS;
590  }
591 
592  std::vector< EntityHandle > parents;
593  ErrorCode result = get_parents( seqman, handle, parents, num_hops );
594  number = parents.size();
595  return result;
596 }

References ErrorCode, get_parents(), get_set(), MB_SUCCESS, and moab::MeshSet::num_parents().

Referenced by moab::Core::num_parent_meshsets().

◆ num_type()

ErrorCode moab::MeshSetSequence::num_type ( SequenceManager const *  seqman,
EntityHandle  set,
EntityType  type,
int &  count,
bool  recursive 
) const

Definition at line 311 of file MeshSetSequence.cpp.

316 {
317  if( !recursive )
318  {
319  number = get_set( handle )->num_entities_by_type( tp );
320  return MB_SUCCESS;
321  }
322  else
323  {
324  Range range;
325  ErrorCode result = get_type( seqman, handle, tp, range, true );
326  number = range.size();
327  return result;
328  }
329 }

References ErrorCode, get_set(), get_type(), MB_SUCCESS, moab::MeshSet::num_entities_by_type(), and moab::Range::size().

Referenced by moab::Core::get_number_entities_by_type().

◆ pop_back()

ErrorCode moab::MeshSetSequence::pop_back ( EntityID  count)
virtual

Erase entities in range: (end_handle()-count, end_handle()].

Reimplemented from moab::EntitySequence.

Definition at line 75 of file MeshSetSequence.cpp.

76 {
77  EntityID offset = end_handle() + 1 - count - data()->start_handle();
78  ErrorCode rval = EntitySequence::pop_back( count );
79  if( MB_SUCCESS == rval )
80  for( EntityID i = 0; i < count; ++i )
81  deallocate_set( i + offset );
82  return rval;
83 }

References moab::EntitySequence::data(), deallocate_set(), moab::EntitySequence::end_handle(), ErrorCode, MB_SUCCESS, moab::EntitySequence::pop_back(), and moab::SequenceData::start_handle().

Referenced by moab::SequenceManager::allocate_mesh_set().

◆ pop_front()

ErrorCode moab::MeshSetSequence::pop_front ( EntityID  count)
virtual

Erase entities in range: [start_handle(), start_handle()+count)

Reimplemented from moab::EntitySequence.

Definition at line 85 of file MeshSetSequence.cpp.

86 {
87  EntityID offset = start_handle() - data()->start_handle();
88  ErrorCode rval = EntitySequence::pop_front( count );
89  if( MB_SUCCESS == rval )
90  for( EntityID i = 0; i < count; ++i )
91  deallocate_set( i + offset );
92  return rval;
93 }

References moab::EntitySequence::data(), deallocate_set(), ErrorCode, MB_SUCCESS, moab::EntitySequence::pop_front(), moab::EntitySequence::start_handle(), and moab::SequenceData::start_handle().

Referenced by moab::SequenceManager::allocate_mesh_set().

◆ push_back()

ErrorCode moab::MeshSetSequence::push_back ( EntityID  count,
const unsigned *  flags 
)

Definition at line 95 of file MeshSetSequence.cpp.

96 {
97  EntityID offset = end_handle() + 1 - data()->start_handle();
99  if( MB_SUCCESS == rval )
100  for( EntityID i = 0; i < count; ++i )
101  allocate_set( flags[i], i + offset );
102  return rval;
103 }

References allocate_set(), moab::EntitySequence::append_entities(), moab::EntitySequence::data(), moab::EntitySequence::end_handle(), ErrorCode, MB_SUCCESS, and moab::SequenceData::start_handle().

Referenced by moab::SequenceManager::allocate_mesh_set(), and moab::SequenceManager::create_mesh_set().

◆ push_front()

ErrorCode moab::MeshSetSequence::push_front ( EntityID  count,
const unsigned *  flags 
)

Definition at line 105 of file MeshSetSequence.cpp.

106 {
107  EntityID offset = start_handle() - data()->start_handle() - count;
109  if( MB_SUCCESS == rval )
110  for( EntityID i = 0; i < count; ++i )
111  allocate_set( flags[i], i + offset );
112  return rval;
113 }

References allocate_set(), moab::EntitySequence::data(), ErrorCode, MB_SUCCESS, moab::EntitySequence::prepend_entities(), moab::EntitySequence::start_handle(), and moab::SequenceData::start_handle().

Referenced by moab::SequenceManager::allocate_mesh_set(), and moab::SequenceManager::create_mesh_set().

◆ recursive_get_sets() [1/2]

ErrorCode moab::MeshSetSequence::recursive_get_sets ( EntityHandle  start_set,
SequenceManager set_sequences,
std::vector< MeshSet * > &  sets_out 
)
staticprivate

Definition at line 383 of file MeshSetSequence.cpp.

386 {
387  std::set< EntityHandle > visited;
388  std::vector< EntityHandle > stack;
389  stack.push_back( start_set );
390  while( !stack.empty() )
391  {
392  EntityHandle handle = stack.back();
393  stack.pop_back();
394 
395  if( !visited.insert( handle ).second ) continue;
396 
397  EntitySequence* seq;
398  ErrorCode rval = seq_sets->find( handle, seq );
399  if( MB_SUCCESS != rval ) return rval;
400 
401  MeshSetSequence* mseq = reinterpret_cast< MeshSetSequence* >( seq );
402  MeshSet* ms_ptr = mseq->get_set( handle );
403  sets.push_back( ms_ptr );
404 
405  Range tmp_range;
406  ms_ptr->get_entities_by_type( MBENTITYSET, tmp_range );
407  std::copy( tmp_range.begin(), tmp_range.end(), std::back_inserter( stack ) );
408  }
409 
410  return MB_SUCCESS;
411 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, moab::SequenceManager::find(), moab::MeshSet::get_entities_by_type(), get_set(), MB_SUCCESS, and MBENTITYSET.

◆ recursive_get_sets() [2/2]

ErrorCode moab::MeshSetSequence::recursive_get_sets ( EntityHandle  start_set,
SequenceManager const *  set_sequences,
std::vector< const MeshSet * > *  sets_out = 0,
Range set_handles_out = 0,
std::vector< EntityHandle > *  set_handle_vect_out = 0 
)
staticprivate

Definition at line 331 of file MeshSetSequence.cpp.

336 {
337  std::set< EntityHandle > visited;
338  std::vector< EntityHandle > stack;
339  stack.push_back( start_set );
340  bool remove_start_set = true;
341  while( !stack.empty() )
342  {
343  EntityHandle handle = stack.back();
344  stack.pop_back();
345 
346  if( !visited.insert( handle ).second )
347  {
348  if( handle == start_set ) remove_start_set = false;
349  continue;
350  }
351 
352  const EntitySequence* seq;
353  ErrorCode rval = seq_sets->find( handle, seq );
354  if( MB_SUCCESS != rval ) return rval;
355 
356  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
357  const MeshSet* ms_ptr = mseq->get_set( handle );
358  if( sets ) sets->push_back( ms_ptr );
359 
360  Range tmp_range;
361  ms_ptr->get_entities_by_type( MBENTITYSET, tmp_range );
362  std::copy( tmp_range.begin(), tmp_range.end(), std::back_inserter( stack ) );
363  }
364 
365  if( set_handles )
366  {
367  if( remove_start_set ) visited.erase( start_set );
368  Range::iterator hint = set_handles->begin();
369  std::set< EntityHandle >::iterator it;
370  for( it = visited.begin(); it != visited.end(); ++it )
371  hint = set_handles->insert( hint, *it, *it );
372  }
373 
374  if( set_vector )
375  {
376  if( remove_start_set ) visited.erase( start_set );
377  std::copy( visited.begin(), visited.end(), std::back_inserter( *set_vector ) );
378  }
379 
380  return MB_SUCCESS;
381 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, moab::SequenceManager::find(), moab::MeshSet::get_entities_by_type(), get_set(), moab::Range::insert(), MB_SUCCESS, and MBENTITYSET.

Referenced by get_dimension(), get_entities(), and get_type().

◆ split()

EntitySequence * moab::MeshSetSequence::split ( EntityHandle  here)
virtual

Split this sequence into two consecutive sequences.

Split this sequence into two sequences.

Parameters
hereNew sequences should be [start_handle(),here) & [here,end_handle()]
Returns
New sequence containing [here,end_handle()]

Implements moab::EntitySequence.

Definition at line 70 of file MeshSetSequence.cpp.

71 {
72  return new MeshSetSequence( *this, here );
73 }

References MeshSetSequence().


The documentation for this class was generated from the following files: