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

jiangtao_ma at yahoo.com jiangtao_ma at yahoo.com
Fri Apr 3 15:02:36 CDT 2009


Author: janehu
Date: 2009-04-03 15:02:36 -0500 (Fri, 03 Apr 2009)
New Revision: 2799

Modified:
   cgm/trunk/geom/OCC/OCCAttribSet.cpp
   cgm/trunk/geom/OCC/OCCBody.cpp
   cgm/trunk/geom/OCC/OCCCoEdge.hpp
   cgm/trunk/geom/OCC/OCCCurve.cpp
   cgm/trunk/geom/OCC/OCCLoop.cpp
   cgm/trunk/geom/OCC/OCCLump.cpp
   cgm/trunk/geom/OCC/OCCModifyEngine.cpp
   cgm/trunk/geom/OCC/OCCPoint.cpp
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/geom/OCC/OCCShell.cpp
   cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Fixed some of the memery problems reported by valgrind.

Modified: cgm/trunk/geom/OCC/OCCAttribSet.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCAttribSet.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCAttribSet.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -122,8 +122,9 @@
   strings->step(); //type string filters out
   for(int i = 0; strings && i < size; i++)
   {
+    char const* string1 = strings->get_and_step()->c_str();
     TCollection_ExtendedString 
-       cstring((Standard_CString)strings->get_and_step()->c_str() );
+       cstring(string1, Standard_True );
     attr_string->SetValue(i, cstring) ;
   }
   
@@ -168,7 +169,9 @@
 {
   DLIList<int*>* ints = csa->int_data_list();
   CubitString type = csa->character_type();
-  TCollection_ExtendedString cstring( (Standard_CString)type.c_str() );
+  char const* string1 = type.c_str();
+  Standard_Boolean isMultiByte = Standard_True;
+  TCollection_ExtendedString cstring( string1, isMultiByte );
   DLIList<double*>* doubles = csa->double_data_list();
   DLIList<CubitString*>* strings = csa->string_data_list();
 
@@ -233,7 +236,8 @@
       for(int i = 0; i < strings->size()-1; i++)
       {
         CubitString astring = *strings->get_and_step();
-        TCollection_ExtendedString string( (Standard_CString)astring.c_str() );
+        char const* string1 = astring.c_str();
+        TCollection_ExtendedString string( string1 , Standard_True);
         if(attr_strings->Value(i) != string)
         {
           is_same = CUBIT_FALSE;
@@ -355,7 +359,8 @@
         temp_string[j-1] = ToCharacter(c);
       }
       temp_string[length2] = '\0';
-      string = new CubitString(&temp_string[0]);
+      const char *s = &temp_string[0];
+      string = new CubitString(s);
       strings.append(string);
     }
   }

Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCBody.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -90,7 +90,7 @@
 
   TopoDS_CompSolid * the_comp = new TopoDS_CompSolid(theshape);
   if(myTopoDSShape)
-    delete myTopoDSShape;
+    delete (TopoDS_CompSolid*)myTopoDSShape;
   myTopoDSShape = the_comp;
 }
 
@@ -121,7 +121,7 @@
 OCCBody::~OCCBody() 
 {
   if (myTopoDSShape)
-    delete myTopoDSShape;
+    delete (TopoDS_CompSolid*)myTopoDSShape;
 }
 
 GeometryQueryEngine* OCCBody::get_geometry_query_engine() const

Modified: cgm/trunk/geom/OCC/OCCCoEdge.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCoEdge.hpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCCoEdge.hpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -60,7 +60,8 @@
     
   inline void set_curve(Curve* curve) {myCurve = curve;}
 
-  inline LoopSM* loop() const { return myLoop; }
+  inline LoopSM* loop() const { if(myLoop)return myLoop;
+                                else return NULL; }
 
   inline void set_loop(LoopSM * loop) {myLoop = loop;}
 
@@ -121,8 +122,8 @@
   
 private:
   int myMark;
-  Curve *myCurve;
-  LoopSM *myLoop;
+  Curve *myCurve ;
+  LoopSM *myLoop ;
   CubitSense edgeSense;
 };
 

Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -111,7 +111,7 @@
 OCCCurve::~OCCCurve() 
 {
   if (myTopoDSEdge)
-    delete myTopoDSEdge;
+    delete (TopoDS_Edge *)myTopoDSEdge;
 }
 
 void OCCCurve::set_TopoDS_Edge(TopoDS_Edge edge)
@@ -121,7 +121,7 @@
 
   TopoDS_Edge* the_edge = new TopoDS_Edge(edge);
   if(myTopoDSEdge)
-    delete myTopoDSEdge;
+    delete (TopoDS_Edge *)myTopoDSEdge;
   myTopoDSEdge = the_edge;
 }
 
@@ -997,7 +997,8 @@
         return (Curve*) NULL;
    }
 
-   BRepAlgo_NormalProjection aProjection(*face);
+   BRepAlgo_NormalProjection aProjection;
+   aProjection.Init(*face);
    aProjection.Add(*edge);
    aProjection.Build();
    if (!aProjection.IsDone())

Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -62,7 +62,7 @@
 {
   disconnect_all_curves();
   if (myTopoDSWire)
-    delete myTopoDSWire;
+    delete (TopoDS_Wire*)myTopoDSWire;
 }
 
 void OCCLoop::set_TopoDS_Wire(TopoDS_Wire loop)
@@ -71,7 +71,7 @@
      return;
    TopoDS_Wire* the_wire = new TopoDS_Wire(loop);
    if(myTopoDSWire)
-     delete myTopoDSWire;
+     delete (TopoDS_Wire*)myTopoDSWire;
    myTopoDSWire = the_wire;
 }
 //-------------------------------------------------------------------------

Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCLump.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -77,7 +77,7 @@
 OCCLump::~OCCLump()
 { 
   if (myTopoDSSolid)
-    delete myTopoDSSolid;
+    delete (TopoDS_Solid*)myTopoDSSolid;
 }
 
 void OCCLump::set_TopoDS_Solid(TopoDS_Solid solid)
@@ -87,7 +87,7 @@
 
   TopoDS_Solid* the_solid = new TopoDS_Solid(solid);
   if(myTopoDSSolid)
-    delete myTopoDSSolid ;
+    delete (TopoDS_Solid*)myTopoDSSolid ;
 
   myTopoDSSolid = the_solid;
 }

Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -3545,7 +3545,7 @@
      double orig_mass = myProps.Mass();
      TopTools_IndexedMapOfShape M;
      TopExp::MapShapes(cut_shape, TopAbs_SOLID, M);
-     double after_mass;
+     double after_mass = 0.0;
      CubitBoolean no_volume = CUBIT_FALSE;
      if(M.Extent() > 0)
      {

Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -81,7 +81,7 @@
 OCCPoint::~OCCPoint() 
 {
   if (myTopoDSVertex)
-    delete myTopoDSVertex;
+    delete (TopoDS_Vertex*)myTopoDSVertex;
 }
 
 void OCCPoint::set_TopoDS_Vertex(TopoDS_Vertex vertex)
@@ -90,7 +90,7 @@
     return;
   TopoDS_Vertex* the_vertex = new TopoDS_Vertex(vertex);
   if(myTopoDSVertex)
-    delete myTopoDSVertex;
+    delete (TopoDS_Vertex*)myTopoDSVertex;
   myTopoDSVertex = the_vertex;
 }
 //-------------------------------------------------------------------------

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -1209,7 +1209,8 @@
   else if(strcmp(file_type, "IGES") == 0)
   {
     IGESControl_Reader reader;
-    IFSelect_ReturnStatus stat = reader.ReadFile( (char*) file_name);
+    const Standard_CString string1 = file_name;
+    IFSelect_ReturnStatus stat = reader.ReadFile( string1);
     if (stat  != IFSelect_RetDone)
     {
        PRINT_INFO("%s: Cannot open file", file_name );
@@ -2273,11 +2274,11 @@
   }
   
   CubitStatus stat = unhook_Curve_from_OCC(curve);
-  if (stat)
-  {
-    CurveList->remove(fcurve);
-    delete curve;
-  }
+  if (!stat)
+    return CUBIT_FAILURE;
+
+  CurveList->remove(fcurve);
+  delete fcurve;
   return stat;
 }
 
@@ -2921,7 +2922,7 @@
          {
            OCCCoEdge* coedge = children.pop();
            CAST_TO(coedge->curve(), OCCCurve)->remove_loop(CAST_TO(loop, OCCLoop));
-           delete coedge;
+           delete (OCCCoEdge*)coedge;
          }
          unhook_LoopSM_from_OCC(loop);
          delete loop;

Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCShell.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -72,7 +72,7 @@
 OCCShell::~OCCShell()
 {
   if(myTopoDSShell)
-    delete myTopoDSShell;
+    delete (TopoDS_Shell*)myTopoDSShell;
 }
 
 OCCCoFace* OCCShell::remove_coface(OCCCoFace *coface)
@@ -87,7 +87,7 @@
 
   TopoDS_Shell* the_shell = new TopoDS_Shell(shell);
   if (myTopoDSShell)
-    delete myTopoDSShell;
+    delete (TopoDS_Shell*)myTopoDSShell;
 
   myTopoDSShell = the_shell;
 }

Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp	2009-04-03 19:35:55 UTC (rev 2798)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp	2009-04-03 20:02:36 UTC (rev 2799)
@@ -96,7 +96,7 @@
 OCCSurface::~OCCSurface() 
 {
   if(myTopoDSFace)
-    delete myTopoDSFace;
+    delete (TopoDS_Face*)myTopoDSFace;
 }
 
 void OCCSurface::set_TopoDS_Face(TopoDS_Face& face)
@@ -106,7 +106,7 @@
 
   TopoDS_Face* face_ptr = new TopoDS_Face(face);
   if(myTopoDSFace)
-    delete myTopoDSFace;
+    delete (TopoDS_Face*)myTopoDSFace;
   myTopoDSFace = face_ptr ; 
 }
 
@@ -1001,7 +1001,7 @@
   }
   if (!old_surface.IsSame(new_surface))
   {
-    TopAbs_ShapeEnum shapetype;
+    TopAbs_ShapeEnum shapetype =  TopAbs_SHAPE;
     if(!new_surface.IsNull())
       shapetype = new_surface.TShape()->ShapeType();  
     if(shapetype == TopAbs_FACE || new_surface.IsNull())



More information about the cgma-dev mailing list