Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 #ifndef __smoab_ExtractShell_h 00002 #define __smoab_ExtractShell_h 00003 00004 #include "SimpleMoab.h" 00005 #include "detail/UsageTable.h" 00006 00007 #include <algorithm> 00008 00009 namespace smoab 00010 { 00011 00012 class ExtractShell 00013 { 00014 const smoab::Interface& Interface; 00015 smoab::CellSets VCells; 00016 00017 public: 00018 ExtractShell( const smoab::CellSets volCells, const smoab::Interface& interface ) 00019 : Interface( interface ), VCells( volCells ) 00020 { 00021 } 00022 00023 bool findSkins( smoab::CellSets& surfaceCellSets ); 00024 }; 00025 00026 //---------------------------------------------------------------------------- 00027 bool ExtractShell::findSkins( smoab::CellSets& surfaceCellSets ) 00028 { 00029 typedef smoab::Range::const_iterator Iterator; 00030 00031 typedef smoab::CellSets::const_iterator SetIterator; 00032 00033 smoab::Range cellsToRemove; 00034 for( SetIterator set = this->VCells.begin(); set != this->VCells.end(); ++set ) 00035 { 00036 const smoab::Range& cells = set->cells(); 00037 this->Interface.createAdjacencies( set->cells(), 2 ); 00038 00039 //we create the usage table for each iteration so that we only 00040 //get the shell of each cell set. If we used the table between 00041 //sets we would get the shell of the combined sets 00042 smoab::detail::UsageTable table; 00043 for( Iterator i = cells.begin(); i != cells.end(); ++i ) 00044 { 00045 std::vector< smoab::EntityHandle > faceCells = this->Interface.sideElements( *i, 2 ); 00046 00047 //the usage id allows you to label cells when going into the table 00048 //so that you can extract multiple shells where each is based on 00049 //a single region id. 00050 std::vector< int > regionId( 1, faceCells.size() ); 00051 table.incrementUsage( faceCells, regionId ); 00052 } 00053 smoab::Range surfaceCells = table.singleUsage(); 00054 00055 //create a new cell set that 00056 smoab::CellSet surfaceSet( set->entity(), surfaceCells ); 00057 surfaceCellSets.push_back( surfaceSet ); 00058 00059 smoab::Range subsetToRemove = table.multipleUsage(); 00060 cellsToRemove.insert( subsetToRemove.begin(), subsetToRemove.end() ); 00061 } 00062 00063 //we will remove all cells that have multiple usages from the moab database 00064 //I really don't care if they already existed or not. 00065 this->Interface.remove( cellsToRemove ); 00066 return true; 00067 } 00068 00069 } // namespace smoab 00070 00071 #endif // __smoab_ExtractShell_h