Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
UnstructuredElemSeq.cpp
Go to the documentation of this file.
2 #include "SequenceData.hpp"
3 #include "moab/CN.hpp"
4 
5 namespace moab
6 {
7 
9  EntityID entity_count,
10  unsigned nodes_per_entity,
11  SequenceData* dat )
12  : ElementSequence( shandle, entity_count, nodes_per_entity, dat )
13 {
14 }
15 
17  EntityID entity_count,
18  unsigned nodes_per_entity,
19  EntityID data_size )
20  : ElementSequence( shandle,
21  entity_count,
22  nodes_per_entity,
23  new SequenceData( 1, shandle, shandle + data_size - 1 ) )
24 {
25  data()->create_sequence_data( 0, nodes_per_entity * sizeof( EntityHandle ) );
26 }
27 
29 
31 {
32  return nodes_per_element();
33 }
34 
36 {
37  if( here <= start_handle() || here > end_handle() ) return 0;
38 
39  return new UnstructuredElemSeq( *this, here );
40 }
41 
43 {
44  int esize = nodes_per_element() * sizeof( EntityHandle );
45  return data()->subset( start, end, &esize );
46 }
47 
48 void UnstructuredElemSeq::get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const
49 {
50  bytes_per_entity = nodes_per_element() * sizeof( EntityHandle );
51  size_of_sequence = sizeof( *this );
52 }
53 
55  std::vector< EntityHandle >& connect,
56  bool topological ) const
57 {
58  EntityHandle const* conn = get_array() + nodes_per_element() * ( handle - start_handle() );
59  int len = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element();
60  connect.reserve( connect.size() + len );
61  std::copy( conn, conn + len, std::back_inserter( connect ) );
62  return MB_SUCCESS;
63 }
64 
66  EntityHandle const*& conn_ptr,
67  int& len,
68  bool topological,
69  std::vector< EntityHandle >* ) const
70 {
71  conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() );
72  len = topological ? CN::VerticesPerEntity( type() ) : nodes_per_element();
73  return MB_SUCCESS;
74 }
75 
76 ErrorCode UnstructuredElemSeq::set_connectivity( EntityHandle handle, EntityHandle const* connect, int connect_length )
77 {
78  if( (unsigned)connect_length != nodes_per_element() ) return MB_INDEX_OUT_OF_RANGE;
79  EntityHandle* conn_ptr = get_array() + nodes_per_element() * ( handle - start_handle() );
80  std::copy( connect, connect + connect_length, conn_ptr );
81  return MB_SUCCESS;
82 }
83 
85 {
86  return get_array();
87 }
88 
90 {
91  return EntitySequence::append_entities( count );
92 }
93 
95 {
96  return EntitySequence::prepend_entities( count );
97 }
98 
99 } // namespace moab