[cgma-dev] r1833 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed May 21 13:54:59 CDT 2008
Author: janehu
Date: 2008-05-21 13:54:59 -0500 (Wed, 21 May 2008)
New Revision: 1833
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/test/modify.cpp
Log:
updated testcase for body-body imprint through GeometryModifyTool interface.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-05-20 21:33:57 UTC (rev 1832)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-05-21 18:54:59 UTC (rev 1833)
@@ -2319,62 +2319,36 @@
BodySM*& newBody1, BodySM*& newBody2,
bool keep_old) const
{
- OCCBody* occ_body = NULL;
newBody1 = NULL;
newBody2 = NULL;
DLIList<TopoDS_Shape*> shape_list;
- for(int i = 0; i <2; i++)
- {
- if (i == 0)
- occ_body = CAST_TO(BodyPtr1, OCCBody);
- else
- occ_body = CAST_TO(BodyPtr2, OCCBody);
- OCCSurface* surface = occ_body->my_sheet_surface();
- OCCShell* shell = occ_body->shell();
- if(surface)
- {
- TopoDS_Face* topo_face = surface->get_TopoDS_Face();
- BRepBuilderAPI_Copy api_copy(*topo_face);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
- }
- else if(shell)
- {
- TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
- BRepBuilderAPI_Copy api_copy(*topo_shell);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
- }
-
- else
- {
- DLIList<Lump*> lumps = occ_body->lumps();
- if (lumps.size() > 1)
- {
- PRINT_ERROR("Can't do boolean operation on CompSolid types. \n");
- return CUBIT_FAILURE;
- }
- TopoDS_Solid* solid = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid();
- BRepBuilderAPI_Copy api_copy(*solid);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
- }
- }
+ DLIList<BodySM*> bodysm_list;
+ bodysm_list.append(BodyPtr1);
+ bodysm_list.append(BodyPtr2);
+ CubitStatus stat = get_the_shape_list(bodysm_list, shape_list, keep_old);
+
+ if(!stat)
+ return stat;
+
TopoDS_Shape* shape1 = shape_list.get();
TopoDS_Shape* shape2 = shape_list.step_and_get();
DLIList<TopologyBridge*> tbs;
- CubitStatus stat = imprint_toposhapes(shape1, shape2);
+ stat = imprint_toposhapes(shape1, shape2);
if(stat)
{
tbs += OCCQueryEngine::instance()->populate_topology_bridge(*shape1);
newBody1 = CAST_TO(tbs.get(),BodySM);
}
+ else if(!stat && keep_old)
+ {
+ delete shape1;
+ PRINT_INFO("There's no imprint on the first body.\n");
+ newBody1 = BodyPtr1;
+ }
+
tbs.clean_out();
stat = imprint_toposhapes(shape2, shape1);
if(stat)
@@ -2383,65 +2357,58 @@
newBody2 = CAST_TO(tbs.get(),BodySM);
}
- if (!keep_old)
+ else if(!stat && keep_old)
{
- if (newBody1)
- OCCQueryEngine::instance()->delete_solid_model_entities(BodyPtr1);
- if (newBody2)
- OCCQueryEngine::instance()->delete_solid_model_entities( BodyPtr2);
- }
-
- if (!newBody1)
- {
- delete shape1;
- newBody1 = BodyPtr1;
- }
-
- if(!newBody2)
- {
delete shape2;
+ PRINT_INFO("There's no imprint on the second body.\n");
newBody2 = BodyPtr2;
}
return CUBIT_SUCCESS;
}
//===============================================================================
-// Function : imprint multiple bodies at once
-// Member Type: PUBLIC
-// Description: imprint boolean operation on OCC-based bodies
-// Author : Jane HU
-// Date : 04/08
+// Function : get_the_shape_list
+// Member Type: PRIVATE
+// Description: get the TopoDS_Shape list for imprinting use.
+// Author : Jane Hu
+// Date : 05/08
//===============================================================================
-CubitStatus OCCModifyEngine::imprint(DLIList<BodySM*> &from_body_list ,
- DLIList<BodySM*> &new_from_body_list,
- bool keep_old,
- DLIList<TopologyBridge*>* new_tbs,
- DLIList<TopologyBridge*>* att_tbs) const
+CubitStatus OCCModifyEngine::get_the_shape_list(DLIList<BodySM*> BodySM_list,
+ DLIList<TopoDS_Shape*>& shape_list,
+ bool keep_old) const
{
- CubitStatus success = CUBIT_SUCCESS;
OCCBody* occ_body = NULL;
- DLIList<TopoDS_Shape*> shape_list;
-
- for(int i = 0; i <from_body_list.size(); i++)
+ shape_list.clean_out();
+ for(int i = 0; i <BodySM_list.size(); i++)
{
- occ_body = CAST_TO(from_body_list.get_and_step(), OCCBody);
+ occ_body = CAST_TO(BodySM_list.get_and_step(), OCCBody);
OCCSurface* surface = occ_body->my_sheet_surface();
OCCShell* shell = occ_body->shell();
if(surface)
{
TopoDS_Face* topo_face = surface->get_TopoDS_Face();
- BRepBuilderAPI_Copy api_copy(*topo_face);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
+ if(keep_old)
+ {
+ BRepBuilderAPI_Copy api_copy(*topo_face);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_face);
+ TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
+ shape_list.append(Shape1);
+ }
+ else
+ shape_list.append(topo_face);
}
else if(shell)
{
TopoDS_Shell* topo_shell = shell->get_TopoDS_Shell();
- BRepBuilderAPI_Copy api_copy(*topo_shell);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
+ if(keep_old)
+ {
+ BRepBuilderAPI_Copy api_copy(*topo_shell);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*topo_shell);
+ TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
+ shape_list.append(Shape1);
+ }
+ else
+ shape_list.append(topo_shell);
}
else
@@ -2454,12 +2421,39 @@
}
TopoDS_Solid* solid = CAST_TO(lumps.get(), OCCLump)->get_TopoDS_Solid();
- BRepBuilderAPI_Copy api_copy(*solid);
- TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
- TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
- shape_list.append(Shape1);
+ if(keep_old)
+ {
+ BRepBuilderAPI_Copy api_copy(*solid);
+ TopoDS_Shape newShape = api_copy.ModifiedShape(*solid);
+ TopoDS_Shape* Shape1 = new TopoDS_Shape(newShape);
+ shape_list.append(Shape1);
+ }
+ else
+ shape_list.append(solid);
}
}
+ return CUBIT_SUCCESS;
+}
+//===============================================================================
+// Function : imprint multiple bodies at once
+// Member Type: PUBLIC
+// Description: imprint boolean operation on OCC-based bodies
+// Author : Jane HU
+// Date : 04/08
+//===============================================================================
+CubitStatus OCCModifyEngine::imprint(DLIList<BodySM*> &from_body_list ,
+ DLIList<BodySM*> &new_from_body_list,
+ bool keep_old,
+ DLIList<TopologyBridge*>* new_tbs,
+ DLIList<TopologyBridge*>* att_tbs) const
+{
+ CubitStatus success = CUBIT_SUCCESS;
+ DLIList<TopoDS_Shape*> shape_list;
+
+ CubitStatus stat = get_the_shape_list(from_body_list, shape_list, keep_old);
+
+ if(!stat)
+ return stat;
int size = shape_list.size();
// total number of imprints to be done
@@ -2468,7 +2462,8 @@
if( size > 2 )
{
char message[128];
- sprintf(message, "Imprinting %d ACIS Bodies", from_body_list.size() ); AppUtil::instance()->progress_tool()->start(0, total_imprints, message);
+ sprintf(message, "Imprinting %d OCC Bodies", from_body_list.size() );
+ AppUtil::instance()->progress_tool()->start(0, total_imprints, message);
}
for(int i = 0; i < size; i++)
@@ -2484,7 +2479,7 @@
break;
}
- TopoDS_Shape* shape2 = shape_list[j];
+ TopoDS_Shape* shape2 = shape_list[j%size];
DLIList<TopologyBridge*> tbs;
CubitStatus stat = imprint_toposhapes(shape1, shape2);
if(stat)
@@ -2512,7 +2507,7 @@
//===============================================================================
// Function : imprint
// Member Type: PUBLIC
-// Description: imprint boolean operation on facet-based bodies
+// Description: imprint boolean operation on OCC-based bodies
// Author : John Fowler
// Date : 10/02
//===============================================================================
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-05-20 21:33:57 UTC (rev 1832)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2008-05-21 18:54:59 UTC (rev 1833)
@@ -669,7 +669,9 @@
private:
int check_intersection(DLIList<TopoDS_Edge*>* edge_list,
TopoDS_Face from_face)const;
-
+ CubitStatus get_the_shape_list(DLIList<BodySM*> BodySM_list,
+ DLIList<TopoDS_Shape*>& shape_list,
+ bool keep_old) const;
} ;
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-05-20 21:33:57 UTC (rev 1832)
+++ cgm/trunk/test/modify.cpp 2008-05-21 18:54:59 UTC (rev 1833)
@@ -221,6 +221,30 @@
d = from_body2->measure();//d = 67.02
d = tool_body->measure(); //d = 31.41
+ // test for sphere making
+ Body* test_body = gmti->sphere(5);
+ d = test_body->measure(); //d =
+
+ //test for prism making
+ test_body = gmti->prism(10, 4, 4,2);
+ d = test_body->measure(); //d =
+
+ //test for pyramid making
+ test_body = gmti->pyramid(10, 4, 5, 2, 3);
+ d = test_body->measure(); //d =
+
+ //test for torus making
+ test_body = gmti->torus(10,5);
+ d = test_body->measure(); //d =
+
+ //test for planar_sheet making
+ CubitVector p1(0, 0, 0);
+ CubitVector p2(0, 0, 1);
+ CubitVector p3(0, 1, 1);
+ CubitVector p4(0, 1, 0);
+ test_body = gmti->planar_sheet(p1, p2, p3, p4);
+ d = test_body->measure(); //d = 1
+
bodies.clean_out();
gti->bodies(bodies);
//delete all entities
@@ -325,22 +349,24 @@
CubitVector v_move3(0,1,0);
gti->translate(tool_body,v_move3);
BodySM* copy_bodysm = ome->copy_body(tool_body->get_body_sm_ptr());
+ Body* copy_tool_body = gmti->copy_body(tool_body);
+
+ //test shell body imprint
+ //TopoDS_Shape* tool_shape = CAST_TO(copy_bodysm,OCCBody)->get_TopoDS_Shape();
+ //TopoDS_Shape* from_shape = CAST_TO(bodysm,OCCBody)->shell()->get_TopoDS_Shell();
+ //ome->imprint_toposhapes(tool_shape, from_shape);
from_bodies.clean_out();
+ new_bodies.clean_out();
+ from_bodies.append(copy_tool_body);
from_bodies.append(from_body2);
- new_bodies.clean_out();
+ CubitStatus stat = gmti->imprint(from_bodies, new_bodies, CUBIT_FALSE);
- //test face body imprint
- TopoDS_Shape* tool_shape = CAST_TO(copy_bodysm,OCCBody)->get_TopoDS_Shape();
-/* TopoDS_Shape* from_shape = CAST_TO(body_list[0],OCCBody)->my_sheet_surface()->get_TopoDS_Face();
- ome->imprint_toposhapes(tool_shape, from_shape);
-*/
- //test shell body imprint.
- TopoDS_Shape* from_shape = CAST_TO(bodysm,OCCBody)->shell()->get_TopoDS_Shell();
- ome->imprint_toposhapes(tool_shape, from_shape);
-
//test body cutting a shell, one surface got cut as the result.
CubitVector v_move6(1,-1,0);
gti->translate(tool_body,v_move6);
+ from_bodies.clean_out();
+ from_bodies.append(from_body2);
+ new_bodies.clean_out();
rsl = gmti->subtract(tool_body, from_bodies, new_bodies,
CUBIT_TRUE, CUBIT_TRUE);
d = new_bodies.step_and_get()->measure();
@@ -360,10 +386,16 @@
CubitVector v_move5(0,0.5,0);
gti->translate(tool_body,v_move5);
from_body = gmti->brick(1,1,1);
- from_shape = CAST_TO(from_body->get_body_sm_ptr(), OCCBody)->get_TopoDS_Shape();
- tool_shape = CAST_TO(tool_body->get_body_sm_ptr(),OCCBody)->get_TopoDS_Shape();
- ome->imprint_toposhapes(tool_shape, from_shape);
- ome->imprint_toposhapes(from_shape, tool_shape);
+ //from_shape = CAST_TO(from_body->get_body_sm_ptr(), OCCBody)->get_TopoDS_Shape();
+ //tool_shape = CAST_TO(tool_body->get_body_sm_ptr(),OCCBody)->get_TopoDS_Shape();
+// ome->imprint_toposhapes(tool_shape, from_shape);
+// ome->imprint_toposhapes(from_shape, tool_shape);
+ from_bodies.clean_out();
+ new_bodies.clean_out();
+ from_bodies.append(from_body);
+ from_bodies.append(tool_body);
+ stat = gmti->imprint(from_bodies, new_bodies, CUBIT_FALSE);
+
return CUBIT_SUCCESS;
}
More information about the cgma-dev
mailing list