/* Rectangle en 2D                              */
/*                                              */
/* Auteur: Nicolas JANEY                        */
/* nicolas.janey@univ-fcomte.fr                 */
/* Novembre 2012                                */

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include "Rectangle2D.h"
#include "Position2D.h"
#include "TraceSegment.h"

/* Constructeurs                                */

Rectangle2D::Rectangle2D(void) {
  ig = new Position2D();
  sd = new Position2D();
}

Rectangle2D::Rectangle2D(Position2D *p1,Position2D *p2) {
  this->ig = new Position2D(min(p1->c[0],p2->c[0]),min(p1->c[1],p2->c[1]));
  this->sd = new Position2D(max(p1->c[0],p2->c[0]),max(p1->c[1],p2->c[1]));
}

Rectangle2D::Rectangle2D(Rectangle2D *r) {
  ig = new Position2D(r->ig);
  sd = new Position2D(r->sd);
}

/* Destructeur                                  */

Rectangle2D::~Rectangle2D(void) {
  delete(sd);
  delete(ig);
}

/* Dessin OpenGL                                */

void Rectangle2D::draw(void) {
  trace(ig->c[0],ig->c[1],ig->c[0],sd->c[1]);
  trace(ig->c[0],ig->c[1],sd->c[0],ig->c[1]);
  trace(sd->c[0],sd->c[1],ig->c[0],sd->c[1]);
  trace(sd->c[0],sd->c[1],sd->c[0],ig->c[1]);
}

//////////////////////////////////////////////////

/* Code de Cohen-Sutherland d'une Position2D    */

int Rectangle2D::code(Position2D *p) {

}

//////////////////////////////////////////////////
