[cgma-dev] r1643 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed Mar 12 13:45:10 CDT 2008
Author: janehu
Date: 2008-03-12 13:45:10 -0500 (Wed, 12 Mar 2008)
New Revision: 1643
Modified:
cgm/trunk/geom/OCC/OCCBody.cpp
cgm/trunk/geom/OCC/OCCBody.hpp
cgm/trunk/geom/OCC/OCCLump.cpp
cgm/trunk/geom/OCC/OCCLump.hpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
cgm/trunk/geom/OCC/OCCShell.hpp
Log:
Added shell body for stitch operation, still has problems dealing with existing surfaces used for stitching, working on that.
Modified: cgm/trunk/geom/OCC/OCCBody.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCBody.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -60,11 +60,12 @@
//
//-------------------------------------------------------------------------
OCCBody::OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody,
- OCCSurface* surface)
+ OCCSurface* surface, OCCShell* shell)
{
myTopoDSShape = theShape;
IsSheetBody = isSheetBody;
mySheetSurface = surface;
+ myShell = shell;
update_bounding_box();
}
@@ -157,6 +158,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -194,6 +201,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -225,6 +238,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -276,6 +295,12 @@
aBRepTrsf.Perform(*face);
OCCQueryEngine::instance()->update_entity_shape(mySheetSurface, aBRepTrsf);
}
+ else if(myShell)
+ {
+ TopoDS_Shell* shell = myShell->get_TopoDS_Shell();
+ aBRepTrsf.Perform(*shell);
+ myShell->update_OCC_entity(aBRepTrsf);
+ }
else
{
aBRepTrsf.Perform(*myTopoDSShape);
@@ -296,7 +321,7 @@
//----------------------------------------------------------------
CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_FAILURE;
TopoDS_Shape shape = aBRepTrsf.Shape();
@@ -347,6 +372,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape=*myTopoDSShape;
@@ -383,6 +410,12 @@
return;
}
+ if (myShell)
+ {
+ lumps.append(myShell->my_lump());
+ return;
+ }
+
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*myTopoDSShape, TopAbs_SOLID, M);
int ii;
@@ -405,7 +438,7 @@
CubitStatus OCCBody::mass_properties( CubitVector& centroid,
double& volume )
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_FAILURE;
GProp_GProps myProps;
BRepGProp::VolumeProperties(*myTopoDSShape, myProps);
@@ -427,7 +460,7 @@
//-------------------------------------------------------------------------
CubitPointContainment OCCBody::point_containment( const CubitVector &point )
{
- if(IsSheetBody)
+ if(IsSheetBody || myShell)
return CUBIT_PNT_UNKNOWN;
CubitPointContainment pc_value;
@@ -464,8 +497,14 @@
surfaces.append(mySheetSurface);
return;
}
+
+ TopoDS_Shape shape;
+ if (myShell)
+ shape = *(myShell->get_TopoDS_Shell());
+ else
+ shape = *myTopoDSShape;
TopTools_IndexedMapOfShape M;
- TopExp::MapShapes(*myTopoDSShape, TopAbs_FACE, M);
+ TopExp::MapShapes(shape, TopAbs_FACE, M);
int ii;
for (ii=1; ii<=M.Extent(); ii++) {
TopologyBridge *surface = OCCQueryEngine::instance()->occ_to_cgm(M(ii));
@@ -490,6 +529,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape = *myTopoDSShape;
@@ -519,6 +560,8 @@
TopoDS_Shape shape;
if(IsSheetBody)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape = *myTopoDSShape;
Modified: cgm/trunk/geom/OCC/OCCBody.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCBody.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCBody.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -47,11 +47,14 @@
public:
OCCBody(TopoDS_CompSolid *theShape, CubitBoolean isSheetBody = CUBIT_FALSE,
- OCCSurface* surface = NULL);
+ OCCSurface* surface = NULL, OCCShell* shell = NULL);
OCCBody(DLIList<Lump*>& my_lumps);
void lumps(DLIList<Lump*>& my_lumps); //add lump list to myLumps
DLIList<Lump*> lumps(){return myLumps;}
+
+ void shell(OCCShell* shell) {myShell = shell;}
+ OCCShell* shell() {return myShell;}
virtual ~OCCBody() ;
//- The destructor.
@@ -190,7 +193,9 @@
CubitBoolean IsSheetBody;
- OCCSurface* mySheetSurface;
+ OCCSurface* mySheetSurface; //one surface body
+
+ OCCShell* myShell; //shell only body
};
Modified: cgm/trunk/geom/OCC/OCCLump.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCLump.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -64,10 +64,11 @@
// Special Notes :
//
//-------------------------------------------------------------------------
-OCCLump::OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface)
+OCCLump::OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface, OCCShell* shell)
{
myTopoDSSolid = theSolid;
mySheetSurface = surface;
+ myShell = shell;
}
OCCLump::~OCCLump()
@@ -85,7 +86,7 @@
CubitStatus OCCLump::mass_properties( CubitVector& centroid,
double& volume )
{
- if (mySheetSurface)
+ if (mySheetSurface || myShell)
return CUBIT_FAILURE;
GProp_GProps myProps;
@@ -177,6 +178,8 @@
TopoDS_Shape shape;
if(mySheetSurface)
shape = *(mySheetSurface->get_TopoDS_Face());
+ else if(myShell)
+ shape = *(myShell->get_TopoDS_Shell());
else
shape =*myTopoDSSolid;
@@ -215,7 +218,7 @@
//-------------------------------------------------------------------------
double OCCLump::measure()
{
- if(mySheetSurface)
+ if(mySheetSurface || myShell)
return 0.0;
GProp_GProps myProps;
BRepGProp::VolumeProperties(*myTopoDSSolid, myProps);
@@ -226,6 +229,8 @@
{
if(mySheetSurface)
bodies.append(mySheetSurface->my_body());
+ else if (myShell)
+ bodies.append(myShell->my_body());
else
bodies.append(myBodyPtr);
}
@@ -237,6 +242,11 @@
shellsms.append(mySheetSurface->my_shell());
return;
}
+ else if(myShell)
+ {
+ shellsms.append(myShell);
+ return;
+ }
TopTools_IndexedMapOfShape M;
TopExp::MapShapes(*myTopoDSSolid, TopAbs_SHELL, M);
int ii;
@@ -250,7 +260,7 @@
CubitPointContainment OCCLump::point_containment( const CubitVector &point )
{
- if (mySheetSurface)
+ if (mySheetSurface || myShell)
return CUBIT_PNT_UNKNOWN;
BOP_SolidClassifier ps;
@@ -283,7 +293,7 @@
//----------------------------------------------------------------
CubitStatus OCCLump::update_OCC_entity( BRepBuilderAPI_Transform &aBRepTrsf)
{
- if(mySheetSurface)
+ if(mySheetSurface || myShell)
return CUBIT_FAILURE;
TopoDS_Shape shape = aBRepTrsf.ModifiedShape(*get_TopoDS_Solid());
Modified: cgm/trunk/geom/OCC/OCCLump.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCLump.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -44,7 +44,8 @@
{
public:
- OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface = NULL);
+ OCCLump(TopoDS_Solid *theSolid, OCCSurface* surface = NULL,
+ OCCShell* shell = NULL);
virtual ~OCCLump();
//- The destructor
@@ -161,6 +162,7 @@
//List of OCCAttrib*'s instead of CubitSimpleAttribs
OCCSurface *mySheetSurface;
+ OCCShell * myShell;
} ;
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -45,6 +45,7 @@
#include "BRepBuilderAPI_MakeEdge.hxx"
#include "BRepAdaptor_Surface.hxx"
#include "BRepBuilderAPI_MakeFace.hxx"
+#include "BRepBuilderAPI_Sewing.hxx"
#include "BRepBuilderAPI_Copy.hxx"
#include "BRep_Tool.hxx"
#include "BRep_Builder.hxx"
@@ -1415,7 +1416,7 @@
//===============================================================================
// Function : stitch_surfs
// Member Type: PUBLIC
-// Description: Unite surfs into one surface sheet body
+// Description: stitch all surfs and try to make a closed solid out of them.
// Author : Jane Hu
// Date : 03/08
//===============================================================================
@@ -1436,7 +1437,7 @@
DLIList<TopoDS_Face*> faces_to_stitch;
for (int i = 0; i < surf_bodies.size(); i++)
{
- BodySM * tool_body = surf_bodies.get();
+ BodySM * tool_body = surf_bodies.get_and_step();
OCCBody* occ_body = CAST_TO(tool_body, OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
if (surface == NULL)
@@ -1449,58 +1450,43 @@
faces_to_stitch.append(topods_face);
}
- TopoDS_Face* first_face = faces_to_stitch.get();
+ TopoDS_Shape* first_face = faces_to_stitch.get();
TopoDS_Face* second_face = NULL;
- TopoDS_Face* new_face = NULL ;
- CubitBoolean disconnected = CUBIT_FALSE;
- TopoDS_Shape fusion;
- int count = 0;
- for(int i = 0; i < faces_to_stitch.size(); i++)
+ TopoDS_Shape fuse;
+ for(int i = 1; i < faces_to_stitch.size(); i++)
{
- if (count > 0)
- first_face = new_face;
-
- for(int j = i + 1; j < faces_to_stitch.size(); j++)
- {
- second_face = faces_to_stitch[j];
- BRepAlgoAPI_Fuse fuse(*first_face, *second_face);
- if (fuse.ErrorStatus() != 0 && fuse.ErrorStatus() != 1)
- {
- PRINT_ERROR("Can't operate fusion for given surfaces. \n");
- return CUBIT_FAILURE;
- }
- else if (fuse.ErrorStatus() == 1)
- {
- //The Object is created but Nothing is Done
- disconnected = CUBIT_TRUE;
- continue;
- }
+ second_face = faces_to_stitch[i];
+ fuse = BRepAlgoAPI_Fuse(*first_face, *second_face);
+ first_face = &fuse;
+ }
- //fused into one face
- fusion = fuse.Shape1();
- if (count > 0)
- delete new_face;
- new_face = new TopoDS_Face(TopoDS::Face(fusion));
- faces_to_stitch.remove(second_face);
- disconnected = CUBIT_FALSE;
- i--;
- count++;
- break;
- }
- if (disconnected)
- {
- //Can't make a body out of disconnected faces
- PRINT_ERROR("Can't create one BodySM out of disconnected surfaces. \n");
- if(new_face != NULL)
- delete new_face;
- return CUBIT_FAILURE;
- }
+ 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)
+ {
+ 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 ;
- Surface* surface = OCCQueryEngine::instance()->
- populate_topology_bridge(*new_face, CUBIT_TRUE);
+ else
+ {
+ OCCSurface* face = CAST_TO(tbs.get(), OCCSurface);
+ if(face)
+ stitched_body = face->my_body();
+ }
- stitched_body = CAST_TO(surface, OCCSurface)->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-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -141,7 +141,6 @@
OccToCGM = new std::map<int, TopologyBridge*>;
BodyList = new DLIList<OCCBody*>;
- ShellList = new DLIList<OCCShell*>;
WireList = new DLIList<OCCLoop*>;
SurfaceList = new DLIList<OCCSurface*>;
CurveList = new DLIList<OCCCurve*>;
@@ -158,7 +157,6 @@
delete OCCMap;
delete OccToCGM;
while( BodyList->size() ) delete BodyList->pop();
- delete[] ShellList;
delete[] WireList;
delete[] SurfaceList;
delete[] CurveList;
@@ -939,15 +937,20 @@
OCCBody* body = OCC_bodies.get_and_step();
TopoDS_CompSolid *shape = body->get_TopoDS_Shape();
- if (shape == NULL) //sheet body
+ if (shape == NULL) //sheet body or shell body
{
OCCSurface* surface = body->my_sheet_surface();
- if (surface == NULL)
+ OCCShell* shell = body->shell();
+ if (surface == NULL && shell == NULL)
{
+
PRINT_ERROR( "Wrong body structure. Internal ERROR\n" );
continue;
}
- B.Add(Co,*(surface->get_TopoDS_Face()));
+ if(surface)
+ B.Add(Co,*(surface->get_TopoDS_Face()));
+ else
+ B.Add(Co,*(shell->get_TopoDS_Shell()));
continue;
}
@@ -969,13 +972,6 @@
}
}
- //Add standalone shells to export BRep file
- for (i = 0; i < ShellList->size(); i++)
- {
- TopoDS_Shell *shell = ShellList->get_and_step()->get_TopoDS_Shell();
- B.Add(Co, *shell);
- }
-
for (i = 0; i < OCC_surfaces.size(); i++)
{
TopoDS_Face *face = OCC_surfaces.get_and_step()->get_TopoDS_Face();
@@ -1079,7 +1075,11 @@
}
for (Ex.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); Ex.More(); Ex.Next())
- populate_topology_bridge(TopoDS::Shell(Ex.Current()), CUBIT_TRUE);
+ {
+ OCCShell* shell =
+ populate_topology_bridge(TopoDS::Shell(Ex.Current()), CUBIT_TRUE);
+ tblist.append(shell->my_body());
+ }
for (Ex.Init(aShape, TopAbs_FACE, TopAbs_SHELL); Ex.More(); Ex.Next())
tblist.append(populate_topology_bridge(TopoDS::Face(Ex.Current()),CUBIT_TRUE));
@@ -1183,8 +1183,10 @@
(TopologyBridge*)shell));
if(standalone)
{
- build_body = CUBIT_TRUE;
- ShellList->append(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);
}
}
else
@@ -1423,6 +1425,14 @@
return delete_solid_model_entities(occ_surface);
}
+ OCCShell* occ_shell = occ_body->shell();
+ if(occ_shell)
+ {
+ delete occ_shell->my_body();
+ delete occ_shell->my_lump();
+ return unhook_ShellSM_from_OCC(occ_shell);
+ }
+
DLIList<Lump*> lumps = occ_body->lumps();
for(int i =0; i < lumps.size(); i++)
{
@@ -1566,7 +1576,6 @@
Surface* surface = CAST_TO(children.get_and_step(), Surface);
delete_solid_model_entities(surface);
}
- ShellList->remove(CAST_TO(shell, OCCShell));
delete Shell;
delete shell;
return CUBIT_SUCCESS;
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -346,7 +346,6 @@
Point* populate_topology_bridge(TopoDS_Vertex aShape);
DLIList<OCCBody*> *BodyList ;
- DLIList<OCCShell*> *ShellList; //standalone shell list
DLIList<OCCSurface*> *SurfaceList ;
DLIList<OCCLoop*> *WireList; //standalone wire list
DLIList<OCCCurve*> *CurveList ;
Modified: cgm/trunk/geom/OCC/OCCShell.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCShell.hpp 2008-03-12 18:04:16 UTC (rev 1642)
+++ cgm/trunk/geom/OCC/OCCShell.hpp 2008-03-12 18:45:10 UTC (rev 1643)
@@ -50,6 +50,11 @@
TopoDS_Shell* get_TopoDS_Shell() {return myTopoDSShell;}
void set_TopoDS_Shell(TopoDS_Shell shell){*myTopoDSShell = shell;}
+ OCCLump* my_lump() {return myLump;}
+ OCCBody* my_body() {return myBody;}
+ void set_lump(OCCLump* lump) {myLump = lump;}
+ void set_body(OCCBody* body) {myBody = body;}
+
virtual GeometryQueryEngine*
get_geometry_query_engine() const;
//R GeometryQueryEngine*
@@ -107,6 +112,8 @@
private:
TopoDS_Shell *myTopoDSShell;
OCCSurface* mySheetSurface;
+ OCCLump* myLump;
+ OCCBody* myBody;
};
More information about the cgma-dev
mailing list