Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
ReadDamsel.cpp
Go to the documentation of this file.
1 /** MOAB Damsel file reader
2  * For description of the Damsel-MOAB data model mapping, see WriteDamsel.cpp.
3  *
4  */
5 
6 #include "moab/ParallelComm.hpp"
7 
8 #include "ReadDamsel.hpp"
9 
10 #include <cassert>
11 #include "moab/Interface.hpp"
12 #include "moab/Core.hpp"
13 #include "moab/Range.hpp"
14 #include "moab/Error.hpp"
15 #include "moab/ReadUtilIface.hpp"
16 #include "moab/FileOptions.hpp"
17 #include "MBTagConventions.hpp"
18 #include "EntitySequence.hpp"
19 #include "Internals.hpp"
20 #include "DenseTag.hpp"
21 
22 namespace moab
23 {
24 
26 {
27  return new ReadDamsel( iface );
28 }
29 
31  : mbImpl( impl ), readMeshIface( NULL ), nativeParallel( false ), myPcomm( NULL ), mGlobalIdTag( 0 ), dU()
32 {
33  init();
34 }
35 
37 {
39 
40  DMSLlib_finalize( dU.dmslLib );
41 }
42 
44 {
46  assert( readMeshIface );
47 
48  return MB_SUCCESS;
49 }
50 
51 ErrorCode ReadDamsel::parse_options( const FileOptions& opts, bool& parallel )
52 {
53  // Handle parallel options
54  bool use_mpio = ( MB_SUCCESS == opts.get_null_option( "USE_MPIO" ) );
55  ErrorCode rval = opts.match_option( "PARALLEL", "READ_PART" );
56  parallel = ( rval != MB_ENTITY_NOT_FOUND );
57  nativeParallel = ( rval == MB_SUCCESS );
58  if( use_mpio && !parallel )
59  {
60  MB_SET_ERR( MB_NOT_IMPLEMENTED, "'USE_MPIO' option specified w/out 'PARALLEL' option" );
61  }
62 
63  return MB_SUCCESS;
64 }
65 
66 // ASSUMPTIONS:
67 // Partition collection is a *flat* collection of handles for entities and other collections that
68 // will be represented on a part
69 
70 ErrorCode ReadDamsel::load_file( const char* filename,
71  const EntityHandle* file_set,
72  const FileOptions& opts,
73  const ReaderIface::SubsetList* subset_list,
74  const Tag* file_id_tag )
75 {
76  ErrorCode rval;
77 
78  rval = parse_options( opts, nativeParallel );
79  if( MB_SUCCESS != rval ) return rval;
80 
81  // Initialize damsel
82  dU.dmslLib = DMSLlib_init();
83 
84  // Create a damsel model
85  dU.dmslModel =
86  DMSLmodel_create( sizeof( EntityHandle ) == 8 ? DAMSEL_HANDLE_TYPE_HANDLE64 : DAMSEL_HANDLE_TYPE_HANDLE32 );
87 
88  // Model attach - need model id from make model, filename
89 #ifdef MOAB_HAVE_MPI
90  MPI_Comm comm = MPI_COMM_WORLD;
91  if( nativeParallel )
92  {
93  comm = myPcomm->proc_config().proc_comm();
94  }
95 #endif
96 
97  damsel_err_t err;
98  err = DMSLmodel_attach( dU.dmslModel, filename, comm, NULL );
99  CHK_DMSL_ERR( err, "DMSLmodel_attach failed" );
100  err = DMSLmodel_populate( dU.dmslModel );
101  CHK_DMSL_ERR( err, "DMSLmodel_populate failed" );
102 
103  // STEP 0: GET COLLECTION, TAG, ENTITY INFOS FOR GLOBAL MODEL
104  int num_containers = 0, num_tag_infos = 0, num_ent_infos = 0;
105  DMSLmodel_get_tuple_count( dU.dmslModel, &num_containers, &num_tag_infos );
106  num_ent_infos = DMSLmodel_get_entity_count( dU.dmslModel );
107  int num_coll_infos = DMSLmodel_get_collection_count( dU.dmslModel );
108  CHK_DMSL_ERR( err, "DMSLmodel_get_collection_count failed" );
109  if( -1 == num_containers || -1 == num_tag_infos || -1 == num_ent_infos )
110  MB_SET_ERR( MB_FAILURE, "Bad count for containers/tags/ents" );
111 
112  std::vector< damsel_entity_buf_type > ent_infos( num_ent_infos );
113  std::vector< damsel_collection_buf_type > coll_infos( num_coll_infos );
114  std::vector< damsel_tag_buf_type > tag_infos( num_tag_infos );
115  std::vector< damsel_container_buf_type > cont_infos( num_containers );
116  err = DMSLmodel_get_entity_infos( dU.dmslModel, &ent_infos[0] );
117  CHK_DMSL_ERR( err, "Failure getting entity infos" );
118  err = DMSLmodel_get_collection_infos( dU.dmslModel, &coll_infos[0] );
119  CHK_DMSL_ERR( err, "Failure getting collection infos" );
120  err = DMSLmodel_get_tag_infos( dU.dmslModel, &tag_infos[0] );
121  CHK_DMSL_ERR( err, "Failure getting tag infos" );
122  err = DMSLmodel_get_container_infos( dU.dmslModel, &cont_infos[0] );
123  CHK_DMSL_ERR( err, "Failure getting container infos" );
124 
125  // Create MOAB-side tags for all damsel tags except pre-defined ones
126  MB_CHK_SET_ERR( process_tags( tag_infos ), "Error processing tags" );
127 
128  /*
129  if (nativeParallel) {
130  // STEP 1: GET COLLECTION(S) REPRESENTING PARTITION:
131  // Input: tag name, optionally value;
132  // Output: container with file-side handles of collections satisfying those criteria
133  // - Get all handles/values for tag
134  // - Select handles matching criteria for tag value (will be collection handles)
135  std::string partn_tag_name("PARALLEL_PARTITION");
136  damsel_handle partn_tag = DMSLselect_tag_by_name(dU.dmslModel, partn_tag_name.c_str());
137  // Get all the parts with that tag regardless of value
138  damsel_container part_handles = DMSLselect_handles_with_values(dU.dmslModel, partn_tag);
139 
140  // STEP 2: GET HANDLES FOR TAGS WE NEED FOR THIS READER:
141  // - "SET_CHARACTERISTIC"
142  damsel_handle setchar_tag = DMSLselect_tag_by_name(dU.dmslModel, "SET_CHARACTERISTIC");
143  // - "PARENT_LIST"
144  //damsel_handle plist_tag = DMSLselect_tag_by_name(dU.dmslModel, "PARENT_LIST");
145  // - "CHILD_LIST"
146  //damsel_handle clist_tag = DMSLselect_tag_by_name(dU.dmslModel, "CHILD_LIST");
147 
148  // STEP 3: GET VALUES FOR "SET_CHARACTERISTIC" TAG ON PARTITION COLLECTIONS,
149  // GET VECTOR- OR SET-TYPE FLAGS FOR PARTITION COLLECTIONS
150  // (gives tracking flag for moab)
151  int num_handles = DMSLcontainer_count(part_handles);
152  std::vector<unsigned> char_tagvals(num_handles);
153  // Map the set chars
154  err = DMSLmodel_map_tag(&char_tagvals[0], part_handles, &setchar_tag);CHK_DMSL_ERR(err,
155  "Problem calling DMSLmodel_map_tag");
156 
157  // Execute the transfer
158  err = DMSLmodel_transfer_sync(dU.dmslModel, DAMSEL_TRANSFER_TYPE_READ);CHK_DMSL_ERR(err,
159  "Problem calling DMSLmodel_transfer_sync");
160 
161  // STEP 4: READ/PROCESS PARTITION COLLECTION(S)
162  // Decide the handles I am responsible using round-robin for now
163  // - GET TYPE, CONTENTS OF COLLECTION CONTENTS CONTAINER
164  // - Allocate moab-side container (using count from container)
165  // - MAP storage TO CONTAINER
166  // - EXECUTE
167  // ==> have list of all handles (entities + collections) represented on this proc
168 
169  int tmp_num = num_handles / proc_size, extra = num_handles % proc_size;
170  if (extra) tmp_num++;
171  int my_num_handles = tmp_num;
172  if (proc_rank >= extra) my_num_handles--;
173  int first_ind = std::min(proc_rank, extra) * tmp_num +
174  std::max(proc_rank - extra, 0) * (tmp_num - 1);
175 
176  // - Create moab entity sets for partition collection(s)
177  EntityHandle start_handle;
178  MB_CHK_SET_ERR( readMeshIface->create_entity_sets(my_num_handles, &char_tagvals[first_ind], 0,
179  start_handle), "Problem creating entity sets" );
180  }
181  else {
182  */
183  // Initialize just by entity; each call to process_ent_info will:
184  // a. Create moab-side representation to read into
185  // b. Map those handles to damsel handles
186  // c. Map coords / connectivity storage to damsel equivalent
187  // d. For each tag, map moab storage to damsel storage
188  std::vector< damsel_entity_buf_type >::iterator eiit;
189 
190  // Process verts info first
191  for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
192  {
193  if( ( *eiit ).entity_type == DAMSEL_ENTITY_TYPE_VERTEX )
194  {
195  MB_CHK_ERR( process_ent_info( *eiit ) );
196  }
197  }
198 
199  for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
200  {
201  if( ( *eiit ).entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
202  {
203  MB_CHK_ERR( process_ent_info( *eiit ) );
204  }
205  }
206 
207  /*
208  }
209 
210  // Process collections
211  MB_CHK_ERR( process_coll_infos(coll_infos) );
212 
213  // STEP 5: Process into list of local info structs, each represents file-side struct and
214  // portion of that struct
215  // ASSUMPTION: Each local info struct represents single entity type & # vertices or collection
216 
217  // STEP 6: For each local info struct:
218 
219  // STEP 6b: READ CONTAINER INTO LOCAL BUFFER
220  // STEP 6c: Create app representation of entities/vertices/collection, and damsel container
221  for them,
222  // and MAP APP HANDLE CONTAINER TO DAMSEL CONTAINER
223  // STEP 6d: Process vertices/entities/collection
224  // 6d1: If vertices, continue
225  // 6d2: If entities:
226  // - MAP LOCAL CONNECTIVITY REP'N TO DAMSEL (might be tag, don't know yet)
227  // 6d3: If collection:
228  // - (everything in STEP 4 for this collection except for EXECUTE)
229  // - might need to filter out things not represented on this rank
230  // 6d4: If sparse tag:
231  // - Create app-side representation of sparse tag
232  // - READ CONTAINER OF MODEL HANDLES INTO LOCAL BUFFER
233  // - Allocate app-side storage for tag values
234  // - MAP APP STORAGE TO MODEL TAG + (implicit?) CONTAINER
235 
236  // STEP 6e: Process dense tags for the local info struct; for each dense tag:
237  // - Get app tag handle for model tag handle
238  // - Get app storage for app tag handle + container
239  // - MAP APP STORAGE TO MODEL TAG + CONTAINER
240 
241  // STEP 7: EXECUTE
242  // - Assign all mapped data
243  // - Translate all damsel handles to app handles
244  // uninit damsel
245 
246  */
247 
248  return MB_SUCCESS;
249 }
250 
251 ErrorCode ReadDamsel::read_tag_values( const char* file_name,
252  const char* tag_name,
253  const FileOptions& opts,
254  std::vector< int >& tag_values_out,
255  const SubsetList* subset_list )
256 {
257  return MB_FAILURE;
258 }
259 
260 ErrorCode ReadDamsel::process_tags( std::vector< damsel_tag_buf_type >& tag_infos )
261 {
262  Tag tagh;
263  ErrorCode rval = MB_SUCCESS, tmp_rval;
264  for( std::vector< damsel_tag_buf_type >::iterator tit = tag_infos.begin(); tit != tag_infos.end(); ++tit )
265  {
266  if( DamselUtil::dtom_data_type[( *tit ).tag_datatype] == MB_TYPE_OPAQUE )
267  {
268  std::cout << "Damsel reader encountered opaque tag." << std::endl;
269  continue;
270  }
271 
272  tmp_rval = mbImpl->tag_get_handle( ( *tit ).name, 1, DamselUtil::dtom_data_type[( *tit ).tag_datatype], tagh,
274  if( MB_SUCCESS != tmp_rval )
275  rval = tmp_rval;
276  else
277  {
278  dU.tagMap.push_back( DamselUtil::tinfo( tagh, 0, MB_TAG_DENSE ) );
279  // Also store predefined tags specially...
280  if( !strncmp( ( *tit ).name, "mbdmsl_", 7 ) )
281  {
282  // Predefined tag name, store the handle
283  if( !strcmp( ( *tit ).name, "mbdmsl_XCOORDS" ) )
284  dU.xcoordsTag = dU.tagMap.back();
285  else if( !strcmp( ( *tit ).name, "mbdmsl_YCOORDS" ) )
286  {
287  dU.ycoordsTag = dU.tagMap.back();
288  }
289  else if( !strcmp( ( *tit ).name, "mbdmsl_ZCOORDS" ) )
290  {
291  dU.zcoordsTag = dU.tagMap.back();
292  }
293  else if( !strcmp( ( *tit ).name, "mbdmsl_COLL_FLAGS" ) )
294  {
295  dU.collFlagsTag = dU.tagMap.back();
296  }
297  else if( !strcmp( ( *tit ).name, "mbdmsl_PARENTS" ) )
298  {
299  dU.parentsTag = dU.tagMap.back();
300  }
301  else if( !strcmp( ( *tit ).name, "mbdmsl_CHILDREN" ) )
302  {
303  dU.childrenTag = dU.tagMap.back();
304  }
305  else
306  {
307  rval = MB_FAILURE;
308  continue;
309  }
310  }
311  }
312  }
313 
314  return rval;
315 }
316 
317 ErrorCode ReadDamsel::process_ent_info( const damsel_entity_buf_type& einfo )
318 {
319  // Create this chunk of entities
320  EntityHandle *connect, start_handle;
321  ErrorCode rval;
322  damsel_err_t err;
323  damsel_container app_cont;
324  Range these_ents;
325 
326  // Check that there's only one contiguous run of file-side handles, fail if there isn't
327 #ifndef NDEBUG
328  Range fside_handles;
329  rval = DamselUtil::container_to_range( dU.dmslModel, const_cast< damsel_container& >( einfo.entity_container ),
330  fside_handles );
331  if( MB_SUCCESS != rval || fside_handles.size() != einfo.count || fside_handles.psize() != 1 ) return MB_FAILURE;
332 #endif
333 
334  if( einfo.entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
335  {
336  // Create the moab entities
337  MB_CHK_ERR( readMeshIface->get_element_connect( einfo.count, einfo.vertices_per_entity,
338  DamselUtil::dtom_entity_type[einfo.entity_type], 0,
339  start_handle, connect ) );
340  these_ents.insert( start_handle, start_handle + einfo.count - 1 );
341 
342  // Create an app-side sequence and map to file-side container
343  app_cont = DMSLcontainer_create_sequence( dU.dmslModel, einfo.count, start_handle, 1 );
344  err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
345  CHK_DMSL_ERR( err, "Error returned mapping entity handles" );
346 
347  // Map connectivity
348  assert( DMSLcontainer_count( einfo.vertex_container ) == (int)( einfo.vertices_per_entity * einfo.count ) );
349  MB_CHK_SET_ERR( get_contents( dU.dmslModel, einfo.vertex_container, connect ),
350  "Error returned mapping connectivity" );
351  }
352  else
353  {
354  // Get the number of coordinate arrays
355  int num_ctags = 0;
356  damsel_handle xcoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_XCOORDS" );
357  if( xcoord_dtag ) num_ctags++;
358  damsel_handle ycoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_YCOORDS" );
359  if( ycoord_dtag ) num_ctags++;
360  damsel_handle zcoord_dtag = DMSLselect_tag_by_name( dU.dmslModel, "mbdmsl_ZCOORDS" );
361  if( zcoord_dtag ) num_ctags++;
362 
363  // Should have one vertex per entity
364  assert( einfo.vertices_per_entity == 1 );
365  std::vector< double* > coord_arrays;
366  MB_CHK_ERR( readMeshIface->get_node_coords( num_ctags, einfo.count, 0, start_handle, coord_arrays ) );
367 
368  these_ents.insert( start_handle, start_handle + einfo.count - 1 );
369 
370  // Create an app-side sequence and map to file-side container
371  app_cont = DMSLcontainer_create_sequence( dU.dmslModel, start_handle, einfo.count, 1 );
372  err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
373  CHK_DMSL_ERR( err, "Trouble mapping entity handles" );
374 
375  // Map the coords storage
376  if( xcoord_dtag != 0 )
377  {
378  err = DMSLmodel_map_tag( coord_arrays[0], app_cont, (damsel_handle_ptr)&dU.xcoordsTag.mTagh );
379  CHK_DMSL_ERR( err, "Trouble mapping x coordinate tag" );
380  }
381  if( ycoord_dtag != 0 )
382  {
383  err = DMSLmodel_map_tag( coord_arrays[1], app_cont, (damsel_handle_ptr)&dU.ycoordsTag.mTagh );
384  CHK_DMSL_ERR( err, "Trouble mapping y coordinate tag" );
385  }
386  if( zcoord_dtag != 0 )
387  {
388  err = DMSLmodel_map_tag( coord_arrays[2], app_cont, (damsel_handle_ptr)&dU.zcoordsTag.mTagh );
389  CHK_DMSL_ERR( err, "Trouble mapping z coordinate tag" );
390  }
391  }
392 
393  // Save mapping from moab entity to einfo
394  dmHandleRMap.insert( DMSLcontainer_handle_at_position( einfo.entity_container, 0 ), start_handle, einfo.count );
395 
396  rval = process_entity_tags( einfo.tag_count, einfo.tag_handle_container, app_cont, these_ents );
397 
398  return rval;
399 }
400 
402  damsel_container tag_container,
403  damsel_container app_cont,
404  Range& these_ents )
405 {
406  // Process tags on these entities
407  ErrorCode rval = MB_SUCCESS;
408  for( int i = 0; i < count; i++ )
409  {
410  damsel_handle dtagh = DMSLcontainer_handle_at_position( tag_container, i );
411 
412  // Don't do conventional tags here
413  std::vector< DamselUtil::tinfo >::iterator vit =
414  std::find_if( dU.tagMap.begin(), dU.tagMap.end(), DamselUtil::DtagP< DamselUtil::tinfo >( dtagh ) );
415 
416  if( ( *vit ).tagType == MB_TAG_ANY )
417  continue;
418  else if( vit == dU.tagMap.end() )
419  MB_SET_ERR( MB_FAILURE, "Failed to find tag" );
420 
421  Tag tagh = ( *vit ).mTagh;
422  assert( tagh );
423  void* tag_data;
424  int ecount = these_ents.size();
425  MB_CHK_SET_ERR( mbImpl->tag_iterate( tagh, these_ents.begin(), these_ents.end(), ecount, tag_data ),
426  "Problem getting tag iterator" );
427  assert( ecount == (int)these_ents.size() );
428  damsel_err_t err = DMSLmodel_map_tag( tag_data, app_cont, (damsel_handle_ptr)&tagh );
429  CHK_DMSL_ERR( err, "Problem calling DMSLmodel_map_tag" );
430  }
431 
432  return rval;
433 }
434 
435 ErrorCode ReadDamsel::get_contents( damsel_model m, damsel_container c, Range& ents )
436 {
437  EntityHandle eh;
438  if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
439  {
440  damsel_handle start;
441  size_t count, stride;
442  damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
443  CHK_DMSL_ERR( err, "DMSLcontainer_sequence_get_contents" );
444  if( stride == 1 )
445  {
446  while( count )
447  {
448  // Get start in rangemap
450  if( beg == dmHandleRMap.end() ) return MB_SUCCESS;
451  unsigned long diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
452  unsigned long num = std::min( count - diff, (size_t)( *beg ).count );
453  ents.insert( ( *beg ).begin + diff, ( *beg ).begin + diff + num - 1 );
454  count -= ( diff + num );
455  ++beg;
456  }
457  }
458  else
459  {
460  for( int i = count - 1; i >= 0; i-- )
461  {
462  if( dmHandleRMap.find( start + i, eh ) ) ents.insert( eh );
463  }
464  }
465  }
466  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
467  {
468  damsel_handle* handle_ptr;
469  size_t count;
470  damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
471  CHK_DMSL_ERR( err, "Trouble getting vector contents" );
472  for( int i = count - 1; i >= 0; i-- )
473  {
474  if( dmHandleRMap.find( handle_ptr[i], eh ) ) ents.insert( eh );
475  }
476  }
477  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
478  {
479  damsel_handle_ptr node_ptr = NULL;
480  damsel_container cont = NULL;
481  while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
482  {
483  ErrorCode rval = get_contents( m, c, ents );
484  if( MB_SUCCESS != rval ) return rval;
485  }
486  }
487 
488  return MB_SUCCESS;
489 }
490 
491 ErrorCode ReadDamsel::get_contents( damsel_model m, damsel_container c, EntityHandle* ents )
492 {
493  EntityHandle eh;
494  int ind = 0;
495 
496  if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
497  {
498  damsel_handle start;
499  size_t count, stride;
500  damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
501  CHK_DMSL_ERR( err, "Problem calling DMSLcontainer_sequence_get_contents" );
502  if( stride == 1 )
503  {
504  while( count )
505  {
506  // Get start in rangemap
508  if( beg == dmHandleRMap.end() ) return MB_SUCCESS;
509  unsigned int diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
510  unsigned int num = std::min( count - diff, (size_t)( *beg ).count );
511  for( EntityHandle hdl = ( *beg ).begin + diff; hdl <= (int)( *beg ).begin + diff + num - 1; hdl++ )
512  ents[ind++] = hdl;
513  count -= ( diff + num );
514  ++beg;
515  }
516  }
517  else
518  {
519  for( int i = count - 1; i >= 0; i-- )
520  {
521  if( dmHandleRMap.find( start + i, eh ) ) ents[i] = eh;
522  }
523  }
524  }
525  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
526  {
527  damsel_handle_ptr handle_ptr;
528  size_t count;
529  damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
530  CHK_DMSL_ERR( err, "Failed to get vector contents" );
531  for( int i = count - 1; i >= 0; i-- )
532  {
533  if( dmHandleRMap.find( handle_ptr[i], eh ) ) ents[i] = eh;
534  }
535  }
536  else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
537  {
538  damsel_handle_ptr node_ptr = NULL;
539  damsel_container cont = NULL;
540  while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
541  {
542  ErrorCode rval = get_contents( m, cont, ents );
543  if( MB_SUCCESS != rval ) return rval;
544  unsigned int num = DMSLcontainer_count( cont );
545  ents += num;
546  }
547  }
548 
549  return MB_SUCCESS;
550 }
551 
552 /*
553 ErrorCode ReadDamsel::process_coll_infos(std::vector<damsel_collection_buf_type> &coll_infos)
554 {
555  ErrorCode rval = MB_SUCCESS, tmp_rval;
556  EntityHandle seth;
557  std::vector<subrange> handle_subranges;
558  for (std::vector<damsel_collection_buf_type>::iterator cit = coll_infos.begin(); cit !=
559 coll_infos.end(); ++cit) {
560  // Make the set
561  tmp_rval = mbImpl->create_meshset(((*cit).type == DAMSEL_HANDLE_COLLECTION_TYPE_SET ?
562 MESHSET_SET : MESHSET_ORDERED), seth); if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
563  // Make datastructures to pass things to process_entity_tags
564  Range tmp_range(seth, seth);
565  damsel_container ch = DMSLcontainer_create_sequence(dU.dmslModel, seth, 1, 1);
566 
567  // Get the tags on this set
568  tmp_rval = process_entity_tags((*cit).tag_count, (*cit).tag_handle_container, ch, tmp_range);
569  if (MB_SUCCESS != tmp_rval)
570  rval = tmp_rval;
571 
572  // Process the set contents
573  if ((*cit).type == DAMSEL_HANDLE_COLLECTION_TYPE_SET) {
574  Range ents;
575  tmp_rval = get_contents(dU.dmslModel, (*cit).contents, ents);
576  if (MB_SUCCESS != tmp_rval)
577  rval = tmp_rval;
578  else if (!ents.empty()) {
579  tmp_rval = mbImpl->add_entities(seth, ents);
580  if (MB_SUCCESS != tmp_rval)
581  rval = tmp_rval;
582  }
583  }
584  else {
585  std::vector<EntityHandle> ents(DMSLcontainer_count((*cit).contents));
586  tmp_rval = get_contents(dU.dmslModel, (*cit).contents, &ents[0]);
587  if (MB_SUCCESS != tmp_rval)
588  rval = tmp_rval;
589  else if (!ents.empty()) {
590  tmp_rval = mbImpl->add_entities(seth, &ents[0], ents.size());
591  if (MB_SUCCESS != tmp_rval)
592  rval = tmp_rval;
593  }
594  }
595 
596  // Get the file handle for this collection, and map it to moab's set handle
597  damsel_handle collh = (damsel_handle)(*((*cit).collection_handle));
598  if (handle_subranges.empty() || seth != (*handle_subranges.rbegin()).seth + 1 ||
599  collh != (*handle_subranges.rbegin()).collh + 1) {
600  handle_subranges.push_back(subrange(collh, seth, 1));
601  }
602  else (*handle_subranges.rbegin()).count++;
603  }
604 
605  for (std::vector<subrange>::iterator vit = handle_subranges.begin(); vit !=
606 handle_subranges.end(); ++vit) dmHandleRMap.insert((*vit).collh, (*vit).seth, (*vit).count);
607 
608  return rval;
609 }
610 */
611 
612 } // namespace moab