Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /** \file VarLenDenseTag.hpp 00002 * \author Jason Kraftcheck 00003 * \date 2010-12-14 00004 */ 00005 00006 #ifndef VAR_LEN_DENSE_TAG_HPP 00007 #define VAR_LEN_DENSE_TAG_HPP 00008 00009 #include "TagInfo.hpp" 00010 #include "VarLenTag.hpp" 00011 00012 namespace moab 00013 { 00014 00015 class VarLenTag; 00016 00017 /**\brief Dense storage of variable-length tag data 00018 * 00019 * Implement variable-length dense tag. 00020 */ 00021 class VarLenDenseTag : public TagInfo 00022 { 00023 private: 00024 int mySequenceArray; //!< Array index in SequenceManager used to store tag data. 00025 00026 VarLenTag meshValue; 00027 00028 VarLenDenseTag( int array_index, 00029 const char* name, 00030 DataType type, 00031 const void* default_value, 00032 int default_value_len ); 00033 00034 public: 00035 static VarLenDenseTag* create_tag( SequenceManager* seqman, 00036 Error* error_handler, 00037 const char* name, 00038 DataType type, 00039 const void* default_value, 00040 int default_value_len ); 00041 00042 virtual ~VarLenDenseTag(); 00043 00044 virtual TagType get_storage_type() const; 00045 00046 /**\brief Remove/clear tag data for all entities 00047 * 00048 * Remove tag values from entities. 00049 * 00050 *\param delete_pending If true, then release any global 00051 * data associated with the tag in preparation for deleting 00052 * the tag itself. 00053 * 00054 *\Note Invalidates tag if \c tag_delete_pending is true. The only 00055 * valid method that can be invoked that is is the destructor. 00056 * 00057 *\param seqman Pointer to mesh entity database 00058 */ 00059 virtual ErrorCode release_all_data( SequenceManager* seqman, Error* error_handler, bool delete_pending ); 00060 00061 /**\brief Get tag value for passed entities 00062 * 00063 * Get tag values for specified entities. 00064 * 00065 *\Note Will fail for variable-length data. 00066 *\param seqman Pointer to mesh entity database 00067 *\param entities Entity handles for which to retrieve tag data 00068 *\param num_entities Length of \c entities array 00069 *\param data Pointer to memory in which to store consecutive tag values, 00070 * one for each passed entity. 00071 */ 00072 virtual ErrorCode get_data( const SequenceManager* seqman, 00073 Error* error_handler, 00074 const EntityHandle* entities, 00075 size_t num_entities, 00076 void* data ) const; 00077 00078 /**\brief Get tag value for passed entities 00079 * 00080 * Get tag values for specified entities. 00081 * 00082 *\Note Will fail for variable-length data. 00083 *\param seqman Pointer to mesh entity database 00084 *\param entities Entity handles for which to retrieve tag data 00085 *\param data Pointer to memory in which to store consecutive tag values, 00086 * one for each passed entity. 00087 */ 00088 virtual ErrorCode get_data( const SequenceManager* seqman, 00089 Error* error_handler, 00090 const Range& entities, 00091 void* data ) const; 00092 00093 /**\brief Get tag value for passed entities 00094 * 00095 * Get tag values for specified entities. 00096 * 00097 *\param seqman Pointer to mesh entity database 00098 *\param entities Entity handles for which to retrieve tag data 00099 *\param num_entities Length of \c entities array 00100 *\param data_ptrs Array of pointers to tag values, one pointer 00101 * for each passed entity. 00102 *\param data_lengths One value for each entity specifying the 00103 * length of the tag value for the corresponding 00104 * entity. 00105 */ 00106 virtual ErrorCode get_data( const SequenceManager* seqman, 00107 Error* error_handler, 00108 const EntityHandle* entities, 00109 size_t num_entities, 00110 const void** data_ptrs, 00111 int* data_lengths ) const; 00112 00113 /**\brief Get tag value for passed entities 00114 * 00115 * Get tag values for specified entities. 00116 * 00117 *\param seqman Pointer to mesh entity database 00118 *\param entities Entity handles for which to retrieve tag data 00119 *\param data_ptrs Array of pointers to tag values, one pointer 00120 * for each passed entity. 00121 *\param data_lengths One value for each entity specifying the 00122 * length of the tag value for the corresponding 00123 * entity. 00124 */ 00125 virtual ErrorCode get_data( const SequenceManager* seqman, 00126 Error* error_handler, 00127 const Range& entities, 00128 const void** data_ptrs, 00129 int* data_lengths ) const; 00130 00131 /**\brief Set tag value for passed entities 00132 * 00133 * Store tag data or update stored tag values 00134 *\Note Will fail for variable-length data. 00135 *\param seqman Pointer to mesh entity database 00136 *\param entities Entity handles for which to store tag data 00137 *\param num_entities Length of \c entities array 00138 *\param data Pointer to memory holding consecutive tag values, 00139 * one for each passed entity. 00140 */ 00141 virtual ErrorCode set_data( SequenceManager* seqman, 00142 Error* error_handler, 00143 const EntityHandle* entities, 00144 size_t num_entities, 00145 const void* data ); 00146 00147 /**\brief Set tag value for passed entities 00148 * 00149 * Store tag data or update stored tag values 00150 *\Note Will fail for variable-length data. 00151 *\param seqman Pointer to mesh entity database 00152 *\param entities Entity handles for which to store tag data 00153 *\param data Pointer to memory holding consecutive tag values, 00154 * one for each passed entity. 00155 */ 00156 virtual ErrorCode set_data( SequenceManager* seqman, 00157 Error* error_handler, 00158 const Range& entities, 00159 const void* data ); 00160 00161 /**\brief Set tag value for passed entities 00162 * 00163 * Store tag data or update stored tag values 00164 * 00165 *\param seqman Pointer to mesh entity database 00166 *\param entities Entity handles for which to store tag data 00167 *\param num_entities Length of \c entities array 00168 *\param data_ptrs Array of pointers to tag values, one pointer 00169 * for each passed entity. 00170 *\param data_lengths One value for each entity specifying the 00171 * length of the tag value for the corresponding 00172 * entity. Array is required for variable-length 00173 * tags and is ignored for fixed-length tags. 00174 */ 00175 virtual ErrorCode set_data( SequenceManager* seqman, 00176 Error* error_handler, 00177 const EntityHandle* entities, 00178 size_t num_entities, 00179 void const* const* data_ptrs, 00180 const int* data_lengths ); 00181 00182 /**\brief Set tag value for passed entities 00183 * 00184 * Store tag data or update stored tag values 00185 * 00186 *\param seqman Pointer to mesh entity database 00187 *\param entities Entity handles for which to store tag data 00188 *\param data_ptrs Array of pointers to tag values, one pointer 00189 * for each passed entity. 00190 *\param data_lengths One value for each entity specifying the 00191 * length of the tag value for the corresponding 00192 * entity. Array is required for variable-length 00193 * tags and is ignored for fixed-length tags. 00194 */ 00195 virtual ErrorCode set_data( SequenceManager* seqman, 00196 Error* error_handler, 00197 const Range& entities, 00198 void const* const* data_ptrs, 00199 const int* data_lengths ); 00200 00201 /**\brief Set tag value for passed entities 00202 * 00203 * Store tag data or update stored tag values. 00204 * 00205 *\param seqman Pointer to mesh entity database 00206 *\param entities Entity handles for which to store tag data 00207 *\param num_entities Length of \c entities array 00208 *\param value_ptr Pointer to a single tag value which is to be 00209 * stored for each of the passed entities. 00210 *\param value_len Length of tag value in bytes. Ignored for 00211 * fixed-length tags. Required for variable- 00212 * length tags. 00213 */ 00214 virtual ErrorCode clear_data( SequenceManager* seqman, 00215 Error* error_handler, 00216 const EntityHandle* entities, 00217 size_t num_entities, 00218 const void* value_ptr, 00219 int value_len = 0 ); 00220 00221 /**\brief Set tag value for passed entities 00222 * 00223 * Store tag data or update stored tag values. 00224 * 00225 *\param seqman Pointer to mesh entity database 00226 *\param entities Entity handles for which to store tag data 00227 *\param value_ptr Pointer to a single tag value which is to be 00228 * stored for each of the passed entities. 00229 *\param value_len Length of tag value in bytes. Ignored for 00230 * fixed-length tags. Required for variable- 00231 * length tags. 00232 */ 00233 virtual ErrorCode clear_data( SequenceManager* seqman, 00234 Error* error_handler, 00235 const Range& entities, 00236 const void* value_ptr, 00237 int value_len = 0 ); 00238 00239 /**\brief Remove/clear tag data for entities 00240 * 00241 * Remove tag values from entities. 00242 * 00243 *\param seqman Pointer to mesh entity database 00244 *\param entities Entity handles for which to store tag data 00245 *\param num_entities Length of \c entities array 00246 */ 00247 virtual ErrorCode remove_data( SequenceManager* seqman, 00248 Error* error_handler, 00249 const EntityHandle* entities, 00250 size_t num_entities ); 00251 00252 /**\brief Remove/clear tag data for entities 00253 * 00254 * Remove tag values from entities. 00255 * 00256 *\param seqman Pointer to mesh entity database 00257 *\param entities Entity handles for which to store tag data 00258 */ 00259 virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const Range& entities ); 00260 00261 /**\brief Access tag data via direct pointer into contiguous blocks 00262 * 00263 * Iteratively obtain direct access to contiguous blocks of tag 00264 * storage. This function cannot be used with bit tags because 00265 * of the compressed bit storage. This function cannot be used 00266 * with variable length tags because it does not provide a mechanism 00267 * to determine the length of the value for each entity. This 00268 * function may be used with sparse tags, but if it is used, it 00269 * will return data for a single entity at a time. 00270 * 00271 *\param iter As input, the first entity for which to return 00272 * data. As output, one past the last entity for 00273 * which data was returned. 00274 *\param end One past the last entity for which data is desired 00275 *\param data_ptr Output: pointer to tag storage. 00276 *\param allocate If true, space for this tag will be allocated, if not it wont 00277 * 00278 *\Note If this function is called for entities for which no tag value 00279 * has been set, but for which a default value exists, it will 00280 * force the allocation of explicit storage for each such entity 00281 * even though MOAB would normally not explicitly store tag values 00282 * for such entities. 00283 */ 00284 virtual ErrorCode tag_iterate( SequenceManager* seqman, 00285 Error* error_handler, 00286 Range::iterator& iter, 00287 const Range::iterator& end, 00288 void*& data_ptr, 00289 bool allocate ); 00290 00291 /**\brief Get all tagged entities 00292 * 00293 * Get the list of entities for which the a tag value has been set, 00294 * or a close approximation if the tag storage scheme cannot 00295 * accurately determine exactly which entities have explicit values. 00296 * 00297 *\param seqman Pointer to entity storage database 00298 *\param output_entities Results *appended* to this range 00299 *\param type Optional entity type. If specified, search is 00300 * limited to entities of specified type. 00301 *\param intersect Optional intersect list. If specified, 00302 * search is restricted to entities in this list. 00303 */ 00304 virtual ErrorCode get_tagged_entities( const SequenceManager* seqman, 00305 Range& output_entities, 00306 EntityType type = MBMAXTYPE, 00307 const Range* intersect = 0 ) const; 00308 00309 /**\brief Count all tagged entities 00310 * 00311 * Count the entities for which the a tag value has been set, 00312 * or a close approximation if the tag storage scheme cannot 00313 * accurately determine exactly which entities have explicit values. 00314 * 00315 *\param seqman Pointer to entity storage database 00316 *\param output_count This is *incremented* for each detected entity. 00317 *\param type Optional entity type. If specified, search is 00318 * limited to entities of specified type. 00319 *\param intersect Optional intersect list. If specified, 00320 * search is restricted to entities in this list. 00321 */ 00322 virtual ErrorCode num_tagged_entities( const SequenceManager* seqman, 00323 size_t& output_count, 00324 EntityType type = MBMAXTYPE, 00325 const Range* intersect = 0 ) const; 00326 00327 /**\brief Get all tagged entities with tag value 00328 * 00329 * Get the list of entities which have the specified tag value. 00330 * 00331 *\param seqman Pointer to entity storage database 00332 *\param output_entities Results *appended* to this range 00333 *\param value Pointer to tag value 00334 *\param value_bytes Size of tag value in bytes. 00335 *\param type Optional entity type. If specified, search is 00336 * limited to entities of specified type. 00337 *\param intersect_entities Optional intersect list. If specified, 00338 * search is restricted to entities in this list. 00339 */ 00340 virtual ErrorCode find_entities_with_value( const SequenceManager* seqman, 00341 Error* error, 00342 Range& output_entities, 00343 const void* value, 00344 int value_bytes = 0, 00345 EntityType type = MBMAXTYPE, 00346 const Range* intersect_entities = 0 ) const; 00347 00348 /**\brief Check if entity is tagged */ 00349 virtual bool is_tagged( const SequenceManager*, EntityHandle h ) const; 00350 00351 /**\brief Get memory use for tag data. 00352 * 00353 */ 00354 virtual ErrorCode get_memory_use( const SequenceManager* seqman, 00355 unsigned long& total, 00356 unsigned long& per_entity ) const; 00357 00358 private: 00359 VarLenDenseTag( const VarLenDenseTag& ); 00360 VarLenDenseTag& operator=( const VarLenDenseTag& ); 00361 00362 /**\brief Get or allocated tag storage 00363 * 00364 *\param h First entity for which to return storage. 00365 *\param ptr Pointer to dag storage. This pointer will be set 00366 * to null and \c MB_SUCCESS will be returned if the handle 00367 * is valid but no tag storage has been allocated. 00368 *\param count Number of consecutive entities for which tag storage 00369 * is returned. This value will be valid even if null 00370 * is returned for \c ptr and indicates the number of 00371 * consecutive entities for which no tag storage has been 00372 * allocated. 00373 *\param allocate If true storage will be allocated and initialized 00374 * if it has not already been allocated. 00375 *\return MB_SUCCESS if handle is valid (regardless of whether 00376 * or not any tag storage is allocated). 00377 */ 00378 inline ErrorCode get_array( SequenceManager* seqman, 00379 Error* error_handler, 00380 EntityHandle h, 00381 VarLenTag*& ptr, 00382 size_t& count, 00383 bool allocate ); 00384 00385 /**\brief Get tag storage 00386 * 00387 *\param h First entity for which to return storage. 00388 *\param ptr Pointer to dag storage. This pointer will be set 00389 * to null and \c MB_SUCCESS will be returned if the handle 00390 * is valid but no tag storage has been allocated. 00391 *\param count Number of consecutive entities for which tag storage 00392 * is returned. This value will be valid even if null 00393 * is returned for \c ptr and indicates the number of 00394 * consecutive entities for which no tag storage has been 00395 * allocated. 00396 *\return MB_SUCCESS if handle is valid (regardless of whether 00397 * or not any tag storage is allocated). 00398 */ 00399 inline ErrorCode get_array( const SequenceManager* seqman, 00400 Error* error_handler, 00401 EntityHandle h, 00402 const VarLenTag*& ptr, 00403 size_t& count ) const; 00404 00405 /**\brief Common implementation of set_data, and clear_data 00406 *\param allocate If false and no storage is currently allocated for 00407 * an entity then leave entity tag unallocated. 00408 *\param one_value If true, pointers and lengths are assumed to be 00409 * arrays of length 1 and all entities are set to the 00410 * corresponding value 00411 */ 00412 inline ErrorCode set_data( SequenceManager* seqman, 00413 Error* error_handler, 00414 const EntityHandle* entities, 00415 size_t num_entities, 00416 bool one_value, 00417 void const* const* pointers, 00418 const int* lengths ); 00419 00420 /**\brief Common implementation of set_data, and clear_data 00421 *\param allocate If false and no storage is currently allocated for 00422 * an entity then leave entity tag unallocated. 00423 *\param one_value If true, pointers and lengths are assumed to be 00424 * arrays of length 1 and all entities are set to the 00425 * corresponding value 00426 */ 00427 inline ErrorCode set_data( SequenceManager* seqman, 00428 Error* error_handler, 00429 const Range& entities, 00430 bool one_value, 00431 void const* const* pointers, 00432 const int* lengths ); 00433 }; 00434 00435 } // namespace moab 00436 00437 #endif // VAR_LEN_DENSE_TAG_HPP