moab
|
00001 /* 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00021 #ifndef MESH_SET_SEQUENCE_HPP 00022 #define MESH_SET_SEQUENCE_HPP 00023 00024 #include "EntitySequence.hpp" 00025 #include "MeshSet.hpp" 00026 #include "SequenceData.hpp" 00027 00028 namespace moab { 00029 00030 class SequenceManager; 00031 00032 class MeshSetSequence : public EntitySequence 00033 { 00034 public: 00035 00036 MeshSetSequence( EntityHandle start, 00037 EntityID count, 00038 const unsigned* flags, 00039 SequenceData* data ); 00040 00041 MeshSetSequence( EntityHandle start, 00042 EntityID count, 00043 unsigned flags, 00044 SequenceData* data ); 00045 00046 MeshSetSequence( EntityHandle start, 00047 EntityID count, 00048 const unsigned* flags, 00049 EntityID sequence_size ); 00050 00051 MeshSetSequence( EntityHandle start, 00052 EntityID count, 00053 unsigned flags, 00054 EntityID sequence_size ); 00055 00056 virtual ~MeshSetSequence(); 00057 00058 EntitySequence* split( EntityHandle here ); 00059 00060 SequenceData* create_data_subset( EntityHandle, EntityHandle ) const 00061 { return 0; } 00062 00063 ErrorCode pop_back( EntityID count ); 00064 ErrorCode pop_front( EntityID count ); 00065 ErrorCode push_back( EntityID count, const unsigned* flags ); 00066 ErrorCode push_front( EntityID count, const unsigned* flags ); 00067 00068 void get_const_memory_use( unsigned long& bytes_per_entity, 00069 unsigned long& size_of_sequence ) const; 00070 unsigned long get_per_entity_memory_use( EntityHandle first, 00071 EntityHandle last ) const; 00072 00073 00074 inline MeshSet* get_set( EntityHandle h ); 00075 inline const MeshSet* get_set( EntityHandle h ) const; 00076 00077 ErrorCode get_entities( EntityHandle set, std::vector<EntityHandle>& entities ) const; 00078 ErrorCode get_entities( SequenceManager const* seqman, EntityHandle set, Range& entities, bool recursive ) const; 00079 ErrorCode get_dimension( SequenceManager const* seqman, EntityHandle set, int dim, std::vector<EntityHandle>& entities, bool recursive ) const; 00080 ErrorCode get_dimension( SequenceManager const* seqman, EntityHandle set, int dim, Range& entities, bool recursive ) const; 00081 ErrorCode get_type( SequenceManager const* seqman, EntityHandle set, EntityType type, std::vector<EntityHandle>& entities, bool recursive ) const; 00082 ErrorCode get_type( SequenceManager const* seqman, EntityHandle set, EntityType type, Range& entities, bool recursive ) const; 00083 00084 ErrorCode num_entities( SequenceManager const* seqman, EntityHandle set, int& count, bool recursive ) const; 00085 ErrorCode num_dimension( SequenceManager const* seqman, EntityHandle set, int dim, int& count, bool recursive ) const; 00086 ErrorCode num_type( SequenceManager const* seqman, EntityHandle set, EntityType type, int& count, bool recursive ) const; 00087 00088 ErrorCode get_parents ( SequenceManager const* seqman, EntityHandle of, std::vector<EntityHandle>& parents, int num_hops ) const; 00089 ErrorCode get_children ( SequenceManager const* seqman, EntityHandle of, std::vector<EntityHandle>& children, int num_hops ) const; 00090 ErrorCode get_contained_sets( SequenceManager const* seqman, EntityHandle of, std::vector<EntityHandle>& contents, int num_hops ) const; 00091 ErrorCode num_parents ( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const; 00092 ErrorCode num_children ( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const; 00093 ErrorCode num_contained_sets( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const; 00094 00095 private: 00096 00097 enum SearchType { PARENTS, CHILDREN, CONTAINED }; 00098 00099 MeshSetSequence( MeshSetSequence& split_from, EntityHandle split_at ) 00100 : EntitySequence( split_from, split_at ) 00101 {} 00102 00103 void initialize( const unsigned* set_flags ); 00104 00105 ErrorCode get_parent_child_meshsets( EntityHandle meshset, 00106 SequenceManager const* set_sequences, 00107 std::vector<EntityHandle>& results, 00108 int num_hops, SearchType link_type ) const; 00109 00110 static ErrorCode recursive_get_sets( EntityHandle start_set, 00111 SequenceManager const* set_sequences, 00112 std::vector<const MeshSet*>* sets_out = 0, 00113 Range* set_handles_out = 0, 00114 std::vector<EntityHandle>* set_handle_vect_out = 0 ); 00115 static ErrorCode recursive_get_sets( EntityHandle start_set, 00116 SequenceManager* set_sequences, 00117 std::vector<MeshSet*>& sets_out ); 00118 00119 enum { SET_SIZE = sizeof(MeshSet) }; 00120 00121 inline const unsigned char* array() const 00122 { return reinterpret_cast<const unsigned char*>(data()->get_sequence_data(0)); } 00123 00124 inline unsigned char* array() 00125 { return reinterpret_cast<unsigned char*>(data()->get_sequence_data(0)); } 00126 00127 inline void allocate_set( unsigned flags, EntityID index ) 00128 { 00129 unsigned char* const ptr = array() + index * SET_SIZE; 00130 new (ptr) MeshSet(flags); 00131 } 00132 00133 inline void deallocate_set( EntityID index ) 00134 { 00135 MeshSet* set = reinterpret_cast<MeshSet*>(array() + SET_SIZE * index ); 00136 set->~MeshSet(); 00137 } 00138 }; 00139 00140 inline MeshSet* MeshSetSequence::get_set( EntityHandle h ) 00141 { 00142 return reinterpret_cast<MeshSet*>(array() + SET_SIZE*(h - data()->start_handle())); 00143 } 00144 inline const MeshSet* MeshSetSequence::get_set( EntityHandle h ) const 00145 { 00146 return reinterpret_cast<const MeshSet*>(array() + SET_SIZE*(h - data()->start_handle())); 00147 } 00148 00149 } // namespace moab 00150 00151 #endif