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