cgma
|
00001 #undef NDEBUG 00002 00003 #include <vector> 00004 00005 #include "InitCGMA.hpp" 00006 #include "CGMApp.hpp" 00007 #include "CubitCompat.hpp" 00008 #include "FacetQueryEngine.hpp" 00009 00010 #include "BodySM.hpp" 00011 #include "Body.hpp" 00012 #include "GeometryQueryTool.hpp" 00013 00014 #include <iostream> 00015 00016 static void print_usage( const char* name, std::ostream& stream ) 00017 { 00018 stream << "Usage: " << name << " <input stl file name> [ <angle (degrees)> <tolerance> <output geometry file name> ] " << std::endl; 00019 stream << " default arguments: angle: 135. tolerance: 1.e-6 output file: out.facet \n"; 00020 } 00021 00022 int main( int argc, char** argv ) { 00023 00024 std::vector<CubitString> args; 00025 CGMApp::instance()->startup(args); 00026 00027 if (argc<2) 00028 { 00029 print_usage(argv[0], std::cout); 00030 return 0; 00031 } 00032 00033 const char* filename = argv[1]; 00034 const char *out_file = "out.facet"; 00035 00036 double angle = 135.; 00037 if (argc>2) 00038 angle = atof(argv[2]); 00039 00040 double tolerance = 1.e-6; 00041 if (argc>3) 00042 tolerance = atof(argv[3]); 00043 00044 if (argc>4) 00045 out_file = argv[4]; 00046 00047 CubitStatus status = InitCGMA::initialize_cgma(); 00048 if (CUBIT_SUCCESS != status) return 1; 00049 00050 DLIList<CubitQuadFacet*> quad_facet_list; 00051 DLIList<CubitFacet*> tri_facet_list; 00052 DLIList<Surface*> surface_list; 00053 FacetQueryEngine* fqe = FacetQueryEngine::instance(); 00054 status = fqe->import_facets(filename, CUBIT_TRUE, angle, tolerance, 4, CUBIT_TRUE, 00055 CUBIT_FALSE, CUBIT_TRUE, CUBIT_TRUE, quad_facet_list, tri_facet_list, 00056 surface_list, STL_FILE); 00057 00058 // get bodies, then export to a facet file 00059 DLIList<Body*> bodies; 00060 GeometryQueryTool::instance()->bodies(bodies); 00061 PRINT_INFO(" num bodies: %d\n", bodies.size()); 00062 //BodySM* bodysm_ptr = body_ptr->get_body_sm_ptr(); 00063 DLIList<TopologyBridge*> model; 00064 for (int j=0; j<bodies.size(); j++) 00065 { 00066 BodySM* bodysm_ptr = bodies[j]->get_body_sm_ptr(); 00067 model.append( (TopologyBridge*)bodysm_ptr); 00068 } 00069 ModelExportOptions opts; 00070 00071 fqe->export_solid_model( 00072 model, out_file, FACET_TYPE, 00073 CubitString(), opts); 00074 PRINT_INFO( "converted stl %s to %s \n", filename, out_file); 00075 if (CUBIT_SUCCESS != status) return 1; 00076 00077 return 0; 00078 }