MOAB: Mesh Oriented datABase  (version 5.4.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,
00057                                 Error* error_handler,
00058                                 const EntityHandle* entities,
00059                                 size_t num_entities,
00060                                 void* data ) const;
00061 
00062     /**\brief Get tag value for passed entities
00063      *
00064      * Get tag values for specified entities.
00065      *
00066      *\Note Will fail for variable-length data.
00067      *\param seqman Pointer to mesh entity database
00068      *\param entities Entity handles for which to retrieve tag data
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 Range& entities,
00075                                 void* data ) const;
00076 
00077     /**\brief Get tag value for passed entities
00078      *
00079      * Get tag values for specified entities.
00080      *
00081      *\param seqman    Pointer to mesh entity database
00082      *\param entities  Entity handles for which to retrieve tag data
00083      *\param num_entities Length of \c entities array
00084      *\param data_ptrs Array of pointers to tag values, one pointer
00085      *                 for each passed entity.
00086      *\param data_lengths One value for each entity specifying the
00087      *                length of the tag value for the corresponding
00088      *                entity.
00089      */
00090     virtual ErrorCode get_data( const SequenceManager* seqman,
00091                                 Error* error_handler,
00092                                 const EntityHandle* entities,
00093                                 size_t num_entities,
00094                                 const void** data_ptrs,
00095                                 int* data_lengths ) const;
00096 
00097     /**\brief Get tag value for passed entities
00098      *
00099      * Get tag values for specified entities.
00100      *
00101      *\param seqman    Pointer to mesh entity database
00102      *\param entities  Entity handles for which to retrieve tag data
00103      *\param data_ptrs Array of pointers to tag values, one pointer
00104      *                 for each passed entity.
00105      *\param data_lengths One value for each entity specifying the
00106      *                length of the tag value for the corresponding
00107      *                entity.
00108      */
00109     virtual ErrorCode get_data( const SequenceManager* seqman,
00110                                 Error* error_handler,
00111                                 const Range& entities,
00112                                 const void** data_ptrs,
00113                                 int* data_lengths ) const;
00114 
00115     /**\brief Set tag value for passed entities
00116      *
00117      * Store tag data or update stored tag values
00118      *\Note Will fail for variable-length data.
00119      *\param seqman Pointer to mesh entity database
00120      *\param entities Entity handles for which to store tag data
00121      *\param num_entities Length of \c entities array
00122      *\param data Pointer to memory holding consecutive tag values,
00123      *            one for each passed entity.
00124      */
00125     virtual ErrorCode set_data( SequenceManager* seqman,
00126                                 Error* error_handler,
00127                                 const EntityHandle* entities,
00128                                 size_t num_entities,
00129                                 const void* data );
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 data Pointer to memory holding consecutive tag values,
00138      *            one for each passed entity.
00139      */
00140     virtual ErrorCode set_data( SequenceManager* seqman,
00141                                 Error* error_handler,
00142                                 const Range& entities,
00143                                 const void* data );
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 num_entities Length of \c entities array
00152      *\param data_ptrs Array of pointers to tag values, one pointer
00153      *                 for each passed entity.
00154      *\param data_lengths One value for each entity specifying the
00155      *                length of the tag value for the corresponding
00156      *                entity.  Array is required for variable-length
00157      *                tags and is ignored for fixed-length tags.
00158      */
00159     virtual ErrorCode set_data( SequenceManager* seqman,
00160                                 Error* error_handler,
00161                                 const EntityHandle* entities,
00162                                 size_t num_entities,
00163                                 void const* const* data_ptrs,
00164                                 const int* data_lengths );
00165 
00166     /**\brief Set tag value for passed entities
00167      *
00168      * Store tag data or update stored tag values
00169      *
00170      *\param seqman    Pointer to mesh entity database
00171      *\param entities  Entity handles for which to store tag data
00172      *\param data_ptrs Array of pointers to tag values, one pointer
00173      *                 for each passed entity.
00174      *\param data_lengths One value for each entity specifying the
00175      *                length of the tag value for the corresponding
00176      *                entity.  Array is required for variable-length
00177      *                tags and is ignored for fixed-length tags.
00178      */
00179     virtual ErrorCode set_data( SequenceManager* seqman,
00180                                 Error* error_handler,
00181                                 const Range& entities,
00182                                 void const* const* data_ptrs,
00183                                 const int* data_lengths );
00184 
00185     /**\brief Set tag value for passed entities
00186      *
00187      * Store tag data or update stored tag values.
00188      *
00189      *\param seqman    Pointer to mesh entity database
00190      *\param entities  Entity handles for which to store tag data
00191      *\param num_entities Length of \c entities array
00192      *\param value_ptr Pointer to a single tag value which is to be
00193      *                 stored for each of the passed entities.
00194      *\param value_len Length of tag value in bytes.  Ignored for
00195      *                 fixed-length tags.  Required for variable-
00196      *                 length tags.
00197      */
00198     virtual ErrorCode clear_data( SequenceManager* seqman,
00199                                   Error* error_handler,
00200                                   const EntityHandle* entities,
00201                                   size_t num_entities,
00202                                   const void* value_ptr,
00203                                   int value_len = 0 );
00204 
00205     /**\brief Set tag value for passed entities
00206      *
00207      * Store tag data or update stored tag values.
00208      *
00209      *\param seqman    Pointer to mesh entity database
00210      *\param entities  Entity handles for which to store tag data
00211      *\param value_ptr Pointer to a single tag value which is to be
00212      *                 stored for each of the passed entities.
00213      *\param value_len Length of tag value in bytes.  Ignored for
00214      *                 fixed-length tags.  Required for variable-
00215      *                 length tags.
00216      */
00217     virtual ErrorCode clear_data( SequenceManager* seqman,
00218                                   Error* error_handler,
00219                                   const Range& entities,
00220                                   const void* value_ptr,
00221                                   int value_len = 0 );
00222 
00223     /**\brief Remove/clear tag data for entities
00224      *
00225      * Remove tag values from entities.
00226      *
00227      *\param seqman    Pointer to mesh entity database
00228      *\param entities  Entity handles for which to store tag data
00229      *\param num_entities Length of \c entities array
00230      */
00231     virtual ErrorCode remove_data( SequenceManager* seqman,
00232                                    Error* error_handler,
00233                                    const EntityHandle* entities,
00234                                    size_t num_entities );
00235 
00236     /**\brief Remove/clear tag data for entities
00237      *
00238      * Remove tag values from entities.
00239      *
00240      *\param seqman    Pointer to mesh entity database
00241      *\param entities  Entity handles for which to store tag data
00242      */
00243     virtual ErrorCode remove_data( SequenceManager* seqman, Error* error_handler, const Range& entities );
00244 
00245     /**\brief Access tag data via direct pointer into contiguous blocks
00246      *
00247      * Iteratively obtain direct access to contiguous blocks of tag
00248      * storage.  This function cannot be used with bit tags because
00249      * of the compressed bit storage.  This function cannot be used
00250      * with variable length tags because it does not provide a mechanism
00251      * to determine the length of the value for each entity.  This
00252      * function may be used with sparse tags, but if it is used, it
00253      * will return data for a single entity at a time.
00254      *
00255      *\param iter        As input, the first entity for which to return
00256      *                   data.  As output, one past the last entity for
00257      *                   which data was returned.
00258      *\param end         One past the last entity for which data is desired
00259      *\param data_ptr    Output: pointer to tag storage.
00260      *\param allocate    If true, allocate space for this tag as part of this call, else don't
00261      *
00262      *\Note If this function is called for entities for which no tag value
00263      *      has been set, but for which a default value exists, it will
00264      *      force the allocation of explicit storage for each such entity
00265      *      even though MOAB would normally not explicitly store tag values
00266      *      for such entities.
00267      */
00268     virtual ErrorCode tag_iterate( SequenceManager* seqman,
00269                                    Error* error_handler,
00270                                    Range::iterator& iter,
00271                                    const Range::iterator& end,
00272                                    void*& data_ptr,
00273                                    bool allocate = true );
00274 
00275     /**\brief Get all tagged entities
00276      *
00277      * Get the list of entities for which the a tag value has been set,
00278      * or a close approximation if the tag storage scheme cannot
00279      * accurately determine exactly which entities have explicit values.
00280      *
00281      *\param seqman   Pointer to entity storage database
00282      *\param output_entities Results *appended* to this range
00283      *\param type     Optional entity type.  If specified, search is
00284      *                limited to entities of specified type.
00285      *\param intersect Optional intersect list.  If specified,
00286      *                search is restricted to entities in this list.
00287      */
00288     virtual ErrorCode get_tagged_entities( const SequenceManager* seqman,
00289                                            Range& output_entities,
00290                                            EntityType type        = MBMAXTYPE,
00291                                            const Range* intersect = 0 ) const;
00292 
00293     /**\brief Count all tagged entities
00294      *
00295      * Count the entities for which the a tag value has been set,
00296      * or a close approximation if the tag storage scheme cannot
00297      * accurately determine exactly which entities have explicit values.
00298      *
00299      *\param seqman   Pointer to entity storage database
00300      *\param output_count This is *incremented* for each detected entity.
00301      *\param type     Optional entity type.  If specified, search is
00302      *                limited to entities of specified type.
00303      *\param intersect Optional intersect list.  If specified,
00304      *                search is restricted to entities in this list.
00305      */
00306     virtual ErrorCode num_tagged_entities( const SequenceManager* seqman,
00307                                            size_t& output_count,
00308                                            EntityType type        = MBMAXTYPE,
00309                                            const Range* intersect = 0 ) const;
00310 
00311     /**\brief Get all tagged entities with tag value
00312      *
00313      * Get the list of entities which have the specified tag value.
00314      *
00315      *\param seqman   Pointer to entity storage database
00316      *\param output_entities Results *appended* to this range
00317      *\param value    Pointer to tag value
00318      *\param value_bytes Size of tag value in bytes.
00319      *\param type     Optional entity type.  If specified, search is
00320      *                limited to entities of specified type.
00321      *\param intersect_entities Optional intersect list.  If specified,
00322      *                search is restricted to entities in this list.
00323      */
00324     virtual ErrorCode find_entities_with_value( const SequenceManager* seqman,
00325                                                 Error* error_handler,
00326                                                 Range& output_entities,
00327                                                 const void* value,
00328                                                 int value_bytes                 = 0,
00329                                                 EntityType type                 = MBMAXTYPE,
00330                                                 const Range* intersect_entities = 0 ) const;
00331 
00332     /**\brief Check if entity is tagged */
00333     virtual bool is_tagged( const SequenceManager*, EntityHandle h ) const;
00334 
00335     /**\brief Get memory use for tag data.
00336      *
00337      */
00338     virtual ErrorCode get_memory_use( const SequenceManager* seqman,
00339                                       unsigned long& total,
00340                                       unsigned long& per_entity ) const;
00341 
00342   private:
00343     MeshTag( const MeshTag& );
00344     MeshTag& operator=( const MeshTag& );
00345     std::vector< unsigned char > mValue;
00346 };
00347 
00348 }  // namespace moab
00349 
00350 #endif  // MESH_TAG_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines