/*
 *  sweepTris.h
 *  VSweep
 *
 *  Created by Chema on 8/12/10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#include "vec.h"
#include "font.h"
#include "triangle.h"
#include <functional>
#include <vector>
#include <string>
#include <list>

struct ST {

    struct Event {
        enum eType {eTop, eMiddle, eBottom};
        
        struct Compare:
            public std::binary_function<const Event&,const Event&,bool> {
            bool operator()(const Event& lhs, const Event& rhs) const;
        };
        typedef std::vector<Event> vector; // list for events


        eType type_;
        DReal3 p_;
        Triangle* tri_;

        Event(const DReal3& p, Triangle* tri, const eType& type):
            type_(type), p_(p), tri_(tri) {;}
    };





    Edge::list aet_;
    Triangle::list at_;    
    Event::vector events_;
    SL sweepline_;

    public:
    ST() {;}
    ~ST(void) {;}

    void clear() {
        aet_.clear();
        at_.clear();
        events_.clear();
    }

    void init(std::vector<Triangle>& tris, std::vector<std::string>&);
    void run(int height, int& debug, Font& font, std::vector<std::string>&);

};



