// Gnurbs - A curve and surface library
// Copyright (C) 2008-2026 Eric Bechet
//
// See the LICENSE file for contributions and license information.
// Please report all bugs and problems to <bechet@cadxfem.org>.
//

#include <iostream>
#include <vector>

#include "nvtkdisplay.h"
#include "nbspline.h"

// function that computes an approximation curve with least squares
void LSapproximation(std::vector<npoint> &pts,nbspline &crv)
{
  // part to code.
  std::cout << pts.size() << " samples for the LS" << std::endl;
}



int main(void)
{
  data_container data;
  nvtkdisplay display;

  std::vector<npoint> LS_list; // samples list
  int nb_pts=100;
  for (int i=0;i<nb_pts;++i)
  {
    double r=1.+rand()/(RAND_MAX * 10.);
    double th=i*2*n_pi/(nb_pts-1);
    double x=r*cos(th)+5;
    double y=r*sin(th)+5;
    double z=0;
    LS_list.push_back(npoint(x,y,z));
  }

  nbspline LS_curve; // b-spline curve
  LSapproximation(LS_list,LS_curve); // call to the approx. function
  for (int i=0;i<LS_list.size();++i) data.add_point(LS_list[i]);
  LS_curve.Display(data);
  display.init_data(data);
  display.display();
  return 0;
}

