MOAB: Mesh Oriented datABase  (version 5.2.1)
ExtractShell.h
Go to the documentation of this file.
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 class ExtractShell
00012 {
00013   const smoab::Interface& Interface;
00014   smoab::CellSets VCells;
00015 
00016 public:
00017   ExtractShell(const smoab::CellSets volCells,
00018                const smoab::Interface& interface):
00019     Interface(interface),
00020     VCells(volCells)
00021     {
00022     }
00023 
00024   bool findSkins(smoab::CellSets &surfaceCellSets);
00025 };
00026 
00027 
00028 //----------------------------------------------------------------------------
00029 bool ExtractShell::findSkins(smoab::CellSets &surfaceCellSets)
00030 {
00031   typedef smoab::Range::const_iterator Iterator;
00032 
00033   typedef smoab::CellSets::const_iterator SetIterator;
00034 
00035 
00036   smoab::Range cellsToRemove;
00037   for(SetIterator set = this->VCells.begin();
00038       set != this->VCells.end();
00039       ++set)
00040     {
00041     const smoab::Range &cells = set->cells();
00042     this->Interface.createAdjacencies(set->cells(),2);
00043 
00044 
00045     //we create the usage table for each iteration so that we only
00046     //get the shell of each cell set. If we used the table between
00047     //sets we would get the shell of the combined sets
00048     smoab::detail::UsageTable table;
00049     for(Iterator i = cells.begin(); i != cells.end(); ++i)
00050       {
00051       std::vector<smoab::EntityHandle> faceCells =
00052                         this->Interface.sideElements(*i,2);
00053 
00054       //the usage id allows you to label cells when going into the table
00055       //so that you can extract multiple shells where each is based on
00056       //a single region id.
00057       std::vector<int> regionId(1,faceCells.size());
00058       table.incrementUsage(faceCells,regionId);
00059       }
00060     smoab::Range surfaceCells = table.singleUsage();
00061 
00062     //create a new cell set that
00063     smoab::CellSet surfaceSet(set->entity(),surfaceCells);
00064     surfaceCellSets.push_back(surfaceSet);
00065 
00066     smoab::Range subsetToRemove = table.multipleUsage();
00067     cellsToRemove.insert(subsetToRemove.begin(),subsetToRemove.end());
00068     }
00069 
00070   //we will remove all cells that have multiple usages from the moab database
00071   //I really don't care if they already existed or not.
00072   this->Interface.remove(cellsToRemove);
00073   return true;
00074 }
00075 
00076 
00077 
00078 }
00079 
00080 #endif // __smoab_ExtractShell_h
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines