![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #include "BitPage.hpp"
00002 #include "moab/Range.hpp"
00003 #include
00004 #include
00005
00006 namespace moab
00007 {
00008
00009 void BitPage::search( unsigned char value, int offset, int count, int per_ent, Range& results, EntityHandle start )
00010 const
00011 {
00012 const int end = offset + count;
00013 Range::iterator hint = results.begin();
00014 while( offset != end )
00015 {
00016 if( get_bits( offset, per_ent ) == value ) hint = results.insert( hint, start );
00017 ++offset;
00018 ++start;
00019 }
00020 }
00021
00022 BitPage::BitPage( int per_ent, unsigned char init_val )
00023 {
00024 unsigned char mask = (unsigned char)( 1 << per_ent ) - 1; // 2^per_ent - 1
00025 init_val &= (unsigned char)mask;
00026 switch( per_ent )
00027 {
00028 default:
00029 assert( false );
00030 abort();
00031 break; // must be power of two
00032
00033 // Note: fall through such that all bits in init_val are set, but with odd structure to avoid
00034 // fall-through warnings
00035 case 1:
00036 init_val |= (unsigned char)( init_val << 1 );
00037 // fall through
00038 case 2:
00039 init_val |= (unsigned char)( init_val << 2 );
00040 // fall through
00041 case 4:
00042 init_val |= (unsigned char)( init_val << 4 );
00043 // fall through
00044 case 8:;
00045 }
00046 memset( byteArray, init_val, BitTag::PageSize );
00047 }
00048
00049 } // namespace moab