Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
MeshSetSequence.hpp
Go to the documentation of this file.
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 /**\file MeshSetSequence.hpp
17  *\author Jason Kraftcheck ([email protected])
18  *\date 2007-04-30
19  */
20 
21 #ifndef MESH_SET_SEQUENCE_HPP
22 #define MESH_SET_SEQUENCE_HPP
23 
24 #include "EntitySequence.hpp"
25 #include "MeshSet.hpp"
26 #include "SequenceData.hpp"
27 
28 namespace moab
29 {
30 
31 class SequenceManager;
32 
34 {
35  public:
36  MeshSetSequence( EntityHandle start, EntityID count, const unsigned* flags, SequenceData* data );
37 
38  MeshSetSequence( EntityHandle start, EntityID count, unsigned flags, SequenceData* data );
39 
40  MeshSetSequence( EntityHandle start, EntityID count, const unsigned* flags, EntityID sequence_size );
41 
42  MeshSetSequence( EntityHandle start, EntityID count, unsigned flags, EntityID sequence_size );
43 
44  virtual ~MeshSetSequence();
45 
47 
49  {
50  return 0;
51  }
52 
53  ErrorCode pop_back( EntityID count );
54  ErrorCode pop_front( EntityID count );
55  ErrorCode push_back( EntityID count, const unsigned* flags );
56  ErrorCode push_front( EntityID count, const unsigned* flags );
57 
58  void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const;
59  unsigned long get_per_entity_memory_use( EntityHandle first, EntityHandle last ) const;
60 
61  inline MeshSet* get_set( EntityHandle h );
62  inline const MeshSet* get_set( EntityHandle h ) const;
63 
64  ErrorCode get_entities( EntityHandle set, std::vector< EntityHandle >& entities ) const;
65  ErrorCode get_entities( SequenceManager const* seqman, EntityHandle set, Range& entities, bool recursive ) const;
67  EntityHandle set,
68  int dim,
69  std::vector< EntityHandle >& entities,
70  bool recursive ) const;
72  EntityHandle set,
73  int dim,
74  Range& entities,
75  bool recursive ) const;
76  ErrorCode get_type( SequenceManager const* seqman,
77  EntityHandle set,
78  EntityType type,
79  std::vector< EntityHandle >& entities,
80  bool recursive ) const;
81  ErrorCode get_type( SequenceManager const* seqman,
82  EntityHandle set,
83  EntityType type,
84  Range& entities,
85  bool recursive ) const;
86 
87  ErrorCode num_entities( SequenceManager const* seqman, EntityHandle set, int& count, bool recursive ) const;
89  EntityHandle set,
90  int dim,
91  int& count,
92  bool recursive ) const;
93  ErrorCode num_type( SequenceManager const* seqman,
94  EntityHandle set,
95  EntityType type,
96  int& count,
97  bool recursive ) const;
98 
99  ErrorCode get_parents( SequenceManager const* seqman,
100  EntityHandle of,
101  std::vector< EntityHandle >& parents,
102  int num_hops ) const;
103  ErrorCode get_children( SequenceManager const* seqman,
104  EntityHandle of,
105  std::vector< EntityHandle >& children,
106  int num_hops ) const;
108  EntityHandle of,
109  std::vector< EntityHandle >& contents,
110  int num_hops ) const;
111  ErrorCode num_parents( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
112  ErrorCode num_children( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
113  ErrorCode num_contained_sets( SequenceManager const* seqman, EntityHandle of, int& number, int num_hops ) const;
114 
115  private:
117  {
120  CONTAINED
121  };
122 
123  MeshSetSequence( MeshSetSequence& split_from, EntityHandle split_at ) : EntitySequence( split_from, split_at ) {}
124 
125  void initialize( const unsigned* set_flags );
126 
128  SequenceManager const* set_sequences,
129  std::vector< EntityHandle >& results,
130  int num_hops,
131  SearchType link_type ) const;
132 
133  static ErrorCode recursive_get_sets( EntityHandle start_set,
134  SequenceManager const* set_sequences,
135  std::vector< const MeshSet* >* sets_out = 0,
136  Range* set_handles_out = 0,
137  std::vector< EntityHandle >* set_handle_vect_out = 0 );
138  static ErrorCode recursive_get_sets( EntityHandle start_set,
139  SequenceManager* set_sequences,
140  std::vector< MeshSet* >& sets_out );
141 
142  enum
143  {
144  SET_SIZE = sizeof( MeshSet )
145  };
146 
147  inline const unsigned char* array() const
148  {
149  return reinterpret_cast< const unsigned char* >( data()->get_sequence_data( 0 ) );
150  }
151 
152  inline unsigned char* array()
153  {
154  return reinterpret_cast< unsigned char* >( data()->get_sequence_data( 0 ) );
155  }
156 
157  inline void allocate_set( unsigned flags, EntityID index )
158  {
159  unsigned char* const ptr = array() + index * SET_SIZE;
160  new( ptr ) MeshSet( flags );
161  }
162 
163  inline void deallocate_set( EntityID index )
164  {
165  MeshSet* set = reinterpret_cast< MeshSet* >( array() + SET_SIZE * index );
166  set->~MeshSet();
167  }
168 };
169 
171 {
172  return reinterpret_cast< MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
173 }
175 {
176  return reinterpret_cast< const MeshSet* >( array() + SET_SIZE * ( h - data()->start_handle() ) );
177 }
178 
179 } // namespace moab
180 
181 #endif