MOAB: Mesh Oriented datABase  (version 5.5.0)
FBGeomAssocPairSide.cpp
Go to the documentation of this file.
2 
3 #include <cstring>
4 #include <sstream>
5 #include <string>
6 
7 #include "Lasso.hpp"
8 #include "iRel_Lasso.hpp"
9 
10 #define PROCESS_ERROR \
11  do \
12  { \
13  if( iBase_SUCCESS != result ) \
14  { \
15  char this_descr[120]; \
16  FBiGeom_getDescription( instance_, this_descr, 120 ); \
17  ERRORR( result, this_descr ); \
18  } \
19  } while( false )
20 
21 // Redefine LASSOI
22 #undef LASSOI
23 #define LASSOI lasso_instance( relation )
24 
25 static const char* GLOBAL_ID_TAG_NAME = "GLOBAL_ID";
26 static const char* RELATION_TAG_NAME = "__FBGEOM_ASSOCIATION";
27 
29  : relation( p_relation ), instance_( reinterpret_cast< FBiGeom_Instance >( p_instance ) ), id( p_id )
30 {
31  int result;
32 
34 
36  if( result == iBase_TAG_NOT_FOUND )
37  {
39  strlen( GLOBAL_ID_TAG_NAME ) );
40  }
41 }
42 
44 {
46 }
47 
49 {
50  return instance_;
51 }
52 
54 {
55  return iRel_FBIGEOM_IFACE;
56 }
57 
59 {
60  int result;
61  std::stringstream ss;
62  ss << RELATION_TAG_NAME << id;
63  std::string rel_tag_name( ss.str() );
64 
65  FBiGeom_getTagHandle( instance_, rel_tag_name.c_str(), &relation_tag, &result, rel_tag_name.size() );
66  if( result == iBase_TAG_NOT_FOUND )
67  {
68  FBiGeom_createTag( instance_, rel_tag_name.c_str(), 1, iBase_ENTITY_HANDLE, &relation_tag, &result,
69  rel_tag_name.size() );
70  }
71 
74 }
75 
77 {
78  if( relation_tag )
79  {
80  int result;
81 
82  FBiGeom_destroyTag( instance_, relation_tag, true, &result );
83  relation_tag = NULL;
84 
86  }
88 }
89 
92  int* entities_alloc,
93  int* entities_size )
94 {
95  int this_type = ( dimension == -1 ? iBase_ALL_TYPES : dimension );
96  int result;
97 
98  FBiGeom_getEntities( instance_, 0, this_type, entities, entities_alloc, entities_size, &result );
101 }
102 
103 int FBGeomAssocPairSide::get_all_sets( iBase_EntitySetHandle** sets, int* sets_alloc, int* sets_size )
104 {
105  int result;
106 
107  FBiGeom_getEntSets( instance_, 0, 0, sets, sets_alloc, sets_size, &result );
110 }
111 
113  iBase_EntitySetHandle set_handle,
115  int* entities_alloc,
116  int* entities_size )
117 {
118  int this_type = ( dimension == -1 ? iBase_ALL_TYPES : dimension );
119  int result;
120 
121  FBiGeom_getEntities( instance_, set_handle, this_type, entities, entities_alloc, entities_size, &result );
124 }
125 
127  int entities_size,
128  int** ent_types,
129  int* ent_types_alloc,
130  int* ent_types_size )
131 {
132  int result;
133 
134  FBiGeom_getArrType( instance_, entities, entities_size, ent_types, ent_types_alloc, ent_types_size, &result );
137 }
138 
140  int* /*entities_alloc*/,
141  int* /*entities_size*/ )
142 {
144 }
145 
146 int FBGeomAssocPairSide::get_related_sets( iBase_EntitySetHandle** /*sets*/, int* /*sets_alloc*/, int* /*sets_size*/ )
147 {
149 }
150 
152 {
153  int values_alloc = num_entities * sizeof( iBase_EntityHandle );
154  int values_size;
155  int result;
156 
157  FBiGeom_getArrData( instance_, entities, num_entities, relation_tag, &values, &values_alloc, &values_size,
158  &result );
161 }
162 
163 int FBGeomAssocPairSide::get_relation_side( iBase_EntitySetHandle* sets, int num_sets, void* values )
164 {
165  char* data = static_cast< char* >( values );
166  int values_alloc = sizeof( iBase_EntityHandle );
167  int values_size;
168  int result;
169 
170  for( int i = 0; i < num_sets; i++ )
171  {
172  FBiGeom_getEntSetData( instance_, sets[i], relation_tag, reinterpret_cast< void** >( &data ), &values_alloc,
173  &values_size, &result );
174  data += values_size;
176  }
178 }
179 
180 int FBGeomAssocPairSide::set_relation_side( iBase_EntityHandle* entities, int num_entities, const void* values )
181 {
182  int result;
183 
184  FBiGeom_setArrData( instance_, entities, num_entities, relation_tag, static_cast< const char* >( values ),
185  num_entities * sizeof( iBase_EntityHandle ), &result );
188 }
189 
190 int FBGeomAssocPairSide::set_relation_side( iBase_EntitySetHandle* sets, int num_sets, const void* values )
191 {
192  const char* data = static_cast< const char* >( values );
193  int size = sizeof( iBase_EntityHandle );
194  int result;
195 
196  for( int i = 0; i < num_sets; i++ )
197  {
198  FBiGeom_setEntSetData( instance_, sets[i], relation_tag, data, size, &result );
199  data += size;
201  }
203 }
204 
206 {
207  int result;
208 
209  FBiGeom_rmvArrTag( instance_, entities, num_entities, relation_tag, &result );
212 }
213 
215 {
216  int result;
217 
218  for( int i = 0; i < num_sets; i++ )
219  {
220  FBiGeom_rmvEntSetTag( instance_, sets[i], relation_tag, &result );
222  }
223 
225 }
226 
228 {
229  int result;
230  FBiGeom_initEntIter( instance_, set, iBase_ALL_TYPES, iter, &result );
232 }
233 
234 int FBGeomAssocPairSide::get_gids( iBase_EntityHandle* entities, int num_entities, int* values )
235 {
236  int values_alloc = num_entities * sizeof( int );
237  int values_size;
238  int result;
239 
240  FBiGeom_getArrData( instance_, entities, num_entities, gid_tag, reinterpret_cast< void** >( &values ),
241  &values_alloc, &values_size, &result );
244 }
245 
246 int FBGeomAssocPairSide::get_gids( iBase_EntitySetHandle* sets, int num_sets, int* values )
247 {
248  char* data = reinterpret_cast< char* >( values );
249  int values_alloc = sizeof( int );
250  int values_size;
251  int result;
252 
253  for( int i = 0; i < num_sets; i++ )
254  {
255  FBiGeom_getEntSetData( instance_, sets[i], gid_tag, reinterpret_cast< void** >( &data ), &values_alloc,
256  &values_size, &result );
257  data += values_size;
259  }
261 }
262 
263 int FBGeomAssocPairSide::get_dims( iBase_EntityHandle* /*entities*/, int /*num_entities*/, int* /*values*/ )
264 {
266 }
267 
268 int FBGeomAssocPairSide::get_dims( iBase_EntitySetHandle* /*sets*/, int /*num_sets*/, int* /*values*/ )
269 {
271 }