[MOAB-dev] r2155 - in MOAB/trunk: . tools/iMesh
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Mon Oct 20 13:39:20 CDT 2008
Author: kraftche
Date: 2008-10-20 13:39:20 -0500 (Mon, 20 Oct 2008)
New Revision: 2155
Added:
MOAB/trunk/tools/iMesh/iMesh_MOAB.hpp
Modified:
MOAB/trunk/MBTypes.h
MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp
MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
- Declare some internal iMesh_MOAB data and types in a header so that
they can be used by iMeshP_MOAB
- Remove duplicate data from iMeshP_MOAB (use iMesh_MOAB.hpp instead.)
Modified: MOAB/trunk/MBTypes.h
===================================================================
--- MOAB/trunk/MBTypes.h 2008-10-20 17:50:57 UTC (rev 2154)
+++ MOAB/trunk/MBTypes.h 2008-10-20 18:39:20 UTC (rev 2155)
@@ -73,7 +73,8 @@
MB_TYPE_INTEGER = 1, /**< native 'int' type */
MB_TYPE_DOUBLE = 2, /**< native 'double' type */
MB_TYPE_BIT = 3, /**< mandatory type for tags with MB_TAG_BIT storage */
- MB_TYPE_HANDLE = 4 /**< MBEntityHandle */
+ MB_TYPE_HANDLE = 4, /**< MBEntityHandle */
+ MB_MAX_DATA_TYPE = MB_TYPE_HANDLE
};
/** Used to reference tags; since they're so different from entities, we
Modified: MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp 2008-10-20 17:50:57 UTC (rev 2154)
+++ MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp 2008-10-20 18:39:20 UTC (rev 2155)
@@ -1,4 +1,5 @@
#include "iMeshP.h"
+#include "iMesh_MOAB.hpp"
#include "MBCore.hpp"
#include "MBRange.hpp"
#include "MBCN.hpp"
@@ -17,72 +18,8 @@
#include "mpi.h"
#endif
-/********************* enum conversion tables **************************/
-
-const iBase_ErrorType iBase_ERROR_MAP[] =
-{
- iBase_SUCCESS, // MB_SUCCESS = 0,
- iBase_INVALID_ENTITY_HANDLE, // MB_INDEX_OUT_OF_RANGE,
- iBase_INVALID_ENTITY_TYPE, // MB_TYPE_OUT_OF_RANGE,
- iBase_MEMORY_ALLOCATION_FAILED, // MB_MEMORY_ALLOCATION_FAILED,
- iBase_INVALID_ENTITY_HANDLE, // MB_ENTITY_NOT_FOUND,
- iBase_NOT_SUPPORTED, // MB_MULTIPLE_ENTITIES_FOUND,
- iBase_TAG_NOT_FOUND, // MB_TAG_NOT_FOUND,
- iBase_FILE_NOT_FOUND, // MB_FILE_DOES_NOT_EXIST,
- iBase_FILE_WRITE_ERROR, // MB_FILE_WRITE_ERROR,
- iBase_NOT_SUPPORTED, // MB_NOT_IMPLEMENTED,
- iBase_TAG_ALREADY_EXISTS, // MB_ALREADY_ALLOCATED,
- iBase_FAILURE, // MB_VARIABLE_DATA_LENGTH,
- iBase_FAILURE, // MB_INVALID_SIZE,
- iBase_FAILURE // MB_FAILURE};
-};
-
-// map to MB's entity type from TSTT's entity topology
-const MBEntityType mb_topology_table[] =
-{
- MBVERTEX,
- MBEDGE,
- MBPOLYGON,
- MBTRI,
- MBQUAD,
- MBPOLYHEDRON,
- MBTET,
- MBHEX,
- MBPRISM,
- MBPYRAMID,
- MBMAXTYPE,
- MBMAXTYPE
-};
-
-const iMesh_EntityTopology tstt_topology_table[] =
-{
- iMesh_POINT, // MBVERTEX
- iMesh_LINE_SEGMENT, // MBEDGE
- iMesh_TRIANGLE, // MBTRI
- iMesh_QUADRILATERAL, // MBQUAD
- iMesh_POLYGON, // MBPOLYGON
- iMesh_TETRAHEDRON, // MBTET
- iMesh_PYRAMID, // MBPYRAMID
- iMesh_PRISM, // MBPRISM
- iMesh_ALL_TOPOLOGIES, // MBKNIFE
- iMesh_HEXAHEDRON, // MBHEX
- iMesh_POLYHEDRON, // MBPOLYHEDRON
- iMesh_ALL_TOPOLOGIES, // MBENTITYSET
- iMesh_ALL_TOPOLOGIES, // MBMAXTYPE
-};
-
/********************* Error Handling **************************/
-extern iBase_Error iMesh_LAST_ERROR;
-
-static inline MBInterface* MBI_cast( iMesh_Instance i )
- { return reinterpret_cast<MBInterface*>(i); }
-#define MBI MBI_cast(instance)
-
-#define RETURN(a) do {iMesh_LAST_ERROR.error_type = a; *err = a; return;} while(false)
-
-#define CHKERR(err) if (MB_SUCCESS != (err)) RETURN(iBase_ERROR_MAP[err])
-
#define FIXME printf("Warning: function has incomplete implementation: %s\n", __func__ )
Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2008-10-20 17:50:57 UTC (rev 2154)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2008-10-20 18:39:20 UTC (rev 2155)
@@ -4,6 +4,7 @@
#include "MBCN.hpp"
#include "MeshTopoUtil.hpp"
#include "FileOptions.hpp"
+#include "iMesh_MOAB.hpp"
#ifdef USE_MPI
#include "mpi.h"
@@ -13,28 +14,7 @@
#include <cassert>
#define MIN(a,b) (a < b ? a : b)
-class MBiMesh : public MBCore
-{
-private:
- bool haveDeletedEntities;
-public:
- MBiMesh(int proc_rank = 0, int proc_size = 1);
-
- virtual ~MBiMesh();
- bool have_deleted_ents( bool reset ) {
- bool result = haveDeletedEntities;
- if (reset)
- haveDeletedEntities = false;
- return result;
- }
-
- virtual MBErrorCode delete_mesh();
- virtual MBErrorCode delete_entities( const MBEntityHandle*, const int );
- virtual MBErrorCode delete_entities( const MBRange& );
- int AdjTable[16];
-};
-
-MBiMesh::MBiMesh(int , int )
+MBiMesh::MBiMesh()
: haveDeletedEntities(false)
{
memset(AdjTable, 0, 16*sizeof(int));
@@ -200,10 +180,19 @@
int requestedSize;
};
-#define MBI reinterpret_cast<MBInterface*>(instance)
-#define MBimesh reinterpret_cast<MBiMesh*>(instance)
+iMesh_EntityIterator create_itaps_iterator( MBRange& range, int array_size )
+{
+ RangeIterator* iter = new RangeIterator;
+ if (iter) {
+ iter->iteratorRange.swap(range);
+ iter->currentPos = range.begin();
+ iter->requestedSize = array_size;
+ }
+ return iter;
+}
-#define RETURN(a) {iMesh_LAST_ERROR.error_type = a; *err = a;return;}
+
+
#define iMesh_processError(a, b) {sprintf(iMesh_LAST_ERROR.description, "%s", b); iMesh_LAST_ERROR.error_type = a; *err = a;}
#ifdef __cplusplus
@@ -275,10 +264,7 @@
// mpi not initialized yet - initialize here
retval = MPI_Init(&argc, &argv);
}
- int rank, size;
- MPI_Comm_rank(MPI_COMM_WORLD, &rank);
- MPI_Comm_size(MPI_COMM_WORLD, &size);
- core = new MBiMesh(rank, size);
+ core = new MBiMesh;
#else
//mError->set_last_error( "PARALLEL option not valid, this instance"
// " compiled for serial execution.\n" );
@@ -286,7 +272,7 @@
return;
#endif
}
- else core = new MBiMesh();
+ else core = new MBiMesh;
*instance = reinterpret_cast<iMesh_Instance>(core);
if (0 == *instance) {
@@ -851,25 +837,23 @@
{
MBEntityType req_type = mb_topology_table[requested_entity_topology];
int req_dimension = (req_type == MBMAXTYPE ? (int) requested_entity_type : -1);
- RangeIterator *new_it = new RangeIterator;
- *entArr_iterator = reinterpret_cast<iMesh_EntityIterator>(new_it);
- new_it->requestedSize = requested_array_size;
+ MBRange range;
MBErrorCode result;
if (requested_entity_type == iBase_ALL_TYPES &&
requested_entity_topology == iMesh_ALL_TOPOLOGIES)
result = MBI->get_entities_by_handle( ENTITY_HANDLE(entity_set_handle),
- new_it->iteratorRange );
+ range );
else if (requested_entity_topology == iMesh_SEPTAHEDRON)
result = MB_SUCCESS; // never any septahedrons because MOAB doesn't support them
else if (MBMAXTYPE != req_type)
result = MBI->get_entities_by_type(ENTITY_HANDLE(entity_set_handle),
req_type,
- new_it->iteratorRange);
+ range);
else
result = MBI->get_entities_by_dimension(ENTITY_HANDLE(entity_set_handle),
req_dimension,
- new_it->iteratorRange);
+ range);
if (result != MB_SUCCESS) {
std::string msg("iMesh_initEntArrIter: ERROR getting entities of proper type or topology, "
@@ -880,9 +864,7 @@
RETURN(iMesh_LAST_ERROR.error_type);
}
- new_it->currentPos = new_it->iteratorRange.begin();
- iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
-
+ *entArr_iterator = create_itaps_iterator( range, requested_array_size );
RETURN(iBase_SUCCESS);
}
Added: MOAB/trunk/tools/iMesh/iMesh_MOAB.hpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.hpp (rev 0)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.hpp 2008-10-20 18:39:20 UTC (rev 2155)
@@ -0,0 +1,66 @@
+#ifndef IMESH_MOAB_HPP
+#define IMESH_MOAB_HPP
+
+#include "iMesh.h"
+#include "MBForward.hpp"
+
+/* map from MB's entity type to TSTT's entity topology */
+extern const iMesh_EntityTopology tstt_topology_table[MBMAXTYPE+1];
+
+/* map from MB's entity type to TSTT's entity type */
+extern const iBase_EntityType tstt_type_table[MBMAXTYPE+1];
+
+/* map to MB's entity type from TSTT's entity topology */
+extern const MBEntityType mb_topology_table[MBMAXTYPE+1];
+
+/* map from TSTT's tag types to MOAB's */
+extern const MBDataType mb_data_type_table[4];
+
+/* map from MOAB's tag types to tstt's */
+extern const iBase_TagValueType tstt_data_type_table[MB_MAX_DATA_TYPE+1];
+
+/* map from MOAB's MBErrorCode to tstt's */
+extern const iBase_ErrorType iBase_ERROR_MAP[MB_FAILURE+1];
+
+/* Create ITAPS iterator */
+iMesh_EntityIterator create_itaps_iterator( MBRange& swap_range,
+ int array_size = 1 );
+
+/* Define macro for quick reference to MBInterface instance */
+static inline MBInterface* MBI_cast( iMesh_Instance i )
+ { return reinterpret_cast<MBInterface*>(i); }
+#define MBI MBI_cast(instance)
+
+/* Most recently returned error code */
+extern "C" iBase_Error iMesh_LAST_ERROR;
+
+#define RETURN(a) do {iMesh_LAST_ERROR.error_type = a; *err = a; return;} while(false)
+
+#define CHKERR(err) if (MB_SUCCESS != (err)) RETURN(iBase_ERROR_MAP[err])
+
+#include "MBCore.hpp"
+
+class MBiMesh : public MBCore
+{
+private:
+ bool haveDeletedEntities;
+public:
+ MBiMesh();
+
+ virtual ~MBiMesh();
+ bool have_deleted_ents( bool reset ) {
+ bool result = haveDeletedEntities;
+ if (reset)
+ haveDeletedEntities = false;
+ return result;
+ }
+
+ virtual MBErrorCode delete_mesh();
+ virtual MBErrorCode delete_entities( const MBEntityHandle*, const int );
+ virtual MBErrorCode delete_entities( const MBRange& );
+ int AdjTable[16];
+};
+
+#define MBimesh reinterpret_cast<MBiMesh*>(MBI)
+
+#endif // IMESH_MOAB_HPP
More information about the moab-dev
mailing list