Go to the documentation of this file.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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00046
00047
00048
00049
00050
00051
00052 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_TRAITS_HH
00053 #define OPENMESH_SUBDIVIDER_ADAPTIVE_TRAITS_HH
00054
00055
00056
00057
00058 #include <map>
00059 #include <OpenMesh/Core/Mesh/Types/TriMesh_ArrayKernelT.hh>
00060
00061
00062
00063 namespace OpenMesh {
00064 namespace Subdivider {
00065 namespace Adaptive {
00066
00067
00068
00069
00073
00074
00075
00076
00077 typedef int state_t;
00078 typedef bool final_t;
00079
00080 struct State
00081 {
00082 int state : 31;
00083 unsigned final : 1;
00084 };
00085
00086 struct Traits : public OpenMesh::DefaultTraits
00087 {
00088
00089
00090 FaceAttributes( OpenMesh::Attributes::Normal );
00091
00092
00093 VertexAttributes( OpenMesh::Attributes::Normal );
00094
00095
00096 HalfedgeAttributes( OpenMesh::Attributes::PrevHalfedge );
00097
00098 FaceTraits
00099 {
00100
00101 private:
00102
00103 typedef typename Refs::Point Point;
00104 typedef typename Refs::HalfedgeHandle HalfedgeHandle;
00105 typedef std::map<state_t, Point> PositionHistory;
00106
00107 State state_;
00108 HalfedgeHandle red_halfedge_;
00109
00110 PositionHistory pos_map_;
00111
00112 public:
00113
00114
00115 state_t state() const { return state_t(state_.state); }
00116 void set_state(const state_t _s) { state_.state = _s; }
00117 void inc_state() { ++state_.state; }
00118
00119
00120 final_t final() const { return final_t(state_.final); }
00121 void set_final() { state_.final = true; }
00122 void set_not_final() { state_.final = false; }
00123
00124
00125 const HalfedgeHandle& red_halfedge() const { return red_halfedge_; }
00126 void set_red_halfedge(const HalfedgeHandle& _h) { red_halfedge_ = _h; }
00127
00128
00129 void set_position(const int& _i, const Point& _p) { pos_map_[_i] = _p; }
00130 const Point position(const int& _i) {
00131 if (pos_map_.find(_i) != pos_map_.end())
00132 return pos_map_[_i];
00133 else {
00134
00135 if (_i <= 0) {
00136 const Point zero_point(0.0, 0.0, 0.0);
00137 return zero_point;
00138 }
00139
00140 return position(_i - 1);
00141 }
00142 }
00143 };
00144
00145
00146 EdgeTraits
00147 {
00148
00149 private:
00150
00151 typedef typename Refs::Point Point;
00152 typedef std::map<state_t, Point> PositionHistory;
00153
00154 State state_;
00155 PositionHistory pos_map_;
00156
00157 public:
00158
00159 typedef typename Refs::Scalar Scalar;
00160
00161
00162
00163
00164 state_t state() const { return state_t(state_.state); }
00165 void set_state(const state_t _s) { state_.state = _s; }
00166 void inc_state() { ++state_.state; }
00167
00168
00169 final_t final() const { return final_t(state_.final); }
00170 void set_final() { state_.final = true; }
00171 void set_not_final() { state_.final = false; }
00172
00173
00174 void set_position(const int& _i, const Point& _p) { pos_map_[_i] = _p; }
00175 const Point position(const int& _i) {
00176
00177 if (pos_map_.find(_i) != pos_map_.end())
00178 {
00179 return pos_map_[_i];
00180 }
00181 else
00182 {
00183 if (_i <= 0)
00184 {
00185 const Point zero_point(0.0, 0.0, 0.0);
00186 return zero_point;
00187 }
00188
00189 return position(_i - 1);
00190 }
00191 }
00192 };
00193
00194
00195 VertexTraits
00196 {
00197
00198 private:
00199
00200 typedef typename Refs::Point Point;
00201 typedef std::map<state_t, Point> PositionHistory;
00202
00203 State state_;
00204
00205 PositionHistory pos_map_;
00206
00207 public:
00208
00209
00210 state_t state() const { return state_.state; }
00211 void set_state(const state_t _s) { state_.state = _s; }
00212 void inc_state() { ++state_.state; }
00213
00214
00215
00216 final_t final() const { return state_.final; }
00217 void set_final() { state_.final = true; }
00218 void set_not_final() { state_.final = false; }
00219
00220
00221 void set_position(const int& _i, const Point& _p) { pos_map_[_i] = _p; }
00222 const Point position(const int& _i) {
00223
00224 if (pos_map_.find(_i) != pos_map_.end())
00225
00226 return pos_map_[_i];
00227
00228 else {
00229
00230 if (_i <= 0) {
00231
00232 const Point zero_point(0.0, 0.0, 0.0);
00233 return zero_point;
00234 }
00235
00236 return position(_i - 1);
00237 }
00238 }
00239 };
00240 };
00241
00242
00243 }
00244 }
00245 }
00246
00247 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_TRAITS_HH defined
00248