[cgma-dev] r1822 - in cgm/trunk: . geom/OCC test

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Mon May 19 11:53:46 CDT 2008


Author: kraftche
Date: 2008-05-19 11:53:45 -0500 (Mon, 19 May 2008)
New Revision: 1822

Added:
   cgm/trunk/test/sheet.cpp
Modified:
   cgm/trunk/configure.in
   cgm/trunk/geom/OCC/OCCModifyEngine.hpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/test/Makefile.am
   cgm/trunk/test/makept.cpp
   cgm/trunk/test/modify.cpp
Log:
configure.in:
  o set HAVE_OCC_DEF="-DHAVE_OCC" if building with OCC

geom/OCC/OCCModifyEngine.hpp:
  o add missing forward declarations
  o remove unnecessary forward declarations

geom/OCC/OCCSurface.hpp:
  o Return CUBIT_UNKNOWN for relative surface/shell sense for
    surfaces that are part of a sheet body.
  o Do not return a BodySM* from Surface::get_parents_virt.  This
    function is expected to query *one* level.  

test/makept.cpp:
test/modify.cpp:
  o Specify correct paths for input files when running in separate
    build tree.

test/sheet.cpp:
  o Test that Body::is_sheet_body() returns the correct result for
    both OCC and ACIS bodies (sheet & non-sheet).



Modified: cgm/trunk/configure.in
===================================================================
--- cgm/trunk/configure.in	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/configure.in	2008-05-19 16:53:45 UTC (rev 1822)
@@ -252,6 +252,7 @@
 
 # if user specified option (other than --without-occ)
 CUBIT_OCC_LIB=
+HAVE_OCC_DEF=
 if test "x$occ_DIR" != "xno"; then
   OCC_LIBS="-lTKMath -lTKXSBase -lTKernel -lTKShHealing -lTKBRep -lTKG3d -lTKBO -lTKFeat -lTKFillet -lTKG2d -lTKOffset -lTKBool -lTKGeomAlgo -lTKGeomBase -lTKPrim -lTKTopAlgo -lTKHLR -lTKIGES -lTKMesh -lTKPrim -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKSTEP -lTKSTL -lTKTopAlgo -lTKXSBase"
   CUBIT_OCC_LIB="-lcubit_OCC"
@@ -305,6 +306,7 @@
   # Restore original values of variables
   CPPFLAGS="$old_CPPFLAGS"
   LDFLAGS="$old_LDFLAGS"
+  HAVE_OCC_DEF="-DHAVE_OCC"
 fi
 
 # Export these variables as variables in Makefiles
@@ -313,6 +315,7 @@
 AC_SUBST(OCC_LIB_FLAG)
 AC_SUBST(OCC_LIBS)
 AC_SUBST(CUBIT_OCC_LIB)
+AC_SUBST(HAVE_OCC_DEF)
 
 # Allow "if WITH_OCC" in Makefile.am
 AM_CONDITIONAL( WITH_OCC, [test "x$occ_DIR" != "xno"] )

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp	2008-05-19 16:53:45 UTC (rev 1822)
@@ -20,14 +20,13 @@
 
 class Point;
 class TopologyBridge;
-class TopologyEntity;
-class Point;
 class CoEdgeSM;
 class ShellSM;
 class OCCBody;
-class Body;
-class RefFace;
 class OCCSurface;
+class TopoDS_Shape;
+class TopoDS_Edge;
+class TopoDS_Face;
 
 class OCCModifyEngine : public GeometryModifyEngine
 {

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-05-19 16:53:45 UTC (rev 1822)
@@ -682,12 +682,6 @@
 
 void OCCSurface::get_parents_virt( DLIList<TopologyBridge*>& parents )
 { 
-  if (myBody) //sheet body
-  {
-     parents.append(myBody);
-     return;
-  }
-
   if(myShell) //shell body
   {
     parents.append(myShell);
@@ -736,6 +730,11 @@
 // return the sense with respect to the given shell
 CubitSense OCCSurface::get_shell_sense( ShellSM* shell_ptr ) const
 {
+  OCCShell* shell = dynamic_cast<OCCShell*>(shell_ptr);
+  if (!shell)
+    return CUBIT_UNKNOWN;
+  if (shell->my_surface() == this)
+    return CUBIT_UNKNOWN;
   return CUBIT_FORWARD;
 }
 

Modified: cgm/trunk/test/Makefile.am
===================================================================
--- cgm/trunk/test/Makefile.am	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/test/Makefile.am	2008-05-19 16:53:45 UTC (rev 1822)
@@ -11,20 +11,27 @@
 	   -I$(srcdir) \
 	   $(OCC_INC_FLAG)
 
-TESTS=
+ENGINE_LIBS = 
+LINK_FLAGS = 
+TESTS = sheet
 if build_ACIS
   TESTS += webcut
+  ENGINE_LIBS += ../geom/ACIS/libcubit_ACIS.la 
+  LINK_FLAGS += -R$(ACIS_LIB_DIR)
 endif
 if WITH_OCC
   TESTS += modify makept
+  ENGINE_LIBS += ../geom/OCC/libcubit_OCC.la
+  LINK_FLAGS += -R$(OCC_LIB_DIR)
 endif
 
-AM_CPPFLAGS += -DSRCDIR=@srcdir@
+AM_CPPFLAGS += -DSRCDIR=@srcdir@ $(HAVE_ACIS_DEF) $(HAVE_OCC_DEF)
 check_PROGRAMS = $(TESTS)
 
 webcut_SOURCES = webcut.cpp
 makept_SOURCES = makept.cpp
 modify_SOURCES = modify.cpp
+sheet_SOURCES  = sheet.cpp
 LDADD = ../geom/virtual/libcubit_virtual.la \
         ../geom/facetbool/libcubit_facetbool.la \
         ../geom/Cholla/libcholla.la \
@@ -37,3 +44,5 @@
 makept_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
 modify_LDFLAGS = $(LDFLAGS) -R$(OCC_LIB_DIR)
 modify_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
+sheet_LDFLAGS = $(LDFLAGS) $(LINK_FLAGS)
+sheet_LDADD = $(ENGINE_LIBS) $(LDADD)

Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/test/makept.cpp	2008-05-19 16:53:45 UTC (rev 1822)
@@ -6,7 +6,6 @@
  * This program acts as a simple driver for CGM.  It reads in a geometry,
  * and performs varies checks for bodies, surfaces, curves and vertices.
  */
-#include "config.h"
 #include "CpuTimer.hpp"
 #include "GeometryModifyTool.hpp"
 #include "GeometryQueryTool.hpp"
@@ -31,6 +30,14 @@
 #include "OCCSurface.hpp"
 #include "OCCCurve.hpp"
 
+#ifndef SRCDIR
+# define SRCDIR .
+#endif
+
+#define STRINGIFY_(X) #X
+#define STRINGIFY(X) STRINGIFY_(X)
+#define SRCPATH STRINGIFY(SRCDIR) "/"
+
 // forward declare some functions used and defined later
 CubitStatus read_geometry(int, char **);
 CubitStatus make_Point();
@@ -87,9 +94,11 @@
   PRINT_SEPARATOR;
 
   for (i = 0; i < num_files; i++) {
-    status = gti->import_solid_model(argv[i], "OCC");
+    std::string filename( SRCPATH );
+    filename += argv[i];
+    status = gti->import_solid_model(filename.c_str(), "OCC");
     if (status != CUBIT_SUCCESS) {
-      PRINT_ERROR("Problems reading geometry file %s.\n", argv[i]);
+      PRINT_ERROR("Problems reading geometry file %s.\n", filename);
     }
   }
   PRINT_SEPARATOR;

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-05-16 21:01:29 UTC (rev 1821)
+++ cgm/trunk/test/modify.cpp	2008-05-19 16:53:45 UTC (rev 1822)
@@ -37,6 +37,14 @@
 #include "RefEntityName.hpp"
 #include "RefEntityFactory.hpp"
 
+#ifndef SRCDIR
+# define SRCDIR .
+#endif
+
+#define STRINGIFY_(X) #X
+#define STRINGIFY(X) STRINGIFY_(X)
+#define SRCPATH STRINGIFY(SRCDIR) "/"
+
 // forward declare some functions used and defined later
 CubitStatus read_geometry(int, char **);
 CubitStatus make_Point();
@@ -93,9 +101,11 @@
   PRINT_SEPARATOR;
 
   for (i = 0; i < num_files; i++) {
-    status = gti->import_solid_model(argv[i], "OCC");
+    std::string filename( SRCPATH );
+    filename += argv[i];
+    status = gti->import_solid_model(filename.c_str(), "OCC");
     if (status != CUBIT_SUCCESS) {
-      PRINT_ERROR("Problems reading geometry file %s.\n", argv[i]);
+      PRINT_ERROR("Problems reading geometry file %s.\n", filename);
     }
   }
   PRINT_SEPARATOR;

Added: cgm/trunk/test/sheet.cpp
===================================================================
--- cgm/trunk/test/sheet.cpp	                        (rev 0)
+++ cgm/trunk/test/sheet.cpp	2008-05-19 16:53:45 UTC (rev 1822)
@@ -0,0 +1,134 @@
+/**
+ * \file makept.cpp
+ *
+ * \brief makept, another simple C++ driver for CGM
+ *
+ * This program acts as a simple driver for CGM.  It reads in a geometry,
+ * and performs varies checks for bodies, surfaces, curves and vertices.
+ */
+#include "GeometryModifyTool.hpp"
+#include "GeometryQueryTool.hpp"
+#include "ModelQueryEngine.hpp"
+#include "Body.hpp"
+#include "RefFace.hpp"
+#include "CubitObserver.hpp"
+
+#include <typeinfo>
+#include <assert.h>
+
+#ifdef HAVE_ACIS
+#include "AcisModifyEngine.hpp"
+#include "AcisQueryEngine.hpp"
+#endif
+
+#ifdef HAVE_OCC
+#include "OCCModifyEngine.hpp"
+#include "OCCQueryEngine.hpp"
+#endif
+
+int test_sheet_query( GeometryModifyEngine* engine );
+
+// main program - initialize, then send to proper function
+int main (int argc, char **argv)
+{
+  CubitObserver::init_static_observers();
+  CGMApp::instance()->startup( argc, argv );
+
+  GeometryQueryEngine* const gqe_list[] = {
+#ifdef HAVE_ACIS
+    AcisQueryEngine::instance(),
+#endif
+#ifdef HAVE_OCC
+    OCCQueryEngine::instance(),
+#endif
+    NULL
+  };
+
+
+  GeometryModifyEngine* const gme_list[] = {
+#ifdef HAVE_ACIS
+    AcisModifyEngine::instance(),
+#endif
+#ifdef HAVE_OCC
+    OCCModifyEngine::instance(),
+#endif
+    NULL
+  };
+
+  int exit_val = 0;
+  for (int i = 0; gme_list[i]; ++i)
+    exit_val += test_sheet_query( gme_list[i] );
+
+  return exit_val;
+}
+
+
+int test_sheet_query( GeometryModifyEngine* engine )
+{
+  CubitStatus rval = GeometryModifyTool::instance()->set_default_gme( engine );
+  assert(rval);
+  
+  Body *sphere = 0, *sheet = 0;
+  
+  sphere = GeometryModifyTool::instance()->sphere( 1.0 );
+  if (!sphere) {
+    fprintf(stderr,"Sphere creation failed for engine (%s)\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+
+/*  This fails for OCC.  Try something else to create sheet body
+  sheet = GeometryModifyTool::instance()->planar_sheet( 
+    CubitVector(0,0,0), CubitVector(1,0,0), 
+    CubitVector(1,1,0), CubitVector(0,1,0) );
+  if (!sphere) {
+    fprintf(stderr,"Planar sheet creation failed for engine (%s)\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+*/  
+  
+  DLIList<ModelEntity*> list;
+  rval = ModelQueryEngine::instance()->query_model( *sphere, DagType::ref_face_type(), list );
+  if (!rval || list.size() != 1) {
+    fprintf(stderr,"Failed to get face from body (%s)\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+  RefFace* sphere_face = dynamic_cast<RefFace*>(list.get());
+  assert(NULL != sphere_face);
+  
+  RefFace* sheet_face = GeometryModifyTool::instance()->make_RefFace( sphere_face );
+  if (!sheet_face) {
+    fprintf(stderr,"Failed to create face from sphere face (%s)\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+  
+  list.clean_out();
+  rval = ModelQueryEngine::instance()->query_model( *sheet_face, DagType::body_type(), list );
+  if (!rval || list.size() != 1) {
+    fprintf(stderr,"Failed to get body from sheet face (%s)\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+  sheet = dynamic_cast<Body*>(list.get());
+  assert(NULL != sheet);
+
+  if (sphere->is_sheet_body()) {
+    fprintf(stderr,"Solid sphere reported as sheet body (%s).\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+  
+  if (!sheet->is_sheet_body()) {
+    fprintf(stderr,"Planar sheet reported as non-sheet body (%s).\n", 
+      typeid(*engine).name());
+    return 1;
+  }
+  
+  printf("Success (%s)\n",typeid(*engine).name());
+  return 0;
+}
+
+    




More information about the cgma-dev mailing list