Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #include "DamselUtil.hpp" 00002 #include "moab/Range.hpp" 00003 00004 #include "damsel.h" 00005 00006 namespace moab 00007 { 00008 00009 damsel_entity_type DamselUtil::mtod_entity_type[] = { 00010 DAMSEL_ENTITY_TYPE_VERTEX, // MBVERTEX 00011 DAMSEL_ENTITY_TYPE_EDGE, // MBEDGE 00012 DAMSEL_ENTITY_TYPE_TRI, // MBTRI 00013 DAMSEL_ENTITY_TYPE_QUAD, // MBQUAD 00014 DAMSEL_ENTITY_TYPE_POLYGON, // MBPOLYGON 00015 DAMSEL_ENTITY_TYPE_TET, // MBTET 00016 DAMSEL_ENTITY_TYPE_PYRAMID, // MBPYRAMID 00017 DAMSEL_ENTITY_TYPE_PRISM, // MBPRISM 00018 DAMSEL_ENTITY_TYPE_UNDEFINED, // MBKNIFE 00019 DAMSEL_ENTITY_TYPE_HEX, // MBHEX, 00020 DAMSEL_ENTITY_TYPE_POLYHEDRON, // MBPOLYHEDRON 00021 DAMSEL_ENTITY_TYPE_UNDEFINED // MBENTITYSET 00022 }; 00023 00024 EntityType DamselUtil::dtom_entity_type[] = { 00025 MBVERTEX, // MBVERTEX 00026 MBEDGE, // MBEDGE 00027 MBTRI, // MBTRI 00028 MBQUAD, // MBQUAD 00029 MBPOLYGON, // MBPOLYGON 00030 MBTET, // MBTET 00031 MBPRISM, // MBPRISM 00032 MBPYRAMID, // MBPYRAMID 00033 MBHEX, // MBHEX, 00034 MBPOLYHEDRON, // MBPOLYHEDRON 00035 MBMAXTYPE, // MBENTITYSET 00036 MBMAXTYPE // MBMAXTYPE 00037 }; 00038 00039 damsel_data_type DamselUtil::mtod_data_type[] = { 00040 DAMSEL_DATA_TYPE_BYTES, // MB_TYPE_OPAQUE 00041 DAMSEL_DATA_TYPE_INTEGER, // MB_TYPE_INTEGER 00042 DAMSEL_DATA_TYPE_DOUBLE, // MB_TYPE_DOUBLE 00043 DAMSEL_DATA_TYPE_INVALID, // MB_TYPE_BIT 00044 DAMSEL_DATA_TYPE_HANDLE // MB_TYPE_HANDLE 00045 }; 00046 00047 DataType DamselUtil::dtom_data_type[] = { 00048 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_INVALID = 0, 00049 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_BYTES = 1, 00050 MB_TYPE_INTEGER, // DAMSEL_DATA_TYPE_INTEGER = 2, 00051 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_INT64 = 3, 00052 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_FLOAT = 4, 00053 MB_TYPE_DOUBLE, // DAMSEL_DATA_TYPE_DOUBLE = 5, 00054 MB_TYPE_HANDLE, // DAMSEL_DATA_TYPE_HANDLE = 6, 00055 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_ID_T = 7, 00056 MB_TYPE_OPAQUE, // DAMSEL_DATA_TYPE_SHORTINT = 8, 00057 MB_TYPE_OPAQUE // DAMSEL_DATA_TYPE_PREDEFINED_WATERMARK = 9; 00058 }; 00059 00060 DamselUtil::DamselUtil() 00061 : dmslLib( DAMSEL_LIBRARY_INVALID ), dmslModel( DAMSEL_MODEL_INVALID ), moabHandleType( DAMSEL_HANDLE_TYPE_INVALID ) 00062 { 00063 } 00064 00065 //! Convert handles in a container to a range; assumes EntityHandle and Damsel 00066 //! entity handles are the same size 00067 ErrorCode DamselUtil::container_to_range( damsel_model m, damsel_container& c, Range& r ) 00068 { 00069 if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE ) 00070 { 00071 damsel_handle start; 00072 size_t count, stride; 00073 damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride ); 00074 CHK_DMSL_ERR_NM( err ); 00075 for( damsel_handle i = start + ( count - 1 ) * stride; i >= start; i -= stride ) 00076 r.insert( i ); 00077 } 00078 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR ) 00079 { 00080 damsel_handle* handle_ptr; 00081 size_t count; 00082 damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count ); 00083 CHK_DMSL_ERR_NM( err ); 00084 for( int i = count - 1; i >= 0; i-- ) 00085 r.insert( handle_ptr[i] ); 00086 } 00087 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE ) 00088 { 00089 damsel_handle_ptr node_ptr = NULL; 00090 damsel_container cont = NULL; 00091 damsel_err_t err = DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ); 00092 while( err.id == DMSL_OK.id && cont ) 00093 { 00094 ErrorCode rval = container_to_range( m, c, r ); 00095 if( MB_SUCCESS != rval ) return rval; 00096 err = DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ); 00097 } 00098 } 00099 00100 return MB_SUCCESS; 00101 } 00102 00103 } // namespace moab