Mesh Oriented datABase
(version 5.5.1)
An array-based unstructured mesh library
SequenceData.hpp
Go to the documentation of this file.
1
#ifndef SEQUENCE_DATA_HPP
2
#define SEQUENCE_DATA_HPP
3
4
#include "
TypeSequenceManager.hpp
"
5
6
#include <vector>
7
#include <cstdlib>
8
#include <cstring>
9
10
namespace
moab
11
{
12
13
class
SequenceData
14
{
15
public
:
16
typedef
std::vector< EntityHandle >*
AdjacencyDataType
;
17
18
/**\param num_sequence_arrays Number of data arrays needed by the EntitySequence
19
* \param start First handle in this SequenceData
20
* \param end Last handle in this SequenceData
21
*/
22
inline
SequenceData
(
int
num_sequence_arrays,
EntityHandle
start,
EntityHandle
end );
23
24
virtual
~SequenceData
();
25
26
/**\return first handle in this sequence data */
27
EntityHandle
start_handle
()
const
28
{
29
return
startHandle
;
30
}
31
32
/**\return last handle in this sequence data */
33
EntityHandle
end_handle
()
const
34
{
35
return
endHandle
;
36
}
37
38
EntityID
size
()
const
39
{
40
return
endHandle
+ 1 -
startHandle
;
41
}
42
43
/**\return ith array of EnitySequence-specific data */
44
void
*
get_sequence_data
(
int
array_num )
45
{
46
return
arraySet
[-1 - array_num];
47
}
48
/**\return ith array of EnitySequence-specific data */
49
void
const
*
get_sequence_data
(
int
array_num )
const
50
{
51
return
arraySet
[-1 - array_num];
52
}
53
54
/**\return array of adjacency data, or NULL if none. */
55
AdjacencyDataType
*
get_adjacency_data
()
56
{
57
return
reinterpret_cast<
AdjacencyDataType
*
>
(
arraySet
[0] );
58
}
59
/**\return array of adjacency data, or NULL if none. */
60
AdjacencyDataType
const
*
get_adjacency_data
()
const
61
{
62
return
reinterpret_cast<
AdjacencyDataType
const*
>
(
arraySet
[0] );
63
}
64
65
/**\return array of dense tag data, or NULL if none. */
66
void
*
get_tag_data
(
unsigned
tag_num )
67
{
68
return
tag_num <
numTagData
?
arraySet
[tag_num + 1] : 0;
69
}
70
/**\return array of dense tag data, or NULL if none. */
71
void
const
*
get_tag_data
(
unsigned
tag_num )
const
72
{
73
return
tag_num <
numTagData
?
arraySet
[tag_num + 1] : 0;
74
}
75
76
/**\brief Allocate array of sequence-specific data
77
*
78
* Allocate an array of EntitySequence-specific data.
79
*\param array_num Index for which to allocate array.
80
* Must be in [0,num_sequence_arrays], where
81
* num_sequence_arrays is constructor argument.
82
*\param bytes_per_ent Bytes to allocate for each entity.
83
*\param initial_val Value to initialize array with. If non-null, must
84
* be bytes_per_ent long. If NULL, array will be zeroed.
85
*\return The newly allocated array, or NULL if error.
86
*/
87
void
*
create_sequence_data
(
int
array_num,
int
bytes_per_ent,
const
void
* initial_val = 0 );
88
89
/**\brief Allocate array of sequence-specific data
90
*
91
* Allocate an array of EntitySequence-specific data.
92
*\param array_num Index for which to allocate array.
93
* Must be in [0,num_sequence_arrays], where
94
* num_sequence_arrays is constructor argument.
95
*\return The newly allocated array, or NULL if error.
96
*/
97
void
*
create_custom_data
(
int
array_num,
size_t
total_bytes );
98
99
/**\brief Allocate array for storing adjacency data.
100
*
101
* Allocate array for storing adjacency data.
102
*\return The newly allocated array, or NULL if already allocated.
103
*/
104
AdjacencyDataType
*
allocate_adjacency_data
();
105
106
/**\brief Allocate array of dense tag data
107
*
108
* Allocate an array of dense tag data.
109
*\param index Dense tag ID for which to allocate array.
110
*\param bytes_per_ent Bytes to allocate for each entity.
111
*\return The newly allocated array, or NULL if error.
112
*/
113
void
*
allocate_tag_array
(
int
index,
int
bytes_per_ent,
const
void
* default_value = 0 );
114
115
/**\brief Create new SequenceData that is a copy of a subset of this one
116
*
117
* Create a new SequenceData that is a copy of a subset of this one.
118
* This function is intended for use in subdividing a SequenceData
119
* for operations such as changing the number of nodes in a block of
120
* elements.
121
*\param start First handle for resulting subset
122
*\param end Last handle for resulting subset
123
*\param sequence_data_sizes Bytes-per-entity for sequence-specific data.
124
*\NOTE Does not copy tag data.
125
*/
126
SequenceData
*
subset
(
EntityHandle
start,
EntityHandle
end,
const
int
* sequence_data_sizes )
const
;
127
128
/**\brief SequenceManager data */
129
TypeSequenceManager::SequenceDataPtr
seqManData
;
130
131
/**\brief Move tag data for a subset of this sequences to specified sequence */
132
void
move_tag_data
(
SequenceData
* destination,
const
int
* tag_sizes,
int
num_tag_sizes );
133
134
/**\brief Free all tag data arrays */
135
void
release_tag_data
(
const
int
* tag_sizes,
int
num_tag_sizes );
136
/**\brief Free specified tag data array */
137
void
release_tag_data
(
int
index,
int
tag_size );
138
139
protected
:
140
SequenceData
(
const
SequenceData
* subset_from,
141
EntityHandle
start,
142
EntityHandle
end,
143
const
int
* sequence_data_sizes );
144
145
private
:
146
void
increase_tag_count
(
unsigned
by_this_many );
147
148
void
*
create_data
(
int
index,
int
bytes_per_ent,
const
void
* initial_val = 0 );
149
void
copy_data_subset
(
int
index,
int
size_per_ent,
const
void
* source,
size_t
offset,
size_t
count );
150
151
const
int
numSequenceData
;
152
unsigned
numTagData
;
153
void
**
arraySet
;
154
EntityHandle
startHandle
,
endHandle
;
155
};
156
157
inline
SequenceData::SequenceData
(
int
num_sequence_arrays,
EntityHandle
start,
EntityHandle
end )
158
: numSequenceData( num_sequence_arrays ), numTagData( 0 ), startHandle( start ), endHandle( end )
159
{
160
const
size_t
sz =
sizeof
(
void
* ) * ( num_sequence_arrays + 1 );
161
void
** data = (
void
**)malloc( sz );
162
memset( data, 0, sz );
163
arraySet
= data + num_sequence_arrays;
164
}
165
166
}
// namespace moab
167
168
#endif
src
SequenceData.hpp
Generated on Tue Oct 29 2024 02:05:49 for Mesh Oriented datABase by
1.9.1.