MeshKit  1.0
example_camalpaver.cpp
Go to the documentation of this file.
00001 
00009 #include "meshkit/MKCore.hpp"
00010 #include "meshkit/CAMALPaver.hpp"
00011 #include "meshkit/SizingFunction.hpp"
00012 #include "meshkit/ModelEnt.hpp"
00013 
00014 using namespace MeshKit;
00015 
00016 
00017 
00018 MKCore *mk = NULL;
00019 bool save_mesh = false;
00020 
00021 void holysurf_test();
00022 void singleholesurf_test();
00023 void singleholesurfimprinted_test();
00024 void baseballfield_test();
00025 void mesh_test(std::string filebase);
00026 
00027 #ifdef HAVE_ACIS
00028 std::string extension = ".sat";
00029 #elif HAVE_OCC
00030 std::string extension = ".stp";
00031 #endif
00032 
00033 int main(int argc, char **argv) 
00034 {
00035   
00036     // start up MK and load the geometry
00037   mk = new MKCore;
00038   int num_fail = 0;
00039   
00040   if (argc == 2) save_mesh = true;
00041   
00042   holysurf_test();
00043   singleholesurf_test();
00044   singleholesurfimprinted_test();
00045   baseballfield_test();
00046   return num_fail;
00047 }
00048 
00049 void holysurf_test() 
00050 {
00051   mesh_test("holysurf");
00052 }
00053 
00054 void singleholesurf_test() 
00055 {
00056   mesh_test("singleholesurf");
00057 }
00058 
00059 void singleholesurfimprinted_test()
00060 {
00061   mesh_test("singleholesurfimprinted");
00062 }
00063 
00064 void baseballfield_test()
00065 {
00066   mesh_test("baseballfield");
00067 }
00068 
00069 void mesh_test(std::string filebase)
00070 {
00071   std::string file_name = (std::string) MESH_DIR + "/" + filebase + extension;
00072   mk->load_geometry(file_name.c_str());
00073 
00074     // get the surface
00075   MEntVector dum, surfs;
00076   mk->get_entities_by_dimension(2, dum);
00077   surfs.push_back(*dum.rbegin());
00078   mk->construct_meshop("CAMALPaver", surfs);
00079 
00080     // make a sizing function and set it on the surface
00081   SizingFunction esize(mk, -1, 0.25);
00082   surfs[0]->sizing_function_index(esize.core_index());
00083   
00084     // mesh the surface, by calling execute
00085   mk->setup_and_execute();
00086 
00087     // report the number of quads
00088   moab::Range quads;
00089   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 2, quads);
00090   std::cout << quads.size() << " quads generated." << std::endl;
00091 
00092   if (save_mesh) {
00093         // output mesh
00094     std::string outfile = filebase + std::string(".vtk");
00095     moab::EntityHandle out_set = surfs[0]->mesh_handle();
00096     rval = mk->moab_instance()->write_file(outfile.c_str(), NULL, NULL, &out_set, 1);
00097   }
00098 
00099   mk->clear_graph();
00100 }
00101 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines