[cgma-dev] r2217 - in cgm/trunk: init itaps

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Wed Nov 5 13:25:22 CST 2008


Author: kraftche
Date: 2008-11-05 13:25:21 -0600 (Wed, 05 Nov 2008)
New Revision: 2217

Modified:
   cgm/trunk/init/InitCGMA.cpp
   cgm/trunk/init/InitCGMA.hpp
   cgm/trunk/itaps/iGeom_CGMA.cc
Log:
o Remove InitCGMA::initialize_engine(const char*).
o Make InitCGMA::initialize_cgma() initialize all engines
o Add optional "const char* default_engine_name" argument to 
    InitCGMA::initialize_cgma()


Modified: cgm/trunk/init/InitCGMA.cpp
===================================================================
--- cgm/trunk/init/InitCGMA.cpp	2008-11-05 18:36:37 UTC (rev 2216)
+++ cgm/trunk/init/InitCGMA.cpp	2008-11-05 19:25:21 UTC (rev 2217)
@@ -3,6 +3,8 @@
 #include "VirtualQueryEngine.hpp"
 #include "FacetQueryEngine.hpp"
 #include "FacetModifyEngine.hpp"
+#include "GeometryQueryTool.hpp"
+#include "GeometryModifyTool.hpp"
 
 #include <ctype.h>
 
@@ -48,59 +50,56 @@
 }
 
 
-CubitStatus InitCGMA::initialize_cgma()
+CubitStatus InitCGMA::initialize_cgma( const char* default_engine_name )
 {
   CGMApp::instance()->startup( 0, NULL );
-  return CUBIT_SUCCESS;
-}
+  GeometryModifyEngine* default_engine = 0;
 
-
-CubitStatus InitCGMA::initialize_engine( const char* name )
-{
-  if (!name) {
-#if defined(CUBIT_CGM) || defined(ACIS)
-    name = "ACIS";
-#elif defined (HAVE_OCC)
-    name = "OCC";
-#else
-    PRINT_INFO("No engine to default to in InitCGMA");
-    return CUBIT_FAILURE;
-#endif
-  }
-
-
-  if (streq_nocase(name,"ACIS")) {
-#ifdef CUBIT_CGM
+#if defined(CUBIT_CGM) || defined(HAVE_ACIS)
+  GeometryModifyEngine* acis_engine_ptr;
+  #ifdef CUBIT_CGM
     if (!AcisQueryEngine::instance_)
       AcisQueryEngine::instance_ = new (reinterpret_cast<AcisQueryEngine*>(new dummym)) AcisQueryEngine;
     if (!AcisModifyEngine::instance_)
       AcisModifyEngine::instance_ = new (reinterpret_cast<AcisModifyEngine*>(new dummym)) AcisModifyEngine;
-#elif defined (HAVE_ACIS)
+    acis_engine_ptr = AcisModfyEngine::instance();
+  #else
     AcisQueryEngine::instance();
     AcisModifyEngine::instance();
-#else
-    return CUBIT_FAILURE;
+    acis_engine_ptr = AcisModifyEngine::instance();
+  #endif
+  if (default_engine_name && streq_nocase("ACIS",default_engine_name))
+    default_engine = acis_engine_ptr;
 #endif
-  }
-  
-  else if (streq_nocase(name,"VIRTUAL") || streq_nocase(name,"vg")) {
-    VirtualQueryEngine::instance();
-  }
+
 #ifdef HAVE_OCC  
-  else if (streq_nocase(name,"OCC")) {
-    OCCQueryEngine::instance();
-    OCCModifyEngine::instance();
-  }
+  OCCQueryEngine::instance();
+  OCCModifyEngine::instance();
+  if (default_engine_name && streq_nocase("OCC",default_engine_name))
+    default_engine = OCCModifyEngine::instance();
 #endif  
-  else if (streq_nocase(name,"facet")) {
-    FacetQueryEngine::instance();
-    FacetModifyEngine::instance();
+
+  FacetQueryEngine::instance();
+  FacetModifyEngine::instance();
+  VirtualQueryEngine::instance();
+
+  if (default_engine_name && streq_nocase("FACET",default_engine_name))
+    default_engine = FacetModifyEngine::instance();
+
+  if(default_engine_name) {
+    if (!default_engine) {
+      PRINT_ERROR("Invalid or unsupported engine: '%s'\n", default_engine_name);
+      return CUBIT_FAILURE;
+    }
+    
+    CubitStatus rval;
+    rval = GeometryModifyTool::instance()->set_default_gme(default_engine);
+    if (CUBIT_SUCCESS != rval)
+      return rval;
+    rval = GeometryQueryTool::instance()->set_default_gqe(default_engine->get_gqe());
+    if (CUBIT_SUCCESS != rval)
+      return rval;
   }
   
-  else {
-    return CUBIT_FAILURE;
-  }
-  
   return CUBIT_SUCCESS;
 }
-

Modified: cgm/trunk/init/InitCGMA.hpp
===================================================================
--- cgm/trunk/init/InitCGMA.hpp	2008-11-05 18:36:37 UTC (rev 2216)
+++ cgm/trunk/init/InitCGMA.hpp	2008-11-05 19:25:21 UTC (rev 2217)
@@ -7,9 +7,7 @@
 {
 public:
 
-  static CubitStatus initialize_cgma();
-  
-  static CubitStatus initialize_engine( const char* name );
+  static CubitStatus initialize_cgma( const char* default_engine_name = 0 );
 };
 
 #endif

Modified: cgm/trunk/itaps/iGeom_CGMA.cc
===================================================================
--- cgm/trunk/itaps/iGeom_CGMA.cc	2008-11-05 18:36:37 UTC (rev 2216)
+++ cgm/trunk/itaps/iGeom_CGMA.cc	2008-11-05 19:25:21 UTC (rev 2217)
@@ -233,10 +233,7 @@
                     int* err,
                     const int options_size) 
 {
-  CubitStatus status = InitCGMA::initialize_cgma();
-  if (CUBIT_SUCCESS != status) RETURN(iBase_FAILURE);
-  
-    // scan options for engine to use
+    // scan options for default engine option
   std::string engine;
   if (options && options_size) {
     char* opt = (char*)malloc( options_size + 1 );
@@ -256,7 +253,14 @@
     }
     free(opt);
   }
-  InitCGMA::initialize_engine(engine.empty() ? 0 : engine.c_str());
+  
+  CubitStatus status;
+  if (engine.empty()) 
+    status = InitCGMA::initialize_cgma();
+  else
+    status = InitCGMA::initialize_cgma( engine.c_str() );
+  if (CUBIT_SUCCESS != status)
+    RETURN (iBase_FAILURE);
 
 // sometimes can't have following, depending on CGM version
   // CGMApp::instance()->attrib_manager()->silent_flag(true);




More information about the cgma-dev mailing list