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
00042 #ifndef OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
00043 #define OPENMESH_DECIMATER_MODNORMALFLIPPING_HH
00044
00045
00046
00047
00048 #include <OpenMesh/Tools/Decimater/ModBaseT.hh>
00049
00050
00051
00052 namespace OpenMesh {
00053 namespace Decimater {
00054
00055
00056
00057
00066 template <typename DecimaterT>
00067 class ModNormalFlippingT : public ModBaseT< DecimaterT >
00068 {
00069 public:
00070
00071 DECIMATING_MODULE( ModNormalFlippingT, DecimaterT, NormalFlipping );
00072
00073 public:
00074
00076 ModNormalFlippingT( DecimaterT &_dec) : Base(_dec, true)
00077 {
00078 set_max_normal_deviation( 90.0f );
00079 }
00080
00081
00082 ~ModNormalFlippingT()
00083 { }
00084
00085
00086 public:
00087
00102 float collapse_priority(const CollapseInfo& _ci)
00103 {
00104
00105 mesh().set_point(_ci.v0, _ci.p1);
00106
00107
00108 typename Mesh::ConstVertexFaceIter vf_it(mesh(), _ci.v0);
00109 typename Mesh::FaceHandle fh;
00110 typename Mesh::Scalar c(1.0);
00111
00112 for (; vf_it; ++vf_it)
00113 {
00114 fh = vf_it.handle();
00115 if (fh != _ci.fl && fh != _ci.fr)
00116 {
00117 typename Mesh::Normal n1 = mesh().normal(fh);
00118 typename Mesh::Normal n2 = mesh().calc_face_normal(fh);
00119
00120 c = dot(n1, n2);
00121
00122 if (c < min_cos_)
00123 break;
00124 }
00125 }
00126
00127
00128 mesh().set_point(_ci.v0, _ci.p0);
00129
00130 return float( (c < min_cos_) ? ILLEGAL_COLLAPSE : LEGAL_COLLAPSE );
00131 }
00132
00133
00134
00135 public:
00136
00138 float max_normal_deviation() const { return max_deviation_ / M_PI * 180.0; }
00139
00141 float normal_deviation() const { return max_normal_deviation(); }
00142
00148 void set_max_normal_deviation(float _f) {
00149 max_deviation_ = _f / 180.0 * M_PI;
00150 min_cos_ = cos(max_deviation_);
00151 }
00152
00154 void set_normal_deviation(float _f)
00155 { set_max_normal_deviation(_f); }
00156
00157 private:
00158
00159
00160 void set_binary(bool _b) {}
00161
00162 private:
00163
00164
00165 double max_deviation_, min_cos_;
00166 };
00167
00168
00169
00170 }
00171 }
00172
00173 #endif // OPENACG_MODNORMALFLIPPING_HH defined
00174
00175