MOAB: Mesh Oriented datABase  (version 5.3.0)
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 (kraftche@cae.wisc.edu)
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, EntityHandle set, int dim,
00067                              std::vector< EntityHandle >& entities, bool recursive ) const;
00068     ErrorCode get_dimension( SequenceManager const* seqman, EntityHandle set, int dim, Range& entities,
00069                              bool recursive ) const;
00070     ErrorCode get_type( SequenceManager const* seqman, EntityHandle set, EntityType type,
00071                         std::vector< EntityHandle >& entities, bool recursive ) const;
00072     ErrorCode get_type( SequenceManager const* seqman, EntityHandle set, EntityType type, Range& entities,
00073                         bool recursive ) const;
00074 
00075     ErrorCode num_entities( SequenceManager const* seqman, EntityHandle set, int& count, bool recursive ) const;
00076     ErrorCode num_dimension( SequenceManager const* seqman, EntityHandle set, int dim, int& count,
00077                              bool recursive ) const;
00078     ErrorCode num_type( SequenceManager const* seqman, EntityHandle set, EntityType type, int& count,
00079                         bool recursive ) const;
00080 
00081     ErrorCode get_parents( SequenceManager const* seqman, EntityHandle of, std::vector< EntityHandle >& parents,
00082                            int num_hops ) const;
00083     ErrorCode get_children( SequenceManager const* seqman, EntityHandle of, std::vector< EntityHandle >& children,
00084                             int num_hops ) const;
00085     ErrorCode get_contained_sets( SequenceManager const* seqman, EntityHandle of, std::vector< EntityHandle >& contents,
00086                                   int num_hops ) const;
00087     ErrorCode num_parents( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00088     ErrorCode num_children( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00089     ErrorCode num_contained_sets( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
00090 
00091   private:
00092     enum SearchType
00093     {
00094         PARENTS,
00095         CHILDREN,
00096         CONTAINED
00097     };
00098 
00099     MeshSetSequence( MeshSetSequence& split_from, EntityHandle split_at ) : EntitySequence( split_from, split_at ) {}
00100 
00101     void initialize( const unsigned* set_flags );
00102 
00103     ErrorCode get_parent_child_meshsets( EntityHandle meshset, SequenceManager const* set_sequences,
00104                                          std::vector< EntityHandle >& results, int num_hops,
00105                                          SearchType link_type ) const;
00106 
00107     static ErrorCode recursive_get_sets( EntityHandle start_set, SequenceManager const* set_sequences,
00108                                          std::vector< const MeshSet* >* sets_out = 0, Range* set_handles_out = 0,
00109                                          std::vector< EntityHandle >* set_handle_vect_out = 0 );
00110     static ErrorCode recursive_get_sets( EntityHandle start_set, SequenceManager* set_sequences,
00111                                          std::vector< MeshSet* >& sets_out );
00112 
00113     enum
00114     {
00115         SET_SIZE = sizeof( MeshSet )
00116     };
00117 
00118     inline const unsigned char* array() const
00119     {
00120         return reinterpret_cast< const unsigned char* >( data()->get_sequence_data( 0 ) );
00121     }
00122 
00123     inline unsigned char* array()
00124     {
00125         return reinterpret_cast< unsigned char* >( data()->get_sequence_data( 0 ) );
00126     }
00127 
00128     inline void allocate_set( unsigned flags, EntityID index )
00129     {
00130         unsigned char* const ptr = array() + index * SET_SIZE;
00131         new( ptr ) MeshSet( flags );
00132     }
00133 
00134     inline void deallocate_set( EntityID index )
00135     {
00136         MeshSet* set = reinterpret_cast< MeshSet* >( array() + SET_SIZE * index );
00137         set->~MeshSet();
00138     }
00139 };
00140 
00141 inline MeshSet* MeshSetSequence::get_set( EntityHandle h )
00142 {
00143     return reinterpret_cast< MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
00144 }
00145 inline const MeshSet* MeshSetSequence::get_set( EntityHandle h ) const
00146 {
00147     return reinterpret_cast< const MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
00148 }
00149 
00150 }  // namespace moab
00151 
00152 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines