[MOAB-dev] r4640 - MOAB/trunk/itaps/imesh

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Mar 24 17:33:51 CDT 2011


Author: kraftche
Date: 2011-03-24 17:33:51 -0500 (Thu, 24 Mar 2011)
New Revision: 4640

Added:
   MOAB/trunk/itaps/imesh/MBIter.hpp
Modified:
   MOAB/trunk/itaps/imesh/Makefile.am
   MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
   MOAB/trunk/itaps/imesh/testc_cbind.c
Log:
Fix various deficiencies in iMesh iterator implementation:
 o preserve order & duplicates when iterating over lists
 o never return MBKINFE or MBENTITYSET from iterator queries
 o add unit tests for iterator
 


Added: MOAB/trunk/itaps/imesh/MBIter.hpp
===================================================================
--- MOAB/trunk/itaps/imesh/MBIter.hpp	                        (rev 0)
+++ MOAB/trunk/itaps/imesh/MBIter.hpp	2011-03-24 22:33:51 UTC (rev 4640)
@@ -0,0 +1,107 @@
+#ifndef MOAB_MB_ITER_HPP
+#define MOAB_MB_ITER_HPP
+
+#define IS_BUILDING_MB
+#include "Internals.hpp"
+#include "moab/Range.hpp"
+#include "moab/Core.hpp"
+#include <vector>
+#include <algorithm>
+
+class iBase_EntityArrIterator_Private 
+{
+  protected:
+    iBase_EntityType entType;
+    iMesh_EntityTopology entTopo;
+    EntityHandle entSet;
+    int arrSize;
+    
+  public:
+    iBase_EntityArrIterator_Private( iBase_EntityType type,
+                                     iMesh_EntityTopology topology,
+                                     EntityHandle set,
+                                     int array_size )
+      : entType(type), entTopo(topology), entSet(set), arrSize(array_size)
+      {}
+
+    virtual ~iBase_EntityArrIterator_Private() {};
+
+    int array_size() const { return arrSize; }
+
+    // NOTE: input array must be at least arrLen long
+    virtual void get_entities( Core* mb, 
+                               EntityHandle* array,
+                               int& count_out ) = 0;
+    
+    virtual ErrorCode reset( Interface* mb ) = 0;
+    
+    class IsType { 
+      private: EntityType type;
+      public:  IsType( EntityType t ) : type(t) {}
+               bool operator()( EntityHandle h )
+                 { return TYPE_FROM_HANDLE(h) == type; }
+    };
+
+    void remove_type( std::vector<EntityHandle>& vect, EntityType t ) {
+      vect.erase( std::remove_if( vect.begin(), vect.end(), IsType(t) ), vect.end() );


More information about the moab-dev mailing list