MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 #include "FBGeomAssocPairSide.hpp" 00002 00003 #include <cstring> 00004 #include <sstream> 00005 #include <string> 00006 00007 #include "Lasso.hpp" 00008 #include "iRel_Lasso.hpp" 00009 00010 #define PROCESS_ERROR \ 00011 do \ 00012 { \ 00013 if( iBase_SUCCESS != result ) \ 00014 { \ 00015 char this_descr[120]; \ 00016 FBiGeom_getDescription( instance_, this_descr, 120 ); \ 00017 ERRORR( result, this_descr ); \ 00018 } \ 00019 } while( false ) 00020 00021 // Redefine LASSOI 00022 #undef LASSOI 00023 #define LASSOI lasso_instance( relation ) 00024 00025 static const char* GLOBAL_ID_TAG_NAME = "GLOBAL_ID"; 00026 static const char* RELATION_TAG_NAME = "__FBGEOM_ASSOCIATION"; 00027 00028 FBGeomAssocPairSide::FBGeomAssocPairSide( iRel_Instance p_relation, iBase_Instance p_instance, int p_id ) 00029 : relation( p_relation ), instance_( reinterpret_cast< FBiGeom_Instance >( p_instance ) ), id( p_id ) 00030 { 00031 int result; 00032 00033 create_relation_side(); 00034 00035 FBiGeom_getTagHandle( instance_, GLOBAL_ID_TAG_NAME, &gid_tag, &result, strlen( GLOBAL_ID_TAG_NAME ) ); 00036 if( result == iBase_TAG_NOT_FOUND ) 00037 { 00038 FBiGeom_createTag( instance_, GLOBAL_ID_TAG_NAME, 1, iBase_INTEGER, &gid_tag, &result, 00039 strlen( GLOBAL_ID_TAG_NAME ) ); 00040 } 00041 } 00042 00043 FBGeomAssocPairSide::~FBGeomAssocPairSide() 00044 { 00045 destroy_relation_side(); 00046 } 00047 00048 iBase_Instance FBGeomAssocPairSide::instance() const 00049 { 00050 return instance_; 00051 } 00052 00053 iRel_IfaceType FBGeomAssocPairSide::type() const 00054 { 00055 return iRel_FBIGEOM_IFACE; 00056 } 00057 00058 int FBGeomAssocPairSide::create_relation_side() 00059 { 00060 int result; 00061 std::stringstream ss; 00062 ss << RELATION_TAG_NAME << id; 00063 std::string rel_tag_name( ss.str() ); 00064 00065 FBiGeom_getTagHandle( instance_, rel_tag_name.c_str(), &relation_tag, &result, rel_tag_name.size() ); 00066 if( result == iBase_TAG_NOT_FOUND ) 00067 { 00068 FBiGeom_createTag( instance_, rel_tag_name.c_str(), 1, iBase_ENTITY_HANDLE, &relation_tag, &result, 00069 rel_tag_name.size() ); 00070 } 00071 00072 PROCESS_ERROR; 00073 RETURNR( iBase_SUCCESS ); 00074 } 00075 00076 int FBGeomAssocPairSide::destroy_relation_side() 00077 { 00078 if( relation_tag ) 00079 { 00080 int result; 00081 00082 FBiGeom_destroyTag( instance_, relation_tag, true, &result ); 00083 relation_tag = NULL; 00084 00085 PROCESS_ERROR; 00086 } 00087 RETURNR( iBase_SUCCESS ); 00088 } 00089 00090 int FBGeomAssocPairSide::get_all_entities( int dimension, 00091 iBase_EntityHandle** entities, 00092 int* entities_alloc, 00093 int* entities_size ) 00094 { 00095 int this_type = ( dimension == -1 ? iBase_ALL_TYPES : dimension ); 00096 int result; 00097 00098 FBiGeom_getEntities( instance_, 0, this_type, entities, entities_alloc, entities_size, &result ); 00099 PROCESS_ERROR; 00100 RETURNR( iBase_SUCCESS ); 00101 } 00102 00103 int FBGeomAssocPairSide::get_all_sets( iBase_EntitySetHandle** sets, int* sets_alloc, int* sets_size ) 00104 { 00105 int result; 00106 00107 FBiGeom_getEntSets( instance_, 0, 0, sets, sets_alloc, sets_size, &result ); 00108 PROCESS_ERROR; 00109 RETURNR( iBase_SUCCESS ); 00110 } 00111 00112 int FBGeomAssocPairSide::get_entities( int dimension, 00113 iBase_EntitySetHandle set_handle, 00114 iBase_EntityHandle** entities, 00115 int* entities_alloc, 00116 int* entities_size ) 00117 { 00118 int this_type = ( dimension == -1 ? iBase_ALL_TYPES : dimension ); 00119 int result; 00120 00121 FBiGeom_getEntities( instance_, set_handle, this_type, entities, entities_alloc, entities_size, &result ); 00122 PROCESS_ERROR; 00123 RETURNR( iBase_SUCCESS ); 00124 } 00125 00126 int FBGeomAssocPairSide::get_ents_dims( iBase_EntityHandle* entities, 00127 int entities_size, 00128 int** ent_types, 00129 int* ent_types_alloc, 00130 int* ent_types_size ) 00131 { 00132 int result; 00133 00134 FBiGeom_getArrType( instance_, entities, entities_size, ent_types, ent_types_alloc, ent_types_size, &result ); 00135 PROCESS_ERROR; 00136 RETURNR( iBase_SUCCESS ); 00137 } 00138 00139 int FBGeomAssocPairSide::get_related_ents( iBase_EntityHandle** /*entities*/, 00140 int* /*entities_alloc*/, 00141 int* /*entities_size*/ ) 00142 { 00143 RETURNR( iBase_FAILURE ); 00144 } 00145 00146 int FBGeomAssocPairSide::get_related_sets( iBase_EntitySetHandle** /*sets*/, int* /*sets_alloc*/, int* /*sets_size*/ ) 00147 { 00148 RETURNR( iBase_FAILURE ); 00149 } 00150 00151 int FBGeomAssocPairSide::get_relation_side( iBase_EntityHandle* entities, int num_entities, void* values ) 00152 { 00153 int values_alloc = num_entities * sizeof( iBase_EntityHandle ); 00154 int values_size; 00155 int result; 00156 00157 FBiGeom_getArrData( instance_, entities, num_entities, relation_tag, &values, &values_alloc, &values_size, 00158 &result ); 00159 PROCESS_ERROR; 00160 RETURNR( iBase_SUCCESS ); 00161 } 00162 00163 int FBGeomAssocPairSide::get_relation_side( iBase_EntitySetHandle* sets, int num_sets, void* values ) 00164 { 00165 char* data = static_cast< char* >( values ); 00166 int values_alloc = sizeof( iBase_EntityHandle ); 00167 int values_size; 00168 int result; 00169 00170 for( int i = 0; i < num_sets; i++ ) 00171 { 00172 FBiGeom_getEntSetData( instance_, sets[i], relation_tag, reinterpret_cast< void** >( &data ), &values_alloc, 00173 &values_size, &result ); 00174 data += values_size; 00175 PROCESS_ERROR; 00176 } 00177 RETURNR( iBase_SUCCESS ); 00178 } 00179 00180 int FBGeomAssocPairSide::set_relation_side( iBase_EntityHandle* entities, int num_entities, const void* values ) 00181 { 00182 int result; 00183 00184 FBiGeom_setArrData( instance_, entities, num_entities, relation_tag, static_cast< const char* >( values ), 00185 num_entities * sizeof( iBase_EntityHandle ), &result ); 00186 PROCESS_ERROR; 00187 RETURNR( iBase_SUCCESS ); 00188 } 00189 00190 int FBGeomAssocPairSide::set_relation_side( iBase_EntitySetHandle* sets, int num_sets, const void* values ) 00191 { 00192 const char* data = static_cast< const char* >( values ); 00193 int size = sizeof( iBase_EntityHandle ); 00194 int result; 00195 00196 for( int i = 0; i < num_sets; i++ ) 00197 { 00198 FBiGeom_setEntSetData( instance_, sets[i], relation_tag, data, size, &result ); 00199 data += size; 00200 PROCESS_ERROR; 00201 } 00202 RETURNR( iBase_SUCCESS ); 00203 } 00204 00205 int FBGeomAssocPairSide::rmv_relation_side( iBase_EntityHandle* entities, int num_entities ) 00206 { 00207 int result; 00208 00209 FBiGeom_rmvArrTag( instance_, entities, num_entities, relation_tag, &result ); 00210 PROCESS_ERROR; 00211 RETURNR( iBase_SUCCESS ); 00212 } 00213 00214 int FBGeomAssocPairSide::rmv_relation_side( iBase_EntitySetHandle* sets, int num_sets ) 00215 { 00216 int result; 00217 00218 for( int i = 0; i < num_sets; i++ ) 00219 { 00220 FBiGeom_rmvEntSetTag( instance_, sets[i], relation_tag, &result ); 00221 PROCESS_ERROR; 00222 } 00223 00224 RETURNR( iBase_SUCCESS ); 00225 } 00226 00227 int FBGeomAssocPairSide::get_iterator( iBase_EntitySetHandle set, iBase_EntityIterator* iter ) 00228 { 00229 int result; 00230 FBiGeom_initEntIter( instance_, set, iBase_ALL_TYPES, iter, &result ); 00231 RETURNR( iBase_SUCCESS ); 00232 } 00233 00234 int FBGeomAssocPairSide::get_gids( iBase_EntityHandle* entities, int num_entities, int* values ) 00235 { 00236 int values_alloc = num_entities * sizeof( int ); 00237 int values_size; 00238 int result; 00239 00240 FBiGeom_getArrData( instance_, entities, num_entities, gid_tag, reinterpret_cast< void** >( &values ), 00241 &values_alloc, &values_size, &result ); 00242 PROCESS_ERROR; 00243 RETURNR( iBase_SUCCESS ); 00244 } 00245 00246 int FBGeomAssocPairSide::get_gids( iBase_EntitySetHandle* sets, int num_sets, int* values ) 00247 { 00248 char* data = reinterpret_cast< char* >( values ); 00249 int values_alloc = sizeof( int ); 00250 int values_size; 00251 int result; 00252 00253 for( int i = 0; i < num_sets; i++ ) 00254 { 00255 FBiGeom_getEntSetData( instance_, sets[i], gid_tag, reinterpret_cast< void** >( &data ), &values_alloc, 00256 &values_size, &result ); 00257 data += values_size; 00258 PROCESS_ERROR; 00259 } 00260 RETURNR( iBase_SUCCESS ); 00261 } 00262 00263 int FBGeomAssocPairSide::get_dims( iBase_EntityHandle* /*entities*/, int /*num_entities*/, int* /*values*/ ) 00264 { 00265 RETURNR( iBase_FAILURE ); 00266 } 00267 00268 int FBGeomAssocPairSide::get_dims( iBase_EntitySetHandle* /*sets*/, int /*num_sets*/, int* /*values*/ ) 00269 { 00270 RETURNR( iBase_FAILURE ); 00271 }