cgma
test_stl.cpp
Go to the documentation of this file.
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 #define STRINGIFY(S) XSTRINGIFY(S)
00015 #define XSTRINGIFY(S) #S
00016 #ifndef SRCDIR
00017 #  define SRCDIR "."
00018 #endif
00019 
00020 int main( int argc, char** argv ) {
00021 
00022   std::vector<CubitString> args;
00023   CGMApp::instance()->startup(args);
00024 
00025   const char* filename = STRINGIFY(SRCDIR) "/unit_cube.stl";
00026   const char *out_file = "unit_cube.facet";
00027 
00028   CubitStatus status = InitCGMA::initialize_cgma();
00029   if (CUBIT_SUCCESS != status) return 1;
00030   if (argc>=2)
00031     filename = argv[1];
00032   if (argc>=3)
00033     out_file = argv[2];
00034 
00035   DLIList<CubitQuadFacet*> quad_facet_list;
00036   DLIList<CubitFacet*> tri_facet_list;
00037   DLIList<Surface*> surface_list;
00038   FacetQueryEngine* fqe = FacetQueryEngine::instance();
00039   status = fqe->import_facets(filename, CUBIT_TRUE, 135, 1.e-6, 4, CUBIT_TRUE,
00040     CUBIT_FALSE, CUBIT_TRUE, CUBIT_TRUE, quad_facet_list, tri_facet_list,
00041     surface_list, STL_FILE);
00042 
00043   // get bodies, then export to a facet file
00044   DLIList<Body*> bodies;
00045   GeometryQueryTool::instance()->bodies(bodies);
00046   PRINT_INFO(" num bodies: %d\n", bodies.size());
00047   //BodySM* bodysm_ptr = body_ptr->get_body_sm_ptr();
00048   DLIList<TopologyBridge*> model;
00049   for (int j=0; j<bodies.size(); j++)
00050   {
00051     BodySM* bodysm_ptr = bodies[j]->get_body_sm_ptr();
00052     model.append( (TopologyBridge*)bodysm_ptr);
00053   }
00054   ModelExportOptions opts;
00055 
00056   fqe->export_solid_model(
00057         model, out_file, FACET_TYPE,
00058         CubitString(), opts);
00059   PRINT_INFO( "converted stl %s to %s \n", filename,  out_file);
00060   if (CUBIT_SUCCESS != status) return 1;
00061  
00062   return 0;
00063 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines