00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00035
00036
00037
00038
00039
00040
00041 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH
00042 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH
00043
00044
00045
00046
00047 #include "Composite/CompositeT.hh"
00048 #include "Composite/CompositeTraits.hh"
00049
00050
00051
00052
00053 namespace OpenMesh {
00054 namespace Subdivider {
00055 namespace Uniform {
00056
00057
00058
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(MeshType& _mesh) : Inherited(_mesh) {};
00073 ~CompositeLoopT() {}
00074
00075 public:
00076
00077 const char *name() const { return "Uniform Composite Loop"; }
00078
00079 protected:
00080
00081 void apply_rules(void)
00082 {
00083 Inherited::Tvv4();
00084 Inherited::VdE();
00085 Inherited::EVc(coeffs_);
00086 Inherited::VdE();
00087 Inherited::EVc(coeffs_);
00088 }
00089
00090 protected:
00091
00092 typedef typename Inherited::Coeff Coeff;
00093
00094
00098 struct EVCoeff : public Coeff
00099 {
00100 EVCoeff() : Coeff() { init(50); }
00101
00102 void init(size_t _max_valence)
00103 {
00104 weights_.resize(_max_valence);
00105 std::generate(weights_.begin(),
00106 weights_.end(), compute_weight() );
00107 }
00108
00109 double operator()(size_t _valence) { return weights_[_valence]; }
00110
00112 struct compute_weight
00113 {
00114 compute_weight() : val_(0) { }
00115
00116 double operator()(void)
00117 {
00118
00119
00120
00121 double f1 = 1.5 + cos(2.0*M_PI/val_++);
00122 return 0.5 * f1 * f1 - 1.0;
00123 }
00124 size_t val_;
00125
00126 };
00127
00128 std::vector<double> weights_;
00129 } coeffs_;
00130
00131 };
00132
00133
00134 }
00135 }
00136 }
00137
00138 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITELOOPT_HH defined
00139