// ==========================================================================
// $Id: example.cpp,v 1.2 2011/10/19 14:20:20 jlang Exp $
// CSI2372 example Code for lecture 7
// ==========================================================================
// (C)opyright:
//
//   Jochen Lang
//   EECS, University of Ottawa
//   800 King Edward Ave.
//   Ottawa, On., K1N 6N5
//   Canada. 
//   http://www.eecs.uottawa.ca
// 
// Creator: jlang (Jochen Lang)
// Email:   jlang@eecs.uottawa.ca
// ==========================================================================
// $Log: example.cpp,v $
// Revision 1.2  2011/10/19 14:20:20  jlang
// update before lecture
//
// Revision 1.1  2011/10/19 03:24:40  jlang
// Added code for lecture 7
//
// Revision 1.1  2011/09/27 17:22:20  jlang
// Added bounding shape example
//
//
// ==========================================================================
#include <iostream>
#include "point2d.h"
#include "aa_box.h"
#include "circle.h"
#include "obbox.h"
#include "bounds.h"

using std::cout;
using std::endl;

int main() {
  // Specify some boundary points to enclose
  Point2D bp[4];
  bp[0] = Point2D(0,1);
  bp[1] = Point2D(1,0);
  bp[2] = Point2D(2,3);
  bp[3] = Point2D(3,2);
  Point2D query(2,0.5);
  // Bound with aabox
  Bounds *boundsA = new AABox();
  if ( boundsA->enclose( bp, 4 ) ) {
    boundsA->print();
    cout << endl;
    query.print();
    if ( boundsA->isInside( query ) ) {
      cout << " Query point is inside!" << endl;
    } else {
      cout << " Query point is outside!" << endl;
    }
  } else {
    cout << "Could not aabox points!" << endl;
  }
  // Bound with circle (not tight)
  Bounds *boundsB = new Circle();
  if ( boundsB->enclose( bp, 4 ) ) {
    boundsB->print();
    cout << endl;
    query.print();
    if ( boundsB->isInside( query ) ) {
      cout << " Query point is inside!" << endl;
    } else {
      cout << " Query point is outside!" << endl;
    }
  } else {
    cout << "Could not circle points!" << endl;
  }
  // Now with oriented bounding box
  OBBox objOBB; Bounds& boundsC = objOBB;
  if ( boundsC.enclose( bp, 4 ) ) {
    boundsC.print();
    cout << endl;
    query.print();
    if ( boundsC.isInside( query ) ) {
      cout << " Query point is inside!" << endl;
    } else {
      cout << " Query point is outside!" << endl;
    }
  } else {
    cout << "Could not obbox points!" << endl;
  }
  return 0;
}
