MOAB: Mesh Oriented datABase  (version 5.4.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) [email protected]
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,
00087                                      size_t element,
00088                                      Sample sample,
00089                                      MsqMatrix< 3, 2 >& W_out,
00090                                      MsqError& err );
00091 
00092     virtual bool get_2D_target( PatchData& pd, size_t element, Sample sample, MsqMatrix< 2, 2 >& W_out, MsqError& err );
00093 
00094     virtual bool have_surface_orient() const
00095     {
00096         return cachedCalculator->have_surface_orient();
00097     }
00098 
00099   protected:
00100     void notify_patch_destroyed( CachedTargetData& d );
00101 
00102     void notify_sub_patch( PatchData& orig_patch,
00103                            CachedTargetData& data,
00104                            PatchData& sub_patch,
00105                            const size_t* vertex_index_map,
00106                            const size_t* element_index_map,
00107                            MsqError& err );
00108 
00109     void notify_new_patch( PatchData& patch, CachedTargetData& data );
00110 
00111   private:
00112     TargetCalculator* const cachedCalculator;
00113 };
00114 
00115 }  // namespace MBMesquite
00116 
00117 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines