#ifndef DP_CURVE_TEST_C
#define DP_CURVE_TEST_C

#include <CGAL/Cartesian.h>
#include <CGAL/IO/Window_stream.h>
//#include <list>
#include <deque>
#include "approx_curve_segment.h"
#include <fstream>


typedef CGAL::Cartesian<double>                  R;
typedef CGAL::Arc_2<R>                           Arc;
typedef R::Segment_2                             Segment;
typedef R::Point_2                               Point;
typedef R::Circle_2                              Circle;
typedef std::deque<Point>::const_iterator        PointIterator;
leda_window W(600,400);

int main()
{
  CGAL::cgalize(W);
  double error ;
   
  std::ostream_iterator<Point> out (std::cout, "\n");

  Point p1(11,12),p2(23,14),p3(25,11),p4(25,32),p5(30,22),p6(29,20),p7(35,10),p8(71,20),p9(81,20);
  
  Circle c1(p1,p2,p3);
  Arc a1(c1,p1,p3);

  Segment s1(p3,p4);
  Arc a2(s1);
  
  Circle c2(p4,p5,p6);
  Arc  a3(c2,p4,p6);

  Circle c3(p6,p7,p8);
  Arc a4(c3, p6, p8);

  Segment s2(p8,p9);
  Arc a5(s2);

  std::deque<Arc* > L;
  std::deque<Point> Result;
  PointIterator res;

  L.push_back( &a1);
  L.push_back( &a2);
  L.push_back( &a3);
  L.push_back( &a4);
  L.push_back( &a5);
  
  W.set_frame_label("Douglas-Peuker Algorithm");

  CGAL::Cartesian<double> param;
  W.display();
  error = W.read_real(" Error bound?");
  
  W.acknowledge("Approximate");
  
  approximate_curve_c(L.begin(),L.end(),L.front(),Result,error,param);
 
  for (res = Result.begin();res != --Result.end();)
    {
      W.set_fg_color(leda_red);
      W<<*res;
      W.set_fg_color(leda_black);
      Segment seg(*res,*(++res));
      W<<seg;
    }
 
  cout<<endl;
  W.acknowledge(" Ready");

  return 1;
}



#endif
