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 void squaresurf();
00025 
00026 #ifdef HAVE_ACIS
00027 std::string extension = ".sat";
00028 #elif HAVE_OCC
00029 std::string extension = ".stp";
00030 #else
00031 std::string extension = ".facet";
00032 #define HAVE_FACET
00033 #endif
00034 
00035 int main(int argc, char **argv) 
00036 {
00037   
00038     // start up MK and load the geometry
00039   mk = new MKCore;
00040   int num_fail = 0;
00041   
00042   if (argc == 2) save_mesh = true;
00043 #ifdef HAVE_FACET
00044   num_fail += RUN_TEST(squaresurf);
00045 #else
00046   num_fail += RUN_TEST(holysurf_test);
00047   num_fail += RUN_TEST(singleholesurf_test);
00048   num_fail += RUN_TEST(singleholesurfimprinted_test);
00049   num_fail += RUN_TEST(baseballfield_test);
00050 #endif
00051   return num_fail;
00052 }
00053 void squaresurf() {
00054   // this is only for square facet test
00055   std::string file_name = TestDir + "/squaresurf.facet";
00056   mk->load_geometry(file_name.c_str());
00057 
00058   // get the surface
00059   MEntVector dum, surfs;
00060   mk->get_entities_by_dimension(2, dum);
00061   surfs.push_back(*dum.rbegin());
00062   mk->construct_meshop("CAMALPaver", surfs);
00063 
00064   // make a sizing function and set it on the surface
00065   SizingFunction esize(mk, -1, 0.25);
00066   surfs[0]->sizing_function_index(esize.core_index());
00067 
00068   // mesh the surface, by calling execute
00069   mk->setup_and_execute();
00070 
00071   // report the number of quads
00072   moab::Range quads;
00073   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 2,
00074       quads);
00075   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00076   std::cout << quads.size() << " quads generated." << std::endl;
00077 
00078   if (save_mesh) {
00079     // output mesh
00080     std::string outfile = "squaresurf" + std::string(".vtk");
00081     moab::EntityHandle out_set = surfs[0]->mesh_handle();
00082     rval = mk->moab_instance()->write_file(outfile.c_str(), NULL, NULL,
00083         &out_set, 1);
00084     MBERRCHK(rval, mk->moab_instance());
00085   }
00086 
00087   mk->clear_graph();
00088 
00089 }
00090 void holysurf_test() 
00091 {
00092   mesh_test("holysurf");
00093 }
00094 
00095 void singleholesurf_test() 
00096 {
00097   mesh_test("singleholesurf");
00098 }
00099 
00100 void singleholesurfimprinted_test()
00101 {
00102   mesh_test("singleholesurfimprinted");
00103 }
00104 
00105 void baseballfield_test()
00106 {
00107   mesh_test("baseballfield");
00108 }
00109 
00110 void mesh_test(std::string filebase)
00111 {
00112   std::string file_name = TestDir + "/" + filebase + extension;
00113   mk->load_geometry(file_name.c_str());
00114 
00115     // get the surface
00116   MEntVector dum, surfs;
00117   mk->get_entities_by_dimension(2, dum);
00118   surfs.push_back(*dum.rbegin());
00119   mk->construct_meshop("CAMALPaver", surfs);
00120 
00121     // make a sizing function and set it on the surface
00122   SizingFunction esize(mk, -1, 0.25);
00123   surfs[0]->sizing_function_index(esize.core_index());
00124   
00125     // mesh the surface, by calling execute
00126   mk->setup_and_execute();
00127 
00128     // report the number of quads
00129   moab::Range quads;
00130   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 2, quads);
00131   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00132   std::cout << quads.size() << " quads generated." << std::endl;
00133 
00134   if (save_mesh) {
00135         // output mesh
00136     std::string outfile = filebase + std::string(".vtk");
00137     moab::EntityHandle out_set = surfs[0]->mesh_handle();
00138     rval = mk->moab_instance()->write_file(outfile.c_str(), NULL, NULL, &out_set, 1);
00139     MBERRCHK(rval, mk->moab_instance());
00140   }
00141 
00142   mk->clear_graph();
00143 }
00144 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines