[cgma-dev] r3456 - cgm/trunk/test
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Thu Jan 21 17:16:01 CST 2010
Author: kraftche
Date: 2010-01-21 17:16:01 -0600 (Thu, 21 Jan 2010)
New Revision: 3456
Modified:
cgm/trunk/test/webcut.cpp
Log:
Fixes to test/webcut:
o Fix one of the issues when linked with cubit (don't assume order of bodies)
o Improve output so that it is easier to figure out which test failed
o Remove some unnecessary code: abort if file read fails
o Consolidate some duplicate code
Modified: cgm/trunk/test/webcut.cpp
===================================================================
--- cgm/trunk/test/webcut.cpp 2010-01-21 17:04:25 UTC (rev 3455)
+++ cgm/trunk/test/webcut.cpp 2010-01-21 23:16:01 UTC (rev 3456)
@@ -34,7 +34,8 @@
#define XSTRINGIFY(S) #S
// forward declare some functions used and defined later
-CubitStatus read_geometry(int, char **);
+void read_geometry(int, char **);
+void read_model6( Body*& brick, Body*& sheet );
CubitStatus evaluate_overlaps();
CubitStatus imprint_bodies();
CubitStatus print_unmerged_surfaces();
@@ -51,7 +52,7 @@
CubitStatus webcut_with_sweep_surfaces_along_curve();
CubitStatus webcut_with_sweep_surfaces_perp();
// macro for printing a separator line
-#define PRINT_SEPARATOR PRINT_INFO("=======================================\n");
+#define PRINT_SEPARATOR PRINT_INFO("===================%s:%d===================\n",__FILE__,__LINE__);
// main program - initialize, then send to proper function
@@ -91,7 +92,7 @@
///
/// Arguments: file name(s) of geometry files in which to look
///
-CubitStatus read_geometry(int num_files, const char **argv)
+void read_geometry(int num_files, const char **argv)
{
CubitStatus status = CUBIT_SUCCESS;
GeometryQueryTool *gti = GeometryQueryTool::instance();
@@ -99,19 +100,52 @@
int i;
// For each file, open and read the geometry
- PRINT_SEPARATOR;
-
for (i = 0; i < num_files; i++) {
status = gti->import_solid_model(argv[i], "ACIS_SAT");
if (status != CUBIT_SUCCESS) {
PRINT_ERROR("Problems reading geometry file %s.\n", argv[i]);
+ abort();
}
}
- PRINT_SEPARATOR;
- return CUBIT_SUCCESS;
+ if (gti->num_bodies() == 0) {
+ PRINT_ERROR("No bodies read; aborting.\n");
+ abort();
+ }
}
+void read_model6( Body*& volume, Body*& sheet )
+{
+ const char *filename = STRINGIFY(SRCDIR) "/model6.sat";
+ read_geometry( 1, &filename );
+
+ DLIList<Body*> bodies;
+ GeometryQueryTool::instance()->bodies(bodies);
+ volume = sheet = 0;
+ for (int i = 0; i < bodies.size(); ++i, bodies.step()) {
+ DLIList<RefVolume*> vols;
+ bodies.get()->ref_volumes( vols );
+ if (vols.size() != 1) {
+ PRINT_ERROR("Unexpected number of volumes in body read from file: %s\n", filename);
+ abort();
+ }
+ if (vols.get()->is_sheet()) {
+ if (sheet) {
+ PRINT_ERROR("Unexpected number of sheet bodies read from file: %s\n",filename);
+ abort();
+ }
+ sheet = bodies.get();
+ }
+ else {
+ if (volume) {
+ PRINT_ERROR("Unexpected number of non-sheet bodies read from file: %s\n",filename);
+ abort();
+ }
+ volume = bodies.get();
+ }
+ }
+}
+
CubitStatus webcut_with_brick()
{
GeometryQueryTool *gti = GeometryQueryTool::instance();
@@ -119,14 +153,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model2.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
//int num_bodies = gti->num_bodies();
DLIList<Body*> old_bodies, new_bodies;
@@ -151,18 +179,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- DLIList<RefEntity*> free_entities;
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -174,14 +191,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model2.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -202,18 +213,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- DLIList<RefEntity*> free_entities;
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -225,15 +225,9 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model2.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
- exit(ret_val);
- }
-
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
old_bodies.reset();
@@ -255,18 +249,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- DLIList<RefEntity*> free_entities;
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -279,14 +262,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/huge.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -323,18 +300,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- free_entities.clean_out();
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -345,15 +311,9 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model3.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
- exit(ret_val);
- }
-
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
DLIList<RefEntity*> free_entities;
@@ -383,18 +343,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- free_entities.clean_out();
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -405,14 +354,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model3.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -454,18 +397,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- free_entities.clean_out();
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -476,14 +408,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model4.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -511,18 +437,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
- free_entities.clean_out();
- gti->get_free_ref_entities(free_entities);
- gti->delete_Body(bodies);
-
- for (int j = free_entities.size(); j--;)
- {
- gti->delete_RefEntity( free_entities.get_and_step());
- }
-
+ gti->delete_geometry();
return rsl;
}
@@ -533,15 +448,9 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model5.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
- exit(ret_val);
- }
-
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -564,12 +473,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
-
- gti->delete_Body(bodies);
-
+ gti->delete_geometry();
return rsl;
}
@@ -580,14 +484,8 @@
// Read in the geometry from files specified on the command line
const char *argv = STRINGIFY(SRCDIR) "/model7.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ PRINT_SEPARATOR;
+ read_geometry(1, &argv);
DLIList<Body*> old_bodies, new_bodies;
gti->bodies(old_bodies);
@@ -599,8 +497,7 @@
old_bodies.remove()->ref_faces(faces);
CubitVector center(4.0,14.0,14.0);
- CubitVector axis;
- axis.set(0.,-1.,0.);
+ CubitVector axis(0.,-1.,0.);
// set 7th parameter to be false to indicate of to_next_surf = false
CubitStatus rsl= gmti->webcut_with_sweep_surfaces_rotated(old_bodies,faces,center,axis,1.6,NULL,true,new_bodies);
@@ -615,12 +512,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
-
- gti->delete_Body(bodies);
-
+ gti->delete_geometry();
return rsl;
}
@@ -629,29 +521,17 @@
GeometryQueryTool *gti = GeometryQueryTool::instance();
GeometryModifyTool *gmti = GeometryModifyTool::instance();
- // Read in the geometry from files specified on the command line
- const char *argv = STRINGIFY(SRCDIR) "/model6.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ // Read file containing one block and one sheet body
+ PRINT_SEPARATOR;
+ Body *vol, *sheet;
+ read_model6( vol, sheet );
DLIList<Body*> old_bodies, new_bodies;
- gti->bodies(old_bodies);
-
- old_bodies.reset();
-
- old_bodies.step();
-
+ old_bodies.append( vol );
DLIList<RefFace*> faces;
- old_bodies.remove()->ref_faces(faces);
+ sheet->ref_faces( faces );
- CubitVector axis;
- axis.set(1.,0.,0.);
+ CubitVector axis(1.,0.,0.);
CubitStatus rsl= gmti->webcut_with_sweep_surfaces(old_bodies,faces,axis,false,true,false, false,NULL,NULL,new_bodies);
if (rsl== CUBIT_FAILURE)
@@ -665,12 +545,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
-
- gti->delete_Body(bodies);
-
+ gti->delete_geometry();
return rsl;
}
@@ -679,25 +554,15 @@
GeometryQueryTool *gti = GeometryQueryTool::instance();
GeometryModifyTool *gmti = GeometryModifyTool::instance();
- // Read in the geometry from files specified on the command line
- const char *argv = STRINGIFY(SRCDIR) "/model6.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
+ // Read file containing one block and one sheet body
+ PRINT_SEPARATOR;
+ Body *vol, *sheet;
+ read_model6( vol, sheet );
DLIList<Body*> old_bodies, new_bodies;
- gti->bodies(old_bodies);
-
- old_bodies.reset();
- old_bodies.step();
-
+ old_bodies.append( vol );
DLIList<RefFace*> faces;
- old_bodies.remove()->ref_faces(faces);
+ sheet->ref_faces( faces );
//use curve 2 as the sweep along curve
DLIList<RefEdge*> temp_curves;
@@ -709,8 +574,7 @@
edge_to_sweep_along = temp_curves.get_and_step();
}
- CubitVector axis;
- axis.set(1.,0.,0.);
+ CubitVector axis(1.,0.,0.);
CubitStatus rsl= gmti->webcut_with_sweep_surfaces(old_bodies,faces,axis,false, true,false,false,NULL,
edge_to_sweep_along,new_bodies);
@@ -725,12 +589,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
-
- gti->delete_Body(bodies);
-
+ gti->delete_geometry();
return rsl;
}
@@ -739,29 +598,17 @@
GeometryQueryTool *gti = GeometryQueryTool::instance();
GeometryModifyTool *gmti = GeometryModifyTool::instance();
- // Read in the geometry from files specified on the command line
- const char *argv = STRINGIFY(SRCDIR) "/model6.sat";
- CubitStatus status = read_geometry(1, &argv);
- if (status == CUBIT_FAILURE) exit(1);
- else if (gti->num_bodies() == 0) {
- PRINT_WARNING("No bodies read; exiting.\n");
- int ret_val = ( CubitMessage::instance()->error_count() );
-
- exit(ret_val);
- }
-
+ // Read file containing one block and one sheet body
+ PRINT_SEPARATOR;
+ Body *vol, *sheet;
+ read_model6( vol, sheet );
+
DLIList<Body*> old_bodies, new_bodies;
- gti->bodies(old_bodies);
-
- old_bodies.reset();
-
- old_bodies.step();
-
+ old_bodies.append( vol );
DLIList<RefFace*> faces;
- old_bodies.remove()->ref_faces(faces);
+ sheet->ref_faces( faces );
- CubitVector axis;
- axis.set(1.,0.,0.);
+ CubitVector axis(1.,0.,0.);
CubitStatus rsl= gmti->webcut_with_sweep_surfaces(old_bodies,faces,axis,true,true,true, false,NULL,NULL,new_bodies);
if (rsl== CUBIT_FAILURE)
@@ -775,12 +622,7 @@
rsl = gti->export_solid_model(ref_entity_list, filename, filetype,
num_ents_exported, cubit_version);
- //delete all entities
- DLIList<Body*> bodies;
- gti->bodies(bodies);
-
- gti->delete_Body(bodies);
-
+ gti->delete_geometry();
return rsl;
}
More information about the cgma-dev
mailing list