void init() {

        edgesYS = new int[edgesCount];
        System.arraycopy(edgesY, 0, edgesYS, 0, edgesCount);
        // Create edgesDY
        edgesDY = new int[edgesCount];
        for(int i = 0; i < edgesCount; i++) {
            int dy = edgesY[getNext(i)] - edgesY[i];
            edgesDY[i] = dy;
        }

        // Create edgesExt
        edgesExt = new boolean[edgesCount];
        int prev = -1;
        int i = 0;
        int pos = 0;
        while(i < edgesCount) {

            TOP: {
                do {
                    if (edgesDY[i] > 0) {
                        break TOP;
                    }
                    i = getNext(i);
                } while (i != pos);
                i = pos = getNextShape(i);
                continue;
            }

            BOTTOM: {
                do {
                    if (edgesDY[i] < 0) {
                        break BOTTOM;
                    }
                    if (edgesDY[i] > 0) {
                        prev = i;
                    }
                    i = getNext(i);
                } while (i != pos);
                i = pos = getNextShape(i);
                continue;
            }

            if (prev != -1) {
                edgesExt[prev] = true;
            }
            edgesExt[i] = true;
        }

        // Sort edgesY and edgesN
        sort(edgesYS, edgesN, edgesCount);

        edgeCur = 0;
        activeCount = 0;
        activeX = new float[edgesCount];
        activeYEnd = new int[edgesCount];
        activeXStep = new float[edgesCount];
        activeDY = new int[edgesCount];
        activeExt = new boolean[edgesCount];

        crossX = new int[edgesCount];
        crossDY = new int[edgesCount];
    }