moab
|
00001 00017 #ifndef MOAB_WRITE_UTIL_IFACE_HPP 00018 #define MOAB_WRITE_UTIL_IFACE_HPP 00019 00020 00021 #include "moab/Range.hpp" 00022 #include "moab/Compiler.hpp" 00023 #include <vector> 00024 00025 namespace moab { 00026 00028 class MB_DLL_EXPORT WriteUtilIface 00029 { 00030 public: 00031 00033 WriteUtilIface(){} 00034 00036 virtual ~WriteUtilIface(){} 00037 00041 virtual ErrorCode check_doesnt_exist( const char* file_name ) = 0; 00042 00044 virtual ErrorCode gather_entities(Range &all_ents, 00046 const EntityHandle *ent_sets = NULL, 00048 int num_sets = 0 00050 ) = 0; 00051 00062 virtual ErrorCode get_node_coords( 00063 const int num_arrays, 00064 const int num_nodes, 00065 const Range& entities, 00066 Tag node_id_tag, 00067 const int start_node_id, 00068 std::vector<double*>& arrays 00069 ) = 0; 00070 00089 virtual ErrorCode get_node_coords( 00090 const int which_array, 00091 Range::const_iterator begin, 00092 const Range::const_iterator end, 00093 const size_t output_size, 00094 double* const output_array 00095 ) = 0; 00096 00109 virtual ErrorCode get_element_connect( 00110 const int num_elements, 00111 const int verts_per_element, 00112 Tag node_id_tag, 00113 const Range& entities, 00114 Tag element_id_tag, 00115 int start_element_id, 00116 int* array, 00117 bool add_sizes = false 00118 ) = 0; 00119 00148 virtual ErrorCode get_element_connect( 00149 Range::const_iterator begin, 00150 const Range::const_iterator end, 00151 const int vertices_per_elem, 00152 Tag node_id_tag, 00153 const size_t array_size, 00154 int *const element_array, 00155 bool add_sizes = false 00156 ) = 0; 00157 00183 virtual ErrorCode get_element_connect( 00184 Range::const_iterator begin, 00185 const Range::const_iterator end, 00186 const int vertices_per_elem, 00187 const size_t array_size, 00188 EntityHandle *const element_array 00189 ) = 0; 00190 00191 00199 virtual ErrorCode get_poly_connect_size( 00200 Range::const_iterator begin, 00201 const Range::const_iterator end, 00202 int& connectivity_size 00203 ) = 0; 00204 00205 00246 virtual ErrorCode get_poly_connect( 00247 Range::const_iterator& iter, 00248 const Range::const_iterator end, 00249 const Tag node_id_tag, 00250 size_t& element_array_len, 00251 int *const element_array, 00252 size_t& index_array_len, 00253 int *const index_array, 00254 int& index_offset 00255 ) = 0; 00256 00262 virtual ErrorCode gather_nodes_from_elements( 00263 const Range& elements, 00264 const Tag node_bit_mark_tag, 00265 Range& nodes 00266 ) = 0; 00267 00274 virtual ErrorCode assign_ids(Range &elements, 00275 Tag id_tag, 00276 const int start_id) = 0; 00277 00278 00290 virtual ErrorCode get_adjacencies( 00291 EntityHandle entity, 00292 Tag id_tag, 00293 std::vector<int>& adj 00294 ) = 0; 00295 00296 00297 virtual ErrorCode get_adjacencies( EntityHandle entity, 00298 const EntityHandle*& adj_array, 00299 int& num_adj ) = 0; 00300 00301 00314 template <typename T> static inline 00315 void reorder( const int* order, T* conn, int num_elem, int node_per_elem ); 00316 00317 00337 virtual ErrorCode 00338 get_tag_list( std::vector<Tag>& result_list, 00339 const Tag* user_tag_list = 0, 00340 int user_tag_list_length = 0, 00341 bool include_variable_length_tags = true ) = 0; 00342 00343 enum EntityListType { 00344 CONTENTS = 0, 00345 CHILDREN = 1, 00346 PARENTS = 2, 00347 TOPOLOGICAL = 1 00348 }; 00349 00350 /*\brief Get pointers to internal storage of entity data 00351 * 00352 * Get pointers to element connectivity or set content storage. 00353 *\param query_begin Start of range of entities for which to return results 00354 *\param query_end End of range of entities for which to return results. 00355 *\param output_pointer_array Result list of pointers. Points to either 00356 * element connectivity or set contents. Note: set contents 00357 * may be in range-compacted format. 00358 *\param lengths Optional per-entity length of list. If passed, then 00359 * always set, for each entity, to the number of values in the 00360 * array passed back in \c output_pointer_array 00361 *\param relation If entity is entity set, which set data to return 00362 * (contents array, parent array, or child array). If 00363 * entity is an element, then CONTENTS for complete connectivity 00364 * or TOPOLOGICAL for only corner vertices. 00365 *\param flags Optional per-entity flag values. If passed, then 00366 * always set to zero for elements and set to set creation 00367 * flags for entity sets. 00368 *\return MB_STRUCTURED_MESH if one or more input elements are stored as 00369 * structured mesh and therefore do not have explicit storage. 00370 * MB_TYPE_OUT_OF_RANGE if called for vertices. 00371 */ 00372 virtual ErrorCode 00373 get_entity_list_pointers( Range::const_iterator query_begin, 00374 Range::const_iterator query_end, 00375 EntityHandle const* * output_pointer_array, 00376 EntityListType relation = CONTENTS, 00377 int* lengths = 0, 00378 unsigned char* flags = 0 ) = 0; 00379 00380 /*\brief Get pointers to internal storage of entity data 00381 * 00382 * Get pointers to element connectivity or set content storage. 00383 *\param entities Pointer to list of entities for which to return results 00384 *\param num_entities Number of entities in list 00385 *\param output_pointer_array Result list of pointers. Points to either 00386 * element connectivity or set contents. Note: set contents 00387 * may be in range-compacted format. 00388 *\param lengths Optional per-entity length of list. If passed, then 00389 * always set, for each entity, to the number of values in the 00390 * array passed back in \c output_pointer_array 00391 *\param relation If entity is entity set, which set data to return 00392 * (contents array, parent array, or child array). If 00393 * entity is an element, then CONTENTS for complete connectivity 00394 * or TOPOLOGICAL for only corner vertices. 00395 *\param flags Optional per-entity flag values. If passed, then 00396 * always set to zero for elements and set to set creation 00397 * flags for entity sets. 00398 *\return MB_STRUCTURED_MESH if one or more input elements are stored as 00399 * structured mesh and therefore do not have explicit storage. 00400 * MB_TYPE_OUT_OF_RANGE if called for vertices. 00401 */ 00402 virtual ErrorCode 00403 get_entity_list_pointers( EntityHandle const* entities, 00404 int num_entities, 00405 EntityHandle const* * output_pointer_array, 00406 EntityListType relation = CONTENTS, 00407 int* lengths = 0, 00408 unsigned char* flags = 0 ) = 0; 00409 00413 virtual ErrorCode report_error( const std::string& error ) = 0; 00414 00417 virtual ErrorCode report_error( const char* error, ... ) MB_PRINTF(1) = 0; 00418 00419 }; 00420 00421 00422 template <typename T> inline 00423 void WriteUtilIface::reorder( const int* order, T* conn, 00424 int num_elem, int node_per_elem ) 00425 { 00426 std::vector<T> elem(node_per_elem); 00427 T* const end = conn + num_elem*node_per_elem; 00428 while (conn != end) { 00429 std::copy( conn, conn+node_per_elem, elem.begin() ); 00430 for (int j = 0; j < node_per_elem; ++j, ++conn) 00431 *conn = elem[order[j]]; 00432 } 00433 } 00434 00435 } // namespace moab 00436 00437 #endif 00438 00439