#ifndef TRIANGLEDISPLAY_H
#define TRIANGLEDISPLAY_H

#include <gobj.h>
#include <mathlib.h>
#include <triangle.h>


/*!
\brief Monolith of triangle display options.

The properties are displayed in a way to show
 how and what they are. For example the centroid
 will show the point and lines from the vertexes 
 generating the point.

Set the boolean variables and when
 the class is drawn the graphics are
 written as unprocessed commands to gx.
*/
template< typename TR >
class triangledisplay : public gobj
{
protected:
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** Display the triangle edges. */
  bool mesh;
  /** Display the mid points. */
  bool midpoints;
  /** Display the bisect points. */
  bool bisectpoints;
  /** Display the triangles centroid. */
  bool centroid;
  /** Display the orthocenter. */
  bool orthocenter;
  /** Display the circumcenter. */
  bool circumcenter;
  /** Display the incenter. */
  bool incenter;
  /** Display the Fermat point. */
  bool fermatpoint;
  /** Display the Napolean point. */
  bool napoleanpoint;
  /** Display the Gergonne point. */
  bool gergonnepoint;

  /** Turn all options on. */
  void turnon();

  /** The graphics output and triangle initialized. */
  triangledisplay
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr), mesh(1), midpoints(0), bisectpoints(0), centroid(0),
      orthocenter(0), circumcenter(0), incenter(0), 
      fermatpoint(0), napoleanpoint(0), gergonnepoint(0) {}

  /** Write the graphics as unprocessed commands to gx. */
  void draw();
};






/*!
\brief Monolith of triangle point properties displayed.

The properties are displayed in a minimal way. For example
 the centroid draws the centroid as a point, and unlike
 triangledisplay the lines showing the construction are not
 drawn.

Set the boolean variables and when
 the class is drawn the graphics are
 written as unprocessed commands to gx.
*/
template< typename TR >
class triangledisplaypoints : public triangledisplay<TR> 
{
public:

  /** The graphics output and triangle initialized. */
  triangledisplaypoints
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : triangledisplay<TR>(_gx,_tr) {}

  /** Write the graphics as unprocessed commands to gx. */
  void draw();
};





/*!
\brief Display the triangle's edges. 
*/
template< typename TR >
class triangledisplaymesh : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaymesh
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's midpoints. 
*/
template< typename TR >
class triangledisplaymidpoints : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaymidpoints
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's bisect points. 
*/
template< typename TR >
class triangledisplaybisectpoints : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaybisectpoints
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the average of the three points
       by constructing lines through the mid points.
*/
template< typename TR >
class triangledisplaycentroid : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaycentroid
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's orthocenter where
 altitudes intersect with the opposite vertex
 and each other. 
*/
template< typename TR >
class triangledisplayorthocenter : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplayorthocenter
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's circumcenter. 

The perpendicular bisectors meet and a circle passes
 through the vertexes.
*/
template< typename TR >
class triangledisplaycircumcenter : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaycircumcenter
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's incenter. 

Constructs a circle inside the triangle touching the
 triangles sides at the angles bisectors.
*/
template< typename TR >
class triangledisplayincenter : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplayincenter
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the Fermat point.

Construct equilateral trianges on the sides with
 new points E[i]. Line pi[i],E[i] uniquely intersect.
*/
template< typename TR >
class triangledisplayfermatpoint : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplayfermatpoint
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's napolean point. 

Construct equilateral triangles about the center
 triangle, then connect their centroids with
 the opposite point in the central triangle.
*/
template< typename TR >
class triangledisplaynapoleanpoint : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaynapoleanpoint
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

/*!
\brief Display the triangle's Gergonne point. 
Find the inner circle intersection points with the
 triangle. Their intersection with their opposite points
 generates the Gergonne point.
*/
template< typename TR >
class triangledisplaygergonnepoint : public gobj
{
  /** Unprocessed graphics. */
  gobjContainer & gx;
  /** The triangle. */
  TR const & tr;
public:

  /** The graphics output and triangle initialized. */
  triangledisplaygergonnepoint
  ( 
    gobjContainer & _gx, 
    TR const & _tr
  ) : gx(_gx), tr(_tr) {}
  
  /** Write the graphics as gobj objects. */
  void draw();
};

//--------------------------------------------------------- 
// Implementation

template< typename TR >
void triangledisplaynapoleanpoint<TR>::draw()
{
  gx.push( new gobjglColor3ub(0,0,139) );

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  typename TR::PTtype e0;
  tr.equilaterali(e0,0);
  typename TR::PTtype e1;
  tr.equilaterali(e1,1);
  typename TR::PTtype e2;
  tr.equilaterali(e2,2);

  gx.push( new gobjMySphereDraw(e0,gd) );
  gx.push( new gobjMySphereDraw(e1,gd) );
  gx.push( new gobjMySphereDraw(e2,gd) );

  gx.push( new gobjglBegin(GL_LINES) );

  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(e0) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(e0) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(e1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(e1) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(e2) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(e2) );

  gx.push( new gobjglEnd() );

  gx.push( new gobjglColor3ub(0,192,225) );
  typename TR::PTtype np;
  tr.napoleanpoint(np);
  gx.push( new gobjMySphereDraw(np,gd) );


  typename TR::PTtype c2;
  TR(tr.pi[1],tr.pi[0],e2).centroid(c2);
  typename TR::PTtype c1;
  TR(tr.pi[0],tr.pi[2],e1).centroid(c1);
  typename TR::PTtype c0;
  TR(tr.pi[2],tr.pi[1],e0).centroid(c0);

  gx.push( new gobjMySphereDraw(c0,gd) );
  gx.push( new gobjMySphereDraw(c1,gd) );
  gx.push( new gobjMySphereDraw(c2,gd) );

  gx.push( new gobjglBegin(GL_LINES) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(c0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(c1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(c2) );

  gx.push( new gobjglEnd() );
}

template< typename TR >
void triangledisplayfermatpoint<TR>::draw()
{
  gx.push( new gobjglColor3ub(0,0,139) );

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  typename TR::PTtype e0;
  tr.equilaterali(e0,0);
  typename TR::PTtype e1;
  tr.equilaterali(e1,1);
  typename TR::PTtype e2;
  tr.equilaterali(e2,2);

  gx.push( new gobjMySphereDraw(e0,gd) );
  gx.push( new gobjMySphereDraw(e1,gd) );
  gx.push( new gobjMySphereDraw(e2,gd) );

  gx.push( new gobjglBegin(GL_LINES) );

  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(e0) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(e0) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(e1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(e1) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(e2) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(e2) );

  gx.push( new gobjglEnd() );

  gx.push( new gobjglColor3ub(148,0,211) );
  typename TR::PTtype fp;
  tr.fermatpoint(fp);
  gx.push( new gobjMySphereDraw(fp,gd) );



  gx.push( new gobjglBegin(GL_LINES) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(e0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(e1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(e2) );

  gx.push( new gobjglEnd() );
}


template< typename TR >
void triangledisplaymesh<TR>::draw()
{
  gx.push( new gobjglColor3ub(0,0,255) );

  gx.push( new gobjglBegin(GL_LINES) );

  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );

  gx.push( new gobjglEnd() );
}

template< typename TR >
void triangledisplaymidpoints<TR>::draw()
{
  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  typename TR::PTtype m0;
  tr.midpoint(m0,0);
  typename TR::PTtype m1;
  tr.midpoint(m1,1);
  typename TR::PTtype m2;
  tr.midpoint(m2,2);

  gx.push( new gobjglColor3ub(255,0,255) );
  gx.push( new gobjMySphereDraw(m0,gd) );
  gx.push( new gobjMySphereDraw(m1,gd) );
  gx.push( new gobjMySphereDraw(m2,gd) );
}

template< typename TR >
void triangledisplaybisectpoints<TR>::draw()
{
  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  typename TR::PTtype b0;
  tr.bisectangle(b0,0);
  typename TR::PTtype b1;
  tr.bisectangle(b1,1);
  typename TR::PTtype b2;
  tr.bisectangle(b2,2);

  gx.push( new gobjglColor3ub(185,185,211) );
  gx.push( new gobjMySphereDraw(b0,gd) );
  gx.push( new gobjMySphereDraw(b1,gd) );
  gx.push( new gobjMySphereDraw(b2,gd) );
}



template< typename TR >
void triangledisplaycentroid<TR>::draw()
{
  typename TR::PTtype m0;
  tr.midpoint(m0,0);
  typename TR::PTtype m1;
  tr.midpoint(m1,1);
  typename TR::PTtype m2;
  tr.midpoint(m2,2);

  gx.push( new gobjglColor3ub(0,255,0) );
  gx.push( new gobjglBegin(GL_LINES) );
  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(m0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(m1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(m2) );
  gx.push( new gobjglEnd() );

  typename TR::PTtype mc;
  tr.centroid(mc);

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );
  gx.push( new gobjMySphereDraw(mc,gd) );
}

template< typename TR >
void triangledisplayorthocenter<TR>::draw()
{
  typename TR::PTtype vc;
  tr.orthocenter(vc);

  gx.push( new gobjglColor3ub(184,134,11) );
  typename TR::PTtype v0;
  tr.orthocenteri(v0,0);
  typename TR::PTtype v1;
  tr.orthocenteri(v1,1);
  typename TR::PTtype v2;
  tr.orthocenteri(v2,2);

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  gx.push( new gobjMySphereDraw(v0,gd) );
  gx.push( new gobjMySphereDraw(v1,gd) );
  gx.push( new gobjMySphereDraw(v2,gd) );

  gx.push( new gobjglColor3ub(255,215,0) );
  gx.push( new gobjglBegin(GL_LINES) );
  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(v0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(v1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(v2) );
  gx.push( new gobjglEnd() );

  //gx.push_back( new gobjglColor3ub(124,184,14) );
  gx.push( new gobjMySphereDraw(vc,gd) );
}

template< typename TR >
void triangledisplaycircumcenter<TR>::draw()
{
  typename TR::PTtype cc;
  tr.circumcenter(cc);

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  gobjMyCircle * gc = new gobjMyCircle();
  gx.push( new gobjglColor3ub(255,0,0) );
  gx.push( new gobjMySphereDraw(cc,gd) );


  typename TR::PTtype m0;
  tr.midpoint(m0,0);
  typename TR::PTtype m1;
  tr.midpoint(m1,1);
  typename TR::PTtype m2;
  tr.midpoint(m2,2);
  
  gx.push( new gobjglBegin(GL_LINES) );
  gx.push( new gobjglVertex3f(cc) );
  gx.push( new gobjglVertex3f(m0) );
  gx.push( new gobjglVertex3f(cc) );
  gx.push( new gobjglVertex3f(m1) );
  gx.push( new gobjglVertex3f(cc) );
  gx.push( new gobjglVertex3f(m2) );
  gx.push( new gobjglEnd() );

  gx.push( gc );

  point3<double> center;
  point3<double> circlenormal;
  double r;
  tr.outercircle(r,center,circlenormal);
  gx.push( new gobjMySphereDraw(center,gd) );
  gx.push( new gobjMyCircleDraw(r,center,circlenormal,*gc) );

/*
  point3<double> cc2(cc);
  point3<double> radius(cc2);
  radius.x -= tr.pi[0].x;
  radius.y -= tr.pi[0].y;
  gx.push_back( new gobjMyCircleDraw(sqrt(radius.dot()),cc2,*gc) );
*/
}

template< typename TR >
void triangledisplayincenter<TR>::draw()
{
  typename TR::PTtype b0;
  tr.bisectangle(b0,0);
  typename TR::PTtype b1;
  tr.bisectangle(b1,1);
  typename TR::PTtype b2;
  tr.bisectangle(b2,2);

  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  gx.push( new gobjglColor3ub(127,255,212) );
  gx.push( new gobjMySphereDraw(b0,gd) );
  gx.push( new gobjMySphereDraw(b1,gd) );
  gx.push( new gobjMySphereDraw(b2,gd) );

  gobjMyCircle * gc = new gobjMyCircle();

  //typename TR::PTtype center;
  //typename TR::PTtype circlenormal;
  point3<double> center;
  point3<double> circlenormal;
  double r;
  tr.innercircle(r,center,circlenormal);
  gx.push( new gobjMySphereDraw(center,gd) );
  gx.push( new gobjMyCircleDraw(r,center,circlenormal,*gc) );
  //gx.push_back( new gobjMyCircleDraw(r,x,*gc) );

  gx.push( new gobjglBegin(GL_LINES) );
  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(b0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(b1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(b2) );
  gx.push( new gobjglEnd() );
}


template< typename TR >
void triangledisplaygergonnepoint<TR>::draw()
{
  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  gx.push( gd );

  gx.push( new gobjglColor3ub(127,255,212) );
  gobjMyCircle * gc = new gobjMyCircle();
  //typename TR::PTtype center;
  //typename TR::PTtype circlenormal;
  point3<double> center;
  point3<double> circlenormal;
  double r;
  tr.innercircle(r,center,circlenormal);
  gx.push( new gobjMySphereDraw(center,gd) );
  gx.push( new gobjMyCircleDraw(r,center,circlenormal,*gc) );

  typename TR::PTtype c0;
  tr.incenteri(c0,0);
  typename TR::PTtype c1;
  tr.incenteri(c1,1);
  typename TR::PTtype c2;
  tr.incenteri(c2,2);

  gx.push( new gobjglColor3ub(127,255,0) );
  gx.push( new gobjMySphereDraw(c0,gd) );
  gx.push( new gobjMySphereDraw(c1,gd) );
  gx.push( new gobjMySphereDraw(c2,gd) );

  typename TR::PTtype gp;
  tr.gergonnepoint(gp);
  gx.push( new gobjMySphereDraw(gp,gd) );

  gx.push( new gobjglBegin(GL_LINES) );
  gx.push( new gobjglVertex3f(tr.pi[0]) );
  gx.push( new gobjglVertex3f(c0) );
  gx.push( new gobjglVertex3f(tr.pi[1]) );
  gx.push( new gobjglVertex3f(c1) );
  gx.push( new gobjglVertex3f(tr.pi[2]) );
  gx.push( new gobjglVertex3f(c2) );
  gx.push( new gobjglEnd() );
}




template< typename TR >
void triangledisplay<TR>::turnon()
{
  mesh=true;
  midpoints=true;
  bisectpoints=true;
  centroid=true;
  orthocenter=true;
  circumcenter=true;
  incenter=true;
  fermatpoint=true;
  napoleanpoint=true;
  gergonnepoint=true;
}

template< typename TR >
void triangledisplay<TR>::draw()
{
  vector< gobj* > vi;

  if (mesh)
    vi.push_back(new triangledisplaymesh<TR>(gx,tr));
  if (midpoints)
    vi.push_back(new triangledisplaymidpoints<TR>(gx,tr));
  if (bisectpoints)
    vi.push_back(new triangledisplaybisectpoints<TR>(gx,tr));
  if (centroid)
    vi.push_back(new triangledisplaycentroid<TR>(gx,tr));
  if (orthocenter)
    vi.push_back(new triangledisplayorthocenter<TR>(gx,tr));
  if (circumcenter)
    vi.push_back(new triangledisplaycircumcenter<TR>(gx,tr));
  if (incenter)
    vi.push_back(new triangledisplayincenter<TR>(gx,tr));
  if (fermatpoint)
    vi.push_back(new triangledisplayfermatpoint<TR>(gx,tr));
  if (napoleanpoint)
    vi.push_back(new triangledisplaynapoleanpoint<TR>(gx,tr));
  if (gergonnepoint)
    vi.push_back(new triangledisplaygergonnepoint<TR>(gx,tr));

  for (uint i=0; i<vi.size(); ++i)
  {
    vi[i]->draw();
    delete vi[i];
  }
}

template< typename TR >
void triangledisplaypoints<TR>::draw()
{
  vector< gobj* > vi;

  if (triangledisplay<TR>::mesh)
    vi.push_back(new triangledisplaymesh<TR>(triangledisplay<TR>::gx,triangledisplay<TR>::tr));

  if (triangledisplay<TR>::midpoints)
    vi.push_back(new triangledisplaymidpoints<TR>(triangledisplay<TR>::gx,triangledisplay<TR>::tr));

  if (triangledisplay<TR>::bisectpoints)
    vi.push_back(new triangledisplaybisectpoints<TR>(triangledisplay<TR>::gx,triangledisplay<TR>::tr));


  gobjQuadric * gd = new gobjQuadric();
  gd->radius=.02;
  triangledisplay<TR>::gx.push( gd );

  typename TR::PTtype c;

  if (triangledisplay<TR>::centroid)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(0,255,0) );
    triangledisplay<TR>::tr.centroid(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::orthocenter)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(184,134,11) );
    triangledisplay<TR>::tr.orthocenter(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::circumcenter)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(255,0,0) );
    triangledisplay<TR>::tr.circumcenter(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::incenter)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(127,255,212) );
    triangledisplay<TR>::tr.incenter(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::fermatpoint)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(148,0,211) );
    triangledisplay<TR>::tr.fermatpoint(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::napoleanpoint)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(0,192,255) );
    triangledisplay<TR>::tr.napoleanpoint(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  if (triangledisplay<TR>::gergonnepoint)
  {
    triangledisplay<TR>::gx.push( new gobjglColor3ub(127,255,0) );
    triangledisplay<TR>::tr.gergonnepoint(c);
    triangledisplay<TR>::gx.push( new gobjMySphereDraw(c,gd) );
  }

  for (uint i=0; i<vi.size(); ++i)
  {
    vi[i]->draw();
    delete vi[i];
  }
}


#endif




