MeshKit
1.0
|
00001 00008 #include <iostream> 00009 00010 #include <time.h> 00011 #include <stdlib.h> 00012 #include <cstring> 00013 #include <cstring> 00014 00015 #include "meshkit/MKCore.hpp" 00016 #include "meshkit/MeshOp.hpp" 00017 #include "meshkit/ModelEnt.hpp" 00018 #include "meshkit/TriangleMesher.hpp" 00019 00020 using namespace MeshKit; 00021 00022 00023 00024 MKCore *mk; 00025 00026 std::string usage_string = 00027 "-o <file> Output final model to given file.\n" 00028 "-i <file> input file \n" 00029 "-O <options> passed to Triangle mesher \n" 00030 "-d <1, 2, 3> (create the mesh in x, y, z normal planes direction, default z(3)) " 00031 "\n"; 00032 00033 00034 int main(int argc, char* argv[]) 00035 { 00036 // check command line arg 00037 const char *filename = 0; 00038 const char *outfile = 0; 00039 00040 //process options 00041 // process all options, as given with regular qslim 00042 // the last argument must be the input file 00043 // one argument must be -o <the output file>, otherwise it is the standard output 00044 // in the process, a mesh file is read (instanced) and the 00045 // set of triangles is passed 00046 // it could be the root set for the mesh 00047 std::string fstr; 00048 char * opts = (char *)("pc"); 00049 int direction = 3; // default 00050 double fretting = 1.e+38;// huge, do not eliminate anything in general 00051 if (argc<=1) 00052 { 00053 std::cout<<usage_string; 00054 std::cout << "\n\n"; 00055 std::cout<< "default arguments: -i TriangleInput.h5m -o mesh.h5m -O pc -f 2. \n"; 00056 //opts = "pc"; 00057 00058 fstr=(std::string) MESH_DIR "/TriangleInput.h5m"; 00059 filename = fstr.c_str(); 00060 //opts = "pc"; // convex hull, poly input 00061 00062 // ostr = "out.smf"; 00063 // outfile = ostr.c_str(); 00064 } 00065 else 00066 { 00067 int i=1;// will loop through arguments, and process them 00068 for (i=1; i<argc ; i++) 00069 { 00070 if (argv[i][0]=='-') 00071 { 00072 switch (argv[i][1]) 00073 { 00074 case 'i': 00075 { 00076 filename = argv[i+1]; 00077 i+=1; 00078 break; 00079 } 00080 case 'o': 00081 { 00082 outfile = argv[i+1]; 00083 i+=1; 00084 break; 00085 } 00086 00087 case 'O': 00088 { 00089 opts = argv[i+1]; 00090 i+=1; 00091 break; 00092 } 00093 00094 case 'd': 00095 { 00096 direction = atoi(argv[i+1]); 00097 i+=1; 00098 break; 00099 } 00100 00101 case 'f': 00102 { 00103 fretting = atof(argv[i+1]); 00104 i+=1; 00105 break; 00106 } 00107 default : 00108 { 00109 std::cout << "unsupported wrong input argument " << argv[i] <<std::endl; 00110 return 1; 00111 } 00112 } 00113 } 00114 } 00115 } 00116 // initialize everything 00117 00118 mk = new MKCore(); 00119 mk->load_mesh(filename); 00120 MEntVector selection, dum; 00121 mk->get_entities_by_dimension(2, dum); 00122 selection.push_back(*dum.rbegin());// push just the last one retrieved from core 00123 00124 TriangleMesher *qm = (TriangleMesher*) mk->construct_meshop("TriangleMesher", selection); 00125 00126 qm->set_options(opts, direction, fretting); 00127 00128 mk->setup_and_execute(); 00129 00130 if(outfile) 00131 { 00132 std::cout << "writing output to " << outfile << std::endl; 00133 mk->moab_instance()->write_mesh(outfile);// write everything left 00134 } 00135 00136 return 0; 00137 }