1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 | #ifndef MBIMESH_HPP
#define MBIMESH_HPP
#include "moab/Core.hpp"
#include <vector>
#include <algorithm>
#include <cstring>
using namespace moab;
/* map from MOAB's ErrorCode to tstt's */
extern "C" const iBase_ErrorType iBase_ERROR_MAP[MB_FAILURE + 1];
class MBiMesh
{
private:
bool haveDeletedEntities;
bool iCreatedInterface;
std::vector< Tag > setHandleTags, entHandleTags;
public:
MBiMesh( moab::Interface* mbImpl = NULL );
virtual ~MBiMesh();
bool have_deleted_ents( bool reset )
{
bool result = haveDeletedEntities;
if( reset ) haveDeletedEntities = false;
return result;
}
virtual ErrorCode delete_mesh();
virtual ErrorCode delete_entities( const EntityHandle*, const int );
virtual ErrorCode delete_entities( const Range& );
iBase_AdjacencyCost AdjTable[16];
moab::Interface* mbImpl;
int lastErrorType;
char lastErrorDescription[120];
inline void note_set_handle_tag( Tag );
inline void note_ent_handle_tag( Tag );
inline void note_tag_destroyed( Tag );
inline bool is_set_handle_tag( Tag ) const;
inline bool is_ent_handle_tag( Tag ) const;
inline int set_last_error( int, const char* );
inline int set_last_error( ErrorCode, const char* );
};
static inline MBiMesh* mbimeshi_instance( iMesh_Instance instance )
{
return reinterpret_cast< MBiMesh* >( instance );
}
#define MBIMESHI mbimeshi_instance( instance )
#define MOABI MBIMESHI->mbImpl
inline MBiMesh::MBiMesh( Interface* impl )
: haveDeletedEntities( false ), iCreatedInterface( false ), mbImpl( impl ), lastErrorType( iBase_SUCCESS )
{
lastErrorDescription[0] = '\0';
iBase_AdjacencyCost tmp_table[] = { iBase_ALL_ORDER_1, iBase_SOME_ORDER_1, iBase_SOME_ORDER_1,
iBase_ALL_ORDER_1, iBase_ALL_ORDER_1, iBase_UNAVAILABLE,
iBase_SOME_ORDER_LOGN, iBase_SOME_ORDER_LOGN, iBase_ALL_ORDER_1,
iBase_SOME_ORDER_LOGN, iBase_UNAVAILABLE, iBase_SOME_ORDER_LOGN,
iBase_ALL_ORDER_1, iBase_SOME_ORDER_LOGN, iBase_SOME_ORDER_LOGN,
iBase_ALL_ORDER_1 };
memcpy( AdjTable, tmp_table, 16 * sizeof( iBase_AdjacencyCost ) );
if( !mbImpl )
{
mbImpl = new Core();<--- Class 'MBiMesh' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s).<--- Class 'MBiMesh' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s).
iCreatedInterface = true;
}
}
inline MBiMesh::~MBiMesh()
{
if( iCreatedInterface ) delete mbImpl;
}
inline ErrorCode MBiMesh::delete_mesh()
{
haveDeletedEntities = true;
return mbImpl->delete_mesh();
}
inline ErrorCode MBiMesh::delete_entities( const EntityHandle* a, const int n )
{
if( n > 0 ) haveDeletedEntities = true;
return mbImpl->delete_entities( a, n );
}
inline ErrorCode MBiMesh::delete_entities( const Range& r )
{
if( !r.empty() ) haveDeletedEntities = true;
return mbImpl->delete_entities( r );
}
void MBiMesh::note_set_handle_tag( Tag t )
{
std::vector< Tag >::iterator i;
i = std::lower_bound( entHandleTags.begin(), entHandleTags.end(), t );
if( i != entHandleTags.end() && *i == t ) entHandleTags.erase( i );
i = std::lower_bound( setHandleTags.begin(), setHandleTags.end(), t );
if( i == setHandleTags.end() || *i != t ) setHandleTags.insert( i, t );
}
void MBiMesh::note_ent_handle_tag( Tag t )
{
std::vector< Tag >::iterator i;
i = std::lower_bound( setHandleTags.begin(), setHandleTags.end(), t );
if( i != setHandleTags.end() && *i == t ) setHandleTags.erase( i );
i = std::lower_bound( entHandleTags.begin(), entHandleTags.end(), t );
if( i == entHandleTags.end() || *i != t ) entHandleTags.insert( i, t );
}
void MBiMesh::note_tag_destroyed( Tag t )
{
std::vector< Tag >::iterator i;
i = std::lower_bound( setHandleTags.begin(), setHandleTags.end(), t );
if( i != setHandleTags.end() && *i == t ) setHandleTags.erase( i );
i = std::lower_bound( entHandleTags.begin(), entHandleTags.end(), t );
if( i != entHandleTags.end() && *i == t ) entHandleTags.erase( i );
}
bool MBiMesh::is_set_handle_tag( Tag t ) const
{
return std::binary_search( setHandleTags.begin(), setHandleTags.end(), t );
}
bool MBiMesh::is_ent_handle_tag( Tag t ) const
{
return std::binary_search( entHandleTags.begin(), entHandleTags.end(), t );
}
int MBiMesh::set_last_error( int code, const char* msg )
{
std::strncpy( lastErrorDescription, msg, sizeof( lastErrorDescription ) );
lastErrorDescription[sizeof( lastErrorDescription ) - 1] = '\0';
return ( lastErrorType = static_cast< iBase_ErrorType >( code ) );
}
int MBiMesh::set_last_error( ErrorCode code, const char* msg )
{
std::string message( msg );
message += " (MOAB Error Code: ";
message += mbImpl->get_error_string( code );
message += ")";
return set_last_error( iBase_ERROR_MAP[code], message.c_str() );
}
#endif
|