[MOAB-dev] r4194 - in MOAB/trunk/src: . moab

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Oct 6 11:54:46 CDT 2010


Author: kraftche
Date: 2010-10-06 11:54:46 -0500 (Wed, 06 Oct 2010)
New Revision: 4194

Modified:
   MOAB/trunk/src/Range.cpp
   MOAB/trunk/src/moab/Range.hpp
Log:
add Range::subset_by_dimension(int)

Modified: MOAB/trunk/src/Range.cpp
===================================================================
--- MOAB/trunk/src/Range.cpp	2010-10-06 00:29:16 UTC (rev 4193)
+++ MOAB/trunk/src/Range.cpp	2010-10-06 16:54:46 UTC (rev 4194)
@@ -995,6 +995,26 @@
   return result;
 }
 
+    //! return a subset of this range, by type
+Range Range::subset_by_dimension( int d ) const
+{
+  EntityHandle handle1 = CREATE_HANDLE( CN::TypeDimensionMap[d].first, 0 );
+  iterator st = lower_bound( begin(), end(), handle1 );
+  
+  iterator en;
+  if (d < 4) { // dimension 4 is MBENTITYSET
+    EntityHandle handle2 = CREATE_HANDLE( CN::TypeDimensionMap[d+1].first, 0 );
+    iterator en = lower_bound( st, end(), handle2 );
+  }
+  else {
+    en = end();
+  }
+
+  Range result;
+  result.insert( st, en );
+  return result;
+}
+
 bool operator==( const Range& r1, const Range& r2 )
 {
   Range::const_pair_iterator i1, i2;

Modified: MOAB/trunk/src/moab/Range.hpp
===================================================================
--- MOAB/trunk/src/moab/Range.hpp	2010-10-06 00:29:16 UTC (rev 4193)
+++ MOAB/trunk/src/moab/Range.hpp	2010-10-06 16:54:46 UTC (rev 4194)
@@ -349,6 +349,9 @@
     //! return a subset of this range, by type
   Range subset_by_type(EntityType t) const;
   
+    //! return a subset of this range, by dimension
+  Range subset_by_dimension(int dim) const;
+  
   struct PairNode : public std::pair<EntityHandle,EntityHandle>
   {
 







More information about the moab-dev mailing list