moab
HelloMOAB.cpp
Go to the documentation of this file.
00001 
00010 #include "moab/Core.hpp"
00011 #include <iostream>
00012 #include <assert.h>
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("/3k-tri-sphere.vtk");
00022 
00023 int main( int argc, char** argv )
00024 {
00025   Interface *iface = new Core;
00026 
00027     // need option handling here for input filename
00028   if (argc > 1){
00029     //user has input a mesh file
00030     test_file_name = argv[1];
00031   }  
00032     //load the mesh from vtk file
00033   ErrorCode rval = iface->load_mesh( test_file_name.c_str() );
00034   assert(rval == MB_SUCCESS);
00035 
00036     // get verts entities, by type
00037   Range verts;
00038   rval = iface->get_entities_by_type(0, MBVERTEX, verts);
00039   assert(rval == MB_SUCCESS);
00040     //get edge entities, by type
00041   Range edges;
00042   rval = iface->get_entities_by_type(0, MBEDGE, edges);
00043   assert(rval == MB_SUCCESS);
00044 
00045     // get faces, by dimension, so we stay generic to entity type
00046   Range faces;
00047   rval = iface->get_entities_by_dimension(0, 2, faces);
00048   assert(rval == MB_SUCCESS);
00049 
00050     //get regions, by dimension, so we stay generic to entity type
00051   Range elems;
00052   rval = iface->get_entities_by_dimension(0, 3, elems);
00053   assert(rval == MB_SUCCESS);
00054 
00055    //output the number of entities
00056   cout << "Number of vertices is " << verts.size() <<  endl;
00057   cout << "Number of edges is " << edges.size() <<  endl;
00058   cout << "Number of faces is " << faces.size() <<  endl;
00059   cout << "Number of elements is " << elems.size() <<  endl;
00060 
00061   delete iface;
00062 
00063   return 0;
00064 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines