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