moab
ReadDamsel.cpp
Go to the documentation of this file.
00001 
00006 #include "moab/ParallelComm.hpp"
00007 
00008 #include "ReadDamsel.hpp"
00009 
00010 #include "assert.h"
00011 #include "moab/Interface.hpp"
00012 #include "moab/Core.hpp"
00013 #include "moab/Range.hpp"
00014 #include "moab/Error.hpp"
00015 #include "moab/ReadUtilIface.hpp"
00016 #include "moab/FileOptions.hpp"
00017 #include "MBTagConventions.hpp"
00018 #include "EntitySequence.hpp"
00019 #include "Internals.hpp"
00020 #include "DenseTag.hpp"
00021 
00022 namespace moab {
00023 
00024 ReaderIface* ReadDamsel::factory( Interface* iface )
00025   { return new ReadDamsel( iface ); }
00026 
00027 ReadDamsel::ReadDamsel(Interface *impl) 
00028         : mbImpl(impl), readMeshIface(NULL), mError(NULL), nativeParallel(false), myPcomm(NULL), mGlobalIdTag(0), 
00029           dU()
00030 {
00031   init();
00032 }
00033 
00034 ReadDamsel::~ReadDamsel()
00035 {
00036   if (readMeshIface) mbImpl->release_interface(readMeshIface);
00037   if (mError) mbImpl->release_interface(mError);
00038   DMSLlib_finalize(dU.dmslLib);
00039 }
00040 
00041 ErrorCode ReadDamsel::init()
00042 {
00043   mbImpl->query_interface(readMeshIface);
00044   assert(readMeshIface);
00045 
00046   mbImpl->query_interface(mError);
00047   assert(mError);
00048   
00049   return MB_SUCCESS;
00050 }
00051 
00052 ErrorCode ReadDamsel::parse_options(const FileOptions &opts,
00053                                     bool &parallel) 
00054 {
00055     // Handle parallel options
00056   std::string junk;
00057   bool use_mpio = (MB_SUCCESS == opts.get_null_option("USE_MPIO"));
00058   ErrorCode rval = opts.match_option("PARALLEL", "READ_PART");
00059   parallel = (rval != MB_ENTITY_NOT_FOUND);
00060   nativeParallel = (rval == MB_SUCCESS);
00061   if (use_mpio && !parallel) {
00062     readMeshIface->report_error( "'USE_MPIO' option specified w/out 'PARALLEL' option" );
00063     return MB_NOT_IMPLEMENTED;
00064   }
00065 
00066   return MB_SUCCESS;
00067 }
00068 
00069 // ASSUMPTIONS:
00070 // Partition collection is a *flat* collection of handles for entities and other collections that
00071 // will be represented on a part
00072 
00073 ErrorCode ReadDamsel::load_file( const char* filename, 
00074                                  const EntityHandle* file_set, 
00075                                  const FileOptions& opts,
00076                                  const ReaderIface::SubsetList* subset_list,
00077                                  const Tag* file_id_tag )
00078 {
00079   ErrorCode rval;
00080  
00081   rval = parse_options(opts, nativeParallel);
00082   if (MB_SUCCESS != rval)
00083     return rval;
00084 
00085     // initialize damsel
00086   dU.dmslLib = DMSLlib_init();
00087   
00088     // create a damsel model
00089   dU.dmslModel = DMSLmodel_create(sizeof(EntityHandle) == 8 ? DAMSEL_HANDLE_TYPE_HANDLE64 : 
00090                                   DAMSEL_HANDLE_TYPE_HANDLE32);
00091   
00092     // model attach - need model id from make model, filename
00093 #ifdef USE_MPI
00094   MPI_Comm comm = MPI_COMM_WORLD;
00095   if (nativeParallel) {
00096     comm = myPcomm->proc_config().proc_comm();
00097   }
00098 #endif
00099 
00100   damsel_err_t err;
00101   err = DMSLmodel_attach(dU.dmslModel, filename, comm, NULL);
00102   CHK_DMSL_ERR(err, "DMSLmodel_attach failed.");
00103   err = DMSLmodel_populate(dU.dmslModel);
00104   CHK_DMSL_ERR(err, "DMSLmodel_populate failed.");
00105   
00106     // STEP 0: GET COLLECTION, TAG, ENTITY INFOS FOR GLOBAL MODEL
00107   int num_containers = 0, num_tag_infos = 0, num_ent_infos = 0;
00108   DMSLmodel_get_tuple_count(dU.dmslModel, &num_containers, &num_tag_infos);
00109   num_ent_infos = DMSLmodel_get_entity_count(dU.dmslModel);
00110   int num_coll_infos = DMSLmodel_get_collection_count(dU.dmslModel);
00111   CHK_DMSL_ERR(err, "DMSLmodel_get_collection_count failed.");
00112   if (-1 == num_containers || -1 == num_tag_infos || -1 == num_ent_infos) 
00113     CHK_MB_ERR(MB_FAILURE, "Bad count for containers/tags/ents.");
00114 
00115   std::vector<damsel_entity_buf_type> ent_infos(num_ent_infos);
00116   std::vector<damsel_collection_buf_type> coll_infos(num_coll_infos);
00117   std::vector<damsel_tag_buf_type> tag_infos(num_tag_infos);
00118   std::vector<damsel_container_buf_type> cont_infos(num_containers);
00119   err = DMSLmodel_get_entity_infos(dU.dmslModel, &ent_infos[0]);
00120   CHK_DMSL_ERR(err, "Failure getting entity infos.");
00121   err = DMSLmodel_get_collection_infos(dU.dmslModel, &coll_infos[0]);
00122   CHK_DMSL_ERR(err, "Failure getting collection infos.");
00123   err = DMSLmodel_get_tag_infos(dU.dmslModel, &tag_infos[0]);
00124   CHK_DMSL_ERR(err, "Failure getting tag infos.");
00125   err = DMSLmodel_get_container_infos(dU.dmslModel, &cont_infos[0]);
00126   CHK_DMSL_ERR(err, "Failure getting container infos.");
00127 
00128     // create MOAB-side tags for all damsel tags except pre-defined ones
00129   rval = process_tags(tag_infos);
00130   CHK_MB_ERR(rval, "Error processing tags.");
00131   
00132 /*
00133   
00134   if (nativeParallel) {
00135       // STEP 1: GET COLLECTION(S) REPRESENTING PARTITION: 
00136       // input: tag name, optionally value; 
00137       // output: container with file-side handles of collections satisfying those criteria
00138       // - get all handles/values for tag
00139       // - select handles matching criteria for tag value (will be collection handles)
00140     std::string partn_tag_name("PARALLEL_PARTITION");
00141     damsel_handle partn_tag = DMSLselect_tag_by_name(dU.dmslModel, partn_tag_name.c_str());
00142       // get all the parts with that tag regardless of value
00143     damsel_container part_handles = DMSLselect_handles_with_values(dU.dmslModel, partn_tag);
00144 
00145       // STEP 2: GET HANDLES FOR TAGS WE NEED FOR THIS READER:
00146       // - "SET_CHARACTERISTIC"
00147     damsel_handle setchar_tag = DMSLselect_tag_by_name(dU.dmslModel, "SET_CHARACTERISTIC");
00148       // - "PARENT_LIST"
00149       //damsel_handle plist_tag = DMSLselect_tag_by_name(dU.dmslModel, "PARENT_LIST");
00150       // - "CHILD_LIST"
00151       //damsel_handle clist_tag = DMSLselect_tag_by_name(dU.dmslModel, "CHILD_LIST");
00152 
00153       // STEP 3: GET VALUES FOR "SET_CHARACTERISTIC" TAG ON PARTITION COLLECTIONS,
00154       //         GET VECTOR- OR SET-TYPE FLAGS FOR PARTITION COLLECTIONS
00155       // (gives tracking flag for moab)
00156     int num_handles = DMSLcontainer_count(part_handles);
00157     std::vector<unsigned> char_tagvals(num_handles);
00158       // map the set chars
00159     err = DMSLmodel_map_tag(&char_tagvals[0], part_handles, &setchar_tag);
00160     CHK_DMSL_ERR(err, "Problem calling DMSLmodel_map_tag");
00161     
00162       // execute the transfer
00163     err = DMSLmodel_transfer_sync(dU.dmslModel, DAMSEL_TRANSFER_TYPE_READ);
00164     CHK_DMSL_ERR(err, "Problem calling DMSLmodel_transfer_sync");
00165 
00166       // STEP 4: READ/PROCESS PARTITION COLLECTION(S)
00167       // decide the handles I am responsible using round-robin for now
00168     // - GET TYPE, CONTENTS OF COLLECTION CONTENTS CONTAINER
00169     // - allocate moab-side container (using count from container)
00170     // - MAP storage TO CONTAINER 
00171     // - EXECUTE
00172     // ==> have list of all handles (entities + collections) represented on this proc
00173 
00174     int tmp_num = num_handles / proc_size, extra = num_handles % proc_size;
00175     if (extra) tmp_num++;
00176     int my_num_handles = tmp_num;
00177     if (proc_rank >= extra) my_num_handles--;
00178     int first_ind = std::min(proc_rank,extra) * tmp_num + 
00179         std::max(proc_rank-extra,0) * (tmp_num-1);
00180 
00181       // - create moab entity sets for partition collection(s)
00182     EntityHandle start_handle;
00183     rval = readMeshIface->create_entity_sets(my_num_handles, &char_tagvals[first_ind], 0, start_handle);
00184     CHK_MB_ERR(rval, "Problem creating entity sets.");
00185   }
00186   else {
00187 
00188 */
00189       // initialize just by entity; each call to process_ent_info will:
00190       // a. create moab-side representation to read into
00191       // b. map those handles to damsel handles
00192       // c. map coords / connectivity storage to damsel equivalent
00193       // d. for each tag, map moab storage to damsel storage
00194     std::vector<damsel_entity_buf_type>::iterator eiit;
00195 
00196       // process verts info first    
00197     for (eiit =  ent_infos.begin(); eiit != ent_infos.end(); eiit++) {
00198       if ((*eiit).entity_type == DAMSEL_ENTITY_TYPE_VERTEX) {
00199         rval = process_ent_info(*eiit);
00200         CHK_MB_ERR(rval, " ");
00201       }
00202     }
00203 
00204     for (eiit =  ent_infos.begin(); eiit != ent_infos.end(); eiit++) {
00205       if ((*eiit).entity_type != DAMSEL_ENTITY_TYPE_VERTEX) {
00206         rval = process_ent_info(*eiit);
00207         CHK_MB_ERR(rval, " ");
00208       }
00209     }
00210     
00211 /*
00212   }
00213 
00214     // process collections
00215   rval = process_coll_infos(coll_infos); 
00216   CHK_MB_ERR(rval, " ");
00217   
00218     // STEP 5: process into list of local info structs, each represents file-side struct and
00219     // portion of that struct
00220     // ASSUMPTION: each local info struct represents single entity type & # vertices or collection
00221   
00222     // STEP 6: For each local info struct:
00223 
00224     // STEP 6b: READ CONTAINER INTO LOCAL BUFFER
00225     // STEP 6c: create app representation of entities/vertices/collection, and damsel container for them,
00226     //    and MAP APP HANDLE CONTAINER TO DAMSEL CONTAINER
00227     // STEP 6d: process vertices/entities/collection
00228     //    6d1: if vertices, continue
00229     //    6d2: if entities:
00230     //    - MAP LOCAL CONNECTIVITY REP'N TO DAMSEL (might be tag, don't know yet)
00231     //    6d3: if collection:
00232     //    - (everything in STEP 4 for this collection except for EXECUTE)
00233     //    - might need to filter out things not represented on this rank
00234     //    6d4: if sparse tag:
00235     //    - create app-side representation of sparse tag
00236     //    - READ CONTAINER OF MODEL HANDLES INTO LOCAL BUFFER
00237     //    - allocate app-side storage for tag values
00238     //    - MAP APP STORAGE TO MODEL TAG + (implicit?) CONTAINER
00239 
00240     // STEP 6e: process dense tags for the local info struct; for each dense tag:
00241     //   - get app tag handle for model tag handle
00242     //   - get app storage for app tag handle + container
00243     //   - MAP APP STORAGE TO MODEL TAG + CONTAINER
00244 
00245     // STEP 7: EXECUTE
00246     //   - assign all mapped data
00247     //   - translate all damsel handles to app handles
00248     // uninit damsel
00249 
00250     */
00251 
00252   return MB_SUCCESS;
00253 }
00254 
00255 ErrorCode ReadDamsel::read_tag_values( const char* file_name,
00256                                        const char* tag_name,
00257                                        const FileOptions& opts,
00258                                        std::vector<int>& tag_values_out,
00259                                        const SubsetList* subset_list) 
00260 {
00261   return MB_FAILURE;
00262 }
00263     
00264 ErrorCode ReadDamsel::process_tags(std::vector<damsel_tag_buf_type> &tag_infos) 
00265 {
00266   Tag tagh;
00267   ErrorCode rval = MB_SUCCESS, tmp_rval;
00268   for (std::vector<damsel_tag_buf_type>::iterator tit = tag_infos.begin(); tit != tag_infos.end(); tit++) {
00269     if (DamselUtil::dtom_data_type[(*tit).tag_datatype] == MB_TYPE_OPAQUE) {
00270       std::cout << "Damsel reader encountered opaque tag." << std::endl;
00271       continue;
00272     }
00273       
00274     tmp_rval = mbImpl->tag_get_handle((*tit).name, 1, 
00275                                       DamselUtil::dtom_data_type[(*tit).tag_datatype],
00276                                       tagh, MB_TAG_CREAT | MB_TAG_DENSE);
00277     if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00278     else {
00279       dU.tagMap.push_back(DamselUtil::tinfo(tagh, 0, MB_TAG_DENSE));
00280         // also store predefined tags specially...
00281       if (!strncmp((*tit).name, "mbdmsl_", 7)) {
00282           // predefined tag name, store the handle
00283         if (!strcmp((*tit).name, "mbdmsl_XCOORDS"))
00284           dU.xcoordsTag = dU.tagMap.back();
00285         else if (!strcmp((*tit).name, "mbdmsl_YCOORDS")) {
00286           dU.ycoordsTag = dU.tagMap.back();
00287         }
00288         else if (!strcmp((*tit).name, "mbdmsl_ZCOORDS")) {
00289           dU.zcoordsTag = dU.tagMap.back();
00290         }
00291         else if (!strcmp((*tit).name, "mbdmsl_COLL_FLAGS")) {
00292           dU.collFlagsTag = dU.tagMap.back();
00293         }
00294         else if (!strcmp((*tit).name, "mbdmsl_PARENTS")) {
00295           dU.parentsTag = dU.tagMap.back();
00296         }
00297         else if (!strcmp((*tit).name, "mbdmsl_CHILDREN")) {
00298           dU.childrenTag = dU.tagMap.back();
00299         }
00300         else {
00301           rval = MB_FAILURE;
00302           continue;
00303         }
00304       }
00305     }
00306   }
00307   
00308   return rval;
00309 }
00310 
00311 ErrorCode ReadDamsel::process_ent_info(const damsel_entity_buf_type &einfo) 
00312 {
00313     // create this chunk of entities
00314   EntityHandle *connect, start_handle;
00315   ErrorCode rval;
00316   damsel_err_t err;
00317   damsel_container app_cont;
00318   Range these_ents;
00319 
00320     // check that there's only one contiguous run of file-side handles, fail if there isn't
00321 #ifndef NDEBUG
00322   Range fside_handles;
00323   rval = DamselUtil::container_to_range(dU.dmslModel, const_cast<damsel_container&>(einfo.entity_container), 
00324                                         fside_handles);
00325   if (MB_SUCCESS != rval || fside_handles.size() != einfo.count ||
00326       fside_handles.psize() != 1) 
00327     return MB_FAILURE;
00328 #endif  
00329   
00330   if (einfo.entity_type != DAMSEL_ENTITY_TYPE_VERTEX) {
00331       // create the moab entities
00332     rval = readMeshIface->get_element_connect(einfo.count, einfo.vertices_per_entity,
00333                                               DamselUtil::dtom_entity_type[einfo.entity_type],
00334                                               0, start_handle, connect);
00335     CHK_MB_ERR(rval, " ");
00336     these_ents.insert(start_handle, start_handle+einfo.count-1);
00337 
00338       // create an app-side sequence and map to file-side container
00339     app_cont = DMSLcontainer_create_sequence(dU.dmslModel, einfo.count, start_handle, 1);
00340     err = DMSLmodel_map_handles(app_cont, einfo.entity_container);
00341     CHK_DMSL_ERR(err, "Error returned mapping entity handles.");
00342 
00343       // map connectivity
00344     assert(DMSLcontainer_count(einfo.vertex_container) == (int)(einfo.vertices_per_entity*einfo.count));
00345     rval = get_contents(dU.dmslModel, einfo.vertex_container, connect);
00346     CHK_MB_ERR(rval, "Error returned mapping connectivity.");
00347   }
00348   else {
00349       // get the number of coordinate arrays
00350     int num_ctags = 0;
00351     damsel_handle xcoord_dtag = DMSLselect_tag_by_name(dU.dmslModel, "mbdmsl_XCOORDS");
00352     if (xcoord_dtag) num_ctags++;
00353     damsel_handle ycoord_dtag = DMSLselect_tag_by_name(dU.dmslModel, "mbdmsl_YCOORDS");
00354     if (ycoord_dtag) num_ctags++;
00355     damsel_handle zcoord_dtag = DMSLselect_tag_by_name(dU.dmslModel, "mbdmsl_ZCOORDS");
00356     if (zcoord_dtag) num_ctags++;
00357     
00358       // should have one vertex per entity
00359     assert(einfo.vertices_per_entity == 1);
00360     std::vector<double*> coord_arrays;
00361     rval = readMeshIface->get_node_coords(num_ctags, einfo.count, 0, start_handle, coord_arrays);
00362     CHK_MB_ERR(rval, " ");
00363 
00364     these_ents.insert(start_handle, start_handle+einfo.count-1);
00365 
00366       // create an app-side sequence and map to file-side container
00367     app_cont = DMSLcontainer_create_sequence(dU.dmslModel, start_handle, einfo.count, 1);
00368     err = DMSLmodel_map_handles(app_cont, einfo.entity_container);
00369     CHK_DMSL_ERR(err, "Trouble mapping entity handles.");
00370 
00371       // map the coords storage
00372     if (xcoord_dtag != 0) {
00373       err = DMSLmodel_map_tag(coord_arrays[0], app_cont, (damsel_handle_ptr)&dU.xcoordsTag.mTagh); 
00374       CHK_DMSL_ERR(err, "Trouble mapping x coordinate tag.");
00375     }
00376     if (ycoord_dtag != 0) {
00377       err = DMSLmodel_map_tag(coord_arrays[1], app_cont, (damsel_handle_ptr)&dU.ycoordsTag.mTagh); 
00378       CHK_DMSL_ERR(err, "Trouble mapping y coordinate tag.");
00379     }
00380     if (zcoord_dtag != 0) {
00381       err = DMSLmodel_map_tag(coord_arrays[2], app_cont, (damsel_handle_ptr)&dU.zcoordsTag.mTagh); 
00382       CHK_DMSL_ERR(err, "Trouble mapping z coordinate tag.");
00383     }
00384   }
00385 
00386     // save mapping from moab entity to einfo
00387   dmHandleRMap.insert(DMSLcontainer_handle_at_position(einfo.entity_container, 0), start_handle, einfo.count);
00388 
00389   rval = process_entity_tags(einfo.tag_count, einfo.tag_handle_container, app_cont, these_ents);
00390   
00391   return rval;
00392 }
00393 
00394 ErrorCode ReadDamsel::process_entity_tags(int count, damsel_container tag_container, 
00395                                           damsel_container app_cont, Range &these_ents) 
00396 {
00397     // process tags on these entities
00398   ErrorCode rval = MB_SUCCESS;
00399   for (int i = 0; i < count; i++) {
00400     damsel_handle dtagh = DMSLcontainer_handle_at_position(tag_container, i);
00401 
00402       // don't do conventional tags here
00403     std::vector<DamselUtil::tinfo>::iterator vit = 
00404         std::find_if(dU.tagMap.begin(), dU.tagMap.end(), DamselUtil::DtagP<DamselUtil::tinfo>(dtagh));
00405     
00406     if ((*vit).tagType == MB_TAG_ANY) continue;
00407     else if (vit == dU.tagMap.end())
00408       CHK_MB_ERR(MB_FAILURE, "Failed to find tag.");
00409       
00410     Tag tagh = (*vit).mTagh;
00411     assert(tagh);
00412     void *tag_data;
00413     int ecount = these_ents.size();
00414     rval = mbImpl->tag_iterate(tagh, these_ents.begin(), these_ents.end(), ecount, tag_data);
00415     CHK_MB_ERR(rval, "Problem getting tag iterator.");
00416     assert(ecount == (int)these_ents.size());
00417     damsel_err_t err = DMSLmodel_map_tag(tag_data, app_cont, (damsel_handle_ptr)&tagh);
00418     CHK_DMSL_ERR(err, " ");
00419   }
00420 
00421   return rval;
00422 }
00423 
00424 ErrorCode ReadDamsel::get_contents(damsel_model m, damsel_container c, Range &ents) {
00425   EntityHandle eh;
00426   if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE) {
00427     damsel_handle start;
00428     size_t count, stride;
00429     damsel_err_t err = DMSLcontainer_sequence_get_contents(m, c, &start, &count, &stride);
00430     CHK_DMSL_ERR(err, " ");
00431     if (stride == 1) {
00432       while (count) {
00433     // get start in rangemap
00434         RangeMap<damsel_handle, EntityHandle, 0>::iterator beg = dmHandleRMap.lower_bound(start);
00435         if (beg == dmHandleRMap.end()) return MB_SUCCESS;
00436         unsigned long diff = std::max((*beg).begin-start, (damsel_handle)0);
00437         unsigned long num = std::min(count-diff, (size_t)(*beg).count);
00438         ents.insert((*beg).begin+diff, (*beg).begin+diff+num-1);
00439         count -= (diff + num);
00440         beg++;
00441       }
00442     }
00443     else {
00444       for (int i = count-1; i >= 0; i--) {
00445         if (dmHandleRMap.find(start+i, eh)) ents.insert(eh);
00446       }
00447     }
00448   }
00449   else if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR) {
00450     damsel_handle *handle_ptr;
00451     size_t count;
00452     damsel_err_t err = DMSLcontainer_vector_get_contents(m, c, &handle_ptr, &count);
00453     CHK_DMSL_ERR(err, "Trouble getting vector contents.");
00454     for (int i = count-1; i >= 0; i--) {
00455       if (dmHandleRMap.find(handle_ptr[i], eh)) ents.insert(eh);
00456     }
00457   }
00458   else if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE) {
00459     damsel_handle_ptr node_ptr = NULL;
00460     damsel_container cont = NULL;
00461     while (DMSLcontainer_tree_get_contents(m, c, &node_ptr, &cont) == DMSL_OK &&
00462            cont) {
00463       ErrorCode rval = get_contents(m, c, ents);
00464       if (MB_SUCCESS != rval) return rval;
00465     }
00466   }
00467 
00468   return MB_SUCCESS;
00469 }
00470 
00471 ErrorCode ReadDamsel::get_contents(damsel_model m, damsel_container c, EntityHandle *ents) {
00472   EntityHandle eh;
00473   int ind = 0;
00474   
00475   if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE) {
00476     damsel_handle start;
00477     size_t count, stride;
00478     damsel_err_t err = DMSLcontainer_sequence_get_contents(m, c, &start, &count, &stride);
00479     CHK_DMSL_ERR(err, " ");
00480     if (stride == 1) {
00481       while (count) {
00482     // get start in rangemap
00483         RangeMap<damsel_handle, EntityHandle, 0>::iterator beg = dmHandleRMap.lower_bound(start);
00484         if (beg == dmHandleRMap.end()) return MB_SUCCESS;
00485         unsigned int diff = std::max((*beg).begin-start, (damsel_handle)0);
00486         unsigned int num = std::min(count-diff, (size_t)(*beg).count);
00487         for (EntityHandle hdl = (*beg).begin+diff; hdl <= (int)(*beg).begin+diff+num-1; hdl++)
00488           ents[ind++] = hdl;
00489         count -= (diff + num);
00490         beg++;
00491       }
00492     }
00493     else {
00494       for (int i = count-1; i >= 0; i--) {
00495         if (dmHandleRMap.find(start+i, eh)) ents[i] = eh;
00496       }
00497     }
00498   }
00499   else if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR) {
00500     damsel_handle_ptr handle_ptr;
00501     size_t count;
00502     damsel_err_t err = DMSLcontainer_vector_get_contents(m, c, &handle_ptr, &count); 
00503     CHK_DMSL_ERR(err, "Failed to get vector contents.");
00504     for (int i = count-1; i >= 0; i--) {
00505       if (dmHandleRMap.find(handle_ptr[i], eh)) ents[i] = eh;
00506     }
00507   }
00508   else if (DMSLcontainer_get_type(c) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE) {
00509     damsel_handle_ptr node_ptr = NULL;
00510     damsel_container cont = NULL;
00511     while (DMSLcontainer_tree_get_contents(m, c, &node_ptr, &cont) == DMSL_OK &&
00512            cont) {
00513       ErrorCode rval = get_contents(m, cont, ents);
00514       if (MB_SUCCESS != rval) return rval;
00515       unsigned int num = DMSLcontainer_count(cont);
00516       ents += num;
00517     }
00518   }
00519 
00520   return MB_SUCCESS;
00521 }
00522 
00523 /*
00524   
00525 ErrorCode ReadDamsel::process_coll_infos(std::vector<damsel_collection_buf_type> &coll_infos) 
00526 {
00527   ErrorCode rval = MB_SUCCESS, tmp_rval;
00528   EntityHandle seth;
00529   std::vector<subrange> handle_subranges;
00530   for (std::vector<damsel_collection_buf_type>::iterator cit = coll_infos.begin(); cit != coll_infos.end(); cit++) {
00531       // make the set
00532     tmp_rval = mbImpl->create_meshset(((*cit).type ==  DAMSEL_HANDLE_COLLECTION_TYPE_SET ? MESHSET_SET : MESHSET_ORDERED),
00533                                       seth);
00534     if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00535       // make datastructures to pass things to process_entity_tags
00536     Range tmp_range(seth, seth);
00537     damsel_container ch = DMSLcontainer_create_sequence(dU.dmslModel, seth, 1, 1);
00538 
00539       // get the tags on this set
00540     tmp_rval = process_entity_tags((*cit).tag_count, (*cit).tag_handle_container, ch, tmp_range);
00541     if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00542 
00543       // process the set contents
00544     if ((*cit).type == DAMSEL_HANDLE_COLLECTION_TYPE_SET) {
00545       Range ents;
00546       tmp_rval = get_contents(dU.dmslModel, (*cit).contents, ents);
00547       if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00548       else if (!ents.empty()) {
00549     tmp_rval = mbImpl->add_entities(seth, ents);
00550     if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00551       }
00552     }
00553     else {
00554       std::vector<EntityHandle> ents(DMSLcontainer_count((*cit).contents));
00555       tmp_rval = get_contents(dU.dmslModel, (*cit).contents, &ents[0]);
00556       if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00557       else if (!ents.empty()) {
00558     tmp_rval = mbImpl->add_entities(seth, &ents[0], ents.size());
00559     if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
00560       }
00561     }
00562 
00563       // get the file handle for this collection, and map it to moab's set handle
00564     damsel_handle collh = (damsel_handle)(*((*cit).collection_handle));
00565     if (handle_subranges.empty() || seth != (*handle_subranges.rbegin()).seth+1 ||
00566         collh != (*handle_subranges.rbegin()).collh+1) {
00567       handle_subranges.push_back(subrange(collh, seth, 1));
00568     }
00569     else (*handle_subranges.rbegin()).count++;
00570   }
00571   
00572   for (std::vector<subrange>::iterator vit = handle_subranges.begin(); vit != handle_subranges.end(); vit++)
00573     dmHandleRMap.insert((*vit).collh, (*vit).seth, (*vit).count);
00574     
00575   return rval;
00576 }
00577 
00578 
00579 */
00580 
00581 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines