/**************************************************************************
**       Title: demo program for some inheritance in reference elements
**        Date: 29.4.2006
**   Copyright: Bernard Haasdonk
**************************************************************************/

/************** desired output after class implementation: ***************
---------------------------------------
type information  : polygon
number of vertices: 6
vertex 0 has coordinates (x,y) = (0,0)
vertex 1 has coordinates (x,y) = (1,0)
vertex 2 has coordinates (x,y) = (2,1)
vertex 3 has coordinates (x,y) = (1,2)
vertex 4 has coordinates (x,y) = (0,2)
vertex 5 has coordinates (x,y) = (-1,1)
circumference     : 7.65685
---------------------------------------
type information  : reference triangle
number of vertices: 3
vertex 0 has coordinates (x,y) = (0,0)
vertex 1 has coordinates (x,y) = (1,0)
vertex 2 has coordinates (x,y) = (0,1)
circumference     : 3.41421
---------------------------------------
type information  : reference square
number of vertices: 4
vertex 0 has coordinates (x,y) = (0,0)
vertex 1 has coordinates (x,y) = (1,0)
vertex 2 has coordinates (x,y) = (1,1)
vertex 3 has coordinates (x,y) = (0,1)
circumference     : 4
***************** end of desired output **********************/

#include "reference_elements.hh"
#include <iostream>

using namespace std;

void print_info(Polygon& poly)
{
  cout << "type information  : ";
  poly.print_type();
  cout << "\n";
  
  int nvertices = poly.nvertices();
  cout << "number of vertices: " << nvertices << "\n";
  
  double x,y;  
  for (int v=0; v<nvertices; v++)
  {
    poly.get_vertex(v,x,y);
    cout << "vertex " << v << " has coordinates (x,y) = (" << 
        x << "," << y << ")\n"; 
  }
  
  cout << "circumference     : " << poly.circumference() << "\n";
}

int main(int /*argc*/, char** /*argv*/)
{
  ReferenceTriangle ref_triangle;
  ReferenceSquare   ref_square;
  
  Polygon  polygon(6);  
  polygon.set_vertex(0,  0.0, 0.0);
  polygon.set_vertex(1,  1.0, 0.0);
  polygon.set_vertex(2,  2.0, 1.0);
  polygon.set_vertex(3,  1.0, 2.0);
  polygon.set_vertex(4,  0.0, 2.0);
  polygon.set_vertex(5, -1.0, 1.0);
  
  cout << "---------------------------------------\n";
  print_info(polygon);  
  cout << "---------------------------------------\n";
  print_info(ref_triangle);  
  cout << "---------------------------------------\n";
  print_info(ref_square);  
}


