[cgma-dev] r1784 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Tue Apr 29 14:25:05 CDT 2008
Author: janehu
Date: 2008-04-29 14:25:05 -0500 (Tue, 29 Apr 2008)
New Revision: 1784
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCLoop.cpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCPoint.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Debugging on free curves leftover issue, free vertices are all removed at this point though. Haven't found the clue, but should be at the delete curve level.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -102,7 +102,8 @@
OCCBody::~OCCBody()
{
- delete myTopoDSShape;
+ if (myTopoDSShape)
+ delete myTopoDSShape;
}
GeometryQueryEngine* OCCBody::get_geometry_query_engine() const
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -111,7 +111,8 @@
//-------------------------------------------------------------------------
OCCCurve::~OCCCurve()
{
- delete myTopoDSEdge;
+ if (myTopoDSEdge)
+ delete myTopoDSEdge;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -62,7 +62,8 @@
OCCLoop::~OCCLoop()
{
disconnect_all_curves();
- delete myTopoDSWire;
+ if (myTopoDSWire)
+ delete myTopoDSWire;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -73,7 +73,10 @@
}
OCCLump::~OCCLump()
-{ delete myTopoDSSolid;}
+{
+ if (myTopoDSSolid)
+ delete myTopoDSSolid;
+}
//-------------------------------------------------------------------------
// Purpose : Find centroid
Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -82,7 +82,8 @@
//-------------------------------------------------------------------------
OCCPoint::~OCCPoint()
{
- delete myTopoDSVertex;
+ if (myTopoDSVertex)
+ delete myTopoDSVertex;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -1413,10 +1413,9 @@
{
if (remove_lower_entities)
return ( this->delete_solid_model_entities(ref_face_ptr) );
- TopoDS_Face *face = NULL;
- CubitStatus stat = this->unhook_Surface_from_OCC(ref_face_ptr, face);
+ CubitStatus stat = this->unhook_Surface_from_OCC(ref_face_ptr);
if(stat)
- delete face;
+ delete ref_face_ptr;
return stat;
}
@@ -1426,10 +1425,9 @@
{
if (remove_lower_entities)
return ( this->delete_solid_model_entities(ref_edge_ptr));
- TopoDS_Edge *edge = NULL;
- CubitStatus stat = this->unhook_Curve_from_OCC(ref_edge_ptr, edge);
+ CubitStatus stat = this->unhook_Curve_from_OCC(ref_edge_ptr);
if(stat)
- delete edge;
+ delete ref_edge_ptr;
return stat;
}
@@ -1447,6 +1445,28 @@
return CUBIT_FAILURE;
}
+
+CubitStatus
+OCCQueryEngine::delete_solid_model_entities(TopologyBridge* tb) const
+{
+ BodySM* body = CAST_TO(tb, BodySM);
+ if(body)
+ return delete_solid_model_entities(body);
+
+ Surface* surface = CAST_TO(tb, Surface);
+ if (surface)
+ return delete_solid_model_entities(surface);
+
+ Curve* curve = CAST_TO(tb, Curve);
+ if (curve)
+ return delete_solid_model_entities(curve);
+
+ Point* point = CAST_TO(tb, Point);
+ if(point)
+ return delete_solid_model_entities(point);
+
+ return CUBIT_FAILURE;
+}
//-------------------------------------------------------------------------
// Purpose : Delete a OCCBody and child entities.
//
@@ -1477,23 +1497,20 @@
{
delete occ_shell->my_body();
delete occ_shell->my_lump();
- TopoDS_Shell* Shell;
- CubitStatus stat = unhook_ShellSM_from_OCC(occ_shell,Shell);
+ CubitStatus stat = unhook_ShellSM_from_OCC(occ_shell);
DLIList<TopologyBridge*> tb_surfaces;
occ_shell->get_children_virt(tb_surfaces);
for(int k = 0; k < tb_surfaces.size(); k++)
delete_solid_model_entities(CAST_TO(tb_surfaces.get_and_step(), Surface));
- if(Shell)
- delete Shell;
+ delete occ_shell;
return stat;
}
- TopoDS_Shape* shape = NULL;
- CubitStatus stat = unhook_BodySM_from_OCC(bodysm, shape);
+ CubitStatus stat = unhook_BodySM_from_OCC(bodysm);
DLIList<TopologyBridge*> children;
DLIList<Lump*> lumps = occ_body->lumps();
- DLIList<TopoDS_Shell*> Shell_list;
+ DLIList<ShellSM*> shell_list;
for(int i =0; i < lumps.size(); i++)
{
@@ -1507,36 +1524,33 @@
{
ShellSM* shell = CAST_TO(children.get_and_step(), ShellSM);
- TopoDS_Shell* Shell = CAST_TO(shell, OCCShell)->get_TopoDS_Shell();
- if (Shell)
- Shell_list.append(Shell);
+ if (shell)
+ shell_list.append(shell);
DLIList<TopologyBridge*> tb_surfaces;
shell->get_children_virt(tb_surfaces);
for(int k = 0; k < tb_surfaces.size(); k++)
delete_solid_model_entities(CAST_TO(tb_surfaces.get_and_step(), Surface));
}
- for(int j = 0; j < Shell_list.size(); j++)
- delete Shell_list.pop();
-
- TopoDS_Solid* solid = occ_lump->get_TopoDS_Solid();
- delete solid;
+ for(int j = 0; j < shell_list.size(); j++)
+ delete shell_list.pop();
+ delete lump;
}
- if(shape)
- delete shape;
+ delete bodysm;
+ BodyList->remove(CAST_TO(bodysm, OCCBody));
+
return stat;
}
CubitStatus
-OCCQueryEngine::unhook_BodySM_from_OCC( BodySM* bodysm,
- TopoDS_Shape*& shape)const
+OCCQueryEngine::unhook_BodySM_from_OCC( BodySM* bodysm )const
{
OCCBody* occ_body = dynamic_cast<OCCBody*>(bodysm);
if (!occ_body)
return CUBIT_FAILURE;
- shape = occ_body->get_TopoDS_Shape();
+ TopoDS_Shape* shape = occ_body->get_TopoDS_Shape();
if (!shape)
return CUBIT_FAILURE;
@@ -1556,29 +1570,26 @@
if(!OccToCGM->erase(k))
PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
}
- if (occ_body_find)
- BodyList->remove(occ_body_find);
- else
- BodyList->remove(occ_body);
DLIList<Lump*> lumps = occ_body->lumps();
for(int i =0; i < lumps.size(); i++)
{
Lump* lump = lumps.get_and_step();
- OCCLump* occ_lump = CAST_TO(lump, OCCLump);
- if (occ_lump)
- occ_lump->remove_body();
+ //OCCLump* occ_lump = CAST_TO(lump, OCCLump);
+ //if(occ_lump)
+ // occ_lump->remove_body();
- TopoDS_Solid* solid;
- unhook_Lump_from_OCC(lump, solid);
+ unhook_Lump_from_OCC(lump);
}
- delete bodysm;
+ delete shape;
+ TopoDS_CompSolid Nullshape;
+ occ_body->set_TopoDS_Shape(Nullshape);
return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
-// Purpose : Delete a OCClumps and child entities.
+// Purpose : unhook a OCClumps and child entities.
//
// Special Notes :
//
@@ -1587,7 +1598,7 @@
// Creation Date : 11/29/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Lump_from_OCC( Lump* lump, TopoDS_Solid*& solid ) const
+OCCQueryEngine::unhook_Lump_from_OCC( Lump* lump ) const
{
if (lump == NULL)
return CUBIT_FAILURE;
@@ -1596,7 +1607,7 @@
if (!occ_lump)
return CUBIT_FAILURE;
- solid = occ_lump->get_TopoDS_Solid();
+ TopoDS_Solid* solid = occ_lump->get_TopoDS_Solid();
if(!solid)
return CUBIT_FAILURE;
@@ -1619,12 +1630,14 @@
for(int i = 0; i < children.size(); i++)
{
ShellSM* shell = CAST_TO(children.get_and_step(), ShellSM);
- TopoDS_Shell* Shell;
- unhook_ShellSM_from_OCC(shell,Shell);
+ unhook_ShellSM_from_OCC(shell);
}
if (occ_lump->get_body() != NULL)
BodyList->remove(CAST_TO(occ_lump->get_body(), OCCBody));
- delete lump;
+
+ delete solid;
+ TopoDS_Solid Nullsolid;
+ occ_lump->set_TopoDS_Solid(Nullsolid);
return CUBIT_SUCCESS;
}
@@ -1638,14 +1651,13 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_ShellSM_from_OCC( ShellSM* shell,
- TopoDS_Shell*& Shell ) const
+OCCQueryEngine::unhook_ShellSM_from_OCC( ShellSM* shell) const
{
OCCShell* occ_shell = dynamic_cast<OCCShell*>(shell);
if (!occ_shell)
return CUBIT_FAILURE;
- Shell = occ_shell->get_TopoDS_Shell();
+ TopoDS_Shell* Shell = occ_shell->get_TopoDS_Shell();
if(!Shell)
return CUBIT_FAILURE;
@@ -1663,7 +1675,9 @@
PRINT_ERROR("The OccSurface and TopoDS_Face pair is not in the map!");
}
- delete shell;
+ delete Shell;
+ TopoDS_Shell Nullshell;
+ occ_shell->set_TopoDS_Shell(Nullshell);
return CUBIT_SUCCESS;
}
@@ -1690,10 +1704,9 @@
LoopSM* loop = CAST_TO(children.get_and_step(), LoopSM);
delete_loop(loop);
}
- TopoDS_Face* face;
- CubitStatus stat = unhook_Surface_from_OCC(surface, face);
+ CubitStatus stat = unhook_Surface_from_OCC(surface);
if (stat)
- delete face;
+ delete surface;
return stat;
}
@@ -1707,14 +1720,13 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Surface_from_OCC( Surface* surface,
- TopoDS_Face*& face ) const
+OCCQueryEngine::unhook_Surface_from_OCC( Surface* surface) const
{
OCCSurface* fsurf = dynamic_cast<OCCSurface*>(surface);
if (!fsurf)
return CUBIT_FAILURE;
- face = fsurf->get_TopoDS_Face();
+ TopoDS_Face *face = fsurf->get_TopoDS_Face();
if(!face)
return CUBIT_FAILURE;
@@ -1734,7 +1746,9 @@
PRINT_WARNING("The OccSurface and TopoDS_Face pair is not in the map!");
}
- delete surface;
+ delete face;
+ TopoDS_Face Nullface;
+ fsurf->set_TopoDS_Face(Nullface);
return CUBIT_SUCCESS;
}
@@ -1757,21 +1771,24 @@
DLIList<OCCCoEdge*> children;
children = occ_loop->coedges();
int size = children.size();
+ DLIList<Curve*> curves;
while(size > 0)
{
OCCCoEdge* coedge = children.pop();
Curve* curve = coedge->curve();
- OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
- if (occ_curve == NULL)
- continue;
-
- delete_solid_model_entities(curve);
+ curves.append(curve);
}
- TopoDS_Wire* wire;
- CubitStatus status = unhook_LoopSM_from_OCC(loopsm, wire);
+ CubitStatus status = unhook_LoopSM_from_OCC(loopsm);
if (status)
- delete wire;
+ {
+ WireList->remove(CAST_TO(loopsm, OCCLoop));
+ delete loopsm;
+ }
+
+ for(int i = 0; i < curves.size(); i ++)
+ delete_solid_model_entities(curves.get_and_step());
+
return status;
}
@@ -1785,14 +1802,13 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_LoopSM_from_OCC( LoopSM* loopsm,
- TopoDS_Wire*& wire ) const
+OCCQueryEngine::unhook_LoopSM_from_OCC( LoopSM* loopsm) const
{
OCCLoop* occ_loop = dynamic_cast<OCCLoop*>(loopsm);
if (!occ_loop)
return CUBIT_FAILURE;
- wire = occ_loop->get_TopoDS_Wire();
+ TopoDS_Wire* wire = occ_loop->get_TopoDS_Wire();
if(!wire)
return CUBIT_FAILURE;
@@ -1850,8 +1866,9 @@
PRINT_ERROR("The OccLoop and TopoDS_Wire pair is not in the map!");
}
- WireList->remove(CAST_TO(loopsm, OCCLoop));
- delete loopsm;
+ delete wire;
+ TopoDS_Wire Nullwire;
+ occ_loop->set_TopoDS_Wire(Nullwire);
return CUBIT_SUCCESS;
}
@@ -1879,10 +1896,12 @@
delete_solid_model_entities(point);
}
- TopoDS_Edge* edge;
- CubitStatus stat = unhook_Curve_from_OCC(curve, edge);
+ CubitStatus stat = unhook_Curve_from_OCC(curve);
if (stat)
- delete edge;
+ {
+ CurveList->remove(CAST_TO(curve, OCCCurve));
+ delete curve;
+ }
return stat;
}
@@ -1896,17 +1915,18 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Curve_from_OCC( Curve* curve, TopoDS_Edge*& edge ) const
+OCCQueryEngine::unhook_Curve_from_OCC( Curve* curve ) const
{
OCCCurve* fcurve = dynamic_cast<OCCCurve*>(curve);
if (!fcurve )
return CUBIT_FAILURE;
fcurve->clean_loops();
- edge = fcurve->get_TopoDS_Edge();
+ TopoDS_Edge* edge = fcurve->get_TopoDS_Edge();
if (!edge)
return CUBIT_FAILURE;
+
//remove the entry from the map
int k;
if(OCCMap->IsBound(*edge))
@@ -1920,7 +1940,9 @@
PRINT_WARNING("The OccCurve and TopoDS_Edge pair is not in the map!");
}
- delete curve;
+ delete edge;
+ TopoDS_Edge Nulledge;
+ fcurve->set_TopoDS_Edge(Nulledge);
return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1939,10 +1961,9 @@
if (!fpoint)
return CUBIT_FAILURE;
- TopoDS_Vertex* vertex;
- CubitStatus stat = unhook_Point_from_OCC(point, vertex);
+ CubitStatus stat = unhook_Point_from_OCC(point);
if(stat)
- delete vertex;
+ delete point;
return stat;
}
@@ -1956,14 +1977,13 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Point_from_OCC( Point* point,
- TopoDS_Vertex*& vertex ) const
+OCCQueryEngine::unhook_Point_from_OCC( Point* point) const
{
OCCPoint* fpoint = dynamic_cast<OCCPoint*>(point);
if (!fpoint)
return CUBIT_FAILURE;
- vertex = fpoint->get_TopoDS_Vertex();
+ TopoDS_Vertex* vertex = fpoint->get_TopoDS_Vertex();
if (!vertex)
return CUBIT_FAILURE;
@@ -1979,7 +1999,9 @@
if(!OccToCGM->erase(k))
PRINT_ERROR("The OccPoint and TopoDS_Vertex pair is not in the map!");
}
- delete point;
+ delete vertex;
+ TopoDS_Vertex Nullvertex;
+ fpoint->set_TopoDS_Vertex(Nullvertex);
return CUBIT_SUCCESS;
}
@@ -2460,7 +2482,7 @@
{
OccToCGM->erase(k);
tb = (*it).second;
- delete tb;
+ delete_solid_model_entities( tb);
}
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -248,14 +248,10 @@
CubitBoolean import_vertices = CUBIT_TRUE,
CubitBoolean free_surfaces = CUBIT_TRUE );
- CubitStatus unhook_BodySM_from_OCC( BodySM* bodysm,
- TopoDS_Shape*& shape)const;
- CubitStatus unhook_Surface_from_OCC( Surface* surface,
- TopoDS_Face*& topo_face ) const;
- CubitStatus unhook_Curve_from_OCC( Curve* curve,
- TopoDS_Edge*& edge ) const;
- CubitStatus unhook_Point_from_OCC( Point* point,
- TopoDS_Vertex*& vertex ) const;
+ CubitStatus unhook_BodySM_from_OCC( BodySM* bodysm)const;
+ CubitStatus unhook_Surface_from_OCC( Surface* surface) const;
+ CubitStatus unhook_Curve_from_OCC( Curve* curve) const;
+ CubitStatus unhook_Point_from_OCC( Point* point) const;
private:
CubitStatus import_solid_model(FILE *file_ptr,
@@ -270,11 +266,9 @@
CubitBoolean import_vertices = CUBIT_TRUE,
CubitBoolean free_surfaces = CUBIT_TRUE);
- CubitStatus unhook_Lump_from_OCC( Lump* lump, TopoDS_Solid*& solid ) const;
- CubitStatus unhook_ShellSM_from_OCC( ShellSM* shell,
- TopoDS_Shell*& shell ) const;
- CubitStatus unhook_LoopSM_from_OCC( LoopSM* loopsm,
- TopoDS_Wire*& wire ) const;
+ CubitStatus unhook_Lump_from_OCC( Lump* lump ) const;
+ CubitStatus unhook_ShellSM_from_OCC( ShellSM* shell ) const;
+ CubitStatus unhook_LoopSM_from_OCC( LoopSM* loopsm) const;
CubitStatus delete_loop( LoopSM* loopsm)const;
public:
virtual void delete_solid_model_entities(DLIList<BodySM*>& body_list) const;
@@ -283,7 +277,7 @@
virtual CubitStatus delete_solid_model_entities(
GeometryEntity* ref_entity_ptr,
bool remove_lower_entities) const;
-
+ CubitStatus delete_solid_model_entities(TopologyBridge* tb) const;
virtual CubitStatus delete_solid_model_entities( BodySM* body_ptr ) const;
virtual CubitStatus delete_solid_model_entities(Surface* surf_ptr)const;
virtual CubitStatus delete_solid_model_entities( Curve* curve_ptr)const;
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -70,7 +70,8 @@
//-------------------------------------------------------------------------
OCCShell::~OCCShell()
{
- delete myTopoDSShell;
+ if(myTopoDSShell)
+ delete myTopoDSShell;
}
OCCCoFace* OCCShell::remove_coface(OCCCoFace *coface)
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-29 13:55:13 UTC (rev 1783)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-29 19:25:05 UTC (rev 1784)
@@ -94,7 +94,8 @@
OCCSurface::~OCCSurface()
{
- delete myTopoDSFace;
+ if(myTopoDSFace)
+ delete myTopoDSFace;
}
@@ -868,6 +869,8 @@
shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
}
OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+ if (shape.IsNull())
+ continue;
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
More information about the cgma-dev
mailing list