#ifndef D3MESHPOINTREADER_H
#define D3MESHPOINTREADER_H

#include <cassert>
#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 d3meshpointreader
{
  d3tess & tess;
public:

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

  d3meshpointreader
  (
    bool & res,
    d3tess & tess_, 
    vector< pt3 > const & vbox,
    string const & filename
  );

  // Inserts the points into the tessellation.
  //   The points are already in the d3tess 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 readtwocolumns(ifstream & targ);
  void readthreecolumns(ifstream & targ);


  

};


#endif



