cgma
imprint_bug.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 "Shell.hpp"
00020 #include "RefFace.hpp"
00021 #include "RefEdge.hpp"
00022 #include "RefVertex.hpp"
00023 #include "CastTo.hpp"
00024 #include "OCCModifyEngine.hpp"
00025 #include "OCCLump.hpp"
00026 #include "OCCBody.hpp"
00027 #include "OCCSurface.hpp"
00028 #include "OCCCurve.hpp"
00029 #include "OCCShell.hpp"
00030 #include "TopoDS_Shape.hxx"
00031 #include "InitCGMA.hpp"
00032 #include "CubitCompat.hpp"
00033 
00034 #ifndef SRCDIR
00035 # define SRCDIR .
00036 #endif
00037 
00038 #define STRINGIFY_(X) #X
00039 #define STRINGIFY(X) STRINGIFY_(X)
00040 #define SRCPATH STRINGIFY(SRCDIR) "/"
00041 
00042 // forward declare some functions used and defined later
00043 CubitStatus read_geometry(int, const char **, bool local = false);
00044 CubitStatus make_Point();
00045 // macro for printing a separator line
00046 #define PRINT_SEPARATOR   PRINT_INFO("=======================================\n");
00047 
00048 
00049 // main program - initialize, then send to proper function
00050 int main (int argc, char **argv)
00051 {
00052   CubitStatus status = InitCGMA::initialize_cgma("OCC");
00053   if (CUBIT_SUCCESS != status) return 1;
00054 
00055   //Do make point.
00056   status = make_Point();
00057   if (status == CUBIT_FAILURE) 
00058      PRINT_INFO("Operation Failed");
00059 
00060   int ret_val = ( CubitMessage::instance()->error_count() );
00061   if ( ret_val != 0 )
00062   {
00063     PRINT_ERROR("Errors found during Mergechk session.\n");
00064   }
00065   else
00066     ret_val = 0;
00067 
00068   return ret_val;
00069   
00070 }
00071 
00076 CubitStatus read_geometry(int num_files, const char **argv, bool local)
00077 {
00078   CubitStatus status = CUBIT_SUCCESS;
00079   GeometryQueryTool *gti = GeometryQueryTool::instance();
00080   assert(gti);
00081   int i;
00082   
00083   PRINT_SEPARATOR;
00084 
00085   for (i = 0; i < num_files; i++) {
00086     std::string filename( local ? "./" : SRCPATH );
00087     filename += argv[i];
00088     status = CubitCompat_import_solid_model(filename.c_str(), "OCC");
00089     if (status != CUBIT_SUCCESS) {
00090       PRINT_ERROR("Problems reading geometry file %s.\n", filename.c_str());
00091       abort();
00092     }
00093   }
00094   PRINT_SEPARATOR;
00095 
00096   return CUBIT_SUCCESS;
00097 }
00098 
00099 CubitStatus make_Point()
00100 {
00101   GeometryQueryTool *gti = GeometryQueryTool::instance();
00102   GeometryModifyTool *gmti = GeometryModifyTool::instance();
00103 
00104   OCCQueryEngine::instance();
00105   //OCCModifyEngine* ome = OCCModifyEngine::instance();
00106 
00107   // Read in the geometry from files specified on the command line
00108   const char *argv = "Solid_2.brep";
00109   CubitStatus  status = read_geometry(1, &argv, false);
00110   if (status == CUBIT_FAILURE) exit(1);
00111   //Read in 1 volume.
00112 
00113   argv = "Solid_7.brep";
00114   status = read_geometry(1, &argv, false);
00115   if (status == CUBIT_FAILURE) exit(1);
00116   //Read in 1 volume.
00117 
00118   DLIList<Body*> from_bodies;
00119   DLIList<Body*> new_bodies;
00120   gti->bodies(from_bodies);
00121   //Bug 247 test, when this bug get fixed, the comment should be removed.
00122 //  status = gmti->imprint(from_bodies, new_bodies, CUBIT_FALSE);
00123 
00124   DLIList<Body*> bodies;
00125   bodies.clean_out();
00126   gti->bodies(bodies);
00127   //delete all entities
00128   gti->delete_Body(bodies);
00129 
00130   DLIList<RefEntity*>  free_entities;
00131   gti->get_free_ref_entities(free_entities);
00132   for(int i = 0; i < free_entities.size(); i++)
00133     gti->delete_RefEntity(free_entities.get_and_step()); 
00134 
00135   Body* body = gmti->brick(10, 10, 10);
00136   DLIList<Shell*> shells;
00137   body->shells(shells);
00138   ShellSM* shell = shells.get()->get_shell_sm_ptr(); 
00139   OCCShell* occ_shell = CAST_TO(shell, OCCShell);
00140   DLIList<TopologyBridge*> parents;
00141   occ_shell->get_parents_virt(parents);
00142   assert (parents.size() == 1);
00143   return status;
00144 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines