cgma-dev
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
April 2008
- 3 participants
- 26 discussions
Author: janehu
Date: 2008-04-30 13:36:10 -0500 (Wed, 30 Apr 2008)
New Revision: 1787
Modified:
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:
Reviewed with Jason and now think that CoEdge hasn't been cleaned out correctly so it still has free ref edges. will update and check on it tomorrow.
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -918,13 +918,15 @@
shapes.Assign(op->Modified(*get_TopoDS_Edge()));
if(shapes.Extent())
shape = shapes.First();
+ else if (op->IsDeleted(*get_TopoDS_Edge()))
+ ;
else
return ;
}
- TopoDS_Edge curve = TopoDS::Edge(shape);
+ TopoDS_Edge curve;
+ if(!shape.IsNull())
+ curve = TopoDS::Edge(shape);
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSEdge, curve);
-
//set the vertices
DLIList<TopologyBridge*> vertices;
get_children_virt(vertices);
@@ -936,7 +938,7 @@
point->update_OCC_entity(aBRepTrsf, op);
}
myMarked = 1;
- set_TopoDS_Edge(curve);
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSEdge, curve);
}
//===============================================================================
Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -238,22 +238,23 @@
shapes.Assign(op->Modified(*get_TopoDS_Wire()));
if(shapes.Extent())
shape = shapes.First();
+ else if (op->IsDeleted(*get_TopoDS_Wire()))
+ ;
else
need_update = CUBIT_FALSE;
}
- TopoDS_Wire loop;
- if (need_update)
- {
- loop = TopoDS::Wire(shape);
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSWire, loop);
- }
+
//set the curves
for (int i = 1; i <= myCoEdgeList.size(); i++)
{
OCCCurve *curve = CAST_TO(myCoEdgeList.get_and_step()->curve(), OCCCurve);
curve->update_OCC_entity(aBRepTrsf, op);
}
+ TopoDS_Wire loop;
if (need_update)
- set_TopoDS_Wire(loop);
+ {
+ loop = TopoDS::Wire(shape);
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSWire, loop);
+ }
}
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -315,13 +315,16 @@
shapes.Assign(op->Modified(*get_TopoDS_Solid()));
if(shapes.Extent() > 0)
shape = shapes.First();
+ else if(op->IsDeleted(*get_TopoDS_Solid()))
+ ;
else
return CUBIT_SUCCESS;
}
- TopoDS_Solid solid = TopoDS::Solid(shape);
+
+ TopoDS_Solid solid;
+ if(!op->IsDeleted(*get_TopoDS_Solid()))
+ solid = TopoDS::Solid(shape);
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);
-
//set the lumps
DLIList<TopologyBridge *> shells;
this->get_children_virt(shells);
@@ -330,6 +333,7 @@
OCCShell *shell = CAST_TO(shells.get_and_step(), OCCShell);
shell->update_OCC_entity(aBRepTrsf, op);
}
- set_TopoDS_Solid(solid);
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSSolid, solid);
+
}
Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -278,10 +278,14 @@
shapes.Assign(op->Modified(*get_TopoDS_Vertex()));
if(shapes.Extent())
shape = shapes.First();
+ else if(op->IsDeleted(*get_TopoDS_Vertex()))
+ ;
else
return ;
}
- TopoDS_Vertex vertex = TopoDS::Vertex(shape);
+ TopoDS_Vertex vertex;
+ if(!shape.IsNull())
+ vertex = TopoDS::Vertex(shape);
OCCQueryEngine::instance()->update_OCC_map(*myTopoDSVertex, vertex);
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -2471,23 +2471,61 @@
OCCMap->UnBind(old_shape);
+ std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
+ TopologyBridge* tb = NULL;
+ if (it != OccToCGM->end())
+ tb = (*it).second;
+
+ else
+ assert(0);
+
if ((!new_shape.IsNull() && !old_shape.IsSame(new_shape)&&
OCCMap->IsBound(new_shape))|| new_shape.IsNull())
//already has a TB built on new_shape
{
//delete the second TB corresponding to old_shape
- std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
- TopologyBridge* tb = NULL;
- if (it != OccToCGM->end())
- {
- OccToCGM->erase(k);
- tb = (*it).second;
- delete_solid_model_entities( tb);
- }
+ OccToCGM->erase(k);
+ delete_solid_model_entities( tb);
}
else
+ {
OCCMap->Bind(new_shape, k);
+ set_TopoDS_Shape(tb, new_shape);
+ }
return k;
}
+
+void OCCQueryEngine::set_TopoDS_Shape(TopologyBridge* tb,
+ TopoDS_Shape shape)
+{
+ BodySM* body = CAST_TO(tb, BodySM);
+ if(body)
+ return CAST_TO(body, OCCBody)->set_TopoDS_Shape(TopoDS::CompSolid(shape));
+
+ Lump* lump = CAST_TO(tb, Lump);
+ if(lump)
+ return CAST_TO(lump, OCCLump)->set_TopoDS_Solid(TopoDS::Solid(shape));
+
+ ShellSM* shell = CAST_TO(tb, ShellSM);
+ if(shell)
+ return CAST_TO(shell, OCCShell)->set_TopoDS_Shell(TopoDS::Shell(shape));
+
+ Surface* surface = CAST_TO(tb, Surface);
+ if (surface)
+ return CAST_TO(surface, OCCSurface)->set_TopoDS_Face(TopoDS::Face(shape));
+
+ LoopSM* loop = CAST_TO(tb, LoopSM);
+ if(loop)
+ return CAST_TO(loop, OCCLoop)->set_TopoDS_Wire(TopoDS::Wire(shape));
+
+ Curve* curve = CAST_TO(tb, Curve);
+ if (curve)
+ return CAST_TO(curve, OCCCurve)->set_TopoDS_Edge(TopoDS::Edge(shape));
+
+ Point* point = CAST_TO(tb, Point);
+ if(point)
+ return CAST_TO(point, OCCPoint)->set_TopoDS_Vertex(TopoDS::Vertex(shape));
+
+}
//EOF
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -310,6 +310,7 @@
BRepBuilderAPI_Transform* aTranf,
BRepAlgoAPI_BooleanOperation *op = NULL);
+ void set_TopoDS_Shape(TopologyBridge* tb, TopoDS_Shape new_shape);
CubitStatus translate( BodySM* body, const CubitVector& offset );
CubitStatus rotate ( BodySM* body, const CubitVector& axis, double angle );
CubitStatus scale ( BodySM* body, double factor );
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -218,13 +218,15 @@
shapes.Assign(op->Modified(*get_TopoDS_Shell()));
if (shapes.Extent())
shape = shapes.First();
+ else if(op->IsDeleted(*get_TopoDS_Shell()))
+ ;
else
return CUBIT_SUCCESS;
}
- TopoDS_Shell shell = TopoDS::Shell(shape);
+ TopoDS_Shell shell;
+ if (!shape.IsNull())
+ shell = TopoDS::Shell(shape);
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShell, shell);
-
//set the surfaces
DLIList<TopologyBridge *> surfaces;
this->get_children_virt(surfaces);
@@ -233,7 +235,7 @@
OCCSurface *surface = CAST_TO(surfaces.get_and_step(), OCCSurface);
surface->update_OCC_entity(aBRepTrsf, op);
}
- set_TopoDS_Shell(shell);
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShell, shell);
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-30 15:42:51 UTC (rev 1786)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-30 18:36:10 UTC (rev 1787)
@@ -784,17 +784,18 @@
shapes.Assign(op->Modified(*get_TopoDS_Face()));
if (shapes.Extent() > 0)
shape = shapes.First();
+ else if(op->IsDeleted(*get_TopoDS_Face()))
+ ;
else
return CUBIT_SUCCESS;
}
TopoDS_Face surface;
- surface = TopoDS::Face(shape);
+ if(!shape.IsNull())
+ surface = TopoDS::Face(shape);
if (aBRepTrsf)
{
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
-
//set the loops
DLIList<OCCLoop *> loops;
this->get_loops(loops);
@@ -803,7 +804,7 @@
OCCLoop *loop = loops.get_and_step();
loop->update_OCC_entity(aBRepTrsf, op);
}
- set_TopoDS_Face(surface);
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
}
else if(op)
@@ -821,17 +822,16 @@
TopoDS_Face& new_surface,
BRepAlgoAPI_BooleanOperation *op)
{
- OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
-
//set the Wires
TopTools_IndexedMapOfShape M;
- TopoDS_Shape shape;
+ TopoDS_Shape shape, shape_edge, shape_vertex;
TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
int ii;
TopTools_ListOfShape shapes;
- for (ii=1; ii<=M.Extent(); ii++) {
+ for (ii=1; ii<=M.Extent(); ii++)
+ {
TopoDS_Wire wire = TopoDS::Wire(M(ii));
if(!new_surface.IsNull())
@@ -846,45 +846,41 @@
TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
shape = M_new(ii);
}
-
- OCCQueryEngine::instance()->update_OCC_map(wire, shape);
}
//set curves
BRepTools_WireExplorer Ex;
+
for(Ex.Init(wire); Ex.More();Ex.Next())
{
TopoDS_Edge edge = Ex.Current();
shapes.Assign(op->Modified(edge));
- shape.Nullify();
if (shapes.Extent() > 0)
- shape = shapes.First();
+ shape_edge = shapes.First();
else if (op->IsDeleted(edge))
;
else
continue;
- if(wire.Orientation() == TopAbs_REVERSED && !shape.IsNull())
+ if(wire.Orientation() == TopAbs_REVERSED && !shape_edge.IsNull())
{
- shape.Orientation(
- shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
+ shape_edge.Orientation(
+ shape_edge.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();
shapes.Assign(op->Modified(vertex));
- shape.Nullify();
if (shapes.Extent() > 0)
- {
- shape = shapes.First();
- OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
- }
- else if(op->IsDeleted(vertex))
- OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
+ shape_vertex = shapes.First();
+
+ if(shapes.Extent() > 0 || op->IsDeleted(vertex))
+ OCCQueryEngine::instance()->update_OCC_map(vertex, shape_vertex);
+
+ OCCQueryEngine::instance()->update_OCC_map(edge, shape_edge);
}
+ OCCQueryEngine::instance()->update_OCC_map(wire, shape);
}
+ OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
return CUBIT_SUCCESS;
}
1
0
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();
1
0
Author: janehu
Date: 2008-04-28 13:09:47 -0500 (Mon, 28 Apr 2008)
New Revision: 1782
Modified:
cgm/trunk/geom/Body.cpp
cgm/trunk/geom/BodySM.hpp
cgm/trunk/geom/GeometryModifyTool.cpp
cgm/trunk/geom/GeometryModifyTool.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/geom/facet/FacetBody.hpp
cgm/trunk/geom/virtual/CompositeBody.hpp
cgm/trunk/geom/virtual/PartitionBody.hpp
Log:
worked on deleting free edge and vertices, still has some left, investgating.
Modified: cgm/trunk/geom/Body.cpp
===================================================================
--- cgm/trunk/geom/Body.cpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/Body.cpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -193,8 +193,19 @@
DLIList<RefVolume*> volumes;
ref_volumes(volumes);
while (volumes.size())
+ {
if (!volumes.pop()->is_sheet())
- return CUBIT_FALSE;
+ {
+ //OCC sheet body just has one face or shell, not like Acis
+ BodySM* bodysm = get_body_sm_ptr();
+ if (bodysm == NULL)
+ {
+ PRINT_ERROR("Body %d is invalid -- no attached BodySM.\n", this->id());
+ return CUBIT_FALSE;
+ }
+ return bodysm->is_sheet_body();
+ }
+ }
return CUBIT_TRUE;
}
Modified: cgm/trunk/geom/BodySM.hpp
===================================================================
--- cgm/trunk/geom/BodySM.hpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/BodySM.hpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -74,6 +74,7 @@
CubitBox bounding_box();
+ virtual CubitBoolean is_sheet_body() = 0;
protected:
private:
Modified: cgm/trunk/geom/GeometryModifyTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.cpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/GeometryModifyTool.cpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -1425,7 +1425,6 @@
//
// Creation Date : 03/29/97
//-------------------------------------------------------------------------
-/*
RefVolume*
GeometryModifyTool::make_RefVolume( DLIList<RefFace*>& ref_face_list) const
{
@@ -1465,13 +1464,14 @@
}
// Use the Lump to make a RefVolume
+ CubitBoolean modified;
RefVolume* ref_volume_ptr =
- GeometryQueryTool::instance()->make_RefVolume(lump_ptr);
+ GeometryQueryTool::instance()->make_RefVolume(lump_ptr, modified);
// Return the new RefVolume
return ref_volume_ptr ;
}
-*/
+
//-------------------------------------------------------------------------
// Purpose : This function takes a list of RefVolumes to create a
// Body. The underlying representation of the Body is
Modified: cgm/trunk/geom/GeometryModifyTool.hpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.hpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/GeometryModifyTool.hpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -916,7 +916,7 @@
* made for some reason.
*/
-// RefVolume* make_RefVolume(DLIList<RefFace*>& ref_face_list) const ;
+ RefVolume* make_RefVolume(DLIList<RefFace*>& ref_face_list) const ;
/**< \return RefVlume*
* \return - A pointer to a newly created RefVlume
* \arg ref_volume_type
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -1632,16 +1632,7 @@
else if(fuser.IsDeleted(face))
{
TopoDS_Face null_face;
- int k = OCCSurface::update_OCC_entity(face, null_face, &fuser);
- std::map<int, TopologyBridge*>::iterator it =
- OCCQueryEngine::instance()->OccToCGM->find(k);
- TopologyBridge* tb = NULL;
- if (it != OCCQueryEngine::instance()->OccToCGM->end())
- {
- OCCQueryEngine::instance()->OccToCGM->erase(k);
- tb = (*it).second;
- delete tb;
- }
+ OCCSurface::update_OCC_entity(face, null_face, &fuser);
}
}
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -2447,8 +2447,10 @@
int k = OCCMap->Find(old_shape);
assert (k > 0 && k <= iTotalTBCreated);
- if (!new_shape.IsNull() && !old_shape.IsSame(new_shape)&&
- OCCMap->IsBound(new_shape))
+ OCCMap->UnBind(old_shape);
+
+ if ((!new_shape.IsNull() && !old_shape.IsSame(new_shape)&&
+ OCCMap->IsBound(new_shape))|| new_shape.IsNull())
//already has a TB built on new_shape
{
//delete the second TB corresponding to old_shape
@@ -2462,8 +2464,7 @@
}
}
- OCCMap->UnBind(old_shape);
- if(!new_shape.IsNull())
+ else
OCCMap->Bind(new_shape, k);
return k;
}
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -853,25 +853,12 @@
for(Ex.Init(wire); Ex.More();Ex.Next())
{
TopoDS_Edge edge = Ex.Current();
- shape.Nullify();
shapes.Assign(op->Modified(edge));
shape.Nullify();
if (shapes.Extent() > 0)
shape = shapes.First();
else if (op->IsDeleted(edge))
- {
- int k = OCCQueryEngine::instance()->update_OCC_map(edge, shape);
- std::map<int, TopologyBridge*>::iterator it =
- OCCQueryEngine::instance()->OccToCGM->find(k);
- TopologyBridge* tb = NULL;
- if (it != OCCQueryEngine::instance()->OccToCGM->end())
- {
- OCCQueryEngine::instance()->OccToCGM->erase(k);
- tb = (*it).second;
- delete tb;
- }
- }
-
+ ;
else
continue;
@@ -879,9 +866,9 @@
{
shape.Orientation(
shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
- OCCQueryEngine::instance()->update_OCC_map(edge, shape);
}
-
+ OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
shapes.Assign(op->Modified(vertex));
@@ -892,18 +879,7 @@
OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
}
else if(op->IsDeleted(vertex))
- {
- int k = OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
- std::map<int, TopologyBridge*>::iterator it =
- OCCQueryEngine::instance()->OccToCGM->find(k);
- TopologyBridge* tb = NULL;
- if (it != OCCQueryEngine::instance()->OccToCGM->end())
- {
- OCCQueryEngine::instance()->OccToCGM->erase(k);
- tb = (*it).second;
- delete tb;
- }
- }
+ OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
}
}
return CUBIT_SUCCESS;
Modified: cgm/trunk/geom/facet/FacetBody.hpp
===================================================================
--- cgm/trunk/geom/facet/FacetBody.hpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/facet/FacetBody.hpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -191,6 +191,7 @@
virtual CubitPointContainment point_containment( const CubitVector& pos );
+ virtual CubitBoolean is_sheet_body(){return CUBIT_FALSE;}
protected:
private:
Modified: cgm/trunk/geom/virtual/CompositeBody.hpp
===================================================================
--- cgm/trunk/geom/virtual/CompositeBody.hpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/virtual/CompositeBody.hpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -78,6 +78,7 @@
void combine( CompositeBody* other );
+ CubitBoolean is_sheet_body(){return CUBIT_FALSE;}
private:
CompositeLump* firstLump;
Modified: cgm/trunk/geom/virtual/PartitionBody.hpp
===================================================================
--- cgm/trunk/geom/virtual/PartitionBody.hpp 2008-04-28 17:27:52 UTC (rev 1781)
+++ cgm/trunk/geom/virtual/PartitionBody.hpp 2008-04-28 18:09:47 UTC (rev 1782)
@@ -100,7 +100,8 @@
void transform(const CubitTransformMatrix&) {}
void get_all_children( DLIList<PartitionEntity*>& list );
-
+
+ virtual CubitBoolean is_sheet_body(){return CUBIT_FALSE;}
protected:
private:
1
0
Author: janehu
Date: 2008-04-25 14:24:47 -0500 (Fri, 25 Apr 2008)
New Revision: 1778
Modified:
cgm/trunk/geom/OCC/Makefile.am
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCCurve.cpp
cgm/trunk/geom/OCC/OCCCurve.hpp
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/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCShell.hpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Modified to delete free curves after a unite operation.
Modified: cgm/trunk/geom/OCC/Makefile.am
===================================================================
--- cgm/trunk/geom/OCC/Makefile.am 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/Makefile.am 2008-04-25 19:24:47 UTC (rev 1778)
@@ -33,6 +33,7 @@
OCCAttribSet.cpp \
OCCBody.cpp \
OCCCoEdge.cpp \
+ OCCCoFace.cpp \
OCCCurve.cpp \
OCCLoop.cpp \
OCCLump.cpp \
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -102,6 +102,7 @@
OCCBody::~OCCBody()
{
+ delete myTopoDSShape;
}
GeometryQueryEngine* OCCBody::get_geometry_query_engine() const
Modified: cgm/trunk/geom/OCC/OCCCurve.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCCurve.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -111,7 +111,7 @@
//-------------------------------------------------------------------------
OCCCurve::~OCCCurve()
{
- assert(myLoopList.size() == 0);
+ delete myTopoDSEdge;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCCurve.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCCurve.hpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCCurve.hpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -45,7 +45,7 @@
{
public :
- OCCCurve( TopoDS_Edge *theEdge );
+ OCCCurve( TopoDS_Edge* theEdge );
virtual ~OCCCurve() ;
//- The destructor
Modified: cgm/trunk/geom/OCC/OCCLoop.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCLoop.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -62,6 +62,7 @@
OCCLoop::~OCCLoop()
{
disconnect_all_curves();
+ delete myTopoDSWire;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -73,7 +73,7 @@
}
OCCLump::~OCCLump()
-{}
+{ delete myTopoDSSolid;}
//-------------------------------------------------------------------------
// Purpose : Find centroid
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -119,7 +119,6 @@
#include "AppUtil.hpp"
#include "SphereEvaluator.hpp"
#include "CylinderEvaluator.hpp"
-
OCCModifyEngine* OCCModifyEngine::instance_ = 0;
//===============================================================================
@@ -1595,6 +1594,7 @@
delete shell->my_lump();
shell->set_body(NULL);
shell->set_lump(NULL);
+
TopoDS_Shell* topods_shell = shell->get_TopoDS_Shell();
if(topods_shell)
faces_to_stitch.append(topods_shell);
@@ -1629,8 +1629,20 @@
new_shape = shapes.First();
OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
}
- //else
- // OCCSurface::update_OCC_entity(face, face, &fuser);
+ else if(fuser.IsDeleted(face))
+ {
+ TopoDS_Face null_face;
+ int k = OCCSurface::update_OCC_entity(face, null_face, &fuser);
+ std::map<int, TopologyBridge*>::iterator it =
+ OCCQueryEngine::instance()->OccToCGM->find(k);
+ TopologyBridge* tb = NULL;
+ if (it != OCCQueryEngine::instance()->OccToCGM->end())
+ {
+ OCCQueryEngine::instance()->OccToCGM->erase(k);
+ tb = (*it).second;
+ delete tb;
+ }
+ }
}
}
Modified: cgm/trunk/geom/OCC/OCCPoint.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCPoint.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -82,6 +82,7 @@
//-------------------------------------------------------------------------
OCCPoint::~OCCPoint()
{
+ delete myTopoDSVertex;
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -53,6 +53,7 @@
#include "OCCPoint.hpp"
#include "OCCCurve.hpp"
#include "OCCCoEdge.hpp"
+#include "OCCCoFace.hpp"
#include "OCCLoop.hpp"
#include "OCCSurface.hpp"
#include "OCCShell.hpp"
@@ -1212,14 +1213,22 @@
}
TopExp_Explorer Ex;
+ DLIList<OCCCoFace*> cofaces;
for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
{
+ TopoDS_Face topo_face = TopoDS::Face(Ex.Current());
Surface* face =
- populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
+ populate_topology_bridge(topo_face, build_body);
+
+ OCCSurface *occ_surface = CAST_TO(face, OCCSurface);
+ OCCCoFace * coface = new OCCCoFace( occ_surface, shell,
+ ( topo_face.Orientation()== TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
+ cofaces.append(coface);
+
if(standalone)
- CAST_TO(face,OCCSurface)->set_shell(shell);
+ occ_surface->set_shell(shell);
}
-
+ shell->cofaces(cofaces);
return shell;
}
@@ -2429,14 +2438,33 @@
return CUBIT_FALSE;
}
-void OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape,
+int OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape,
TopoDS_Shape new_shape)
{
if (!OCCMap->IsBound(old_shape))
- return;
+ return -1;
+
int k = OCCMap->Find(old_shape);
assert (k > 0 && k <= iTotalTBCreated);
+
+ if (!new_shape.IsNull() && !old_shape.IsSame(new_shape)&&
+ OCCMap->IsBound(new_shape))
+ //already has a TB built on new_shape
+ {
+ //delete the second TB corresponding to old_shape
+ std::map<int, TopologyBridge*>::iterator it = OccToCGM->find(k);
+ TopologyBridge* tb = NULL;
+ if (it != OccToCGM->end())
+ {
+ OccToCGM->erase(k);
+ tb = (*it).second;
+ delete tb;
+ }
+ }
+
OCCMap->UnBind(old_shape);
- OCCMap->Bind(new_shape, k);
+ if(!new_shape.IsNull())
+ OCCMap->Bind(new_shape, k);
+ return k;
}
//EOF
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -110,7 +110,7 @@
//- Singleton pattern
//- Controlled access and creation of the sole instance of this class.
- void update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
+ int update_OCC_map(TopoDS_Shape old_shape, TopoDS_Shape new_shape);
virtual ~OCCQueryEngine();
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -70,8 +70,14 @@
//-------------------------------------------------------------------------
OCCShell::~OCCShell()
{
+ delete myTopoDSShell;
}
+OCCCoFace* OCCShell::remove_coface(OCCCoFace *coface)
+{
+ return myCoFaceList.remove(coface);
+}
+
void OCCShell::set_TopoDS_Shell(TopoDS_Shell shell)
{
if (!myTopoDSShell)
Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCShell.hpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -31,7 +31,7 @@
class OCCLump;
class OCCSurface;
class OCCLoop;
-class OCCCoEdge;
+class OCCCoFace;
class OCCCurve;
class OCCPoint;
class BRepBuilderAPI_Transform;
@@ -48,6 +48,11 @@
virtual ~OCCShell() ;
//- Destructor.
+ void cofaces(DLIList<OCCCoFace *> cofaces) {myCoFaceList = cofaces;}
+
+ DLIList<OCCCoFace*> cofaces() {return myCoFaceList;}
+
+ OCCCoFace* remove_coface(OCCCoFace *coface);
TopoDS_Shell* get_TopoDS_Shell() {return myTopoDSShell;}
void set_TopoDS_Shell(TopoDS_Shell shell);
@@ -120,6 +125,7 @@
OCCSurface* mySheetSurface;
OCCLump* myLump;
OCCBody* myBody;
+ DLIList<OCCCoFace *> myCoFaceList;
};
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-24 19:55:06 UTC (rev 1777)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-25 19:24:47 UTC (rev 1778)
@@ -94,6 +94,7 @@
OCCSurface::~OCCSurface()
{
+ delete myTopoDSFace;
}
@@ -774,7 +775,6 @@
assert(aBRepTrsf != NULL || op != NULL);
TopoDS_Shape shape;
- CubitBoolean need_update = CUBIT_TRUE;
if (aBRepTrsf)
shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face());
else
@@ -828,47 +828,82 @@
TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
int ii;
+ TopTools_ListOfShape shapes;
+
for (ii=1; ii<=M.Extent(); ii++) {
- TopoDS_Wire wire = TopoDS::Wire(M(ii));
- TopTools_ListOfShape shapes;
- shapes.Assign(op->Modified(wire));
- if (shapes.Extent() > 0)
- shape = shapes.First();
- else
+ TopoDS_Wire wire = TopoDS::Wire(M(ii));
+
+ if(!new_surface.IsNull())
{
- TopTools_IndexedMapOfShape M_new;
- TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
- shape = M_new(ii);
- }
+ TopTools_ListOfShape shapes;
+ shapes.Assign(op->Modified(wire));
+ if (shapes.Extent() > 0)
+ shape = shapes.First();
+ else
+ {
+ TopTools_IndexedMapOfShape M_new;
+ TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
+ shape = M_new(ii);
+ }
- OCCQueryEngine::instance()->update_OCC_map(wire, shape);
-
+ OCCQueryEngine::instance()->update_OCC_map(wire, shape);
+ }
//set curves
- CubitBoolean need_update = CUBIT_TRUE;
BRepTools_WireExplorer Ex;
for(Ex.Init(wire); Ex.More();Ex.Next())
{
TopoDS_Edge edge = Ex.Current();
+ shape.Nullify();
shapes.Assign(op->Modified(edge));
+ shape.Nullify();
if (shapes.Extent() > 0)
shape = shapes.First();
- else
+ else if (op->IsDeleted(edge))
+ {
+ int k = OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+ std::map<int, TopologyBridge*>::iterator it =
+ OCCQueryEngine::instance()->OccToCGM->find(k);
+ TopologyBridge* tb = NULL;
+ if (it != OCCQueryEngine::instance()->OccToCGM->end())
+ {
+ OCCQueryEngine::instance()->OccToCGM->erase(k);
+ tb = (*it).second;
+ delete tb;
+ }
+ }
+
+ else
continue;
- if(wire.Orientation() == TopAbs_REVERSED)
+ if(wire.Orientation() == TopAbs_REVERSED && !shape.IsNull())
+ {
shape.Orientation(
shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
- OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+ OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+ }
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
shapes.Assign(op->Modified(vertex));
- need_update = CUBIT_TRUE;
+ shape.Nullify();
if (shapes.Extent() > 0)
{
shape = shapes.First();
OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
}
+ else if(op->IsDeleted(vertex))
+ {
+ int k = OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
+ std::map<int, TopologyBridge*>::iterator it =
+ OCCQueryEngine::instance()->OccToCGM->find(k);
+ TopologyBridge* tb = NULL;
+ if (it != OCCQueryEngine::instance()->OccToCGM->end())
+ {
+ OCCQueryEngine::instance()->OccToCGM->erase(k);
+ tb = (*it).second;
+ delete tb;
+ }
+ }
}
}
return CUBIT_SUCCESS;
1
0
Author: janehu
Date: 2008-04-24 14:55:06 -0500 (Thu, 24 Apr 2008)
New Revision: 1777
Modified:
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
bug fixed in unite surfaces or build solid out of surfaces, after it's done, there are still some free ref_edges and refvertices left, debugging on it.
Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp 2008-04-24 18:08:03 UTC (rev 1776)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2008-04-24 19:55:06 UTC (rev 1777)
@@ -182,6 +182,8 @@
return (OCCSurface*) NULL;}
void set_sheet_surface(OCCSurface* surface);
+ virtual CubitBoolean is_sheet_body(){return IsSheetBody;}
+
protected:
private:
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-24 18:08:03 UTC (rev 1776)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-24 19:55:06 UTC (rev 1777)
@@ -1515,6 +1515,7 @@
DLIList<BodySM*>& surf_bodies,
BodySM*& new_body) const
{
+ new_body = NULL;
if (surf_bodies.size()==0)
return CUBIT_SUCCESS;
@@ -1563,64 +1564,77 @@
if (surf_bodies.size() < 2)
return CUBIT_SUCCESS;
- DLIList<TopoDS_Face*> faces_to_stitch;
- DLIList<OCCSurface*> surfaces;
+ DLIList<TopoDS_Shape*> faces_to_stitch;
for (int i = 0; i < surf_bodies.size(); i++)
{
BodySM * tool_body = surf_bodies.get_and_step();
OCCBody* occ_body = CAST_TO(tool_body, OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
OCCShell* shell = occ_body->shell();
- if (surface == NULL)
+ if (surface == NULL && shell == NULL)
{
PRINT_ERROR("Can't stitch non-sheet bodySM's. \n");
return CUBIT_FAILURE;
}
- surfaces.append(surface);
delete occ_body;
- delete surface->my_shell();
- delete surface->my_lump();
- surface->set_shell(NULL);
- surface->set_lump(NULL);
- surface->set_body(NULL);
- TopoDS_Face* topods_face = surface->get_TopoDS_Face();
- if (topods_face != NULL)
- faces_to_stitch.append(topods_face);
+ if (surface)
+ {
+ delete surface->my_shell();
+ delete surface->my_lump();
+ surface->set_shell(NULL);
+ surface->set_lump(NULL);
+ surface->set_body(NULL);
+
+ TopoDS_Face* topods_face = surface->get_TopoDS_Face();
+ if (topods_face != NULL)
+ faces_to_stitch.append(topods_face);
+ }
+ else
+ {
+ delete shell->my_lump();
+ shell->set_body(NULL);
+ shell->set_lump(NULL);
+ TopoDS_Shell* topods_shell = shell->get_TopoDS_Shell();
+ if(topods_shell)
+ faces_to_stitch.append(topods_shell);
+ }
}
faces_to_stitch.reset();
surf_bodies.reset();
TopoDS_Shape* first_face = faces_to_stitch.pop();
- TopoDS_Face* second_face = NULL;
+ TopoDS_Shape* second_face = NULL;
for( int i = faces_to_stitch.size()-1; i >= 0; i --)
{
second_face = faces_to_stitch[i];
BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
- OCCSurface* surface = surfaces[i];
- surface->update_OCC_entity(NULL, &fuser);
+
TopoDS_Shape new_shape ;
- TopTools_IndexedMapOfShape M;
- TopExp::MapShapes(*first_face, TopAbs_FACE, M);
- for(int ii=1; ii<=M.Extent(); ii++)
+ for(int j = 0; j < 2; j++)
{
- TopoDS_Face face = TopoDS::Face(M(ii));
- TopTools_ListOfShape shapes;
- shapes.Assign(fuser.Modified(face));
- if (shapes.Extent() > 0)
- {
- new_shape = shapes.First();
- OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
+ TopTools_IndexedMapOfShape M;
+ if(j == 0)
+ TopExp::MapShapes(*second_face, TopAbs_FACE, M);
+ else
+ TopExp::MapShapes(*first_face, TopAbs_FACE, M);
+ for(int ii=1; ii<=M.Extent(); ii++)
+ {
+ TopoDS_Face face = TopoDS::Face(M(ii));
+ TopTools_ListOfShape shapes;
+ shapes.Assign(fuser.Modified(face));
+ if (shapes.Extent() > 0)
+ {
+ new_shape = shapes.First();
+ OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
+ }
+ //else
+ // OCCSurface::update_OCC_entity(face, face, &fuser);
}
- else
- OCCSurface::update_OCC_entity(face, face, &fuser);
- }
+ }
+
fuse = fuser.Shape();
- TopExp_Explorer Ex_edge;
- TopoDS_Edge edge;
- for (Ex_edge.Init(fuse,TopAbs_EDGE); Ex_edge.More(); Ex_edge.Next())
- edge = TopoDS::Edge(Ex_edge.Current());
first_face = &fuse;
}
@@ -2355,11 +2369,6 @@
CubitStatus success = CUBIT_SUCCESS;
OCCBody* occ_body = NULL;
DLIList<TopoDS_Shape*> shape_list;
- // pass in keep_old to the delete_owner_attrib flag; if we're not keeping
- // old bodies, we want to keep the owner attrib, so we can pick up entities
- // that didn't change
- bool delete_attribs =
- (GeometryModifyTool::instance()->get_new_ids() || keep_old);
for(int i = 0; i <from_body_list.size(); i++)
{
@@ -3037,43 +3046,11 @@
{
//keep_old and heal are ignored, always delete old.
//all surfaces should be stand along surface bodies or shell bodies' surface
- DLIList<BodySM*> body_list;
- for(int i = 0; i < ref_face_list.size(); i++)
- {
- OCCSurface* occ_surface = CAST_TO(ref_face_list.get_and_step(), OCCSurface);
- if (occ_surface == NULL)
- {
- PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
- "Possible incompatible geometry engines.\n");
- return CUBIT_FAILURE;
- }
- OCCBody* occ_body = occ_surface->my_body();
- if(occ_body && occ_body->my_sheet_surface() == NULL)
- {
- PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
- "The surfaces are not free.\n");
- return CUBIT_FAILURE;
- }
- else if(!occ_body)
- {
- OCCShell* shell = occ_surface->my_shell();
- if(!shell)
- {
- PRINT_ERROR("This is a bug, please report it. \n");
- return CUBIT_FAILURE;
- }
- occ_body = shell->my_body();
- }
- body_list.append_unique(occ_body);
- }
-
- BodySM* new_body = NULL;
- CubitStatus stat = stitch_surfs(body_list,new_body);
- if (!new_body)
- new_bodies = body_list;
- else
- new_bodies.append(new_body);
+ Lump* lump = make_Lump(ref_face_list);
+ if (!lump)
+ return CUBIT_FAILURE;
+ new_bodies.append(CAST_TO(lump, OCCLump)->get_body());
return CUBIT_SUCCESS;
}
1
0
Author: janehu
Date: 2008-04-22 14:30:00 -0500 (Tue, 22 Apr 2008)
New Revision: 1773
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
Log:
worked on interface of stitch_surf into a shell body or into a solid body.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-21 19:49:42 UTC (rev 1772)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-22 19:30:00 UTC (rev 1773)
@@ -1016,7 +1016,7 @@
if (surface_list.size() < 2)
return (Lump*) NULL;
- //all surfaces should be stand along surface bodies
+ //all surfaces should be stand along surface bodies or shell bodies' surface
DLIList<BodySM*> body_list;
for(int i = 0; i < surface_list.size(); i++)
{
@@ -1028,18 +1028,33 @@
return (Lump *)NULL;
}
OCCBody* occ_body = occ_surface->my_body();
- if(occ_body->my_sheet_surface() == NULL)
+ if(occ_body && occ_body->my_sheet_surface() == NULL)
{
PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
"The surfaces are not free.\n");
- return (Lump *)NULL;
+ return (Lump *)NULL;
}
- body_list.append(occ_body);
+ else if(!occ_body)
+ {
+ OCCShell* shell = occ_surface->my_shell();
+ if(!shell)
+ {
+ PRINT_ERROR("This is a bug, please report it. \n");
+ return (Lump*)NULL;
+ }
+ occ_body = shell->my_body();
+ }
+ body_list.append_unique(occ_body);
}
TopoDS_Shape aShape;
CubitStatus stat = stitch_surfs(body_list, aShape);
-
+ if(!stat)
+ {
+ PRINT_ERROR("The surfaces are not all connected, can't make a lump. \n");
+ return (Lump*)NULL;
+ }
+
TopExp_Explorer Ex, Ex2;
TopoDS_Shell aShell ;
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More()&& stat; Ex.Next())
@@ -1052,7 +1067,7 @@
{
TopoDS_Edge edge1 = TopoDS::Edge(Ex.Current());
num_edges++;
- for (Ex2.Init(aShell, TopAbs_EDGE); Ex2.More()&& stat; Ex2.Next())
+ for (Ex2.Init(aShell, TopAbs_EDGE); Ex2.More(); Ex2.Next())
{
TopoDS_Edge edge2 = TopoDS::Edge(Ex2.Current());
if (!edge1.IsEqual(edge2)&& edge1.IsSame(edge2))
@@ -1080,9 +1095,6 @@
TopoDS_Solid aSolid = aMakeSolid.Solid();
- int num_edge = 0;
- for (Ex.Init(aSolid, TopAbs_EDGE); Ex.More()&& stat; Ex.Next())
- num_edge++;
return
OCCQueryEngine::instance()->populate_topology_bridge(aSolid, CUBIT_TRUE);
}
@@ -1163,26 +1175,10 @@
}
TopoDS_Solid* solid = occ_lump->get_TopoDS_Solid();
B.Add(CS, *solid);
-
- BodySM* bodysm_ptr = occ_lump->get_body();
- if(bodysm_ptr == NULL)
- continue;
-
- bodysm_list.append_unique(bodysm_ptr);
}
BodySM* bodysm = OCCQueryEngine::instance()->populate_topology_bridge(CS);
- if(bodysm)
- {
- //remove each Lump's body from the BodyList
- for(int i = 0; i < bodysm_list.size(); i++)
- {
- BodySM* bodysm_ptr = bodysm_list.get_and_step();
-
- OCCQueryEngine::instance()->unhook_BodySM_from_OCC(bodysm_ptr);
- }
- }
return bodysm;
}
@@ -1517,34 +1513,36 @@
//===============================================================================
CubitStatus OCCModifyEngine::stitch_surfs(
DLIList<BodySM*>& surf_bodies,
- BodySM*& stitched_body) const
+ BodySM*& new_body) const
{
- stitched_body = NULL;
if (surf_bodies.size()==0)
return CUBIT_SUCCESS;
if (surf_bodies.size()==1)
{
- stitched_body = surf_bodies.get();
+ new_body = surf_bodies.get();
return CUBIT_SUCCESS;
}
TopoDS_Shape fuse;
CubitStatus stat = stitch_surfs(surf_bodies, fuse);
- if (stat == CUBIT_FAILURE)
- return stat;
-
+
DLIList<TopologyBridge*> tbs = OCCQueryEngine::instance()->
populate_topology_bridge(fuse);
- OCCBody* body = CAST_TO(tbs.get(), OCCBody);
- if (body)
- stitched_body = body ;
+ if (stat)
+ {
+ OCCBody* body = CAST_TO(tbs.get(), OCCBody);
+
+ if (body)
+ new_body = body ;
+ }
+
else
{
- OCCSurface* face = CAST_TO(tbs.get(), OCCSurface);
- if(face)
- stitched_body = face->my_body();
+ surf_bodies.clean_out();
+ for(int i= 0; i<tbs.size(); i++)
+ surf_bodies.append(CAST_TO(tbs.get_and_step(), OCCBody));
}
return CUBIT_SUCCESS;
@@ -1566,16 +1564,26 @@
return CUBIT_SUCCESS;
DLIList<TopoDS_Face*> faces_to_stitch;
+ DLIList<OCCSurface*> surfaces;
for (int i = 0; i < surf_bodies.size(); i++)
{
BodySM * tool_body = surf_bodies.get_and_step();
OCCBody* occ_body = CAST_TO(tool_body, OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
+ OCCShell* shell = occ_body->shell();
if (surface == NULL)
{
PRINT_ERROR("Can't stitch non-sheet bodySM's. \n");
return CUBIT_FAILURE;
}
+ surfaces.append(surface);
+
+ delete occ_body;
+ delete surface->my_shell();
+ delete surface->my_lump();
+ surface->set_shell(NULL);
+ surface->set_lump(NULL);
+ surface->set_body(NULL);
TopoDS_Face* topods_face = surface->get_TopoDS_Face();
if (topods_face != NULL)
faces_to_stitch.append(topods_face);
@@ -1590,8 +1598,8 @@
{
second_face = faces_to_stitch[i];
BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
- OCCBody* occ_body = CAST_TO(surf_bodies[i], OCCBody);
- occ_body->my_sheet_surface()->update_OCC_entity(NULL, &fuser);
+ OCCSurface* surface = surfaces[i];
+ surface->update_OCC_entity(NULL, &fuser);
TopoDS_Shape new_shape ;
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*first_face, TopAbs_FACE, M);
@@ -3018,15 +3026,54 @@
//===============================================================================
// Function : create_body_from_surfs
// Member Type: PUBLIC
-// Description:
-// Author : Steve Owen
-// Date : 9/11/03
+// Description:
+// Author : Jane Hu
+// Date : 4/22/08
//===============================================================================
CubitStatus OCCModifyEngine::create_solid_bodies_from_surfs(DLIList<Surface*> & ref_face_list,
DLIList<BodySM*>& new_bodies,
bool keep_old,
bool heal) const
{
+ //keep_old and heal are ignored, always delete old.
+ //all surfaces should be stand along surface bodies or shell bodies' surface
+ DLIList<BodySM*> body_list;
+ for(int i = 0; i < ref_face_list.size(); i++)
+ {
+ OCCSurface* occ_surface = CAST_TO(ref_face_list.get_and_step(), OCCSurface);
+ if (occ_surface == NULL)
+ {
+ PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
+ "Possible incompatible geometry engines.\n");
+ return CUBIT_FAILURE;
+ }
+ OCCBody* occ_body = occ_surface->my_body();
+ if(occ_body && occ_body->my_sheet_surface() == NULL)
+ {
+ PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
+ "The surfaces are not free.\n");
+ return CUBIT_FAILURE;
+ }
+ else if(!occ_body)
+ {
+ OCCShell* shell = occ_surface->my_shell();
+ if(!shell)
+ {
+ PRINT_ERROR("This is a bug, please report it. \n");
+ return CUBIT_FAILURE;
+ }
+ occ_body = shell->my_body();
+ }
+ body_list.append_unique(occ_body);
+ }
+
+ BodySM* new_body = NULL;
+ CubitStatus stat = stitch_surfs(body_list,new_body);
+ if (!new_body)
+ new_bodies = body_list;
+ else
+ new_bodies.append(new_body);
+
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-21 19:49:42 UTC (rev 1772)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-22 19:30:00 UTC (rev 1773)
@@ -1404,7 +1404,11 @@
{
if (remove_lower_entities)
return ( this->delete_solid_model_entities(ref_face_ptr) );
- return ( this->unhook_Surface_from_OCC(ref_face_ptr));
+ TopoDS_Face *face = NULL;
+ CubitStatus stat = this->unhook_Surface_from_OCC(ref_face_ptr, face);
+ if(stat)
+ delete face;
+ return stat;
}
// Curve
@@ -1413,7 +1417,11 @@
{
if (remove_lower_entities)
return ( this->delete_solid_model_entities(ref_edge_ptr));
- return ( this->unhook_Curve_from_OCC(ref_edge_ptr));
+ TopoDS_Edge *edge = NULL;
+ CubitStatus stat = this->unhook_Curve_from_OCC(ref_edge_ptr, edge);
+ if(stat)
+ delete edge;
+ return stat;
}
// Point
@@ -1460,30 +1468,66 @@
{
delete occ_shell->my_body();
delete occ_shell->my_lump();
- return unhook_ShellSM_from_OCC(occ_shell);
+ TopoDS_Shell* Shell;
+ CubitStatus stat = unhook_ShellSM_from_OCC(occ_shell,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;
+ return stat;
}
+ TopoDS_Shape* shape = NULL;
+ CubitStatus stat = unhook_BodySM_from_OCC(bodysm, shape);
+
+ DLIList<TopologyBridge*> children;
DLIList<Lump*> lumps = occ_body->lumps();
+ DLIList<TopoDS_Shell*> Shell_list;
+
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();
- unhook_Lump_from_OCC(lump);
+ if (!occ_lump)
+ continue;
+ children.clean_out();
+ occ_lump->get_children_virt(children);
+ for(int j = 0; j < children.size(); j++)
+ {
+ 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);
+ 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;
}
- return unhook_BodySM_from_OCC(bodysm);
+ if(shape)
+ delete shape;
+ return stat;
}
CubitStatus
-OCCQueryEngine::unhook_BodySM_from_OCC( BodySM* bodysm)const
+OCCQueryEngine::unhook_BodySM_from_OCC( BodySM* bodysm,
+ TopoDS_Shape*& shape)const
{
OCCBody* occ_body = dynamic_cast<OCCBody*>(bodysm);
if (!occ_body)
return CUBIT_FAILURE;
- TopoDS_Shape* shape = occ_body->get_TopoDS_Shape();
+ shape = occ_body->get_TopoDS_Shape();
if (!shape)
return CUBIT_FAILURE;
@@ -1503,15 +1547,25 @@
if(!OccToCGM->erase(k))
PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
}
- DLIList<Lump*> lumps;
- occ_body->lumps(lumps);
if (occ_body_find)
BodyList->remove(occ_body_find);
else
BodyList->remove(occ_body);
- //delete shape;
- delete shape;
+
+ 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();
+
+ TopoDS_Solid* solid;
+ unhook_Lump_from_OCC(lump, solid);
+ }
+
delete bodysm;
+ return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1524,7 +1578,7 @@
// Creation Date : 11/29/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Lump_from_OCC( Lump* lump ) const
+OCCQueryEngine::unhook_Lump_from_OCC( Lump* lump, TopoDS_Solid*& solid ) const
{
if (lump == NULL)
return CUBIT_FAILURE;
@@ -1533,7 +1587,7 @@
if (!occ_lump)
return CUBIT_FAILURE;
- TopoDS_Solid* solid = occ_lump->get_TopoDS_Solid();
+ solid = occ_lump->get_TopoDS_Solid();
if(!solid)
return CUBIT_FAILURE;
@@ -1556,11 +1610,11 @@
for(int i = 0; i < children.size(); i++)
{
ShellSM* shell = CAST_TO(children.get_and_step(), ShellSM);
- unhook_ShellSM_from_OCC(shell);
+ TopoDS_Shell* Shell;
+ unhook_ShellSM_from_OCC(shell,Shell);
}
if (occ_lump->get_body() != NULL)
BodyList->remove(CAST_TO(occ_lump->get_body(), OCCBody));
- delete solid;
delete lump;
return CUBIT_SUCCESS;
}
@@ -1575,13 +1629,14 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_ShellSM_from_OCC( ShellSM* shell ) const
+OCCQueryEngine::unhook_ShellSM_from_OCC( ShellSM* shell,
+ TopoDS_Shell*& Shell ) const
{
OCCShell* occ_shell = dynamic_cast<OCCShell*>(shell);
if (!occ_shell)
return CUBIT_FAILURE;
- TopoDS_Shell* Shell = occ_shell->get_TopoDS_Shell();
+ Shell = occ_shell->get_TopoDS_Shell();
if(!Shell)
return CUBIT_FAILURE;
@@ -1599,14 +1654,6 @@
PRINT_ERROR("The OccSurface and TopoDS_Face pair is not in the map!");
}
- DLIList<TopologyBridge*> children;
- occ_shell->get_children_virt(children);
- for(int i = 0; i < children.size(); i++)
- {
- Surface* surface = CAST_TO(children.get_and_step(), Surface);
- delete_solid_model_entities(surface);
- }
- delete Shell;
delete shell;
return CUBIT_SUCCESS;
}
@@ -1634,9 +1681,11 @@
LoopSM* loop = CAST_TO(children.get_and_step(), LoopSM);
delete_loop(loop);
}
-
- return unhook_Surface_from_OCC(surface);
-
+ TopoDS_Face* face;
+ CubitStatus stat = unhook_Surface_from_OCC(surface, face);
+ if (stat)
+ delete face;
+ return stat;
}
//-------------------------------------------------------------------------
@@ -1649,13 +1698,14 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Surface_from_OCC( Surface* surface ) const
+OCCQueryEngine::unhook_Surface_from_OCC( Surface* surface,
+ TopoDS_Face*& face ) const
{
OCCSurface* fsurf = dynamic_cast<OCCSurface*>(surface);
if (!fsurf)
return CUBIT_FAILURE;
- TopoDS_Face* face = fsurf->get_TopoDS_Face();
+ face = fsurf->get_TopoDS_Face();
if(!face)
return CUBIT_FAILURE;
@@ -1675,7 +1725,6 @@
PRINT_WARNING("The OccSurface and TopoDS_Face pair is not in the map!");
}
- delete face;
delete surface;
return CUBIT_SUCCESS;
}
@@ -1707,17 +1756,60 @@
if (occ_curve == NULL)
continue;
+ delete_solid_model_entities(curve);
+ }
+
+ TopoDS_Wire* wire;
+ CubitStatus status = unhook_LoopSM_from_OCC(loopsm, wire);
+ if (status)
+ delete wire;
+ return status;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : unhook a LoopSM from its underlining OCC entity.
+//
+// Special Notes :
+//
+// Creator : Jane Hu
+//
+// Creation Date : 12/12/07
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::unhook_LoopSM_from_OCC( LoopSM* loopsm,
+ TopoDS_Wire*& wire ) const
+{
+ OCCLoop* occ_loop = dynamic_cast<OCCLoop*>(loopsm);
+ if (!occ_loop)
+ return CUBIT_FAILURE;
+
+ wire = occ_loop->get_TopoDS_Wire();
+
+ if(!wire)
+ return CUBIT_FAILURE;
+
+ DLIList<OCCCoEdge*> children;
+ children = occ_loop->coedges();
+ int size = children.size();
+ while(size > 0)
+ {
+ OCCCoEdge* coedge = children.pop();
+ Curve* curve = coedge->curve();
+ OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
+ if (occ_curve == NULL)
+ continue;
+
DLIList<OCCLoop*> loops;
-
+
//remove all coedges corresponding to this curve from their loops.
loops = occ_curve->loops();
for(int j = 0; j < loops.size(); j++)
{
OCCLoop* occ_loop = loops.get_and_step();
- OCCCoEdge* found_coedge = occ_loop->remove_coedge(coedge);
+ OCCCoEdge* found_coedge = occ_loop->remove_coedge(coedge);
if (found_coedge)
- delete found_coedge;
+ delete found_coedge;
//there might be 2 coedges in the same loop that uses the same curve
//as in a scar curve situation
@@ -1727,40 +1819,15 @@
found_coedge = coedges.get_and_step();
if (CAST_TO(found_coedge->curve(), OCCCurve) == occ_curve)
{
- occ_loop->remove_coedge(found_coedge);
+ occ_loop->remove_coedge(found_coedge);
children.remove(found_coedge);
delete found_coedge;
}
}
}
size = children.size();
- delete_solid_model_entities(curve);
}
-
- return unhook_LoopSM_from_OCC(loopsm);
-}
-//-------------------------------------------------------------------------
-// Purpose : unhook a LoopSM from its underlining OCC entity.
-//
-// Special Notes :
-//
-// Creator : Jane Hu
-//
-// Creation Date : 12/12/07
-//-------------------------------------------------------------------------
-CubitStatus
-OCCQueryEngine::unhook_LoopSM_from_OCC( LoopSM* loopsm ) const
-{
- OCCLoop* occ_loop = dynamic_cast<OCCLoop*>(loopsm);
- if (!occ_loop)
- return CUBIT_FAILURE;
-
- TopoDS_Wire* wire = occ_loop->get_TopoDS_Wire();
-
- if(!wire)
- return CUBIT_FAILURE;
-
//remove the entry from the map
int k;
if(OCCMap->IsBound(*wire))
@@ -1775,7 +1842,6 @@
}
WireList->remove(CAST_TO(loopsm, OCCLoop));
- delete wire;
delete loopsm;
return CUBIT_SUCCESS;
}
@@ -1803,8 +1869,12 @@
Point* point = CAST_TO(children.get_and_step(), Point);
delete_solid_model_entities(point);
}
-
- return unhook_Curve_from_OCC(curve);
+
+ TopoDS_Edge* edge;
+ CubitStatus stat = unhook_Curve_from_OCC(curve, edge);
+ if (stat)
+ delete edge;
+ return stat;
}
//-------------------------------------------------------------------------
@@ -1817,14 +1887,14 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Curve_from_OCC( Curve* curve ) const
+OCCQueryEngine::unhook_Curve_from_OCC( Curve* curve, TopoDS_Edge*& edge ) const
{
OCCCurve* fcurve = dynamic_cast<OCCCurve*>(curve);
if (!fcurve )
return CUBIT_FAILURE;
fcurve->clean_loops();
- TopoDS_Edge * edge = fcurve->get_TopoDS_Edge();
+ edge = fcurve->get_TopoDS_Edge();
if (!edge)
return CUBIT_FAILURE;
@@ -1841,7 +1911,6 @@
PRINT_WARNING("The OccCurve and TopoDS_Edge pair is not in the map!");
}
- delete edge;
delete curve;
return CUBIT_SUCCESS;
}
@@ -1861,8 +1930,11 @@
if (!fpoint)
return CUBIT_FAILURE;
- return unhook_Point_from_OCC(point);
-
+ TopoDS_Vertex* vertex;
+ CubitStatus stat = unhook_Point_from_OCC(point, vertex);
+ if(stat)
+ delete vertex;
+ return stat;
}
//-------------------------------------------------------------------------
@@ -1875,13 +1947,14 @@
// Creation Date : 12/12/07
//-------------------------------------------------------------------------
CubitStatus
-OCCQueryEngine::unhook_Point_from_OCC( Point* point ) const
+OCCQueryEngine::unhook_Point_from_OCC( Point* point,
+ TopoDS_Vertex*& vertex ) const
{
OCCPoint* fpoint = dynamic_cast<OCCPoint*>(point);
if (!fpoint)
return CUBIT_FAILURE;
- TopoDS_Vertex *vertex = fpoint->get_TopoDS_Vertex();
+ vertex = fpoint->get_TopoDS_Vertex();
if (!vertex)
return CUBIT_FAILURE;
@@ -1897,7 +1970,6 @@
if(!OccToCGM->erase(k))
PRINT_ERROR("The OccPoint and TopoDS_Vertex pair is not in the map!");
}
- delete vertex;
delete point;
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-21 19:49:42 UTC (rev 1772)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-22 19:30:00 UTC (rev 1773)
@@ -248,7 +248,14 @@
CubitBoolean import_vertices = CUBIT_TRUE,
CubitBoolean free_surfaces = CUBIT_TRUE );
- CubitStatus unhook_BodySM_from_OCC( BodySM* bodysm)const;
+ 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;
private:
CubitStatus import_solid_model(FILE *file_ptr,
@@ -263,12 +270,11 @@
CubitBoolean import_vertices = CUBIT_TRUE,
CubitBoolean free_surfaces = CUBIT_TRUE);
- 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 unhook_Surface_from_OCC( Surface* surface ) const;
- CubitStatus unhook_Curve_from_OCC( Curve* curve ) const;
- CubitStatus unhook_Point_from_OCC( Point* point ) const;
+ 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 delete_loop( LoopSM* loopsm)const;
public:
virtual void delete_solid_model_entities(DLIList<BodySM*>& body_list) const;
1
0
Author: janehu
Date: 2008-04-21 14:49:42 -0500 (Mon, 21 Apr 2008)
New Revision: 1772
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
Solved the stitched shell unclosed issue: we have to check the closed status, and set up the flag. some other make_Lump changes.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-18 19:20:39 UTC (rev 1771)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-21 19:49:42 UTC (rev 1772)
@@ -1040,14 +1040,34 @@
TopoDS_Shape aShape;
CubitStatus stat = stitch_surfs(body_list, aShape);
- TopExp_Explorer Ex;
+ TopExp_Explorer Ex, Ex2;
TopoDS_Shell aShell ;
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More()&& stat; Ex.Next())
aShell = TopoDS::Shell(Ex.Current());
- int num_edge = 0;
+ //check to make sure the aShell is closed.
+ int num_edges = 0;
+ int pairs = 0;
for (Ex.Init(aShell, TopAbs_EDGE); Ex.More()&& stat; Ex.Next())
- num_edge++;
+ {
+ TopoDS_Edge edge1 = TopoDS::Edge(Ex.Current());
+ num_edges++;
+ for (Ex2.Init(aShell, TopAbs_EDGE); Ex2.More()&& stat; Ex2.Next())
+ {
+ TopoDS_Edge edge2 = TopoDS::Edge(Ex2.Current());
+ if (!edge1.IsEqual(edge2)&& edge1.IsSame(edge2))
+ {
+ pairs++;
+ break;
+ }
+ }
+ }
+ if (num_edges == pairs)
+ aShell.Closed(CUBIT_TRUE);
+
+ else
+ PRINT_ERROR("Surfaces must make a water-tight shape to make a lump.\n");
+
if(aShell.Closed())
{
BRepBuilderAPI_MakeSolid aMakeSolid(aShell);
@@ -1111,6 +1131,18 @@
if (lump_list.size() == 0)
return (BodySM*) NULL;
+ //make sure the lumps in lump_list don't attached to any Bodies.
+ for (int i = 0; i < lump_list.size(); i++)
+ {
+ Lump* lump = lump_list.get_and_step();
+ BodySM* body = CAST_TO(lump, OCCLump)->get_body();
+ if (body)
+ {
+ if (lump_list.size()>1)
+ PRINT_ERROR("the lump_list should be free to bodysm's to make a new bodysm.\n");
+ return body;
+ }
+ }
//Create a compsolid shape, save all BodySM's correponding to lump_list
//for deletion.
DLIList<BodySM*> bodysm_list;
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-18 19:20:39 UTC (rev 1771)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-21 19:49:42 UTC (rev 1772)
@@ -784,13 +784,13 @@
if (shapes.Extent() > 0)
shape = shapes.First();
else
- need_update = CUBIT_FALSE;
+ return CUBIT_SUCCESS;
}
TopoDS_Face surface;
surface = TopoDS::Face(shape);
- if (aBRepTrsf && need_update)
+ if (aBRepTrsf)
{
OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
@@ -805,13 +805,9 @@
set_TopoDS_Face(surface);
}
- else if(op && need_update)
+ else if(op)
update_OCC_entity(*myTopoDSFace, surface, op);
- else
- update_OCC_entity(*myTopoDSFace, *myTopoDSFace, op); //underling curves may
- //need update
-
return CUBIT_SUCCESS;
}
@@ -859,6 +855,9 @@
else
continue;
+ if(wire.Orientation() == TopAbs_REVERSED)
+ shape.Orientation(
+ shape.Orientation()==TopAbs_FORWARD? TopAbs_REVERSED:TopAbs_FORWARD);
OCCQueryEngine::instance()->update_OCC_map(edge, shape);
//update vertex
1
0
Author: janehu
Date: 2008-04-18 14:20:39 -0500 (Fri, 18 Apr 2008)
New Revision: 1771
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
Log:
make_Lump failed because it doesn't consider the shell with 6 faces a closed shell, debugging on it.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-17 20:12:35 UTC (rev 1770)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-18 19:20:39 UTC (rev 1771)
@@ -1045,7 +1045,10 @@
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More()&& stat; Ex.Next())
aShell = TopoDS::Shell(Ex.Current());
- if(aShell.Closed(CUBIT_TRUE))
+ int num_edge = 0;
+ for (Ex.Init(aShell, TopAbs_EDGE); Ex.More()&& stat; Ex.Next())
+ num_edge++;
+ if(aShell.Closed())
{
BRepBuilderAPI_MakeSolid aMakeSolid(aShell);
if (!aMakeSolid.IsDone())
@@ -1057,6 +1060,9 @@
TopoDS_Solid aSolid = aMakeSolid.Solid();
+ int num_edge = 0;
+ for (Ex.Init(aSolid, TopAbs_EDGE); Ex.More()&& stat; Ex.Next())
+ num_edge++;
return
OCCQueryEngine::instance()->populate_topology_bridge(aSolid, CUBIT_TRUE);
}
@@ -1571,18 +1577,19 @@
OCCSurface::update_OCC_entity(face, face, &fuser);
}
fuse = fuser.Shape();
+ TopExp_Explorer Ex_edge;
+ TopoDS_Edge edge;
+ for (Ex_edge.Init(fuse,TopAbs_EDGE); Ex_edge.More(); Ex_edge.Next())
+ edge = TopoDS::Edge(Ex_edge.Current());
first_face = &fuse;
}
TopExp_Explorer Ex;
- int count_face = 0;
int count_shell = 0;
- for (Ex.Init(fuse, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
- count_face++;
for (Ex.Init(fuse, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
count_shell++;
- if (count_face != 1 && count_shell != 1)
+ if ( count_shell != 1)
{
PRINT_ERROR("Can't stitch all surfaces into one BodySM's. \n");
return CUBIT_FAILURE;
@@ -1642,6 +1649,15 @@
}
TopoDS_Solid* solid = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid();
+ TopExp_Explorer Ex_edge;
+ TopoDS_Edge edge;
+ int num_edge = 0;
+ for (Ex_edge.Init(*solid,TopAbs_EDGE); Ex_edge.More(); Ex_edge.Next())
+ {
+ edge = TopoDS::Edge(Ex_edge.Current());
+ num_edge++;
+ }
+
BRepBuilderAPI_Copy api_copy(*solid);
TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
TopoDS_Shape* newShape_ptr = new TopoDS_Shape(newShape);
1
0
Author: janehu
Date: 2008-04-17 15:12:35 -0500 (Thu, 17 Apr 2008)
New Revision: 1770
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
Log:
fine tuned the stitch_surfs function, makes a seperate call to stitch surfaces into a TopoDS_Shape, share this call with make_Lump in ModifyEngine. There's a global CurveList need to be updated.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-16 20:19:10 UTC (rev 1769)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-17 20:12:35 UTC (rev 1770)
@@ -1013,62 +1013,40 @@
//===============================================================================
Lump* OCCModifyEngine::make_Lump( DLIList<Surface*>& surface_list ) const
{
- if (surface_list.size() == 0)
+ if (surface_list.size() < 2)
return (Lump*) NULL;
- Surface* surface = surface_list.get();
- OCCSurface* occ_surface = CAST_TO(surface, OCCSurface);
- if(!occ_surface)
+ //all surfaces should be stand along surface bodies
+ DLIList<BodySM*> body_list;
+ for(int i = 0; i < surface_list.size(); i++)
{
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
+ OCCSurface* occ_surface = CAST_TO(surface_list.get_and_step(), OCCSurface);
+ if (occ_surface == NULL)
+ {
+ PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
"Possible incompatible geometry engines.\n");
- return (Lump *)NULL;
+ return (Lump *)NULL;
+ }
+ OCCBody* occ_body = occ_surface->my_body();
+ if(occ_body->my_sheet_surface() == NULL)
+ {
+ PRINT_ERROR("Cannot create an OCC lump from the given surfaces.\n"
+ "The surfaces are not free.\n");
+ return (Lump *)NULL;
+ }
+ body_list.append(occ_body);
}
- TopoDS_Face* face_ptr = occ_surface->get_TopoDS_Face();
- for(int i = 1; i < surface_list.size(); i++)
- {
- Surface* surface = surface_list.step_and_get();
- OCCSurface* occ_surface = CAST_TO(surface, OCCSurface);
- if(!occ_surface)
- {
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
- "Possible incompatible geometry engines.\n");
- return (Lump *)NULL;
- }
- TopoDS_Face* face2_ptr = occ_surface->get_TopoDS_Face();
-
- BRepAlgoAPI_Fuse aFuse(*face_ptr, *face2_ptr);
- if(aFuse.ErrorStatus() == 1) //The Object is created but Nothing is Done
- {
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
- "Check surface connectivities.\n");
- return (Lump *)NULL;
- }
- else if (aFuse.ErrorStatus() != 0)
- {
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
- "OCC internal error.\n");
- return (Lump *)NULL;
- }
-
- TopTools_ListOfShape shapes;
- shapes.Assign( aFuse.Modified(*face_ptr));
- face_ptr = & (TopoDS::Face(shapes.First()));
- }
+ TopoDS_Shape aShape;
+ CubitStatus stat = stitch_surfs(body_list, aShape);
- Handle_Geom_Surface HGeom_surface = BRep_Tool::Surface(*face_ptr);
- BRepBuilderAPI_MakeShell aMakeShell(HGeom_surface);
- if(!aMakeShell.IsDone())
+ TopExp_Explorer Ex;
+ TopoDS_Shell aShell ;
+ for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More()&& stat; Ex.Next())
+ aShell = TopoDS::Shell(Ex.Current());
+
+ if(aShell.Closed(CUBIT_TRUE))
{
- PRINT_ERROR("Cannot create an OCC Lump from the given surfaces.\n"
- "OCC internal error.\n");
- return (Lump *)NULL;
- }
-
- TopoDS_Shell aShell = aMakeShell.Shell();
- if(aShell.Closed())
- {
BRepBuilderAPI_MakeSolid aMakeSolid(aShell);
if (!aMakeSolid.IsDone())
{
@@ -1082,9 +1060,8 @@
return
OCCQueryEngine::instance()->populate_topology_bridge(aSolid, CUBIT_TRUE);
}
- OCCShell* occ_shell =
- OCCQueryEngine::instance()->populate_topology_bridge(aShell, CUBIT_TRUE);
- return occ_shell->my_lump();
+
+ return (Lump*) NULL;
}
//===============================================================================
@@ -1514,6 +1491,42 @@
return CUBIT_SUCCESS;
}
+ TopoDS_Shape fuse;
+ CubitStatus stat = stitch_surfs(surf_bodies, fuse);
+ if (stat == CUBIT_FAILURE)
+ return stat;
+
+ DLIList<TopologyBridge*> tbs = OCCQueryEngine::instance()->
+ populate_topology_bridge(fuse);
+ OCCBody* body = CAST_TO(tbs.get(), OCCBody);
+ if (body)
+ stitched_body = body ;
+
+ else
+ {
+ OCCSurface* face = CAST_TO(tbs.get(), OCCSurface);
+ if(face)
+ stitched_body = face->my_body();
+ }
+
+ return CUBIT_SUCCESS;
+}
+
+//===============================================================================
+// Function : stitch_surfs
+// Member Type: PUBLIC
+// Description: stitch all surfs and try to make a TopoDS_Shell .
+// called by stitch into surface body
+// Author : Jane Hu
+// Date : 03/08
+//===============================================================================
+CubitStatus OCCModifyEngine::stitch_surfs(
+ DLIList<BodySM*>& surf_bodies,
+ TopoDS_Shape& fuse) const
+{
+ if (surf_bodies.size() < 2)
+ return CUBIT_SUCCESS;
+
DLIList<TopoDS_Face*> faces_to_stitch;
for (int i = 0; i < surf_bodies.size(); i++)
{
@@ -1524,7 +1537,7 @@
{
PRINT_ERROR("Can't stitch non-sheet bodySM's. \n");
return CUBIT_FAILURE;
- }
+ }
TopoDS_Face* topods_face = surface->get_TopoDS_Face();
if (topods_face != NULL)
faces_to_stitch.append(topods_face);
@@ -1535,12 +1548,10 @@
TopoDS_Shape* first_face = faces_to_stitch.pop();
TopoDS_Face* second_face = NULL;
- TopoDS_Shape fuse;
for( int i = faces_to_stitch.size()-1; i >= 0; i --)
{
second_face = faces_to_stitch[i];
BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
- fuse = fuser.Shape();
OCCBody* occ_body = CAST_TO(surf_bodies[i], OCCBody);
occ_body->my_sheet_surface()->update_OCC_entity(NULL, &fuser);
TopoDS_Shape new_shape ;
@@ -1548,7 +1559,7 @@
TopExp::MapShapes(*first_face, TopAbs_FACE, M);
for(int ii=1; ii<=M.Extent(); ii++)
{
- TopoDS_Face face = TopoDS::Face(M(ii));
+ TopoDS_Face face = TopoDS::Face(M(ii));
TopTools_ListOfShape shapes;
shapes.Assign(fuser.Modified(face));
if (shapes.Extent() > 0)
@@ -1556,7 +1567,10 @@
new_shape = shapes.First();
OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
}
+ else
+ OCCSurface::update_OCC_entity(face, face, &fuser);
}
+ fuse = fuser.Shape();
first_face = &fuse;
}
@@ -1573,21 +1587,7 @@
PRINT_ERROR("Can't stitch all surfaces into one BodySM's. \n");
return CUBIT_FAILURE;
}
-
- DLIList<TopologyBridge*> tbs = OCCQueryEngine::instance()->
- populate_topology_bridge(fuse);
- OCCBody* body = CAST_TO(tbs.get(), OCCBody);
- if (body)
- stitched_body = body ;
-
- else
- {
- OCCSurface* face = CAST_TO(tbs.get(), OCCSurface);
- if(face)
- stitched_body = face->my_body();
- }
-
- return CUBIT_SUCCESS;
+ return CUBIT_SUCCESS;
}
//===============================================================================
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-04-16 20:19:10 UTC (rev 1769)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-04-17 20:12:35 UTC (rev 1770)
@@ -664,6 +664,9 @@
CubitStatus sort_curves(DLIList<Curve*> curve_list,
DLIList<DLIList<TopoDS_Edge*>*>& topo_edges_loops)const;
+
+ CubitStatus stitch_surfs(DLIList<BodySM*>& surf_bodies,
+ TopoDS_Shape& stitched_shape) const;
private:
int check_intersection(DLIList<TopoDS_Edge*>* edge_list,
TopoDS_Face from_face)const;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-16 20:19:10 UTC (rev 1769)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-17 20:12:35 UTC (rev 1770)
@@ -2360,6 +2360,8 @@
void OCCQueryEngine::update_OCC_map(TopoDS_Shape old_shape,
TopoDS_Shape new_shape)
{
+ if (!OCCMap->IsBound(old_shape))
+ return;
int k = OCCMap->Find(old_shape);
assert (k > 0 && k <= iTotalTBCreated);
OCCMap->UnBind(old_shape);
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-16 20:19:10 UTC (rev 1769)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-17 20:12:35 UTC (rev 1770)
@@ -774,6 +774,7 @@
assert(aBRepTrsf != NULL || op != NULL);
TopoDS_Shape shape;
+ CubitBoolean need_update = CUBIT_TRUE;
if (aBRepTrsf)
shape = aBRepTrsf->ModifiedShape(*get_TopoDS_Face());
else
@@ -783,13 +784,13 @@
if (shapes.Extent() > 0)
shape = shapes.First();
else
- return CUBIT_SUCCESS;
+ need_update = CUBIT_FALSE;
}
TopoDS_Face surface;
surface = TopoDS::Face(shape);
- if (aBRepTrsf)
+ if (aBRepTrsf && need_update)
{
OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
@@ -804,9 +805,13 @@
set_TopoDS_Face(surface);
}
- else
+ else if(op && need_update)
update_OCC_entity(*myTopoDSFace, surface, op);
+ else
+ update_OCC_entity(*myTopoDSFace, *myTopoDSFace, op); //underling curves may
+ //need update
+
return CUBIT_SUCCESS;
}
@@ -852,10 +857,9 @@
if (shapes.Extent() > 0)
shape = shapes.First();
else
- need_update = CUBIT_FALSE;
+ continue;
- if (need_update)
- OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+ OCCQueryEngine::instance()->update_OCC_map(edge, shape);
//update vertex
TopoDS_Vertex vertex = Ex.CurrentVertex();
1
0
Author: janehu
Date: 2008-04-16 15:19:10 -0500 (Wed, 16 Apr 2008)
New Revision: 1769
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.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
cgm/trunk/geom/OCC/OCCSurface.hpp
Log:
Figured out several places that need to update after a boolean operation for mapping up the surfaces and below entity, stitch_surfs now passed testing with 'owner attributes' setting up correctly.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -165,7 +165,7 @@
{
TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
aBRepTrsf.Perform(*face);
- OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+ OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
}
else if(myShell)
{
@@ -208,7 +208,7 @@
{
TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
aBRepTrsf.Perform(*face);
- OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+ OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
}
else if(myShell)
{
@@ -245,7 +245,7 @@
{
TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
aBRepTrsf.Perform(*face);
- OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+ OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
}
else if(myShell)
{
@@ -302,7 +302,7 @@
{
TopoDS_Face * face = mySheetSurface->get_TopoDS_Face();
aBRepTrsf.Perform(*face);
- OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
+ OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, &aBRepTrsf);
}
else if(myShell)
{
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -71,6 +71,7 @@
#include "Handle_Geom_RectangularTrimmedSurface.hxx"
#include "TopOpeBRep_EdgesIntersector.hxx"
#include "TopExp_Explorer.hxx"
+#include "TopExp.hxx"
#include "OCCModifyEngine.hpp"
#include "OCCQueryEngine.hpp"
#include "CubitMessage.hpp"
@@ -1540,9 +1541,23 @@
second_face = faces_to_stitch[i];
BRepAlgoAPI_Fuse fuser(*second_face, *first_face);
fuse = fuser.Shape();
- first_face = &fuse;
OCCBody* occ_body = CAST_TO(surf_bodies[i], OCCBody);
occ_body->my_sheet_surface()->update_OCC_entity(NULL, &fuser);
+ TopoDS_Shape new_shape ;
+ TopTools_IndexedMapOfShape M;
+ TopExp::MapShapes(*first_face, TopAbs_FACE, M);
+ for(int ii=1; ii<=M.Extent(); ii++)
+ {
+ TopoDS_Face face = TopoDS::Face(M(ii));
+ TopTools_ListOfShape shapes;
+ shapes.Assign(fuser.Modified(face));
+ if (shapes.Extent() > 0)
+ {
+ new_shape = shapes.First();
+ OCCSurface::update_OCC_entity(face, TopoDS::Face(new_shape), &fuser);
+ }
+ }
+ first_face = &fuse;
}
TopExp_Explorer Ex;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -28,6 +28,7 @@
#include "TColgp_Array1OfPnt.hxx"
#include "Poly_Array1OfTriangle.hxx"
#include "Poly_Triangle.hxx"
+#include "BRepAlgoAPI_BooleanOperation.hxx"
#include "Handle_Poly_Triangulation.hxx"
#include "Poly_Polygon3D.hxx"
#include "Handle_Poly_Polygon3D.hxx"
@@ -1116,22 +1117,24 @@
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)body));
BodyList->append(body);
-
- TopExp_Explorer Ex;
- DLIList<Lump*> lumps;
- for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
- {
- Lump* lump = populate_topology_bridge(TopoDS::Solid(Ex.Current()));
- lumps.append(lump);
- CAST_TO(lump, OCCLump)->add_body(body);
- }
- body->lumps(lumps);
}
else
{
int k = OCCMap->Find(*posolid);
body = (OCCBody*)(OccToCGM->find(k))->second;
+ body->set_TopoDS_Shape(*posolid);
}
+
+ TopExp_Explorer Ex;
+ DLIList<Lump*> lumps;
+ for (Ex.Init(aShape, TopAbs_SOLID); Ex.More(); Ex.Next())
+ {
+ Lump* lump = populate_topology_bridge(TopoDS::Solid(Ex.Current()));
+ lumps.append(lump);
+ CAST_TO(lump, OCCLump)->add_body(body);
+ }
+ body->lumps(lumps);
+
return body;
}
@@ -1160,16 +1163,18 @@
OCCMap->Bind(*posolid, iTotalTBCreated);
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)lump));
-
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Shell(Ex.Current()));
}
else
{
int k = OCCMap->Find(*posolid);
lump = (OCCLump*)(OccToCGM->find(k))->second;
+ lump->set_TopoDS_Solid(*posolid);
}
+
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+
return lump;
}
@@ -1198,22 +1203,23 @@
shell->set_lump(lump);
//don't need to add body into BodyList.
}
-
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
- {
- Surface* face =
- populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
- if(standalone)
- CAST_TO(face,OCCSurface)->set_shell(shell);
- }
}
else
{
int k = OCCMap->Find(*poshell);
shell = (OCCShell*)(OccToCGM->find(k))->second;
+ shell->set_TopoDS_Shell(*poshell);
}
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
+ {
+ Surface* face =
+ populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
+ if(standalone)
+ CAST_TO(face,OCCSurface)->set_shell(shell);
+ }
+
return shell;
}
@@ -1246,17 +1252,19 @@
shell->set_lump(lump);
//Doesn't need to save sheet bodies.
}
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Wire(Ex.Current()));
}
else
{
int k = OCCMap->Find(*poface);
surface = (OCCSurface*)(OccToCGM->find(k))->second;
+ surface->set_TopoDS_Face(*poface);
}
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_WIRE); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Wire(Ex.Current()));
+
return surface;
}
@@ -1277,26 +1285,27 @@
(TopologyBridge*)loop));
if(standalone)
WireList->append(loop);
-
- BRepTools_WireExplorer Ex;
- DLIList <OCCCoEdge*> coedges;
- for (Ex.Init(aShape); Ex.More(); Ex.Next())
- {
- Curve* curve = populate_topology_bridge(Ex.Current());
- OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
- OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
- (Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
- coedges.append(coedge);
- occ_curve->add_loop(loop);
- }
- loop->coedges(coedges);
}
else
{
int k = OCCMap->Find(*powire);
loop = (OCCLoop*)(OccToCGM->find(k))->second;
+ loop->set_TopoDS_Wire(*powire);
}
+ BRepTools_WireExplorer Ex;
+ DLIList <OCCCoEdge*> coedges;
+ for (Ex.Init(aShape); Ex.More(); Ex.Next())
+ {
+ Curve* curve = populate_topology_bridge(Ex.Current());
+ OCCCurve *occ_curve = CAST_TO(curve, OCCCurve);
+ OCCCoEdge * coedge = new OCCCoEdge( curve, loop,
+ (Ex.Orientation() == TopAbs_FORWARD ? CUBIT_FORWARD : CUBIT_REVERSED));
+ coedges.append(coedge);
+ occ_curve->add_loop(loop);
+ }
+ loop->coedges(coedges);
+
return loop;
}
@@ -1315,17 +1324,18 @@
OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)curve));
CurveList->append((OCCCurve*)curve);
-
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
}
else
{
int i = OCCMap->Find(*poedge);
curve = (OCCCurve*)(OccToCGM->find(i))->second;
+ CAST_TO(curve, OCCCurve)->set_TopoDS_Edge(*poedge);
}
+ TopExp_Explorer Ex;
+ for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
+ populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
+
return curve;
}
@@ -1348,6 +1358,7 @@
{
int i = OCCMap->Find(*povertex);
point = (OCCPoint*)(OccToCGM->find(i))->second;
+ point->set_TopoDS_Vertex(*povertex);
}
return point;
}
@@ -2147,34 +2158,35 @@
BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
- update_entity_shape(entity, aBRepTrsf);
+ update_entity_shape(entity, &aBRepTrsf);
return CUBIT_SUCCESS;
}
CubitStatus OCCQueryEngine::update_entity_shape(GeometryEntity* entity_ptr,
- BRepBuilderAPI_Transform& aBRepTrsf)
+ BRepBuilderAPI_Transform* aBRepTrsf,
+ BRepAlgoAPI_BooleanOperation *op)
{
if (OCCBody *body_ptr = CAST_TO( entity_ptr, OCCBody))
{
- body_ptr->update_OCC_entity(&aBRepTrsf);
+ body_ptr->update_OCC_entity(aBRepTrsf, op);
return CUBIT_SUCCESS;
}
else if( OCCSurface *surface_ptr = CAST_TO( entity_ptr, OCCSurface))
{
- surface_ptr->update_OCC_entity(&aBRepTrsf);
+ surface_ptr->update_OCC_entity(aBRepTrsf, op);
return CUBIT_SUCCESS;
}
else if( OCCCurve *curve_ptr = CAST_TO( entity_ptr, OCCCurve))
{
- curve_ptr->update_OCC_entity(&aBRepTrsf);
+ curve_ptr->update_OCC_entity(aBRepTrsf, op);
return CUBIT_SUCCESS;
}
else if( OCCPoint *point_ptr = CAST_TO( entity_ptr, OCCPoint))
{
- point_ptr->update_OCC_entity(&aBRepTrsf);
+ point_ptr->update_OCC_entity(aBRepTrsf, op);
return CUBIT_SUCCESS;
}
@@ -2203,7 +2215,7 @@
aTrsf.SetRotation(anAxis, a);
BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
- update_entity_shape(entity, aBRepTrsf);
+ update_entity_shape(entity, &aBRepTrsf);
return CUBIT_SUCCESS;
}
@@ -2221,7 +2233,7 @@
aTrsf.SetScaleFactor(f);
BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
- update_entity_shape(entity, aBRepTrsf);
+ update_entity_shape(entity, &aBRepTrsf);
return CUBIT_SUCCESS;
}
@@ -2251,7 +2263,7 @@
aTrsf.SetMirror(anAx2);
BRepBuilderAPI_Transform aBRepTrsf(*shape, aTrsf);
- update_entity_shape(entity, aBRepTrsf);
+ update_entity_shape(entity, &aBRepTrsf);
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -78,6 +78,7 @@
class BRepBuilderAPI_Transform;
class TopTools_DataMapOfShapeInteger;
+class BRepAlgoAPI_BooleanOperation;
class TopoDS_Vertex;
class TopoDS_Edge;
class TopoDS_Shape;
@@ -306,7 +307,8 @@
CubitBox& super_box );
CubitStatus update_entity_shape(GeometryEntity* entity_ptr,
- BRepBuilderAPI_Transform& aTranf);
+ BRepBuilderAPI_Transform* aTranf,
+ BRepAlgoAPI_BooleanOperation *op = NULL);
CubitStatus translate( BodySM* body, const CubitVector& offset );
CubitStatus rotate ( BodySM* body, const CubitVector& axis, double angle );
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -179,7 +179,7 @@
{
if(mySheetSurface && op == NULL)
return CUBIT_FAILURE;
-
+/*
else if(mySheetSurface && op)//stitch surface body into shell body
{
mySheetSurface->update_OCC_entity(aBRepTrsf, op);
@@ -199,6 +199,7 @@
}
return CUBIT_SUCCESS;
}
+*/
assert (aBRepTrsf != NULL || op != NULL);
TopoDS_Shape shape;
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -44,8 +44,9 @@
#include "LoopSM.hpp"
#include "CubitPointData.hpp"
#include "BRepAlgoAPI_BooleanOperation.hxx"
+#include "BRepTools_WireExplorer.hxx"
+#include "BRep_Tool.hxx"
-
// ********** END CUBIT INCLUDES **********
@@ -764,7 +765,7 @@
//----------------------------------------------------------------
// Function: to update the core Surface
-// for any movement of the body.
+// for any movement or Boolean operation of the body.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCSurface::update_OCC_entity( BRepBuilderAPI_Transform *aBRepTrsf,
@@ -788,21 +789,89 @@
TopoDS_Face surface;
surface = TopoDS::Face(shape);
- OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
+ if (aBRepTrsf)
+ {
+ OCCQueryEngine::instance()->update_OCC_map(*myTopoDSFace, surface);
- //set the loops
- DLIList<OCCLoop *> loops;
- this->get_loops(loops);
- for (int i = 1; i <= loops.size(); i++)
- {
- OCCLoop *loop = loops.get_and_step();
- loop->update_OCC_entity(aBRepTrsf, op);
+ //set the loops
+ DLIList<OCCLoop *> loops;
+ this->get_loops(loops);
+ for (int i = 1; i <= loops.size(); i++)
+ {
+ OCCLoop *loop = loops.get_and_step();
+ loop->update_OCC_entity(aBRepTrsf, op);
+ }
+ set_TopoDS_Face(surface);
}
- set_TopoDS_Face(surface);
+ else
+ update_OCC_entity(*myTopoDSFace, surface, op);
+
return CUBIT_SUCCESS;
}
+//----------------------------------------------------------------
+// Function: TopoDS_Shape level function to update the core Surface
+// for any movement or Boolean operation of the body.
+// Author: Jane Hu
+//----------------------------------------------------------------
+CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
+ TopoDS_Face& new_surface,
+ BRepAlgoAPI_BooleanOperation *op)
+{
+ OCCQueryEngine::instance()->update_OCC_map(old_surface, new_surface);
+
+ //set the Wires
+ TopTools_IndexedMapOfShape M;
+ TopoDS_Shape shape;
+ TopExp::MapShapes(old_surface, TopAbs_WIRE, M);
+ double tol = OCCQueryEngine::instance()->get_sme_resabs_tolerance();
+ int ii;
+ for (ii=1; ii<=M.Extent(); ii++) {
+ TopoDS_Wire wire = TopoDS::Wire(M(ii));
+ TopTools_ListOfShape shapes;
+ shapes.Assign(op->Modified(wire));
+ if (shapes.Extent() > 0)
+ shape = shapes.First();
+ else
+ {
+ TopTools_IndexedMapOfShape M_new;
+ TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
+ shape = M_new(ii);
+ }
+
+ OCCQueryEngine::instance()->update_OCC_map(wire, shape);
+
+ //set curves
+ CubitBoolean need_update = CUBIT_TRUE;
+ BRepTools_WireExplorer Ex;
+ for(Ex.Init(wire); Ex.More();Ex.Next())
+ {
+ TopoDS_Edge edge = Ex.Current();
+ shapes.Assign(op->Modified(edge));
+ if (shapes.Extent() > 0)
+ shape = shapes.First();
+ else
+ need_update = CUBIT_FALSE;
+
+ if (need_update)
+ OCCQueryEngine::instance()->update_OCC_map(edge, shape);
+
+ //update vertex
+ TopoDS_Vertex vertex = Ex.CurrentVertex();
+ shapes.Assign(op->Modified(vertex));
+ need_update = CUBIT_TRUE;
+ if (shapes.Extent() > 0)
+ {
+ shape = shapes.First();
+ OCCQueryEngine::instance()->update_OCC_map(vertex, shape);
+ }
+ }
+ }
+ return CUBIT_SUCCESS;
+}
+
+
// ********** END PUBLIC FUNCTIONS **********
// ********** BEGIN PROTECTED FUNCTIONS **********
Modified: cgm/trunk/geom/OCC/OCCSurface.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.hpp 2008-04-15 19:15:02 UTC (rev 1768)
+++ cgm/trunk/geom/OCC/OCCSurface.hpp 2008-04-16 20:19:10 UTC (rev 1769)
@@ -61,6 +61,11 @@
virtual ~OCCSurface() ;
//- The destructor
+ static CubitStatus update_OCC_entity(TopoDS_Face& old_surface,
+ TopoDS_Face& new_surface,
+ BRepAlgoAPI_BooleanOperation *op);
+
+
virtual void append_simple_attribute_virt(CubitSimpleAttrib*);
//R void
//I
1
0