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

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Jan 14 15:42:04 CST 2008


Author: janehu
Date: 2008-01-14 15:42:04 -0600 (Mon, 14 Jan 2008)
New Revision: 1524

Modified:
   cgm/trunk/configure.in
   cgm/trunk/geom/GeometryQueryTool.cpp
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCBody.hpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.hpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/geom/OCC/OCCSurface.hpp
   cgm/trunk/test/Makefile.am
   cgm/trunk/test/makept.cpp
Log:
changes to move any GeometryEntity, test file update, I need to make one change in OCC library code, now is doing local build. after that I'll submit a patch to opencascade.

Modified: cgm/trunk/configure.in
===================================================================
--- cgm/trunk/configure.in	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/configure.in	2008-01-14 21:42:04 UTC (rev 1524)
@@ -257,7 +257,7 @@
     OCC_LIB_FLAG=
   else
     uname=`uname`
-    OCC_INC_FLAG="-I${occ_DIR}/ros/inc"
+    OCC_INC_FLAG="-I${occ_DIR}/ros/inc -I/usr/include"
 # -I/usr/include/c++/4.2 -I/usr/include/c++/4.2/tr1"
     OCC_LIB_FLAG="-L${occ_DIR}/ros/${uname}/lib"
   fi
@@ -273,7 +273,7 @@
   # Check if 64-bit
   AC_MSG_CHECKING([if platform is 64-bit (-D_OCC64)])
   AC_TRY_COMPILE([],[int array[6-(int)sizeof(void*)];],[AC_MSG_RESULT(no)],
-                 [AC_MSG_RESULT(yes); OCC_INC_FLAG="$OCC_INC_FLAG -D_OCC64"])
+                 [AC_MSG_RESULT(yes); OCC_INC_FLAG="$OCC_INC_FLAG -D_OCC64 -DHAVE_IOSTREAM_H -DHAVE_LIMITS_H"])
 
   # Check if OCC has Stadard_Version.hxx
   AC_CHECK_HEADER( [Standard_Version.hxx], [],

Modified: cgm/trunk/geom/GeometryQueryTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryQueryTool.cpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/GeometryQueryTool.cpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -1773,7 +1773,6 @@
     PRINT_ERROR("Invalid SolidModel topology encountered in "
                 "GeometryQueryTool::make_RefEdge.  Curve %d "
                 "has %d vertices.\n", edge->id(), points.size() );
-    assert( points.size() == 1 || points.size() == 2 );
     if( points.size() == 0 )
       return edge;
   }

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -237,9 +237,8 @@
 
   BRepBuilderAPI_Transform aBRepTrsf(*myTopoDSShape, aTrsf); 
 
-  // calculate for bounding box
+  // update underlining OCC entities
   update_OCC_entity(aBRepTrsf);
-  update_bounding_box();
 
   return CUBIT_SUCCESS;
 }
@@ -273,7 +272,9 @@
      lump->update_OCC_entity(aBRepTrsf);
   }
   set_TopoDS_Shape(compsolid);
-  
+
+  update_bounding_box(); 
+
   //unset marks.
   DLIList<OCCCurve*> curves;
   DLIList<OCCPoint*> points;

Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCBody.hpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -169,6 +169,8 @@
   
   virtual CubitPointContainment point_containment( const CubitVector& pos );
 
+  //update the underlining CompSolid
+  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf);
 protected: 
   
 private:
@@ -180,8 +182,6 @@
   TopoDS_CompSolid *myTopoDSShape;
 
   CubitBox boundingbox;
-  CubitStatus update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf); 
-  //update the underlining CompSolid
 };
 
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -1951,85 +1951,43 @@
   gp_Trsf aTrsf;  
   aTrsf.SetTranslation(aVec);
 
-  BRepBuilderAPI_Transform aBRepTrsf( aTrsf);
-  aBRepTrsf.Perform(*shape);
-  TopoDS_Shape translated_shape = aBRepTrsf.Shape();
+  BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
   
-  update_entity_shape(entity, &translated_shape);
+  update_entity_shape(entity, aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
 CubitStatus OCCQueryEngine::update_entity_shape(GeometryEntity* entity_ptr,
-						TopoDS_Shape *shape)
+						BRepBuilderAPI_Transform& aBRepTrsf)
 {
   if (OCCBody *body_ptr = CAST_TO( entity_ptr, OCCBody))
     {
-      TopoDS_CompSolid* theShape = (TopoDS_CompSolid*) shape;
-      if (!theShape)
-        {
-          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
-          return CUBIT_FAILURE;
-        }
-      body_ptr->set_TopoDS_Shape(*theShape);
+      body_ptr->update_OCC_entity(aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
-  else if (OCCLump * lump_ptr = CAST_TO( entity_ptr,OCCLump))
-    {
-      TopoDS_Solid * theSolid = (TopoDS_Solid *) shape;
-      if(theSolid)
-        {
-	  lump_ptr->set_TopoDS_Solid(*theSolid);
-          return CUBIT_SUCCESS;
-        }
-      else
-        {
-          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
-          return CUBIT_FAILURE;
-        }
-    }
-
   else if( OCCSurface *surface_ptr = CAST_TO( entity_ptr, OCCSurface))
     {
-      TopoDS_Face *theFace = (TopoDS_Face *)shape;
-      if(!theFace)
-        {
-          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
-          return CUBIT_FAILURE;
-        }
-
-      surface_ptr->set_TopoDS_Face(*theFace);
+      surface_ptr->update_OCC_entity(aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
   else if( OCCCurve *curve_ptr = CAST_TO( entity_ptr, OCCCurve))
     {
-      TopoDS_Edge *theEdge = (TopoDS_Edge *) shape;
-      if (!theEdge)
-        {
-          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
-          return CUBIT_FAILURE;
-        }
-       curve_ptr->set_TopoDS_Edge(*theEdge); 
+       curve_ptr->update_OCC_entity(aBRepTrsf); 
        return CUBIT_SUCCESS;
     }
 
   else if( OCCPoint *point_ptr = CAST_TO( entity_ptr, OCCPoint))
     {
-      TopoDS_Vertex *thePoint = (TopoDS_Vertex*) shape;
-      if (!thePoint)
-        {           
-          PRINT_ERROR("Entity and TopoDS_Shape don't match.\n" );
-          return CUBIT_FAILURE;
-        }
-
-      point_ptr->set_TopoDS_Vertex(*thePoint);
+      point_ptr->update_OCC_entity(aBRepTrsf);
       return CUBIT_SUCCESS;
     }
 
   PRINT_ERROR("Non-OCC TopologyBridge at %s:%d.\n", __FILE__, __LINE__ );
   return CUBIT_FAILURE;
 }
+
 //a is angular value of rotation in radians
 CubitStatus OCCQueryEngine::rotate( GeometryEntity* entity,
                                     const CubitVector& v, double a )
@@ -2051,6 +2009,7 @@
   aTrsf.SetRotation(anAxis, a);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+  update_entity_shape(entity, aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
@@ -2068,6 +2027,7 @@
   aTrsf.SetScaleFactor(f);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+  update_entity_shape(entity, aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 
@@ -2097,6 +2057,7 @@
   aTrsf.SetMirror(anAx2);
 
   BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
+  update_entity_shape(entity, aBRepTrsf);
   return CUBIT_SUCCESS;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -76,6 +76,7 @@
 class OCCCurve;
 class OCCPoint;
  
+class BRepBuilderAPI_Transform;
 class TopTools_DataMapOfShapeInteger;
 class TopoDS_Vertex;
 class TopoDS_Edge;
@@ -296,7 +297,7 @@
                                 CubitBox& super_box );
 
   CubitStatus update_entity_shape(GeometryEntity* entity_ptr,
-                                  TopoDS_Shape *shape);
+                                  BRepBuilderAPI_Transform& aTranf);
 
   CubitStatus translate( BodySM* body, const CubitVector& offset );
   CubitStatus rotate   ( BodySM* body, const CubitVector& axis, double angle );

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -227,7 +227,7 @@
 CubitStatus OCCSurface::get_point_normal( CubitVector& location,
                                             CubitVector& normal )
 {
-  assert(0);
+  //assert(0);
   return closest_point( location, NULL, &normal );
 }   
 
@@ -252,8 +252,8 @@
 CubitStatus OCCSurface::closest_point( CubitVector const& location, 
                                          CubitVector* closest_location,
                                          CubitVector* unit_normal_ptr,
-                                         CubitVector* curvature1_ptr,
-                                         CubitVector* curvature2_ptr)
+                                         CubitVector* curvature_1,
+                                         CubitVector* curvature_2)
 {
   BRepAdaptor_Surface asurface(*myTopoDSFace);
   gp_Pnt p(location.x(), location.y(), location.z()), newP(0.0, 0.0, 0.0);
@@ -262,7 +262,7 @@
   BRepLProp_SLProps SLP(asurface, 2, Precision::PConfusion());
   Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
   if (ext.IsDone() && (ext.NbExt() > 0)) {
-	  for ( i = 1 ; i < ext.NbExt() ; i++ ) {
+	  for ( i = 1 ; i <= ext.NbExt() ; i++ ) {
 		  if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
 			  minDist = p.Distance(ext.Point(i).Value());
 			  newP = ext.Point(i).Value();
@@ -270,17 +270,20 @@
 			  SLP.SetParameters(u, v);
 		  }
 	  }
-  }
-  *closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
-  if (unit_normal_ptr != NULL) {
-	  gp_Dir normal;
-	  if (SLP.IsNormalDefined()) {
+  
+	if (closest_location != NULL)
+ 	 	*closest_location = CubitVector(newP.X(), newP.Y(), newP.Z());
+  	if (unit_normal_ptr != NULL) {
+	  	gp_Dir normal;
+	  	if (SLP.IsNormalDefined()) {
 		  normal = SLP.Normal();
 		  *unit_normal_ptr = CubitVector(normal.X(), normal.Y(), normal.Z()); 
-	  }
+	  	}
+  	}
+  
+  	return CUBIT_SUCCESS;
   }
-  
-  return CUBIT_SUCCESS;
+  return CUBIT_FAILURE;
 }
 
 //-------------------------------------------------------------------------
@@ -332,7 +335,7 @@
   BRepLProp_SLProps SLP(asurface, 2, Precision::PConfusion());
   Extrema_ExtPS ext(p, asurface, Precision::Approximation(), Precision::Approximation());
   if (ext.IsDone() && (ext.NbExt() > 0)) {
-	  for ( i = 1 ; i < ext.NbExt() ; i++ ) {
+	  for ( i = 1 ; i <= ext.NbExt() ; i++ ) {
 		  if ( (i==1) || (p.Distance(ext.Point(i).Value()) < minDist) ) {
 			  minDist = p.Distance(ext.Point(i).Value());
 			  newP = ext.Point(i).Value();
@@ -563,6 +566,7 @@
 {
   BRepAdaptor_Surface asurface(*myTopoDSFace);
   lower_bound = asurface.FirstVParameter();
+
   upper_bound = asurface.LastVParameter();
   return CUBIT_TRUE;
 }
@@ -579,6 +583,19 @@
 }
 
 //-------------------------------------------------------------------------
+// Purpose       : Returns the center of the Surface mass
+//
+//-------------------------------------------------------------------------
+CubitVector OCCSurface::center_point()
+{
+  GProp_GProps myProps;
+  BRepGProp::SurfaceProperties(*myTopoDSFace, myProps);
+  gp_Pnt pt = myProps.CentreOfMass();
+  CubitVector v(pt.X(),pt.Y(), pt.Z());
+  return v; 
+}
+
+//-------------------------------------------------------------------------
 // Purpose       : This function tests the passed in position to see if
 //                 is on the underlying surface.
 //

Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -364,6 +364,7 @@
     //- Returns volume for Lump, area for Surface, length for Curve and 
     //- 1.0 for Point
 
+  CubitVector center_point();
   virtual CubitSense get_geometry_sense();
     //- Return the relative surface sense. (see below)
   

Modified: cgm/trunk/test/Makefile.am
===================================================================
--- cgm/trunk/test/Makefile.am	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/test/Makefile.am	2008-01-14 21:42:04 UTC (rev 1524)
@@ -8,7 +8,9 @@
            -I$(top_srcdir)/geom/facet \
            -I$(top_srcdir)/geom/Cholla \
 	   -I$(top_srcdir)/geom/OCC \
-           -I$(srcdir)
+	   -I$(srcdir) \
+	   $(OCC_INC_FLAG) \
+	   -I..\$(OCC_INC_FLAG)
 
 TESTS = makept
 if build_ACIS

Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp	2008-01-14 20:54:05 UTC (rev 1523)
+++ cgm/trunk/test/makept.cpp	2008-01-14 21:42:04 UTC (rev 1524)
@@ -29,6 +29,9 @@
 #include "AppUtil.hpp"
 #include "RefEntityFactory.hpp"
 #include "RefEdge.hpp"
+#include "BodySM.hpp"
+#include "OCCBody.hpp"
+#include "OCCSurface.hpp"
 
 // forward declare some functions used and defined later
 CubitStatus read_geometry(int, char **);
@@ -116,19 +119,21 @@
   argv = "./72_shaver6.brep";
   status = read_geometry(1, &argv);
   if (status == CUBIT_FAILURE) exit(1);
-
-  CubitVector vector(10,10,10);
+  
+  CubitVector vector1(10,10,10);
+  CubitVector vector2(15,15,15);
   DLIList<RefEntity*> free_entities;
   gti->get_free_ref_entities(free_entities);
  
   for(int i = 1; i <= free_entities.size(); i++)
   {
      RefEntity * entity = free_entities.get_and_step();
-     gti->translate((BasicTopologyEntity*)entity, i*vector); 
+     gti->translate((BasicTopologyEntity*)entity, i*vector1); 
   }
 
   // Read in the geometry from files specified on the command line
-  gmti->make_RefVertex(vector,5);
+  gmti->make_RefVertex(vector1,5);
+  gmti->make_RefVertex(vector2,5);
 
   CubitStatus rsl = CUBIT_SUCCESS;
   DLIList<RefEntity*> ref_entity_list;
@@ -136,13 +141,84 @@
   const CubitString cubit_version="10.2";
   const char * filename = "point.occ";
   const char * filetype = "OCC";
+  /*
   rsl = gti->export_solid_model(ref_entity_list, filename, filetype, 
                                  num_ents_exported, cubit_version);
 
+  */
   //delete all entities
   DLIList<Body*> bodies;
   gti->bodies(bodies);
   gti->get_free_ref_entities(free_entities);
+ 
+  RefVertex* vertex1 = CAST_TO(free_entities.get_and_step(),RefVertex);
+  RefVertex* vertex2 = CAST_TO(free_entities.get(),RefVertex);
+  CubitBoolean is_equal = gti->
+		about_spatially_equal(vertex1,vertex2);
+ 
+  CubitVector vi, vii;
+  double d;
+  gti->entity_entity_distance(vertex1,vertex2,vi, vii,d);
+ 
+  d = bodies.get()->measure(); 
+  vi = bodies.get()->center_point();
+  
+  CubitBox box = bodies.get()->bounding_box();
+
+  gti->entity_entity_distance(gti->get_first_ref_volume(), vertex2,vi, vii,d);
+
+  BodySM* body = bodies.get()->get_body_sm_ptr();
+  CubitVector axis(10,0,0);
+  gti->reflect(bodies, axis);
+  vi = bodies.get()->center_point();
+  gti->scale(bodies.get(),2);
+  vi = bodies.get()->center_point();
+  gti->translate(bodies.get(),axis);
+  vi = bodies.get()->center_point();
+  gti->rotate(bodies.get(), axis, 30);
+  vi = bodies.get()->center_point();
+  OCCBody* occ_body = CAST_TO(body, OCCBody);
+  occ_body->mass_properties(vi, d);
+  vi = occ_body->get_bounding_box().center(); 
+
+  //check for surfaces
+  DLIList<OCCSurface*> surfaces;
+
+  CAST_TO(body, OCCBody)->get_all_surfaces(surfaces);
+  OCCSurface* surface = surfaces.get();
+  GeometryType type = surface->geometry_type();
+  box = surface->bounding_box();
+  vi = surface->center_point();
+  CubitVector normal;
+  surface->get_point_normal(vi, normal);
+  CubitVector* closest_location = new CubitVector;
+  CubitVector* unit_normal_ptr = new CubitVector;
+  CubitVector* curvature1_ptr = new CubitVector;
+  CubitVector* curvature2_ptr = new CubitVector;
+  surface->closest_point(vi, closest_location, unit_normal_ptr, curvature1_ptr,
+                         curvature2_ptr);
+
+  double u = 0.5;      
+  double v = 0.5;
+  vi = surface->position_from_u_v(u,v);
+  CubitBoolean periodic = surface->is_periodic();
+  double p = 0; //period
+  periodic = surface->is_periodic_in_U(p); 
+  periodic = surface->is_periodic_in_V(p);
+  CubitBoolean sigular = surface->is_singular_in_U(1);
+  double lower, upper;
+  surface->get_param_range_U(lower, upper);
+  sigular = surface->is_singular_in_U(upper); 
+  sigular = surface->is_singular_in_U(lower);
+   
+  surface->get_param_range_V(lower, upper);
+  sigular = surface->is_singular_in_V(upper);
+  sigular = surface->is_singular_in_V(lower);
+
+  CubitBoolean closed = surface->is_closed_in_U();
+  closed = surface->is_closed_in_V();
+
+  CubitPointContainment pc = surface->point_containment(1,1);
   gti->delete_Body(bodies);
 
   for (int j = free_entities.size(); j--;)




More information about the cgma-dev mailing list