[MOAB-dev] r1888 - in MOAB/trunk: . parallel test tools/iMesh

tautges at mcs.anl.gov tautges at mcs.anl.gov
Tue Jun 10 15:20:17 CDT 2008


Author: tautges
Date: 2008-06-10 15:20:16 -0500 (Tue, 10 Jun 2008)
New Revision: 1888

Added:
   MOAB/trunk/tools/iMesh/iMeshP.h
   MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp
   MOAB/trunk/tools/iMesh/iMeshP_f.h
   MOAB/trunk/tools/iMesh/iMeshP_protos.h
Modified:
   MOAB/trunk/MBParallelConventions.h
   MOAB/trunk/configure.in
   MOAB/trunk/parallel/MBParallelComm.cpp
   MOAB/trunk/parallel/MBParallelComm.hpp
   MOAB/trunk/parallel/ReadParallel.cpp
   MOAB/trunk/test/brick_cubit10.cub
   MOAB/trunk/tools/iMesh/Makefile.am
   MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
First crack at implementing (some of) the ITAPS parallel interface
iMeshP, along with a few other things.

iMesh_MOAB.cpp: move several things within the extern "C" braces.
Indent this file to account for those braces.

tools/iMesh/Makefile.am: add iMeshP stuff

configure.in: make mcnpmit off by default

MBParallelConventions.h: changing the PSTATUS tag definitions a bit.

parallel/MBParallelComm.?pp: Moving around some of the functionality,
mostly to make the interface closer to something usable to others

parallel/ReadParallel.cpp: fixing typo in variable name for ghost
option


Modified: MOAB/trunk/MBParallelConventions.h
===================================================================
--- MOAB/trunk/MBParallelConventions.h	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/MBParallelConventions.h	2008-06-10 20:20:16 UTC (rev 1888)
@@ -54,17 +54,19 @@
 /** \brief Tag storing parallel status (as bits in this tag)
  *
  * This tag stores various aspects of parallel status in bits; see also 
- * #define's following, to be used in bit mask operations
+ * #define's following, to be used in bit mask operations.  If an entity is
+ * not shared with any other processors, the pstatus is 0, otherwise it's > 0
  *
- * bit 0: shared (0=not shared, 1=shared)
- * bit 1: !owned (0=owned, 1=not owned)
+ * bit 0: !owned (0=owned, 1=not owned)
+ * bit 1: interface (0=not interface, 1=interface)
  * bit 2: ghost (0=not ghost, 1=ghost)
  */
 #define PARALLEL_STATUS_TAG_NAME "PARALLEL_STATUS"
 
-#define PSTATUS_SHARED 0x1
-#define PSTATUS_NOT_OWNED 0x2
-#define PSTATUS_GHOST 0x4
+#define PSTATUS_NOT_OWNED 0x0
+#define PSTATUS_SHARED 0x2
+#define PSTATUS_INTERFACE 0x4
+#define PSTATUS_GHOST 0x8
  
 /** \brief Tag storing interface sets
  *

Modified: MOAB/trunk/configure.in
===================================================================
--- MOAB/trunk/configure.in	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/configure.in	2008-06-10 20:20:16 UTC (rev 1888)
@@ -242,7 +242,7 @@
 MB_OPTIONAL_TOOL([mbsize],       [yes])
 MB_OPTIONAL_TOOL([mbskin],       [yes])
 MB_OPTIONAL_TOOL([mbtagprop],    [yes])
-MB_OPTIONAL_TOOL([mcnpmit],      [yes])
+MB_OPTIONAL_TOOL([mcnpmit],      [no])
 MB_OPTIONAL_TOOL([mbcoupler],    [$ENABLE_mcnpmit] )
 MB_OPTIONAL_TOOL([spheredecomp], [yes])
 MB_OPTIONAL_TOOL([mbsurfplot],   [yes])

Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/parallel/MBParallelComm.cpp	2008-06-10 20:20:16 UTC (rev 1888)
@@ -2197,10 +2197,9 @@
   MBRange proc_ents;
       // get the entities in the partition sets
   MBRange part_sets;
-  MBTag part_tag = partition_tag();
-  result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &part_tag,
-                                                NULL, 1, part_sets);
-  if (MB_SUCCESS != result) return result;
+  result = get_partition_sets(part_sets);
+  RRA(" ");
+  
   for (MBRange::iterator rit = part_sets.begin(); rit != part_sets.end(); rit++) {
     MBRange tmp_ents;
     result = mbImpl->get_entities_by_handle(*rit, tmp_ents, true);
@@ -2428,6 +2427,41 @@
   return result;
 }
 
+MBErrorCode MBParallelComm::set_pstatus_entities(MBRange &pstatus_ents,
+                                                 unsigned char pstatus_val,
+                                                 bool lower_dim_ents,
+                                                 bool verts_too,
+                                                 int operation) 
+{
+  std::vector<unsigned char> pstatus_vals(pstatus_ents.size());
+  MBRange all_ents, *range_ptr = &pstatus_ents;
+  MBErrorCode result;
+  if (lower_dim_ents || verts_too) {
+    all_ents = pstatus_ents;
+    range_ptr = &all_ents;
+    int start_dim = (lower_dim_ents ? mbImpl->dimension_from_handle(*pstatus_ents.rbegin())-1 : 0);
+    for (; start_dim >= 0; start_dim--) {
+      result = mbImpl->get_adjacencies(all_ents, start_dim, true, all_ents,
+                                       MBInterface::UNION);
+      RRA(" ");
+    }
+  }
+  if (MBInterface::UNION == operation) {
+    result = mbImpl->tag_get_data(pstatus_tag(), *range_ptr, &pstatus_vals[0]);
+    RRA("Couldn't get pstatus tag value.");
+    for (unsigned int i = pstatus_ents.size()-1; i >= 0; i--)
+      pstatus_vals[i] |= pstatus_val;
+  }
+  else {
+    for (unsigned int i = pstatus_ents.size()-1; i >= 0; i--)
+      pstatus_vals[i] = pstatus_val;
+  }
+  result = mbImpl->tag_set_data(pstatus_tag(), *range_ptr, &pstatus_vals[0]);
+  RRA("Couldn't set pstatus tag value.");
+  
+  return MB_SUCCESS;
+}
+  
 MBErrorCode MBParallelComm::create_interface_sets(std::map<std::vector<int>, MBRange> &proc_nranges,
                                                   int resolve_dim, int shared_dim,
                                                   MBRange *iface_sets_ptr) 
@@ -2480,7 +2514,7 @@
 
       // get the owning proc, then set the pstatus tag on iface set
     int min_proc = ((*mit).first)[0];
-    unsigned char pstatus = PSTATUS_SHARED;
+    unsigned char pstatus = (PSTATUS_SHARED | PSTATUS_INTERFACE);
     if (min_proc < (int) procConfig.proc_rank()) pstatus |= PSTATUS_NOT_OWNED;
     result = mbImpl->tag_set_data(pstatus_tag, &new_set, 1, &pstatus); 
     RRA("Failed to tag interface set with pstatus.");
@@ -2757,7 +2791,7 @@
 {
   MBRange iface_sets;
   std::vector<int> iface_procs;
-  MBErrorCode result = get_iface_sets_procs(iface_sets, iface_procs);
+  MBErrorCode result = get_interface_sets_procs(iface_sets, iface_procs);
   RRA("Failed to get iface sets/procs.");
   
   for (MBRange::iterator rit = iface_sets.begin(); rit != iface_sets.end(); rit++) {
@@ -2771,6 +2805,82 @@
   return MB_SUCCESS;
 }
 
+  //! return partition sets; if tag_name is input, gets sets with
+  //! that tag name, otherwise uses PARALLEL_PARTITION tag
+MBErrorCode MBParallelComm::get_partition_sets(MBRange &part_sets,
+                                               const char *tag_name) 
+{
+  MBErrorCode result;
+  
+  if (NULL != tag_name) {
+    result = MB_NOT_IMPLEMENTED;
+    RRA("Specified tag name not yet implemented.");
+  }
+    
+  MBTag part_tag = partition_tag();
+  result = mbImpl->get_entities_by_type_and_tag(0, MBENTITYSET, &part_tag,
+                                                NULL, 1, part_sets);
+  return result;
+}
+
+  //! get communication interface sets and the processors with which
+  //! this processor communicates; sets are sorted by processor
+MBErrorCode MBParallelComm::get_interface_sets_procs(MBRange &iface_sets,
+                                                     std::vector<int> &iface_procs)
+{
+  MBTag iface_tag = iface_sets_tag();
+  if (0 == iface_tag) return MB_FAILURE;
+
+    // make sure the sharing procs vector is empty
+  iface_procs.clear();
+
+    // get the iface sets, which are stored on the instance
+  int tag_sz;
+  MBErrorCode result = mbImpl->tag_get_size(iface_tag, tag_sz);
+  RRA("Failed to get iface tag size.");
+  tag_sz /= sizeof(MBEntityHandle);
+  std::vector<MBEntityHandle> iface_sets_vec(tag_sz);
+  result = mbImpl->tag_get_data(iface_tag, NULL, 0, &iface_sets_vec[0]);
+  RRA("Failed to find iface tag.");
+    // can do a straight copy because ranges don't keep 0-values
+  std::copy(iface_sets_vec.begin(), iface_sets_vec.end(), 
+            mb_range_inserter(iface_sets));
+
+    // pre-load vector of single-proc tag values
+  unsigned int i, j;
+  std::vector<int> iface_proc(iface_sets.size());
+  result = mbImpl->tag_get_data(sharedp_tag(), iface_sets, &iface_proc[0]);
+  RRA("Failed to get iface_proc for iface sets.");
+
+    // get sharing procs either from single-proc vector or by getting
+    // multi-proc tag value
+  int tmp_iface_procs[MAX_SHARING_PROCS];
+  std::set<int> procs_set;
+  std::fill(tmp_iface_procs, tmp_iface_procs+MAX_SHARING_PROCS, -1);
+  MBRange::iterator rit;
+  for (rit = iface_sets.begin(), i = 0; rit != iface_sets.end(); rit++, i++) {
+    if (-1 != iface_proc[i]) procs_set.insert(iface_proc[i]);
+    else {
+        // get the sharing_procs tag
+      result = mbImpl->tag_get_data(sharedps_tag(), &(*rit), 1,
+                                    tmp_iface_procs);
+      RRA("Failed to get iface_procs for iface set.");
+      for (j = 0; j < MAX_SHARING_PROCS; j++) {
+        if (-1 != tmp_iface_procs[j]) procs_set.insert(tmp_iface_procs[j]);
+        else {
+          std::fill(tmp_iface_procs, tmp_iface_procs+j, -1);
+          break;
+        }
+      }
+    }
+  }
+
+    // now put the set contents into the vector
+  std::copy(procs_set.begin(), procs_set.end(), std::back_inserter(iface_procs));
+  
+  return MB_SUCCESS;
+}
+  
 MBErrorCode MBParallelComm::get_pstatus_entities(int dim,
                                                  unsigned char pstatus_val,
                                                  MBRange &pstatus_ents)
@@ -2787,11 +2897,19 @@
   RRA("Couldn't get pastatus tag.");
   MBRange::iterator rit = ents.begin();
   int i = 0;
-  for (; rit != ents.end(); i++, rit++)
-    if (pstatus[i]&pstatus_val &&
-        (-1 == dim || mbImpl->dimension_from_handle(*rit) == dim)) 
-      pstatus_ents.insert(*rit);
-
+  if (pstatus_val) {
+    for (; rit != ents.end(); i++, rit++)
+      if (pstatus[i]&pstatus_val &&
+          (-1 == dim || mbImpl->dimension_from_handle(*rit) == dim)) 
+        pstatus_ents.insert(*rit);
+  }
+  else {
+    for (; rit != ents.end(); i++, rit++)
+      if (!pstatus[i] &&
+          (-1 == dim || mbImpl->dimension_from_handle(*rit) == dim)) 
+        pstatus_ents.insert(*rit);
+  }
+  
   return MB_SUCCESS;
 }
 
@@ -2857,62 +2975,6 @@
   return MB_SUCCESS;
 }
 
-MBErrorCode MBParallelComm::get_iface_sets_procs(MBRange &iface_sets,
-                                                 std::vector<int> &sharing_procs) 
-{
-  MBTag iface_tag = iface_sets_tag();
-  if (0 == iface_tag) return MB_FAILURE;
-
-    // make sure the sharing procs vector is empty
-  sharing_procs.clear();
-
-    // get the iface sets, which are stored on the instance
-  int tag_sz;
-  MBErrorCode result = mbImpl->tag_get_size(iface_tag, tag_sz);
-  RRA("Failed to get iface tag size.");
-  tag_sz /= sizeof(MBEntityHandle);
-  std::vector<MBEntityHandle> iface_sets_vec(tag_sz);
-  result = mbImpl->tag_get_data(iface_tag, NULL, 0, &iface_sets_vec[0]);
-  RRA("Failed to find iface tag.");
-    // can do a straight copy because ranges don't keep 0-values
-  std::copy(iface_sets_vec.begin(), iface_sets_vec.end(), 
-            mb_range_inserter(iface_sets));
-
-    // pre-load vector of single-proc tag values
-  unsigned int i, j;
-  std::vector<int> iface_proc(iface_sets.size());
-  result = mbImpl->tag_get_data(sharedp_tag(), iface_sets, &iface_proc[0]);
-  RRA("Failed to get iface_proc for iface sets.");
-
-    // get sharing procs either from single-proc vector or by getting
-    // multi-proc tag value
-  int iface_procs[MAX_SHARING_PROCS];
-  std::set<int> procs_set;
-  std::fill(iface_procs, iface_procs+MAX_SHARING_PROCS, -1);
-  MBRange::iterator rit;
-  for (rit = iface_sets.begin(), i = 0; rit != iface_sets.end(); rit++, i++) {
-    if (-1 != iface_proc[i]) procs_set.insert(iface_proc[i]);
-    else {
-        // get the sharing_procs tag
-      result = mbImpl->tag_get_data(sharedps_tag(), &(*rit), 1,
-                                    &iface_procs[0]);
-      RRA("Failed to get iface_procs for iface set.");
-      for (j = 0; j < MAX_SHARING_PROCS; j++) {
-        if (-1 != iface_procs[j]) procs_set.insert(iface_procs[j]);
-        else {
-          std::fill(iface_procs, iface_procs+j, -1);
-          break;
-        }
-      }
-    }
-  }
-
-    // now put the set contents into the vector
-  std::copy(procs_set.begin(), procs_set.end(), std::back_inserter(sharing_procs));
-  
-  return MB_SUCCESS;
-}
-
 bool MBParallelComm::is_iface_proc(MBEntityHandle this_set,
                                    int to_proc) 
 {
@@ -2998,7 +3060,7 @@
     // get all procs interfacing to this proc
   MBRange iface_sets;
   std::vector<int> iface_procs;
-  result = get_iface_sets_procs(iface_sets, iface_procs);
+  result = get_interface_sets_procs(iface_sets, iface_procs);
   RRA("Failed to get iface sets, procs");
 
     // post ghost irecv's for all interface procs

Modified: MOAB/trunk/parallel/MBParallelComm.hpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.hpp	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/parallel/MBParallelComm.hpp	2008-06-10 20:20:16 UTC (rev 1888)
@@ -26,6 +26,7 @@
 #define MB_PARALLEL_COMM_HPP
 
 #include "MBForward.hpp"
+#include "MBInterface.hpp"
 #include "MBRange.hpp"
 #include "MBProcConfig.hpp"
 #include <map>
@@ -191,6 +192,22 @@
                                    unsigned char pstatus_val,
                                    MBRange &pstatus_ents);
   
+    /** \brief Set pstatus values on entities
+     *
+     * \param pstatus_ents Entities to be set
+     * \param pstatus_val Pstatus value to be set
+     * \param lower_dim_ents If true, lower-dimensional ents (incl. vertices) set too
+     *        (and created if they don't exist)
+     * \param verts_too If true, vertices also set
+     * \param operation If UNION, pstatus_val is OR-d with existing value, otherwise
+     *        existing value is over-written
+     */
+  MBErrorCode set_pstatus_entities(MBRange &pstatus_ents,
+                                   unsigned char pstatus_val,
+                                   bool lower_dim_ents = false,
+                                   bool verts_too = true,
+                                   int operation = MBInterface::UNION);
+  
     /** \brief Get entities on an inter-processor interface and of specified dimension
      * If other_proc is -1, any interface entities are returned.  If dim is -1,
      * entities of all dimensions on interface are returned.
@@ -202,6 +219,16 @@
                                  int dim,
                                  MBRange &iface_ents);
   
+    //! return partition sets; if tag_name is input, gets sets with
+    //! that tag name, otherwise uses PARALLEL_PARTITION tag
+  MBErrorCode get_partition_sets(MBRange &part_sets,
+                                 const char *tag_name = NULL);
+
+    //! get communication interface sets and the processors with which
+    //! this processor communicates; sets are sorted by processor
+  MBErrorCode get_interface_sets_procs(MBRange &iface_sets,
+                                       std::vector<int> &iface_procs);
+  
     //! pack the buffer with ALL data for orig_ents; return entities actually
     //! packed (including reference sub-entities) in final_ents
   MBErrorCode pack_buffer(MBRange &orig_ents,
@@ -482,10 +509,6 @@
                               int remote_proc,
                               MBEntityHandle remote_handle);
   
-    //! returns the interface sets and union of sharing procs
-  MBErrorCode get_iface_sets_procs(MBRange &iface_sets,
-                                   std::vector<int> &sharing_procs);
-  
     //! MB interface associated with this writer
   MBInterface *mbImpl;
 
@@ -514,16 +537,6 @@
     //! tags used to save sharing procs and handles
   MBTag sharedpTag, sharedpsTag, sharedhTag, sharedhsTag, pstatusTag, 
     ifaceSetsTag, partitionTag;
-
-    //! interface sets, one set per unique combination of procs
-  MBRange ifaceSets;
-  
-    //! ghost sets (sets of ghost entities), one set per unique combination of procs
-  MBRange ghostSets;
-  
-    //! ghosted sets (sets of ghosted entities), one set per unique combination of procs
-  MBRange ghostedSets;
-  
 };
 
 inline MBErrorCode MBParallelComm::get_shared_proc_tags(MBTag &sharedp,

Modified: MOAB/trunk/parallel/ReadParallel.cpp
===================================================================
--- MOAB/trunk/parallel/ReadParallel.cpp	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/parallel/ReadParallel.cpp	2008-06-10 20:20:16 UTC (rev 1888)
@@ -106,7 +106,7 @@
   }
   else if (MB_SUCCESS == result) {
     int num_fields = 
-      sscanf(ghost_str.c_str(), "%d.%d", &resolve_dim, &shared_dim);
+      sscanf(shared_str.c_str(), "%d.%d", &resolve_dim, &shared_dim);
     if (2 != num_fields) {
       merror->set_last_error( "Didn't read 2 fields from PARALLEL_RESOLVE_SHARED_ENTS string\n" );
       return MB_FAILURE;

Modified: MOAB/trunk/test/brick_cubit10.cub
===================================================================
(Binary files differ)

Modified: MOAB/trunk/tools/iMesh/Makefile.am
===================================================================
--- MOAB/trunk/tools/iMesh/Makefile.am	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/tools/iMesh/Makefile.am	2008-06-10 20:20:16 UTC (rev 1888)
@@ -16,18 +16,12 @@
 check_PROGRAMS = testc_cbind
 testc_cbind_SOURCES = testc_cbind.c
 
-if PARALLEL
-  check_PROGRAMS += partest
-  partest_SOURCES = partest.cpp
-  partest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
-endif
-
 LDADD = libiMesh.la $(top_builddir)/libMOAB.la ${MOAB_CXX_LDFLAGS} ${MOAB_CXX_LIBS}
 testc_cbind_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la
 
 libiMesh_la_SOURCES = \
 	iMesh_MOAB.cpp
-                   
+
 libiMesh_la_include_HEADERS = iMesh.h \
                              iMesh_extensions.h \
                              iMesh_extensions_protos.h \
@@ -36,6 +30,15 @@
                              iBase.h \
                              iBase_f.h 
 
+if PARALLEL
+  libiMesh_la_SOURCES += iMeshP_MOAB.cpp
+  libiMesh_la_include_HEADERS += iMeshP.h iMeshP_f.h iMeshP_protos.h
+  INCLUDES += -I$(top_srcdir)/parallel
+  check_PROGRAMS += partest
+  partest_SOURCES = partest.cpp
+  partest_DEPENDENCIES = libiMesh.la $(top_builddir)/libMOAB.la 
+endif
+
 lib_LTLIBRARIES = libiMesh.la
 
 libiMesh_la_includedir = $(includedir)

Added: MOAB/trunk/tools/iMesh/iMeshP.h
===================================================================
--- MOAB/trunk/tools/iMesh/iMeshP.h	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/iMeshP.h	2008-06-10 20:20:16 UTC (rev 1888)
@@ -0,0 +1,191 @@
+#ifndef IMESHP_H__
+#define IMESHP_H__
+
+  /** \mainpage The ITAPS Parallel Mesh Interface iMesh
+   *
+   */
+
+#ifndef ITAPS
+#define ITAPS
+#endif
+
+#include "iMesh_extensions.h"
+#include "iMeshP_protos.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /**\brief  Type used to store a part handle
+     *
+     * Type used to store a part handle
+     */
+  typedef void* iMeshP_PartHandle;
+
+    /**\brief  Type used to store a partition handle
+     *
+     * Type used to store a partition handle
+     */
+  typedef void* iMeshP_PartitionHandle;
+
+  const int iMeshP_INTERNAL = 0;
+  const int iMeshP_BOUNDARY = 1;
+  const int iMeshP_GHOST = 2;
+  
+// Given a partition handle, return the total global number of parts 
+// in the partition.
+//  COMMUNICATION:  None++.
+  void iMeshP_getNumParts(iMesh_Instance instance,
+                          const iMeshP_PartitionHandle partition_handle,
+                          int *num_global_part, 
+                          int *err); 
+
+//  Map from parts to processes:  
+//  Given a partition handle and a part handle, return the rank of the 
+//  process that owns the part.
+//  The part_handle may be local or remote.
+//  COMMUNICATION:  None++.
+  void iMeshP_getRankOfPart(iMesh_Instance instance,
+                            const iMeshP_PartitionHandle partition_handle,
+                            /*in*/    const iMeshP_PartHandle part_handle,
+                            /*out*/   int *rank,
+                            int *err); 
+  void iMeshP_getRankOfPartArr(iMesh_Instance instance,
+                               const iMeshP_PartitionHandle partition_handle,
+                               /*in*/    const iMeshP_PartHandle *part_handle,
+                               /*in*/    const int part_handle_size,
+                               /*inout*/ int **rank, 
+                               /*inout*/ int *rank_allocated, 
+                               int *err); 
+
+//  Map from processes to parts:  
+//  Given a partition handle and a process rank,
+//  return the part handles owned by the process.
+//  COMMUNICATION:  None++.
+  void iMeshP_getPartsOnRank(iMesh_Instance instance,
+                             const iMeshP_PartitionHandle partition_handle,
+                             /*in*/    const int rank,
+                             /*inout*/ iMeshP_PartHandle **part_handles, 
+                             /*inout*/ int *part_handles_allocated, 
+                             /*out*/   int *part_handles_size, 
+                             int *err); 
+  void iMeshP_getPartsArrOnRank(iMesh_Instance instance,
+                                const iMeshP_PartitionHandle partition_handle,
+                                /*in*/    const int *rank,
+                                /*in*/    const int rank_size,
+                                /*inout*/ iMeshP_PartHandle **part_handles, 
+                                /*inout*/ int *part_handles_allocated, 
+                                /*out*/   int *part_handles_size, 
+                                int *err); 
+
+//  Provide global mesh information about a partition.  
+//  Note that these functions may require communication and, thus, 
+//  would have to be called by all processes in the partition handle.
+//  Given a mesh instance and partition handle, return the
+//  total number of entities with given type or topology in the partition.
+//  COMMUNICATION:  Collective.
+  void iMeshP_getNumOfTypeAll(iMesh_Instance instance,
+                              const iMeshP_PartitionHandle partition_handle,
+                              const iBase_EntitySetHandle entity_set_handle,
+                              const int entity_type, int *num_type, int *err);
+  void iMeshP_getNumOfTopoAll(iMesh_Instance instance,
+                              const iMeshP_PartitionHandle partition_handle,
+                              const iBase_EntitySetHandle entity_set_handle,
+                              const int entity_topology, int *num_topo, int *err);
+
+
+// Given a partition handle and a part handle, test whether the part
+// handle refers to a local or remote part, and whether it is valid.
+  void iMeshP_testPart(iMesh_Instance instance,
+                       /* in */ iMeshP_PartitionHandle partition_handle,
+                       /* in */ iMeshP_PartHandle part_handle,
+                       /* out */ int *part_status, /* LOCAL, REMOTE, INVALID */
+                       int *err);
+ 
+//  Provide part information about an entity: Given an entity and a 
+//  partition handle, return the part handle of the part that owns the entity.
+//  Return an error code if an entity is not in the partition.
+//  COMMUNICATION:  None++.
+  void iMeshP_getEntOwnerPart(iMesh_Instance instance,
+                              /*in*/  const iMeshP_PartitionHandle partition_handle, 
+                              /*in*/  iBase_EntityHandle entity_handle,
+                              /*out*/  iMeshP_PartHandle *part_handle,
+                              int* err); 
+  void iMeshP_getEntOwnerPartArr(iMesh_Instance instance,
+                                 /*in*/  const iMeshP_PartitionHandle partition_handle, 
+                                 /*in*/  iBase_EntityHandle *entity_handles,
+                                 /*in*/  int entity_handles_size,
+                                 /*inout*/  iMeshP_PartHandle **part_handles,
+                                 /*inout*/  int *part_handles_allocated,
+                                 int* err); 
+  
+//  Provide entity categorization within part.
+//  Given a partition handle, a part handle, and an entity handle, return a
+//  flag indicating whether the entity is owned by the part.
+//  If part_handle is remote, an error is returned.
+//  COMMUNICATION:  None.
+  void iMeshP_isEntOwner(iMesh_Instance instance,
+                         /*in*/ const iMeshP_PartHandle part_handle, 
+                         /*in*/ const iBase_EntityHandle entity_handle, 
+                         /*out*/ int* is_owner, 
+                         int *err); 
+  void iMeshP_isEntOwnerArr(iMesh_Instance instance,
+                            /*in*/ const iMeshP_PartHandle part_handle, 
+                            /*in*/ const iBase_EntityHandle *entity_handles, 
+                            /*in*/ const int entity_handles_size, 
+                            /*inout*/ int** is_owner, 
+                            /*inout*/ int* is_owner_allocated, 
+                            /*inout*/ int* is_owner_size, 
+                            int *err); 
+
+//  Given a partition handle, a part handle, and an entity handle, return a
+//  flag indicating whether the entity is strictly internal, on a 
+//  boundary, or a ghost.
+//  If part_handle is remote, an error is returned.
+//  COMMUNICATION:  None.
+  void iMeshP_getEntStatus(iMesh_Instance instance,
+                           /*in*/ const iMeshP_PartHandle part_handle, 
+                           /*in*/ const iBase_EntityHandle entity_handle, 
+                           /*out*/ int* par_status, // Values=INTERNAL,BOUNDARY,GHOST
+                           int *err); 
+  void iMeshP_getEntStatusArr(iMesh_Instance instance,
+                              /*in*/ const iMeshP_PartHandle part_handle, 
+                              /*in*/ const iBase_EntityHandle *entity_handles, 
+                              /*in*/ const int entity_handles_size, 
+                              /*inout*/ int** par_status, // Values=INTERNAL,BOUNDARY,GHOST
+                              /*inout*/ int* par_status_allocated, 
+                              /*inout*/ int* par_status_size, 
+                              int *err); 
+
+//  Provide information about copies of entities.  
+//  All these functions should work on the local process as well as 
+//  remote processes; entity handles returned are likely but not 
+//  necessarily remote. 
+//  Given a partition handle and an entity handle, return the number 
+//  of copies of the entity in the partition.
+//  COMMUNICATION:  None++.
+  void iMeshP_getNumCopies(iMesh_Instance instance,
+                           /*in*/ const iMeshP_PartitionHandle partition_handle, 
+                           /*in*/ const iBase_EntityHandle entity_handle, 
+                           /*out*/ int *num_copies_ent,
+                           int *err); 
+
+//  Given a partition handle and an entity handle, return (remote) entity
+//  handles and part handles of all copies of the entity.
+//  COMMUNICATION:  None++.
+  void iMeshP_getCopies(iMesh_Instance instance,
+                        /*in*/ const iMeshP_PartitionHandle partition_handle, 
+                        /*in*/ const iBase_EntityHandle entity_handle, 
+                        /*inout*/ iMeshP_PartHandle **part_handles, 
+                        /*inout*/ int *part_handles_allocated, 
+                        /*out*/ int *part_handles_size, 
+                        /*inout*/ iBase_EntityHandle **copies_entity_handles, 
+                        /*inout*/ int *copies_entity_handles_allocated, 
+                        /*inout*/ int *copies_entity_handles_size, 
+                        int *err); 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/iMeshP_MOAB.cpp	2008-06-10 20:20:16 UTC (rev 1888)
@@ -0,0 +1,343 @@
+#include "iMeshP.h"
+#include "MBCore.hpp"
+#include "MBRange.hpp"
+#include "MBCN.hpp"
+#include "MeshTopoUtil.hpp"
+#include "FileOptions.hpp"
+#include "MBParallelComm.hpp"
+#include "MBParallelConventions.h"
+
+#ifdef USE_MPI    
+#include "mpi.h"
+#endif
+
+#define MBI reinterpret_cast<MBInterface*>(instance)
+
+#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;}
+
+#define CHECK_SIZE(array, allocated, size, type, retval)  \
+  if (0 != allocated && NULL != array && allocated < (size)) {\
+    iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
+          "Allocated array not large enough to hold returned contents.");\
+    RETURN(iBase_MEMORY_ALLOCATION_FAILED);\
+  }\
+  if (allocated == 0 || NULL == array) {\
+    array = (type*)malloc((size)*sizeof(type));\
+    allocated=(size);\
+    if (NULL == array) {iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
+          "Couldn't allocate array.");RETURN(iBase_MEMORY_ALLOCATION_FAILED); }\
+  }
+// TAG_CHECK_SIZE is like CHECK_SIZE except it checks for and makes the allocated memory
+// size a multiple of sizeof(void*), and the pointer is assumed to be type char*
+#define TAG_CHECK_SIZE(array, allocated, size)  \
+  if (0 != allocated && NULL != array && allocated < (size)) {\
+    iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
+          "Allocated array not large enough to hold returned contents.");\
+    RETURN(iBase_MEMORY_ALLOCATION_FAILED);\
+  }\
+  if (NULL == array || allocated == 0) {\
+    allocated=(size); \
+    if (allocated%sizeof(void*) != 0) allocated=((size)/sizeof(void*)+1)*sizeof(void*);\
+    array = (char*)malloc(allocated); \
+    if (NULL == array) {iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
+          "Couldn't allocate array.");RETURN(iBase_MEMORY_ALLOCATION_FAILED); }\
+  }
+#define HANDLE_ARRAY_PTR(array) reinterpret_cast<MBEntityHandle*>(array)
+#define CONST_HANDLE_ARRAY_PTR(array) reinterpret_cast<const MBEntityHandle*>(array)
+#define TAG_HANDLE(handle) reinterpret_cast<MBTag>(handle)
+#define CONST_TAG_HANDLE(handle) static_cast<const MBTag>(handle)
+#define ENTITY_HANDLE(handle) reinterpret_cast<MBEntityHandle>(handle)
+#define CONST_ENTITY_HANDLE(handle) reinterpret_cast<const MBEntityHandle>(handle)
+#define RANGE_ITERATOR(it) reinterpret_cast<RangeIterator*>(it)
+#define CAST_TO_VOID(ptr) reinterpret_cast<void*>(ptr)
+
+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_FAILURE};
+};
+
+extern iBase_Error iMesh_LAST_ERROR;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//  Given a partition handle, a part handle, and an entity handle, return a
+//  flag indicating whether the entity is strictly internal, on a 
+//  boundary, or a ghost.
+//  If part_handle is remote, an error is returned.
+//  COMMUNICATION:  None.
+  void iMeshP_getEntStatus(iMesh_Instance instance,
+                           /*in*/ const iMeshP_PartHandle part_handle, 
+                           /*in*/ const iBase_EntityHandle entity_handle, 
+                           /*out*/ int* par_status, // Values=INTERNAL,BOUNDARY,GHOST
+                           int *err) 
+  {
+    MBParallelComm pc(MBI);
+    unsigned char pstatus;
+    MBErrorCode result = MBI->tag_get_data(pc.pstatus_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(&entity_handle), 1, 
+                                           &pstatus);
+    if (MB_SUCCESS != result) RETURN(result);
+    *par_status = iMeshP_INTERNAL;
+    if (pstatus & PSTATUS_GHOST) *par_status = iMeshP_GHOST;
+    else if (pstatus & PSTATUS_INTERFACE) *par_status = iMeshP_BOUNDARY;
+
+    RETURN(iBase_SUCCESS);
+  }
+  
+  void iMeshP_getEntStatusArr(iMesh_Instance instance,
+                              /*in*/ const iMeshP_PartHandle part_handle, 
+                              /*in*/ const iBase_EntityHandle *entity_handles, 
+                              /*in*/ const int entity_handles_size, 
+                              /*inout*/ int** par_status, // Values=INTERNAL,BOUNDARY,GHOST
+                              /*inout*/ int* par_status_allocated, 
+                              /*inout*/ int* par_status_size, 
+                              int *err) 
+  {
+    MBParallelComm pc(MBI);
+    std::vector<unsigned char> pstatus(entity_handles_size);
+    MBErrorCode result = MBI->tag_get_data(pc.pstatus_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(entity_handles), 
+                                           entity_handles_size,
+                                           &pstatus[0]);
+    if (MB_SUCCESS != result) RETURN(result);
+    *par_status_size = entity_handles_size;
+
+    CHECK_SIZE(*par_status, *par_status_allocated, *par_status_size, int, );
+  
+    for (int i = 0; i < entity_handles_size; i++) {
+      if (!pstatus[i]) (*par_status)[i] = iMeshP_INTERNAL;
+      else if (pstatus[i] & PSTATUS_GHOST) (*par_status)[i] = iMeshP_GHOST;
+      else if (pstatus[i] & PSTATUS_INTERFACE) (*par_status)[i] = iMeshP_BOUNDARY;
+    }
+
+    RETURN(iBase_SUCCESS);
+  }
+
+//  Map from processes to parts:  
+//  Given a partition handle and a process rank,
+//  return the part handles owned by the process.
+//  COMMUNICATION:  None++.
+  void iMeshP_getPartsOnRank(iMesh_Instance instance,
+                             const iMeshP_PartitionHandle partition_handle,
+                             /*in*/    const int rank,
+                             /*inout*/ iMeshP_PartHandle **part_handles, 
+                             /*inout*/ int *part_handles_allocated, 
+                             /*out*/   int *part_handles_size, 
+                             int *err) 
+  {
+    MBParallelComm pc(MBI);
+    MBRange part_sets;
+    MBErrorCode result = pc.get_partition_sets(part_sets);
+    if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
+  
+    *part_handles_size = part_sets.size();
+    CHECK_SIZE(*part_handles, *part_handles_allocated, *part_handles_size, iMeshP_PartHandle,);
+    MBRange::iterator rit;
+    int i;
+    for (i = 0, rit = part_sets.begin(); rit != part_sets.end(); rit++, i++)
+      (*part_handles)[i] = CAST_TO_VOID(*rit);
+  
+    RETURN(iBase_SUCCESS);
+  }
+    
+  void iMeshP_getPartsArrOnRank(iMesh_Instance instance,
+                                const iMeshP_PartitionHandle partition_handle,
+                                /*in*/    const int *rank,
+                                /*in*/    const int rank_size,
+                                /*inout*/ iMeshP_PartHandle **part_handles, 
+                                /*inout*/ int *part_handles_allocated, 
+                                /*out*/   int *part_handles_size, 
+                                int *err) 
+  {
+    if (rank[0] != MBI->proc_rank() || rank_size > 1) {
+      RETURN(iBase_ERROR_MAP[MB_NOT_IMPLEMENTED]);
+    }
+  
+    iMeshP_getPartsOnRank(instance, partition_handle, rank[0],
+                          part_handles, part_handles_allocated, part_handles_size,
+                          err);
+  }
+
+//  Provide entity categorization within part.
+//  Given a partition handle, a part handle, and an entity handle, return a
+//  flag indicating whether the entity is owned by the part.
+//  If part_handle is remote, an error is returned.
+//  COMMUNICATION:  None.
+  void iMeshP_isEntOwner(iMesh_Instance instance,
+                         /*in*/ const iMeshP_PartHandle part_handle, 
+                         /*in*/ const iBase_EntityHandle entity_handle, 
+                         /*out*/ int* is_owner, 
+                         int *err) 
+  {
+    MBParallelComm pc(MBI);
+    unsigned char pstatus;
+    MBErrorCode result = MBI->tag_get_data(pc.pstatus_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(&entity_handle), 1, 
+                                           &pstatus);
+    if (MB_SUCCESS != result) RETURN(result);
+
+    if (pstatus & PSTATUS_NOT_OWNED) *is_owner = 1;
+    else *is_owner = 0;
+
+    RETURN(iBase_SUCCESS);
+  }
+
+  void iMeshP_isEntOwnerArr(iMesh_Instance instance,
+                            /*in*/ const iMeshP_PartHandle part_handle, 
+                            /*in*/ const iBase_EntityHandle *entity_handles, 
+                            /*in*/ const int entity_handles_size, 
+                            /*inout*/ int** is_owner, 
+                            /*inout*/ int* is_owner_allocated, 
+                            /*inout*/ int* is_owner_size, 
+                            int *err)
+  {
+    MBParallelComm pc(MBI);
+    std::vector<unsigned char> pstatus(entity_handles_size);
+    MBErrorCode result = MBI->tag_get_data(pc.pstatus_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(entity_handles), 
+                                           entity_handles_size,
+                                           &pstatus[0]);
+    if (MB_SUCCESS != result) RETURN(result);
+    *is_owner_size = entity_handles_size;
+
+    CHECK_SIZE(*is_owner, *is_owner_allocated, *is_owner_size, int, );
+  
+    for (int i = 0; i < entity_handles_size; i++) {
+      if (pstatus[i] & PSTATUS_NOT_OWNED) (*is_owner)[i] = 1;
+      else (*is_owner)[i] = 0;
+    }
+
+    RETURN(iBase_SUCCESS);
+  }
+
+//  Provide information about copies of entities.  
+//  All these functions should work on the local process as well as 
+//  remote processes; entity handles returned are likely but not 
+//  necessarily remote. 
+//  Given a partition handle and an entity handle, return the number 
+//  of copies of the entity in the partition.
+//  COMMUNICATION:  None++.
+  void iMeshP_getNumCopies(iMesh_Instance instance,
+                           /*in*/ const iMeshP_PartitionHandle partition_handle, 
+                           /*in*/ const iBase_EntityHandle entity_handle, 
+                           /*out*/ int *num_copies_ent,
+                           int *err) 
+  {
+    MBParallelComm pc(MBI);
+    int shared_proc;
+    MBErrorCode result = MBI->tag_get_data(pc.sharedp_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(&entity_handle), 1,
+                                           &shared_proc);
+    if (MB_SUCCESS != result) {
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
+    if (-1 != shared_proc) {
+      *num_copies_ent = 1;
+      RETURN(iBase_SUCCESS);
+    }
+  
+    static int tag_size = 0;
+    if (!tag_size) {
+      result = MBI->tag_get_size(pc.sharedps_tag(), tag_size);
+      if (MB_SUCCESS != result) {
+        RETURN(iBase_ERROR_MAP[result]);
+      }
+    }
+    static std::vector<int> shared_procs(tag_size);
+
+    result = MBI->tag_get_data(pc.sharedps_tag(), 
+                               CONST_HANDLE_ARRAY_PTR(&entity_handle), 1,
+                               &shared_procs[0]);
+    if (MB_SUCCESS != result) {
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
+    *num_copies_ent = std::find(shared_procs.begin(), shared_procs.end(), -1) - shared_procs.begin();
+
+    RETURN(iBase_SUCCESS);
+  }
+
+//  Given a partition handle and an entity handle, return (remote) entity
+//  handles and part handles of all copies of the entity.
+//  COMMUNICATION:  None++.
+  void iMeshP_getCopies(iMesh_Instance instance,
+                        /*in*/ const iMeshP_PartitionHandle partition_handle, 
+                        /*in*/ const iBase_EntityHandle entity_handle, 
+                        /*inout*/ iMeshP_PartHandle **part_handles, 
+                        /*inout*/ int *part_handles_allocated, 
+                        /*out*/ int *part_handles_size, 
+                        /*inout*/ iBase_EntityHandle **copies_entity_handles, 
+                        /*inout*/ int *copies_entity_handles_allocated, 
+                        /*inout*/ int *copies_entity_handles_size, 
+                        int *err)
+  {
+    MBParallelComm pc(MBI);
+    MBEntityHandle shared_handle;
+    MBErrorCode result = MBI->tag_get_data(pc.sharedh_tag(), 
+                                           CONST_HANDLE_ARRAY_PTR(&entity_handle), 1,
+                                           &shared_handle);
+    if (MB_SUCCESS != result) {
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
+    if (0 != shared_handle) {
+      *part_handles_size = 1;
+      *copies_entity_handles_size = 1;
+      CHECK_SIZE(*part_handles, *part_handles_allocated, *part_handles_size, 
+                 iMeshP_PartHandle, );
+      CHECK_SIZE(*copies_entity_handles, *copies_entity_handles_allocated, 
+                 *copies_entity_handles_size, iBase_EntityHandle, );
+      (*part_handles)[0] = 0;
+      (*copies_entity_handles)[0] = CAST_TO_VOID(shared_handle);
+      RETURN(iBase_SUCCESS);
+    }
+  
+    static int tag_size = 0;
+    if (!tag_size) {
+      result = MBI->tag_get_size(pc.sharedhs_tag(), tag_size);
+      if (MB_SUCCESS != result) {
+        RETURN(iBase_ERROR_MAP[result]);
+      }
+    }
+    static std::vector<MBEntityHandle> shared_handles(tag_size);
+
+    result = MBI->tag_get_data(pc.sharedhs_tag(), 
+                               CONST_HANDLE_ARRAY_PTR(&entity_handle), 1,
+                               &shared_handles[0]);
+    if (MB_SUCCESS != result) {
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
+    int index = std::find(shared_handles.begin(), shared_handles.end(), -1) - shared_handles.begin();
+    
+    *part_handles_size = index+1;
+    *copies_entity_handles_size = index+1;
+    CHECK_SIZE(*part_handles, *part_handles_allocated, *part_handles_size, 
+               iMeshP_PartHandle, );
+    CHECK_SIZE(*copies_entity_handles, *copies_entity_handles_allocated, 
+               *copies_entity_handles_size, iMeshP_PartHandle, );
+    std::copy(&shared_handles[0], &shared_handles[index], 
+              HANDLE_ARRAY_PTR(*copies_entity_handles));
+    std::fill(*part_handles, *part_handles+index, CAST_TO_VOID(0));
+
+    RETURN(iBase_SUCCESS);
+  }
+
+#ifdef __cplusplus
+} // extern "C"
+#endif

Added: MOAB/trunk/tools/iMesh/iMeshP_f.h
===================================================================
--- MOAB/trunk/tools/iMesh/iMeshP_f.h	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/iMeshP_f.h	2008-06-10 20:20:16 UTC (rev 1888)
@@ -0,0 +1,25 @@
+#ifndef IMESHP_F_H
+#define IMESHP_F_H
+
+#define iMeshP_PartitionHandle integer
+#define iMeshP_PartHandle integer
+
+#endif 
+
+#include "iMesh_f.h"
+
+      integer iMeshP_LOCAL
+      integer iMeshP_REMOTE
+      integer iMeshP_INVALID
+
+      integer iMeshP_INTERNAL
+      integer iMeshP_BOUNDARY
+      integer iMeshP_GHOST
+
+      parameter (iMeshP_LOCAL = 0)
+      parameter (iMeshP_REMOTE = 1)
+      parameter (iMeshP_INVALID = 2)
+
+      parameter (iMeshP_INTERNAL = 0)
+      parameter (iMeshP_BOUNDARY = 1)
+      parameter (iMeshP_GHOST = 2)

Added: MOAB/trunk/tools/iMesh/iMeshP_protos.h
===================================================================
--- MOAB/trunk/tools/iMesh/iMeshP_protos.h	                        (rev 0)
+++ MOAB/trunk/tools/iMesh/iMeshP_protos.h	2008-06-10 20:20:16 UTC (rev 1888)
@@ -0,0 +1,25 @@
+#include "MBCN_FCDefs.h"
+
+#ifdef FC_FUNC_
+
+#define iMesh_getErrorType FC_FUNC_(imesh_geterrortype, IMESH_GETERRORTYPE)
+#define iMeshP_getNumParts FC_FUNC_(imeshp_getnumparts, IMESHP_GETNUMPARTS)
+#define iMeshP_getRankOfPart FC_FUNC_(imeshp_getrankofpart, IMESHP_GETRANKOFPART)
+#define iMeshP_getRankOfPartArr FC_FUNC_(imeshp_getrankofpartarr, IMESHP_GETRANKOFPARTARR)
+#define iMeshP_getPartsOnRank FC_FUNC_(imeshp_getpartsonrank, IMESHP_GETPARTSONRANK)
+#define iMeshP_getPartsArrOnRank FC_FUNC_(imeshp_getpartsarronrank, IMESHP_GETPARTSARRONRANK)
+#define iMeshP_getNumOfTypeAll FC_FUNC_(imeshp_getnumoftypeall, IMESHP_GETNUMOFTYPEALL)
+#define iMeshP_getNumOfTopoAll FC_FUNC_(imeshp_getnumoftopoall, IMESHP_GETNUMOFTOPOALL)
+#define iMeshP_testPart FC_FUNC_(imeshp_testpart, IMESHP_TESTPART)
+#define iMeshP_getEntOwnerPart FC_FUNC_(imeshp_getentownerpart, IMESHP_GETENTOWNERPART)
+#define iMeshP_getEntOwnerPartArr FC_FUNC_(imeshp_getentownerpartarr, IMESHP_GETENTOWNERPARTARR)
+#define iMeshP_isEntOwner FC_FUNC_(imeshp_isentowner, IMESHP_ISENTOWNER)
+#define iMeshP_isEntOwnerArr FC_FUNC_(imeshp_isentownerarr, IMESHP_ISENTOWNERARR)
+#define iMeshP_getEntStatus FC_FUNC_(imeshp_getentstatus, IMESHP_GETENTSTATUS)
+#define iMeshP_getEntStatusArr FC_FUNC_(imeshp_getentstatusarr, IMESHP_GETENTSTATUSARR)
+#define iMeshP_getNumCopies FC_FUNC_(imeshp_getnumcopies, IMESHP_GETNUMCOPIES)
+#define iMeshP_getCopies FC_FUNC_(imeshp_getcopies, IMESHP_GETCOPIES)
+
+#endif
+ 
+

Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-06-10 19:34:51 UTC (rev 1887)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-06-10 20:20:16 UTC (rev 1888)
@@ -195,2508 +195,2425 @@
 extern "C" {
 #endif
 
-void eatwhitespace(std::string &this_string);
+  void eatwhitespace(std::string &this_string);
 
-MBErrorCode iMesh_tag_set_vertices(iMesh_Instance instance,
-                                   MBEntityHandle in_set, 
-                                   const int req_dimension, 
-                                   const MBEntityType req_type,
-                                   MBTag &tag, MBRange &req_entities, 
-                                   int &num_verts, int *err);
+  MBErrorCode iMesh_tag_set_vertices(iMesh_Instance instance,
+                                     MBEntityHandle in_set, 
+                                     const int req_dimension, 
+                                     const MBEntityType req_type,
+                                     MBTag &tag, MBRange &req_entities, 
+                                     int &num_verts, int *err);
 
-iBase_Error iMesh_LAST_ERROR;
+  iBase_Error iMesh_LAST_ERROR;
 
-void iMesh_getErrorType(iMesh_Instance instance, 
-                        int *error_type, int *err) 
-{
-  *error_type = iMesh_LAST_ERROR.error_type;
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getErrorType(iMesh_Instance instance, 
+                          int *error_type, int *err) 
+  {
+    *error_type = iMesh_LAST_ERROR.error_type;
+    RETURN(iBase_SUCCESS);
+  }
   
-void iMesh_getDescription(iMesh_Instance instance, 
-                          char *descr, int *err, int descr_len)
-{
-  unsigned int len = MIN(strlen(iMesh_LAST_ERROR.description), ((unsigned int) descr_len));
-  strncpy(descr, iMesh_LAST_ERROR.description, len);
-  descr[len] = '\0';
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getDescription(iMesh_Instance instance, 
+                            char *descr, int *err, int descr_len)
+  {
+    unsigned int len = MIN(strlen(iMesh_LAST_ERROR.description), ((unsigned int) descr_len));
+    strncpy(descr, iMesh_LAST_ERROR.description, len);
+    descr[len] = '\0';
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_setError(iMesh_Instance instance,
-                    int err_type, char *descr, int *err, int descr_len) 
-{
-  iMesh_LAST_ERROR.error_type = static_cast<iBase_ErrorType>(err_type);
-  strncpy(iMesh_LAST_ERROR.description, descr, descr_len);
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_setError(iMesh_Instance instance,
+                      int err_type, char *descr, int *err, int descr_len) 
+  {
+    iMesh_LAST_ERROR.error_type = static_cast<iBase_ErrorType>(err_type);
+    strncpy(iMesh_LAST_ERROR.description, descr, descr_len);
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getError(iMesh_Instance instance,
-                    int *err_type, char *descr, int *err, int descr_len) 
-{
-  *err_type = iMesh_LAST_ERROR.error_type;
-  strncpy(descr, iMesh_LAST_ERROR.description,
-          MIN(strlen(iMesh_LAST_ERROR.description), (unsigned int)descr_len));
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getError(iMesh_Instance instance,
+                      int *err_type, char *descr, int *err, int descr_len) 
+  {
+    *err_type = iMesh_LAST_ERROR.error_type;
+    strncpy(descr, iMesh_LAST_ERROR.description,
+            MIN(strlen(iMesh_LAST_ERROR.description), (unsigned int)descr_len));
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_newMesh(const char *options, 
-                   iMesh_Instance *instance, int *err, int options_len) 
-{
-  std::string tmp_options(options, options_len);
-  FileOptions opts(tmp_options.c_str());
+  void iMesh_newMesh(const char *options, 
+                     iMesh_Instance *instance, int *err, int options_len) 
+  {
+    std::string tmp_options(options, options_len);
+    FileOptions opts(tmp_options.c_str());
 
-  MBInterface* core;
+    MBInterface* core;
 
-  MBErrorCode result = opts.get_null_option("PARALLEL");
-  if (MB_SUCCESS == result) {
+    MBErrorCode result = opts.get_null_option("PARALLEL");
+    if (MB_SUCCESS == result) {
 #ifdef USE_MPI    
-    int rank, size;
-    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
-    MPI_Comm_size(MPI_COMM_WORLD, &size); 
-    core = new MBiMesh(rank, size);
+      int rank, size;
+      MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
+      MPI_Comm_size(MPI_COMM_WORLD, &size); 
+      core = new MBiMesh(rank, size);
 #else
-    //mError->set_last_error( "PARALLEL option not valid, this instance"
-    //                        " compiled for serial execution.\n" );
-    *err = MB_NOT_IMPLEMENTED;
-    return;
+        //mError->set_last_error( "PARALLEL option not valid, this instance"
+        //                        " compiled for serial execution.\n" );
+      *err = MB_NOT_IMPLEMENTED;
+      return;
 #endif
-  }
-  else core = new MBiMesh();
+    }
+    else core = new MBiMesh();
 
-  *instance = reinterpret_cast<iMesh_Instance>(core);
-  if (0 == *instance) {
-    iMesh_processError(iBase_FAILURE, "Failed to instantiate mesh instance.");
-    RETURN(iBase_FAILURE);
-  }
+    *instance = reinterpret_cast<iMesh_Instance>(core);
+    if (0 == *instance) {
+      iMesh_processError(iBase_FAILURE, "Failed to instantiate mesh instance.");
+      RETURN(iBase_FAILURE);
+    }
   
-  if (0 != options_len) {
-    iMesh_processError(iBase_NOT_SUPPORTED, "No options for iMesh factory have been implemented.");
-    RETURN(iBase_NOT_SUPPORTED);
-  }
+    if (0 != options_len) {
+      iMesh_processError(iBase_NOT_SUPPORTED, "No options for iMesh factory have been implemented.");
+      RETURN(iBase_NOT_SUPPORTED);
+    }
   
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_dtor(iMesh_Instance instance, int *err) 
-{
-  delete MBI;
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_dtor(iMesh_Instance instance, int *err) 
+  {
+    delete MBI;
+    RETURN(iBase_SUCCESS);
+  }
    
-void iMesh_load(iMesh_Instance instance,
-                   const iBase_EntityHandle handle,
-                   const char *name, const char *options, 
-                   int *err, int name_len, int options_len) 
-{
-    // get filename, option & null-terminate
-  std::string tmp_filename(name, name_len), 
-    tmp_options(options, options_len);
+  void iMesh_load(iMesh_Instance instance,
+                  const iBase_EntityHandle handle,
+                  const char *name, const char *options, 
+                  int *err, int name_len, int options_len) 
+  {
+      // get filename, option & null-terminate
+    std::string tmp_filename(name, name_len), 
+      tmp_options(options, options_len);
 
-  eatwhitespace(tmp_filename);
-  eatwhitespace(tmp_options);
+    eatwhitespace(tmp_filename);
+    eatwhitespace(tmp_options);
   
-  MBEntityHandle file_set;
+    MBEntityHandle file_set;
   
-  MBErrorCode result = MBI->load_file(tmp_filename.c_str(), file_set, 
-                                      tmp_options.c_str());
+    MBErrorCode result = MBI->load_file(tmp_filename.c_str(), file_set, 
+                                        tmp_options.c_str());
 
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_load:ERROR loading a mesh, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_load:ERROR loading a mesh, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+  void iMesh_save(iMesh_Instance instance,
+                  const iBase_EntityHandle handle,
+                  const char *name, const char *options, 
+                  int *err, const int name_len, int options_len) 
+  {
+      // get filename & attempt to NULL-terminate
+    std::string tmp_filename( name, name_len ), tmp_options(options, options_len);
 
-void iMesh_save(iMesh_Instance instance,
-                 const iBase_EntityHandle handle,
-                 const char *name, const char *options, 
-                 int *err, const int name_len, int options_len) 
-{
-    // get filename & attempt to NULL-terminate
-  std::string tmp_filename( name, name_len ), tmp_options(options, options_len);
-
-  eatwhitespace(tmp_filename);
-  eatwhitespace(tmp_options);
+    eatwhitespace(tmp_filename);
+    eatwhitespace(tmp_options);
   
-  MBErrorCode result = MBI->write_file(tmp_filename.c_str(), NULL, tmp_options.c_str(),
-                                       CONST_HANDLE_ARRAY_PTR(&handle), 1);
+    MBErrorCode result = MBI->write_file(tmp_filename.c_str(), NULL, tmp_options.c_str(),
+                                         CONST_HANDLE_ARRAY_PTR(&handle), 1);
 
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_save:ERROR saving a mesh, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_save:ERROR saving a mesh, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
   
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_getRootSet(iMesh_Instance instance,
-                     iBase_EntitySetHandle *root_set, int *err) 
-{
-  *root_set = 0;
-    //return CAST_TO_VOID(MBI->get_root_set());
-  RETURN(iBase_SUCCESS);
+  void iMesh_getRootSet(iMesh_Instance instance,
+                        iBase_EntitySetHandle *root_set, int *err) 
+  {
+    *root_set = 0;
+      //return CAST_TO_VOID(MBI->get_root_set());
+    RETURN(iBase_SUCCESS);
 
-}
+  }
 
-void iMesh_getGeometricDimension(iMesh_Instance instance,
-                                int *geom_dim, int *err)
-{
-  MBI->get_dimension(*geom_dim);
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getGeometricDimension(iMesh_Instance instance,
+                                   int *geom_dim, int *err)
+  {
+    MBI->get_dimension(*geom_dim);
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getDfltStorage(iMesh_Instance instance,
-                         int *order, int *err)
-{
-  *order = iBase_BLOCKED;
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getDfltStorage(iMesh_Instance instance,
+                            int *order, int *err)
+  {
+    *order = iBase_BLOCKED;
+    RETURN(iBase_SUCCESS);
+  }
   
-void iMesh_getAdjTable (iMesh_Instance instance,
-                       int** adjacency_table,
-                       /*inout*/ int* adjacency_table_allocated, 
-                       /*out*/ int* adjacency_table_size, int *err)
-{
-  *adjacency_table_allocated = 0;
-  *adjacency_table_size = 0;
-  *adjacency_table = NULL;
-  RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
-}
+  void iMesh_getAdjTable (iMesh_Instance instance,
+                          int** adjacency_table,
+                          /*inout*/ int* adjacency_table_allocated, 
+                          /*out*/ int* adjacency_table_size, int *err)
+  {
+    *adjacency_table_allocated = 0;
+    *adjacency_table_size = 0;
+    *adjacency_table = NULL;
+    RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
+  }
 
-void iMesh_getNumOfType(iMesh_Instance instance,
-                       /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                       /*in*/ const int entity_type,
-                       int *num_type, int *err)
-{
-  iMesh_getNumOfTypeRec(instance, entity_set_handle, entity_type, false,
-                        num_type, err);
-}
+  void iMesh_getNumOfType(iMesh_Instance instance,
+                          /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                          /*in*/ const int entity_type,
+                          int *num_type, int *err)
+  {
+    iMesh_getNumOfTypeRec(instance, entity_set_handle, entity_type, false,
+                          num_type, err);
+  }
   
-void iMesh_getNumOfTopo(iMesh_Instance instance,
-                       /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                       /*in*/ const int entity_topology,
-                       int *num_topo, int *err)
-{
-  iMesh_getNumOfTopoRec(instance, entity_set_handle, entity_topology,
-                        false, num_topo, err);
-}
-
-void iMesh_areEHValid( iMesh_Instance instance,
-                       int doReset,
-                       int* areHandlesInvarient, 
-                       int* err )
-{
-  MBiMesh* mbi = dynamic_cast<MBiMesh*>(MBI);
-  if (!mbi) {
-    RETURN(iBase_FAILURE);
+  void iMesh_getNumOfTopo(iMesh_Instance instance,
+                          /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                          /*in*/ const int entity_topology,
+                          int *num_topo, int *err)
+  {
+    iMesh_getNumOfTopoRec(instance, entity_set_handle, entity_topology,
+                          false, num_topo, err);
   }
+
+  void iMesh_areEHValid( iMesh_Instance instance,
+                         int doReset,
+                         int* areHandlesInvarient, 
+                         int* err )
+  {
+    MBiMesh* mbi = dynamic_cast<MBiMesh*>(MBI);
+    if (!mbi) {
+      RETURN(iBase_FAILURE);
+    }
   
-  *areHandlesInvarient = !mbi->have_deleted_ents( !!doReset );
-  RETURN(iBase_SUCCESS);
-}
+    *areHandlesInvarient = !mbi->have_deleted_ents( !!doReset );
+    RETURN(iBase_SUCCESS);
+  }
 
 
-void iMesh_getAllVtxCoords (iMesh_Instance instance,
-                           /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                           /*inout*/ double** coordinates,
-                           /*inout*/ int* coordinates_allocated,
-                           /*out*/ int* coordinates_size,
-                           /*inout*/ int** in_entity_set,
-                           /*inout*/ int* in_entity_set_allocated,
-                           /*out*/ int* in_entity_set_size,
-                           /*inout*/ int* storage_order, int *err) 
-{
-  MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
+  void iMesh_getAllVtxCoords (iMesh_Instance instance,
+                              /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                              /*inout*/ double** coordinates,
+                              /*inout*/ int* coordinates_allocated,
+                              /*out*/ int* coordinates_size,
+                              /*inout*/ int** in_entity_set,
+                              /*inout*/ int* in_entity_set_allocated,
+                              /*out*/ int* in_entity_set_size,
+                              /*inout*/ int* storage_order, int *err) 
+  {
+    MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
 
-    // get all the entities then vertices
-  MBRange entities, vertices;
-  MBErrorCode result = MBI->get_entities_by_handle(in_set, entities, false);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_entitysetGetVertexCoordinates: getting entities didn't succeed, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+      // get all the entities then vertices
+    MBRange entities, vertices;
+    MBErrorCode result = MBI->get_entities_by_handle(in_set, entities, false);
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_entitysetGetVertexCoordinates: getting entities didn't succeed, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-    // remove any sets
-  entities.erase(entities.lower_bound(MBENTITYSET),
-                 entities.upper_bound(MBENTITYSET));
+      // remove any sets
+    entities.erase(entities.lower_bound(MBENTITYSET),
+                   entities.upper_bound(MBENTITYSET));
   
-    // get all the vertices
-  result = MBI->get_adjacencies(entities, 0, false, vertices,
-                                MBInterface::UNION);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_entitysetGetVertexCoordinates: getting vertices didn't succeed, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+      // get all the vertices
+    result = MBI->get_adjacencies(entities, 0, false, vertices,
+                                  MBInterface::UNION);
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_entitysetGetVertexCoordinates: getting vertices didn't succeed, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
   
-    // now get all the coordinates
-  CHECK_SIZE(*coordinates, *coordinates_allocated,
-             (int)(3*vertices.size()), double, iBase_MEMORY_ALLOCATION_FAILED);
-  CHECK_SIZE(*in_entity_set, *in_entity_set_allocated,
-             (int)vertices.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
+      // now get all the coordinates
+    CHECK_SIZE(*coordinates, *coordinates_allocated,
+               (int)(3*vertices.size()), double, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*in_entity_set, *in_entity_set_allocated,
+               (int)vertices.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
   
-    // coords will come back interleaved by default
-  MBRange::iterator vit;
-  if (*storage_order == iBase_INTERLEAVED || *storage_order == iBase_UNDETERMINED) {
-    result = MBI->get_coords(vertices, *coordinates);
-    *storage_order = iBase_INTERLEAVED;
-  }
+      // coords will come back interleaved by default
+    MBRange::iterator vit;
+    if (*storage_order == iBase_INTERLEAVED || *storage_order == iBase_UNDETERMINED) {
+      result = MBI->get_coords(vertices, *coordinates);
+      *storage_order = iBase_INTERLEAVED;
+    }
   
-  else {
-    double *dum_coords = new double[3*vertices.size()];
-    result = MBI->get_coords(vertices, dum_coords);
-    if (MB_SUCCESS == result) {
-      unsigned int offset = vertices.size();
-      for (unsigned int i= 0; i < offset; i++) {
-        (*coordinates)[i]= dum_coords[3*i];
-        (*coordinates)[offset+i] = dum_coords[3*i+1];
-        (*coordinates)[2*offset+i] = dum_coords[3*i+2];
+    else {
+      double *dum_coords = new double[3*vertices.size()];
+      result = MBI->get_coords(vertices, dum_coords);
+      if (MB_SUCCESS == result) {
+        unsigned int offset = vertices.size();
+        for (unsigned int i= 0; i < offset; i++) {
+          (*coordinates)[i]= dum_coords[3*i];
+          (*coordinates)[offset+i] = dum_coords[3*i+1];
+          (*coordinates)[2*offset+i] = dum_coords[3*i+2];
+        }
       }
+      delete [] dum_coords;
     }
-    delete [] dum_coords;
-  }
   
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_entitysetGetVertexCoordinates: problem getting vertex coords, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_entitysetGetVertexCoordinates: problem getting vertex coords, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
   
-    // now fill the in_entity_set array
-  MBRange::iterator endr = entities.end();
-  int i;
-  for (i = 0, vit = vertices.begin(); vit != vertices.end(); vit++, i++) {
-    if (0 == in_set || entities.find(*vit) != endr)
-      (*in_entity_set)[i] = 1;
-    else 
-      (*in_entity_set)[i] = 0;
-  }
+      // now fill the in_entity_set array
+    MBRange::iterator endr = entities.end();
+    int i;
+    for (i = 0, vit = vertices.begin(); vit != vertices.end(); vit++, i++) {
+      if (0 == in_set || entities.find(*vit) != endr)
+        (*in_entity_set)[i] = 1;
+      else 
+        (*in_entity_set)[i] = 0;
+    }
 
-  *coordinates_size = 3*vertices.size();
-  *in_entity_set_size = vertices.size();
+    *coordinates_size = 3*vertices.size();
+    *in_entity_set_size = vertices.size();
   
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getVtxCoordIndex (iMesh_Instance instance,
-                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                            /*in*/ const int requested_entity_type,
-                            /*in*/ const int requested_entity_topology,
-                            /*in*/ const int entity_adjacency_type,
-                            /*inout*/ int** offset,
-                            /*inout*/ int* offset_allocated,
-                            /*out*/ int* offset_size,
-                            /*inout*/ int** index,
-                            /*inout*/ int* index_allocated,
-                            /*out*/ int* index_size,
-                            /*inout*/  int** entity_topologies,
-                            /*inout*/ int* entity_topologies_allocated,
-                            /*out*/ int* entity_topologies_size, int *err) 
-{
-  MBEntityType req_type = mb_topology_table[requested_entity_topology];
-  int req_dimension = (req_type == MBMAXTYPE ? (int) requested_entity_type : -1);
+  void iMesh_getVtxCoordIndex (iMesh_Instance instance,
+                               /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                               /*in*/ const int requested_entity_type,
+                               /*in*/ const int requested_entity_topology,
+                               /*in*/ const int entity_adjacency_type,
+                               /*inout*/ int** offset,
+                               /*inout*/ int* offset_allocated,
+                               /*out*/ int* offset_size,
+                               /*inout*/ int** index,
+                               /*inout*/ int* index_allocated,
+                               /*out*/ int* index_size,
+                               /*inout*/  int** entity_topologies,
+                               /*inout*/ int* entity_topologies_allocated,
+                               /*out*/ int* entity_topologies_size, int *err) 
+  {
+    MBEntityType req_type = mb_topology_table[requested_entity_topology];
+    int req_dimension = (req_type == MBMAXTYPE ? (int) requested_entity_type : -1);
 
-  MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
+    MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
   
-  MBTag pos_tag = 0;
-  MBRange req_entities;
-  int num_verts;
-  MBErrorCode result = 
-    iMesh_tag_set_vertices(instance, in_set, 
-                           req_dimension, req_type, 
-                           pos_tag, req_entities, num_verts, err);
-  if (MB_SUCCESS != result) {
-    RETURN(iMesh_LAST_ERROR.error_type);
-  }
+    MBTag pos_tag = 0;
+    MBRange req_entities;
+    int num_verts;
+    MBErrorCode result = 
+      iMesh_tag_set_vertices(instance, in_set, 
+                             req_dimension, req_type, 
+                             pos_tag, req_entities, num_verts, err);
+    if (MB_SUCCESS != result) {
+      RETURN(iMesh_LAST_ERROR.error_type);
+    }
   
-  if (0 == pos_tag || req_entities.empty()) {
-    *offset_size = 0;
-    *index_size = 0;
-    *entity_topologies_size = 0;
-    RETURN(iBase_SUCCESS);
-  }
+    if (0 == pos_tag || req_entities.empty()) {
+      *offset_size = 0;
+      *index_size = 0;
+      *entity_topologies_size = 0;
+      RETURN(iBase_SUCCESS);
+    }
   
-    // now get the connectivity; get it all in one vector before setting indices, so that
-    // we can check size of or allocate index vector; but, we can check and allocate
-    // count vector
-  const MBEntityHandle *tmp_connect;
-  int num_connect;
-  std::vector<MBEntityHandle> connect;
-  CHECK_SIZE(*offset, *offset_allocated, 
-             (int)req_entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
-  CHECK_SIZE(*entity_topologies, *entity_topologies_allocated, 
-             (int)req_entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
+      // now get the connectivity; get it all in one vector before setting indices, so that
+      // we can check size of or allocate index vector; but, we can check and allocate
+      // count vector
+    const MBEntityHandle *tmp_connect;
+    int num_connect;
+    std::vector<MBEntityHandle> connect;
+    CHECK_SIZE(*offset, *offset_allocated, 
+               (int)req_entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*entity_topologies, *entity_topologies_allocated, 
+               (int)req_entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
   
-  MBRange::iterator ent_it;
-  int curr_offset = 0;
-  int i;
-  for (ent_it = req_entities.begin(), i = 0; ent_it != req_entities.end(); 
-       ent_it++, i++) {
-    MBErrorCode result = MBI->get_connectivity(*ent_it, tmp_connect, num_connect, true);
+    MBRange::iterator ent_it;
+    int curr_offset = 0;
+    int i;
+    for (ent_it = req_entities.begin(), i = 0; ent_it != req_entities.end(); 
+         ent_it++, i++) {
+      MBErrorCode result = MBI->get_connectivity(*ent_it, tmp_connect, num_connect, true);
+      if (MB_SUCCESS != result) {
+        std::string msg("iMesh_getVtxCoordIndex: couldn't get connectivity, with error type: ");
+        msg += MBI->get_error_string(result);
+        iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+        RETURN(iBase_ERROR_MAP[result]);
+      }
+      std::copy(tmp_connect, tmp_connect+num_connect, std::back_inserter(connect));
+      MBEntityType this_type = MBI->type_from_handle(*ent_it);
+      (*entity_topologies)[i] = tstt_topology_table[this_type];
+      (*offset)[i] = curr_offset;
+      curr_offset += num_connect;
+    }
+  
+      // now check size of, allocate, and assign index vector
+    CHECK_SIZE(*index, *index_allocated, 
+               (int)connect.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
+      // get the tags all at once, it's more efficient
+    result = MBI->tag_get_data(pos_tag, &connect[0], 
+                               connect.size(), *index);
     if (MB_SUCCESS != result) {
-      std::string msg("iMesh_getVtxCoordIndex: couldn't get connectivity, with error type: ");
+      std::string msg("iMesh_getVtxCoordIndex: couldn't get index tag, with error type: ");
       msg += MBI->get_error_string(result);
       iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
       RETURN(iBase_ERROR_MAP[result]);
     }
-    std::copy(tmp_connect, tmp_connect+num_connect, std::back_inserter(connect));
-    MBEntityType this_type = MBI->type_from_handle(*ent_it);
-    (*entity_topologies)[i] = tstt_topology_table[this_type];
-    (*offset)[i] = curr_offset;
-    curr_offset += num_connect;
-  }
-  
-    // now check size of, allocate, and assign index vector
-  CHECK_SIZE(*index, *index_allocated, 
-             (int)connect.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
-    // get the tags all at once, it's more efficient
-  result = MBI->tag_get_data(pos_tag, &connect[0], 
-                             connect.size(), *index);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_getVtxCoordIndex: couldn't get index tag, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
 
-    // don't need the tag any more
-  result = MBI->tag_delete(pos_tag);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_getVtxCoordIndex: error deleting tag, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+      // don't need the tag any more
+    result = MBI->tag_delete(pos_tag);
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_getVtxCoordIndex: error deleting tag, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  *offset_size = req_entities.size();
-  *entity_topologies_size = req_entities.size();
-  *index_size = connect.size();
+    *offset_size = req_entities.size();
+    *entity_topologies_size = req_entities.size();
+    *index_size = connect.size();
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getEntities(iMesh_Instance instance,
-                      /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                      /*in*/ const int entity_type,
-                      /*in*/ const int entity_topology,
-                      /*inout*/ iBase_EntityHandle** entity_handles,
-                      /*inout*/ int* entity_handles_allocated,
-                      /*out*/ int* entity_handles_size, 
-                       int *err) 
-{
-  iMesh_getEntitiesRec(instance, entity_set_handle, entity_type,
-                       entity_topology, false,
-                       entity_handles, entity_handles_allocated, entity_handles_size,
-                       err);
-}
+  void iMesh_getEntities(iMesh_Instance instance,
+                         /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                         /*in*/ const int entity_type,
+                         /*in*/ const int entity_topology,
+                         /*inout*/ iBase_EntityHandle** entity_handles,
+                         /*inout*/ int* entity_handles_allocated,
+                         /*out*/ int* entity_handles_size, 
+                         int *err) 
+  {
+    iMesh_getEntitiesRec(instance, entity_set_handle, entity_type,
+                         entity_topology, false,
+                         entity_handles, entity_handles_allocated, entity_handles_size,
+                         err);
+  }
 
-void iMesh_getVtxArrCoords (iMesh_Instance instance,
-                           /*in*/ const iBase_EntityHandle* vertex_handles,
-                           /*in*/ const int vertex_handles_size,
-                           /*inout*/ int* storage_order,
-                           /*inout*/ double** coords,
-                           /*inout*/ int* coords_allocated,
-                           /*out*/ int* coords_size, int *err) 
-{
+  void iMesh_getVtxArrCoords (iMesh_Instance instance,
+                              /*in*/ const iBase_EntityHandle* vertex_handles,
+                              /*in*/ const int vertex_handles_size,
+                              /*inout*/ int* storage_order,
+                              /*inout*/ double** coords,
+                              /*inout*/ int* coords_allocated,
+                              /*out*/ int* coords_size, int *err) 
+  {
 
-    // make sure we can hold them all
-  CHECK_SIZE(*coords, *coords_allocated, 3*vertex_handles_size, double, iBase_MEMORY_ALLOCATION_FAILED);
+      // make sure we can hold them all
+    CHECK_SIZE(*coords, *coords_allocated, 3*vertex_handles_size, double, iBase_MEMORY_ALLOCATION_FAILED);
   
-    // now get all the coordinates
-    // coords will come back interleaved by default
-  MBErrorCode result;
-  if (*storage_order == iBase_INTERLEAVED || *storage_order == iBase_UNDETERMINED) {
-    result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
-                             vertex_handles_size, *coords);
-    *storage_order = iBase_INTERLEAVED;
-  }
+      // now get all the coordinates
+      // coords will come back interleaved by default
+    MBErrorCode result;
+    if (*storage_order == iBase_INTERLEAVED || *storage_order == iBase_UNDETERMINED) {
+      result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
+                               vertex_handles_size, *coords);
+      *storage_order = iBase_INTERLEAVED;
+    }
   
-  else {
-    std::vector<double> dum_coords(3*vertex_handles_size);
-    result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
-                             vertex_handles_size,
-                             &dum_coords[0]);
-    if (MB_SUCCESS == result) {
-      int i;
-      double *x = *coords;
-      double *y = *coords+vertex_handles_size;
-      double *z = *coords+2*vertex_handles_size;
-      std::vector<double>::const_iterator c_iter = dum_coords.begin();
-      for (i = 0; i < vertex_handles_size; i++) {
-        *x = *c_iter; ++x; ++c_iter;
-        *y = *c_iter; ++y; ++c_iter;
-        *z = *c_iter; ++z; ++c_iter;
+    else {
+      std::vector<double> dum_coords(3*vertex_handles_size);
+      result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
+                               vertex_handles_size,
+                               &dum_coords[0]);
+      if (MB_SUCCESS == result) {
+        int i;
+        double *x = *coords;
+        double *y = *coords+vertex_handles_size;
+        double *z = *coords+2*vertex_handles_size;
+        std::vector<double>::const_iterator c_iter = dum_coords.begin();
+        for (i = 0; i < vertex_handles_size; i++) {
+          *x = *c_iter; ++x; ++c_iter;
+          *y = *c_iter; ++y; ++c_iter;
+          *z = *c_iter; ++z; ++c_iter;
+        }
       }
     }
-  }
   
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_getVtxArrCoords: problem getting vertex coords, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_getVtxArrCoords: problem getting vertex coords, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  *coords_size = 3*vertex_handles_size;
+    *coords_size = 3*vertex_handles_size;
   
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getAdjEntities(iMesh_Instance instance,
-                         /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                         /*in*/ const int entity_type_requestor,
-                         /*in*/ const int entity_topology_requestor,
-                         /*in*/ const int entity_type_requested,
-                         /*inout*/ iBase_EntityHandle** adj_entity_handles,
-                         /*inout*/ int* adj_entity_handles_allocated,
-                         /*out*/ int* adj_entity_handles_size,
-                         /*inout*/ int** offset,
-                         /*inout*/ int* offset_allocated,
-                         /*out*/ int* offset_size,
-                         /*inout*/ int** in_entity_set,
-                         /*inout*/ int* in_entity_set_allocated,
-                         /*out*/ int* in_entity_set_size, int *err) 
-{
-  MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
-  MBRange entities;
-  MBEntityType requestor_type = mb_topology_table[entity_topology_requestor];
-  MBErrorCode result;
+  void iMesh_getAdjEntities(iMesh_Instance instance,
+                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                            /*in*/ const int entity_type_requestor,
+                            /*in*/ const int entity_topology_requestor,
+                            /*in*/ const int entity_type_requested,
+                            /*inout*/ iBase_EntityHandle** adj_entity_handles,
+                            /*inout*/ int* adj_entity_handles_allocated,
+                            /*out*/ int* adj_entity_handles_size,
+                            /*inout*/ int** offset,
+                            /*inout*/ int* offset_allocated,
+                            /*out*/ int* offset_size,
+                            /*inout*/ int** in_entity_set,
+                            /*inout*/ int* in_entity_set_allocated,
+                            /*out*/ int* in_entity_set_size, int *err) 
+  {
+    MBEntityHandle in_set = ENTITY_HANDLE(entity_set_handle);
+    MBRange entities;
+    MBEntityType requestor_type = mb_topology_table[entity_topology_requestor];
+    MBErrorCode result;
 
-  if (entity_type_requestor == iBase_ALL_TYPES &&
-      entity_topology_requestor == iMesh_ALL_TOPOLOGIES )
-    result = MBI->get_entities_by_handle( in_set, entities );
-  else if (requestor_type == MBMAXTYPE)
-    result = MBI->get_entities_by_dimension
-      (in_set, entity_type_requestor, entities);
-  else if (entity_topology_requestor == iMesh_SEPTAHEDRON)
-    result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any of them.
-  else
-    result = MBI->get_entities_by_type(in_set, requestor_type, entities);
+    if (entity_type_requestor == iBase_ALL_TYPES &&
+        entity_topology_requestor == iMesh_ALL_TOPOLOGIES )
+      result = MBI->get_entities_by_handle( in_set, entities );
+    else if (requestor_type == MBMAXTYPE)
+      result = MBI->get_entities_by_dimension
+        (in_set, entity_type_requestor, entities);
+    else if (entity_topology_requestor == iMesh_SEPTAHEDRON)
+      result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any of them.
+    else
+      result = MBI->get_entities_by_type(in_set, requestor_type, entities);
   
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_getAdjEntities: ERROR getting requestor entities in entityset, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_getAdjEntities: ERROR getting requestor entities in entityset, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  int num_entities = entities.size();
+    int num_entities = entities.size();
 
-  if (num_entities == 0) 
-  {
-    *adj_entity_handles_size = *offset_size = *in_entity_set_size = 0;
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    if (num_entities == 0) 
+    {
+      *adj_entity_handles_size = *offset_size = *in_entity_set_size = 0;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-    // first, count the number of adjacent entities we'll have
-  int num_sub = 0;
-  int to_dim = entity_type_requested;
-  if (to_dim == 0) {
-    const MBEntityHandle *connect;
-    int num_connect;
-    MBErrorCode result;
-    for (MBRange::iterator rit = entities.begin(); rit != entities.end(); rit++) {
-      result = MBI->get_connectivity(*rit, connect, num_connect);
-      if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
-      num_sub += num_connect;
+      // first, count the number of adjacent entities we'll have
+    int num_sub = 0;
+    int to_dim = entity_type_requested;
+    if (to_dim == 0) {
+      const MBEntityHandle *connect;
+      int num_connect;
+      MBErrorCode result;
+      for (MBRange::iterator rit = entities.begin(); rit != entities.end(); rit++) {
+        result = MBI->get_connectivity(*rit, connect, num_connect);
+        if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
+        num_sub += num_connect;
+      }
     }
-  }
-  else {
-    MBRange tmp_adjs;
-    MBErrorCode result;
-    for (MBRange::iterator rit = entities.begin(); rit != entities.end(); rit++) {
-      result = MBI->get_adjacencies(&(*rit), 1, to_dim, false, tmp_adjs);
-      if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
-      num_sub += tmp_adjs.size();
-      tmp_adjs.clear();
+    else {
+      MBRange tmp_adjs;
+      MBErrorCode result;
+      for (MBRange::iterator rit = entities.begin(); rit != entities.end(); rit++) {
+        result = MBI->get_adjacencies(&(*rit), 1, to_dim, false, tmp_adjs);
+        if (MB_SUCCESS != result) RETURN(iBase_ERROR_MAP[result]);
+        num_sub += tmp_adjs.size();
+        tmp_adjs.clear();
+      }
     }
-  }
   
-    // allocate enough space for those adjacent entities
-  CHECK_SIZE(*adj_entity_handles, *adj_entity_handles_allocated,
-             num_sub, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+      // allocate enough space for those adjacent entities
+    CHECK_SIZE(*adj_entity_handles, *adj_entity_handles_allocated,
+               num_sub, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
   
-  CHECK_SIZE(*offset, *offset_allocated, 
-             (int)entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*offset, *offset_allocated, 
+               (int)entities.size(), int, iBase_MEMORY_ALLOCATION_FAILED);
 
-  CHECK_SIZE(*in_entity_set, *in_entity_set_allocated,
-             num_sub, int, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*in_entity_set, *in_entity_set_allocated,
+               num_sub, int, iBase_MEMORY_ALLOCATION_FAILED);
 
-    // now iterate over entities
-  num_sub = 0;
-  int i = 0;
-  std::vector<MBEntityHandle> adj_ents;
-  MBRange::iterator endr = entities.end();
-  for (MBRange::iterator rit = entities.begin(); rit != endr; rit++) {
-    adj_ents.clear();
-    (*offset)[i] = num_sub;
+      // now iterate over entities
+    num_sub = 0;
+    int i = 0;
+    std::vector<MBEntityHandle> adj_ents;
+    MBRange::iterator endr = entities.end();
+    for (MBRange::iterator rit = entities.begin(); rit != endr; rit++) {
+      adj_ents.clear();
+      (*offset)[i] = num_sub;
     
-    result = MBI->get_adjacencies(&(*rit), 1, (int)entity_type_requested, false,
-                                  adj_ents);
+      result = MBI->get_adjacencies(&(*rit), 1, (int)entity_type_requested, false,
+                                    adj_ents);
     
-    if (result != MB_SUCCESS) {
-      std::string msg("iMesh_getAdjEntities: ERROR getting adjacencies of requested entities, "
-                      "with error type: ");
-      msg += MBI->get_error_string(result);
-      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-      RETURN(iBase_ERROR_MAP[result]);
-    }
+      if (result != MB_SUCCESS) {
+        std::string msg("iMesh_getAdjEntities: ERROR getting adjacencies of requested entities, "
+                        "with error type: ");
+        msg += MBI->get_error_string(result);
+        iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+        RETURN(iBase_ERROR_MAP[result]);
+      }
     
-    for (std::vector<MBEntityHandle>::iterator vit = adj_ents.begin(); 
-         vit != adj_ents.end(); vit++) {
-      (*adj_entity_handles)[num_sub] = (iBase_EntityHandle)*vit;
-      if (0 == in_set || entities.find(*vit) != endr)
-        (*in_entity_set)[num_sub] = 1;
-      else
-        (*in_entity_set)[num_sub] = 0;
+      for (std::vector<MBEntityHandle>::iterator vit = adj_ents.begin(); 
+           vit != adj_ents.end(); vit++) {
+        (*adj_entity_handles)[num_sub] = (iBase_EntityHandle)*vit;
+        if (0 == in_set || entities.find(*vit) != endr)
+          (*in_entity_set)[num_sub] = 1;
+        else
+          (*in_entity_set)[num_sub] = 0;
 
-      num_sub++;
+        num_sub++;
+      }
+
+      i++;
     }
 
-    i++;
+    *adj_entity_handles_size = num_sub;
+    *offset_size = entities.size();
+    *in_entity_set_size = num_sub;
+
+    RETURN(iBase_SUCCESS);
   }
 
-  *adj_entity_handles_size = num_sub;
-  *offset_size = entities.size();
-  *in_entity_set_size = num_sub;
-
-  RETURN(iBase_SUCCESS);
-}
-
 /**
  * Method:  initEntArrIter[]
  */
-void iMesh_initEntArrIter (iMesh_Instance instance,
-                          /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                          /*in*/ const int requested_entity_type,
-                          /*in*/ const int requested_entity_topology,
-                          /*in*/ const int requested_array_size,
-                          /*out*/ iMesh_EntityIterator* entArr_iterator,
-                          int *err) 
-{
-  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;
+  void iMesh_initEntArrIter (iMesh_Instance instance,
+                             /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                             /*in*/ const int requested_entity_type,
+                             /*in*/ const int requested_entity_topology,
+                             /*in*/ const int requested_array_size,
+                             /*out*/ iMesh_EntityIterator* entArr_iterator,
+                             int *err) 
+  {
+    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;
   
-  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 );
-  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);
-  else
-    result = MBI->get_entities_by_dimension(ENTITY_HANDLE(entity_set_handle),
-                                            req_dimension,
-                                            new_it->iteratorRange);
+    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 );
+    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);
+    else
+      result = MBI->get_entities_by_dimension(ENTITY_HANDLE(entity_set_handle),
+                                              req_dimension,
+                                              new_it->iteratorRange);
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_initEntArrIter: ERROR getting entities of proper type or topology, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    iMesh_LAST_ERROR.error_type = iBase_ERROR_MAP[result];
-    RETURN(iMesh_LAST_ERROR.error_type);
-  }
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_initEntArrIter: ERROR getting entities of proper type or topology, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      iMesh_LAST_ERROR.error_type = iBase_ERROR_MAP[result];
+      RETURN(iMesh_LAST_ERROR.error_type);
+    }
 
-  new_it->currentPos = new_it->iteratorRange.begin();
-  iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+    new_it->currentPos = new_it->iteratorRange.begin();
+    iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
 /**
  * Method:  getEntArrNextIter[]
  */
-void iMesh_getNextEntArrIter (iMesh_Instance instance,
-                             /*in*/ iMesh_EntityIterator entArr_iterator,
-                             /*inout*/ iBase_EntityHandle** entity_handles,
-                             /*inout*/ int* entity_handles_allocated,
-                             /*out*/ int* entity_handles_size,
-                             int *is_end, int *err) 
-{
-  RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
+  void iMesh_getNextEntArrIter (iMesh_Instance instance,
+                                /*in*/ iMesh_EntityIterator entArr_iterator,
+                                /*inout*/ iBase_EntityHandle** entity_handles,
+                                /*inout*/ int* entity_handles_allocated,
+                                /*out*/ int* entity_handles_size,
+                                int *is_end, int *err) 
+  {
+    RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
 
-    // check the size of the destination array
-  int expected_size = (this_it->requestedSize < (int)this_it->iteratorRange.size() ? 
-                       this_it->requestedSize : this_it->iteratorRange.size());
-  CHECK_SIZE(*entity_handles, *entity_handles_allocated, expected_size,
-             iBase_EntityHandle, false);
+      // check the size of the destination array
+    int expected_size = (this_it->requestedSize < (int)this_it->iteratorRange.size() ? 
+                         this_it->requestedSize : this_it->iteratorRange.size());
+    CHECK_SIZE(*entity_handles, *entity_handles_allocated, expected_size,
+               iBase_EntityHandle, false);
   
-  int& i = *entity_handles_size;
-  for (i = 0; i < this_it->requestedSize; ++i, ++this_it->currentPos)
-  {
-    if (this_it->currentPos == this_it->iteratorRange.end()) {
-      *is_end = false;
-      RETURN(iBase_SUCCESS);
-    }
+    int& i = *entity_handles_size;
+    for (i = 0; i < this_it->requestedSize; ++i, ++this_it->currentPos)
+    {
+      if (this_it->currentPos == this_it->iteratorRange.end()) {
+        *is_end = false;
+        RETURN(iBase_SUCCESS);
+      }
     
-    (*entity_handles)[i] = (iBase_EntityHandle)*this_it->currentPos;
-  }
+      (*entity_handles)[i] = (iBase_EntityHandle)*this_it->currentPos;
+    }
   
-  *is_end = true;
-  RETURN(iBase_SUCCESS);
-}
+    *is_end = true;
+    RETURN(iBase_SUCCESS);
+  }
 
 /**
  * Method:  resetEntArrIter[]
  */
-void iMesh_resetEntArrIter (iMesh_Instance instance,
-                           /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
-{
-  RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
+  void iMesh_resetEntArrIter (iMesh_Instance instance,
+                              /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
+  {
+    RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
 
-  this_it->currentPos = this_it->iteratorRange.begin();
+    this_it->currentPos = this_it->iteratorRange.begin();
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_endEntArrIter (iMesh_Instance instance,
-                         /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
-{
-  RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
+  void iMesh_endEntArrIter (iMesh_Instance instance,
+                            /*in*/ iMesh_EntityIterator entArr_iterator, int *err) 
+  {
+    RangeIterator *this_it = RANGE_ITERATOR(entArr_iterator);
 
-  this_it->currentPos = this_it->iteratorRange.end();
+    this_it->currentPos = this_it->iteratorRange.end();
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getEntArrTopo(iMesh_Instance instance,
-                        /*in*/ const iBase_EntityHandle* entity_handles,
-                        /*in*/ const int entity_handles_size,
-                        /*inout*/ int** topology,
-                        /*inout*/ int* topology_allocated,
-                        /*out*/ int* topology_size, int *err) 
-{
-    // go through each entity and look up its type
-  CHECK_SIZE(*topology, *topology_allocated, entity_handles_size, 
-             int, iBase_MEMORY_ALLOCATION_FAILED);
+  void iMesh_getEntArrTopo(iMesh_Instance instance,
+                           /*in*/ const iBase_EntityHandle* entity_handles,
+                           /*in*/ const int entity_handles_size,
+                           /*inout*/ int** topology,
+                           /*inout*/ int* topology_allocated,
+                           /*out*/ int* topology_size, int *err) 
+  {
+      // go through each entity and look up its type
+    CHECK_SIZE(*topology, *topology_allocated, entity_handles_size, 
+               int, iBase_MEMORY_ALLOCATION_FAILED);
 
-  for (int i = 0; i < entity_handles_size; i++)
-    (*topology)[i] = 
-      tstt_topology_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handles[i]))];
+    for (int i = 0; i < entity_handles_size; i++)
+      (*topology)[i] = 
+        tstt_topology_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handles[i]))];
 
-  *topology_size = entity_handles_size;
+    *topology_size = entity_handles_size;
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
   
-void iMesh_getEntArrType(iMesh_Instance instance,
-                        /*in*/ const iBase_EntityHandle* entity_handles,
-                        /*in*/ const int entity_handles_size,
-                        /*inout*/ int** etype,
-                        /*inout*/ int* etype_allocated,
-                        /*out*/ int* etype_size, int *err) 
-{
-    // go through each entity and look up its type
-  CHECK_SIZE(*etype, *etype_allocated, entity_handles_size, 
-             int, iBase_MEMORY_ALLOCATION_FAILED);
+  void iMesh_getEntArrType(iMesh_Instance instance,
+                           /*in*/ const iBase_EntityHandle* entity_handles,
+                           /*in*/ const int entity_handles_size,
+                           /*inout*/ int** etype,
+                           /*inout*/ int* etype_allocated,
+                           /*out*/ int* etype_size, int *err) 
+  {
+      // go through each entity and look up its type
+    CHECK_SIZE(*etype, *etype_allocated, entity_handles_size, 
+               int, iBase_MEMORY_ALLOCATION_FAILED);
 
-  for (int i = 0; i < entity_handles_size; i++)
-    (*etype)[i] = 
-      tstt_type_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handles[i]))];
+    for (int i = 0; i < entity_handles_size; i++)
+      (*etype)[i] = 
+        tstt_type_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handles[i]))];
 
-  *etype_size = entity_handles_size;
+    *etype_size = entity_handles_size;
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getEntArrAdj(iMesh_Instance instance,
-                       /*in*/ const iBase_EntityHandle* entity_handles,
-                       /*in*/ const int entity_handles_size,
-                       /*in*/ const int entity_type_requested,
-                       /*inout*/ iBase_EntityHandle** adjacentEntityHandles,
-                       /*inout*/ int* adjacentEntityHandles_allocated,
-                       /*out*/ int* adjacentEntityHandles_size,
-                       /*inout*/ int** offset,
-                       /*inout*/ int* offset_allocated,
-                       /*out*/ int* offset_size, int *err) 
-{
-  MBErrorCode result = MB_SUCCESS;
+  void iMesh_getEntArrAdj(iMesh_Instance instance,
+                          /*in*/ const iBase_EntityHandle* entity_handles,
+                          /*in*/ const int entity_handles_size,
+                          /*in*/ const int entity_type_requested,
+                          /*inout*/ iBase_EntityHandle** adjacentEntityHandles,
+                          /*inout*/ int* adjacentEntityHandles_allocated,
+                          /*out*/ int* adjacentEntityHandles_size,
+                          /*inout*/ int** offset,
+                          /*inout*/ int* offset_allocated,
+                          /*out*/ int* offset_size, int *err) 
+  {
+    MBErrorCode result = MB_SUCCESS;
 
-  CHECK_SIZE(*offset, *offset_allocated, entity_handles_size+1, 
-             int, iBase_MEMORY_ALLOCATION_FAILED);
+    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;
+    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;
+    std::vector<MBEntityHandle> all_adj_ents;
     
-  for ( ; entity_iter != entity_end; ++entity_iter)
-  {
-    *off_iter = prev_off;
-    off_iter++;
-    std::vector<MBEntityHandle> adj_ents;
+    for ( ; entity_iter != entity_end; ++entity_iter)
+    {
+      *off_iter = prev_off;
+      off_iter++;
+      std::vector<MBEntityHandle> adj_ents;
 
-    result = MBI->get_adjacencies( entity_iter, 1, 
-                                   entity_type_requested, false, adj_ents );
-    if (MB_SUCCESS != result) {
-      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
-      RETURN(iBase_ERROR_MAP[result]);
+      result = MBI->get_adjacencies( entity_iter, 1, 
+                                     entity_type_requested, false, 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;
 
-    std::copy(adj_ents.begin(), adj_ents.end(), std::back_inserter(all_adj_ents));
-    prev_off += adj_ents.size();
+    CHECK_SIZE(*adjacentEntityHandles, *adjacentEntityHandles_allocated, 
+               (int)all_adj_ents.size(), 
+               iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    memcpy(*adjacentEntityHandles, &all_adj_ents[0], sizeof(MBEntityHandle) * all_adj_ents.size() );
+
+    *adjacentEntityHandles_size = all_adj_ents.size();
+    *offset_size = entity_handles_size+1;
+    RETURN(iBase_SUCCESS);
   }
-  *off_iter = prev_off;
 
-  CHECK_SIZE(*adjacentEntityHandles, *adjacentEntityHandles_allocated, 
-             (int)all_adj_ents.size(), 
-             iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
-  memcpy(*adjacentEntityHandles, &all_adj_ents[0], sizeof(MBEntityHandle) * all_adj_ents.size() );
+  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;
 
-  *adjacentEntityHandles_size = all_adj_ents.size();
-  *offset_size = entity_handles_size+1;
-  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);
+    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;
+    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);
+    std::vector<MBEntityHandle> all_adj_ents;
+    MeshTopoUtil mtu(MBI);
     
-  for ( ; entity_iter != entity_end; ++entity_iter)
-  {
+    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;
-    off_iter++;
-    MBRange adj_ents;
 
-    result = mtu.get_bridge_adjacencies( *entity_iter,
-                                         order_adjacent_key,
-                                         requested_entity_type, adj_ents );
+    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) 
+  {
+      // create the entity set
+    MBEntityHandle meshset;
+    MBErrorCode result;
+
+    if (isList)
+      result = MBI->create_meshset(MESHSET_ORDERED, meshset);
+    else
+      result = MBI->create_meshset(MESHSET_SET, meshset);
+  
     if (MB_SUCCESS != result) {
-      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createEntSet: ERROR creating a entityset instance");
       RETURN(iBase_ERROR_MAP[result]);
     }
-
-    std::copy(adj_ents.begin(), adj_ents.end(), std::back_inserter(all_adj_ents));
-    prev_off += adj_ents.size();
+  
+      // return EntitySet_Handle
+    *entity_set_created = (iBase_EntityHandle)meshset;
+    RETURN(iBase_ERROR_MAP[result]);
   }
-  *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() );
+  void iMesh_destroyEntSet (iMesh_Instance instance,
+                            /*in*/ iBase_EntitySetHandle entity_set, int *err) 
+  {
+    MBErrorCode result = MBI->delete_entities(HANDLE_ARRAY_PTR(&entity_set), 1);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_destroyEntSet: couldn't delete the set.");
 
-  *adj_entity_handles_size = all_adj_ents.size();
-  *offset_size = entity_handles_size+1;
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_createEntSet(iMesh_Instance instance,
-                       /*in*/ const int isList,
-                       /*out*/ iBase_EntitySetHandle* entity_set_created, int *err) 
-{
-    // create the entity set
-  MBEntityHandle meshset;
-  MBErrorCode result;
-
-  if (isList)
-    result = MBI->create_meshset(MESHSET_ORDERED, meshset);
-  else
-    result = MBI->create_meshset(MESHSET_SET, meshset);
+  void iMesh_isList (iMesh_Instance instance,
+                     /*in*/ const iBase_EntitySetHandle entity_set,
+                     int *is_list, int *err) 
+  {
+    unsigned int options;
+    MBErrorCode result = MBI->get_meshset_options(ENTITY_HANDLE(entity_set), options);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_isList: couldn't query set.");
+    if (options & MESHSET_ORDERED)
+      *is_list = true;
+    else *is_list = false;
   
-  if (MB_SUCCESS != result) {
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createEntSet: ERROR creating a entityset instance");
-    RETURN(iBase_ERROR_MAP[result]);
+    RETURN(iBase_SUCCESS);
   }
-  
-    // return EntitySet_Handle
-  *entity_set_created = (iBase_EntityHandle)meshset;
-  RETURN(iBase_ERROR_MAP[result]);
-}
 
-void iMesh_destroyEntSet (iMesh_Instance instance,
-                         /*in*/ iBase_EntitySetHandle entity_set, int *err) 
-{
-  MBErrorCode result = MBI->delete_entities(HANDLE_ARRAY_PTR(&entity_set), 1);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_destroyEntSet: couldn't delete the set.");
+  void iMesh_getNumEntSets(iMesh_Instance instance,
+                           /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                           /*in*/ const int num_hops,
+                           int *num_sets, int *err) 
+  {
+    if (num_hops > 1) {
+      iMesh_processError(iBase_ERROR_MAP[iBase_NOT_SUPPORTED], 
+                         "iMesh_getNumEntSets: not currently implemented for num_hops > 1.");
+      *num_sets = 0;
+      RETURN(iBase_ERROR_MAP[iBase_NOT_SUPPORTED]);
+    }
+    
+    MBErrorCode result = MBI->get_number_entities_by_type
+      (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, 
+       *num_sets, (num_hops == -1 ? true : false));
 
-  RETURN(iBase_SUCCESS);
-}
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_entitysetGetNumberEntitySets:ERROR getting number of entitysets "
+                      "in EntitySet, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
 
-void iMesh_isList (iMesh_Instance instance,
-                  /*in*/ const iBase_EntitySetHandle entity_set,
-                  int *is_list, int *err) 
-{
-  unsigned int options;
-  MBErrorCode result = MBI->get_meshset_options(ENTITY_HANDLE(entity_set), options);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_isList: couldn't query set.");
-  if (options & MESHSET_ORDERED)
-    *is_list = true;
-  else *is_list = false;
-  
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  } 
 
-void iMesh_getNumEntSets(iMesh_Instance instance,
+  void iMesh_getEntSets(iMesh_Instance instance,
                         /*in*/ const iBase_EntitySetHandle entity_set_handle,
                         /*in*/ const int num_hops,
-                        int *num_sets, int *err) 
-{
-  if (num_hops > 1) {
-    iMesh_processError(iBase_ERROR_MAP[iBase_NOT_SUPPORTED], 
-                       "iMesh_getNumEntSets: not currently implemented for num_hops > 1.");
-    *num_sets = 0;
-    RETURN(iBase_ERROR_MAP[iBase_NOT_SUPPORTED]);
-  }
+                        /*inout*/ iBase_EntitySetHandle** contained_entset_handles,
+                        /*inout*/ int* contained_entset_handles_allocated,
+                        /*inout*/ int* contained_entset_handles_size, int *err) 
+  {
+    if (num_hops > 1) {
+      iMesh_processError(iBase_NOT_SUPPORTED, "iMesh_getEntSets: not currently implemented for num_hops > 1.");
+      RETURN(iBase_NOT_SUPPORTED);
+    }
     
-  MBErrorCode result = MBI->get_number_entities_by_type
-    (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, 
-     *num_sets, (num_hops == -1 ? true : false));
+    MBRange sets;
+    MBErrorCode result = MBI->get_entities_by_type
+      (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, sets, (num_hops == -1 ? true : false));
+    if (MB_SUCCESS != result) {
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_entitysetGetEntitySets: problem getting entities by type.");
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_entitysetGetNumberEntitySets:ERROR getting number of entitysets "
-                    "in EntitySet, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
+    CHECK_SIZE(*contained_entset_handles, *contained_entset_handles_allocated,
+               (int)sets.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
 
-  RETURN(iBase_ERROR_MAP[result]);
-} 
+    MBRange::iterator iter = sets.begin();
+    MBRange::iterator end_iter = sets.end();
+    int k = 0;
 
-void iMesh_getEntSets(iMesh_Instance instance,
-                     /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                     /*in*/ const int num_hops,
-                     /*inout*/ iBase_EntitySetHandle** contained_entset_handles,
-                     /*inout*/ int* contained_entset_handles_allocated,
-                     /*inout*/ int* contained_entset_handles_size, int *err) 
-{
-  if (num_hops > 1) {
-    iMesh_processError(iBase_NOT_SUPPORTED, "iMesh_getEntSets: not currently implemented for num_hops > 1.");
-    RETURN(iBase_NOT_SUPPORTED);
+    for (; iter != end_iter; iter++)
+      (*contained_entset_handles)[k++] = (iBase_EntityHandle)*iter;
+
+    *contained_entset_handles_size = sets.size();
+    RETURN(iBase_SUCCESS);
   }
-    
-  MBRange sets;
-  MBErrorCode result = MBI->get_entities_by_type
-    (ENTITY_HANDLE(entity_set_handle), MBENTITYSET, sets, (num_hops == -1 ? true : false));
-  if (MB_SUCCESS != result) {
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_entitysetGetEntitySets: problem getting entities by type.");
+
+  void iMesh_addEntArrToSet(iMesh_Instance instance,
+                            /*in*/ const iBase_EntityHandle* entity_handles,
+                            /*in*/ const int entity_handles_size,
+                            /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
+  {
+    const MBEntityHandle *ents = CONST_HANDLE_ARRAY_PTR(entity_handles);
+    MBErrorCode result = MBI->add_entities(ENTITY_HANDLE(*entity_set),
+                                           ents, entity_handles_size);
+
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_addEntArrToSet:ERROR adding entities in EntitySet, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+  
     RETURN(iBase_ERROR_MAP[result]);
   }
 
-  CHECK_SIZE(*contained_entset_handles, *contained_entset_handles_allocated,
-             (int)sets.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
-
-  MBRange::iterator iter = sets.begin();
-  MBRange::iterator end_iter = sets.end();
-  int k = 0;
-
-  for (; iter != end_iter; iter++)
-    (*contained_entset_handles)[k++] = (iBase_EntityHandle)*iter;
-
-  *contained_entset_handles_size = sets.size();
-  RETURN(iBase_SUCCESS);
-}
-
-void iMesh_addEntArrToSet(iMesh_Instance instance,
-                         /*in*/ const iBase_EntityHandle* entity_handles,
-                         /*in*/ const int entity_handles_size,
+  void iMesh_addEntToSet(iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
                          /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
-{
-  const MBEntityHandle *ents = CONST_HANDLE_ARRAY_PTR(entity_handles);
-  MBErrorCode result = MBI->add_entities(ENTITY_HANDLE(*entity_set),
-                                         ents, entity_handles_size);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_addEntArrToSet:ERROR adding entities in EntitySet, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+  {
+    iMesh_addEntArrToSet(instance, &entity_handle, 1, entity_set, err);
   }
-  
-  RETURN(iBase_ERROR_MAP[result]);
-}
 
-void iMesh_addEntToSet(iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle entity_handle,
-                      /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
-{
-  iMesh_addEntArrToSet(instance, &entity_handle, 1, entity_set, err);
-}
+  void iMesh_rmvEntArrFromSet(iMesh_Instance instance,
+                              /*in*/ const iBase_EntityHandle* entity_handles,
+                              /*in*/ const int entity_handles_size,
+                              /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
+  {
+    const MBEntityHandle *ents = CONST_HANDLE_ARRAY_PTR(entity_handles);
 
-void iMesh_rmvEntArrFromSet(iMesh_Instance instance,
-                           /*in*/ const iBase_EntityHandle* entity_handles,
-                           /*in*/ const int entity_handles_size,
-                           /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
-{
-  const MBEntityHandle *ents = CONST_HANDLE_ARRAY_PTR(entity_handles);
-
-  MBErrorCode result = MBI->remove_entities
-    (ENTITY_HANDLE(*entity_set), ents, entity_handles_size);
+    MBErrorCode result = MBI->remove_entities
+      (ENTITY_HANDLE(*entity_set), ents, entity_handles_size);
   
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_rmvEntArrFromSet:ERROR removing entities in EntitySet, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_rmvEntArrFromSet:ERROR removing entities in EntitySet, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+  
+    RETURN(iBase_ERROR_MAP[result]);
   }
   
-  RETURN(iBase_ERROR_MAP[result]);
-}
-  
-void iMesh_rmvEntFromSet(iMesh_Instance instance,
-                        /*in*/ const iBase_EntityHandle entity_handle,
-                        /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
-{
-  iMesh_rmvEntArrFromSet(instance, &entity_handle, 1, entity_set, err);
-}
-  
-void iMesh_addEntSet(iMesh_Instance instance,
-                    /*in*/ const iBase_EntitySetHandle entity_set_to_add,
-                    /*inout*/ iBase_EntitySetHandle* entity_set_handle, int *err)
-{
-  MBErrorCode result = MBI->add_entities(ENTITY_HANDLE(*entity_set_handle),
-                                         CONST_HANDLE_ARRAY_PTR(&entity_set_to_add), 1);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_addEntSet:ERROR adding entitysets, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+  void iMesh_rmvEntFromSet(iMesh_Instance instance,
+                           /*in*/ const iBase_EntityHandle entity_handle,
+                           /*inout*/ iBase_EntitySetHandle* entity_set, int *err)
+  {
+    iMesh_rmvEntArrFromSet(instance, &entity_handle, 1, entity_set, err);
   }
   
+  void iMesh_addEntSet(iMesh_Instance instance,
+                       /*in*/ const iBase_EntitySetHandle entity_set_to_add,
+                       /*inout*/ iBase_EntitySetHandle* entity_set_handle, int *err)
+  {
+    MBErrorCode result = MBI->add_entities(ENTITY_HANDLE(*entity_set_handle),
+                                           CONST_HANDLE_ARRAY_PTR(&entity_set_to_add), 1);
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_rmvEntSet(iMesh_Instance instance,
-                    /*in*/ const iBase_EntitySetHandle entity_set_to_remove,
-                    /*inout*/ iBase_EntitySetHandle *entity_set_handle, int *err)
-{
-  MBErrorCode result = MBI->remove_entities
-    (ENTITY_HANDLE(*entity_set_handle), CONST_HANDLE_ARRAY_PTR(&entity_set_to_remove), 1);
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_addEntSet:ERROR adding entitysets, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
   
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_rmvEntSet:ERROR removing entitysets in EntitySet, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
-  
-  RETURN(iBase_ERROR_MAP[result]);
-}
 
-void iMesh_isEntContained (iMesh_Instance instance,
-                          /*in*/ const iBase_EntitySetHandle containing_entity_set,
-                          /*in*/ const iBase_EntitySetHandle contained_entity,
-                          int *is_contained, int *err) 
-{
-  MBRange all_ents;
-  MBErrorCode result = MBI->get_entities_by_handle(ENTITY_HANDLE(containing_entity_set),
-                                                   all_ents);
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_isContainedIn:ERROR getting entities in EntitySet, "
-                    "with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    RETURN(iBase_ERROR_MAP[result]);
   }
+
+  void iMesh_rmvEntSet(iMesh_Instance instance,
+                       /*in*/ const iBase_EntitySetHandle entity_set_to_remove,
+                       /*inout*/ iBase_EntitySetHandle *entity_set_handle, int *err)
+  {
+    MBErrorCode result = MBI->remove_entities
+      (ENTITY_HANDLE(*entity_set_handle), CONST_HANDLE_ARRAY_PTR(&entity_set_to_remove), 1);
   
-  if (all_ents.find(ENTITY_HANDLE(contained_entity)) == all_ents.end())
-    *is_contained = false;
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_rmvEntSet:ERROR removing entitysets in EntitySet, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
   
-  else
-    *is_contained = true;
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_isEntSetContained (iMesh_Instance instance,
+  void iMesh_isEntContained (iMesh_Instance instance,
                              /*in*/ const iBase_EntitySetHandle containing_entity_set,
-                             /*in*/ const iBase_EntitySetHandle contained_entity_set,
+                             /*in*/ const iBase_EntitySetHandle contained_entity,
                              int *is_contained, int *err) 
-{
-  iMesh_isEntContained(instance, containing_entity_set, contained_entity_set,
-                       is_contained, err);
-}
+  {
+    MBRange all_ents;
+    MBErrorCode result = MBI->get_entities_by_handle(ENTITY_HANDLE(containing_entity_set),
+                                                     all_ents);
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_isContainedIn:ERROR getting entities in EntitySet, "
+                      "with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+  
+    if (all_ents.find(ENTITY_HANDLE(contained_entity)) == all_ents.end())
+      *is_contained = false;
+  
+    else
+      *is_contained = true;
 
-void iMesh_addPrntChld(iMesh_Instance instance,
-                      /*inout*/ iBase_EntitySetHandle* parent_entity_set,
-                      /*inout*/ iBase_EntitySetHandle* child_entity_set, int *err) 
-{
-  MBErrorCode result = MBI->add_parent_child
-    (ENTITY_HANDLE(*parent_entity_set),
-     ENTITY_HANDLE(*child_entity_set));
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-  if (result != MB_SUCCESS) {
-    std::string msg("MB Mesh::addPrntChld: ERROR addParentChild failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+  void iMesh_isEntSetContained (iMesh_Instance instance,
+                                /*in*/ const iBase_EntitySetHandle containing_entity_set,
+                                /*in*/ const iBase_EntitySetHandle contained_entity_set,
+                                int *is_contained, int *err) 
+  {
+    iMesh_isEntContained(instance, containing_entity_set, contained_entity_set,
+                         is_contained, err);
   }
-  
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+  void iMesh_addPrntChld(iMesh_Instance instance,
+                         /*inout*/ iBase_EntitySetHandle* parent_entity_set,
+                         /*inout*/ iBase_EntitySetHandle* child_entity_set, int *err) 
+  {
+    MBErrorCode result = MBI->add_parent_child
+      (ENTITY_HANDLE(*parent_entity_set),
+       ENTITY_HANDLE(*child_entity_set));
 
-void iMesh_rmvPrntChld(iMesh_Instance instance,
-                      /*inout*/ iBase_EntitySetHandle* parent_entity_set,
-                      /*inout*/ iBase_EntitySetHandle* child_entity_set, int *err)
-{
-  MBErrorCode result = MBI->remove_parent_child
-    (ENTITY_HANDLE(*parent_entity_set),
-     ENTITY_HANDLE(*child_entity_set));
+    if (result != MB_SUCCESS) {
+      std::string msg("MB Mesh::addPrntChld: ERROR addParentChild failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
   
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_rmvPrntChld: ERROR RemoveParentChild failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+  void iMesh_rmvPrntChld(iMesh_Instance instance,
+                         /*inout*/ iBase_EntitySetHandle* parent_entity_set,
+                         /*inout*/ iBase_EntitySetHandle* child_entity_set, int *err)
+  {
+    MBErrorCode result = MBI->remove_parent_child
+      (ENTITY_HANDLE(*parent_entity_set),
+       ENTITY_HANDLE(*child_entity_set));
+  
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_rmvPrntChld: ERROR RemoveParentChild failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
 
-void iMesh_isChildOf(iMesh_Instance instance,
-                    /*in*/ const iBase_EntitySetHandle parent_entity_set,
-                    /*in*/ const iBase_EntitySetHandle child_entity_set,
-                    int *is_child, int *err)
-{
-  std::vector<MBEntityHandle> children;
-
-  MBErrorCode result = MBI->get_child_meshsets
-    (ENTITY_HANDLE(parent_entity_set), children);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_isChildOf: ERROR IsParentChildRelated failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    *is_child = false;
     RETURN(iBase_ERROR_MAP[result]);
   }
-  
 
-  
-  if (std::find(children.begin(), children.end(), ENTITY_HANDLE(child_entity_set))
-      != children.end())
-    *is_child = true;
+  void iMesh_isChildOf(iMesh_Instance instance,
+                       /*in*/ const iBase_EntitySetHandle parent_entity_set,
+                       /*in*/ const iBase_EntitySetHandle child_entity_set,
+                       int *is_child, int *err)
+  {
+    std::vector<MBEntityHandle> children;
 
-  else
-    *is_child = false;
+    MBErrorCode result = MBI->get_child_meshsets
+      (ENTITY_HANDLE(parent_entity_set), children);
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_isChildOf: ERROR IsParentChildRelated failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      *is_child = false;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
 
-void iMesh_getNumChld(iMesh_Instance instance,
-                     /*in*/ const iBase_EntitySetHandle entity_set,
-                     /*in*/ const int num_hops,
-                     int *num_child, int *err)
-{
-  *num_child = 0;
-  MBErrorCode result = MBI->num_child_meshsets
-    (ENTITY_HANDLE(entity_set), num_child, num_hops);
+  
+    if (std::find(children.begin(), children.end(), ENTITY_HANDLE(child_entity_set))
+        != children.end())
+      *is_child = true;
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_getNumChld: ERROR GetNumChildren failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    *num_child = 0;
+    else
+      *is_child = false;
+
     RETURN(iBase_ERROR_MAP[result]);
   }
 
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getNumChld(iMesh_Instance instance,
+                        /*in*/ const iBase_EntitySetHandle entity_set,
+                        /*in*/ const int num_hops,
+                        int *num_child, int *err)
+  {
+    *num_child = 0;
+    MBErrorCode result = MBI->num_child_meshsets
+      (ENTITY_HANDLE(entity_set), num_child, num_hops);
 
-void iMesh_getNumPrnt(iMesh_Instance instance,
-                     /*in*/ const iBase_EntitySetHandle entity_set,
-                     /*in*/ const int num_hops,
-                     int *num_parent, int *err)
-{
-  *num_parent = 0;
-  MBErrorCode result = MBI->num_parent_meshsets
-    (ENTITY_HANDLE(entity_set), num_parent, num_hops);
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_getNumChld: ERROR GetNumChildren failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      *num_child = 0;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_getNumPrnt:\
-           ERROR GetNumParents failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
+    RETURN(iBase_SUCCESS);
   }
 
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getNumPrnt(iMesh_Instance instance,
+                        /*in*/ const iBase_EntitySetHandle entity_set,
+                        /*in*/ const int num_hops,
+                        int *num_parent, int *err)
+  {
+    *num_parent = 0;
+    MBErrorCode result = MBI->num_parent_meshsets
+      (ENTITY_HANDLE(entity_set), num_parent, num_hops);
 
-void iMesh_getChldn(iMesh_Instance instance,
-                   /*in*/ const iBase_EntitySetHandle from_entity_set,
-                   /*in*/ const int num_hops,
-                   /*out*/ iBase_EntitySetHandle** entity_set_handles,
-                   /*out*/ int* entity_set_handles_allocated,
-                   /*out*/ int* entity_set_handles_size, int *err) 
-{
-  std::vector<MBEntityHandle> children;
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_getNumPrnt:\
+           ERROR GetNumParents failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  MBErrorCode result = MBI->get_child_meshsets
-    (ENTITY_HANDLE(from_entity_set), children, num_hops);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_getChldn:\
-           ERROR getChildren failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
+    RETURN(iBase_SUCCESS);
   }
 
-  CHECK_SIZE(*entity_set_handles, *entity_set_handles_allocated,
-             (int)children.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
+  void iMesh_getChldn(iMesh_Instance instance,
+                      /*in*/ const iBase_EntitySetHandle from_entity_set,
+                      /*in*/ const int num_hops,
+                      /*out*/ iBase_EntitySetHandle** entity_set_handles,
+                      /*out*/ int* entity_set_handles_allocated,
+                      /*out*/ int* entity_set_handles_size, int *err) 
+  {
+    std::vector<MBEntityHandle> children;
 
-  MBEntityHandle *ents = HANDLE_ARRAY_PTR(*entity_set_handles);
-    // use a memcpy for efficiency
-  memcpy(ents, &children[0], children.size()*sizeof(MBEntityHandle));
+    MBErrorCode result = MBI->get_child_meshsets
+      (ENTITY_HANDLE(from_entity_set), children, num_hops);
 
-  *entity_set_handles_size = children.size();
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_getChldn:\
+           ERROR getChildren failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    CHECK_SIZE(*entity_set_handles, *entity_set_handles_allocated,
+               (int)children.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
 
-void iMesh_getPrnts(iMesh_Instance instance,
-                   /*in*/ const iBase_EntitySetHandle from_entity_set,
-                   /*in*/ const int num_hops,
-                   /*out*/ iBase_EntitySetHandle** entity_set_handles,
-                   /*out*/ int* entity_set_handles_allocated,
-                   /*out*/ int* entity_set_handles_size, int *err) 
-{
-  std::vector<MBEntityHandle> parents;
+    MBEntityHandle *ents = HANDLE_ARRAY_PTR(*entity_set_handles);
+      // use a memcpy for efficiency
+    memcpy(ents, &children[0], children.size()*sizeof(MBEntityHandle));
 
-  MBErrorCode result = MBI->get_parent_meshsets
-    (ENTITY_HANDLE(from_entity_set), parents, num_hops);
+    *entity_set_handles_size = children.size();
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_getPrnts:\
-           ERROR getParents failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
     RETURN(iBase_ERROR_MAP[result]);
   }
 
-  CHECK_SIZE(*entity_set_handles, *entity_set_handles_allocated,
-             (int)parents.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
+  void iMesh_getPrnts(iMesh_Instance instance,
+                      /*in*/ const iBase_EntitySetHandle from_entity_set,
+                      /*in*/ const int num_hops,
+                      /*out*/ iBase_EntitySetHandle** entity_set_handles,
+                      /*out*/ int* entity_set_handles_allocated,
+                      /*out*/ int* entity_set_handles_size, int *err) 
+  {
+    std::vector<MBEntityHandle> parents;
 
-  MBEntityHandle *ents = HANDLE_ARRAY_PTR(*entity_set_handles);
-    // use a memcpy for efficiency
-  memcpy(ents, &parents[0], parents.size()*sizeof(MBEntityHandle));
+    MBErrorCode result = MBI->get_parent_meshsets
+      (ENTITY_HANDLE(from_entity_set), parents, num_hops);
 
-  *entity_set_handles_size = parents.size();
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_getPrnts:\
+           ERROR getParents failed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    CHECK_SIZE(*entity_set_handles, *entity_set_handles_allocated,
+               (int)parents.size(), iBase_EntitySetHandle, iBase_MEMORY_ALLOCATION_FAILED);
 
-void iMesh_setVtxArrCoords (iMesh_Instance instance,
-                           /*in*/ iBase_EntityHandle* vertex_handles,
-                           /*in*/ const int vertex_handles_size,
-                           /*in*/ const int storage_order,
-                           /*in*/ const double* new_coords,
-                           /*in*/ const int new_coords_size, int *err) 
-{
-  MBErrorCode result = MB_SUCCESS, tmp_result;
-  if (storage_order == iBase_INTERLEAVED) {
-    result = MBI->set_coords(HANDLE_ARRAY_PTR(vertex_handles),
-                             vertex_handles_size, new_coords);
+    MBEntityHandle *ents = HANDLE_ARRAY_PTR(*entity_set_handles);
+      // use a memcpy for efficiency
+    memcpy(ents, &parents[0], parents.size()*sizeof(MBEntityHandle));
+
+    *entity_set_handles_size = parents.size();
+
+    RETURN(iBase_ERROR_MAP[result]);
   }
-  else {
-    MBEntityHandle *verts = HANDLE_ARRAY_PTR(vertex_handles);
-    double dummy[3];
-    for (int i = 0; i < vertex_handles_size; i++) {
-      dummy[0] = new_coords[i]; dummy[1] = new_coords[vertex_handles_size+i]; 
-      dummy[2] = new_coords[2*vertex_handles_size+i];
-      tmp_result = MBI->set_coords(&verts[i], 1, dummy);
-      if (MB_SUCCESS != tmp_result) result = tmp_result;
+
+  void iMesh_setVtxArrCoords (iMesh_Instance instance,
+                              /*in*/ iBase_EntityHandle* vertex_handles,
+                              /*in*/ const int vertex_handles_size,
+                              /*in*/ const int storage_order,
+                              /*in*/ const double* new_coords,
+                              /*in*/ const int new_coords_size, int *err) 
+  {
+    MBErrorCode result = MB_SUCCESS, tmp_result;
+    if (storage_order == iBase_INTERLEAVED) {
+      result = MBI->set_coords(HANDLE_ARRAY_PTR(vertex_handles),
+                               vertex_handles_size, new_coords);
     }
-  }
+    else {
+      MBEntityHandle *verts = HANDLE_ARRAY_PTR(vertex_handles);
+      double dummy[3];
+      for (int i = 0; i < vertex_handles_size; i++) {
+        dummy[0] = new_coords[i]; dummy[1] = new_coords[vertex_handles_size+i]; 
+        dummy[2] = new_coords[2*vertex_handles_size+i];
+        tmp_result = MBI->set_coords(&verts[i], 1, dummy);
+        if (MB_SUCCESS != tmp_result) result = tmp_result;
+      }
+    }
   
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_setVtxArrCoords: problem setting coordinates.");
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_setVtxArrCoords: problem setting coordinates.");
   
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_createVtxArr(iMesh_Instance instance,
-                       /*in*/ const int num_verts,
-                       /*in*/ const int storage_order,
-                       /*in*/ const double* new_coords,
-                       /*in*/ const int new_coords_size,
-                       /*inout*/ iBase_EntityHandle** new_vertex_handles,
-                       /*inout*/ int* new_vertex_handles_allocated,
-                       /*inout*/ int* new_vertex_handles_size, int *err) 
-{
-    // if there aren't any elements in the array, allocate it
-  CHECK_SIZE(*new_vertex_handles, *new_vertex_handles_allocated,
-             num_verts, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+  void iMesh_createVtxArr(iMesh_Instance instance,
+                          /*in*/ const int num_verts,
+                          /*in*/ const int storage_order,
+                          /*in*/ const double* new_coords,
+                          /*in*/ const int new_coords_size,
+                          /*inout*/ iBase_EntityHandle** new_vertex_handles,
+                          /*inout*/ int* new_vertex_handles_allocated,
+                          /*inout*/ int* new_vertex_handles_size, int *err) 
+  {
+      // if there aren't any elements in the array, allocate it
+    CHECK_SIZE(*new_vertex_handles, *new_vertex_handles_allocated,
+               num_verts, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
   
-    // make the entities
-  MBEntityHandle *new_verts = HANDLE_ARRAY_PTR(*new_vertex_handles);
+      // make the entities
+    MBEntityHandle *new_verts = HANDLE_ARRAY_PTR(*new_vertex_handles);
   
-  for (int i = 0; i < num_verts; i++) {
-    MBErrorCode result = MBI->create_vertex(&new_coords[3*i], new_verts[i]);
-    if (MB_SUCCESS != result) {
-      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createVtxArr: couldn't create vertex.");
-      RETURN(iBase_ERROR_MAP[result]);
-    }
-  }  
+    for (int i = 0; i < num_verts; i++) {
+      MBErrorCode result = MBI->create_vertex(&new_coords[3*i], new_verts[i]);
+      if (MB_SUCCESS != result) {
+        iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createVtxArr: couldn't create vertex.");
+        RETURN(iBase_ERROR_MAP[result]);
+      }
+    }  
 
-  *new_vertex_handles_size = new_coords_size/3;
+    *new_vertex_handles_size = new_coords_size/3;
 
-  RETURN(iBase_SUCCESS);
-}
+    RETURN(iBase_SUCCESS);
+  }
                                                    
-void iMesh_createEntArr(iMesh_Instance instance,
-                       /*in*/ const int new_entity_topology,
-                       /*in*/ const iBase_EntityHandle* lower_order_entity_handles,
-                       /*in*/ const int lower_order_entity_handles_size,
-                       /*out*/ iBase_EntityHandle** new_entity_handles,
-                       /*out*/ int* new_entity_handles_allocated,
-                       /*out*/ int* new_entity_handles_size,
-                       /*inout*/  int** status,
-                       /*inout*/ int* status_allocated,
-                       /*out*/ int* status_size, int *err) 
-{
-    // for now, throw an error if lower order entity handles aren't vertices
-  MBEntityType this_type = mb_topology_table[new_entity_topology];
-  int num_ents = 0, num_verts;
-  const MBEntityHandle *lower_ents;
-  if (MBVERTEX != this_type) {
-    num_verts = MBCN::VerticesPerEntity(this_type);
-    num_ents = lower_order_entity_handles_size / num_verts;
-    lower_ents = CONST_HANDLE_ARRAY_PTR(lower_order_entity_handles);
-      // check that we have the right number of lower order entity handles
-    if (lower_order_entity_handles_size % MBCN::VerticesPerEntity(this_type) != 0) {
-      iMesh_processError(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT], "iMesh_createEntArr: wrong # vertices for this entity type.");
-      RETURN(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT]);
+  void iMesh_createEntArr(iMesh_Instance instance,
+                          /*in*/ const int new_entity_topology,
+                          /*in*/ const iBase_EntityHandle* lower_order_entity_handles,
+                          /*in*/ const int lower_order_entity_handles_size,
+                          /*out*/ iBase_EntityHandle** new_entity_handles,
+                          /*out*/ int* new_entity_handles_allocated,
+                          /*out*/ int* new_entity_handles_size,
+                          /*inout*/  int** status,
+                          /*inout*/ int* status_allocated,
+                          /*out*/ int* status_size, int *err) 
+  {
+      // for now, throw an error if lower order entity handles aren't vertices
+    MBEntityType this_type = mb_topology_table[new_entity_topology];
+    int num_ents = 0, num_verts;
+    const MBEntityHandle *lower_ents;
+    if (MBVERTEX != this_type) {
+      num_verts = MBCN::VerticesPerEntity(this_type);
+      num_ents = lower_order_entity_handles_size / num_verts;
+      lower_ents = CONST_HANDLE_ARRAY_PTR(lower_order_entity_handles);
+        // check that we have the right number of lower order entity handles
+      if (lower_order_entity_handles_size % MBCN::VerticesPerEntity(this_type) != 0) {
+        iMesh_processError(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT], "iMesh_createEntArr: wrong # vertices for this entity type.");
+        RETURN(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT]);
+      }
     }
-  }
-  else {
-    iMesh_processError(iBase_ERROR_MAP[iBase_INVALID_ARGUMENT], "iMesh_createEntArr: can't create vertices with this function, use createVtxArr instead.");
-    RETURN(iBase_ERROR_MAP[iBase_INVALID_ARGUMENT]);
-  }
+    else {
+      iMesh_processError(iBase_ERROR_MAP[iBase_INVALID_ARGUMENT], "iMesh_createEntArr: can't create vertices with this function, use createVtxArr instead.");
+      RETURN(iBase_ERROR_MAP[iBase_INVALID_ARGUMENT]);
+    }
   
-  if (num_ents == 0) {
-    iMesh_processError(iBase_INVALID_ENTITY_COUNT, 
-                       "iMesh_createEntArr: called to create 0 entities.");
-    RETURN(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT]);
-  }
+    if (num_ents == 0) {
+      iMesh_processError(iBase_INVALID_ENTITY_COUNT, 
+                         "iMesh_createEntArr: called to create 0 entities.");
+      RETURN(iBase_ERROR_MAP[iBase_INVALID_ENTITY_COUNT]);
+    }
 
-    // if there aren't any elements in the array, allocate it
-  CHECK_SIZE(*new_entity_handles, *new_entity_handles_allocated,
-             num_ents, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+      // if there aren't any elements in the array, allocate it
+    CHECK_SIZE(*new_entity_handles, *new_entity_handles_allocated,
+               num_ents, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
   
-  CHECK_SIZE(*status, *status_allocated, num_ents, 
-             int, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*status, *status_allocated, num_ents, 
+               int, iBase_MEMORY_ALLOCATION_FAILED);
   
-    // make the entities
-  MBEntityHandle *new_ents = HANDLE_ARRAY_PTR(*new_entity_handles);
-  static double dum_coords[] = {0.0, 0.0, 0.0};
+      // make the entities
+    MBEntityHandle *new_ents = HANDLE_ARRAY_PTR(*new_entity_handles);
+    static double dum_coords[] = {0.0, 0.0, 0.0};
 
-  MBErrorCode tmp_result, result = MB_SUCCESS;
+    MBErrorCode tmp_result, result = MB_SUCCESS;
   
-  if (this_type == MBVERTEX) {
-    for (int i = 0; i < num_ents; i++) {
-      tmp_result = MBI->create_vertex(dum_coords, new_ents[i]);
-      if (MB_SUCCESS != tmp_result) {
-        (*status)[i] = iBase_CREATION_FAILED;
-        result = tmp_result;
-      }
-      else
-        (*status)[i] = iBase_NEW;
-    }  
-  }
-  else {
-    for (int i = 0; i < num_ents; i++) {
-      tmp_result = MBI->create_element(this_type, lower_ents, num_verts,
-                                       new_ents[i]);
-      if (MB_SUCCESS != tmp_result) {
-        (*status)[i] = iBase_CREATION_FAILED;
-        result = tmp_result;
-      }
-      else
-        (*status)[i] = iBase_NEW;
+    if (this_type == MBVERTEX) {
+      for (int i = 0; i < num_ents; i++) {
+        tmp_result = MBI->create_vertex(dum_coords, new_ents[i]);
+        if (MB_SUCCESS != tmp_result) {
+          (*status)[i] = iBase_CREATION_FAILED;
+          result = tmp_result;
+        }
+        else
+          (*status)[i] = iBase_NEW;
+      }  
+    }
+    else {
+      for (int i = 0; i < num_ents; i++) {
+        tmp_result = MBI->create_element(this_type, lower_ents, num_verts,
+                                         new_ents[i]);
+        if (MB_SUCCESS != tmp_result) {
+          (*status)[i] = iBase_CREATION_FAILED;
+          result = tmp_result;
+        }
+        else
+          (*status)[i] = iBase_NEW;
     
-      lower_ents += num_verts;
+        lower_ents += num_verts;
+      }
     }
-  }
 
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createEntArr: couldn't create one of the entities.");
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_createEntArr: couldn't create one of the entities.");
 
-  if (MB_SUCCESS == result) {
-    *new_entity_handles_size = num_ents;
-    *status_size = num_ents;
-  }
+    if (MB_SUCCESS == result) {
+      *new_entity_handles_size = num_ents;
+      *status_size = num_ents;
+    }
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-                                                   
-void iMesh_deleteEntArr(iMesh_Instance instance,
-                       /*in*/ iBase_EntityHandle* entity_handles,
-                       /*in*/ const int entity_handles_size, int *err) 
-{
-  if (0 == entity_handles_size) {
-    RETURN(iBase_SUCCESS);
+    RETURN(iBase_ERROR_MAP[result]);
   }
+                                                   
+  void iMesh_deleteEntArr(iMesh_Instance instance,
+                          /*in*/ iBase_EntityHandle* entity_handles,
+                          /*in*/ const int entity_handles_size, int *err) 
+  {
+    if (0 == entity_handles_size) {
+      RETURN(iBase_SUCCESS);
+    }
 
-  MBErrorCode result = MBI->delete_entities(HANDLE_ARRAY_PTR(entity_handles),
-                                            entity_handles_size);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_deleteEntArr: trouble deleting entities.");
+    MBErrorCode result = MBI->delete_entities(HANDLE_ARRAY_PTR(entity_handles),
+                                              entity_handles_size);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_deleteEntArr: trouble deleting entities.");
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
                                                  
-void iMesh_createTag(iMesh_Instance instance,
-                    /*in*/ const char* tag_name,
-                    /*in*/ const int tag_size,
-                    /*in*/ const int tag_type,
-                    /*out*/ iBase_TagHandle* tag_handle, 
-                     int *err,
-                     const int tag_name_size)
-{
-  MBTag new_tag;
-  int this_size = tag_size;
+  void iMesh_createTag(iMesh_Instance instance,
+                       /*in*/ const char* tag_name,
+                       /*in*/ const int tag_size,
+                       /*in*/ const int tag_type,
+                       /*out*/ iBase_TagHandle* tag_handle, 
+                       int *err,
+                       const int tag_name_size)
+  {
+    MBTag new_tag;
+    int this_size = tag_size;
 
-  std::string tmp_tagname(tag_name);
-  eatwhitespace(tmp_tagname);
+    std::string tmp_tagname(tag_name);
+    eatwhitespace(tmp_tagname);
 
-  switch (tag_type) {
-    case iBase_INTEGER:
-      this_size *= sizeof(int);
-      break;
-    case iBase_DOUBLE:
-      this_size *= sizeof(double);
-      break;
-    case iBase_ENTITY_HANDLE:
-      this_size *= sizeof(iBase_EntityHandle);
-      break;
-    case iBase_BYTES:
-      break;
-  }
+    switch (tag_type) {
+      case iBase_INTEGER:
+        this_size *= sizeof(int);
+        break;
+      case iBase_DOUBLE:
+        this_size *= sizeof(double);
+        break;
+      case iBase_ENTITY_HANDLE:
+        this_size *= sizeof(iBase_EntityHandle);
+        break;
+      case iBase_BYTES:
+        break;
+    }
       
-  MBErrorCode result = MBI->tag_create(tmp_tagname.c_str(), this_size,
-                                       MB_TAG_SPARSE, 
-                                       mb_data_type_table[tag_type],
-                                       new_tag,
-                                       NULL);
+    MBErrorCode result = MBI->tag_create(tmp_tagname.c_str(), this_size,
+                                         MB_TAG_SPARSE, 
+                                         mb_data_type_table[tag_type],
+                                         new_tag,
+                                         NULL);
 
-  if (MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result) {
-    std::string msg = std::string("iMesh_createTag: error creating tag with name '") +
-      std::string(tag_name) + std::string("'.");
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
-  else if (MB_ALREADY_ALLOCATED == result) {
-    std::string msg = std::string("iMesh_createTag: tag with name '") +
-      std::string(tag_name) + std::string("' already created.");
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
+    if (MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result) {
+      std::string msg = std::string("iMesh_createTag: error creating tag with name '") +
+        std::string(tag_name) + std::string("'.");
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+    else if (MB_ALREADY_ALLOCATED == result) {
+      std::string msg = std::string("iMesh_createTag: tag with name '") +
+        std::string(tag_name) + std::string("' already created.");
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
 
-  *tag_handle = (iBase_TagHandle) new_tag;
+    *tag_handle = (iBase_TagHandle) new_tag;
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_destroyTag(iMesh_Instance instance,
-                     /*in*/ iBase_TagHandle tag_handle,
-                     /*in*/ const int forced, int *err)
-{
-    // might need to check if it's used first
-  if (false == forced) {
-    MBRange ents;
-    MBErrorCode result;
-    MBTag this_tag = TAG_HANDLE(tag_handle);
-    for (MBEntityType this_type = MBVERTEX; this_type != MBMAXTYPE; this_type++) {
-      result = MBI->get_entities_by_type_and_tag(0, this_type, &this_tag, NULL, 1, 
-                                                 ents, MBInterface::UNION);
-      if (result != MB_SUCCESS) {
-        std::string msg("iMesh_destroyTag: problem finding tag., with error type: ");
-        msg += MBI->get_error_string(result);
-        iMesh_processError(iBase_ERROR_MAP[result],
-                           msg.c_str());
+  void iMesh_destroyTag(iMesh_Instance instance,
+                        /*in*/ iBase_TagHandle tag_handle,
+                        /*in*/ const int forced, int *err)
+  {
+      // might need to check if it's used first
+    if (false == forced) {
+      MBRange ents;
+      MBErrorCode result;
+      MBTag this_tag = TAG_HANDLE(tag_handle);
+      for (MBEntityType this_type = MBVERTEX; this_type != MBMAXTYPE; this_type++) {
+        result = MBI->get_entities_by_type_and_tag(0, this_type, &this_tag, NULL, 1, 
+                                                   ents, MBInterface::UNION);
+        if (result != MB_SUCCESS) {
+          std::string msg("iMesh_destroyTag: problem finding tag., with error type: ");
+          msg += MBI->get_error_string(result);
+          iMesh_processError(iBase_ERROR_MAP[result],
+                             msg.c_str());
+        }
+        else if (!ents.empty()) {
+          iMesh_processError(iBase_FAILURE, "iMesh_destroyTag: forced=false and entities"
+                             " are still assigned this tag.");
+          RETURN(iBase_FAILURE);
+        }
       }
-      else if (!ents.empty()) {
-        iMesh_processError(iBase_FAILURE, "iMesh_destroyTag: forced=false and entities"
-                           " are still assigned this tag.");
-        RETURN(iBase_FAILURE);
-      }
     }
-  }
   
-    // ok, good to go - either forced or no entities with this tag
-  MBErrorCode result = MBI->tag_delete(TAG_HANDLE(tag_handle));
-  if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_destroyTag: problem deleting tag.");
+      // ok, good to go - either forced or no entities with this tag
+    MBErrorCode result = MBI->tag_delete(TAG_HANDLE(tag_handle));
+    if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_destroyTag: problem deleting tag.");
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_getTagName(iMesh_Instance instance,
-                     /*in*/ const iBase_TagHandle tag_handle,
-                     char *out_data, int *err,
-                     int out_data_len)
-{
-  static ::std::string name;
-  MBErrorCode result = MBI->tag_get_name(TAG_HANDLE(tag_handle), name);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagName: problem getting name.")
-      else
-        iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+  void iMesh_getTagName(iMesh_Instance instance,
+                        /*in*/ const iBase_TagHandle tag_handle,
+                        char *out_data, int *err,
+                        int out_data_len)
+  {
+    static ::std::string name;
+    MBErrorCode result = MBI->tag_get_name(TAG_HANDLE(tag_handle), name);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagName: problem getting name.")
+        else
+          iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
 
-  strncpy(out_data, name.c_str(), out_data_len);
+    strncpy(out_data, name.c_str(), out_data_len);
 
-  RETURN(iMesh_LAST_ERROR.error_type);
-}
-
-void iMesh_getTagType (iMesh_Instance instance,
-                      /*in*/ const iBase_TagHandle tag_handle,
-                      int *value_type, int *err) 
-{
-  MBDataType this_type;
-  MBErrorCode result = MBI->tag_get_data_type(TAG_HANDLE(tag_handle),
-                                              this_type);
-  if (MB_SUCCESS != result) {
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagType: problem getting type.");
-    *value_type = iBase_BYTES;
-    RETURN(iBase_ERROR_MAP[result]);
+    RETURN(iMesh_LAST_ERROR.error_type);
   }
-  
-  else
+
+  void iMesh_getTagType (iMesh_Instance instance,
+                         /*in*/ const iBase_TagHandle tag_handle,
+                         int *value_type, int *err) 
   {
-    iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
-    *value_type = tstt_data_type_table[this_type];
-    RETURN(iBase_ERROR_MAP[result]);
+    MBDataType this_type;
+    MBErrorCode result = MBI->tag_get_data_type(TAG_HANDLE(tag_handle),
+                                                this_type);
+    if (MB_SUCCESS != result) {
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagType: problem getting type.");
+      *value_type = iBase_BYTES;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+  
+    else
+    {
+      iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+      *value_type = tstt_data_type_table[this_type];
+      RETURN(iBase_ERROR_MAP[result]);
+    }
   }
-}
 
-void iMesh_getTagSizeValues(iMesh_Instance instance,
-                           /*in*/ const iBase_TagHandle tag_handle,
-                           int *tag_size_val, int *err)
-{
-  MBErrorCode result = MBI->tag_get_size(TAG_HANDLE(tag_handle), *tag_size_val);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagSize: problem getting size.")
-      else {
-        int this_type;
-        int success;
-        iMesh_getTagType(instance, tag_handle, &this_type, &success);
-        if (iBase_ERROR_MAP[success] != iBase_SUCCESS) 
-          return;
-        switch (this_type) {
-          case iBase_INTEGER:
-            *tag_size_val /= sizeof(int);
-            break;
-          case iBase_DOUBLE:
-            *tag_size_val /= sizeof(double);
-            break;
-          case iBase_ENTITY_HANDLE:
-            *tag_size_val /= sizeof(MBEntityHandle);
-            break;
-          case iBase_BYTES:
-            break;
-        }
+  void iMesh_getTagSizeValues(iMesh_Instance instance,
+                              /*in*/ const iBase_TagHandle tag_handle,
+                              int *tag_size_val, int *err)
+  {
+    MBErrorCode result = MBI->tag_get_size(TAG_HANDLE(tag_handle), *tag_size_val);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagSize: problem getting size.")
+        else {
+          int this_type;
+          int success;
+          iMesh_getTagType(instance, tag_handle, &this_type, &success);
+          if (iBase_ERROR_MAP[success] != iBase_SUCCESS) 
+            return;
+          switch (this_type) {
+            case iBase_INTEGER:
+              *tag_size_val /= sizeof(int);
+              break;
+            case iBase_DOUBLE:
+              *tag_size_val /= sizeof(double);
+              break;
+            case iBase_ENTITY_HANDLE:
+              *tag_size_val /= sizeof(MBEntityHandle);
+              break;
+            case iBase_BYTES:
+              break;
+          }
         
-        iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
-      }
+          iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+        }
 
   
-  RETURN(iMesh_LAST_ERROR.error_type);
-}
+    RETURN(iMesh_LAST_ERROR.error_type);
+  }
 
-void iMesh_getTagSizeBytes(iMesh_Instance instance,
-                          /*in*/ const iBase_TagHandle tag_handle,
-                          int *tag_size_bytes, int *err)
-{
-  MBErrorCode result = MBI->tag_get_size(TAG_HANDLE(tag_handle), *tag_size_bytes);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagSize: problem getting size.")
-      else {
-        iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
-      }
+  void iMesh_getTagSizeBytes(iMesh_Instance instance,
+                             /*in*/ const iBase_TagHandle tag_handle,
+                             int *tag_size_bytes, int *err)
+  {
+    MBErrorCode result = MBI->tag_get_size(TAG_HANDLE(tag_handle), *tag_size_bytes);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getTagSize: problem getting size.")
+        else {
+          iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+        }
   
-  RETURN(iMesh_LAST_ERROR.error_type);
-}
+    RETURN(iMesh_LAST_ERROR.error_type);
+  }
 
-void iMesh_getTagHandle(iMesh_Instance instance,
-                       /*in*/ const char* tag_name,
-                       iBase_TagHandle *tag_handle, int *err,
-                        const int tag_name_len)
-{
-  MBErrorCode result = MBI->tag_get_handle(tag_name, (MBTag&)*tag_handle);
+  void iMesh_getTagHandle(iMesh_Instance instance,
+                          /*in*/ const char* tag_name,
+                          iBase_TagHandle *tag_handle, int *err,
+                          const int tag_name_len)
+  {
+    MBErrorCode result = MBI->tag_get_handle(tag_name, (MBTag&)*tag_handle);
     
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_getTagHandle: problem getting handle for tag named '");
-    msg += std::string(tag_name) + std::string("'");
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    *tag_handle = 0;
-    return;
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_getTagHandle: problem getting handle for tag named '");
+      msg += std::string(tag_name) + std::string("'");
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      *tag_handle = 0;
+      return;
+    }
+
+    iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
+    RETURN(iMesh_LAST_ERROR.error_type);
   }
 
-  iMesh_LAST_ERROR.error_type = iBase_SUCCESS;
-  RETURN(iMesh_LAST_ERROR.error_type);
-}
+  void iMesh_setEntSetData (iMesh_Instance instance,
+                            /*in*/ iBase_EntitySetHandle entity_set_handle,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*in*/ const char* tag_value,
+                            /*in*/ const int , int *err) 
+  {
+    MBErrorCode result;
 
-void iMesh_setEntSetData (iMesh_Instance instance,
-                         /*in*/ iBase_EntitySetHandle entity_set_handle,
-                         /*in*/ const iBase_TagHandle tag_handle,
-                         /*in*/ const char* tag_value,
-                         /*in*/ const int , int *err) 
-{
-  MBErrorCode result;
-
-  if (entity_set_handle == 0)
-      // set the tag data on this entity set
-    result = MBI->tag_set_data(TAG_HANDLE(tag_handle),
-                               NULL, 0, tag_value);
-  else
-    result = MBI->tag_set_data(TAG_HANDLE(tag_handle),
-                               HANDLE_ARRAY_PTR(&entity_set_handle), 1, tag_value);
+    if (entity_set_handle == 0)
+        // set the tag data on this entity set
+      result = MBI->tag_set_data(TAG_HANDLE(tag_handle),
+                                 NULL, 0, tag_value);
+    else
+      result = MBI->tag_set_data(TAG_HANDLE(tag_handle),
+                                 HANDLE_ARRAY_PTR(&entity_set_handle), 1, tag_value);
   
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_setEntSetData: error");
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_setEntSetData: error");
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_setEntSetIntData (iMesh_Instance instance,
-                            /*in*/ iBase_EntitySetHandle entity_set,
-                            /*in*/ const iBase_TagHandle tag_handle,
-                            /*in*/ const int tag_value, int *err) 
-{
-  iMesh_setEntSetData(instance, entity_set, tag_handle, 
-                      reinterpret_cast<const char*>(&tag_value), 
-                      sizeof(int), err);
-}
+  void iMesh_setEntSetIntData (iMesh_Instance instance,
+                               /*in*/ iBase_EntitySetHandle entity_set,
+                               /*in*/ const iBase_TagHandle tag_handle,
+                               /*in*/ const int tag_value, int *err) 
+  {
+    iMesh_setEntSetData(instance, entity_set, tag_handle, 
+                        reinterpret_cast<const char*>(&tag_value), 
+                        sizeof(int), err);
+  }
 
-void iMesh_setEntSetDblData (iMesh_Instance instance,
-                            /*in*/ iBase_EntitySetHandle entity_set,
-                            /*in*/ const iBase_TagHandle tag_handle,
-                            /*in*/ const double tag_value, int *err) 
-{
-  iMesh_setEntSetData(instance, entity_set, tag_handle, 
-                      reinterpret_cast<const char*>(&tag_value),
-                      sizeof(double), err);
-}
+  void iMesh_setEntSetDblData (iMesh_Instance instance,
+                               /*in*/ iBase_EntitySetHandle entity_set,
+                               /*in*/ const iBase_TagHandle tag_handle,
+                               /*in*/ const double tag_value, int *err) 
+  {
+    iMesh_setEntSetData(instance, entity_set, tag_handle, 
+                        reinterpret_cast<const char*>(&tag_value),
+                        sizeof(double), err);
+  }
 
-void iMesh_setEntSetBoolData (iMesh_Instance instance,
-                             /*in*/ iBase_EntitySetHandle entity_set,
-                             /*in*/ const iBase_TagHandle tag_handle,
-                             /*in*/ const bool tag_value, int *err) 
-{
-  iMesh_setEntSetData(instance, entity_set, tag_handle, 
-                      reinterpret_cast<const char*>(&tag_value), 
-                      sizeof(bool), err);
-}
+  void iMesh_setEntSetBoolData (iMesh_Instance instance,
+                                /*in*/ iBase_EntitySetHandle entity_set,
+                                /*in*/ const iBase_TagHandle tag_handle,
+                                /*in*/ const bool tag_value, int *err) 
+  {
+    iMesh_setEntSetData(instance, entity_set, tag_handle, 
+                        reinterpret_cast<const char*>(&tag_value), 
+                        sizeof(bool), err);
+  }
 
-void iMesh_setEntSetEHData (iMesh_Instance instance,
-                           /*in*/ iBase_EntitySetHandle entity_set,
-                           /*in*/ const iBase_TagHandle tag_handle,
-                           /*in*/ const iBase_EntityHandle tag_value, int *err) 
-{
-  iMesh_setEntSetData(instance, entity_set, tag_handle, 
-                             reinterpret_cast<const char*>(&tag_value), 
-                             sizeof(iBase_EntityHandle), err);
-}
+  void iMesh_setEntSetEHData (iMesh_Instance instance,
+                              /*in*/ iBase_EntitySetHandle entity_set,
+                              /*in*/ const iBase_TagHandle tag_handle,
+                              /*in*/ const iBase_EntityHandle tag_value, int *err) 
+  {
+    iMesh_setEntSetData(instance, entity_set, tag_handle, 
+                        reinterpret_cast<const char*>(&tag_value), 
+                        sizeof(iBase_EntityHandle), err);
+  }
 
-void iMesh_getEntSetData (iMesh_Instance instance,
-                         /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                         /*in*/ const iBase_TagHandle tag_handle,
-                      /*inout*/ char** tag_value,
-                         /*inout*/ int* tag_value_allocated,
-                         /*inout*/ int* tag_value_size, int *err) 
-{
-  MBEntityHandle eh = ENTITY_HANDLE(entity_set_handle);
-  MBTag tag = TAG_HANDLE(tag_handle);
+  void iMesh_getEntSetData (iMesh_Instance instance,
+                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*inout*/ char** tag_value,
+                            /*inout*/ int* tag_value_allocated,
+                            /*inout*/ int* tag_value_size, int *err) 
+  {
+    MBEntityHandle eh = ENTITY_HANDLE(entity_set_handle);
+    MBTag tag = TAG_HANDLE(tag_handle);
 
-  int tag_size;
-  MBErrorCode result = MBI->tag_get_size(tag, tag_size);
-  if (MB_SUCCESS != result) {
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntSetData: couldn't get tag size.");
-  }
+    int tag_size;
+    MBErrorCode result = MBI->tag_get_size(tag, tag_size);
+    if (MB_SUCCESS != result) {
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntSetData: couldn't get tag size.");
+    }
 
-  else {
-    TAG_CHECK_SIZE(*tag_value, *tag_value_allocated, tag_size);
+    else {
+      TAG_CHECK_SIZE(*tag_value, *tag_value_allocated, tag_size);
 
-    if (eh == 0)
-      result = MBI->tag_get_data(tag, NULL, 0, *tag_value);
-    else
-      result = MBI->tag_get_data(tag, &eh, 1, *tag_value);
+      if (eh == 0)
+        result = MBI->tag_get_data(tag, NULL, 0, *tag_value);
+      else
+        result = MBI->tag_get_data(tag, &eh, 1, *tag_value);
 
-    if (MB_SUCCESS != result) {
-      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntSetData didn't succeed.");
+      if (MB_SUCCESS != result) {
+        iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntSetData didn't succeed.");
+      }
+      else
+        *tag_value_size = tag_size;
     }
-    else
-      *tag_value_size = tag_size;
-  }
   
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_getEntSetIntData (iMesh_Instance instance,
-                            /*in*/ const iBase_EntitySetHandle entity_set,
-                            /*in*/ const iBase_TagHandle tag_handle,
-                            int *out_data, int *err) 
-{
-  char *tag_ptr = reinterpret_cast<char*>(out_data);
-  int dum_size = sizeof(int);
-  iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
-                             &dum_size, &dum_size, err);
-}
+  void iMesh_getEntSetIntData (iMesh_Instance instance,
+                               /*in*/ const iBase_EntitySetHandle entity_set,
+                               /*in*/ const iBase_TagHandle tag_handle,
+                               int *out_data, int *err) 
+  {
+    char *tag_ptr = reinterpret_cast<char*>(out_data);
+    int dum_size = sizeof(int);
+    iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
+                        &dum_size, &dum_size, err);
+  }
 
-void iMesh_getEntSetDblData (iMesh_Instance instance,
-                            /*in*/ const iBase_EntitySetHandle entity_set,
-                            /*in*/ const iBase_TagHandle tag_handle,
-                            double *out_data, int *err) 
-{
-  char *tag_ptr = reinterpret_cast<char*>(out_data);
-  int tag_size = sizeof(double);
-  iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
-                             &tag_size, &tag_size, err);
-}
+  void iMesh_getEntSetDblData (iMesh_Instance instance,
+                               /*in*/ const iBase_EntitySetHandle entity_set,
+                               /*in*/ const iBase_TagHandle tag_handle,
+                               double *out_data, int *err) 
+  {
+    char *tag_ptr = reinterpret_cast<char*>(out_data);
+    int tag_size = sizeof(double);
+    iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
+                        &tag_size, &tag_size, err);
+  }
 
-void iMesh_getEntSetBoolData (iMesh_Instance instance,
-                             /*in*/ const iBase_EntitySetHandle entity_set,
-                             /*in*/ const iBase_TagHandle tag_handle,
-                             int *out_data, int *err) 
-{
-  char *tag_ptr = reinterpret_cast<char*>(out_data);
-  int tag_size = sizeof(bool);
-  iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
-                             &tag_size, &tag_size, err);
-}
+  void iMesh_getEntSetBoolData (iMesh_Instance instance,
+                                /*in*/ const iBase_EntitySetHandle entity_set,
+                                /*in*/ const iBase_TagHandle tag_handle,
+                                int *out_data, int *err) 
+  {
+    char *tag_ptr = reinterpret_cast<char*>(out_data);
+    int tag_size = sizeof(bool);
+    iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
+                        &tag_size, &tag_size, err);
+  }
 
-void iMesh_getEntSetEHData (iMesh_Instance instance,
-                           /*in*/ const iBase_EntitySetHandle entity_set,
-                           /*in*/ const iBase_TagHandle tag_handle,
-                           iBase_EntityHandle *out_data, int *err) 
-{
-  char *tag_ptr = reinterpret_cast<char*>(out_data);
-  int tag_size = sizeof(MBEntityHandle);
-  iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
-                             &tag_size, &tag_size, err);
-}
+  void iMesh_getEntSetEHData (iMesh_Instance instance,
+                              /*in*/ const iBase_EntitySetHandle entity_set,
+                              /*in*/ const iBase_TagHandle tag_handle,
+                              iBase_EntityHandle *out_data, int *err) 
+  {
+    char *tag_ptr = reinterpret_cast<char*>(out_data);
+    int tag_size = sizeof(MBEntityHandle);
+    iMesh_getEntSetData(instance, entity_set, tag_handle, &tag_ptr, 
+                        &tag_size, &tag_size, err);
+  }
 
-void iMesh_getAllEntSetTags (iMesh_Instance instance,
-                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                            /*out*/ iBase_TagHandle** tag_handles,
-                            /*out*/ int* tag_handles_allocated,
-                            /*out*/ int* tag_handles_size, int *err) 
-{
-  MBEntityHandle eh = ENTITY_HANDLE(entity_set_handle);
-  std::vector<MBTag> all_tags;
+  void iMesh_getAllEntSetTags (iMesh_Instance instance,
+                               /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                               /*out*/ iBase_TagHandle** tag_handles,
+                               /*out*/ int* tag_handles_allocated,
+                               /*out*/ int* tag_handles_size, int *err) 
+  {
+    MBEntityHandle eh = ENTITY_HANDLE(entity_set_handle);
+    std::vector<MBTag> all_tags;
   
-  MBErrorCode result = MBI->tag_get_tags_on_entity(eh, all_tags);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_entitysetGetAllTagHandles failed.");
+    MBErrorCode result = MBI->tag_get_tags_on_entity(eh, all_tags);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_entitysetGetAllTagHandles failed.");
  
-    // now put those tag handles into sidl array
-  CHECK_SIZE(*tag_handles, *tag_handles_allocated, 
-             (int)all_tags.size(), iBase_TagHandle, iBase_MEMORY_ALLOCATION_FAILED);
-  memcpy(*tag_handles, &all_tags[0], all_tags.size()*sizeof(MBTag));
+      // now put those tag handles into sidl array
+    CHECK_SIZE(*tag_handles, *tag_handles_allocated, 
+               (int)all_tags.size(), iBase_TagHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    memcpy(*tag_handles, &all_tags[0], all_tags.size()*sizeof(MBTag));
 
-  if (MB_SUCCESS == result)
-    *tag_handles_size = (int) all_tags.size();
+    if (MB_SUCCESS == result)
+      *tag_handles_size = (int) all_tags.size();
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_rmvEntSetTag (iMesh_Instance instance,
-                        /*in*/ iBase_EntitySetHandle entity_set_handle,
-                        /*in*/ const iBase_TagHandle tag_handle, int *err) 
-{
-  if (0 == entity_set_handle) {
-    int success;
-    iMesh_getRootSet(instance, &entity_set_handle, &success);
-    if (iBase_ERROR_MAP[success] != iBase_SUCCESS) RETURN(iBase_ERROR_MAP[success]);
+    RETURN(iBase_ERROR_MAP[result]);
   }
-  MBErrorCode result = MBI->tag_delete_data(TAG_HANDLE(tag_handle),
-                                            HANDLE_ARRAY_PTR(&entity_set_handle), 1);
+
+  void iMesh_rmvEntSetTag (iMesh_Instance instance,
+                           /*in*/ iBase_EntitySetHandle entity_set_handle,
+                           /*in*/ const iBase_TagHandle tag_handle, int *err) 
+  {
+    if (0 == entity_set_handle) {
+      int success;
+      iMesh_getRootSet(instance, &entity_set_handle, &success);
+      if (iBase_ERROR_MAP[success] != iBase_SUCCESS) RETURN(iBase_ERROR_MAP[success]);
+    }
+    MBErrorCode result = MBI->tag_delete_data(TAG_HANDLE(tag_handle),
+                                              HANDLE_ARRAY_PTR(&entity_set_handle), 1);
   
-    // don't check return; this tag may have never been set on the entity set
-  RETURN(iBase_ERROR_MAP[result]);
-}
+      // don't check return; this tag may have never been set on the entity set
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_setVtxCoords (iMesh_Instance instance,
-                        /*in*/ iBase_EntityHandle vertex_handle,
-                        /*in*/ const double x, /*in*/ const double y, 
-                        /*in*/ const double z, int *err)
+  void iMesh_setVtxCoords (iMesh_Instance instance,
+                           /*in*/ iBase_EntityHandle vertex_handle,
+                           /*in*/ const double x, /*in*/ const double y, 
+                           /*in*/ const double z, int *err)
                     
-{
-  const double xyz[3] = {x, y, z};
+  {
+    const double xyz[3] = {x, y, z};
   
-  iMesh_setVtxArrCoords(instance, &vertex_handle, 1, iBase_BLOCKED,
-                               xyz, 3, err);
-}
-
-void iMesh_createVtx(iMesh_Instance instance,
-                    /*in*/ const double x, /*in*/ const double y, 
-                    /*in*/ const double z,
-                    /*out*/ iBase_EntityHandle* new_vertex_handle, int *err) 
-{
-  int dum = 1;
-  const double xyz[3] = {x, y, z};
-  iMesh_createVtxArr(instance, 1, iBase_BLOCKED,
-                            xyz, 3, &new_vertex_handle, &dum, &dum, err);
-}
-                                                   
-void iMesh_createEnt(iMesh_Instance instance,
-                    /*in*/ const int new_entity_topology,
-                    /*in*/ const iBase_EntityHandle* lower_order_entity_handles,
-                    /*in*/ const int lower_order_entity_handles_size,
-                    /*out*/ iBase_EntityHandle* new_entity_handle,
-                    /*out*/ int* status, int *err) 
-{
-  if (0 == lower_order_entity_handles_size) {
-    iMesh_processError(iBase_INVALID_ENTITY_COUNT, 
-                       "iMesh_createEnt: need more than zero lower order entities.");
-    RETURN(iBase_INVALID_ENTITY_COUNT);
+    iMesh_setVtxArrCoords(instance, &vertex_handle, 1, iBase_BLOCKED,
+                          xyz, 3, err);
   }
 
-  int dum = 1;
-  iMesh_createEntArr(instance, new_entity_topology, 
-                            lower_order_entity_handles,
-                            lower_order_entity_handles_size,
-                            &new_entity_handle,
-                            &dum, &dum,
-                            &status, &dum, &dum, err);
-}
-
-void iMesh_deleteEnt(iMesh_Instance instance,
-                    /*in*/ iBase_EntityHandle entity_handle, int *err) 
-{
-  iMesh_deleteEntArr(instance, &entity_handle, 1, err);
-}
-                                                 
-void iMesh_getArrData (iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle* entity_handles,
-                      /*in*/ const int entity_handles_size,
-                      /*in*/ const iBase_TagHandle tag_handle,
-                      /*inout*/ char** tag_values,
-                      /*inout*/int* tag_values_allocated,
-                      /*out*/ int* tag_values_size, int *err) 
-{
-  const MBEntityHandle *ents = reinterpret_cast<const MBEntityHandle *>(entity_handles);
-  MBTag tag = TAG_HANDLE(tag_handle);
-  int tag_size;
-  MBErrorCode result = MBI->tag_get_size(tag, tag_size);
-  if (MB_SUCCESS != result) {
-    int nerr=-1; char tagn[64], msg[256];
-    iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
-    snprintf(msg, sizeof(msg), "iMesh_getArrData: couldn't get size for tag \"%s\"",
-        nerr==0?tagn:"unknown");
-    iMesh_processError(iBase_ERROR_MAP[result], msg);
-    RETURN(iBase_ERROR_MAP[result]);
+  void iMesh_createVtx(iMesh_Instance instance,
+                       /*in*/ const double x, /*in*/ const double y, 
+                       /*in*/ const double z,
+                       /*out*/ iBase_EntityHandle* new_vertex_handle, int *err) 
+  {
+    int dum = 1;
+    const double xyz[3] = {x, y, z};
+    iMesh_createVtxArr(instance, 1, iBase_BLOCKED,
+                       xyz, 3, &new_vertex_handle, &dum, &dum, err);
   }
+                                                   
+  void iMesh_createEnt(iMesh_Instance instance,
+                       /*in*/ const int new_entity_topology,
+                       /*in*/ const iBase_EntityHandle* lower_order_entity_handles,
+                       /*in*/ const int lower_order_entity_handles_size,
+                       /*out*/ iBase_EntityHandle* new_entity_handle,
+                       /*out*/ int* status, int *err) 
+  {
+    if (0 == lower_order_entity_handles_size) {
+      iMesh_processError(iBase_INVALID_ENTITY_COUNT, 
+                         "iMesh_createEnt: need more than zero lower order entities.");
+      RETURN(iBase_INVALID_ENTITY_COUNT);
+    }
 
-  if (0 == entity_handles_size) {
-    RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
+    int dum = 1;
+    iMesh_createEntArr(instance, new_entity_topology, 
+                       lower_order_entity_handles,
+                       lower_order_entity_handles_size,
+                       &new_entity_handle,
+                       &dum, &dum,
+                       &status, &dum, &dum, err);
   }
-  
-  TAG_CHECK_SIZE(*tag_values, *tag_values_allocated, 
-                 tag_size * entity_handles_size);
 
-  result = MBI->tag_get_data(tag, ents, entity_handles_size,
-                             *tag_values);
-
-  if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) {
-    int nerr=-1; char tagn[64], msg[256];
-    iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
-    snprintf(msg, sizeof(msg), "iMesh_getArrData: didn't succeed for tag \"%s\"",
-        nerr==0?tagn:"unknown");
-    iMesh_processError(iBase_ERROR_MAP[result], msg);
+  void iMesh_deleteEnt(iMesh_Instance instance,
+                       /*in*/ iBase_EntityHandle entity_handle, int *err) 
+  {
+    iMesh_deleteEntArr(instance, &entity_handle, 1, err);
   }
-  else if (MB_TAG_NOT_FOUND == result) {
-    int nerr=-1; char tagn[64], msg[256];
-    iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
-    snprintf(msg, sizeof(msg), "iMesh_getArrData: tag \"%s\" not found",
-        nerr==0?tagn:"unknown");
-    iMesh_processError(iBase_ERROR_MAP[result], msg);
-  }
-
-  if (MB_SUCCESS == result)
-    *tag_values_size = tag_size * entity_handles_size;
-  
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_getIntArrData (iMesh_Instance instance,
+                                                 
+  void iMesh_getArrData (iMesh_Instance instance,
                          /*in*/ const iBase_EntityHandle* entity_handles,
                          /*in*/ const int entity_handles_size,
                          /*in*/ const iBase_TagHandle tag_handle,
-                         /*inout*/ int** tag_values,
-                         /*inout*/ int* tag_values_allocated,
+                         /*inout*/ char** tag_values,
+                         /*inout*/int* tag_values_allocated,
                          /*out*/ int* tag_values_size, int *err) 
-{
-  *tag_values_allocated *= sizeof(int);
-  *tag_values_size *= sizeof(int);
-  iMesh_getArrData(instance, entity_handles, 
-                                entity_handles_size, tag_handle,
-                                reinterpret_cast<char**>(tag_values), 
-                                tag_values_allocated, 
-                                tag_values_size, err);
-  *tag_values_allocated /= sizeof(int);
-  *tag_values_size /= sizeof(int);
-}
+  {
+    const MBEntityHandle *ents = reinterpret_cast<const MBEntityHandle *>(entity_handles);
+    MBTag tag = TAG_HANDLE(tag_handle);
+    int tag_size;
+    MBErrorCode result = MBI->tag_get_size(tag, tag_size);
+    if (MB_SUCCESS != result) {
+      int nerr=-1; char tagn[64], msg[256];
+      iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
+      snprintf(msg, sizeof(msg), "iMesh_getArrData: couldn't get size for tag \"%s\"",
+               nerr==0?tagn:"unknown");
+      iMesh_processError(iBase_ERROR_MAP[result], msg);
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-void iMesh_getDblArrData (iMesh_Instance instance,
-                         /*in*/ const iBase_EntityHandle* entity_handles,
-                         /*in*/ const int entity_handles_size,
-                         /*in*/ const iBase_TagHandle tag_handle,
-                         /*inout*/ double** tag_values,
-                         /*inout*/ int* tag_values_allocated,
-                         /*out*/ int* tag_values_size, int *err) 
-{
-  *tag_values_allocated *= sizeof(double);
-  *tag_values_size *= sizeof(double);
-  iMesh_getArrData(instance, entity_handles, 
-                                entity_handles_size, tag_handle,
-                                reinterpret_cast<char**>(tag_values), 
-                                tag_values_allocated, tag_values_size, err);
-  *tag_values_allocated /= sizeof(double);
-  *tag_values_size /= sizeof(double);
-}
+    if (0 == entity_handles_size) {
+      RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
+    }
+  
+    TAG_CHECK_SIZE(*tag_values, *tag_values_allocated, 
+                   tag_size * entity_handles_size);
 
-void iMesh_getBoolArrData (iMesh_Instance instance,
-                          /*in*/ const iBase_EntityHandle* entity_handles,
-                          /*in*/ const int entity_handles_size,
-                          /*in*/ const iBase_TagHandle tag_handle,
-                          /*inout*/ bool** tag_value,
-                          /*inout*/ int* tag_value_allocated,
-                          /*out*/ int* tag_value_size, int *err) 
-{
-  *tag_value_allocated *= sizeof(bool);
-  *tag_value_size *= sizeof(bool);
-  iMesh_getArrData(instance, entity_handles, 
-                                entity_handles_size, tag_handle,
-                                reinterpret_cast<char**>(tag_value), 
-                                tag_value_allocated, tag_value_size, err);
-  *tag_value_allocated /= sizeof(bool);
-  *tag_value_size /= sizeof(bool);
-}
+    result = MBI->tag_get_data(tag, ents, entity_handles_size,
+                               *tag_values);
 
-void iMesh_getEHArrData (iMesh_Instance instance,
-                        /*in*/ const iBase_EntityHandle* entity_handles,
-                        /*in*/ const int entity_handles_size,
-                        /*in*/ const iBase_TagHandle tag_handle,
-                        /*inout*/ iBase_EntityHandle** tag_value,
-                        /*inout*/ int* tag_value_allocated,
-                        /*out*/ int* tag_value_size, int *err) 
-{
-  *tag_value_allocated *= sizeof(iBase_EntityHandle);
-  *tag_value_size *= sizeof(iBase_EntityHandle);
-  iMesh_getArrData(instance, entity_handles, 
-                                entity_handles_size, tag_handle,
-                                reinterpret_cast<char**>(tag_value), 
-                                tag_value_allocated, 
-                                tag_value_size, err);
-  *tag_value_allocated /= sizeof(iBase_EntityHandle);
-  *tag_value_size /= sizeof(iBase_EntityHandle);
-}
+    if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) {
+      int nerr=-1; char tagn[64], msg[256];
+      iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
+      snprintf(msg, sizeof(msg), "iMesh_getArrData: didn't succeed for tag \"%s\"",
+               nerr==0?tagn:"unknown");
+      iMesh_processError(iBase_ERROR_MAP[result], msg);
+    }
+    else if (MB_TAG_NOT_FOUND == result) {
+      int nerr=-1; char tagn[64], msg[256];
+      iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
+      snprintf(msg, sizeof(msg), "iMesh_getArrData: tag \"%s\" not found",
+               nerr==0?tagn:"unknown");
+      iMesh_processError(iBase_ERROR_MAP[result], msg);
+    }
 
-void iMesh_setArrData (iMesh_Instance instance,
-                      /*in*/ iBase_EntityHandle* entity_handles,
-                      /*in*/ const int entity_handles_size,
-                      /*in*/ const iBase_TagHandle tag_handle,
-                      /*in*/ const char* tag_values,
-                      /*in*/ const int tag_values_size, int *err) 
-{
-  if (0 == entity_handles_size) {
-    RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
+    if (MB_SUCCESS == result)
+      *tag_values_size = tag_size * entity_handles_size;
+  
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-  MBErrorCode result = MBI->tag_set_data(TAG_HANDLE(tag_handle), 
-                                         HANDLE_ARRAY_PTR(entity_handles),
-                                         entity_handles_size,
-                                         tag_values);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_setArrData didn't succeed, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+  void iMesh_getIntArrData (iMesh_Instance instance,
+                            /*in*/ const iBase_EntityHandle* entity_handles,
+                            /*in*/ const int entity_handles_size,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*inout*/ int** tag_values,
+                            /*inout*/ int* tag_values_allocated,
+                            /*out*/ int* tag_values_size, int *err) 
+  {
+    *tag_values_allocated *= sizeof(int);
+    *tag_values_size *= sizeof(int);
+    iMesh_getArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle,
+                     reinterpret_cast<char**>(tag_values), 
+                     tag_values_allocated, 
+                     tag_values_size, err);
+    *tag_values_allocated /= sizeof(int);
+    *tag_values_size /= sizeof(int);
   }
-  
-  RETURN(iBase_ERROR_MAP[result]);
-}
 
-void iMesh_setIntArrData (iMesh_Instance instance,
-                         /*in*/ iBase_EntityHandle* entity_handles,
-                         /*in*/ const int entity_handles_size,
-                         /*in*/ const iBase_TagHandle tag_handle,
-                         /*in*/ const int* tag_values,
-                         /*in*/ const int tag_values_size, int *err) 
-{
-  iMesh_setArrData(instance, entity_handles, 
-                          entity_handles_size, tag_handle, 
-                          reinterpret_cast<const char*>(tag_values), 
-                          sizeof(int)*tag_values_size, err);
-}
+  void iMesh_getDblArrData (iMesh_Instance instance,
+                            /*in*/ const iBase_EntityHandle* entity_handles,
+                            /*in*/ const int entity_handles_size,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*inout*/ double** tag_values,
+                            /*inout*/ int* tag_values_allocated,
+                            /*out*/ int* tag_values_size, int *err) 
+  {
+    *tag_values_allocated *= sizeof(double);
+    *tag_values_size *= sizeof(double);
+    iMesh_getArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle,
+                     reinterpret_cast<char**>(tag_values), 
+                     tag_values_allocated, tag_values_size, err);
+    *tag_values_allocated /= sizeof(double);
+    *tag_values_size /= sizeof(double);
+  }
 
-void iMesh_setDblArrData (iMesh_Instance instance,
+  void iMesh_getBoolArrData (iMesh_Instance instance,
+                             /*in*/ const iBase_EntityHandle* entity_handles,
+                             /*in*/ const int entity_handles_size,
+                             /*in*/ const iBase_TagHandle tag_handle,
+                             /*inout*/ bool** tag_value,
+                             /*inout*/ int* tag_value_allocated,
+                             /*out*/ int* tag_value_size, int *err) 
+  {
+    *tag_value_allocated *= sizeof(bool);
+    *tag_value_size *= sizeof(bool);
+    iMesh_getArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle,
+                     reinterpret_cast<char**>(tag_value), 
+                     tag_value_allocated, tag_value_size, err);
+    *tag_value_allocated /= sizeof(bool);
+    *tag_value_size /= sizeof(bool);
+  }
+
+  void iMesh_getEHArrData (iMesh_Instance instance,
+                           /*in*/ const iBase_EntityHandle* entity_handles,
+                           /*in*/ const int entity_handles_size,
+                           /*in*/ const iBase_TagHandle tag_handle,
+                           /*inout*/ iBase_EntityHandle** tag_value,
+                           /*inout*/ int* tag_value_allocated,
+                           /*out*/ int* tag_value_size, int *err) 
+  {
+    *tag_value_allocated *= sizeof(iBase_EntityHandle);
+    *tag_value_size *= sizeof(iBase_EntityHandle);
+    iMesh_getArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle,
+                     reinterpret_cast<char**>(tag_value), 
+                     tag_value_allocated, 
+                     tag_value_size, err);
+    *tag_value_allocated /= sizeof(iBase_EntityHandle);
+    *tag_value_size /= sizeof(iBase_EntityHandle);
+  }
+
+  void iMesh_setArrData (iMesh_Instance instance,
                          /*in*/ iBase_EntityHandle* entity_handles,
                          /*in*/ const int entity_handles_size,
                          /*in*/ const iBase_TagHandle tag_handle,
-                         /*in*/ const double* tag_values,
+                         /*in*/ const char* tag_values,
                          /*in*/ const int tag_values_size, int *err) 
-{
-  iMesh_setArrData(instance, entity_handles, 
-                          entity_handles_size, tag_handle, 
-                          reinterpret_cast<const char*>(tag_values), 
-                          sizeof(double)*tag_values_size, err);
-}
+  {
+    if (0 == entity_handles_size) {
+      RETURN(iBase_ERROR_MAP[MB_SUCCESS]);
+    }
 
-void iMesh_setBoolArrData (iMesh_Instance instance,
-                          /*in*/ iBase_EntityHandle* entity_handles,
-                          /*in*/ const int entity_handles_size,
-                          /*in*/ const iBase_TagHandle tag_handle,
-                          /*in*/ const bool* tag_values,
-                          /*in*/ const int tag_values_size, int *err) 
-{
-  iMesh_setArrData(instance, entity_handles, 
-                          entity_handles_size, tag_handle, 
-                          reinterpret_cast<const char*>(tag_values), 
-                          sizeof(bool)*tag_values_size, err);
-}
+    MBErrorCode result = MBI->tag_set_data(TAG_HANDLE(tag_handle), 
+                                           HANDLE_ARRAY_PTR(entity_handles),
+                                           entity_handles_size,
+                                           tag_values);
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_setArrData didn't succeed, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
+  
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_setEHArrData (iMesh_Instance instance,
+  void iMesh_setIntArrData (iMesh_Instance instance,
+                            /*in*/ iBase_EntityHandle* entity_handles,
+                            /*in*/ const int entity_handles_size,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*in*/ const int* tag_values,
+                            /*in*/ const int tag_values_size, int *err) 
+  {
+    iMesh_setArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle, 
+                     reinterpret_cast<const char*>(tag_values), 
+                     sizeof(int)*tag_values_size, err);
+  }
+
+  void iMesh_setDblArrData (iMesh_Instance instance,
+                            /*in*/ iBase_EntityHandle* entity_handles,
+                            /*in*/ const int entity_handles_size,
+                            /*in*/ const iBase_TagHandle tag_handle,
+                            /*in*/ const double* tag_values,
+                            /*in*/ const int tag_values_size, int *err) 
+  {
+    iMesh_setArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle, 
+                     reinterpret_cast<const char*>(tag_values), 
+                     sizeof(double)*tag_values_size, err);
+  }
+
+  void iMesh_setBoolArrData (iMesh_Instance instance,
+                             /*in*/ iBase_EntityHandle* entity_handles,
+                             /*in*/ const int entity_handles_size,
+                             /*in*/ const iBase_TagHandle tag_handle,
+                             /*in*/ const bool* tag_values,
+                             /*in*/ const int tag_values_size, int *err) 
+  {
+    iMesh_setArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle, 
+                     reinterpret_cast<const char*>(tag_values), 
+                     sizeof(bool)*tag_values_size, err);
+  }
+
+  void iMesh_setEHArrData (iMesh_Instance instance,
+                           /*in*/ iBase_EntityHandle* entity_handles,
+                           /*in*/ const int entity_handles_size,
+                           /*in*/ const iBase_TagHandle tag_handle,
+                           /*in*/ const iBase_EntityHandle* tag_values,
+                           /*in*/ const int tag_values_size, int *err) 
+  {
+    iMesh_setArrData(instance, entity_handles, 
+                     entity_handles_size, tag_handle, 
+                     reinterpret_cast<const char*>(tag_values), 
+                     sizeof(iBase_EntityHandle)*tag_values_size, err);
+  }
+
+  void iMesh_rmvArrTag (iMesh_Instance instance,
                         /*in*/ iBase_EntityHandle* entity_handles,
                         /*in*/ const int entity_handles_size,
-                        /*in*/ const iBase_TagHandle tag_handle,
-                        /*in*/ const iBase_EntityHandle* tag_values,
-                        /*in*/ const int tag_values_size, int *err) 
-{
-  iMesh_setArrData(instance, entity_handles, 
-                          entity_handles_size, tag_handle, 
-                          reinterpret_cast<const char*>(tag_values), 
-                          sizeof(iBase_EntityHandle)*tag_values_size, err);
-}
-
-void iMesh_rmvArrTag (iMesh_Instance instance,
-                     /*in*/ iBase_EntityHandle* entity_handles,
-                     /*in*/ const int entity_handles_size,
-                     /*in*/ const iBase_TagHandle tag_handle, int *err) 
-{
-  MBErrorCode result = MBI->tag_delete_data(TAG_HANDLE(tag_handle),
-                                            HANDLE_ARRAY_PTR(entity_handles),
-                                            entity_handles_size);
+                        /*in*/ const iBase_TagHandle tag_handle, int *err) 
+  {
+    MBErrorCode result = MBI->tag_delete_data(TAG_HANDLE(tag_handle),
+                                              HANDLE_ARRAY_PTR(entity_handles),
+                                              entity_handles_size);
   
-    // don't check return; this tag may have never been set on the entity
-  RETURN(iBase_ERROR_MAP[result]);
-}
+      // don't check return; this tag may have never been set on the entity
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_getData (iMesh_Instance instance,
-                   /*in*/ const iBase_EntityHandle entity_handle,
-                   /*in*/ const iBase_TagHandle tag_handle,
-                   /*out*/ char** tag_value,
-                   /*inout*/ int *tag_value_allocated,
-                   /*out*/ int *tag_value_size, int *err) 
-{
-  iMesh_getArrData(instance, &entity_handle, 1,
-                          tag_handle, tag_value, tag_value_allocated,
-                          tag_value_size, err);
-}
-
-void iMesh_getIntData (iMesh_Instance instance,
+  void iMesh_getData (iMesh_Instance instance,
                       /*in*/ const iBase_EntityHandle entity_handle,
                       /*in*/ const iBase_TagHandle tag_handle,
-                      int *out_data, int *err) 
-{
-  char *val_ptr = reinterpret_cast<char*>(out_data);
-  int val_size = sizeof(int);
-  iMesh_getArrData(instance, &entity_handle, 1,
-                          tag_handle, &val_ptr, &val_size, &val_size, err);
-}
+                      /*out*/ char** tag_value,
+                      /*inout*/ int *tag_value_allocated,
+                      /*out*/ int *tag_value_size, int *err) 
+  {
+    iMesh_getArrData(instance, &entity_handle, 1,
+                     tag_handle, tag_value, tag_value_allocated,
+                     tag_value_size, err);
+  }
 
-void iMesh_getDblData (iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle entity_handle,
-                      /*in*/ const iBase_TagHandle tag_handle,
-                      double *out_data, int *err) 
-{
-  char *val_ptr = reinterpret_cast<char*>(out_data);
-  int val_size = sizeof(double);
-  iMesh_getArrData(instance, &entity_handle, 1,
-                          tag_handle, &val_ptr, &val_size, &val_size, err);
-}
+  void iMesh_getIntData (iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
+                         /*in*/ const iBase_TagHandle tag_handle,
+                         int *out_data, int *err) 
+  {
+    char *val_ptr = reinterpret_cast<char*>(out_data);
+    int val_size = sizeof(int);
+    iMesh_getArrData(instance, &entity_handle, 1,
+                     tag_handle, &val_ptr, &val_size, &val_size, err);
+  }
 
-void iMesh_getBoolData (iMesh_Instance instance,
-                       /*in*/ const iBase_EntityHandle entity_handle,
-                       /*in*/ const iBase_TagHandle tag_handle,
-                       int *out_data, int *err) 
-{
-  char *val_ptr = reinterpret_cast<char*>(out_data);
-    // make the data size a full word, because of sidl needing at least a full word
-  int val_size = sizeof(int);
-  iMesh_getArrData(instance, &entity_handle, 1,
-                          tag_handle, &val_ptr, &val_size, &val_size, err);
-}
+  void iMesh_getDblData (iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
+                         /*in*/ const iBase_TagHandle tag_handle,
+                         double *out_data, int *err) 
+  {
+    char *val_ptr = reinterpret_cast<char*>(out_data);
+    int val_size = sizeof(double);
+    iMesh_getArrData(instance, &entity_handle, 1,
+                     tag_handle, &val_ptr, &val_size, &val_size, err);
+  }
 
-void iMesh_getEHData (iMesh_Instance instance,
-                     /*in*/ const iBase_EntityHandle entity_handle,
-                     /*in*/ const iBase_TagHandle tag_handle,
-                     iBase_EntityHandle *out_data, int *err) 
-{
-  char *val_ptr = reinterpret_cast<char*>(out_data);
-  int dum = sizeof(iBase_EntityHandle);
-  iMesh_getArrData(instance, &entity_handle, 1,
-                          tag_handle, &val_ptr, &dum, &dum, err);
-}
+  void iMesh_getBoolData (iMesh_Instance instance,
+                          /*in*/ const iBase_EntityHandle entity_handle,
+                          /*in*/ const iBase_TagHandle tag_handle,
+                          int *out_data, int *err) 
+  {
+    char *val_ptr = reinterpret_cast<char*>(out_data);
+      // make the data size a full word, because of sidl needing at least a full word
+    int val_size = sizeof(int);
+    iMesh_getArrData(instance, &entity_handle, 1,
+                     tag_handle, &val_ptr, &val_size, &val_size, err);
+  }
 
-void iMesh_setData (iMesh_Instance instance,
-                   /*in*/ iBase_EntityHandle entity_handle,
-                   /*in*/ const iBase_TagHandle tag_handle,
-                   /*in*/ const char* tag_value,
-                   /*in*/ const int tag_value_size, int *err) 
-{
-  iMesh_setArrData(instance, &entity_handle, 1,
-                          tag_handle, tag_value, tag_value_size, err);
-}
+  void iMesh_getEHData (iMesh_Instance instance,
+                        /*in*/ const iBase_EntityHandle entity_handle,
+                        /*in*/ const iBase_TagHandle tag_handle,
+                        iBase_EntityHandle *out_data, int *err) 
+  {
+    char *val_ptr = reinterpret_cast<char*>(out_data);
+    int dum = sizeof(iBase_EntityHandle);
+    iMesh_getArrData(instance, &entity_handle, 1,
+                     tag_handle, &val_ptr, &dum, &dum, err);
+  }
 
-void iMesh_setIntData (iMesh_Instance instance,
+  void iMesh_setData (iMesh_Instance instance,
                       /*in*/ iBase_EntityHandle entity_handle,
                       /*in*/ const iBase_TagHandle tag_handle,
-                      /*in*/ const int tag_value, int *err) 
-{
-  iMesh_setArrData(instance, &entity_handle, 1,
-                          tag_handle, 
-                          reinterpret_cast<const char*>(&tag_value), 
-                          sizeof(int), err);
-}
+                      /*in*/ const char* tag_value,
+                      /*in*/ const int tag_value_size, int *err) 
+  {
+    iMesh_setArrData(instance, &entity_handle, 1,
+                     tag_handle, tag_value, tag_value_size, err);
+  }
 
-void iMesh_setDblData (iMesh_Instance instance,
+  void iMesh_setIntData (iMesh_Instance instance,
+                         /*in*/ iBase_EntityHandle entity_handle,
+                         /*in*/ const iBase_TagHandle tag_handle,
+                         /*in*/ const int tag_value, int *err) 
+  {
+    iMesh_setArrData(instance, &entity_handle, 1,
+                     tag_handle, 
+                     reinterpret_cast<const char*>(&tag_value), 
+                     sizeof(int), err);
+  }
+
+  void iMesh_setDblData (iMesh_Instance instance,
                    
-                      /*in*/ iBase_EntityHandle entity_handle,
-                      /*in*/ const iBase_TagHandle tag_handle,
-                      /*in*/ const double tag_value, int *err) 
-{
-  iMesh_setArrData(instance, &entity_handle, 1,
-                          tag_handle, 
-                          reinterpret_cast<const char*>(&tag_value), 
-                          sizeof(double), err);
-}
+                         /*in*/ iBase_EntityHandle entity_handle,
+                         /*in*/ const iBase_TagHandle tag_handle,
+                         /*in*/ const double tag_value, int *err) 
+  {
+    iMesh_setArrData(instance, &entity_handle, 1,
+                     tag_handle, 
+                     reinterpret_cast<const char*>(&tag_value), 
+                     sizeof(double), err);
+  }
 
-void iMesh_setBoolData (iMesh_Instance instance,
-                       /*in*/ iBase_EntityHandle entity_handle,
-                       /*in*/ const iBase_TagHandle tag_handle,
-                       /*in*/ const bool tag_value, int *err) 
-{
-  iMesh_setArrData(instance, &entity_handle, 1,
-                          tag_handle, 
-                          reinterpret_cast<const char*>(&tag_value), 
-                          sizeof(bool), err);
-}
+  void iMesh_setBoolData (iMesh_Instance instance,
+                          /*in*/ iBase_EntityHandle entity_handle,
+                          /*in*/ const iBase_TagHandle tag_handle,
+                          /*in*/ const bool tag_value, int *err) 
+  {
+    iMesh_setArrData(instance, &entity_handle, 1,
+                     tag_handle, 
+                     reinterpret_cast<const char*>(&tag_value), 
+                     sizeof(bool), err);
+  }
 
-void iMesh_setEHData (iMesh_Instance instance,
-                     /*in*/ iBase_EntityHandle entity_handle,
-                     /*in*/ const iBase_TagHandle tag_handle,
-                     /*in*/ const iBase_EntityHandle tag_value, int *err) 
-{
-  iMesh_setArrData(instance, &entity_handle, 1,
-                          tag_handle, 
-                          reinterpret_cast<const char*>(&tag_value), 
-                          sizeof(iBase_EntityHandle), err);
-}
+  void iMesh_setEHData (iMesh_Instance instance,
+                        /*in*/ iBase_EntityHandle entity_handle,
+                        /*in*/ const iBase_TagHandle tag_handle,
+                        /*in*/ const iBase_EntityHandle tag_value, int *err) 
+  {
+    iMesh_setArrData(instance, &entity_handle, 1,
+                     tag_handle, 
+                     reinterpret_cast<const char*>(&tag_value), 
+                     sizeof(iBase_EntityHandle), err);
+  }
 
-void iMesh_getAllTags (iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle entity_handle,
-                      /*inout*/ iBase_TagHandle** tag_handles,
-                      /*inout*/ int* tag_handles_allocated,
-                      /*out*/ int* tag_handles_size, int *err) 
-{
-  std::vector<MBTag> all_tags;
+  void iMesh_getAllTags (iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
+                         /*inout*/ iBase_TagHandle** tag_handles,
+                         /*inout*/ int* tag_handles_allocated,
+                         /*out*/ int* tag_handles_size, int *err) 
+  {
+    std::vector<MBTag> all_tags;
   
-  MBErrorCode result = MBI->tag_get_tags_on_entity(ENTITY_HANDLE(entity_handle), all_tags);
-  if (MB_SUCCESS != result)
-    iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getAllTags failed.");
+    MBErrorCode result = MBI->tag_get_tags_on_entity(ENTITY_HANDLE(entity_handle), all_tags);
+    if (MB_SUCCESS != result)
+      iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getAllTags failed.");
     
-    // now put those tag handles into sidl array
-  CHECK_SIZE(*tag_handles, *tag_handles_allocated,
-             (int)all_tags.size(), iBase_TagHandle, iBase_MEMORY_ALLOCATION_FAILED);
-  memcpy(*tag_handles, &all_tags[0], all_tags.size()*sizeof(MBTag));
+      // now put those tag handles into sidl array
+    CHECK_SIZE(*tag_handles, *tag_handles_allocated,
+               (int)all_tags.size(), iBase_TagHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    memcpy(*tag_handles, &all_tags[0], all_tags.size()*sizeof(MBTag));
 
-  if (MB_SUCCESS == result)
-    *tag_handles_size = all_tags.size();
+    if (MB_SUCCESS == result)
+      *tag_handles_size = all_tags.size();
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
+    RETURN(iBase_ERROR_MAP[result]);
+  }
 
-void iMesh_rmvTag (iMesh_Instance instance,
-                  /*in*/ iBase_EntityHandle entity_handle,
-                  /*in*/ const iBase_TagHandle tag_handle, int *err) 
-{
-  iMesh_rmvArrTag(instance, &entity_handle, 1, tag_handle, err);
-}
+  void iMesh_rmvTag (iMesh_Instance instance,
+                     /*in*/ iBase_EntityHandle entity_handle,
+                     /*in*/ const iBase_TagHandle tag_handle, int *err) 
+  {
+    iMesh_rmvArrTag(instance, &entity_handle, 1, tag_handle, err);
+  }
 
-void iMesh_initEntIter (iMesh_Instance instance,
-                       /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                       /*in*/ const int requested_entity_type,
-                       /*in*/ const int requested_entity_topology,
-                       /*out*/ iMesh_EntityIterator* entity_iterator,
-                       int *err) 
-{
-  iMesh_initEntArrIter(instance, entity_set_handle, requested_entity_type,
-                              requested_entity_topology, 1, entity_iterator,
-                              err);
-}
+  void iMesh_initEntIter (iMesh_Instance instance,
+                          /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                          /*in*/ const int requested_entity_type,
+                          /*in*/ const int requested_entity_topology,
+                          /*out*/ iMesh_EntityIterator* entity_iterator,
+                          int *err) 
+  {
+    iMesh_initEntArrIter(instance, entity_set_handle, requested_entity_type,
+                         requested_entity_topology, 1, entity_iterator,
+                         err);
+  }
 
-void iMesh_getNextEntIter (iMesh_Instance instance,
-                          /*in*/ iMesh_EntityIterator entity_iterator,
-                          /*out*/ iBase_EntityHandle* entity_handle, 
-                          int *is_end, int *err) 
-{
-  int eh_size = 1;
-  iMesh_getNextEntArrIter(instance,
-                                 entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
+  void iMesh_getNextEntIter (iMesh_Instance instance,
+                             /*in*/ iMesh_EntityIterator entity_iterator,
+                             /*out*/ iBase_EntityHandle* entity_handle, 
+                             int *is_end, int *err) 
+  {
+    int eh_size = 1;
+    iMesh_getNextEntArrIter(instance,
+                            entity_iterator, &entity_handle, &eh_size, &eh_size, is_end, err);
   
-}
+  }
 
-void iMesh_resetEntIter (iMesh_Instance instance,
-                        /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
-{
-  iMesh_resetEntArrIter(instance, entity_iterator, err);  
-}
+  void iMesh_resetEntIter (iMesh_Instance instance,
+                           /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
+  {
+    iMesh_resetEntArrIter(instance, entity_iterator, err);  
+  }
 
-void iMesh_endEntIter (iMesh_Instance instance,
-                      /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
-{
-  iMesh_endEntArrIter(instance, entity_iterator, err);
-}
+  void iMesh_endEntIter (iMesh_Instance instance,
+                         /*in*/ iMesh_EntityIterator entity_iterator, int *err) 
+  {
+    iMesh_endEntArrIter(instance, entity_iterator, err);
+  }
 
-void iMesh_getEntTopo (iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle entity_handle,
-                      int *out_topo, int *err) 
-{
-  *out_topo = tstt_topology_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handle))];
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getEntTopo (iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
+                         int *out_topo, int *err) 
+  {
+    *out_topo = tstt_topology_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handle))];
+    RETURN(iBase_SUCCESS);
+  }
   
-void iMesh_getEntType (iMesh_Instance instance,
-                      /*in*/ const iBase_EntityHandle entity_handle,
-                      int *out_type, int *err) 
-{
-  *out_type = tstt_type_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handle))];
-  RETURN(iBase_SUCCESS);
-}
+  void iMesh_getEntType (iMesh_Instance instance,
+                         /*in*/ const iBase_EntityHandle entity_handle,
+                         int *out_type, int *err) 
+  {
+    *out_type = tstt_type_table[MBI->type_from_handle(ENTITY_HANDLE(entity_handle))];
+    RETURN(iBase_SUCCESS);
+  }
 
-void iMesh_getVtxCoord (iMesh_Instance instance,
-                       /*in*/ const iBase_EntityHandle vertex_handle,
-                       /*out*/ double *x, /*out*/ double *y, /*out*/ double *z, int *err)
-{
-  int order = iBase_BLOCKED;
-  double xyz[3], *tmp_xyz = xyz;
-  int dum = 3;
+  void iMesh_getVtxCoord (iMesh_Instance instance,
+                          /*in*/ const iBase_EntityHandle vertex_handle,
+                          /*out*/ double *x, /*out*/ double *y, /*out*/ double *z, int *err)
+  {
+    int order = iBase_BLOCKED;
+    double xyz[3], *tmp_xyz = xyz;
+    int dum = 3;
   
-  iMesh_getVtxArrCoords(instance,
-                        &vertex_handle, 1, &order,
-                        &tmp_xyz, &dum, &dum, err);
-  if (iBase_SUCCESS == *err) {
-    *x = xyz[0]; *y = xyz[1]; *z = xyz[2];
+    iMesh_getVtxArrCoords(instance,
+                          &vertex_handle, 1, &order,
+                          &tmp_xyz, &dum, &dum, err);
+    if (iBase_SUCCESS == *err) {
+      *x = xyz[0]; *y = xyz[1]; *z = xyz[2];
+    }
   }
-}
 
-void iMesh_getEntAdj(iMesh_Instance instance,
-                     /*in*/ const iBase_EntityHandle entity_handle,
-                     /*in*/ const int entity_type_requested,
-                     /*inout*/ iBase_EntityHandle** adj_entity_handles,
-                     /*inout*/ int* adj_entity_handles_allocated,
-                     /*out*/ int* adj_entity_handles_size, int *err)
-{
-  int offsets[2];
-  int *offsets_ptr = offsets;
-  int offset_size, offset_allocated = 2;
+  void iMesh_getEntAdj(iMesh_Instance instance,
+                       /*in*/ const iBase_EntityHandle entity_handle,
+                       /*in*/ const int entity_type_requested,
+                       /*inout*/ iBase_EntityHandle** adj_entity_handles,
+                       /*inout*/ int* adj_entity_handles_allocated,
+                       /*out*/ int* adj_entity_handles_size, int *err)
+  {
+    int offsets[2];
+    int *offsets_ptr = offsets;
+    int offset_size, offset_allocated = 2;
   
-  iMesh_getEntArrAdj(instance,
-                     &entity_handle, 1, entity_type_requested,
-                     adj_entity_handles, adj_entity_handles_allocated, 
-                     adj_entity_handles_size, &offsets_ptr, &offset_allocated, 
-                     &offset_size, err);
-}
+    iMesh_getEntArrAdj(instance,
+                       &entity_handle, 1, entity_type_requested,
+                       adj_entity_handles, adj_entity_handles_allocated, 
+                       adj_entity_handles_size, &offsets_ptr, &offset_allocated, 
+                       &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;
+  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);
-}
+    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,
-                   /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
-{
-  MBEntityHandle temp_set;
-  MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
-    set2 = ENTITY_HANDLE(entity_set_2);
-  MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
-  if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
-  if (MB_SUCCESS == result) result = MBI->subtract_meshset(temp_set, set2);
+  void iMesh_subtract(iMesh_Instance instance,
+                      /*in*/ const iBase_EntitySetHandle entity_set_1,
+                      /*in*/ const iBase_EntitySetHandle entity_set_2,
+                      /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
+  {
+    MBEntityHandle temp_set;
+    MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
+      set2 = ENTITY_HANDLE(entity_set_2);
+    MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
+    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
+    if (MB_SUCCESS == result) result = MBI->subtract_meshset(temp_set, set2);
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_entitysetSubtract:\
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_entitysetSubtract:\
            ERROR subtract failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    MBI->delete_entities(&temp_set, 1);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
+      msg += MBI->get_error_string(result);
+      MBI->delete_entities(&temp_set, 1);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
 
-  *result_entity_set = (iBase_EntitySetHandle)temp_set;
+    *result_entity_set = (iBase_EntitySetHandle)temp_set;
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_intersect(iMesh_Instance instance,
-                    /*in*/ const iBase_EntitySetHandle entity_set_1,
-                    /*in*/ const iBase_EntitySetHandle entity_set_2,
-                    /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
-{
-  MBEntityHandle temp_set;
-  MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
-    set2 = ENTITY_HANDLE(entity_set_2);
-  MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
-  if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
-  if (MB_SUCCESS == result) result = MBI->intersect_meshset(temp_set, set2);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_entitysetIntersect:\
-           ERROR subtract failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    MBI->delete_entities(&temp_set, 1);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-  *result_entity_set = (iBase_EntitySetHandle)temp_set;
+  void iMesh_intersect(iMesh_Instance instance,
+                       /*in*/ const iBase_EntitySetHandle entity_set_1,
+                       /*in*/ const iBase_EntitySetHandle entity_set_2,
+                       /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
+  {
+    MBEntityHandle temp_set;
+    MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
+      set2 = ENTITY_HANDLE(entity_set_2);
+    MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
+    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
+    if (MB_SUCCESS == result) result = MBI->intersect_meshset(temp_set, set2);
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_unite(iMesh_Instance instance,
-                /*in*/ const iBase_EntitySetHandle entity_set_1,
-                /*in*/ const iBase_EntitySetHandle entity_set_2,
-                /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
-{  
-  MBEntityHandle temp_set;
-  MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
-    set2 = ENTITY_HANDLE(entity_set_2);
-  MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
-  if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
-  if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set2);
-
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_entitysetIntersect:\
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_entitysetIntersect:\
            ERROR subtract failed, with error type: ");
-    msg += MBI->get_error_string(result);
-    MBI->delete_entities(&temp_set, 1);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-  }
+      msg += MBI->get_error_string(result);
+      MBI->delete_entities(&temp_set, 1);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    }
 
-  *result_entity_set = (iBase_EntitySetHandle)temp_set;
+    *result_entity_set = (iBase_EntitySetHandle)temp_set;
 
-  RETURN(iBase_ERROR_MAP[result]);
-}
-
-void iMesh_free(iBase_EntityHandle *ptr, int *err) 
-{
-  free(ptr);
-  RETURN(iBase_SUCCESS);
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-MBErrorCode iMesh_tag_set_vertices(iMesh_Instance instance,
-                                   MBEntityHandle in_set, 
-                                   const int req_dimension, 
-                                   const MBEntityType req_type,
-                                   MBTag &tag, MBRange &req_entities, 
-                                   int &num_verts, int *err) 
-{
-    // get all the entities then vertices
-  MBRange vertices, entities;
-  entities.clear();
-  MBErrorCode result = MBI->get_entities_by_handle(in_set, entities, false);
-  if (MB_SUCCESS != result) {
-    std::string msg("MBMesh::tag_set_vertices: getting entities didn't succeed., with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    return result;
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-    // remove any sets
-  entities.erase(entities.lower_bound(MBENTITYSET),
-                 entities.upper_bound(MBENTITYSET));
+  void iMesh_unite(iMesh_Instance instance,
+                   /*in*/ const iBase_EntitySetHandle entity_set_1,
+                   /*in*/ const iBase_EntitySetHandle entity_set_2,
+                   /*out*/ iBase_EntitySetHandle* result_entity_set, int *err)
+  {  
+    MBEntityHandle temp_set;
+    MBEntityHandle set1 = ENTITY_HANDLE(entity_set_1), 
+      set2 = ENTITY_HANDLE(entity_set_2);
+    MBErrorCode result = MBI->create_meshset(MESHSET_SET, temp_set);
+    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
+    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set2);
 
-    // get vertices
-  result = MBI->get_adjacencies(entities, 0, false, vertices,
-                                MBInterface::UNION);
-  if (MB_SUCCESS != result) {
-    std::string msg("MBMesh::tag_set_vertices: getting vertices didn't succeed., with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    return result;
-  }
-  
-    // tag each vertex with its index in this list
-  int i = 0;
-  if (tag == 0) {
-    result = MBI->tag_create("__position_tag", 4, MB_TAG_DENSE, tag, &i);
-    if (0 == tag) {
-      std::string msg("MBMesh::tag_set_vertices: couldn't make tag., with error type: ");
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_entitysetIntersect:\
+           ERROR subtract failed, with error type: ");
       msg += MBI->get_error_string(result);
+      MBI->delete_entities(&temp_set, 1);
       iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-      return result;
     }
-  }
-  
-  MBRange::iterator vit;
-  for (vit = vertices.begin(), i = 0; vit != vertices.end(); vit++, i++) {
-    result = MBI->tag_set_data(tag, &(*vit), 1, &i);
-    if (MB_SUCCESS != result) {
-      std::string msg("MBMesh::tag_set_vertices: couldn't set pos_tag., with error type: ");
-      msg += MBI->get_error_string(result);
-      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-      return result;
-    }
-  }
 
-  if (req_dimension == -1 && req_type == MBMAXTYPE) return MB_SUCCESS;
-  
-    // winnow the list for entities of the desired type and/or topology
-  num_verts = 0;
-  MBRange::iterator ent_it;
-  MBEntityType this_type;
-  for (ent_it = entities.begin(); ent_it != entities.end(); ent_it++) {
-    this_type = MBI->type_from_handle(*ent_it);
-    if (req_dimension == MBCN::Dimension(this_type) ||
-        this_type == req_type) {
-      req_entities.insert(*ent_it);
-      num_verts += MBCN::VerticesPerEntity(this_type);
-    }
+    *result_entity_set = (iBase_EntitySetHandle)temp_set;
+
+    RETURN(iBase_ERROR_MAP[result]);
   }
 
-  return result;
-}
-
-void iMesh_getEntitiesRec(iMesh_Instance instance,
-                          /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                          /*in*/ const int entity_type,
-                          /*in*/ const int entity_topology,
-                          /*in*/ const int recursive,
-                          /*out*/ iBase_EntityHandle** entity_handles,
-                          /*out*/ int* entity_handles_allocated,
-                          /*out*/ int* entity_handles_size,
-                          /*out*/ int *err) 
-{
-  bool use_top = false;
-  bool use_type = false;
-    // initialize just to get rid of compiler warning
-  MBEntityType type = mb_topology_table[iMesh_ALL_TOPOLOGIES];
-  MBRange out_entities;
+  void iMesh_getEntitiesRec(iMesh_Instance instance,
+                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                            /*in*/ const int entity_type,
+                            /*in*/ const int entity_topology,
+                            /*in*/ const int recursive,
+                            /*out*/ iBase_EntityHandle** entity_handles,
+                            /*out*/ int* entity_handles_allocated,
+                            /*out*/ int* entity_handles_size,
+                            /*out*/ int *err) 
+  {
+    bool use_top = false;
+    bool use_type = false;
+      // initialize just to get rid of compiler warning
+    MBEntityType type = mb_topology_table[iMesh_ALL_TOPOLOGIES];
+    MBRange out_entities;
  
-  if (entity_topology >= iMesh_POINT
-      && entity_topology < iMesh_ALL_TOPOLOGIES) {
-    type = mb_topology_table[entity_topology];
-    use_top = true;
-  }
-  else if (entity_type >= iBase_VERTEX
-           && entity_type <= iBase_ALL_TYPES)
-    use_type = true;
-  else {
-    iMesh_processError(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO], 
-                       "iMesh_getEntities:ERROR not valid entity type or topology");
-    RETURN(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO]);
-  }
+    if (entity_topology >= iMesh_POINT
+        && entity_topology < iMesh_ALL_TOPOLOGIES) {
+      type = mb_topology_table[entity_topology];
+      use_top = true;
+    }
+    else if (entity_type >= iBase_VERTEX
+             && entity_type <= iBase_ALL_TYPES)
+      use_type = true;
+    else {
+      iMesh_processError(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO], 
+                         "iMesh_getEntities:ERROR not valid entity type or topology");
+      RETURN(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO]);
+    }
 
-  MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
-  MBErrorCode result;
+    MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
+    MBErrorCode result;
 
-  if (use_top) {
-    if (entity_topology == iMesh_SEPTAHEDRON)
-      result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any.
-    else
-      result = MBI->get_entities_by_type(handle, type, out_entities, recursive);
-  }
-  else if (use_type && entity_type != iBase_ALL_TYPES)
-    result = MBI->get_entities_by_dimension(handle, entity_type, out_entities, recursive);
-  else 
-    result = MBI->get_entities_by_handle(handle, out_entities, recursive);
+    if (use_top) {
+      if (entity_topology == iMesh_SEPTAHEDRON)
+        result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any.
+      else
+        result = MBI->get_entities_by_type(handle, type, out_entities, recursive);
+    }
+    else if (use_type && entity_type != iBase_ALL_TYPES)
+      result = MBI->get_entities_by_dimension(handle, entity_type, out_entities, recursive);
+    else 
+      result = MBI->get_entities_by_handle(handle, out_entities, recursive);
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_GetEntities:ERROR getting entities, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_GetEntities:ERROR getting entities, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  CHECK_SIZE(*entity_handles, *entity_handles_allocated, 
-             (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    CHECK_SIZE(*entity_handles, *entity_handles_allocated, 
+               (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
   
-  MBRange::iterator iter = out_entities.begin();
-  MBRange::iterator end_iter = out_entities.end();
-  int k = 0;
+    MBRange::iterator iter = out_entities.begin();
+    MBRange::iterator end_iter = out_entities.end();
+    int k = 0;
 
-    // filter out entity sets here
-  if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
-    for (; iter != end_iter && MBI->type_from_handle(*iter) != MBENTITYSET; iter++)
-      (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
-  }
-  else {
-    for (; iter != end_iter; iter++)
-      (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
-  }
+      // filter out entity sets here
+    if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
+      for (; iter != end_iter && MBI->type_from_handle(*iter) != MBENTITYSET; iter++)
+        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+    }
+    else {
+      for (; iter != end_iter; iter++)
+        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+    }
 
-    // now it's safe to set the size; set it to k, not out_entities.size(), to
-    // account for sets which might have been removed
-  *entity_handles_size = k;
+      // now it's safe to set the size; set it to k, not out_entities.size(), to
+      // account for sets which might have been removed
+    *entity_handles_size = k;
 
-  RETURN(iBase_SUCCESS);
-}  
+    RETURN(iBase_SUCCESS);
+  }  
 
     /**\brief  Get the number of entities with the specified type in the instance or set, recursive
      *
@@ -2713,35 +2630,35 @@
      * \param num_type Pointer to number of entities, returned from function
      * \param *err Pointer to error type returned from function
      */
-void iMesh_getNumOfTypeRec(iMesh_Instance instance,
-                           /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                           /*in*/ const int entity_type,
-                           /*in*/ const int recursive,
-                           /*out*/ int *num_type, 
-                           /*out*/ int *err) 
-{
-  *num_type = 0;
-  MBErrorCode result;
-  if (entity_type == iBase_ALL_TYPES)
-    result = MBI->get_number_entities_by_handle
+  void iMesh_getNumOfTypeRec(iMesh_Instance instance,
+                             /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                             /*in*/ const int entity_type,
+                             /*in*/ const int recursive,
+                             /*out*/ int *num_type, 
+                             /*out*/ int *err) 
+  {
+    *num_type = 0;
+    MBErrorCode result;
+    if (entity_type == iBase_ALL_TYPES)
+      result = MBI->get_number_entities_by_handle
         (ENTITY_HANDLE(entity_set_handle), *num_type, recursive);
-  else
-    result = MBI->get_number_entities_by_dimension
+    else
+      result = MBI->get_number_entities_by_dimension
         (ENTITY_HANDLE(entity_set_handle), entity_type, *num_type, recursive);
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_entitysetGetNumberEntityOfType: ERROR getting number of entities"
-                    " by type, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    *num_type = 0;
-    RETURN(iBase_ERROR_MAP[result]);
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_entitysetGetNumberEntityOfType: ERROR getting number of entities"
+                      " by type, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      *num_type = 0;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+
+    RETURN(iBase_SUCCESS);
   }
 
-  RETURN(iBase_SUCCESS);
-}
 
-
     /**\brief  Get the number of entities with the specified topology in the instance or set
      *
      * Get the number of entities with the specified topology in the instance 
@@ -2757,35 +2674,35 @@
      * \param num_topo Pointer to number of entities, returned from function
      * \param *err Pointer to error type returned from function
      */
-void iMesh_getNumOfTopoRec(iMesh_Instance instance,
-                           /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                           /*in*/ const int entity_topology,
-                           /*in*/ const int recursive,
-                           /*out*/ int *num_topo, 
-                           /*out*/ int *err) 
-{
-  if (entity_topology == iMesh_SEPTAHEDRON) {
-    *num_topo = 0;
-    RETURN(iBase_SUCCESS);
-  }
+  void iMesh_getNumOfTopoRec(iMesh_Instance instance,
+                             /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                             /*in*/ const int entity_topology,
+                             /*in*/ const int recursive,
+                             /*out*/ int *num_topo, 
+                             /*out*/ int *err) 
+  {
+    if (entity_topology == iMesh_SEPTAHEDRON) {
+      *num_topo = 0;
+      RETURN(iBase_SUCCESS);
+    }
 
-  *num_topo = 0;
-  MBErrorCode result = 
+    *num_topo = 0;
+    MBErrorCode result = 
       MBI->get_number_entities_by_type(ENTITY_HANDLE(entity_set_handle), 
                                        mb_topology_table[entity_topology], 
                                        *num_topo, recursive);
-  if (MB_SUCCESS != result) {
-    std::string msg("iMesh_entitysetGetNumberEntityOfTopology: ERROR getting "
-                    "number of entities by topology., with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    *num_topo = -1;
-    RETURN(iBase_ERROR_MAP[result]);
+    if (MB_SUCCESS != result) {
+      std::string msg("iMesh_entitysetGetNumberEntityOfTopology: ERROR getting "
+                      "number of entities by topology., with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      *num_topo = -1;
+      RETURN(iBase_ERROR_MAP[result]);
+    }
+    else {
+      RETURN(iBase_SUCCESS);
+    }
   }
-  else {
-    RETURN(iBase_SUCCESS);
-  }
-}
 
     /**\brief  Get entities with specified type, topology, tag(s) and (optionally) tag value(s)
      *
@@ -2807,150 +2724,227 @@
      * \param *entity_handles_size Pointer to occupied size of entity_handles array
      * \param *err Pointer to error type returned from function
      */
-void iMesh_getEntsByTagsRec(iMesh_Instance instance,
-                            /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                            /*in*/ const int entity_type,
-                            /*in*/ const int entity_topology,
-                            /*in*/ const iBase_TagHandle *tag_handles,
-                            /*in*/ const char * const *tag_vals,
-                            /*in*/ const int num_tags_vals,
-                            /*in*/ const int recursive,
-                            /*out*/ iBase_EntityHandle** entity_handles,
-                            /*out*/ int* entity_handles_allocated,
-                            /*out*/ int* entity_handles_size,
-                            /*out*/ int *err)
-{
-  bool use_top = false;
-  bool use_type = false;
-    // initialize just to get rid of compiler warning
-  MBEntityType type = mb_topology_table[iMesh_ALL_TOPOLOGIES];
-  MBRange out_entities;
+  void iMesh_getEntsByTagsRec(iMesh_Instance instance,
+                              /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                              /*in*/ const int entity_type,
+                              /*in*/ const int entity_topology,
+                              /*in*/ const iBase_TagHandle *tag_handles,
+                              /*in*/ const char * const *tag_vals,
+                              /*in*/ const int num_tags_vals,
+                              /*in*/ const int recursive,
+                              /*out*/ iBase_EntityHandle** entity_handles,
+                              /*out*/ int* entity_handles_allocated,
+                              /*out*/ int* entity_handles_size,
+                              /*out*/ int *err)
+  {
+    bool use_top = false;
+    bool use_type = false;
+      // initialize just to get rid of compiler warning
+    MBEntityType type = mb_topology_table[iMesh_ALL_TOPOLOGIES];
+    MBRange out_entities;
  
-  if (entity_topology >= iMesh_POINT
-      && entity_topology < iMesh_ALL_TOPOLOGIES) {
-    type = mb_topology_table[entity_topology];
-    use_top = true;
-  }
-  else if (entity_type >= iBase_VERTEX
-           && entity_type <= iBase_ALL_TYPES)
-    use_type = true;
-  else {
-    iMesh_processError(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO], 
-                       "iMesh_getEntities:ERROR not valid entity type or topology");
-    RETURN(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO]);
-  }
+    if (entity_topology >= iMesh_POINT
+        && entity_topology < iMesh_ALL_TOPOLOGIES) {
+      type = mb_topology_table[entity_topology];
+      use_top = true;
+    }
+    else if (entity_type >= iBase_VERTEX
+             && entity_type <= iBase_ALL_TYPES)
+      use_type = true;
+    else {
+      iMesh_processError(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO], 
+                         "iMesh_getEntities:ERROR not valid entity type or topology");
+      RETURN(iBase_ERROR_MAP[iBase_BAD_TYPE_AND_TOPO]);
+    }
 
-  MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
-  MBErrorCode result;
+    MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
+    MBErrorCode result;
 
-  if (use_top) {
-    if (entity_topology == iMesh_SEPTAHEDRON)
-      result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any.
-    else
+    if (use_top) {
+      if (entity_topology == iMesh_SEPTAHEDRON)
+        result = MB_SUCCESS;  // MOAB doesn't do septahedrons, so there are never any.
+      else
+        result = MBI->get_entities_by_type_and_tag(handle, type, (MBTag*)tag_handles, 
+                                                   (const void* const *)tag_vals,
+                                                   num_tags_vals, out_entities, 
+                                                   MBInterface::INTERSECT, recursive);
+    }
+    else if (use_type && entity_type != iBase_ALL_TYPES) {
+        // need to loop over all types of this dimension
+      for (MBEntityType tp = MBCN::TypeDimensionMap[entity_type].first;
+           tp <= MBCN::TypeDimensionMap[entity_type].second; tp++) {
+        MBRange tmp_range;
+        MBErrorCode tmp_result = MBI->get_entities_by_type_and_tag(handle, type, (MBTag*)tag_handles, 
+                                                                   (const void* const *)tag_vals,
+                                                                   num_tags_vals, tmp_range, 
+                                                                   MBInterface::INTERSECT, recursive);
+        if (MB_SUCCESS != tmp_result) result = tmp_result;
+        else out_entities.merge(tmp_range);
+      }
+    }
+    else 
       result = MBI->get_entities_by_type_and_tag(handle, type, (MBTag*)tag_handles, 
                                                  (const void* const *)tag_vals,
-                                                 num_tags_vals, out_entities, 
+                                                 num_tags_vals, out_entities,
                                                  MBInterface::INTERSECT, recursive);
-  }
-  else if (use_type && entity_type != iBase_ALL_TYPES) {
-      // need to loop over all types of this dimension
-    for (MBEntityType tp = MBCN::TypeDimensionMap[entity_type].first;
-         tp <= MBCN::TypeDimensionMap[entity_type].second; tp++) {
-      MBRange tmp_range;
-      MBErrorCode tmp_result = MBI->get_entities_by_type_and_tag(handle, type, (MBTag*)tag_handles, 
-                                                                 (const void* const *)tag_vals,
-                                                                 num_tags_vals, tmp_range, 
-                                                                 MBInterface::INTERSECT, recursive);
-      if (MB_SUCCESS != tmp_result) result = tmp_result;
-      else out_entities.merge(tmp_range);
+
+    if (result != MB_SUCCESS) {
+      std::string msg("iMesh_GetEntities:ERROR getting entities, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
     }
+
+    CHECK_SIZE(*entity_handles, *entity_handles_allocated, 
+               (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+  
+    MBRange::iterator iter = out_entities.begin();
+    MBRange::iterator end_iter = out_entities.end();
+    int k = 0;
+
+      // filter out entity sets here
+    if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
+      for (; iter != end_iter && MBI->type_from_handle(*iter) != MBENTITYSET; iter++)
+        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+    }
+    else {
+      for (; iter != end_iter; iter++)
+        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+    }
+
+      // now it's safe to set the size; set it to k, not out_entities.size(), to
+      // account for sets which might have been removed
+    *entity_handles_size = k;
+
+    RETURN(iBase_SUCCESS);
   }
-  else 
-    result = MBI->get_entities_by_type_and_tag(handle, type, (MBTag*)tag_handles, 
+
+  void iMesh_getEntSetsByTagsRec(iMesh_Instance instance,
+                                 /*in*/ const iBase_EntitySetHandle entity_set_handle,
+                                 /*in*/ const iBase_TagHandle *tag_handles,
+                                 /*in*/ const char * const *tag_vals,
+                                 /*in*/ const int num_tags_vals,
+                                 /*in*/ const int recursive,
+                                 /*out*/ iBase_EntityHandle** set_handles,
+                                 /*out*/ int* set_handles_allocated,
+                                 /*out*/ int* set_handles_size,
+                                 /*out*/ int *err)
+  {
+    MBRange out_entities;
+ 
+    MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
+    MBErrorCode result;
+
+    result = MBI->get_entities_by_type_and_tag(handle, MBENTITYSET, (MBTag*)tag_handles, 
                                                (const void* const *)tag_vals,
-                                               num_tags_vals, out_entities,
+                                               num_tags_vals, out_entities, 
                                                MBInterface::INTERSECT, recursive);
+    if (result != MB_SUCCESS) {
+      std::string msg("ERROR getting entities, with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      RETURN(iBase_ERROR_MAP[result]);
+    }
 
-  if (result != MB_SUCCESS) {
-    std::string msg("iMesh_GetEntities:ERROR getting entities, with error type: ");
-    msg += MBI->get_error_string(result);
-    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
-  }
+    CHECK_SIZE(*set_handles, *set_handles_allocated, 
+               (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
 
-  CHECK_SIZE(*entity_handles, *entity_handles_allocated, 
-             (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    std::copy(out_entities.begin(), out_entities.end(), ((MBEntityHandle*) *set_handles));
   
-  MBRange::iterator iter = out_entities.begin();
-  MBRange::iterator end_iter = out_entities.end();
-  int k = 0;
+      // now it's safe to set the size; set it to k, not out_entities.size(), to
+      // account for sets which might have been removed
+    *set_handles_size = out_entities.size();
 
-    // filter out entity sets here
-  if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
-    for (; iter != end_iter && MBI->type_from_handle(*iter) != MBENTITYSET; iter++)
-      (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+    RETURN(iBase_SUCCESS);
   }
-  else {
-    for (; iter != end_iter; iter++)
-      (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
+
+  void iMesh_MBCNType(/*in*/ const int imesh_entity_topology,
+                      /*out*/ int *mbcn_type) 
+  {
+    if (iMesh_POINT > imesh_entity_topology ||
+        iMesh_ALL_TOPOLOGIES <= imesh_entity_topology)
+      *mbcn_type = -1;
+    else
+      *mbcn_type = mb_topology_table[imesh_entity_topology];
   }
+    
+#ifdef __cplusplus
+} // extern "C"
+#endif
 
-    // now it's safe to set the size; set it to k, not out_entities.size(), to
-    // account for sets which might have been removed
-  *entity_handles_size = k;
-
-  RETURN(iBase_SUCCESS);
-}
-
-void iMesh_getEntSetsByTagsRec(iMesh_Instance instance,
-                               /*in*/ const iBase_EntitySetHandle entity_set_handle,
-                               /*in*/ const iBase_TagHandle *tag_handles,
-                               /*in*/ const char * const *tag_vals,
-                               /*in*/ const int num_tags_vals,
-                               /*in*/ const int recursive,
-                               /*out*/ iBase_EntityHandle** set_handles,
-                               /*out*/ int* set_handles_allocated,
-                               /*out*/ int* set_handles_size,
-                               /*out*/ int *err)
+MBErrorCode iMesh_tag_set_vertices(iMesh_Instance instance,
+                                   MBEntityHandle in_set, 
+                                   const int req_dimension, 
+                                   const MBEntityType req_type,
+                                   MBTag &tag, MBRange &req_entities, 
+                                   int &num_verts, int *err) 
 {
-  MBRange out_entities;
- 
-  MBEntityHandle handle = ENTITY_HANDLE(entity_set_handle);
-  MBErrorCode result;
-
-  result = MBI->get_entities_by_type_and_tag(handle, MBENTITYSET, (MBTag*)tag_handles, 
-                                                 (const void* const *)tag_vals,
-                                                 num_tags_vals, out_entities, 
-                                                 MBInterface::INTERSECT, recursive);
-  if (result != MB_SUCCESS) {
-    std::string msg("ERROR getting entities, with error type: ");
+    // get all the entities then vertices
+  MBRange vertices, entities;
+  entities.clear();
+  MBErrorCode result = MBI->get_entities_by_handle(in_set, entities, false);
+  if (MB_SUCCESS != result) {
+    std::string msg("MBMesh::tag_set_vertices: getting entities didn't succeed., with error type: ");
     msg += MBI->get_error_string(result);
     iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
-    RETURN(iBase_ERROR_MAP[result]);
+    return result;
   }
 
-  CHECK_SIZE(*set_handles, *set_handles_allocated, 
-             (int)out_entities.size(), iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
+    // remove any sets
+  entities.erase(entities.lower_bound(MBENTITYSET),
+                 entities.upper_bound(MBENTITYSET));
 
-  std::copy(out_entities.begin(), out_entities.end(), ((MBEntityHandle*) *set_handles));
+    // get vertices
+  result = MBI->get_adjacencies(entities, 0, false, vertices,
+                                MBInterface::UNION);
+  if (MB_SUCCESS != result) {
+    std::string msg("MBMesh::tag_set_vertices: getting vertices didn't succeed., with error type: ");
+    msg += MBI->get_error_string(result);
+    iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+    return result;
+  }
   
-    // now it's safe to set the size; set it to k, not out_entities.size(), to
-    // account for sets which might have been removed
-  *set_handles_size = out_entities.size();
+    // tag each vertex with its index in this list
+  int i = 0;
+  if (tag == 0) {
+    result = MBI->tag_create("__position_tag", 4, MB_TAG_DENSE, tag, &i);
+    if (0 == tag) {
+      std::string msg("MBMesh::tag_set_vertices: couldn't make tag., with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      return result;
+    }
+  }
+  
+  MBRange::iterator vit;
+  for (vit = vertices.begin(), i = 0; vit != vertices.end(); vit++, i++) {
+    result = MBI->tag_set_data(tag, &(*vit), 1, &i);
+    if (MB_SUCCESS != result) {
+      std::string msg("MBMesh::tag_set_vertices: couldn't set pos_tag., with error type: ");
+      msg += MBI->get_error_string(result);
+      iMesh_processError(iBase_ERROR_MAP[result], msg.c_str());
+      return result;
+    }
+  }
 
-  RETURN(iBase_SUCCESS);
-}
+  if (req_dimension == -1 && req_type == MBMAXTYPE) return MB_SUCCESS;
+  
+    // winnow the list for entities of the desired type and/or topology
+  num_verts = 0;
+  MBRange::iterator ent_it;
+  MBEntityType this_type;
+  for (ent_it = entities.begin(); ent_it != entities.end(); ent_it++) {
+    this_type = MBI->type_from_handle(*ent_it);
+    if (req_dimension == MBCN::Dimension(this_type) ||
+        this_type == req_type) {
+      req_entities.insert(*ent_it);
+      num_verts += MBCN::VerticesPerEntity(this_type);
+    }
+  }
 
-void iMesh_MBCNType(/*in*/ const int imesh_entity_topology,
-                    /*out*/ int *mbcn_type) 
-{
-  if (iMesh_POINT > imesh_entity_topology ||
-      iMesh_ALL_TOPOLOGIES <= imesh_entity_topology)
-    *mbcn_type = -1;
-  else
-    *mbcn_type = mb_topology_table[imesh_entity_topology];
+  return result;
 }
-    
+
 void eatwhitespace(std::string &this_string) 
 {
   std::string::size_type len = this_string.find_last_not_of(" ");




More information about the moab-dev mailing list