MOAB: Mesh Oriented datABase  (version 5.4.1)
PatchSetUser.hpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2006 Lawrence Livermore National Laboratory.  Under
00005     the terms of Contract B545069 with the University of Wisconsin --
00006     Madison, Lawrence Livermore National Laboratory retains certain
00007     rights in this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     (2006) [email protected]
00024 
00025   ***************************************************************** */
00026 
00027 #ifndef MSQ_PATCH_SET_USER_HPP
00028 #define MSQ_PATCH_SET_USER_HPP
00029 
00030 #include "Mesquite.hpp"
00031 #include "VertexPatches.hpp"
00032 #include "GlobalPatch.hpp"
00033 
00034 namespace MBMesquite
00035 {
00036 
00037 /**\brief Utility class for handling variable patch types
00038  *
00039  * Common implementation for classes supporting variable patch types.
00040  */
00041 class PatchSetUser
00042 {
00043   public:
00044     PatchSetUser( bool defaultGlobal ) : myVertexPatches( 1, true )
00045     {
00046         if( defaultGlobal )
00047             activePatchSet = &myGlobalPatch;
00048         else
00049             activePatchSet = &myVertexPatches;
00050     }
00051 
00052     PatchSetUser( PatchSet* my_patch_set ) : myVertexPatches( 1, true ), activePatchSet( my_patch_set ) {}
00053 
00054     virtual ~PatchSetUser();
00055 
00056     /**\brief Use a single patch representing the entire mesh */
00057     void use_global_patch()
00058     {
00059         activePatchSet = &myGlobalPatch;
00060     }
00061 
00062     /**\brief Using a single patch representing the entire mesh */
00063     bool using_global_patch() const
00064     {
00065         return activePatchSet == &myGlobalPatch;
00066     }
00067 
00068     /**\brief Construct a patch for each free vertex in the mesh
00069      *\param num_layers Number of layers of adjacent elements to
00070      *                  include in the patch.  If unsure, use 1.
00071      */
00072     void use_element_on_vertex_patch( unsigned num_layers = 1 )
00073     {
00074         activePatchSet = &myVertexPatches;
00075         myVertexPatches.set_num_layers( num_layers );
00076     }
00077 
00078     /**\brief True if a patch will be constructed for each free vertex */
00079     bool using_element_on_vertex_patch() const
00080     {
00081         return activePatchSet == &myVertexPatches;
00082     }
00083 
00084     /**\brief Get the number of layers of elements that will be included
00085      *        in an element-on-vertex patch
00086      */
00087     unsigned num_element_on_vertex_layers() const
00088     {
00089         return myVertexPatches.get_num_layers();
00090     }
00091 
00092     virtual PatchSet* get_patch_set()
00093     {
00094         return activePatchSet;
00095     }
00096 
00097     void use_patch_set( PatchSet* patch_set )
00098     {
00099         activePatchSet = patch_set;
00100     }
00101 
00102   private:
00103     VertexPatches myVertexPatches;
00104     GlobalPatch myGlobalPatch;
00105     PatchSet* activePatchSet;
00106 };
00107 
00108 }  // namespace MBMesquite
00109 
00110 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines