<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkVTKTetrahedralMeshReader.hxx,v $
  Language:  C++
  Date:      $Date: 2011-10-05 18:01:00 $
  Version:   $Revision: 1.19 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or https://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef itkVTKTetrahedralMeshReader_hxx
#define itkVTKTetrahedralMeshReader_hxx

#include "itkVTKTetrahedralMeshReader.h"
#include <fstream>
#include <cstdio>
#include <cstring>

namespace itk
{

//
// Constructor
//
template <typename TOutputMesh>
VTKTetrahedralMeshReader<TOutputMesh>::VTKTetrahedralMeshReader()
{
  //
  // Create the output
  //
  typename TOutputMesh::Pointer output = TOutputMesh::New();
  this->ProcessObject::SetNumberOfRequiredOutputs(1);
  this->ProcessObject::SetNthOutput(0, output.GetPointer());
}

//
// Destructor
//
template <typename TOutputMesh>
VTKTetrahedralMeshReader<TOutputMesh>::~VTKTetrahedralMeshReader()
{}

template <typename TOutputMesh>
void
VTKTetrahedralMeshReader<TOutputMesh>::GenerateData()
{
  OutputMeshType * outputMesh = this->GetOutput();

  outputMesh->SetCellsAllocationMethod(OutputMeshType::CellsAllocatedDynamicallyCellByCell);

  if (m_FileName == "")
  {
    itkExceptionMacro(<< "No input FileName");
  }

  //
  // Read input file
  //
  std::ifstream inputFile(m_FileName.c_str());

  if (!inputFile.is_open())
  {
    itkExceptionMacro(<< "Unable to open file\n"
                      << "inputFilename= " << m_FileName);
  }

  inputFile.imbue(std::locale::classic());
  std::string line;

  // The first line must be "# vtk DataFile Version x.x" where x.x can
  // vary
  std::getline(inputFile, m_Version, '\n');
  if (inputFile.fail())
  {
    itkExceptionMacro(<< "Error reading file: " << m_FileName << "\nUnexpected end-of-file trying to read first line.");
  }

  if (m_Version.find("# vtk DataFile Version ") == std::string::npos)
  {<commit_msg>COMP: update VTKTetrahedralMeshReader to enum class<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkVTKTetrahedralMeshReader.hxx,v $
  Language:  C++
  Date:      $Date: 2011-10-05 18:01:00 $
  Version:   $Revision: 1.19 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or https://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef itkVTKTetrahedralMeshReader_hxx
#define itkVTKTetrahedralMeshReader_hxx

#include "itkVTKTetrahedralMeshReader.h"
#include <fstream>
#include <cstdio>
#include <cstring>

namespace itk
{

//
// Constructor
//
template <typename TOutputMesh>
VTKTetrahedralMeshReader<TOutputMesh>::VTKTetrahedralMeshReader()
{
  //
  // Create the output
  //
  typename TOutputMesh::Pointer output = TOutputMesh::New();
  this->ProcessObject::SetNumberOfRequiredOutputs(1);
  this->ProcessObject::SetNthOutput(0, output.GetPointer());
}

//
// Destructor
//
template <typename TOutputMesh>
VTKTetrahedralMeshReader<TOutputMesh>::~VTKTetrahedralMeshReader()
{}

template <typename TOutputMesh>
void
VTKTetrahedralMeshReader<TOutputMesh>::GenerateData()
{
  OutputMeshType * outputMesh = this->GetOutput();

  outputMesh->SetCellsAllocationMethod(MeshClassCellsAllocationMethodType::CellsAllocatedDynamicallyCellByCell);

  if (m_FileName == "")
  {
    itkExceptionMacro(<< "No input FileName");
  }

  //
  // Read input file
  //
  std::ifstream inputFile(m_FileName.c_str());

  if (!inputFile.is_open())
  {
    itkExceptionMacro(<< "Unable to open file\n"
                      << "inputFilename= " << m_FileName);
  }

  inputFile.imbue(std::locale::classic());
  std::string line;

  // The first line must be "# vtk DataFile Version x.x" where x.x can
  // vary
  std::getline(inputFile, m_Version, '\n');
  if (inputFile.fail())
  {
    itkExceptionMacro(<< "Error reading file: " << m_FileName << "\nUnexpected end-of-file trying to read first line.");
  }

  if (m_Version.find("# vtk DataFile Version ") == std::string::npos)
  {
{'fraction_non_alphanumeric': 0.17722315436241612, 'fraction_numerical': 0.007969798657718121, 'mean_word_length': 4.623820754716981, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, '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': '2274468', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1419, 'n_words': 329}