MeshKit  1.0
example_mbgeomop.cpp
Go to the documentation of this file.
00001 
00015 #include <iostream>
00016 
00017 #include <time.h>
00018 #include <stdlib.h>
00019 #include <cstring>
00020 #include <cstring>
00021 
00022 #include "meshkit/MKCore.hpp"
00023 #include "meshkit/MeshOp.hpp"
00024 #include "meshkit/ModelEnt.hpp"
00025 #include "meshkit/MBGeomOp.hpp"
00026 
00027 using namespace MeshKit;
00028 
00029 
00030 
00031 MKCore *mk;
00032 
00033 std::string usage_string =
00034     "<input file>      input file \n"
00035     "<output file>     Output final model to given file \n"
00036     "\n";
00037 
00038 int main(int argc, char* argv[])
00039 {
00040   // check command line arg
00041   const char *filename = 0;
00042   const char *outfile = 0;
00043   std::string fstr;
00044   if (argc==3)
00045   {
00046     filename = argv[1];
00047     outfile = argv[2];
00048   }
00049   else
00050   {
00051     std::cout << usage_string ;
00052     fstr=(std::string) MESH_DIR +  "/partBed.smf";
00053     std::cout << "using default input file:" << fstr <<", no output\n";
00054     filename = fstr.c_str();
00055   }
00056 
00057   // initialize everything
00058 
00059   mk = new MKCore();
00060   mk->load_mesh(filename);
00061   MEntVector selection, dum;
00062   mk->get_entities_by_dimension(2, dum);
00063   selection.push_back(*dum.rbegin());// push just the last one retrieved from core
00064 
00065   mk->construct_meshop("MBGeomOp", selection);
00066 
00067   mk->setup_and_execute();
00068 
00069   if(outfile)
00070   {
00071     std::cout << "writing the set output to " << outfile << std::endl;
00072     moab::EntityHandle outset= (*dum.begin())->mesh_handle();
00073     mk->moab_instance()->write_mesh(outfile, &outset, 1);// write the original mesh set
00074     // it will write its children too
00075   }
00076   return 0;
00077 
00078 }
00079 
00080   //process options
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines