[MOAB-dev] r1295 - MOAB/trunk/tools/iMesh
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Wed Sep 26 12:10:32 CDT 2007
Author: tautges
Date: 2007-09-26 12:10:31 -0500 (Wed, 26 Sep 2007)
New Revision: 1295
Modified:
MOAB/trunk/tools/iMesh/iMesh.h
MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
Adding 2nd order adjacency function, added recently to itaps,
so far only C interface.
Modified: MOAB/trunk/tools/iMesh/iMesh.h
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh.h 2007-09-26 14:56:47 UTC (rev 1294)
+++ MOAB/trunk/tools/iMesh/iMesh.h 2007-09-26 17:10:31 UTC (rev 1295)
@@ -662,6 +662,38 @@
/*out*/ int* offset_size,
/*out*/ int *err);
+/**\brief Get "2nd order" adjacencies to an array of entities
+ * Get "2nd order" adjacencies to an array of entities, that is, from each
+ * entity, through other entities of a specified "bridge" dimension, to other
+ * entities of another specified "to" dimension.
+ *
+ * \param instance iMesh instance for this call
+ * \param entity_handles Entities from which adjacencies are requested
+ * \param entity_handles_size Number of entities whose adjacencies are requested
+ * \param bridge_dimension Bridge dimension for 2nd order adjacencies
+ * \param to_dimension Dimension of adjacent entities returned
+ * \param adj_entity_handles Adjacent entities
+ * \param adj_entity_handles_allocated Allocated size of returned array
+ * \param adj_entity_handles_size Occupied size of returned array
+ * \param offset Offset[i] is offset into adj_entity_handles of 2nd order
+ * adjacencies of ith entity in entity_handles
+ * \param offset_allocated Allocated size of offset array
+ * \param offset_size Occupied size of offset array
+ * \param err
+ */
+ void iMesh_getEntArr2ndAdj( iMesh_Instance instance,
+ iBase_EntityHandle const* entity_handles,
+ int entity_handles_size,
+ int order_adjacent_key,
+ int requested_entity_type,
+ iBase_EntityHandle** adj_entity_handles,
+ int* adj_entity_handles_allocated,
+ int* adj_entity_handles_size,
+ int** offset,
+ int* offset_allocated,
+ int* offset_size,
+ int* err );
+
/**\brief Create an entity set
*
* Create an entity set, either ordered (isList=1) or unordered
@@ -1920,6 +1952,28 @@
/*out*/ int* adj_entity_handles_size,
/*out*/ int *err);
+/**\brief Get "2nd order" adjacencies to an entity
+ * Get "2nd order" adjacencies to an entity, that is, from an entity, through
+ * other entities of a specified "bridge" dimension, to other entities of another
+ * specified "to" dimension.
+ * \param instance iMesh instance for this call
+ * \param entity_handle Entity from which adjacencies are requested
+ * \param bridge_dimension Bridge dimension for 2nd order adjacencies
+ * \param to_dimension Dimension of adjacent entities returned
+ * \param adjacent_entities Adjacent entities
+ * \param adjacent_entities_allocated Allocated size of returned array
+ * \param adjacent_entities_size Occupied size of returned array
+ * \param err
+ */
+ void iMesh_getEnt2ndAdj( iMesh_Instance instance,
+ iBase_EntityHandle entity_handle,
+ int order_adjacent_key,
+ int requested_entity_type,
+ iBase_EntityHandle** adjacent_entities,
+ int* adjacent_entities_allocated,
+ int* adjacent_entities_size,
+ int* err );
+
/**\brief Subtract contents of one entity set from another
*
* Subtract contents of one entity set from another
Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2007-09-26 14:56:47 UTC (rev 1294)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2007-09-26 17:10:31 UTC (rev 1295)
@@ -2,6 +2,7 @@
#include "MBCore.hpp"
#include "MBRange.hpp"
#include "MBCN.hpp"
+#include "MeshTopoUtil.hpp"
#include <iostream>
#define MIN(a,b) (a < b ? a : b)
@@ -1024,6 +1025,62 @@
RETURN(iBase_SUCCESS);
}
+void iMesh_getEntArr2ndAdj( iMesh_Instance instance,
+ iBase_EntityHandle const* entity_handles,
+ int entity_handles_size,
+ int order_adjacent_key,
+ int requested_entity_type,
+ iBase_EntityHandle** adj_entity_handles,
+ int* adj_entity_handles_allocated,
+ int* adj_entity_handles_size,
+ int** offset,
+ int* offset_allocated,
+ int* offset_size,
+ int* err )
+{
+ MBErrorCode result = MB_SUCCESS;
+
+ CHECK_SIZE(*offset, *offset_allocated, entity_handles_size+1,
+ int, iBase_MEMORY_ALLOCATION_FAILED);
+
+ const MBEntityHandle* entity_iter = (const MBEntityHandle*)entity_handles;
+ const MBEntityHandle* const entity_end = entity_iter + entity_handles_size;
+ int* off_iter = *offset;
+ int prev_off = 0;
+
+ std::vector<MBEntityHandle> all_adj_ents;
+ MeshTopoUtil mtu(MBI);
+
+ for ( ; entity_iter != entity_end; ++entity_iter)
+ {
+ *off_iter = prev_off;
+ off_iter++;
+ MBRange adj_ents;
+
+ result = mtu.get_bridge_adjacencies( *entity_iter,
+ order_adjacent_key,
+ requested_entity_type, adj_ents );
+ if (MB_SUCCESS != result) {
+ iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+ RETURN(iBase_ERROR_MAP[result]);
+ }
+
+ std::copy(adj_ents.begin(), adj_ents.end(), std::back_inserter(all_adj_ents));
+ prev_off += adj_ents.size();
+ }
+ *off_iter = prev_off;
+
+ CHECK_SIZE(*adj_entity_handles, *adj_entity_handles_allocated,
+ (int)all_adj_ents.size(),
+ iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+ memcpy(*adj_entity_handles, &all_adj_ents[0],
+ sizeof(MBEntityHandle)*all_adj_ents.size() );
+
+ *adj_entity_handles_size = all_adj_ents.size();
+ *offset_size = entity_handles_size+1;
+ RETURN(iBase_SUCCESS);
+}
+
void iMesh_createEntSet(iMesh_Instance instance,
/*in*/ const int isList,
/*out*/ iBase_EntitySetHandle* entity_set_created, int *err)
@@ -2427,6 +2484,27 @@
&offset_size, err);
}
+void iMesh_getEnt2ndAdj( iMesh_Instance instance,
+ iBase_EntityHandle entity_handle,
+ int order_adjacent_key,
+ int requested_entity_type,
+ iBase_EntityHandle** adj_entities,
+ int* adj_entities_allocated,
+ int* adj_entities_size,
+ int* err )
+{
+ int offsets[2];
+ int *offsets_ptr = offsets;
+ int offset_size, offset_allocated = 2;
+
+ iMesh_getEntArr2ndAdj(instance,
+ &entity_handle, 1, order_adjacent_key,
+ requested_entity_type,
+ adj_entities, adj_entities_allocated,
+ adj_entities_size, &offsets_ptr, &offset_allocated,
+ &offset_size, err);
+}
+
void iMesh_subtract(iMesh_Instance instance,
/*in*/ const iBase_EntitySetHandle entity_set_1,
/*in*/ const iBase_EntitySetHandle entity_set_2,
More information about the moab-dev
mailing list