MOAB: Mesh Oriented datABase  (version 5.2.1)
CachingTargetCalculator.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) kraftche@cae.wisc.edu
00024 
00025   ***************************************************************** */
00026 
00027 /** \file CachingTargetCalculator.hpp
00028  *  \brief
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #ifndef MSQ_CACHING_TARGET_CALCULATOR_HPP
00033 #define MSQ_CACHING_TARGET_CALCULATOR_HPP
00034 
00035 #include "Mesquite.hpp"
00036 #include "TargetCalculator.hpp"
00037 #include "ExtraDataUser.hpp"
00038 #include "MsqMatrix.hpp"
00039 
00040 #include <vector>
00041 
00042 namespace MBMesquite
00043 {
00044 
00045 struct CachedTargetData
00046 {
00047     std::vector< size_t > elementOffsets;
00048     std::vector< MsqMatrix< 3, 3 > > targets3D;
00049     std::vector< MsqMatrix< 3, 2 > > targetsSurface;
00050     std::vector< MsqMatrix< 2, 2 > > targets2D;
00051     bool has_data() const
00052     {
00053         return !elementOffsets.empty();
00054     }
00055     void clear()
00056     {
00057         elementOffsets.clear();
00058         targets3D.clear();
00059         targets2D.clear();
00060         targetsSurface.clear();
00061     }
00062 };
00063 
00064 /**\brief Cache target matrices on PatchData
00065  *
00066  * This class is a decorator for concrete TargetCalculator
00067  * that caches the previously calculated targets.  This class
00068  * should not be used if the target matrices produced by the
00069  * concrete target calculator are a function of the vertex
00070  * positions in the active mesh.
00071  */
00072 class CachingTargetCalculator : public TargetCalculator, private ExtraDataUser< CachedTargetData >
00073 {
00074   public:
00075     CachingTargetCalculator( TargetCalculator* cached ) : cachedCalculator( cached ) {}
00076 
00077     virtual ~CachingTargetCalculator();
00078 
00079     TargetCalculator* get_cached_calculator() const
00080     {
00081         return cachedCalculator;
00082     }
00083 
00084     virtual bool get_3D_target( PatchData& pd, size_t element, Sample sample, MsqMatrix< 3, 3 >& W_out, MsqError& err );
00085 
00086     virtual bool get_surface_target( PatchData& pd, size_t element, Sample sample, MsqMatrix< 3, 2 >& W_out,
00087                                      MsqError& err );
00088 
00089     virtual bool get_2D_target( PatchData& pd, size_t element, Sample sample, MsqMatrix< 2, 2 >& W_out, MsqError& err );
00090 
00091     virtual bool have_surface_orient() const
00092     {
00093         return cachedCalculator->have_surface_orient();
00094     }
00095 
00096   protected:
00097     void notify_patch_destroyed( CachedTargetData& d );
00098 
00099     void notify_sub_patch( PatchData& orig_patch, CachedTargetData& data, PatchData& sub_patch,
00100                            const size_t* vertex_index_map, const size_t* element_index_map, MsqError& err );
00101 
00102     void notify_new_patch( PatchData& patch, CachedTargetData& data );
00103 
00104   private:
00105     TargetCalculator* const cachedCalculator;
00106 };
00107 
00108 }  // namespace MBMesquite
00109 
00110 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines