00001 #ifndef UV_MAPPING_H_HAS_BEEN_INCLUDED
00002 #define UV_MAPPING_H_HAS_BEEN_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "bface.H"
00021
00022
00023
00024
00025
00026
00027 #define CUVMapping const UVMapping
00028 class UVMapping {
00029
00030 protected:
00031
00032
00033
00034 ARRAY<ARRAY<Bface*>*> _mapping;
00035 Bface* _seed_face;
00036 int _face_cnt;
00037 int _bin_cnt;
00038 int _entry_cnt;
00039 int _use_cnt;
00040 double _du;
00041 double _dv;
00042 double _min_u;
00043 double _min_v;
00044 double _max_u;
00045 double _max_v;
00046 double _span_u;
00047 double _span_v;
00048 bool _wrap_u;
00049 bool _wrap_v;
00050 bool _wrap_bad;
00051 unsigned char * _virgin_debug_image;
00052 unsigned char * _marked_debug_image;
00053
00054 public:
00055
00056
00057
00058 UVMapping(Bface *f);
00059 ~UVMapping();
00060
00061 protected:
00062
00063
00064
00065
00066 static bool intersect(CUVpt &pt1a, mlib::CUVpt &pt1b, mlib::CUVpt &pt2a, mlib::CUVpt &pt2b);
00067
00068 public:
00069
00070
00071 Bface* find_face(CUVpt &uv, mlib::Wvec &bc);
00072
00073 void draw_debug();
00074 void clear_debug_image();
00075
00076 void debug_dot(double u,double val, unsigned char r,unsigned char g,unsigned char b);
00077
00078
00079
00080
00081
00082 void register_usage() { _use_cnt++; }
00083 void unregister_usage() { --_use_cnt; assert(_use_cnt>=0); if (!_use_cnt) delete this;}
00084
00085
00086
00087 inline bool wrap_u() { return _wrap_u; }
00088 inline bool wrap_v() { return _wrap_v; }
00089
00090 inline double span_u() { return _span_u; }
00091 inline double span_v() { return _span_v; }
00092
00093 inline double min_u() { return _min_u; }
00094 inline double min_v() { return _min_v; }
00095
00096 inline double max_u() { return _max_u; }
00097 inline double max_v() { return _max_v; }
00098
00099 Bface* seed_face() { return _seed_face; }
00100
00101
00102 void interpolate(CUVpt &uv1, double frac1,mlib::CUVpt &uv2, double frac2,mlib::UVpt &uv);
00103 void apply_wrap(UVpt &uv);
00104
00105 protected:
00106
00107
00108 typedef void (UVMapping::*rec_fun_t)(Bface *);
00109
00110
00111
00112 void compute_mapping(Bface *f);
00113 void compute_limits(Bface *f);
00114 void compute_wrapping(Bface *f);
00115 void compute_debug_image();
00116 void recurse_wrapping(Bface *f);
00117 void recurse(Bface *f, rec_fun_t fun);
00118 void add_face(Bface *f);
00119 void add_limit(Bface *f);
00120
00121 };
00122
00123 #endif // UV_MAPPING_H_HAS_BEEN_INCLUDED
00124
00125