void test_tags_retrieval() { iMesh_Instance mesh; int err; iMesh_newMesh("", &mesh, &err, 0); CHECK_EQUAL( iBase_SUCCESS, err ); iBase_EntitySetHandle root_set; iMesh_getRootSet(mesh, &root_set, &err); CHECK_EQUAL( iBase_SUCCESS, err ); // open a file with var len tags (sense tags) // they should be filtered out std::string filename = STRINGIFY(MESHDIR) "/PB.h5m"; iMesh_load(mesh, root_set, filename.c_str(), NULL, &err, filename.length(), 0); CHECK_EQUAL( iBase_SUCCESS, err ); iBase_EntitySetHandle* contained_set_handles = NULL; int contained_set_handles_allocated = 0; int contained_set_handles_size; // get all entity sets iMesh_getEntSets(mesh, root_set, 1, &contained_set_handles, &contained_set_handles_allocated, &contained_set_handles_size, &err ); CHECK_EQUAL( iBase_SUCCESS, err ); // get tags for all sets for (int i=0; i< contained_set_handles_size; i++) { iBase_TagHandle* tag_handles = NULL; int tag_handles_allocated=0; int tag_handles_size; iMesh_getAllEntSetTags (mesh, contained_set_handles[i], &tag_handles, &tag_handles_allocated, &tag_handles_size, &err); CHECK_EQUAL( iBase_SUCCESS, err ); for (int j=0; j<tag_handles_size; j++) { int tagSize; iMesh_getTagSizeValues(mesh, tag_handles[j], &tagSize, &err); CHECK_EQUAL( iBase_SUCCESS, err ); } free(tag_handles); } free (contained_set_handles); // Delete the iMesh instance iMesh_dtor(mesh, &err); CHECK_EQUAL(iBase_SUCCESS, err); return; }
/**\brief Add copied entities/sets recursively * * Helper function for process_ce_sets. This adds any entities directly * contained in the current set to the dest set and then loops through the * contained sets and adds the children if they are also CE sets. If not, it * adds the entities in the child set and recurses down a level. * \param imeshImpl the iMesh instance handle * \param src the source set * \param current the child set to examine (start with current == src) * \param local_tag the tag relating source and target sets */ static void process_ce_subsets(iMesh_Instance imeshImpl, iBase_EntitySetHandle src, iBase_EntitySetHandle current, const std::set<iBase_EntitySetHandle> &cesets, iBase_TagHandle local_tag) { int err; iBase_EntitySetHandle dest; // First, add entities directly contained in this set. std::vector<iBase_EntityHandle> tmp_tags; get_copied_ents(imeshImpl, current, local_tag, tmp_tags); if (!tmp_tags.empty()) { get_dest_set(imeshImpl, local_tag, src, &dest); iMesh_addEntArrToSet(imeshImpl, &tmp_tags[0], tmp_tags.size(), dest, &err); check_error(imeshImpl, err); } // Next, start looking at children. SimpleArray<iBase_EntitySetHandle> children; iMesh_getEntSets(imeshImpl, current, 1, ARRAY_INOUT(children), &err); check_error(imeshImpl, err); for (int i = 0; i < children.size(); i++) { // If this child set is one of our cesets, add just the set... if (cesets.find(children[i]) != cesets.end()) { get_dest_set(imeshImpl, local_tag, src, &dest); if (src == dest) continue; iMesh_addEntSet(imeshImpl, children[i], dest, &err); check_error(imeshImpl, err); } // ... otherwise, add the entities and recurse into the next level of // children. else { process_ce_subsets(imeshImpl, src, children[i], cesets, local_tag); } } }