#include "tree.h"
#include "ellipse.h"
#include "treelps.h"

void makeellipseinorder(point *tree,       /* Traverses `tree' in order and */
			ellipse *ellipses, /* generates an array of */
			int *counter,      /* `ellipse's corresponding to */
			double a,          /* the ellipses centred at the */
			double b           /* points in `tree' with semi-x */
			)                  /* axis a and semi-y axis b */
{
  if(tree == NULL)
    return;
  makeellipseinorder(tree->left,ellipses,counter,a,b);
  makeellipse(tree,&(ellipses[*counter]),a,b);
  ++(*counter);
  makeellipseinorder(tree->right,ellipses,counter,a,b);
}

void makeellipseinorder_min(point *tree,   /* Traverses `tree' in order and */
			    ellipse *ellipses, /* generates an array of */
			    int *counter,  /* `ellipse's corresponding to */
			    double a,      /* the ellipses centred at the */
			    double b       /* points in `tree' with semi-x */
			    )              /* axis a and semi-y axis b */
{
  if(tree == NULL)
    return;
  makeellipseinorder_min(tree->left,ellipses,counter,a,b);
  if(tree->min_life){
    makeellipse(tree,&(ellipses[*counter]),a,b);
    ++(*counter);
  }
  makeellipseinorder_min(tree->right,ellipses,counter,a,b);
}

