[cgma-dev] r1649 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Thu Mar 13 14:31:27 CDT 2008
Author: janehu
Date: 2008-03-13 14:31:27 -0500 (Thu, 13 Mar 2008)
New Revision: 1649
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCShell.cpp
cgm/trunk/geom/OCC/OCCSurface.cpp
cgm/trunk/test/Makefile.am
cgm/trunk/test/modify.cpp
Log:
Modified model import/export code to work with shell bodies,standalone surfaces and shells are all in bodySM's. Added tests on these and stitch surfs now working too.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -88,6 +88,7 @@
}
myTopoDSShape = new TopoDS_CompSolid(Co);
IsSheetBody = CUBIT_FALSE;
+ myShell = NULL;
update_bounding_box();
}
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -1487,8 +1487,6 @@
stitched_body = face->my_body();
}
- //delete all original surfaces
- OCCQueryEngine::instance()->delete_solid_model_entities(surf_bodies);
return CUBIT_SUCCESS;
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -1082,7 +1082,12 @@
}
for (Ex.Init(aShape, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
- tblist.append(populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE));
+ {
+ Surface* face =
+ populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE);
+ if(face)
+ tblist.append(CAST_TO(face, OCCSurface)->my_body());
+ }
for (Ex.Init(aShape, TopAbs_WIRE, TopAbs_FACE); Ex.More(); Ex.Next())
populate_topology_bridge(TopoDS::Wire(Ex.Current()), CUBIT_TRUE);
@@ -1092,6 +1097,7 @@
for (Ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); Ex.More(); Ex.Next())
tblist.append(populate_topology_bridge(TopoDS::Vertex(Ex.Current())));
+ tblist.remove_all_with_value(NULL);
return tblist;
}
@@ -1110,21 +1116,22 @@
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;
}
- 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;
}
@@ -1137,31 +1144,32 @@
OCCLump *lump;
OCCBody *body;
if (!OCCMap->IsBound(*posolid))
+ {
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding solids.\n");
+ iTotalTBCreated++;
+ lump = new OCCLump(posolid);
+ if (build_body)
{
- if(PRINT_RESULT)
- PRINT_INFO("Adding solids.\n");
- iTotalTBCreated++;
- lump = new OCCLump(posolid);
- if (build_body)
- {
- DLIList<Lump*> lumps;
- lumps.append(lump);
- body = new OCCBody(lumps);
- BodyList->append(body);
- lump->add_body(body);
- }
- OCCMap->Bind(*posolid, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
- (TopologyBridge*)lump));
+ DLIList<Lump*> lumps;
+ lumps.append(lump);
+ body = new OCCBody(lumps);
+ BodyList->append(body);
+ lump->add_body(body);
}
+ 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;
- }
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_SHELL); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Shell(Ex.Current()));
+ {
+ int k = OCCMap->Find(*posolid);
+ lump = (OCCLump*)(OccToCGM->find(k))->second;
+ }
return lump;
}
@@ -1173,31 +1181,39 @@
OCCShell *shell ;
CubitBoolean build_body = CUBIT_FALSE;
if (!OCCMap->IsBound(*poshell))
+ {
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding shells.\n");
+ iTotalTBCreated++;
+ shell = new OCCShell(poshell);
+ OCCMap->Bind(*poshell, iTotalTBCreated);
+ OccToCGM->insert(valType(iTotalTBCreated,
+ (TopologyBridge*)shell));
+
+ if(standalone)
{
- if(PRINT_RESULT)
- PRINT_INFO("Adding shells.\n");
- iTotalTBCreated++;
- shell = new OCCShell(poshell);
- OCCMap->Bind(*poshell, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
- (TopologyBridge*)shell));
+ OCCLump* lump = new OCCLump(NULL, NULL, shell);
+ OCCBody* body = new OCCBody(NULL, CUBIT_FALSE, NULL, shell);
+ shell->set_body(body);
+ 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)
- {
- OCCLump* lump = new OCCLump(NULL, NULL, shell);
- OCCBody* body = new OCCBody(NULL, CUBIT_FALSE, NULL, shell);
- shell->set_body(body);
- shell->set_lump(lump);
- }
+ CAST_TO(face,OCCSurface)->set_shell(shell);
}
+ }
else
- {
- int k = OCCMap->Find(*poshell);
- shell = (OCCShell*)(OccToCGM->find(k))->second;
- }
+ {
+ int k = OCCMap->Find(*poshell);
+ shell = (OCCShell*)(OccToCGM->find(k))->second;
+ }
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_FACE); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Face(Ex.Current()), build_body);
return shell;
}
@@ -1206,38 +1222,38 @@
{
TopoDS_Face *poface = new TopoDS_Face;
*poface = aShape;
- OCCSurface *surface;
+ OCCSurface *surface = NULL;
if (!OCCMap->IsBound(*poface))
- {
- surface = new OCCSurface(poface);
+ {
+ surface = new OCCSurface(poface);
- if(PRINT_RESULT)
- PRINT_INFO("Adding faces.\n");
- iTotalTBCreated++;
- OCCMap->Bind(*poface, iTotalTBCreated);
- OccToCGM->insert(valType(iTotalTBCreated,
+ if(PRINT_RESULT)
+ PRINT_INFO("Adding faces.\n");
+ iTotalTBCreated++;
+ OCCMap->Bind(*poface, iTotalTBCreated);
+ OccToCGM->insert(valType(iTotalTBCreated,
(TopologyBridge*)surface));
- SurfaceList->append(surface);
- }
- else
+ SurfaceList->append(surface);
+ if(build_body)
{
- int k = OCCMap->Find(*poface);
- surface = (OCCSurface*)(OccToCGM->find(k))->second;
- }
-
- if(build_body)
- {
OCCShell* shell = new OCCShell(NULL, surface);
OCCLump* lump = new OCCLump(NULL, surface);
OCCBody* body = new OCCBody(NULL, CUBIT_TRUE, surface);
surface->set_body(body);
surface->set_lump(lump);
surface->set_shell(shell);
+ //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()));
+ }
- 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;
+ }
return surface;
}
@@ -1259,6 +1275,19 @@
(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
{
@@ -1266,19 +1295,6 @@
loop = (OCCLoop*)(OccToCGM->find(k))->second;
}
- 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;
}
@@ -1297,6 +1313,10 @@
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
{
@@ -1304,9 +1324,6 @@
curve = (OCCCurve*)(OccToCGM->find(i))->second;
}
- TopExp_Explorer Ex;
- for (Ex.Init(aShape, TopAbs_VERTEX); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Vertex(Ex.Current()));
return curve;
}
Modified: cgm/trunk/geom/OCC/OCCShell.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCShell.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -110,7 +110,7 @@
{
if(mySheetSurface)
{
- parents.append(mySheetSurface->my_lump());
+ parents.append(mySheetSurface->my_body());
return;
}
Modified: cgm/trunk/geom/OCC/OCCSurface.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCSurface.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/geom/OCC/OCCSurface.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -676,6 +676,12 @@
return;
}
+ if(myShell) //shell body
+ {
+ parents.append(myShell);
+ return;
+ }
+
OCCQueryEngine* oqe = (OCCQueryEngine*) get_geometry_query_engine();
OCCBody * body = NULL;
DLIList <OCCBody* > *bodies = oqe->BodyList;
Modified: cgm/trunk/test/Makefile.am
===================================================================
--- cgm/trunk/test/Makefile.am 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/test/Makefile.am 2008-03-13 19:31:27 UTC (rev 1649)
@@ -35,4 +35,5 @@
webcut_LDADD = ../geom/ACIS/libcubit_ACIS.la $(LDADD)
makept_LDFLAGS = $(LDFLAGS) -R$(OCC_LIB_DIR)
makept_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
-
+modify_LDFLAGS = $(LDFLAGS) -R$(OCC_LIB_DIR)
+modify_LDADD = ../geom/OCC/libcubit_OCC.la $(LDADD)
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-03-13 19:27:31 UTC (rev 1648)
+++ cgm/trunk/test/modify.cpp 2008-03-13 19:31:27 UTC (rev 1649)
@@ -143,6 +143,16 @@
CubitVector v = body2->center_point();
+ CubitStatus rsl = CUBIT_SUCCESS;
+ DLIList<RefEntity*> ref_entity_list;
+ int num_ents_exported=0;
+ const CubitString cubit_version="10.2";
+ const char * filename = "stitch.occ";
+ const char * filetype = "OCC";
+
+ rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
+ num_ents_exported, cubit_version);
+
DLIList<Body*> bodies;
DLIList<RefEntity*> free_entities;
gti->bodies(bodies);
@@ -155,5 +165,14 @@
gti->delete_RefEntity( free_entities.get_and_step());
}
+ // Read in the geometry from files specified on the command line
+ char *argv = "./stitch.occ";
+ CubitStatus status = read_geometry(1, &argv);
+ if (status == CUBIT_FAILURE) exit(1);
+
+ bodies.clean_out();
+ free_entities.clean_out();
+ gti->bodies(bodies);
+ gti->get_free_ref_entities(free_entities);
return stat;
}
More information about the cgma-dev
mailing list