LCOV - code coverage report
Current view: top level - src - WriteUtil.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 1 1 100.0 %
Date: 2020-12-16 07:07:30 Functions: 1 1 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : #ifndef MB_WRITE_UTIL_HPP
      17                 :            : #define MB_WRITE_UTIL_HPP
      18                 :            : 
      19                 :            : #ifndef IS_BUILDING_MB
      20                 :            : #error "WriteUtil.hpp isn't supposed to be included into an application"
      21                 :            : #endif
      22                 :            : 
      23                 :            : #include "moab/WriteUtilIface.hpp"
      24                 :            : 
      25                 :            : namespace moab
      26                 :            : {
      27                 :            : 
      28                 :            : class Core;
      29                 :            : 
      30                 :            : class WriteUtil : public WriteUtilIface
      31                 :            : {
      32                 :            :   private:
      33                 :            :     //! Pointer to the Core
      34                 :            :     Core* mMB;
      35                 :            : 
      36                 :            :   public:
      37                 :            :     //! Constructor takes Core pointer
      38                 :            :     WriteUtil( Core* mdb );
      39                 :            : 
      40                 :            :     //! Destructor
      41         [ -  + ]:        188 :     ~WriteUtil() {}
      42                 :            : 
      43                 :            :     //! Check if the specified file already exists.
      44                 :            :     //! Returns MB_SUCCESS if file does not exist, MB_ALREADY_ALLOCATED
      45                 :            :     //! if file does exist, or MB_FAILURE for some other error condition.
      46                 :            :     virtual ErrorCode check_doesnt_exist( const char* file_name );
      47                 :            : 
      48                 :            :     //! Gather all entities in the mesh, or in the sets specified
      49                 :            :     virtual ErrorCode gather_entities(
      50                 :            :         Range& all_ents,                     /**< range in which entities are returned */
      51                 :            :         const EntityHandle* ent_sets = NULL, /**< entity sets whose contents are to be gathered */
      52                 :            :         const int num_sets           = 0 /**< number of sets in list */ );
      53                 :            : 
      54                 :            :     //! Gets arrays for coordinate data from the MB
      55                 :            :     ErrorCode get_node_coords( const int num_arrays, const int num_nodes, const Range& entities, Tag node_id_tag,
      56                 :            :                                const int start_node_id, std::vector< double* >& arrays );
      57                 :            : 
      58                 :            :     /** Get an array of coordinate values for nodes
      59                 :            :      *
      60                 :            :      * Given a range of node handles, retrieve a single or multiple coordinate
      61                 :            :      * value(s) for each.
      62                 :            :      *
      63                 :            :      * Failure conditions:
      64                 :            :      *  - invalid entity handles (not vertices, non-existent entity, etc.)
      65                 :            :      *  - range is empty (<code>iter == end</code>)
      66                 :            :      *  - <code>output_array</code> is null
      67                 :            :      *  - insufficient space in <code>output_array</code>
      68                 :            :      *
      69                 :            :      *\param which_array  The coordinate to retrieve (0-&gt;X, 1-&gt;Y, 2-&gt;Z, -1-&gt;all)
      70                 :            :      *\param begin        The first node handle.
      71                 :            :      *\param end          One past the last node handle.
      72                 :            :      *\param output_size  The size of <code>output_array</code>.
      73                 :            :      *\param output_array The memory in which to write the node coordinates.
      74                 :            :      *\author Jason Kraftcheck
      75                 :            :      */
      76                 :            :     ErrorCode get_node_coords( const int which_array, Range::const_iterator begin, const Range::const_iterator& end,
      77                 :            :                                const size_t output_size, double* const output_array );
      78                 :            : 
      79                 :            :     /** Get connectivity for elements
      80                 :            :      *
      81                 :            :      * Get the connectivity list for a range of elements.
      82                 :            :      *
      83                 :            :      *\param num_elements Number of elements for which connectivity is needed
      84                 :            :      *\param vertices_per_elem Number of vertices to retrieve for each
      85                 :            :      *                    element.
      86                 :            :      *\param node_id_tag  A tag with integer values.
      87                 :            :      *\param entities Entities being queried
      88                 :            :      *\param element_id_tag If non-zero, elements are tagged with an id starting at start_element_id
      89                 :            :      *\param start_element_id Starting id value for element_id_tag
      90                 :            :      *\param add_sizes If true, writes size of connect array before connectivity in array
      91                 :            :      */
      92                 :            :     ErrorCode get_element_connect( const int num_elements, const int verts_per_element, Tag node_id_tag,
      93                 :            :                                    const Range& entities, Tag element_id_tag, int start_element_id, int* array,
      94                 :            :                                    bool add_sizes = false );
      95                 :            : 
      96                 :            :     /** Get connectivity for elements
      97                 :            :      *
      98                 :            :      * Get the connectivity list for a range of elements.
      99                 :            :      *
     100                 :            :      * Failure cases:
     101                 :            :      *  - Passed range is empty (<code>begin == end</code>).
     102                 :            :      *  - <code>vertices_per_elem</code> is less than one
     103                 :            :      *  - <code>element_array</code> is null.
     104                 :            :      *  - The range contains invalid handles (non-existent entities,
     105                 :            :      *      not an element, etc.)
     106                 :            :      *  - Retrieving ID tag for an entity failed.
     107                 :            :      *  - Insufficient space in passed array.
     108                 :            :      *
     109                 :            :      *\param begin        The first element handle
     110                 :            :      *\param end          One past the last element handle
     111                 :            :      *\param vertices_per_elem Number of vertices to retrieve for each
     112                 :            :      *                    element. If the element has more vertices, the
     113                 :            :      *                    element connectivity will be truncated. If
     114                 :            :      *                    <code>vertices_per_elem</code> is greater than the
     115                 :            :      *                    number of nodes for an element, the data will be
     116                 :            :      *                    padded with zeros.
     117                 :            :      *\param node_id_tag  A tag with integer values.
     118                 :            :      *\param array_size   The length of <code>element_array</code>
     119                 :            :      *\param element_array The memory location at which to store the
     120                 :            :      *                    connectivity list.
     121                 :            :      *\param add_sizes If true, writes size of connect array before connectivity in array
     122                 :            :      *\author Jason Kraftcheck
     123                 :            :      */
     124                 :            :     ErrorCode get_element_connect( Range::const_iterator begin, const Range::const_iterator& end,
     125                 :            :                                    const int vertices_per_elem, Tag node_id_tag, const size_t array_size,
     126                 :            :                                    int* const element_array, bool add_sizes = false );
     127                 :            : 
     128                 :            :     /** Get connectivity for elements
     129                 :            :      *
     130                 :            :      * Get the connectivity list for a range of elements.
     131                 :            :      *
     132                 :            :      * Failure cases:
     133                 :            :      *  - Passed range is empty (<code>begin == end</code>).
     134                 :            :      *  - <code>vertices_per_elem</code> is less than one
     135                 :            :      *  - <code>element_array</code> is null.
     136                 :            :      *  - The range contains invalid handles (non-existent entities,
     137                 :            :      *      not an element, etc.)
     138                 :            :      *  - Insufficient space in passed array.
     139                 :            :      *
     140                 :            :      *\param begin        The first element handle
     141                 :            :      *\param end          One past the last element handle
     142                 :            :      *\param vertices_per_elem Number of vertices to retrieve for each
     143                 :            :      *                    element. If the element has more vertices, the
     144                 :            :      *                    element connectivity will be truncated. If
     145                 :            :      *                    <code>vertices_per_elem</code> is greater than the
     146                 :            :      *                    number of nodes for an element, the data will be
     147                 :            :      *                    padded with zeros.
     148                 :            :      *\param array_size   The length of <code>element_array</code>
     149                 :            :      *\param element_array The memory location at which to store the
     150                 :            :      *                    connectivity list.
     151                 :            :      *\author Jason Kraftcheck
     152                 :            :      */
     153                 :            :     virtual ErrorCode get_element_connect( Range::const_iterator begin, const Range::const_iterator& end,
     154                 :            :                                            const int vertices_per_elem, const size_t array_size,
     155                 :            :                                            EntityHandle* const element_array );
     156                 :            : 
     157                 :            :     /** Get poly (polygon or polyhedron) connectivity size
     158                 :            :      *\param begin  First iterator in range of poly
     159                 :            :      *\param end    One past last in range of poly.
     160                 :            :      *\param connectivity_size  The length of the connectivity list
     161                 :            :      *              For the specified range of polyhedra.
     162                 :            :      *\author Jason Kraftcheck
     163                 :            :      */
     164                 :            :     virtual ErrorCode get_poly_connect_size( Range::const_iterator begin, const Range::const_iterator& end,
     165                 :            :                                              int& connectivity_size );
     166                 :            : 
     167                 :            :     /** Get poly (polygon or polyhedron) connectivity.
     168                 :            :      *
     169                 :            :      * This function will add as many polys as possible to the
     170                 :            :      * passed arrays given the sizes of those arrays. It will
     171                 :            :      * then pass back position at which it stopped and the sizes
     172                 :            :      * of the data written to the arrays.
     173                 :            :      *
     174                 :            :      *\param iter               As input, the first element handle.
     175                 :            :      *                          As output, one past the last element handle
     176                 :            :      *                          for which data was written to the arrays.
     177                 :            :      *\param end                The iterator at which to stop.
     178                 :            :      *\param node_id_tag        A tag with integer values.
     179                 :            :      *\param element_array_len  As input, length of <code>element_array</code>.
     180                 :            :      *                          As output, the number of entries written in that
     181                 :            :      *                          array.
     182                 :            :      *\param element_array      The memory location at which to store the
     183                 :            :      *                          connectivity list.
     184                 :            :      *\param index_array_len    As input, the length of <code>index_array</code>.
     185                 :            :      *                          As output, the number of entries written in that
     186                 :            :      *                          array.
     187                 :            :      *\param index_array        The memory location at which to store offsets.
     188                 :            :      *\param index_offset       Value to offset (add to) index values. As output
     189                 :            :      *                          the input value plus the amount of data
     190                 :            :      *                          written to the element array. (The value you
     191                 :            :      *                          presumably want to pass to the next call.)
     192                 :            :      *\author Jason Kraftcheck
     193                 :            :      */
     194                 :            :     virtual ErrorCode get_poly_connect( Range::const_iterator& iter, const Range::const_iterator& end,
     195                 :            :                                         const Tag node_id_tag, size_t& handle_array_len, int* const handle_array,
     196                 :            :                                         size_t& index_array_len, int* const index_array, int& index_offset );
     197                 :            : 
     198                 :            :     //! Get a set of nodes that represent a set of elements
     199                 :            :     ErrorCode gather_nodes_from_elements( const Range& elements, const Tag node_bit_mark_tag, Range& nodes );
     200                 :            : 
     201                 :            :     //! Assign ids to input elements starting with start_id, written to id_tag
     202                 :            :     //! if zero, assigns to GLOBAL_ID_TAG_NAME
     203                 :            :     ErrorCode assign_ids( Range& elements, Tag id_tag, const int start_id );
     204                 :            : 
     205                 :            :     /** Get explicit adjacencies
     206                 :            :      *
     207                 :            :      * Get explicit adjacences stored in database.
     208                 :            :      * Does not create any explicit adjacencies or search for
     209                 :            :      * implicit ones.
     210                 :            :      *
     211                 :            :      *\param entity  The entity to retrieve adjacencies for.
     212                 :            :      *\param id_tag  The global ID tag
     213                 :            :      *\param adj     The output list of global IDs of adjacent entities.
     214                 :            :      */
     215                 :            :     ErrorCode get_adjacencies( EntityHandle entity, Tag id_tag, std::vector< int >& adj );
     216                 :            : 
     217                 :            :     ErrorCode get_adjacencies( EntityHandle entity, const EntityHandle*& adj_array, int& num_adj );
     218                 :            : 
     219                 :            :     /**\brief Get list of tags to write.
     220                 :            :      *
     221                 :            :      * Get the list of tags to write to the file, possibly using
     222                 :            :      * an optional user-specified tag list. This function consolidates
     223                 :            :      * some common code for file writers to use to figure out what
     224                 :            :      * tag data to write to the file. It provides the following features:
     225                 :            :      *  o filter list based on user-specified array of tag handles
     226                 :            :      *  o filter internal tags (those for which the name is prefixed with
     227                 :            :      *    two underscore characters)
     228                 :            :      *  o filter anonymous tags
     229                 :            :      *  o optionally filter variable-length tags.
     230                 :            :      *
     231                 :            :      *\author Jason Kraftcheck
     232                 :            :      *\param result_list List of tag handles for which to write data
     233                 :            :      *\param user_tag_list Optional array of tag handles passed by user
     234                 :            :      *                     to write to file.
     235                 :            :      *\param include_variable_length_tags If false, return only fixed-length
     236                 :            :      *                                    tags.
     237                 :            :      */
     238                 :            :     virtual ErrorCode get_tag_list( std::vector< Tag >& result_list, const Tag* user_tag_list = 0,
     239                 :            :                                     int user_tag_list_length = 0, bool include_variable_length_tags = true );
     240                 :            : 
     241                 :            :     /*\brief Get pointers to internal storage of entity data
     242                 :            :      *
     243                 :            :      * Get pointers to element connectivity or set content storage.
     244                 :            :      *\param query_begin Start of range of entities for which to return results
     245                 :            :      *\param query_end   End of range of entities for which to return results.
     246                 :            :      *\param output_pointer_array Result list of pointers. Points to either
     247                 :            :      *          element connectivity or set contents. Note: set contents
     248                 :            :      *          may be in range-compacted format.
     249                 :            :      *\param lengths Optional per-entity length of list. If passed, then
     250                 :            :      *          always set, for each entity, to the number of values in the
     251                 :            :      *          array passed back in \c output_pointer_array
     252                 :            :      *\param relation If entity is entity set, which set data to return
     253                 :            :      *          (contents array, parent array, or child array). If
     254                 :            :      *          entity is an element, then CONTENTS for complete connectivity
     255                 :            :      *          or TOPOLOGICAL for only corner vertices.
     256                 :            :      *\param flags Optional per-entity flag values. If passed, then
     257                 :            :      *          always set to zero for elements and set to set creation
     258                 :            :      *          flags for entity sets.
     259                 :            :      *\return MB_STRUCTURED_MESH if one or more input elements are stored as
     260                 :            :      *          structured mesh and therefore do not have explicit storage.
     261                 :            :      *        MB_TYPE_OUT_OF_RANGE if called for vertices.
     262                 :            :      */
     263                 :            :     virtual ErrorCode get_entity_list_pointers( Range::const_iterator query_begin, Range::const_iterator query_end,
     264                 :            :                                                 EntityHandle const** output_pointer_array,
     265                 :            :                                                 EntityListType relation = CONTENTS, int* lengths = 0,
     266                 :            :                                                 unsigned char* flags = 0 );
     267                 :            : 
     268                 :            :     /*\brief Get pointers to internal storage of entity data
     269                 :            :      *
     270                 :            :      * Get pointers to element connectivity or set content storage.
     271                 :            :      *\param entities Pointer to list of entities for which to return results
     272                 :            :      *\param num_entities Number of entities in list
     273                 :            :      *\param output_pointer_array Result list of pointers. Points to either
     274                 :            :      *          element connectivity or set contents. Note: set contents
     275                 :            :      *          may be in range-compacted format.
     276                 :            :      *\param lengths Optional per-entity length of list. If passed, then
     277                 :            :      *          always set, for each entity, to the number of values in the
     278                 :            :      *          array passed back in \c output_pointer_array
     279                 :            :      *\param relation If entity is entity set, which set data to return
     280                 :            :      *          (contents array, parent array, or child array). If
     281                 :            :      *          entity is an element, then CONTENTS for complete connectivity
     282                 :            :      *          or TOPOLOGICAL for only corner vertices.
     283                 :            :      *\param flags Optional per-entity flag values. If passed, then
     284                 :            :      *          always set to zero for elements and set to set creation
     285                 :            :      *          flags for entity sets.
     286                 :            :      *\return MB_STRUCTURED_MESH if one or more input elements are stored as
     287                 :            :      *          structured mesh and therefore do not have explicit storage.
     288                 :            :      *        MB_TYPE_OUT_OF_RANGE if called for vertices.
     289                 :            :      */
     290                 :            :     virtual ErrorCode get_entity_list_pointers( EntityHandle const* entities, int num_entities,
     291                 :            :                                                 EntityHandle const** output_pointer_array,
     292                 :            :                                                 EntityListType relation = CONTENTS, int* lengths = 0,
     293                 :            :                                                 unsigned char* flags = 0 );
     294                 :            : };
     295                 :            : 
     296                 :            : }  // namespace moab
     297                 :            : 
     298                 :            : #endif

Generated by: LCOV version 1.11