00001 #ifndef BMESH_CURVATURE_H_IS_INCLUDED
00002 #define BMESH_CURVATURE_H_IS_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <vector>
00015
00016 class Bvert;
00017 class BMESH;
00018
00019
00020
00021
00022
00023 class BMESHcurvature_data {
00024
00025 public:
00026
00027
00028
00029
00030
00031 BMESHcurvature_data(const BMESH *mesh_in);
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 struct corner_areas_t {
00045
00046 corner_areas_t(double val = 0.0) { areas[0] = areas[1] = areas[2] = val; }
00047
00048 double areas[3];
00049
00050 double &operator[](int idx) { return areas[idx]; }
00051 double operator[](int idx) const { return areas[idx]; }
00052
00053 };
00054
00055
00056
00057
00058
00059
00060
00061 struct curv_tensor_t {
00062
00063 curv_tensor_t(double val = 0.0)
00064 { curv[0] = curv[1] = curv[2] = val; }
00065
00066 curv_tensor_t(double val0, double val1, double val2)
00067 { curv[0] = val0; curv[1] = val1; curv[2] = val2; }
00068
00069 double curv[3];
00070
00071 double &operator[](int idx) { return curv[idx]; }
00072 double operator[](int idx) const { return curv[idx]; }
00073
00074 curv_tensor_t operator+(const curv_tensor_t &other) const
00075 { return curv_tensor_t(curv[0] + other[0],
00076 curv[1] + other[1],
00077 curv[2] + other[2]); }
00078
00079 curv_tensor_t &operator+=(const curv_tensor_t &other)
00080 { *this = curv_tensor_t(curv[0] + other[0], curv[1] + other[1],
00081 curv[2] + other[2]);
00082 return *this; }
00083
00084 curv_tensor_t operator-(const curv_tensor_t &other) const
00085 { return curv_tensor_t(curv[0] - other[0],
00086 curv[1] - other[1],
00087 curv[2] - other[2]); }
00088
00089 curv_tensor_t operator*(double s) const
00090 { return curv_tensor_t(curv[0]*s, curv[1]*s, curv[2]*s); }
00091
00092 friend curv_tensor_t operator*(double s, const curv_tensor_t &curv)
00093 { return curv*s; }
00094
00095 };
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 struct dcurv_tensor_t {
00106
00107 dcurv_tensor_t(double val = 0.0)
00108 { dcurv[0] = dcurv[1] = dcurv[2] = dcurv[3] = val; }
00109
00110 dcurv_tensor_t(double val0, double val1, double val2, double val3)
00111 { dcurv[0] = val0; dcurv[1] = val1; dcurv[2] = val2; dcurv[3] = val3; }
00112
00113 double dcurv[4];
00114
00115 double &operator[](int idx) { return dcurv[idx]; }
00116 double operator[](int idx) const { return dcurv[idx]; }
00117
00118 dcurv_tensor_t operator+(const dcurv_tensor_t &other) const
00119 { return dcurv_tensor_t(dcurv[0] + other[0], dcurv[1] + other[1],
00120 dcurv[2] + other[2], dcurv[3] + other[3]); }
00121
00122 dcurv_tensor_t &operator+=(const dcurv_tensor_t &other)
00123 { *this = dcurv_tensor_t(dcurv[0] + other[0], dcurv[1] + other[1],
00124 dcurv[2] + other[2], dcurv[3] + other[3]);
00125 return *this; }
00126
00127 dcurv_tensor_t operator-(const dcurv_tensor_t &other) const
00128 { return dcurv_tensor_t(dcurv[0] - other[0], dcurv[1] - other[1],
00129 dcurv[2] - other[2], dcurv[3] - other[3]); }
00130
00131 dcurv_tensor_t operator*(double s) const
00132 { return dcurv_tensor_t(dcurv[0]*s, dcurv[1]*s, dcurv[2]*s, dcurv[3]*s); }
00133
00134 friend dcurv_tensor_t operator*(double s, const dcurv_tensor_t &dcurv)
00135 { return dcurv*s; }
00136
00137 };
00138
00139
00140
00141
00142
00143
00144
00145 struct diag_curv_t {
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 double _k1, _k2;
00156 Wvec _pdir1, _pdir2;
00157
00158 double k1() const { return _k1; }
00159 double k2() const { return _k2; }
00160
00161 Wvec pdir1() const { return _pdir1; }
00162 Wvec pdir2() const { return _pdir2; }
00163
00164 };
00165
00166
00167
00168
00169
00170
00171 curv_tensor_t curv_tensor(const Bvert *v);
00172 diag_curv_t diag_curv(const Bvert *v);
00173 double k1(const Bvert *v);
00174 double k2(const Bvert *v);
00175 Wvec pdir1(const Bvert *v);
00176 Wvec pdir2(const Bvert *v);
00177 dcurv_tensor_t dcurv_tensor(const Bvert *v);
00178 double feature_size()
00179 { return mesh_feature_size; }
00180
00181
00182
00183 private:
00184
00185 const BMESH *mesh;
00186
00187 std::vector<corner_areas_t> corner_areas;
00188 std::vector<double> vertex_areas;
00189 std::vector<curv_tensor_t> face_curv;
00190 std::vector<curv_tensor_t> vertex_curv;
00191 std::vector<diag_curv_t> diag_vertex_curv;
00192 std::vector<dcurv_tensor_t> face_dcurv;
00193 std::vector<dcurv_tensor_t> vertex_dcurv;
00194 double mesh_feature_size;
00195
00196
00197
00198
00199 void compute_corner_areas();
00200 void compute_vertex_areas();
00201 void compute_face_curvatures();
00202 void compute_vertex_curvatures();
00203 void diagonalize_vertex_curvatures();
00204 void compute_face_dcurv();
00205 void compute_vertex_dcurv();
00206 void compute_feature_size();
00207
00208
00209
00210 };
00211
00212 #endif