cgma
section.cpp
Go to the documentation of this file.
00001 
00010 #undef NDEBUG
00011 #include <cassert>
00012 
00013 #include "GeometryModifyTool.hpp"
00014 #include "GeometryQueryTool.hpp"
00015 #include "OCCQueryEngine.hpp"
00016 #include "CubitMessage.hpp"
00017 #include "Body.hpp"
00018 #include "RefVolume.hpp"
00019 #include "RefFace.hpp"
00020 #include "RefEdge.hpp"
00021 #include "RefVertex.hpp"
00022 #include "CastTo.hpp"
00023 #include "OCCModifyEngine.hpp"
00024 #include "OCCLump.hpp"
00025 #include "OCCBody.hpp"
00026 #include "OCCSurface.hpp"
00027 #include "OCCCurve.hpp"
00028 #include "OCCShell.hpp"
00029 #include "TopoDS_Shape.hxx"
00030 #include "InitCGMA.hpp"
00031 #include "CubitCompat.hpp"
00032 
00033 #ifndef SRCDIR
00034 # define SRCDIR .
00035 #endif
00036 
00037 #define STRINGIFY_(X) #X
00038 #define STRINGIFY(X) STRINGIFY_(X)
00039 #define SRCPATH STRINGIFY(SRCDIR) "/"
00040 
00041 // forward declare some functions used and defined later
00042 CubitStatus read_geometry(int, const char **, bool local = false);
00043 CubitStatus make_Point();
00044 // macro for printing a separator line
00045 #define PRINT_SEPARATOR   PRINT_INFO("=======================================\n");
00046 
00047 
00048 // main program - initialize, then send to proper function
00049 int main (int argc, char **argv)
00050 {
00051   CubitStatus status = InitCGMA::initialize_cgma("OCC");
00052   if (CUBIT_SUCCESS != status) return 1;
00053 
00054   //Do make point.
00055   status = make_Point();
00056   if (status == CUBIT_FAILURE) 
00057      PRINT_INFO("Operation Failed");
00058 
00059   int ret_val = ( CubitMessage::instance()->error_count() );
00060   if ( ret_val != 0 )
00061   {
00062     PRINT_ERROR("Errors found during Mergechk session.\n");
00063   }
00064   else
00065     ret_val = 0;
00066 
00067   return ret_val;
00068   
00069 }
00070 
00075 CubitStatus read_geometry(int num_files, const char **argv, bool local)
00076 {
00077   CubitStatus status = CUBIT_SUCCESS;
00078   GeometryQueryTool *gti = GeometryQueryTool::instance();
00079   assert(gti);
00080   int i;
00081   
00082   PRINT_SEPARATOR;
00083 
00084   for (i = 0; i < num_files; i++) {
00085     std::string filename( local ? "./" : SRCPATH );
00086     filename += argv[i];
00087     status = CubitCompat_import_solid_model(filename.c_str(), "OCC");
00088     if (status != CUBIT_SUCCESS) {
00089       PRINT_ERROR("Problems reading geometry file %s.\n", filename.c_str());
00090       abort();
00091     }
00092   }
00093   PRINT_SEPARATOR;
00094 
00095   return CUBIT_SUCCESS;
00096 }
00097 
00098 CubitStatus make_Point()
00099 {
00100   GeometryQueryTool *gti = GeometryQueryTool::instance();
00101   GeometryModifyTool *gmti = GeometryModifyTool::instance();
00102 
00103   //OCCQueryEngine* oqe = OCCQueryEngine::instance();
00104   //OCCModifyEngine* ome = OCCModifyEngine::instance();
00105 
00106   //test for tweak fillet and chamfer
00107   Body* body = gmti->sphere(53.726642);
00108   Body* body2 = gmti->brick(186, 372, 372);
00109   CubitVector move(96, 0, 1);
00110   DLIList<Body*> bods;
00111   bods.append(body2);
00112   gti->translate(bods, move);
00113   CubitBox box1;
00114   box1 = body2->bounding_box();
00115   
00116   DLIList<Body*> from_bodies, new_bodies;
00117   from_bodies.append(body);
00118   CubitStatus rsl = gmti->subtract(body2, from_bodies, new_bodies,
00119                        CUBIT_FALSE, CUBIT_FALSE);
00120   if (CUBIT_SUCCESS != rsl) {
00121     PRINT_ERROR("GeometryModifyTool::subtract failed.\n");
00122     return rsl;
00123   }
00124   //int i = new_bodies.size();
00125 
00126   int num_ents_exported=0;
00127   DLIList<RefEntity*> ref_entities;
00128   const CubitString cubit_version="10.2";
00129   const char * filename = "section.occ";
00130   const char * filetype = "OCC";
00131 
00132   rsl = CubitCompat_export_solid_model(ref_entities, filename, filetype,
00133                                  num_ents_exported, cubit_version);
00134   assert(num_ents_exported == 1);
00135 
00136   DLIList<Body*> bodies;
00137   gti->bodies(bodies);
00138   //delete all entities
00139   gti->delete_Body(bodies);
00140 
00141   remove(filename);
00142   return CUBIT_SUCCESS;
00143 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines