MOAB: Mesh Oriented datABase  (version 5.2.1)
MeshTag.hpp
Go to the documentation of this file.
00001 /** \file   MeshTag.hpp
00002  *  \author Jason Kraftcheck
00003  *  \date   2010-12-14
00004  */
00005 
00006 #ifndef MESH_TAG_HPP
00007 #define MESH_TAG_HPP
00008 
00009 #include "TagInfo.hpp"
00010 
00011 namespace moab
00012 {
00013 
00014 /**\brief Tag with only a global/mesh value
00015  *
00016  * Trivial tag implementation.  No per-entity values.  Only
00017  * the global mesh value which is handled by the \c TagInfo
00018  * base class.
00019  */
00020 class MeshTag : public TagInfo
00021 {
00022   public:
00023     //! constructor that takes all parameters
00024     MeshTag( const char* name, int size, DataType type, const void* default_value, int default_value_size );
00025 
00026     virtual ~MeshTag();
00027 
00028     virtual TagType get_storage_type() const;
00029 
00030     /**\brief Remove/clear tag data for all entities
00031      *
00032      * Remove tag values from entities.
00033      *
00034      *\param delete_pending  If true, then release any global
00035      *          data associated with the tag in preparation for deleting
00036      *          the tag itself.
00037      *
00038      *\Note Invalidates tag if \c tag_delete_pending is true.  The only
00039      *        valid method that can be invoked that is is the destructor.
00040      *
00041      *\param seqman    Pointer to mesh entity database
00042      */
00043     virtual ErrorCode release_all_data( SequenceManager* seqman, Error* error_handler, bool delete_pending );
00044 
00045     /**\brief Get tag value for passed entities
00046      *
00047      * Get tag values for specified entities.
00048      *
00049      *\Note Will fail for variable-length data.
00050      *\param seqman Pointer to mesh entity database
00051      *\param entities Entity handles for which to retrieve tag data
00052      *\param num_entities Length of \c entities array
00053      *\param data Pointer to memory in which to store consecutive tag values,
00054      *            one for each passed entity.
00055      */
00056     virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00057                                 size_t num_entities, void* data ) const;
00058 
00059     /**\brief Get tag value for passed entities
00060      *
00061      * Get tag values for specified entities.
00062      *
00063      *\Note Will fail for variable-length data.
00064      *\param seqman Pointer to mesh entity database
00065      *\param entities Entity handles for which to retrieve tag data
00066      *\param data Pointer to memory in which to store consecutive tag values,
00067      *            one for each passed entity.
00068      */
00069     virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const Range& entities,
00070                                 void* data ) const;
00071 
00072     /**\brief Get tag value for passed entities
00073      *
00074      * Get tag values for specified entities.
00075      *
00076      *\param seqman    Pointer to mesh entity database
00077      *\param entities  Entity handles for which to retrieve tag data
00078      *\param num_entities Length of \c entities array
00079      *\param data_ptrs Array of pointers to tag values, one pointer
00080      *                 for each passed entity.
00081      *\param data_lengths One value for each entity specifying the
00082      *                length of the tag value for the corresponding
00083      *                entity.
00084      */
00085     virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00086                                 size_t num_entities, const void** data_ptrs, int* data_lengths ) const;
00087 
00088     /**\brief Get tag value for passed entities
00089      *
00090      * Get tag values for specified entities.
00091      *
00092      *\param seqman    Pointer to mesh entity database
00093      *\param entities  Entity handles for which to retrieve tag data
00094      *\param data_ptrs Array of pointers to tag values, one pointer
00095      *                 for each passed entity.
00096      *\param data_lengths One value for each entity specifying the
00097      *                length of the tag value for the corresponding
00098      *                entity.
00099      */
00100     virtual ErrorCode get_data( const SequenceManager* seqman, Error* error_handler, const Range& entities,
00101                                 const void** data_ptrs, int* data_lengths ) const;
00102 
00103     /**\brief Set tag value for passed entities
00104      *
00105      * Store tag data or update stored tag values
00106      *\Note Will fail for variable-length data.
00107      *\param seqman Pointer to mesh entity database
00108      *\param entities Entity handles for which to store tag data
00109      *\param num_entities Length of \c entities array
00110      *\param data Pointer to memory holding consecutive tag values,
00111      *            one for each passed entity.
00112      */
00113     virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00114                                 size_t num_entities, const void* data );
00115 
00116     /**\brief Set tag value for passed entities
00117      *
00118      * Store tag data or update stored tag values
00119      *\Note Will fail for variable-length data.
00120      *\param seqman Pointer to mesh entity database
00121      *\param entities Entity handles for which to store tag data
00122      *\param data Pointer to memory holding consecutive tag values,
00123      *            one for each passed entity.
00124      */
00125     virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const Range& entities,
00126                                 const void* data );
00127 
00128     /**\brief Set tag value for passed entities
00129      *
00130      * Store tag data or update stored tag values
00131      *
00132      *\param seqman    Pointer to mesh entity database
00133      *\param entities  Entity handles for which to store tag data
00134      *\param num_entities Length of \c entities array
00135      *\param data_ptrs Array of pointers to tag values, one pointer
00136      *                 for each passed entity.
00137      *\param data_lengths One value for each entity specifying the
00138      *                length of the tag value for the corresponding
00139      *                entity.  Array is required for variable-length
00140      *                tags and is ignored for fixed-length tags.
00141      */
00142     virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00143                                 size_t num_entities, void const* const* data_ptrs, const int* data_lengths );
00144 
00145     /**\brief Set tag value for passed entities
00146      *
00147      * Store tag data or update stored tag values
00148      *
00149      *\param seqman    Pointer to mesh entity database
00150      *\param entities  Entity handles for which to store tag data
00151      *\param data_ptrs Array of pointers to tag values, one pointer
00152      *                 for each passed entity.
00153      *\param data_lengths One value for each entity specifying the
00154      *                length of the tag value for the corresponding
00155      *                entity.  Array is required for variable-length
00156      *                tags and is ignored for fixed-length tags.
00157      */
00158     virtual ErrorCode set_data( SequenceManager* seqman, Error* error_handler, const Range& entities,
00159                                 void const* const* data_ptrs, const int* data_lengths );
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 value_ptr Pointer to a single tag value which is to be
00169      *                 stored for each of the passed entities.
00170      *\param value_len Length of tag value in bytes.  Ignored for
00171      *                 fixed-length tags.  Required for variable-
00172      *                 length tags.
00173      */
00174     virtual ErrorCode clear_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00175                                   size_t num_entities, const void* value_ptr, int value_len = 0 );
00176 
00177     /**\brief Set tag value for passed entities
00178      *
00179      * Store tag data or update stored tag values.
00180      *
00181      *\param seqman    Pointer to mesh entity database
00182      *\param entities  Entity handles for which to store tag data
00183      *\param value_ptr Pointer to a single tag value which is to be
00184      *                 stored for each of the passed entities.
00185      *\param value_len Length of tag value in bytes.  Ignored for
00186      *                 fixed-length tags.  Required for variable-
00187      *                 length tags.
00188      */
00189     virtual ErrorCode clear_data( SequenceManager* seqman, Error* error_handler, const Range& entities,
00190                                   const void* value_ptr, int value_len = 0 );
00191 
00192     /**\brief Remove/clear tag data for entities
00193      *
00194      * Remove tag values from entities.
00195      *
00196      *\param seqman    Pointer to mesh entity database
00197      *\param entities  Entity handles for which to store tag data
00198      *\param num_entities Length of \c entities array
00199      */
00200     virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const EntityHandle* entities,
00201                                    size_t num_entities );
00202 
00203     /**\brief Remove/clear tag data for entities
00204      *
00205      * Remove tag values from entities.
00206      *
00207      *\param seqman    Pointer to mesh entity database
00208      *\param entities  Entity handles for which to store tag data
00209      */
00210     virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const Range& entities );
00211 
00212     /**\brief Access tag data via direct pointer into contiguous blocks
00213      *
00214      * Iteratively obtain direct access to contiguous blocks of tag
00215      * storage.  This function cannot be used with bit tags because
00216      * of the compressed bit storage.  This function cannot be used
00217      * with variable length tags because it does not provide a mechanism
00218      * to determine the length of the value for each entity.  This
00219      * function may be used with sparse tags, but if it is used, it
00220      * will return data for a single entity at a time.
00221      *
00222      *\param iter        As input, the first entity for which to return
00223      *                   data.  As output, one past the last entity for
00224      *                   which data was returned.
00225      *\param end         One past the last entity for which data is desired
00226      *\param data_ptr    Output: pointer to tag storage.
00227      *\param allocate    If true, allocate space for this tag as part of this call, else don't
00228      *
00229      *\Note If this function is called for entities for which no tag value
00230      *      has been set, but for which a default value exists, it will
00231      *      force the allocation of explicit storage for each such entity
00232      *      even though MOAB would normally not explicitly store tag values
00233      *      for such entities.
00234      */
00235     virtual ErrorCode tag_iterate( SequenceManager* seqman, Error* error_handler, Range::iterator& iter,
00236                                    const Range::iterator& end, void*& data_ptr, bool allocate = true );
00237 
00238     /**\brief Get all tagged entities
00239      *
00240      * Get the list of entities for which the a tag value has been set,
00241      * or a close approximation if the tag storage scheme cannot
00242      * accurately determine exactly which entities have explicit values.
00243      *
00244      *\param seqman   Pointer to entity storage database
00245      *\param output_entities Results *appended* to this range
00246      *\param type     Optional entity type.  If specified, search is
00247      *                limited to entities of specified type.
00248      *\param intersect Optional intersect list.  If specified,
00249      *                search is restricted to entities in this list.
00250      */
00251     virtual ErrorCode get_tagged_entities( const SequenceManager* seqman, Range& output_entities,
00252                                            EntityType type = MBMAXTYPE, const Range* intersect = 0 ) const;
00253 
00254     /**\brief Count all tagged entities
00255      *
00256      * Count the entities for which the a tag value has been set,
00257      * or a close approximation if the tag storage scheme cannot
00258      * accurately determine exactly which entities have explicit values.
00259      *
00260      *\param seqman   Pointer to entity storage database
00261      *\param output_count This is *incremented* for each detected entity.
00262      *\param type     Optional entity type.  If specified, search is
00263      *                limited to entities of specified type.
00264      *\param intersect Optional intersect list.  If specified,
00265      *                search is restricted to entities in this list.
00266      */
00267     virtual ErrorCode num_tagged_entities( const SequenceManager* seqman, size_t& output_count,
00268                                            EntityType type = MBMAXTYPE, const Range* intersect = 0 ) const;
00269 
00270     /**\brief Get all tagged entities with tag value
00271      *
00272      * Get the list of entities which have the specified tag value.
00273      *
00274      *\param seqman   Pointer to entity storage database
00275      *\param output_entities Results *appended* to this range
00276      *\param value    Pointer to tag value
00277      *\param value_bytes Size of tag value in bytes.
00278      *\param type     Optional entity type.  If specified, search is
00279      *                limited to entities of specified type.
00280      *\param intersect_entities Optional intersect list.  If specified,
00281      *                search is restricted to entities in this list.
00282      */
00283     virtual ErrorCode find_entities_with_value( const SequenceManager* seqman, Error* error_handler,
00284                                                 Range& output_entities, const void* value, int value_bytes = 0,
00285                                                 EntityType type                 = MBMAXTYPE,
00286                                                 const Range* intersect_entities = 0 ) const;
00287 
00288     /**\brief Check if entity is tagged */
00289     virtual bool is_tagged( const SequenceManager*, EntityHandle h ) const;
00290 
00291     /**\brief Get memory use for tag data.
00292      *
00293      */
00294     virtual ErrorCode get_memory_use( const SequenceManager* seqman, unsigned long& total,
00295                                       unsigned long& per_entity ) const;
00296 
00297   private:
00298     MeshTag( const MeshTag& );
00299     MeshTag& operator=( const MeshTag& );
00300     std::vector< unsigned char > mValue;
00301 };
00302 
00303 }  // namespace moab
00304 
00305 #endif  // MESH_TAG_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines