[MOAB-dev] r3838 - MOAB/trunk/src/io
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Tue May 4 09:48:37 CDT 2010
Author: kraftche
Date: 2010-05-04 09:48:37 -0500 (Tue, 04 May 2010)
New Revision: 3838
Modified:
MOAB/trunk/src/io/Tqdcfr.cpp
MOAB/trunk/src/io/Tqdcfr.hpp
Log:
fail rather than segfaulting when reading unsupported Cubit 12 files
Modified: MOAB/trunk/src/io/Tqdcfr.cpp
===================================================================
--- MOAB/trunk/src/io/Tqdcfr.cpp 2010-05-03 22:30:10 UTC (rev 3837)
+++ MOAB/trunk/src/io/Tqdcfr.cpp 2010-05-04 14:48:37 UTC (rev 3838)
@@ -88,6 +88,8 @@
5, 5, 8, 13, 18, // pyramids
8, 8, 9, 20, 27, 12, // hexes (incl. hexshell at end)
0};
+const int Tqdcfr::cub_elem_num_verts_len =
+ sizeof(cub_elem_num_verts)/sizeof(cub_elem_num_verts[0]);
// Define node-order map from Cubit to CN. Table is indexed
// by EntityType and number of nodes. Entries are NULL if Cubit order
@@ -1680,6 +1682,12 @@
// 4 new trishell element types
if (data_version <= 1.0 && block_headers[i].blockElemType >= 15)
block_headers[i].blockElemType += 4;
+
+ if (block_headers[i].blockElemType >= (unsigned)cub_elem_num_verts_len) {
+ std::cerr << "Invalid block element type: " << block_headers[i].blockElemType << std::endl;
+ instance->readUtilIface->report_error( "Invalid block element type: %d", block_headers[i].blockElemType );
+ return MB_FAILURE;
+ }
// set the material set tag and id tag both to id
result = instance->mdbImpl->tag_set_data(instance->blockTag, &(block_headers[i].setHandle), 1,
Modified: MOAB/trunk/src/io/Tqdcfr.hpp
===================================================================
--- MOAB/trunk/src/io/Tqdcfr.hpp 2010-05-03 22:30:10 UTC (rev 3837)
+++ MOAB/trunk/src/io/Tqdcfr.hpp 2010-05-04 14:48:37 UTC (rev 3838)
@@ -388,6 +388,7 @@
INVALID_ELEMENT_TYPE};
static const EntityType block_type_to_mb_type[];
static const int cub_elem_num_verts[];
+ static const int cub_elem_num_verts_len;
//! mapping from mesh packet type to moab type
static const EntityType mp_type_to_mb_type[];
More information about the moab-dev
mailing list