public void optimize_data()
  {
    // Removing segments of length zero
    for(int i=0;i < size();)
    {
      if(
        (getPoint(i)[0] == getPoint(i + 1)[0])
        && (getPoint(i)[1] == getPoint(i + 1)[1]))
      {
        removePoint(i);
      }
      else
      {
        i++;
      }
    }

    // Concatenating consequitive parallel segments
    for(int i = 0; i < size();)
    {
      if(
        ((isOpen() && ((i + 1) < size())) || !isOpen())
        && are_segments_parallel(
          getPoint(i),
          getPoint(i + 1),
          getPoint(i + 1),
          getPoint(i + 2)))
      {
        removePoint(i + 1);
      }
      else
      {
        i++;
      }
    }
  }