Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

uv_mapping.H

Go to the documentation of this file.
00001 #ifndef UV_MAPPING_H_HAS_BEEN_INCLUDED
00002 #define UV_MAPPING_H_HAS_BEEN_INCLUDED
00003 
00004 ////////////////////////////////////////////
00005 // UVMapping
00006 ////////////////////////////////////////////
00007 //
00008 // -Walks a mesh (starting from a seed) and
00009 //  bins the faces within a contiguous uv
00010 //  region into a fast lookup uv->wpt structure
00011 // -The number of bins is fixed, but the uv
00012 //  scaling varies depending upon the uv
00013 //  extent of the region
00014 // -Wrapping is u or v (along constant lines
00015 //  in u or v) is detected and checked for
00016 //  consistency with the u,v extrema of region
00017 //
00018 ////////////////////////////////////////////
00019 
00020 #include "bface.H"
00021 
00022 
00023 /*****************************************************************
00024  * UVMapping
00025  *****************************************************************/
00026 
00027 #define CUVMapping const UVMapping
00028 class UVMapping {
00029 
00030  protected:
00031 
00032    /******** MEMBERS VARIABLES ********/
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    /******** CONSTRUCTOR/DECONSTRUCTOR *******/
00057 
00058    UVMapping(Bface *f);
00059    ~UVMapping();
00060 
00061  protected:
00062 
00063    /******** STATIC MEMBERS METHODS ********/
00064 
00065    //Handy for isecting two line segments
00066    static bool intersect(CUVpt &pt1a, mlib::CUVpt &pt1b, mlib::CUVpt &pt2a, mlib::CUVpt &pt2b);
00067 
00068  public:
00069    /******** MEMBERS METHODS ********/
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    //When a FreeHatchingGroup sets its map
00079    //it registers, and when it dies is unregisters
00080    //If nobody cares about a map, it goes away...
00081 
00082    void                        register_usage()                { _use_cnt++; }
00083    void                        unregister_usage()        { --_use_cnt; assert(_use_cnt>=0); if (!_use_cnt) delete this;}
00084 
00085    //Accessors
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    //Interpolating method
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    /******** MEMBERS TYPES ********/
00107 
00108    typedef void (UVMapping::*rec_fun_t)(Bface *); 
00109 
00110    /******** MEMBERS METHODS ********/
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 /* end of file uv_mapping.H */

Generated on Mon Sep 18 11:39:34 2006 for jot by  doxygen 1.4.4