[cgma-dev] r1911 - in cgm/trunk: geom/OCC test
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Wed Jun 18 14:17:45 CDT 2008
Author: janehu
Date: 2008-06-18 14:17:45 -0500 (Wed, 18 Jun 2008)
New Revision: 1911
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.cpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
cgm/trunk/test/modify.cpp
Log:
Tested on unite operation, BRepAlgoAPI_Fuse seems to have problems with coplanar face fusion which left seam lines in between, looking into opencascade forum for solutions.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-06-18 01:02:48 UTC (rev 1910)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.cpp 2008-06-18 19:17:45 UTC (rev 1911)
@@ -3392,7 +3392,9 @@
if(after_mass < tol) //no common section
cut_shape.Nullify();
has_changed = CUBIT_TRUE;
- TopoDS_Solid old_solid = TopoDS::Solid(op->Shape1());
+ TopExp_Explorer Ex;
+ Ex.Init(*from_shape, TopAbs_SOLID);
+ TopoDS_Solid old_solid = TopoDS::Solid(Ex.Current());
OCCLump::update_OCC_entity(old_solid , cut_shape, op);
}
else
@@ -3508,46 +3510,47 @@
if(!stat)
return stat;
- TopoDS_Shape* first_shape = shape_list.pop();
-
+ //find a non-sheet body to be the first shape
+ TopoDS_Shape* first_shape;
+ CubitBoolean first_is_volume;
+ if(first_is_volume = is_volume.move_to(CUBIT_TRUE))
+ {
+ int index = is_volume.get_index();
+ first_shape = shape_list[index];
+ shape_list.remove(first_shape);
+ is_volume.step(index);
+ is_volume.remove();
+ bodies.step(index);
+ bodies.remove();
+ }
+
+ else
+ {
+ first_shape = shape_list.pop();
+ bodies.pop();
+ }
+
int size = shape_list.size();
OCCBody* deleted_body = NULL;
CubitBoolean restore_first_shape = CUBIT_FALSE;
for(int i = 0; i < size; i++)
{
TopoDS_Shape* second_shape = shape_list.get_and_step();
-
+
BRepAlgoAPI_Fuse fuser(*first_shape, *second_shape);
- TopTools_ListOfShape shapes;
- shapes.Assign(fuser.Modified(*first_shape));
- if(shapes.Extent() != 1)
- {
- restore_first_shape = CUBIT_TRUE;
- PRINT_WARNING("The unite boolean didn't work in opencascade.\n");
- break;
- }
+ TopoDS_Shape new_shape = fuser.Shape();
+ //Debug:: check how many faces are there in new_shape.
+ TopExp_Explorer Ex;
+ int count = 0;
+ for (Ex.Init(new_shape, TopAbs_FACE);Ex.More(); Ex.Next())
+ count++;
+
CubitBoolean has_changed;
- if(is_volume[size] == CUBIT_TRUE || is_volume[i] == CUBIT_TRUE)
- {
- if(is_volume[size] == CUBIT_FALSE)
- {
- //exchange the first and second bodies.
- TopoDS_Shape* temp_shape = first_shape;
- first_shape = second_shape;
- second_shape = temp_shape;
- OCCBody temp_body1 = *CAST_TO(bodies[size], OCCBody);
- OCCBody temp_body2 = *CAST_TO(bodies.get(), OCCBody);
- BodySM* first_body = bodies.get();
- first_body = &temp_body1;
- BodySM* second_body = bodies[size];
- second_body = &temp_body2;
- }
- check_operation(shapes.First(), first_shape, CUBIT_TRUE, has_changed, &fuser);
- }
- else
- check_operation(shapes.First(), first_shape, CUBIT_FALSE,has_changed, &fuser);
+ check_operation(new_shape, first_shape, first_is_volume, has_changed, &fuser);
+ check_operation(new_shape,second_shape, is_volume[i], has_changed, &fuser);
+/*
BodySM* second_body = bodies.get_and_step();
if(second_body)
{
@@ -3558,7 +3561,9 @@
CUBIT_FALSE);
second_body = NULL;
}
+
TopExp_Explorer Ex;
+ TopTools_ListOfShape shapes;
for (Ex.Init(*second_shape, TopAbs_FACE);Ex.More(); Ex.Next())
{
TopoDS_Face face = TopoDS::Face(Ex.Current());
@@ -3574,9 +3579,11 @@
PRINT_WARNING("The unite boolean didn't work in opencascade.\n");
break;
}
- OCCSurface::update_OCC_entity(face, shapes.First(), &fuser);
+ else if(shapes.Extent() == 1)
+ OCCSurface::update_OCC_entity(face, shapes.First(), &fuser);
}
}
+*/
}
//ok, we're done wih all unites, construct new Body'
@@ -3590,9 +3597,10 @@
newBodies.append(bodysm);
}
- //ok, we're done wih all unites, delete unnecessaries.
+ //ok, we're done with all unites, delete unnecessaries.
if(keep_old)
{
+ shape_list.append(first_shape);
int size = shape_list.size();
for (int i = 0; i < size; i++)
{
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-06-18 01:02:48 UTC (rev 1910)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2008-06-18 19:17:45 UTC (rev 1911)
@@ -1495,19 +1495,25 @@
if(lump != NULL)
{
BodySM* body = CAST_TO(lump, OCCLump)->get_body();
-
+ DLIList<Lump*> lumps = CAST_TO(body, OCCBody)->lumps();
+
if (remove_lower_entities)
return delete_solid_model_entities(body);
DLIList<TopologyBridge*> children;
+ for(int i = 0; i < lumps.size(); i++)
+ {
+ lump = lumps.get_and_step();
CAST_TO(lump, OCCLump)->get_children_virt(children);
+ }
CubitStatus stat = this->unhook_BodySM_from_OCC(body);
if(stat)
{
while (children.size())
delete children.pop();
- delete lump;
+ while(lumps.size())
+ delete lumps.pop();
delete body;
}
return stat;
Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp 2008-06-18 01:02:48 UTC (rev 1910)
+++ cgm/trunk/test/modify.cpp 2008-06-18 19:17:45 UTC (rev 1911)
@@ -607,5 +607,52 @@
free_entities.clean_out();
gti->get_free_ref_entities(free_entities);
+
+ //test unite 1
+ tool_body = gmti->brick(1,1,1);
+ gti->translate(tool_body,v_move7);
+ gti->translate(tool_body,v_move7);
+ from_body = gmti->brick(1,1,1);
+ from_bodies.append(from_body);
+ from_bodies.append(tool_body);
+ new_bodies.clean_out();
+ stat = gmti->unite(from_bodies, new_bodies, CUBIT_FALSE);
+ //Updated volume(s): 49
+ //Destroyed volume(s): 48
+ d = new_bodies.get()->measure(); //d = 2
+ n = new_bodies.get()->num_ref_faces(); //d = 10
+
+ bodies.clean_out();
+ gti->bodies(bodies); //bodies.size() = 1
+ free_entities.clean_out();
+ gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+ //delete all entities
+ gti->delete_Body(bodies);
+ free_entities.clean_out();
+ gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+
+ //test unite 2
+ tool_body = gmti->brick(4, 4,4);
+ gti->translate(tool_body,v_move7);
+ from_body = gmti->brick(1,1,1);
+ from_bodies.clean_out();
+ from_bodies.append(from_body);
+ from_bodies.append(tool_body);
+ new_bodies.clean_out();
+ stat = gmti->unite(from_bodies, new_bodies, CUBIT_FALSE);
+ //Updated volume(s): 51
+ //Destroyed volume(s): 50
+ d = new_bodies.get()->measure(); //d = 65
+ n = new_bodies.get()->num_ref_faces(); //d = 11
+
+ bodies.clean_out();
+ gti->bodies(bodies); //bodies.size() = 1
+ free_entities.clean_out();
+ gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+ //delete all entities
+ gti->delete_Body(bodies);
+ free_entities.clean_out();
+ gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+
return CUBIT_SUCCESS;
}
More information about the cgma-dev
mailing list