/*
 *  triangle.h
 *  TriInterx
 *
 *  Created by Chema on 8/9/10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef Triangle_H
#define Triangle_H

#include <vector>
#include <utility>
#include <list>
#include <set>
#include "vec.h"

struct Edge;
struct Segment;

struct Triangle {

    typedef std::list<Triangle*> list; // active triangle table
    typedef std::vector<Triangle> vector;

    const DReal3* vx_[3];
    Edge* eg_[3];
    const DReal3* normal_;
    const Color3* rgb_; // material
    Segment* seg_;
    list::iterator aitr_;

    Triangle()
    : normal_(0)
    , rgb_(0)
    , seg_(0)
    {
        vx_[0]=0;vx_[1]=0;vx_[2]=0;
        eg_[0]=0;eg_[1]=0;eg_[2]=0;
    }
    
    void init( Segment* seg, const DReal3* a, const DReal3* b, const DReal3* c, Edge* e0, Edge* e1, Edge* e2, const DReal3* normal, const Color3* rgb);
    bool setlevel(dreal level);
    void reset(list& at);
};

#endif
