[cgma-dev] r1409 - cgm/trunk/geom/OCC

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Nov 19 11:47:39 CST 2007


Author: janehu
Date: 2007-11-19 11:47:39 -0600 (Mon, 19 Nov 2007)
New Revision: 1409

Modified:
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCCurve.hpp
Log:
Added get_center_radius and get_tangent, get_curvature for OCCCurve. Removed some unnecessary code.

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2007-11-19 16:36:02 UTC (rev 1408)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2007-11-19 17:47:39 UTC (rev 1409)
@@ -52,7 +52,11 @@
 #include "GeomLProp_CurveTool.hxx"
 #include "GeomAPI_ExtremaCurveCurve.hxx"
 #include "Geom_Line.hxx"
+#include "Geom_Circle.hxx"
+#include "Geom_Ellipse.hxx"
 #include "GC_MakeLine.hxx"
+#include "gp_Circ.hxx"
+#include "gp_Elips.hxx"
 //#include "TopOpeBRep_ShapeIntersector.hxx"
 //#include "TopOpeBRep_Point2d.hxx"
 //#include "TopOpeBRep_EdgesIntersector.hxx"
@@ -269,7 +273,7 @@
 // Creation Date : 07/14/00
 //-------------------------------------------------------------------
 CubitBoolean OCCCurve::get_param_range( double& lower_bound,
-                                          double& upper_bound )
+                                        double& upper_bound )
 {
   BRepAdaptor_Curve acurve(*myTopoDSEdge);
   lower_bound = acurve.FirstParameter();
@@ -636,11 +640,29 @@
   if( geometry_type() != ELLIPSE_CURVE_TYPE &&
       geometry_type() != ARC_CURVE_TYPE )
     return CUBIT_FAILURE;
-  
-  center = center;
-  radius = radius;
-  PRINT_DEBUG_122("OCCCurve::get_center_radius currently not implemented.\n");
-  return CUBIT_FAILURE;
+ 
+  //get the Geom_Curve of the OCCCurve
+  Standard_Real first;
+  Standard_Real last;
+  Handle(Geom_Curve) myCurve = BRep_Tool::Curve(*myTopoDSEdge, first, last); 
+
+  if (Handle(Geom_Circle) gCircle = Handle(Geom_Circle)::DownCast(myCurve))
+  {
+     radius = gCircle->Radius();
+     gp_Circ gp_circ = gCircle->Circ();
+     gp_Pnt  gp_p = gp_circ.Location();
+     center.set(gp_p.X(), gp_p.Y(), gp_p.Z());
+  }
+
+  else //ellipse
+  {
+     Handle(Geom_Ellipse) gEllipse = Handle(Geom_Ellipse)::DownCast(myCurve);
+     radius = gEllipse->MajorRadius();
+     gp_Elips gp_ellip = gEllipse->Elips();
+     gp_Pnt  gp_p = gp_ellip.Location();
+     center.set(gp_p.X(), gp_p.Y(), gp_p.Z());
+  }
+  return CUBIT_SUCCESS;
 }
 
 //-------------------------------------------------------------------------
@@ -677,77 +699,10 @@
    return end;
 }
 
-/*
-void OCCCurve::bodysms(DLIList<BodySM*> &bodies)
-{
-  int ii;
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    myCoEdges.get_and_step()->bodysms(bodies);
-  }
-}
 
-void OCCCurve::lumps(DLIList<Lump*> &lumps)
-{
-  int ii;
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    myCoEdges.get_and_step()->lumps(lumps);
-  }
-}
-
-void OCCCurve::shellsms(DLIList<ShellSM*> &shellsms)
-{
-  int ii;
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    myCoEdges.get_and_step()->shellsms(shellsms);
-  }
-}
-
-void OCCCurve::surfaces(DLIList<Surface*> &surfaces)
-{
-  int ii;
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    myCoEdges.get_and_step()->surfaces(surfaces);
-  }
-}
-
-void OCCCurve::loopsms(DLIList<LoopSM*> &loopsms)
-{
-  int ii; 
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    myCoEdges.get_and_step()->loopsms(loopsms);
-  }
-}
-
-
-void OCCCurve::coedgesms(DLIList<CoEdgeSM*> &coedgesms)
-{
-  int ii; 
-  for ( ii = myCoEdges.size(); ii > 0; ii-- )
-  {
-    coedgesms.append_unique( myCoEdges.get_and_step() );
-  } 
-}
-
-void OCCCurve::curves(DLIList<Curve*> &curves)
-{
-  curves.append_unique( this );
-}
-
-void OCCCurve::points(DLIList<Point*> &points)
-{
-  points.append_unique( myStartPoint );
-  points.append_unique( myEndPoint );
-}
-*/
-
-
 void OCCCurve::get_parents_virt( DLIList<TopologyBridge*>& parents ) 
-  { CAST_LIST_TO_PARENT( myCoEdges, parents ); }
+  {/* CAST_LIST_TO_PARENT( myCoEdges, parents );*/ }
+
 void OCCCurve::get_children_virt( DLIList<TopologyBridge*>& children ) 
 {
 	TopTools_IndexedMapOfShape M;
@@ -773,7 +728,7 @@
 		}
 	}
 }
-  
+ 
 
 
 
@@ -810,72 +765,6 @@
   return CUBIT_FALSE;
 }
 
-void OCCCurve::get_lumps( DLIList<OCCLump*>& result_list )
-{
-  DLIList<OCCShell*> shell_list;
-  get_shells( shell_list );
-  shell_list.reset();
-  for ( int i = shell_list.size(); i--; )
-  {
-    OCCShell* shell = shell_list.get_and_step();
-    shell->get_lumps( result_list );
-    OCCLump* lump = dynamic_cast<OCCLump*>(shell->get_lump());
-    if (lump)
-      result_list.append_unique(lump);
-  }
-}
-
-void OCCCurve::get_shells( DLIList<OCCShell*>& result_list )
-{
-  DLIList<OCCSurface*> surface_list;
-  DLIList<OCCShell*> temp_list;
-  get_surfaces( surface_list );
-  surface_list.reset();
-  for ( int i = surface_list.size(); i--; )
-  {
-    OCCSurface* surface = surface_list.get_and_step();
-    temp_list.clean_out();
-    surface->get_shells( temp_list );
-    result_list.merge_unique( temp_list );
-  }
-}
-
-void OCCCurve::get_surfaces( DLIList<OCCSurface*>& result_list )
-{
-  DLIList<OCCLoop*> loop_list;
-  get_loops( loop_list );
-  loop_list.reset();
-  for ( int i = loop_list.size(); i--; )
-  {
-    OCCLoop* loop = loop_list.get_and_step();
-    OCCSurface* surface = dynamic_cast<OCCSurface*>(loop->get_surface());
-    if (surface)
-      result_list.append_unique(surface);
-  }
-}
-
-void OCCCurve::get_loops( DLIList<OCCLoop*>& result_list )
-{
-  DLIList<OCCCoEdge*> coedge_list;
-  get_coedges( coedge_list );
-  coedge_list.reset();
-  for ( int i = coedge_list.size(); i--; )
-  {
-    OCCCoEdge* coedge = coedge_list.get_and_step();
-    OCCLoop* loop = dynamic_cast<OCCLoop*>(coedge->get_loop());
-    if (loop)
-      result_list.append_unique(loop);
-  }
-}
-
-void OCCCurve::get_coedges( DLIList<OCCCoEdge*>& result_list )
-{
-  myCoEdges.reset();
-  for ( int i = 0; i < myCoEdges.size(); i++ )
-    if ( OCCCoEdge* coedge = dynamic_cast<OCCCoEdge*>(myCoEdges.next(i)) )
-      result_list.append(coedge);
-}
-
 void OCCCurve::get_points( DLIList<OCCPoint*>& result_list )
 {
   TopTools_IndexedMapOfShape M;
@@ -887,7 +776,34 @@
   }
 }
 
+void OCCCurve::get_tangent( CubitVector const& location,
+                            CubitVector& tangent)
+{
+    double u = u_from_position(location);
+    Standard_Real first;
+    Standard_Real last;
+    Handle(Geom_Curve) myCurve = BRep_Tool::Curve(*myTopoDSEdge, first, last);
+ 
+    gp_Pnt p;
+    gp_Vec tan;
+    GeomLProp_CurveTool::D1(myCurve, u , p, tan) ;
+    tangent.set(tan.X(), tan.Y(), tan.Z());
+} 
 
+void OCCCurve::get_curvature( CubitVector const& location,
+                              CubitVector& curvature)
+{  
+    double u = u_from_position(location);
+    Standard_Real first;
+    Standard_Real last;
+    Handle(Geom_Curve) myCurve = BRep_Tool::Curve(*myTopoDSEdge, first, last);
+
+    gp_Pnt p;
+    gp_Vec tan, cur;
+    GeomLProp_CurveTool::D2(myCurve, u , p, tan, cur) ;
+    curvature.set(cur.X(), cur.Y(), cur.Z()); 
+}
+
 // ********** END PUBLIC FUNCTIONS         **********
 
 // ********** BEGIN PROTECTED FUNCTIONS    **********
@@ -928,44 +844,13 @@
       param -= period;
   }
 }
-CubitPointContainment OCCCurve::point_containment( const CubitVector &/*point*/ )
+
+CubitPointContainment OCCCurve::point_containment( const CubitVector &point )
 {
+   
    return CUBIT_PNT_UNKNOWN;
 }
-CubitPointContainment OCCCurve::point_containment( double /*u_param*/, 
-                                                       double /*v_param*/ )
-{
-  return CUBIT_PNT_UNKNOWN; 
-}
-CubitPointContainment OCCCurve::point_containment( CubitVector &/*point*/, 
-                                                       double /*u_param*/,
-                                                       double /*v_param*/ )
-{
-   return CUBIT_PNT_UNKNOWN;
-}
 
-//-------------------------------------------------------------------------
-// Purpose       : Tear down topology
-//
-// Special Notes : 
-//
-// Creator       : Jason Kraftcheck
-//
-// Creation Date : 09/29/03
-//-------------------------------------------------------------------------
-CubitStatus OCCCurve::disconnect_coedge( OCCCoEdge* coedge )
-{
-  assert(0);
-  if (!myCoEdges.move_to(coedge))
-    return CUBIT_FAILURE;
-  myCoEdges.remove();
-
-  assert(coedge->curve() == this);
-  coedge->remove_curve();
-  
-  return CUBIT_SUCCESS;
-}
-
 // ********** END PRIVATE FUNCTIONS        **********
 
 // ********** BEGIN HELPER CLASSES         **********

Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp	2007-11-19 16:36:02 UTC (rev 1408)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp	2007-11-19 17:47:39 UTC (rev 1409)
@@ -213,7 +213,6 @@
     //- *owning RefEdge*, regardless of the positive direction of the
     //- underlying solid model entities.
   
-#ifdef BOYD14
   void get_tangent( CubitVector const& location, 
                     CubitVector& tangent);
     //- this function returns the tangent vector at the given location
@@ -221,7 +220,6 @@
   void get_curvature( CubitVector const& location, 
                       CubitVector& curvature);
     //- this function returns the curvature vector at the given location
-#endif
   
   virtual CubitStatus position_from_u (double u_value,
                                        CubitVector& output_position);
@@ -318,54 +316,15 @@
   CubitStatus restore_attribs( FILE* file_ptr, unsigned int endian );
     // Read FactAttribs from file
   
-#ifdef BOYD14
-  void get_bodies  ( DLIList<OCCBody   *>& bodies   );
-#endif
-  void get_lumps   ( DLIList<OCCLump   *>& lumps    );
-  void get_shells  ( DLIList<OCCShell  *>& shells   );
-  void get_surfaces( DLIList<OCCSurface*>& surfaces );
-  void get_loops   ( DLIList<OCCLoop   *>& loops    );
-  void get_coedges ( DLIList<OCCCoEdge *>& coedges  );
-#ifdef BOYD14
-  void get_curves  ( DLIList<OCCCurve  *>& curves   );
-#endif
-  void get_points  ( DLIList<OCCPoint  *>& points   );
-
   void get_parents_virt( DLIList<TopologyBridge*>& parents );
   void get_children_virt( DLIList<TopologyBridge*>& children );
 
-  void get_facets(DLIList<CubitFacetEdge*>& facet_list);
-    //- Gets the list of facets describing this curve.
-  void get_points(DLIList<CubitPoint*>& point_list);
+  void get_points(DLIList<OCCPoint*>& point_list);
     //- Gets the list of points describing this curve.
 
-  void reset_length();
-    //- update the length of the facet curve
-
   TopoDS_Edge *get_TopoDS_Edge( )
     { return myTopoDSEdge; } 
 
-  void add_loop( LoopSM *loop_ptr )
-    { myLoops.append_unique( loop_ptr ); }
-    //- associate this curve with a coedge
-
-  void add_coedge( CoEdgeSM *coedge_ptr )
-    { myCoEdges.append_unique( coedge_ptr ); }
-    //- associate this curve with a coedge
-
-  Point *start_point()
-    { assert(0);return myStartPoint; }
-  Point *end_point()
-    { assert(0);return myEndPoint; }
-  CubitSense get_sense() { return sense_; }
-
-  CubitStatus disconnect_coedge( OCCCoEdge* coedge );
-  
-  void remove_start_point() { myStartPoint = 0; }
-  void remove_end_point() { myEndPoint = 0; }
-  
-  bool has_parent_coedge() { return myCoEdges.size() > 0; }
-
 protected: 
   
 private:
@@ -393,10 +352,6 @@
   friend void run_test_function();
 
   TopoDS_Edge *myTopoDSEdge;
-  DLIList<LoopSM*> myLoops;
-  Point *myStartPoint;
-  Point *myEndPoint;
-  DLIList<CoEdgeSM*> myCoEdges;
   int myId;
   bool periodic;
 };




More information about the cgma-dev mailing list