moab
|
00001 00009 #include "moab/Core.hpp" 00010 #include "moab/Range.hpp" 00011 #include "moab/CN.hpp" 00012 #include <iostream> 00013 00014 using namespace moab; 00015 using namespace std; 00016 00017 #ifndef MESH_DIR 00018 #define MESH_DIR "." 00019 #endif 00020 00021 string test_file_name = string(MESH_DIR) + string("/1hex.g"); 00022 00023 int main(int argc, char **argv) { 00024 00025 if (argc > 1){ 00026 //user has input a mesh file 00027 test_file_name = argv[1]; 00028 } 00029 // instantiate & load a mesh from a file 00030 Core *mb = new Core(); 00031 ErrorCode rval = mb->load_mesh(test_file_name.c_str()); 00032 if (MB_SUCCESS != rval) { 00033 delete mb; 00034 return 1; 00035 } 00036 00037 Range ents; 00038 00039 // get all entities in the database 00040 rval = mb->get_entities_by_handle(0, ents); 00041 if (MB_SUCCESS != rval) { 00042 delete mb; 00043 return 1; 00044 } 00045 00046 for (Range::iterator it = ents.begin(); it != ents.end(); it++) { 00047 if (MBVERTEX == mb->type_from_handle(*it)) { 00048 Range adjs; 00049 rval = mb->get_adjacencies(&(*it), 1, 3, false, adjs); 00050 if (MB_SUCCESS != rval) { 00051 delete mb; 00052 return 1; 00053 } 00054 cout << "Vertex " << mb->id_from_handle(*it) << " adjacencies:" << endl; 00055 adjs.print(); 00056 } 00057 else if (mb->type_from_handle(*it) < MBENTITYSET) { 00058 const EntityHandle *connect; 00059 int num_connect; 00060 rval = mb->get_connectivity(*it, connect, num_connect); 00061 if (MB_SUCCESS != rval) { 00062 delete mb; 00063 return 1; 00064 } 00065 cout << CN::EntityTypeName(mb->type_from_handle(*it)) << " " << mb->id_from_handle(*it) << " vertex connectivity is: "; 00066 for (int i = 0; i < num_connect; i++) 00067 cout << mb->id_from_handle(connect[i]) << " "; 00068 cout << endl; 00069 } 00070 } 00071 00072 delete mb; 00073 00074 return 0; 00075 }