42 #define PP_CAT_( a, b ) a##b
43 #define PP_CAT( a, b ) PP_CAT_( a, b )
45 #define RETURN( CODE ) \
48 *err = MBIMESHI->set_last_error( ( CODE ), "" ); \
52 #define ERROR( CODE, MSG ) \
55 *err = MBIMESHI->set_last_error( ( CODE ), ( MSG ) ); \
59 #define CHKERR( CODE, MSG ) \
62 if( iMesh_isError( ( CODE ) ) ) ERROR( ( CODE ), ( MSG ) ); \
65 #define CHKENUM( VAL, TYPE, ERR ) \
68 if( ( VAL ) < PP_CAT( TYPE, _MIN ) || ( VAL ) > PP_CAT( TYPE, _MAX ) ) \
69 ERROR( ( ERR ), "Invalid enumeration value" ); \
74 #define CHKTAGTYPE( TAG, TYPE ) \
78 iMesh_getTagType( instance, ( TAG ), &type, &result ); \
79 CHKERR( result, "Couldn't get tag data type" ); \
80 if( ( type == iBase_ENTITY_HANDLE && ( TYPE ) == iBase_ENTITY_SET_HANDLE ) || \
81 ( type == iBase_ENTITY_SET_HANDLE && ( TYPE ) == iBase_ENTITY_HANDLE ) ) \
83 if( type != ( TYPE ) ) ERROR( iBase_INVALID_TAG_HANDLE, "Invalid tag data type" ); \
86 #define CHKNONEMPTY() \
90 iMesh_getNumOfType( instance, 0, iBase_ALL_TYPES, &count, &result ); \
91 CHKERR( result, "Couldn't get number of entities" ); \
92 if( count == 0 ) ERROR( iBase_INVALID_ENTITY_HANDLE, "Invalid entity handle: mesh is empty" ); \
98 #define ALLOC_CHECK_ARRAY( array, this_size ) \
99 iMeshArrayManager array##_manager( instance, reinterpret_cast< void** >( array ), *( array##_allocated ), \
100 *( array##_size ), this_size, sizeof( **( array ) ), err ); \
101 if( iBase_SUCCESS != *err ) return
103 #define ALLOC_CHECK_TAG_ARRAY( array, this_size ) \
104 iMeshArrayManager array##_manager( instance, reinterpret_cast< void** >( array ), *( array##_allocated ), \
105 *( array##_size ), this_size, 1, err ); \
106 if( iBase_SUCCESS != *err ) return
108 #define KEEP_ARRAY( array ) array##_manager.keep_array()
112 #define ALLOC_CHECK_ARRAY_NOFAIL( array, this_size ) \
113 ALLOC_CHECK_ARRAY( array, this_size ); \
124 int& array_allocated_space,
131 if( !array_allocated_space || !*array_ptr )
133 *array_ptr = std::malloc( val_size * count );
134 array_allocated_space = array_size = count;
139 arrayPtr = array_ptr;
144 if( array_allocated_space < count )
156 std::free( *arrayPtr );
169 for(
size_t i = 1; i != n && *str1 && toupper( *str1 ) == toupper( *str2 ); ++i, ++str1, ++str2 )
171 return toupper( *str2 ) - toupper( *str1 );
177 const char* opt_begin = begin;
178 const char* opt_end = begin;
180 std::string filtered;
183 while( opt_end != end )
185 opt_end = std::find( opt_begin, end,
' ' );
187 if( opt_end - opt_begin >= 5 &&
compare_no_case( opt_begin,
"moab:", 5 ) == 0 )
189 if( !
first ) filtered.push_back(
';' );
191 filtered.append( opt_begin + 5, opt_end );
194 opt_begin = opt_end + 1;