ErrorCode WriteDamsel::map_dense_tags(RangeSeqIntersectIter &rsi, damsel_container &ent_cont) { // all dense_tags have been initialized before this, so here we just go through // them and map data if there is any const unsigned char *val_ptr; ErrorCode rval = MB_SUCCESS; std::vector<DamselUtil::tinfo>::iterator tagit; damsel_err_t err; for (tagit = dU.tagMap.begin(); tagit != dU.tagMap.end(); tagit++) { if ((*tagit).tagType != MB_TAG_DENSE) continue; // get a ptr to memory for this tag/sequence DenseTag *dtag = dynamic_cast<DenseTag*>((*tagit).mTagh); assert(dtag); rval = dtag->get_array(rsi.get_sequence(), val_ptr); CHK_MB_ERR_2(rval, "Failed to get tag coordinates pointer for vertices starting with handle %lu.", rsi.get_start_handle()); // if ptr is NULL, no data for this tag in this sequence if (!val_ptr) continue; // else, register with damsel err = DMSLmodel_map_tag((void*)val_ptr, ent_cont, (damsel_handle_ptr)&dtag); CHK_DMSL_ERR_2(err, "Failed to write coordinates tag for vertices starting with handle %lu.", rsi.get_start_handle()); } return rval; }
ErrorCode WriteDamsel::write_entities(RangeSeqIntersectIter &rsi) { // write the entities; these entities will be in the same sequence and will be contiguous, guaranteed EntityHandle start_ent = rsi.get_start_handle(), end_ent = rsi.get_end_handle(); // create a damsel container for these entity handles damsel_container ent_cont; ent_cont = DMSLcontainer_create_sequence(dU.dmslModel, start_ent, (int)(end_ent-start_ent+1), 1); std::cerr << "MOAB: created model container: ent_cont = " << ent_cont <<std::endl; if (DAMSEL_CONTAINER_INVALID == ent_cont) CHK_MB_ERR(MB_FAILURE, "Bad sequence returned by Damsel."); damsel_err_t err = DMSLmodel_map_handles_inventing_file_handles(ent_cont); CHK_DMSL_ERR(err, "Failed to map handles."); // get # verts per entity and entity type EntityType etype = mbImpl->type_from_handle(start_ent); assert(MBMAXTYPE != etype); int num_connect = rsi.get_sequence()->values_per_entity(); assert(0 < num_connect); // get the connectivity storage location and pass to damsel Range ent_range(start_ent, end_ent); int count; EntityHandle *connect; int verts_per_ent; ErrorCode rval = mbImpl->connect_iterate(ent_range.begin(), ent_range.end(), connect, verts_per_ent, count); CHK_MB_ERR_2(rval, "Failed to get connect iterator for entities starting with handle %lu.", rsi.get_start_handle()); if (count != (int)ent_range.size()) CHK_MB_ERR_2(MB_FAILURE, "Entity subrange not in the same sequence for entities starting with handle %lu.", rsi.get_start_handle()); // define the entities to damsel err = DMSLentity_define_fast(ent_cont, DamselUtil::mtod_entity_type[etype], num_connect, (damsel_handle*)connect); CHK_DMSL_ERR_2(err, "DMSLentity_define failed for entities starting with handle %lu.", rsi.get_start_handle()); // write dense tags rval = map_dense_tags(rsi, ent_cont); CHK_MB_ERR(rval, NULL); err = DMSLcontainer_release(ent_cont); CHK_DMSL_ERR(err, "Problem releasing entity handle container."); return MB_SUCCESS; }