#include "Mesh.h"
#include "MeshCCMIO.h"
#include "MeshNGEOM.h"
#include "IOException.h"
#include <iostream>

using namespace std;

const char kDefaultState[] = "default";

Mesh* BuildMesh( const char* filename )
{
    if (strstr(filename, ".ngeom"))
	return(new MeshNGEOM(filename));
    else if (strstr(filename, ".ccm") || strstr(filename, ".sff"))
	return(new MeshCCMIO(filename));
    return(NULL);
}

int main( int argc, char *argv[] )
{
    if (argc < 2)
    {
	cout << "Usage:  " << argv[0] << " file1.ccm" << endl;
	return(0);
    }
    
    bool result = false;
    MeshCCMIO *mesh;
    try
    {
	mesh = new MeshCCMIO(argv[1]);
    }
    catch(IOException& e)
    {
	cerr << e.what() << endl;
    }

    Mesh::CellVertsArray cells;

    Mesh::CreateCellVertsArray(*mesh, cells);
    mesh->CheckFaceOrientation(cells);

    return(result);
}
