[cgma-dev] r1566 - in cgm/trunk: geom/OCC util

janehu at mcs.anl.gov janehu at mcs.anl.gov
Tue Jan 29 14:04:20 CST 2008


Author: janehu
Date: 2008-01-29 14:04:20 -0600 (Tue, 29 Jan 2008)
New Revision: 1566

Modified:
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
   cgm/trunk/util/GeometryDefines.h
Log:
Added make_Curve for spline curves, corrected mistakes on curve and surface types.

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2008-01-29 20:04:20 UTC (rev 1566)
@@ -585,9 +585,9 @@
 {
   BRepAdaptor_Curve acurve(*myTopoDSEdge);
   if (acurve.GetType() == GeomAbs_BezierCurve)
-     return BEZIER_CURVE_TYPE;
+     return SPLINE_CURVE_TYPE;
   if (acurve.GetType() == GeomAbs_BSplineCurve)
-     return SPLINE_CURVE_TYPE;
+     return BSPLINE_CURVE_TYPE;
   if (acurve.GetType() == GeomAbs_Line)
      return STRAIGHT_CURVE_TYPE;
   if (acurve.GetType() == GeomAbs_Parabola)

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2008-01-29 20:04:20 UTC (rev 1566)
@@ -15,6 +15,10 @@
 #include "config.h"
 #include "gp_Pnt.hxx"
 #include "TopoDS_Shape.hxx"
+#include "TColgp_Array1OfPnt.hxx"
+#include "Geom_BezierCurve.hxx"
+#include "BRepBuilderAPI_MakeEdge.hxx"
+#include "BRep_Tool.hxx"
 #include "TopoDS.hxx"
 #include "TopologyBridge.hpp"
 #include "OCCModifyEngine.hpp"
@@ -162,8 +166,14 @@
     if(third_point != NULL && face_ptr != NULL) 
     {
        closed = CUBIT_TRUE;
-       //curve = make_Curve(type, point1_ptr, third_point, mid_points);
+       Point * Pnt = make_Point(*third_point);
+       curve = make_Curve(type, point1_ptr, Pnt, mid_points);
     }
+    else
+    {
+       PRINT_ERROR("Cannot create an OCC curve from the given duplicated points.\n");
+       return (Curve *)NULL;
+    }
   }
 
   Curve* new_curve = NULL;
@@ -180,7 +190,7 @@
 //===============================================================================
 // Function   : make_Curve
 // Member Type: PUBLIC
-// Description: make a curve
+// Description: make a  spline curve by using the points on surface.
 // Author     : Jane Hu
 // Date       : 01/08
 //===============================================================================
@@ -191,22 +201,84 @@
                              Surface* face_ptr) const
 {
   assert(point1_ptr != NULL && point2_ptr != NULL);
- /* 
-  OCCPoint const* occ_point1 = CAST_TO(point1_ptr, OCCPoint);
-  OCCPoint const* occ_point2 = CAST_TO(point2_ptr, OCCPoint);
+  
+  if (curve_type != SPLINE_CURVE_TYPE
+      && curve_type != STRAIGHT_CURVE_TYPE)
+  {
+     PRINT_ERROR("Cannot create an OCC curve from the given curve_type.\n"
+                 "Candidates are SPLINE_CURVE_TYPE and STRAIGHT_CURVE_TYPE.\n");
+     return (Curve *)NULL;
+  }
 
+  OCCPoint* occ_point1 = CAST_TO(const_cast<Point*>(point1_ptr), OCCPoint);
+  OCCPoint* occ_point2 = CAST_TO(const_cast<Point*>(point2_ptr), OCCPoint);
+
   if (occ_point1 == NULL || occ_point2 == NULL)
   {
      PRINT_ERROR("Cannot create an OCC curve from the given points.\n"
                  "Possible incompatible geometry engines.\n");
      return (Curve *)NULL;
   }
- */   
-  //project all points on the surface
+    
+  //project all points on the surface if possible
+  OCCSurface* occ_face = NULL;
   if (face_ptr != NULL)
+     occ_face = CAST_TO(face_ptr, OCCSurface);
+ 
+  gp_Pnt pt;
+  int size = 2+vector_list.size();
+  TColgp_Array1OfPnt points(1, size);
+  CubitVector* vector = NULL;
+  CubitVector closest_location;
+  for(int i = 1; i <= size; i++)
   {
+     if (i == 1) 
+     {
+       TopoDS_Vertex *point = occ_point1->get_TopoDS_Vertex();
+       pt = BRep_Tool::Pnt(*point);
+       vector = new CubitVector(point1_ptr->coordinates());
+     }
+     else if (i == size)
+     {
+       TopoDS_Vertex *point = occ_point2->get_TopoDS_Vertex();
+       pt = BRep_Tool::Pnt(*point);
+       vector = new CubitVector(point2_ptr->coordinates()); 
+     } 
+     else
+     {
+       vector = vector_list.get_and_step();
+       pt.SetCoord(vector->x(), vector->y(), vector->z());
+     } 
+
+     if (occ_face != NULL)
+     {
+       occ_face->closest_point(*vector, &closest_location);
+       pt.SetCoord(closest_location.x(), closest_location.y(), closest_location.z()) ;  	 
+     }
+
+     points.SetValue(i, pt); 
   }    
      
+  //make curve according to the curve type.
+  if(curve_type == SPLINE_CURVE_TYPE)
+  {
+    Geom_BezierCurve BezierCurve(points);
+    Handle(Geom_Curve) curve_ptr(&BezierCurve);
+    TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
+    return OCCQueryEngine::instance()->populate_topology_bridge(new_edge); 
+  }
+
+  else if(curve_type == STRAIGHT_CURVE_TYPE)
+  {
+    TColgp_Array1OfPnt two_points(1,2); 
+    two_points.SetValue(1, points.Value(1));
+    two_points.SetValue(2, points.Value(size));
+    Geom_BezierCurve BezierCurve(two_points);
+    Handle(Geom_Curve) curve_ptr(&BezierCurve);
+    TopoDS_Edge new_edge = BRepBuilderAPI_MakeEdge(curve_ptr);
+    return OCCQueryEngine::instance()->populate_topology_bridge(new_edge); 
+  }
+
   return (Curve*) NULL;
 }
 

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-01-29 20:04:20 UTC (rev 1566)
@@ -1540,12 +1540,12 @@
       k = OCCMap->Find(*face);
 
       if(!OCCMap->UnBind(*face))
-        PRINT_ERROR("The OccSurface and TopoDS_Face pair is not in the map!");
+        PRINT_WARNING("The OccSurface and TopoDS_Face pair is not in the map!");
 
       SurfaceList->remove((OCCSurface*)(OccToCGM->find(k))->second);
 
       if(!OccToCGM->erase(k))
-        PRINT_ERROR("The OccSurface and TopoDS_Face pair is not in the map!");
+        PRINT_WARNING("The OccSurface and TopoDS_Face pair is not in the map!");
     }
 
   DLIList<TopologyBridge*> children;
@@ -1555,6 +1555,7 @@
      LoopSM* loop = CAST_TO(children.get_and_step(), LoopSM);
      unhook_LoopSM_from_OCC(loop);
   }
+  return CUBIT_SUCCESS;
 }
 
 //-------------------------------------------------------------------------
@@ -1657,10 +1658,11 @@
       k = OCCMap->Find(*edge);
 
       if(!OCCMap->UnBind(*edge))
-        PRINT_ERROR("The OccCurve and TopoDS_Edge pair is not in the map!");
+        PRINT_WARNING("The OccCurve and TopoDS_Edge pair is not in the map!");
       CurveList->remove((OCCCurve*)(OccToCGM->find(k))->second);
       if(!OccToCGM->erase(k))
-        PRINT_ERROR("The OccCurve and TopoDS_Edge pair is not in the map!");    }
+        PRINT_WARNING("The OccCurve and TopoDS_Edge pair is not in the map!");
+    }
 
   DLIList<TopologyBridge*> children;
   fcurve->get_children_virt(children);
@@ -1669,6 +1671,7 @@
      Point* point = CAST_TO(children.get_and_step(), Point);
      unhook_Point_from_OCC(point);
   }
+  return CUBIT_SUCCESS;
 }
 //-------------------------------------------------------------------------
 // Purpose       : Delete a OCCPoint and child entities.
@@ -1729,6 +1732,7 @@
       if(!OccToCGM->erase(k))
         PRINT_ERROR("The OccPoint and TopoDS_Vertex pair is not in the map!");
     }
+  return CUBIT_SUCCESS;
 }
 
 

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2008-01-29 20:04:20 UTC (rev 1566)
@@ -169,6 +169,7 @@
      surface->update_OCC_entity(aBRepTrsf);
   }
   set_TopoDS_Shell(shell);
+  return CUBIT_SUCCESS;
 }
 
 // ********** END PUBLIC FUNCTIONS         **********

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2008-01-29 20:04:20 UTC (rev 1566)
@@ -186,9 +186,9 @@
 {
   BRepAdaptor_Surface asurface(*myTopoDSFace);
   if (asurface.GetType() == GeomAbs_BezierSurface)
-     return BEZIER_SURFACE_TYPE;
+     return SPLINE_SURFACE_TYPE;
   if (asurface.GetType() == GeomAbs_BSplineSurface)
-     return SPLINE_SURFACE_TYPE;
+     return BSPLINE_SURFACE_TYPE;
   if (asurface.GetType() == GeomAbs_Plane)      
      return PLANE_SURFACE_TYPE;
   if (asurface.GetType() == GeomAbs_Cylinder ||
@@ -769,6 +769,7 @@
      loop->update_OCC_entity(aBRepTrsf);
   }
   set_TopoDS_Face(surface);
+  return CUBIT_SUCCESS;
 }
 
 // ********** END PUBLIC FUNCTIONS         **********

Modified: cgm/trunk/util/GeometryDefines.h
===================================================================
--- cgm/trunk/util/GeometryDefines.h	2008-01-28 21:30:01 UTC (rev 1565)
+++ cgm/trunk/util/GeometryDefines.h	2008-01-29 20:04:20 UTC (rev 1566)
@@ -68,7 +68,7 @@
   SPLINE_CURVE_TYPE,
   STRAIGHT_CURVE_TYPE,
   POINT_CURVE_TYPE,
-  BEZIER_CURVE_TYPE,   //OCC curve types 
+  BSPLINE_CURVE_TYPE,   //OCC curve types 
   HYPERBOLA_CURVE_TYPE,
   UNDEFINED_CURVE_TYPE,
   
@@ -80,7 +80,7 @@
   TORUS_SURFACE_TYPE,
   BEST_FIT_SURFACE_TYPE,
   FACET_SURFACE_TYPE,
-  BEZIER_SURFACE_TYPE,      //OCC surface type
+  BSPLINE_SURFACE_TYPE,     //OCC surface type
   REVOLUTION_SURFACE_TYPE,  //OCC surface type
   EXTRUSION_SURFACE_TYPE,   //OCC surface type
   OFFSET_SURFACE_TYPE,      //OCC surface type




More information about the cgma-dev mailing list