MeshKit
1.0
|
00001 00016 #include "meshkit/MKCore.hpp" 00017 #include "meshkit/NGTetMesher.hpp" 00018 #include "meshkit/SizingFunction.hpp" 00019 #include "meshkit/ModelEnt.hpp" 00020 00021 using namespace MeshKit; 00022 00023 MKCore *mk = NULL; 00024 bool save_mesh = true; 00025 00026 #ifdef HAVE_ACIS 00027 std::string extension = ".sat"; 00028 #elif HAVE_OCC 00029 std::string extension = ".stp"; 00030 #endif 00031 00032 int main(int argc, char **argv) 00033 { 00034 00035 // start up MK and load the geometry 00036 mk = new MKCore; 00037 std::string filebase = "threeholecube"; 00038 std::string file_name = (std::string) MESH_DIR + "/" + filebase + extension; 00039 mk->load_geometry(file_name.c_str()); 00040 00041 // get the volume 00042 MEntVector dum, vols; 00043 mk->get_entities_by_dimension(3, dum); 00044 vols.push_back(*dum.rbegin()); 00045 (NGTetMesher*) mk->construct_meshop("NGTetMesher", vols); 00046 00047 // make a sizing function and set it on the surface 00048 SizingFunction esize(mk, -1, 0.25); 00049 vols[0]->sizing_function_index(esize.core_index()); 00050 00051 // mesh the surface, by calling execute 00052 mk->setup_and_execute(); 00053 00054 // report the number of tets 00055 moab::Range tets; 00056 mk->moab_instance()->get_entities_by_dimension(0, 3, tets); 00057 std::cout << tets.size() << " tets generated." << std::endl; 00058 00059 if (save_mesh) { 00060 // output mesh 00061 std::string outfile = filebase + std::string(".vtk"); 00062 moab::EntityHandle out_set = vols[0]->mesh_handle(); 00063 mk->moab_instance()->write_file(outfile.c_str(), NULL, NULL, &out_set, 1); 00064 } 00065 00066 return 0; 00067 } 00068