#include "mfem.hpp"
#include <string>
#include <iostream>
#include <fstream>

#include "meshIO.h"


MeshIO::MeshIO(const std::string &mesh_file)
{
    mesh_file_ = mesh_file;
    std::ifstream mesh_stream(mesh_file);
    if (!mesh_stream)
    {
        throw std::runtime_error("Mesh file not found: " + mesh_file);
        loaded_ = false;
    }
    else
    {
        mesh_ = mfem::Mesh(mesh_stream, 1, 2);
        loaded_ = true;
    }
}

MeshIO::~MeshIO()
{
}

bool MeshIO::IsLoaded() const
{
    return loaded_;
}

mfem::Mesh& MeshIO::GetMesh()
{
    return mesh_;
}