Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
MeshSetSequence.hpp
Go to the documentation of this file.
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 Corporation, 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 
00016 /**\file MeshSetSequence.hpp
00017  *\author Jason Kraftcheck ([email protected])
00018  *\date 2007-04-30
00019  */
00020 
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 
00031 class SequenceManager;
00032 
00033 class MeshSetSequence : public EntitySequence
00034 {
00035   public:
00036     MeshSetSequence( EntityHandle start, EntityID count, const unsigned* flags, SequenceData* data );
00037 
00038     MeshSetSequence( EntityHandle start, EntityID count, unsigned flags, SequenceData* data );
00039 
00040     MeshSetSequence( EntityHandle start, EntityID count, const unsigned* flags, EntityID sequence_size );
00041 
00042     MeshSetSequence( EntityHandle start, EntityID count, unsigned flags, EntityID sequence_size );
00043 
00044     virtual ~MeshSetSequence();
00045 
00046     EntitySequence* split( EntityHandle here );
00047 
00048     SequenceData* create_data_subset( EntityHandle, EntityHandle ) const
00049     {
00050         return 0;
00051     }
00052 
00053     ErrorCode pop_back( EntityID count );
00054     ErrorCode pop_front( EntityID count );
00055     ErrorCode push_back( EntityID count, const unsigned* flags );
00056     ErrorCode push_front( EntityID count, const unsigned* flags );
00057 
00058     void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const;
00059     unsigned long get_per_entity_memory_use( EntityHandle first, EntityHandle last ) const;
00060 
00061     inline MeshSet* get_set( EntityHandle h );
00062     inline const MeshSet* get_set( EntityHandle h ) const;
00063 
00064     ErrorCode get_entities( EntityHandle set, std::vector< EntityHandle >& entities ) const;
00065     ErrorCode get_entities( SequenceManager const* seqman, EntityHandle set, Range& entities, bool recursive ) const;
00066     ErrorCode get_dimension( SequenceManager const* seqman,
00067                              EntityHandle set,
00068                              int dim,
00069                              std::vector< EntityHandle >& entities,
00070                              bool recursive ) const;
00071     ErrorCode get_dimension( SequenceManager const* seqman,
00072                              EntityHandle set,
00073                              int dim,
00074                              Range& entities,
00075                              bool recursive ) const;
00076     ErrorCode get_type( SequenceManager const* seqman,
00077                         EntityHandle set,
00078                         EntityType type,
00079                         std::vector< EntityHandle >& entities,
00080                         bool recursive ) const;
00081     ErrorCode get_type( SequenceManager const* seqman,
00082                         EntityHandle set,
00083                         EntityType type,
00084                         Range& entities,
00085                         bool recursive ) const;
00086 
00087     ErrorCode num_entities( SequenceManager const* seqman, EntityHandle set, int& count, bool recursive ) const;
00088     ErrorCode num_dimension( SequenceManager const* seqman,
00089                              EntityHandle set,
00090                              int dim,
00091                              int& count,
00092                              bool recursive ) const;
00093     ErrorCode num_type( SequenceManager const* seqman,
00094                         EntityHandle set,
00095                         EntityType type,
00096                         int& count,
00097                         bool recursive ) const;
00098 
00099     ErrorCode get_parents( SequenceManager const* seqman,
00100                            EntityHandle of,
00101                            std::vector< EntityHandle >& parents,
00102                            int num_hops ) const;
00103     ErrorCode get_children( SequenceManager const* seqman,
00104                             EntityHandle of,
00105                             std::vector< EntityHandle >& children,
00106                             int num_hops ) const;
00107     ErrorCode get_contained_sets( SequenceManager const* seqman,
00108                                   EntityHandle of,
00109                                   std::vector< EntityHandle >& contents,
00110                                   int num_hops ) const;
00111     ErrorCode num_parents( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00112     ErrorCode num_children( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00113     ErrorCode num_contained_sets( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00114 
00115   private:
00116     enum SearchType
00117     {
00118         PARENTS,
00119         CHILDREN,
00120         CONTAINED
00121     };
00122 
00123     MeshSetSequence( MeshSetSequence& split_from, EntityHandle split_at ) : EntitySequence( split_from, split_at ) {}
00124 
00125     void initialize( const unsigned* set_flags );
00126 
00127     ErrorCode get_parent_child_meshsets( EntityHandle meshset,
00128                                          SequenceManager const* set_sequences,
00129                                          std::vector< EntityHandle >& results,
00130                                          int num_hops,
00131                                          SearchType link_type ) const;
00132 
00133     static ErrorCode recursive_get_sets( EntityHandle start_set,
00134                                          SequenceManager const* set_sequences,
00135                                          std::vector< const MeshSet* >* sets_out          = 0,
00136                                          Range* set_handles_out                           = 0,
00137                                          std::vector< EntityHandle >* set_handle_vect_out = 0 );
00138     static ErrorCode recursive_get_sets( EntityHandle start_set,
00139                                          SequenceManager* set_sequences,
00140                                          std::vector< MeshSet* >& sets_out );
00141 
00142     enum
00143     {
00144         SET_SIZE = sizeof( MeshSet )
00145     };
00146 
00147     inline const unsigned char* array() const
00148     {
00149         return reinterpret_cast< const unsigned char* >( data()->get_sequence_data( 0 ) );
00150     }
00151 
00152     inline unsigned char* array()
00153     {
00154         return reinterpret_cast< unsigned char* >( data()->get_sequence_data( 0 ) );
00155     }
00156 
00157     inline void allocate_set( unsigned flags, EntityID index )
00158     {
00159         unsigned char* const ptr = array() + index * SET_SIZE;
00160         new( ptr ) MeshSet( flags );
00161     }
00162 
00163     inline void deallocate_set( EntityID index )
00164     {
00165         MeshSet* set = reinterpret_cast< MeshSet* >( array() + SET_SIZE * index );
00166         set->~MeshSet();
00167     }
00168 };
00169 
00170 inline MeshSet* MeshSetSequence::get_set( EntityHandle h )
00171 {
00172     return reinterpret_cast< MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
00173 }
00174 inline const MeshSet* MeshSetSequence::get_set( EntityHandle h ) const
00175 {
00176     return reinterpret_cast< const MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
00177 }
00178 
00179 }  // namespace moab
00180 
00181 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines