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