Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CompositeLoopT.hh

Go to the documentation of this file.
00001 //=============================================================================
00002 //                                                                            
00003 //                               OpenMesh                                     
00004 //      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen       
00005 //                           www.openmesh.org                                 
00006 //                                                                            
00007 //-----------------------------------------------------------------------------
00008 //                                                                            
00009 //                                License                                     
00010 //                                                                            
00011 //   This library is free software; you can redistribute it and/or modify it 
00012 //   under the terms of the GNU Library General Public License as published  
00013 //   by the Free Software Foundation, version 2.                             
00014 //                                                                             
00015 //   This library is distributed in the hope that it will be useful, but       
00016 //   WITHOUT ANY WARRANTY; without even the implied warranty of                
00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00018 //   Library General Public License for more details.                          
00019 //                                                                            
00020 //   You should have received a copy of the GNU Library General Public         
00021 //   License along with this library; if not, write to the Free Software       
00022 //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 
00023 //                                                                            
00024 //-----------------------------------------------------------------------------
00025 //                                                                            
00026 //   $Revision: 1.3 $
00027 //   $Date: 2005/04/18 09:07:12 $
00028 //                                                                            
00029 //=============================================================================
00030 
00035 //=============================================================================
00036 //
00037 //  CLASS LoopT
00038 //
00039 //=============================================================================
00040 
00041 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH
00042 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH
00043 
00044 
00045 //== INCLUDES =================================================================
00046 
00047 #include "Composite/CompositeT.hh"
00048 #include "Composite/CompositeTraits.hh"
00049 
00050 
00051 //== NAMESPACE ================================================================
00052 
00053 namespace OpenMesh   { // BEGIN_NS_OPENMESH
00054 namespace Subdivider { // BEGIN_NS_DECIMATER
00055 namespace Uniform    { // BEGIN_NS_DECIMATER
00056 
00057 
00058 //== CLASS DEFINITION =========================================================
00059 
00062 template <class MeshType, class RealType=float>
00063 class CompositeLoopT : public CompositeT<MeshType, RealType>
00064 {
00065 public:
00066 
00067   typedef CompositeT<MeshType, RealType>  Inherited;
00068    
00069 public:
00070 
00071   CompositeLoopT() : Inherited() {};
00072   ~CompositeLoopT() {}
00073 
00074 public:
00075   
00076   const char *name() const { return "Uniform Composite Loop"; }
00077   
00078 protected: // inherited interface
00079 
00080   void apply_rules(void)  { Inherited::Tvv4(); Inherited::VdE(); EVc(coeffs_); Inherited::VdE(); EVc(coeffs_); }
00081 
00082 protected:
00083   
00084   typedef typename Inherited::Coeff Coeff;
00085   
00086   struct EVCoeff : public Coeff 
00087   {
00088     EVCoeff() : Coeff() { init(50); }
00089 
00090     void init(size_t _max_valence)
00091     {
00092       weights_.resize(_max_valence);
00093       std::generate(weights_.begin(), 
00094                     weights_.end(), compute_weight() );
00095     }
00096     
00097     double operator()(size_t _valence) { return weights_[_valence]; }
00098 
00099 
00100     struct compute_weight 
00101     {
00102       compute_weight() : val_(0) { }
00103 
00104       double operator()(void) // Loop weights for non-boundary vertices
00105       {
00106         // 1      3          2 * pi
00107         // - * ( --- + cos ( ------- ) )² - 1.0
00108         // 2      2          valence        
00109         double f1 = 1.5 + cos(2.0*M_PI/val_++);
00110         return 0.5 * f1 * f1 - 1.0;
00111       }
00112       size_t val_;
00113 
00114     };
00115 
00116     std::vector<double> weights_;
00117   } coeffs_;
00118 
00119 };
00120   
00121 //=============================================================================
00122 } // END_NS_UNIFORM
00123 } // END_NS_SUBDIVIDER
00124 } // END_NS_OPENMESH
00125 //=============================================================================
00126 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH defined
00127 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .