void FBSplineSurface::samplePoints(std::vector< std::vector< double > > &points, double tResolution, double uResolution)
{
  double currentT = knots1[0];
  double currentU = knots2[0];
  double deltaT = tResolution;
  double deltaU = uResolution;


  int stepsT = numSamplePointsT = (int)((knots1[knots1.size() - 1] - knots1[0]) / deltaT + 1);
  int stepT = 0;
  int stepsU = numSamplePointsU = (int)((knots2[knots2.size() - 1] - knots2[0]) / deltaU + 1);
  int stepU = 0;

  for( stepU = 0; stepU < stepsU; stepU++)
  {
    currentU = knots2[0] + stepU * deltaU;
    for( stepT = 0; stepT < stepsT; stepT++)
    {
      std::vector< double > dmy;

      currentT = knots1[0] + stepT * deltaT;
      FArray samplePoint = this->f(currentT, currentU);
      samplePoint.getCoordinates(dmy);
      points.push_back(dmy);
    }
  }

  return;
}
void FBSpline::samplePoints(std::vector< std::vector< double > > &points, double resolution)
{
    double deltaT = resolution;
    double currentT = knots[0];

    int steps = (int)((knots[knots.size() - 1] - knots[0]) / deltaT + 1);

    for( int step = 0; step < steps; step++)
    {
        std::vector< double > dmy;
        currentT = knots[0] + step * deltaT;
        FArray samplePoint = f(currentT);
        samplePoint.getCoordinates(dmy);
        points.push_back(dmy);
    }
}
FArray FBSplineSurface::f(double _t, double _u)
{
    /*
           numDeBoorPoints1 -> t-parameter (knots1)
    n 0,0 _____________x_____________
    u    |  |  |  |  |  |  |  |  |  |
    m    |_____________x____________|
    D    |  |  |  |  |  |  |  |  |  |
    e    |_____________x____________| first all splines with t-param
    B    |  |  |  |  |  |  |  |  |  | then final spline with u-param
    o    |_____________x____________|
    o    |  |  |  |  |  |  |  |  |  |
    r    |____________[x]___________| f(t, u)
    P    |  |  |  |  |  |  |  |  |  |
    2    |_____________x____________|
    ->   |  |  |  |  |  |  |  |  |  |
    u    |_____________x____________|
    -    |  |  |  |  |  |  |  |  |  |
    param|_____________x____________|
 (knots2)|  |  |  |  |  |  |  |  |  |
         |_____________x____________|
  */

  std::vector< std::vector< double > > uSplineDeBoorPoints;

  for(int row = 0; row < numDeBoorPoints2; row++)
  {
    std::vector< std::vector< double > > tSplineDeBoorPoints;

    for(int col = 0; col < numDeBoorPoints1; col++)
      tSplineDeBoorPoints.push_back(this->deBoorPoints[row * numDeBoorPoints1 + col]);

    FBSpline tSpline(order1, tSplineDeBoorPoints);
    FArray dmyArray = tSpline.f(_t);

    std::vector< double > dmyVector;
    dmyArray.getCoordinates(dmyVector);

    uSplineDeBoorPoints.push_back(dmyVector);
  }

  FBSpline uSpline(order2, uSplineDeBoorPoints);
  return uSpline.f(_u);
}