moab
|
#include <WriteDamsel.hpp>
Public Types | |
enum | { DAMSEL_IS_TRACKING = 0x1 } |
Public Member Functions | |
WriteDamsel (Interface *impl) | |
Constructor. | |
virtual | ~WriteDamsel () |
Destructor. | |
ErrorCode | write_file (const char *file_name, const bool, const FileOptions &opts, const EntityHandle *meshset_list, const int num_sets, const std::vector< std::string > &, const Tag *=NULL, int=0, int=3) |
Static Public Member Functions | |
static WriterIface * | factory (Interface *iface) |
factory function, for ReaderWriter | |
Public Attributes | |
enum moab::WriteDamsel:: { ... } | DAMSEL_FLAGS |
Private Member Functions | |
ErrorCode | init_tag_info () |
Initialize global information about dense/sparse/conventional tags, once for entire write_file call. | |
ErrorCode | write_subrange (RangeSeqIntersectIter &rsi) |
write a subrange of entities/sets; just a wrapper to write_[vertices, entities, sets] | |
ErrorCode | write_vertices (RangeSeqIntersectIter &rsi) |
ErrorCode | write_entities (RangeSeqIntersectIter &rsi) |
ErrorCode | write_sets (RangeSeqIntersectIter &rsi) |
ErrorCode | map_dense_tags (RangeSeqIntersectIter &rsi, damsel_container &ent_cont) |
Map dense tags for the specified entities, using the specified damsel entity container. | |
ErrorCode | map_sparse_tags () |
Map sparse tags for all entities. | |
Private Attributes | |
Interface * | mbImpl |
interface instance | |
WriteUtilIface * | mWriteIface |
WriteUtil object used in this writer. | |
Error * | mError |
Error object used to register errors. | |
SequenceManager * | sequenceManager |
Used to initialize the RangeSeqIntersectIter. | |
std::string | fileName |
file name | |
DamselUtil | dU |
utility for storing damsel-specific stuff |
Definition at line 40 of file WriteDamsel.hpp.
anonymous enum |
Definition at line 73 of file WriteDamsel.hpp.
{DAMSEL_IS_TRACKING = 0x1 } DAMSEL_FLAGS;
moab::WriteDamsel::WriteDamsel | ( | Interface * | impl | ) |
Constructor.
Definition at line 69 of file WriteDamsel.cpp.
: mbImpl(impl), mWriteIface(NULL), mError(NULL), sequenceManager(NULL), dU() { assert(impl != NULL); impl->query_interface( mWriteIface ); assert(mWriteIface); sequenceManager = dynamic_cast<Core*>(impl)->sequence_manager(); assert(sequenceManager); impl->query_interface(mError); assert(mError); ErrorCode rval = mbImpl->tag_get_handle("mbdmsl_XCOORDS", 1, MB_TYPE_DOUBLE, dU.xcoordsTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_XCOORDS."); dU.xcoordsTag.tagType = MB_TAG_ANY; dU.tagMap.push_back(dU.xcoordsTag); rval = mbImpl->tag_get_handle("mbdmsl_YCOORDS", 1, MB_TYPE_DOUBLE, dU.ycoordsTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_YCOORDS."); dU.ycoordsTag.tagType = MB_TAG_ANY; dU.tagMap.push_back(dU.ycoordsTag); rval = mbImpl->tag_get_handle("mbdmsl_ZCOORDS", 1, MB_TYPE_DOUBLE, dU.zcoordsTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_ZCOORDS."); dU.zcoordsTag.tagType = MB_TAG_ANY; dU.tagMap.push_back(dU.zcoordsTag); rval = mbImpl->tag_get_handle("mbdmsl_COLL_FLAGS", 1, MB_TYPE_INTEGER, dU.collFlagsTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_COLL_FLAGS."); dU.collFlagsTag.tagType = MB_TAG_ANY; dU.tagMap.push_back(dU.collFlagsTag); /* rval = mbImpl->tag_get_handle("mbdmsl_PARENTS", 1, MB_TYPE_HANDLE, dU.parentsTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT|MB_TAG_VARLEN); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_PARENTS."); dU.parentsTag.tagType = MB_TAG_DENSE; dU.tagMap.push_back(dU.parentsTag); rval = mbImpl->tag_get_handle("mbdmsl_CHILDREN", 1, MB_TYPE_HANDLE, dU.childrenTag.mTagh, MB_TAG_DENSE|MB_TAG_CREAT|MB_TAG_VARLEN); CHK_MB_ERR_NR(rval, "Failed to create_tag mbdmsl_CHILDREN."); dU.childrenTag.tagType = MB_TAG_DENSE; dU.tagMap.push_back(dU.childrenTag); */ dU.moabHandleType = (sizeof(EntityHandle) == 64 ? DAMSEL_HANDLE_TYPE_HANDLE64 : DAMSEL_HANDLE_TYPE_HANDLE32); }
moab::WriteDamsel::~WriteDamsel | ( | ) | [virtual] |
Destructor.
Definition at line 126 of file WriteDamsel.cpp.
{ if (mWriteIface) mbImpl->release_interface(mWriteIface); if (mError) mbImpl->release_interface(mError); }
WriterIface * moab::WriteDamsel::factory | ( | Interface * | iface | ) | [static] |
factory function, for ReaderWriter
Definition at line 66 of file WriteDamsel.cpp.
{ return new WriteDamsel( iface ); }
ErrorCode moab::WriteDamsel::init_tag_info | ( | ) | [private] |
Initialize global information about dense/sparse/conventional tags, once for entire write_file call.
Definition at line 204 of file WriteDamsel.cpp.
{ // initialize allTags and tagIndices std::vector<Tag> tmp_mtags; ErrorCode rval = mbImpl->tag_get_tags(tmp_mtags); CHK_MB_ERR(rval, "Failed to get all tag handles."); int dum_size; damsel_err_t err; // define damsel tag handles for all dense/sparse tags for (std::vector<Tag>::iterator vit = tmp_mtags.begin(); vit != tmp_mtags.end(); vit++) { if (((*vit)->get_storage_type() != MB_TAG_DENSE && (*vit)->get_storage_type() != MB_TAG_SPARSE) || mbImpl->tag_get_length(*vit, dum_size) == MB_VARIABLE_DATA_LENGTH || dum_size != 1) { std::cerr << "Warning: tag " << (*vit)->get_name() << "is not of type dense or sparse, and is not currently supported by the damsel writer." << std::endl; continue; } std::vector<DamselUtil::tinfo>::iterator vit2 = std::find_if(dU.tagMap.begin(), dU.tagMap.end(), DamselUtil::MtagP<DamselUtil::tinfo>(*vit)); if (vit2 != dU.tagMap.end() && (*vit2).tagType == MB_TAG_ANY) // conventional tag - skip continue; else if (vit2 == dU.tagMap.end()) { // create a damsel counterpart for this tag Tag thandle = *vit; err = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&thandle, DamselUtil::mtod_data_type[(*vit)->get_data_type()], (*vit)->get_name().c_str()); CHK_DMSL_ERR(err, "Failure to get Damsel tag for MOAB tag ."); dU.tagMap.push_back(DamselUtil::tinfo(thandle, 0, (*vit)->get_storage_type())); } else { // assert there's a corresponding moab tag handle assert((*vit2).mTagh); } } // do the same for conventional tags: // XCOORDS err = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.xcoordsTag.mTagh), DamselUtil::mtod_data_type[MB_TYPE_DOUBLE], dU.xcoordsTag.mTagh->get_name().c_str()); dU.tagMap.push_back(dU.xcoordsTag); CHK_DMSL_ERR(err, "Failure to get Damsel tag for MOAB tag."); // YCOORDS err = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.ycoordsTag.mTagh), DamselUtil::mtod_data_type[MB_TYPE_DOUBLE], dU.ycoordsTag.mTagh->get_name().c_str()); dU.tagMap.push_back(dU.ycoordsTag); CHK_DMSL_ERR(err, "Failure to get Damsel tag for MOAB tag."); // ZCOORDS err = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.zcoordsTag.mTagh), DamselUtil::mtod_data_type[MB_TYPE_DOUBLE], dU.zcoordsTag.mTagh->get_name().c_str()); dU.tagMap.push_back(dU.zcoordsTag); CHK_DMSL_ERR(err, "Failure to get Damsel tag for MOAB tag."); // COLL_FLAGS err = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.collFlagsTag.mTagh), DamselUtil::mtod_data_type[MB_TYPE_INTEGER], dU.collFlagsTag.mTagh->get_name().c_str()); dU.tagMap.push_back(dU.collFlagsTag); CHK_DMSL_ERR(err, "Failure to get Damsel tag for MOAB tag."); /* SKIP PARENTS/CHILDREN FOR NOW, UNTIL WE HAVE VAR LENGTH TAGS IN DAMSEL // PARENTS dU.parentsTagPair.second = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.collFlagsTagPair.first), DamselUtil::mtod_data_type[(dU.collFlagsTagPair.first)->get_data_type()], (dU.parentsTagPair.first)->get_name().c_str()); if (DAMSEL_TAG_INVALID == dtag) CHK_MB_ERR_2(MB_FAILURE, "Failure to get Damsel tag for MOAB tag %s.", (dU.parentsTagPair.first)->get_name()); // CHILDREN dU.childrenTagPair.second = DMSLtag_define(dU.dmslModel, (damsel_handle_ptr)&(dU.collFlagsTagPair.first), DamselUtil::mtod_data_type[(dU.collFlagsTagPair.first)->get_data_type()], (dU.childrenTagPair.first)->get_name().c_str()); if (DAMSEL_TAG_INVALID == dtag) CHK_MB_ERR_2(MB_FAILURE, "Failure to get Damsel tag for MOAB tag %s.", (dU.childrenTagPair.first)->get_name()); */ // map the tag handles in one big call int num_tags = dU.tagMap.size(); std::vector<Tag> moab_taghs; moab_taghs.reserve(num_tags); for (std::vector<DamselUtil::tinfo>::iterator vit = dU.tagMap.begin(); vit != dU.tagMap.end(); vit++) { moab_taghs.push_back((*vit).mTagh); } damsel_container mtags = DMSLcontainer_create_vector(dU.dmslModel, (damsel_handle_ptr)&moab_taghs[0], moab_taghs.size()); std::cerr << "MOAB: created model container: mtags = " << mtags <<std::endl; err = DMSLmodel_map_handles_inventing_file_handles(mtags); CHK_DMSL_ERR(err, "Failed to map tag handles."); err = DMSLcontainer_release(mtags); CHK_DMSL_ERR(err, "Problem releasing tag handle container."); return MB_SUCCESS; }
ErrorCode moab::WriteDamsel::map_dense_tags | ( | RangeSeqIntersectIter & | rsi, |
damsel_container & | ent_cont | ||
) | [private] |
Map dense tags for the specified entities, using the specified damsel entity container.
Definition at line 424 of file WriteDamsel.cpp.
{ // 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 moab::WriteDamsel::map_sparse_tags | ( | ) | [private] |
Map sparse tags for all entities.
Definition at line 454 of file WriteDamsel.cpp.
{ // all sparse_tags have been initialized before this, so here we just go through // them and map data if there is any ErrorCode rval = MB_SUCCESS; damsel_err_t err; std::vector<DamselUtil::tinfo>::iterator tagit; std::vector<unsigned char> tag_values; std::vector<EntityHandle> tagged_ents; damsel_container ent_cont; for (tagit = dU.tagMap.begin(); tagit != dU.tagMap.end(); tagit++) { if ((*tagit).tagType != MB_TAG_SPARSE) continue; // get a ptr to memory for this tag/sequence SparseTag *stag = dynamic_cast<SparseTag*>((*tagit).mTagh); assert(stag); Range output_ents; rval = stag->get_tagged_entities(sequenceManager, output_ents); CHK_MB_ERR_2(rval, "Trouble getting tagged entities for tag %s.", stag->get_name().c_str()); // if no entities have this tag set, don't map it if (output_ents.empty()) continue; // else, register with damsel // allocate space for and get values tag_values.resize(stag->get_size() * output_ents.size()); rval = mbImpl->tag_get_data(stag, output_ents, &tag_values[0]); CHK_MB_ERR_2(rval, "Trouble getting tag values for tag %s.", stag->get_name().c_str()); // build a vector of entity handles from the range, and a container from that tagged_ents.resize(output_ents.size()); std::copy(output_ents.begin(), output_ents.end(), tagged_ents.begin()); ent_cont = DMSLcontainer_create_vector(dU.dmslModel, (damsel_handle_ptr)&tagged_ents[0], tagged_ents.size()); std::cerr << "MOAB: created model container: sparse_tag_ent_cont = " << ent_cont <<std::endl; if (ent_cont == DAMSEL_CONTAINER_INVALID) CHK_MB_ERR_2(MB_FAILURE, "Trouble creating entity handle container for tag %s.", stag->get_name().c_str()); // now map it err = DMSLmodel_map_tag((void*)&tag_values[0], ent_cont, (damsel_handle_ptr)&stag); CHK_DMSL_ERR_2(err, "Failed to write tag %s.", stag->get_name().c_str()); err = DMSLcontainer_release(ent_cont); CHK_DMSL_ERR(err, "Problem releasing entity handle container."); } return rval; }
ErrorCode moab::WriteDamsel::write_entities | ( | RangeSeqIntersectIter & | rsi | ) | [private] |
Write the entities in the model, for the handles in the specified RangeSeqIntersectIter
rsi | Range sequence iterator defining range of entities/sets to be written |
Definition at line 378 of file WriteDamsel.cpp.
{ // 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; }
ErrorCode moab::WriteDamsel::write_file | ( | const char * | file_name, |
const bool | , | ||
const FileOptions & | opts, | ||
const EntityHandle * | meshset_list, | ||
const int | num_sets, | ||
const std::vector< std::string > & | , | ||
const Tag * | = NULL , |
||
int | = 0 , |
||
int | = 3 |
||
) | [virtual] |
Primary interface function
file_name | Filename being written |
overwrite | If true and the file exists, an error is returned |
opts | File options, e.g. whether and how to write in parallel |
meshset_list | If non-NULL, a vector of sets defining what is to be written |
num_sets | The number of sets to be written, only used if meshset_list is non-NULL |
qa_records | Strings defining provenance information |
tag_list | If non-NULL, only these tags should be written |
num_tags | The number of tag handles in tag_list, used only if tag_list is non-NULL |
requested_output_dimension | Dimension used for coordinates |
Implements moab::WriterIface.
Definition at line 132 of file WriteDamsel.cpp.
{ // gather all entities into one big range Range all_ents; ErrorCode rval; damsel_err_t err; dU.dmslLib = DMSLlib_init(); // create a damsel model dU.dmslModel = DMSLmodel_create(sizeof(EntityHandle) == 8 ? DAMSEL_HANDLE_TYPE_HANDLE64 : DAMSEL_HANDLE_TYPE_HANDLE32); // attach to a file, since we need it for creating containers MPI_Comm comm = MPI_COMM_WORLD; unlink(file_name); err = DMSLmodel_attach(dU.dmslModel, file_name, comm, NULL); CHK_DMSL_ERR(err, "DMSLmodel_attach failed."); rval = mWriteIface->gather_entities(all_ents, meshset_list, num_sets); CHK_MB_ERR(rval, "Gather entities failed in WriteDamsel."); if (all_ents.empty()) return MB_SUCCESS; // create damsel tags for MOAB dense, sparse, and conventional tags rval = init_tag_info(); CHK_MB_ERR(rval, NULL); // iterate through the groups of contiguous sequences of handles RangeSeqIntersectIter rsi(sequenceManager); rval = rsi.init(all_ents.begin(), all_ents.end()); while (rval == MB_SUCCESS) { // write subrange of things to damsel: map handles, map entity definition data (connectivity/coords/set contents), // map dense tags rval = write_subrange(rsi); CHK_MB_ERR(rval, "Failed to write subrange."); rval = rsi.step(); while (MB_ENTITY_NOT_FOUND == rval) rval = rsi.step(); } // write sparse tags rval = map_sparse_tags(); CHK_MB_ERR(rval, "Failed to write sparse tags."); //damsel_request_t request; //err = DMSLmodel_transfer_async(dU.dmslModel, DAMSEL_TRANSFER_TYPE_WRITE, &request); err = DMSLmodel_transfer_sync(dU.dmslModel, DAMSEL_TRANSFER_TYPE_WRITE); CHK_DMSL_ERR(err, "DMSLmodel_transfer_asynch failed."); //damsel_status_t status; //err = DMSLmodel_wait(request, &status); CHK_DMSL_ERR(err, "DMSLmodel_wait failed."); DMSLmodel_close(dU.dmslModel); DMSLlib_finalize(dU.dmslLib); // we should be done return MB_SUCCESS; }
ErrorCode moab::WriteDamsel::write_sets | ( | RangeSeqIntersectIter & | rsi | ) | [private] |
Write the sets in the model, for the handles in the specified RangeSeqIntersectIter
rsi | Range sequence iterator defining range of entities/sets to be written |
Definition at line 501 of file WriteDamsel.cpp.
{ // write the sets ErrorCode rval = MB_SUCCESS; std::vector<EntityHandle> ents; damsel_container mcont; damsel_err_t err; unsigned int i, num_sets = rsi.get_end_handle() - rsi.get_start_handle() + 1; std::vector<unsigned int> set_flags(num_sets, 0); EntityHandle seth; for (seth = rsi.get_start_handle(), i = 0; seth <= rsi.get_end_handle(); seth++, i++) { // get all the entities in the set ents.clear(); rval = mbImpl->get_entities_by_handle(seth, ents); CHK_MB_ERR_2(rval, "get_entities_by_handle failed for set %lu.", seth); if (!ents.empty()) { mcont = DMSLcontainer_create_vector(dU.dmslModel, (damsel_handle*)&ents[0], ents.size()); } else { mcont = DMSLcontainer_create_vector(dU.dmslModel, (damsel_handle*)NULL, 0); } std::cerr << "MOAB: created model container: sets_cont = " << mcont <<std::endl; // get the set type (range or set) unsigned int opts; rval = mbImpl->get_meshset_options(seth, opts); CHK_MB_ERR_2(rval, "Failed to get options for meshset %lu.", seth); damsel_collection_type coll_type = (opts&MESHSET_SET ? DAMSEL_HANDLE_COLLECTION_TYPE_SET : DAMSEL_HANDLE_COLLECTION_TYPE_VECTOR); // parents/children... // set flags if (opts & MESHSET_TRACK_OWNER) set_flags[i] |= MESHSET_TRACK_OWNER; else set_flags[i] &= !MESHSET_TRACK_OWNER; // create the collection DMSLcoll_create(dU.dmslModel, (damsel_handle_ptr) &seth, mcont, coll_type); // release the container err = DMSLcontainer_release(mcont); CHK_DMSL_ERR(err, "Problem releasing set entity handle container."); } // set the COLL_FLAGS tag, using assign (direct) // make a container of set handles... mcont = DMSLcontainer_create_sequence(dU.dmslModel, rsi.get_start_handle(), num_sets, 1); std::cerr << "MOAB: created model container: sets_cont = " << mcont <<std::endl; // assign the tags on them err = DMSLmodel_map_tag(&set_flags[0], mcont, (damsel_handle_ptr)&(dU.collFlagsTag.mTagh)); CHK_DMSL_ERR(err, "Failed to assign COLL_FLAGS tag for sets."); err = DMSLmodel_map_handles_inventing_file_handles(mcont); CHK_DMSL_ERR(err, "Failed to map set handles."); // map other dense tags rval = map_dense_tags(rsi, mcont); CHK_MB_ERR(rval, "Failed to map dense tags for sets."); return rval; }
ErrorCode moab::WriteDamsel::write_subrange | ( | RangeSeqIntersectIter & | rsi | ) | [inline, private] |
write a subrange of entities/sets; just a wrapper to write_[vertices, entities, sets]
Definition at line 121 of file WriteDamsel.hpp.
{ ErrorCode rval = MB_SUCCESS; if (MBVERTEX == mbImpl->type_from_handle(rsi.get_start_handle())) rval = write_vertices(rsi); else if (MBENTITYSET > mbImpl->type_from_handle(rsi.get_start_handle())) rval = write_entities(rsi); // else // rval = write_sets(rsi); return rval; }
ErrorCode moab::WriteDamsel::write_vertices | ( | RangeSeqIntersectIter & | rsi | ) | [private] |
Write the vertices in the model, for the handles in the specified RangeSeqIntersectIter
rsi | Range sequence iterator defining range of entities/sets to be written |
Definition at line 314 of file WriteDamsel.cpp.
{ // write the vertices; these vertices will be in the same sequence and will be contiguous, guaranteed EntityHandle start_vert = rsi.get_start_handle(), end_vert = rsi.get_end_handle(); // create a damsel container for these vertex handles damsel_container vertex_cont = DMSLcontainer_create_sequence(dU.dmslModel, start_vert, (int)(end_vert-start_vert+1), 1); std::cerr << "MOAB: created model container: vertex_cont = " << vertex_cont <<std::endl; if (DAMSEL_CONTAINER_INVALID == vertex_cont) CHK_MB_ERR_2(MB_FAILURE, "Failed to create vertex sequence for vertices starting with handle %lu.", rsi.get_start_handle()); damsel_err_t err = DMSLmodel_map_handles_inventing_file_handles(vertex_cont); CHK_DMSL_ERR(err, "Failed to map handles."); // define the entities to damsel err = DMSLentity_define(vertex_cont, DAMSEL_ENTITY_TYPE_VERTEX, 1, vertex_cont); CHK_DMSL_ERR_2(err, "Failure in DMSLentity_define for vertices starting with handle %lu.", rsi.get_start_handle()); // get the vertex coordinates storage locations and pass to damsel Range vert_range(start_vert, end_vert); double *xcoords = NULL, *ycoords = NULL, *zcoords = NULL; int count; ErrorCode rval = mbImpl->coords_iterate(vert_range.begin(), vert_range.end(), xcoords, ycoords, zcoords, count); CHK_MB_ERR_2(rval, "Failed to get coordinate iterator for vertices starting with handle %lu.", rsi.get_start_handle()); if (count != (int)vert_range.size()) { CHK_MB_ERR_2(MB_FAILURE, "Vertex subrange not in the same sequence for vertices starting with handle %lu.", rsi.get_start_handle()); } if (xcoords && !ycoords && !zcoords) { // interleaved // map the data to damsel err = DMSLmodel_map_tag(xcoords, vertex_cont, (damsel_handle_ptr)&dU.xcoordsTag.mTagh); CHK_DMSL_ERR_2(err, "Failed to assign vertex coordinates tag for vertices starting with handle %lu.", rsi.get_start_handle()); } else { // map the data to damsel err = DMSLmodel_map_tag(xcoords, vertex_cont, (damsel_handle_ptr)&dU.xcoordsTag.mTagh); CHK_DMSL_ERR_2(err, "Failed to assign vertex x coordinates tag for vertices starting with handle %lu.", rsi.get_start_handle()); err = DMSLmodel_map_tag(ycoords, vertex_cont, (damsel_handle_ptr)&dU.ycoordsTag.mTagh); CHK_DMSL_ERR_2(err, "Failed to assign vertex y coordinates tag for vertices starting with handle %lu.", rsi.get_start_handle()); err = DMSLmodel_map_tag(zcoords, vertex_cont, (damsel_handle_ptr)&dU.zcoordsTag.mTagh); CHK_DMSL_ERR_2(err, "Failed to assign vertex z coordinates tag for vertices starting with handle %lu.", rsi.get_start_handle()); } // write/map dense tags rval = map_dense_tags(rsi, vertex_cont); CHK_MB_ERR(rval, NULL); err = DMSLcontainer_release(vertex_cont); CHK_DMSL_ERR(err, "Problem releasing vertex handle container."); return MB_SUCCESS; }
enum { ... } moab::WriteDamsel::DAMSEL_FLAGS |
DamselUtil moab::WriteDamsel::dU [private] |
utility for storing damsel-specific stuff
Definition at line 118 of file WriteDamsel.hpp.
std::string moab::WriteDamsel::fileName [private] |
file name
Definition at line 115 of file WriteDamsel.hpp.
Interface* moab::WriteDamsel::mbImpl [private] |
interface instance
Definition at line 103 of file WriteDamsel.hpp.
Error* moab::WriteDamsel::mError [private] |
Error object used to register errors.
Definition at line 109 of file WriteDamsel.hpp.
WriteUtilIface* moab::WriteDamsel::mWriteIface [private] |
WriteUtil object used in this writer.
Definition at line 106 of file WriteDamsel.hpp.
Used to initialize the RangeSeqIntersectIter.
Definition at line 112 of file WriteDamsel.hpp.