[cgma-dev] r1802 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Fri May 9 15:04:58 CDT 2008
Author: janehu
Date: 2008-05-09 15:04:58 -0500 (Fri, 09 May 2008)
New Revision: 1802
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCCurve.hpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Still working on subtracting a body which makes a surface be divided into two surfaces case. there's some memory leaks, looking for reasons.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -446,7 +446,8 @@
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *lump = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
- lumps.append_unique(lump);
+ if (lump)
+ lumps.append_unique(lump);
}
}
Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -35,7 +35,6 @@
class OCCShell;
class OCCSurface;
class OCCLoop;
-class OCCCoEdge;
class OCCPoint;
class BRepBuilderAPI_Transform;
class BRepAlgoAPI_BooleanOperation;
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -259,7 +259,8 @@
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *shell = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
- shellsms.append_unique(shell);
+ if (shell)
+ shellsms.append_unique(shell);
}
}
@@ -349,6 +350,11 @@
//set the Shells
TopTools_IndexedMapOfShape M;
TopoDS_Shape shape;
+ TopExp::MapShapes(new_shape, TopAbs_SOLID,M);
+ if(M.Extent() > 1)
+ new_shape.Nullify();
+
+ M.Clear();
TopExp::MapShapes(old_solid, TopAbs_SHELL, M);
TopTools_ListOfShape shapes;
@@ -356,18 +362,34 @@
{
TopoDS_Shell shell = TopoDS::Shell(M(ii));
- if(!new_shape.IsNull())
+ TopTools_ListOfShape shapes;
+ shapes.Assign(op->Modified(shell));
+ if (shapes.Extent() == 1)
+ shape = shapes.First();
+
+ else if(shapes.Extent() > 1)
+ shape.Nullify();
+
+ else if(op->IsDeleted(shell))
{
- TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(shell));
- if (shapes.Extent() > 0)
- shape = shapes.First();
+ TopTools_IndexedMapOfShape M_new;
+ TopExp::MapShapes(new_shape, TopAbs_SHELL, M_new);
+ if (M_new.Extent()== 1)
+ shape = M_new(1);
+ else
+ shape.Nullify();
}
+ else
+ {
+ shape = shell;
+ continue;
+ }
+
if(shapes.Extent() > 0 || op->IsDeleted(shell))
OCCShell::update_OCC_entity(shell, shape, op);
}
TopoDS_Solid new_solid;
- if(!op->IsDeleted(old_solid))
+ if(!new_shape.IsNull() && !op->IsDeleted(old_solid))
new_solid = TopoDS::Solid(new_shape);
OCCQueryEngine::instance()->update_OCC_map(old_solid, new_solid);
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -1197,7 +1197,8 @@
OCCMap->Bind(*poshell, iTotalTBCreated);
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)shell));
-
+ shell->set_body(NULL);
+ shell->set_lump(NULL);
if(standalone)
{
OCCLump* lump = new OCCLump(NULL, NULL, shell);
@@ -1243,8 +1244,8 @@
OCCCoFace * coface = new OCCCoFace( occ_surface, shell,
( topo_face.Orientation()== TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
cofaces_new.append(coface);
+ occ_surface->add_shell(shell);
}
- occ_surface->add_shell(shell);
if(standalone)
occ_surface->set_shell(shell);
@@ -1270,6 +1271,9 @@
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)surface));
SurfaceList->append(surface);
+ surface->set_body(NULL);
+ surface->set_lump(NULL);
+ surface->set_shell(NULL);
if(build_body)
{
OCCShell* shell = new OCCShell(NULL, surface);
@@ -1349,9 +1353,8 @@
coedge = new OCCCoEdge( curve, loop,
(Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
coedges_new.append(coedge);
- total_coedges++;
+ occ_curve->add_loop(loop);
}
- occ_curve->add_loop(loop);
}
loop->coedges(coedges_new);
@@ -2522,7 +2525,7 @@
}
int OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape,
- TopoDS_Shape new_shape)
+ TopoDS_Shape new_shape)
{
if (!OCCMap->IsBound(old_shape) || old_shape.IsEqual(new_shape))
return -1;
@@ -2552,11 +2555,40 @@
else
{
ShellSM * shell = CAST_TO(tb, ShellSM);
- if(shell && CAST_TO(shell, OCCShell)->my_lump())
+ if(shell)
{
- unhook_ShellSM_from_OCC(shell);
- delete shell;
+ DLIList<OCCCoFace*> children;
+ children = CAST_TO(shell, OCCShell)->cofaces();
+ while(children.size())
+ {
+ OCCCoFace* coface = children.pop();
+ CAST_TO(coface->surface(),OCCSurface)->remove_shell(CAST_TO(shell, OCCShell));
+ delete coface;
+ }
+
+ OCCLump* lump = CAST_TO(shell, OCCShell)->my_lump();
+ if(lump)
+ {
+ delete CAST_TO(shell, OCCShell)->my_body();
+ delete lump;
+ unhook_ShellSM_from_OCC(shell);
+ delete shell;
+ }
}
+ LoopSM* loop = CAST_TO(tb, LoopSM);
+ if(loop)
+ {
+ DLIList<OCCCoEdge*> children;
+ children = CAST_TO(loop, OCCLoop)->coedges();
+ while(children.size())
+ {
+ OCCCoEdge* coedge = children.pop();
+ CAST_TO(coedge->curve(), OCCCurve)->remove_loop(CAST_TO(loop, OCCLoop));
+ delete coedge;
+ }
+ unhook_LoopSM_from_OCC(loop);
+ delete loop;
+ }
}
}
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -172,7 +172,8 @@
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *surface = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
- children.append_unique(surface);
+ if(surface)
+ children.append_unique(surface);
}
}
@@ -268,8 +269,11 @@
{
TopoDS_Face face = TopoDS::Face(M(ii));
shapes.Assign(op->Modified(face));
- if(shapes.Extent() > 0)
+ if(shapes.Extent() == 1)
shape = shapes.First();
+ else
+ shape.Nullify();
+
if(shapes.Extent() > 0 || op->IsDeleted(face))
OCCSurface::update_OCC_entity(face,shape, op);
}
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-05-09 19:38:34 UTC (rev 1801)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-05-09 20:04:58 UTC (rev 1802)
@@ -720,7 +720,8 @@
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *loop = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
- children.append_unique(loop);
+ if(loop)
+ children.append_unique(loop);
}
}
@@ -832,25 +833,27 @@
for (int ii=1; ii<=M.Extent(); ii++)
{
TopoDS_Wire wire = TopoDS::Wire(M(ii));
- if(!new_surface.IsNull())
+ TopTools_ListOfShape shapes;
+ shapes.Assign(op->Modified(wire));
+ if (shapes.Extent() == 1)
+ shape = shapes.First();
+ else if(shapes.Extent() > 1)
+ shape.Nullify();
+ else if(op->IsDeleted(wire))
{
- TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(wire));
- if (shapes.Extent() > 0)
- shape = shapes.First();
- else if(op->IsDeleted(wire))
- {
- TopTools_IndexedMapOfShape M_new;
- TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
- if (M_new.Extent()>= ii)
- shape = M_new(ii);
- }
+ TopTools_IndexedMapOfShape M_new;
+ TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
+ if (M_new.Extent()== 1)
+ shape = M_new(1);
else
- {
- shape = wire;
- continue;
- }
- }
+ shape.Nullify();
+ }
+ else
+ {
+ shape = wire;
+ continue;
+ }
+
//set curves
BRepTools_WireExplorer Ex;
@@ -858,10 +861,12 @@
{
TopoDS_Edge edge = Ex.Current();
shapes.Assign(op->Modified(edge));
- if (shapes.Extent() > 0)
+ if (shapes.Extent() == 1)
shape_edge = shapes.First();
+ else if (shapes.Extent() > 1)
+ shape_edge.Nullify();
else if (op->IsDeleted(edge))
- ;
+ shape_edge.Nullify();
else
shape_edge = edge;
/*
@@ -874,9 +879,12 @@
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
shapes.Assign(op->Modified(vertex));
- if (shapes.Extent() > 0)
+ if (shapes.Extent() == 1)
shape_vertex = shapes.First();
+ else
+ shape_vertex.Nullify();
+
if(shapes.Extent() > 0 || op->IsDeleted(vertex))
OCCQueryEngine::instance()->update_OCC_map(vertex, shape_vertex);
More information about the cgma-dev
mailing list