[cgma-dev] r1619 - in cgm/trunk/geom: . OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed Feb 27 14:42:13 CST 2008
Author: janehu
Date: 2008-02-27 14:42:12 -0600 (Wed, 27 Feb 2008)
New Revision: 1619
Modified:
cgm/trunk/geom/GeometryModifyTool.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.hpp
Log:
modified delete solid modeling entities to cooperate with delete lower entities flag, when using a list of RefVolumns to create a single body, it puts all lumps into a single body without unite them, and delete old bodies
Modified: cgm/trunk/geom/GeometryModifyTool.cpp
===================================================================
--- cgm/trunk/geom/GeometryModifyTool.cpp 2008-02-27 16:45:17 UTC (rev 1618)
+++ cgm/trunk/geom/GeometryModifyTool.cpp 2008-02-27 20:42:12 UTC (rev 1619)
@@ -1520,7 +1520,18 @@
return (Body *)NULL;
}
- return GeometryQueryTool::instance()->make_Body(bodySM_ptr);
+ DLIList<BodySM*> bodysm_list;
+ bodysm_list.append(bodySM_ptr);
+
+ DLIList<Body*> input_bodies;
+ for (int i =0; i < ref_volume_list.size(); i++)
+ input_bodies.append(ref_volume_list.get_and_step()->get_body_ptr());
+
+ DLIList<Body*> results;
+
+ finish_sm_op(input_bodies, bodysm_list, results, CUBIT_TRUE);
+
+ return results.get();
}
//-------------------------------------------------------------------------
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-02-27 16:45:17 UTC (rev 1618)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-02-27 20:42:12 UTC (rev 1619)
@@ -820,7 +820,7 @@
aWire.Add(*(topo_edges->step_and_get()));
test_Wire = aWire.Wire();
- wires.append(&(aWire.Wire()));
+ wires.append(&test_Wire);
if (topo_edges_list.size() == 1)
break;
@@ -981,7 +981,7 @@
//===============================================================================
// Function : make_BodySM
// Member Type: PUBLIC
-// Description: make a BodySM
+// Description: make a BodySM from a surface
// Author : Jane Hu
// Date : 02/08
//===============================================================================
@@ -1037,39 +1037,26 @@
}
TopoDS_Solid* solid = occ_lump->get_TopoDS_Solid();
B.Add(CS, *solid);
+ }
+
+ BodySM* bodysm = OCCQueryEngine::instance()->populate_topology_bridge(CS);
+ if(bodysm)
+ {
//remove each Lump's body from the BodyList
- BodySM* bodysm = occ_lump->get_body();
- if(bodysm == NULL)
- continue;
-
- occ_lump->remove_body();
-
- OCCBody * occ_body = dynamic_cast<OCCBody*>(bodysm);
- if(occ_body == NULL)
- continue;
-
- TopoDS_Shape* shape = occ_body->get_TopoDS_Shape();
- if (shape == NULL)
- continue;
-
- int k;
- if(OCCQueryEngine::instance()->OCCMap->IsBound(*shape))
+ for(int i = 0; i < lump_list.size(); i++)
{
- k = OCCQueryEngine::instance()->OCCMap->Find(*shape);
+ Lump* lump = lump_list.get_and_step();
+ OCCLump* occ_lump = CAST_TO(lump, OCCLump);
+ BodySM* bodysm_ptr = occ_lump->get_body();
+ if(bodysm_ptr == NULL)
+ continue;
- if(!OCCQueryEngine::instance()->OCCMap->UnBind(*shape))
- PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
-
- if(!OCCQueryEngine::instance()->OccToCGM->erase(k))
- PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
+ OCCQueryEngine::instance()->unhook_BodySM_from_OCC(bodysm_ptr);
}
+ }
+ return bodysm;
- }
-
- return
- OCCQueryEngine::instance()->populate_topology_bridge(CS);
-
}
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-02-27 16:45:17 UTC (rev 1618)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-02-27 20:42:12 UTC (rev 1619)
@@ -1362,6 +1362,42 @@
return;
}
+CubitStatus OCCQueryEngine::delete_solid_model_entities(
+ GeometryEntity* ref_entity_ptr,
+ bool remove_lower_entities) const
+{
+ // Surface
+ Surface* ref_face_ptr = CAST_TO(ref_entity_ptr, Surface);
+ if (ref_face_ptr != NULL)
+ {
+ if (remove_lower_entities)
+ return ( this->delete_solid_model_entities(ref_face_ptr) );
+ return ( this->unhook_Surface_from_OCC(ref_face_ptr));
+ }
+
+ // Curve
+ Curve* ref_edge_ptr = CAST_TO(ref_entity_ptr, Curve);
+ if (ref_edge_ptr != NULL)
+ {
+ if (remove_lower_entities)
+ return ( this->delete_solid_model_entities(ref_edge_ptr));
+ return ( this->unhook_Curve_from_OCC(ref_edge_ptr));
+ }
+
+ // Point
+ Point* ref_vertex_ptr = CAST_TO(ref_entity_ptr, Point);
+ if (ref_vertex_ptr != NULL)
+ {
+ return ( this->delete_solid_model_entities(ref_vertex_ptr) );
+ }
+
+ // Oops!
+ PRINT_ERROR("In AcisQueryEngine::delete_solid_model_entities\n"
+ " Can only delete solid model entities underlying \n"
+ "RefFaces, RefEdges and RefVertices.\n");
+ return CUBIT_FAILURE;
+
+}
//-------------------------------------------------------------------------
// Purpose : Delete a OCCBody and child entities.
//
@@ -1378,6 +1414,25 @@
if (!occ_body)
return CUBIT_FAILURE;
+ for(int i =0; i < occ_body->lumps().size(); i++)
+ {
+ Lump* lump = occ_body->lumps().get_and_step();
+ OCCLump* occ_lump = CAST_TO(lump, OCCLump);
+ if (occ_lump)
+ occ_lump->remove_body();
+ unhook_Lump_from_OCC(lump);
+ }
+
+ return unhook_BodySM_from_OCC(bodysm);
+}
+
+CubitStatus
+OCCQueryEngine::unhook_BodySM_from_OCC( BodySM* bodysm)const
+{
+ OCCBody* occ_body = dynamic_cast<OCCBody*>(bodysm);
+ if (!occ_body)
+ return CUBIT_FAILURE;
+
TopoDS_Shape* shape = occ_body->get_TopoDS_Shape();
if (!shape)
@@ -1389,25 +1444,15 @@
if(OCCMap->IsBound(*shape))
{
k = OCCMap->Find(*shape);
-
+
if(!OCCMap->UnBind(*shape))
- PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
+ PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
occ_body_find = (OCCBody*)(OccToCGM->find(k))->second;
if(!OccToCGM->erase(k))
- PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
- }
-
- for(int i =0; i < occ_body->lumps().size(); i++)
- {
- Lump* lump = occ_body->lumps().get_and_step();
- OCCLump* occ_lump = CAST_TO(lump, OCCLump);
- if (occ_lump)
- occ_lump->remove_body();
- unhook_Lump_from_OCC(lump);
+ PRINT_ERROR("The OccBody and TopoDS_Shape pair is not in the map!");
}
-
occ_body->lumps().clean_out();
if (occ_body_find)
BodyList->remove(occ_body_find);
@@ -1415,9 +1460,8 @@
BodyList->remove(occ_body);
delete shape;
delete bodysm;
- return CUBIT_SUCCESS;
-}
-
+}
+
//-------------------------------------------------------------------------
// Purpose : Delete a OCClumps and child entities.
//
@@ -1464,6 +1508,7 @@
}
if (occ_lump->body() != NULL)
BodyList->remove(CAST_TO(occ_lump->body(), OCCBody));
+ delete solid;
delete lump;
return CUBIT_SUCCESS;
}
@@ -1507,9 +1552,10 @@
for(int i = 0; i < children.size(); i++)
{
Surface* surface = CAST_TO(children.get_and_step(), Surface);
- unhook_Surface_from_OCC(surface);
+ delete_solid_model_entities(surface);
}
ShellList->remove(CAST_TO(shell, OCCShell));
+ delete Shell;
delete shell;
return CUBIT_SUCCESS;
}
@@ -1530,16 +1576,16 @@
if (!fsurf)
return CUBIT_FAILURE;
- TopoDS_Face* face = fsurf->get_TopoDS_Face();
+ DLIList<TopologyBridge*> children;
+ fsurf->get_children_virt(children);
+ for(int i = 0; i < children.size(); i++)
+ {
+ LoopSM* loop = CAST_TO(children.get_and_step(), LoopSM);
+ delete_loop(loop);
+ }
- if(!face)
- return CUBIT_FAILURE;
-
- unhook_Surface_from_OCC(surface);
+ return unhook_Surface_from_OCC(surface);
- delete face;
- delete surface;
- return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1578,14 +1624,36 @@
PRINT_WARNING("The OccSurface and TopoDS_Face pair is not in the map!");
}
- DLIList<TopologyBridge*> children;
- fsurf->get_children_virt(children);
+ delete face;
+ delete surface;
+ return CUBIT_SUCCESS;
+}
+
+//-------------------------------------------------------------------------
+// Purpose : Delete a OCCSurface and child entities.
+//
+// Special Notes :
+//
+// Creator : Jane Hu
+//
+// Creation Date : 10/29/07
+//-------------------------------------------------------------------------
+CubitStatus
+OCCQueryEngine::delete_loop( LoopSM* loopsm)const
+{
+ OCCLoop* occ_loop = dynamic_cast<OCCLoop*>(loopsm);
+ if (!occ_loop)
+ return CUBIT_FAILURE;
+
+ DLIList<OCCCoEdge*> children;
+ occ_loop->coedges(children);
for(int i = 0; i < children.size(); i++)
{
- LoopSM* loop = CAST_TO(children.get_and_step(), LoopSM);
- unhook_LoopSM_from_OCC(loop);
+ Curve* curve = children.get_and_step()->curve();
+ delete_solid_model_entities(curve);
}
- return CUBIT_SUCCESS;
+
+ return unhook_LoopSM_from_OCC(loopsm);
}
//-------------------------------------------------------------------------
@@ -1622,14 +1690,8 @@
PRINT_ERROR("The OccLoop and TopoDS_Wire pair is not in the map!");
}
- DLIList<OCCCoEdge*> children;
- occ_loop->coedges(children);
- for(int i = 0; i < children.size(); i++)
- {
- Curve* curve = children.get_and_step()->curve();
- unhook_Curve_from_OCC(curve);
- }
WireList->remove(CAST_TO(loopsm, OCCLoop));
+ delete wire;
delete loopsm;
return CUBIT_SUCCESS;
}
@@ -1650,15 +1712,15 @@
if (!fcurve )
return CUBIT_FAILURE;
- TopoDS_Edge * edge = fcurve->get_TopoDS_Edge();
- if (!edge)
- return CUBIT_FAILURE;
-
- unhook_Curve_from_OCC(curve);
+ DLIList<TopologyBridge*> children;
+ fcurve->get_children_virt(children);
+ for(int i = 0; i < children.size(); i++)
+ {
+ Point* point = CAST_TO(children.get_and_step(), Point);
+ delete_solid_model_entities(point);
+ }
- delete edge;
- delete curve;
- return CUBIT_SUCCESS;
+ return unhook_Curve_from_OCC(curve);
}
//-------------------------------------------------------------------------
@@ -1694,13 +1756,8 @@
PRINT_WARNING("The OccCurve and TopoDS_Edge pair is not in the map!");
}
- DLIList<TopologyBridge*> children;
- fcurve->get_children_virt(children);
- for(int i = 0; i < children.size(); i++)
- {
- Point* point = CAST_TO(children.get_and_step(), Point);
- unhook_Point_from_OCC(point);
- }
+ delete edge;
+ delete curve;
return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1719,15 +1776,8 @@
if (!fpoint)
return CUBIT_FAILURE;
- TopoDS_Vertex *vertex = fpoint->get_TopoDS_Vertex();
- if (!vertex)
- return CUBIT_FAILURE;
+ return unhook_Point_from_OCC(point);
- unhook_Point_from_OCC(point);
-
- delete vertex;
- delete point;
- return CUBIT_SUCCESS;
}
//-------------------------------------------------------------------------
@@ -1762,6 +1812,8 @@
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-02-27 16:45:17 UTC (rev 1618)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.hpp 2008-02-27 20:42:12 UTC (rev 1619)
@@ -244,6 +244,9 @@
CubitBoolean import_curves = CUBIT_TRUE,
CubitBoolean import_vertices = CUBIT_TRUE,
CubitBoolean free_surfaces = CUBIT_TRUE );
+
+ CubitStatus unhook_BodySM_from_OCC( BodySM* bodysm)const;
+
private:
CubitStatus import_solid_model(FILE *file_ptr,
const char* /*file_type*/,
@@ -263,11 +266,15 @@
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 delete_loop( LoopSM* loopsm)const;
public:
virtual void delete_solid_model_entities(DLIList<BodySM*>& body_list) const;
//- Deletes all solid model entities associated with the Bodies in
//- the input list.
-
+ virtual CubitStatus delete_solid_model_entities(
+ GeometryEntity* ref_entity_ptr,
+ bool remove_lower_entities) 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;
More information about the cgma-dev
mailing list