<commit_before>// C++ includes
#include <iostream>
#include <cassert>

// Boost includes
#include <boost/filesystem.hpp>

// VTK includes
#include <vtkDataSetReader.h>
#include <vtkXMLReader.h>

#include <vtkXMLPRectilinearGridReader.h>
#include <vtkXMLPStructuredGridReader.h>
#include <vtkXMLPUnstructuredGridReader.h>

#include <vtkXMLRectilinearGridReader.h>
#include <vtkXMLStructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>

#include <vtkRectilinearGridReader.h>
#include <vtkStructuredGridReader.h>
#include <vtkUnstructuredGridReader.h>

#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>

#include <vtkDataSet.h>
#include <vtkDataArray.h>
#include <vtkCell.h>
#include <vtkIdList.h>


// ---------------------------------------------------------------------------

using namespace std;
namespace fs = boost::filesystem;


typedef enum {
    VTK, VTU, VTS, VTR, PVTU, PVTS, PVTR
} VtkReaderType;

// ---------------------------------------------------------------------------

double dist(double dx, double dy, double dz)
{
    return sqrt(dx*dx + dy*dy + dz*dz);
}

double BoxSize(double bounds[6])
{
    const double x0 = bounds[0];
    const double x1 = bounds[1];
    const double y0 = bounds[2];
    const double y1 = bounds[3];
    const double z0 = bounds[4];
    const double z1 = bounds[5];
    
    assert(x0 <= x1);
    assert(y0 <= y1);
    assert(z0 <= z1);

    return dist(x1-x0, y1-y0, z1-z0);
}

void PrintSize(vtkAlgorithm *algorithm, VtkReaderType readerType)
{
    vtkDataSet *dataset = 0;

    algorithm->Update();

    if (readerType == VTK)
    {
        vtkDataSetReader *legacy_reader = static_cast<vtkDataSetReader*>(algorithm);
        dataset = legacy_reader->GetOutput();
    }
    else
    {
        vtkXMLReader *xml_reader = static_cast<vtkXMLReader*>(algorithm);
        dataset = xml_reader->GetOutputAsDataSet();
    }

    dataset->Update();
    dataset->ComputeBounds();

    int n_points, n_cells;
    int e, emax;
    double bounds[6];
    double h, hmax;

    hmax = 0.0;<commit_msg>If mesh-info can't read its input vtk file, then just exit.<commit_after>// C++ includes
#include <iostream>
#include <cassert>

// Boost includes
#include <boost/filesystem.hpp>

// VTK includes
#include <vtkDataSetReader.h>
#include <vtkXMLReader.h>

#include <vtkXMLPRectilinearGridReader.h>
#include <vtkXMLPStructuredGridReader.h>
#include <vtkXMLPUnstructuredGridReader.h>

#include <vtkXMLRectilinearGridReader.h>
#include <vtkXMLStructuredGridReader.h>
#include <vtkXMLUnstructuredGridReader.h>

#include <vtkRectilinearGridReader.h>
#include <vtkStructuredGridReader.h>
#include <vtkUnstructuredGridReader.h>

#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkUnstructuredGrid.h>

#include <vtkDataSet.h>
#include <vtkDataArray.h>
#include <vtkCell.h>
#include <vtkIdList.h>


// ---------------------------------------------------------------------------

using namespace std;
namespace fs = boost::filesystem;


typedef enum {
    VTK, VTU, VTS, VTR, PVTU, PVTS, PVTR
} VtkReaderType;

// ---------------------------------------------------------------------------

double dist(double dx, double dy, double dz)
{
    return sqrt(dx*dx + dy*dy + dz*dz);
}

double BoxSize(double bounds[6])
{
    const double x0 = bounds[0];
    const double x1 = bounds[1];
    const double y0 = bounds[2];
    const double y1 = bounds[3];
    const double z0 = bounds[4];
    const double z1 = bounds[5];
    
    assert(x0 <= x1);
    assert(y0 <= y1);
    assert(z0 <= z1);

    return dist(x1-x0, y1-y0, z1-z0);
}

void PrintSize(vtkAlgorithm *algorithm, VtkReaderType readerType)
{
    vtkDataSet *dataset = 0;

    algorithm->Update();

    if (readerType == VTK)
    {
        vtkDataSetReader *legacy_reader = static_cast<vtkDataSetReader*>(algorithm);
        
        int err = legacy_reader->OpenVTKFile();
        if (err != 0)
        {
            cerr << "Error " << err << ": Could not read " << legacy_reader->GetFileName() << endl;
            exit(1);
        }

        dataset = legacy_reader->GetOutput();
    }
    else
    {
        vtkXMLReader *xml_reader = static_cast<vtkXMLReader*>(algorithm);

        int err = xml_reader->CanReadFile(xml_reader->GetFileName());
        if (err == 0)
        {
            cerr << "Error " << err << ": Could not read " << xml_reader->GetFileName() << endl;
            exit(2);
        }

        dataset = xml_reader->GetOutputAsDataSet();
    }

    dataset->Update();
    dataset->ComputeBounds();

    int n_points, n_cells;
    int e, emax;
    double bounds[6];
    double h, hmax;

    hmax = 0.0;
{'fraction_non_alphanumeric': 0.18756675923947874, 'fraction_numerical': 0.013245033112582781, 'mean_word_length': 2.6578125, 'pattern_counts': {'":': 2, '<': 75, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6237798', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1546, 'n_words': 341}