Logo Search packages:      
Sourcecode: inkscape version File versions


Go to the documentation of this file.

/** \file
 * Coverage with floating-point boundaries.

#include <vector>
#include "livarot/LivarotDefs.h"

class IntLigne;
class BitLigne;

/// A coverage portion ("run") with floating point boundaries.
00015 struct float_ligne_run {
    float st;
    float en;
    float vst;
    float ven;
00020     float pente;   ///< (ven-vst)/(en-st)

 * A floating-point boundary.
 * Each float_ligne_bord is a boundary of some coverage.
 * The Flatten() function will extract non-overlapping runs and produce an 
 * array of float_ligne_run. The float_ligne_bord are stored in an array, but 
 * linked like a doubly-linked list.
 * The idea behind that is that a given edge produces one float_ligne_bord at 
 * the beginning of Scan() and possibly another in AvanceEdge() and 
 * DestroyEdge(); but that second float_ligne_bord will not be far away in 
 * the list from the first, so it's faster to salvage the index of the first 
 * float_ligne_bord and try to insert the second from that salvaged position.
00037 struct float_ligne_bord {
00038     float pos;    ///< position of the boundary
00039     bool start;   ///< is the beginning of the coverage portion?
00040     float val;    ///< amount of coverage (ie vst if start==true, and ven if start==false)
00041     float pente;  ///< (ven-vst)/(en-st)
00042     int other;    ///< index, in the array of float_ligne_bord, of the other boundary associated to this one
00043     int s_prev;   ///< index of the previous bord in the doubly-linked list
00044     int s_next;   ///< index of the next bord in the doubly-linked list
00045     int pend_ind; ///< bords[i].pend_ind is the index of the float_ligne_bord that is the start of the
                  ///< coverage portion being scanned (in the Flatten() )  
00047     int pend_inv; ///< inverse of pend_ind, for faster handling of insertion/removal in the "pending" array

 * Coverage with floating-point boundaries.
 * The goal is to salvage exact coverage info in the sweepline performed by 
 * Scan() or QuickScan(), then clean up a bit, convert floating point bounds
 * to integer bounds, because pixel have integer bounds, and then raster runs 
 * of the type:
 * \verbatim
   position on the (pixel) line:                st         en
                                                |          |
   coverage value (0=empty, 1=full)            vst   ->   ven   \endverbatim
00062 class FloatLigne {
00064     std::vector<float_ligne_bord> bords; ///< vector of coverage boundaries
00065     std::vector<float_ligne_run> runs;   ///< vector of runs

    /// first boundary in the doubly-linked list
00068     int s_first;
    /// last boundary in the doubly-linked list
00070     int s_last;


    void Reset();
    int AddBord(float spos, float sval, float epos, float eval, int guess = -1);
    int AddBord(float spos, float sval, float epos, float eval, float pente, int guess = -1);
    int AddBordR(float spos, float sval, float epos, float eval, float pente, int guess = -1);
    int AppendBord(float spos, float sval, float epos, float eval, float pente);
    void Flatten();

    void Affiche();

    void Max(FloatLigne *a, float tresh, bool addIt);
    void Min(FloatLigne *a, float tresh, bool addIt);
    void Split(FloatLigne *a, float tresh, FloatLigne *over);
    void Over(FloatLigne *a, float tresh);
    void Copy(IntLigne *a);
    void Copy(FloatLigne *a);

    float RemainingValAt(float at, int pending);
    static int CmpBord(float_ligne_bord const &d1, float_ligne_bord const &d2) {
        if ( d1.pos == d2.pos ) {
            if ( d1.start && !(d2.start) ) {
                return 1;
            if ( !(d1.start) && d2.start ) {
                return -1;
            return 0;
        return (( d1.pos < d2.pos ) ? -1 : 1);

    int AddRun(float st, float en, float vst, float ven, float pente);

    void InsertBord(int no, float p, int guess);
    int AddRun(float st, float en, float vst, float ven);

    inline float ValAt(float at, float ps, float pe, float vs, float ve) {
        return ((at - ps) * ve + (pe - at) * vs) / (pe - ps);


  Local Variables:
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :

Generated by  Doxygen 1.6.0   Back to index