MOAB: Mesh Oriented datABase  (version 5.2.1)
CellSets.h
Go to the documentation of this file.
00001 
00002 #ifndef __smoab_CellSets_h
00003 #define __smoab_CellSets_h
00004 
00005 #include "SimpleMoab.h"
00006 
00007 namespace smoab
00008 {
00009 //----------------------------------------------------------------------------
00010 class CellSet
00011 {
00012 public:
00013   CellSet(smoab::EntityHandle p,const smoab::Range& cells):
00014     Entity(p),
00015     Cells(cells)
00016     {}
00017 
00018   const smoab::Range& cells() const { return this->Cells; }
00019   EntityHandle entity() const { return this->Entity; }
00020 
00021   bool contains(smoab::EntityHandle c) const
00022     {
00023     return this->Cells.find(c) != this->Cells.end();
00024     }
00025 
00026   void erase(smoab::Range cells)
00027     {
00028     //seems that erase() has a bug, so use subtract
00029     this->Cells = smoab::subtract(this->Cells,cells);
00030     }
00031 
00032 private:
00033   smoab::EntityHandle Entity;
00034   smoab::Range Cells;
00035 };
00036 
00037 //----------------------------------------------------------------------------
00038 //CellSets are just a vector of CellSets
00039 typedef std::vector<CellSet> CellSets;
00040 
00041 //----------------------------------------------------------------------------
00042 //templated so it works with FaceCellSets and CellSets
00043 template<typename T>
00044 smoab::Range getParents(const T& set)
00045 {
00046   typedef typename T::const_iterator iterator;
00047   smoab::Range result;
00048 
00049   for(iterator i=set.begin(); i != set.end(); ++i)
00050     {
00051     result.insert(i->entity());
00052     }
00053   return result;
00054 }
00055 
00056 //----------------------------------------------------------------------------
00057 //templated so it works with FaceCellSets and CellSets
00058 template<typename T>
00059 smoab::Range getAllCells(const T& set)
00060 {
00061   typedef typename T::const_iterator iterator;
00062   smoab::Range result;
00063 
00064   for(iterator i=set.begin(); i != set.end(); ++i)
00065     {
00066     smoab::Range c = i->cells();
00067     result.insert(c.begin(),c.end());
00068     }
00069   return result;
00070 }
00071 
00072 
00073 }
00074 
00075 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines