#ifndef	D4MESHPOINTREADER_H
#define D4MESHPOINTREADER_H

#include <string>
#include <iosfwd>
#include <vector>
using namespace std;

//
//  Brief:  Read and construct the mesh from points in files.
//
//  For timing experiments use constructor for reading the points in.  
//    Time the eval() function call for the time taken to insert the
//    points into the mesh.
class d4meshpointreader
{
  d4tess & tess;
public:

  // Reads the points into the mesh.
  //   Expecting a file with two or three columns of points.
  d4meshpointreader
  (
    bool & res, 
    d4tess & _tess, 
    string const &filename
  );

  d4meshpointreader
  (
    bool & res,
    d4tess & _tess, 
    vector< pt4 > const & vbox,
    string const & filename
  );

  // Inserts the points into the tessellation.
  //   The points are already in the d4tess point vector.
  void eval();

  // Inserts and times the point insertion.
  //   Writes the number of points and time on one line.
  void eval(ostream & os);

private:

  // Gets the number of columns by looking at first line of file.
  bool const isfilegood
  (
    uint & columns, 
    string const & filename
  ) const;

  void readthreecolumns(ifstream & targ);
  void readfourcolumns(ifstream & targ);
};


#endif


