#include <QDebug>
#include "vibes.h"
#include "interval.h"
#include "box.h"
#include <list>
//   more more explanation, see : https://www.ensta-bretagne.fr/jaulin/easibex.html  Example 1

using namespace std;

void Cout(box& X)
{    SinRing(X[1],X[2], 1, 2, interval(4,5), true);
     SinRing(X[1],X[2], 2, 5, interval(5,6), true);
}

void Cin(box& X)
{    box A(X);
     box B(X);
     SinRing(A[1],A[2], 1, 2, interval(4,5), false);
     SinRing(B[1],B[2], 2, 5, interval(5,6), false);
     X=Union(A,B);
}

int main()
{   vibes::beginDrawing();
    vibes::newFigure("SIVIA");
    box X(interval(-10,10),interval(-10,10));
    list<box> L;
    L.push_back (X);
    while ( !L.empty() )
    {   X=L.front();   L.pop_front();
        vibes::drawBox(X[1].inf,X[1].sup,X[2].inf,X[2].sup,"blue[cyan]");
        Cout(X);
        vibes::drawBox(X[1].inf,X[1].sup,X[2].inf,X[2].sup,"red[magenta]");
        Cin(X);
        vibes::drawBox(X[1].inf,X[1].sup,X[2].inf,X[2].sup,"black[yellow]");
        if (X.Width()>0.1)
        {   box X1(2);  box X2(2);
            Bisect (X,X1,X2);
            L.push_back(X1);  L.push_back(X2);
        }
    }
    vibes::endDrawing();
    return 0;
}
