예제 #1
0
    /* Function to sort an array using insertion sort*/
    void insertionSort(EdgeTableTuple ett)
    {
        int        i, j;
        EdgeBucket temp = new EdgeBucket();

        for (i = 1; i < ett.countEdgeBucket; i++)
        {
            temp.ymax         = ett.buckets[i].ymax;
            temp.xofymin      = ett.buckets[i].xofymin;
            temp.slopeinverse = ett.buckets[i].slopeinverse;
            j = i - 1;

            while (j >= 0)
            {
                bool v = (temp.xofymin < ett.buckets[j].xofymin);
                if (!v)
                {
                    break;
                }
                ett.buckets[j + 1].ymax         = ett.buckets[j].ymax;
                ett.buckets[j + 1].xofymin      = ett.buckets[j].xofymin;
                ett.buckets[j + 1].slopeinverse = ett.buckets[j].slopeinverse;
                j = j - 1;
            }
            ett.buckets[j + 1].ymax         = temp.ymax;
            ett.buckets[j + 1].xofymin      = temp.xofymin;
            ett.buckets[j + 1].slopeinverse = temp.slopeinverse;
        }
    }
예제 #2
0
    void updatexbyslopeinv(EdgeTableTuple Tup)
    {
        int i;

        for (i = 0; i < Tup.countEdgeBucket; i++)
        {
            (Tup.buckets[i]).xofymin = (Tup.buckets[i]).xofymin + (Tup.buckets[i]).slopeinverse;
        }
    }
예제 #3
0
    static void printTuple(EdgeTableTuple tup)
    {
        int j;

        if (tup.countEdgeBucket > 0)
        {
            printf("\nCount {0}-----\n", tup.countEdgeBucket);
        }

        for (j = 0; j < tup.countEdgeBucket; j++)
        {
            printf(" {0} + {1} + {2}",
                   tup.buckets[j].ymax, tup.buckets[j].xofymin, tup.buckets[j].slopeinverse);
        }
    }
예제 #4
0
    void storeEdgeInTuple(EdgeTableTuple receiver, Scaler ym, Scaler xm, float slopInv)
    {
        // both used for edgetable and active edge table..
        // The edge tuple sorted in increasing ymax and x of the lower end.
        int countEdgeBucket = receiver.countEdgeBucket;
        var buckets         = receiver.buckets;

        buckets[countEdgeBucket].ymax         = ym;
        buckets[countEdgeBucket].xofymin      = xm;
        buckets[countEdgeBucket].slopeinverse = slopInv;

        // sort the buckets
        insertionSort(receiver);

        (receiver.countEdgeBucket)++;
    }
예제 #5
0
    void removeEdgeByYmax(EdgeTableTuple Tup, int yy)
    {
        int i, j;

        for (i = 0; i < Tup.countEdgeBucket; i++)
        {
            if (Tup.buckets[i].ymax == yy)
            {
                //printf( "\nRemoved at {0}" , yy );

                for (j = i; j < Tup.countEdgeBucket - 1; j++)
                {
                    Tup.buckets[j].ymax         = Tup.buckets[j + 1].ymax;
                    Tup.buckets[j].xofymin      = Tup.buckets[j + 1].xofymin;
                    Tup.buckets[j].slopeinverse = Tup.buckets[j + 1].slopeinverse;
                }
                Tup.countEdgeBucket--;
                i--;
            }
        }
    }