<commit_before>/*=========================================================================
               
  Program:   Insight Segmentation & Registration Toolkit
  Module:    FEMBrainStripValidationApp.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://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.

=========================================================================*/
// disable debug warnings in MS compiler 
#ifdef _MSC_VER 
#pragma warning(disable: 4786)
#endif

#include <iostream>
#include <fstream>
#include <stdio.h>
#include "FEMBrainStripValidationApp.h"
#include "itkImage.h"
#include "itkExceptionObject.h"       

// to use:  FEMBrainStripValidationApp U:\itk\Insight\Applications\IBSRValidation\FEMAtlasSegmentation\Inputs\input_1.txt 
typedef itk::Image<unsigned char,3> ImageType;
typedef itk::Image<unsigned char, 3> LabelImageType;
typedef itk::Image<float, 3> RealImageType;

typedef itk::fem::Element3DC0LinearHexahedronMembrane   ElementType;
typedef itk::fem::Element3DC0LinearTetrahedronMembrane   ElementType2;

typedef itk::fem::ImageMetricLoad<RealImageType,RealImageType>     ImageLoadType;
template class itk::fem::ImageMetricLoadImplementation<ImageLoadType>;
typedef ElementType::LoadImplementationFunctionPointer     LoadImpFP;
typedef ElementType::LoadType                              ElementLoadType;
typedef itk::fem::VisitorDispatcher<ElementType,ElementLoadType, LoadImpFP>   
                                                          DispatcherType;
typedef itk::fem::VisitorDispatcher<ElementType2,ElementLoadType, LoadImpFP>   
                                                          DispatcherType2;


typedef itk::FEMBrainStripValidationApp<ImageType,LabelImageType,RealImageType> AppType;

int main(int argc, char *argv[])
{
  char* paramname;
  if ( argc < 2 )
    {
    std::cout << "Parameter file name missing" << std::endl;
    std::cout << std::endl;
    std::cout << "Usage:  FEMBrainStripValidationApp param.file" << std::endl;
    paramname="U:\\itk\\Insight\\Applications\\IBSRValidation\\FEMAtlasSegmentation\\Inputs\\myinput_resample.txt";
//    return 1;
    } else paramname=argv[1];

  // registering the load for both hexahedron and tetrahedron elements   
  DispatcherType::RegisterVisitor((ImageLoadType*)0, 
          &(itk::fem::ImageMetricLoadImplementation<ImageLoadType>::ImplementImageMetricLoad));
  DispatcherType2::RegisterVisitor((ImageLoadType*)0, 
          &(itk::fem::ImageMetricLoadImplementation<ImageLoadType>::ImplementImageMetricLoad));

  // registering the load for both hexahedron and tetrahedron elements
  
  LoadImpFP fp = &itk::fem::ImageMetricLoadImplementation<ImageLoadType>::ImplementImageMetricLoad;
  DispatcherType::RegisterVisitor((ImageLoadType*)0, fp);
  DispatcherType2::RegisterVisitor((ImageLoadType*)0, fp);


  AppType::Pointer app = AppType::New();


  // Parse the input file and set up the app
  std::ifstream inputStream( paramname, std::ios::in );

  if ( !inputStream.is_open() )
    {
    std::cout << "Can't open parameter file: " << argv[1] << std::endl;
    return -1;
    }

  const unsigned int maxChar = 512;
  char lineBuffer[maxChar];
  char buffer[maxChar];

  // get the IBSR "20Normal_T1" directory name
  inputStream.getline( lineBuffer, maxChar, '\n' );
  
  if ( sscanf( lineBuffer, "%s", buffer ) != 1 )
    {
    std::cout << "Can't find image directory name." << std::endl;
    return -1;<commit_msg>ERR: removed duplication of RegisterVisitor.<commit_after>/*=========================================================================
               
  Program:   Insight Segmentation & Registration Toolkit
  Module:    FEMBrainStripValidationApp.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://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.

=========================================================================*/
// disable debug warnings in MS compiler 
#ifdef _MSC_VER 
#pragma warning(disable: 4786)
#endif

#include <iostream>
#include <fstream>
#include <stdio.h>
#include "FEMBrainStripValidationApp.h"
#include "itkImage.h"
#include "itkExceptionObject.h"       

// to use:  FEMBrainStripValidationApp U:\itk\Insight\Applications\IBSRValidation\FEMAtlasSegmentation\Inputs\input_1.txt 
typedef itk::Image<unsigned char,3> ImageType;
typedef itk::Image<unsigned char, 3> LabelImageType;
typedef itk::Image<float, 3> RealImageType;

typedef itk::fem::Element3DC0LinearHexahedronMembrane   ElementType;
typedef itk::fem::Element3DC0LinearTetrahedronMembrane   ElementType2;

typedef itk::fem::ImageMetricLoad<RealImageType,RealImageType>     ImageLoadType;
template class itk::fem::ImageMetricLoadImplementation<ImageLoadType>;
typedef ElementType::LoadImplementationFunctionPointer     LoadImpFP;
typedef ElementType::LoadType                              ElementLoadType;
typedef itk::fem::VisitorDispatcher<ElementType,ElementLoadType, LoadImpFP>   
                                                          DispatcherType;
typedef itk::fem::VisitorDispatcher<ElementType2,ElementLoadType, LoadImpFP>   
                                                          DispatcherType2;


typedef itk::FEMBrainStripValidationApp<ImageType,LabelImageType,RealImageType> AppType;

int main(int argc, char *argv[])
{
  char* paramname;
  if ( argc < 2 )
    {
    std::cout << "Parameter file name missing" << std::endl;
    std::cout << std::endl;
    std::cout << "Usage:  FEMBrainStripValidationApp param.file" << std::endl;
    paramname="U:\\itk\\Insight\\Applications\\IBSRValidation\\FEMAtlasSegmentation\\Inputs\\myinput_resample.txt";
//    return 1;
    } else paramname=argv[1];

  // registering the load for both hexahedron and tetrahedron elements
  
  LoadImpFP fp = &itk::fem::ImageMetricLoadImplementation<ImageLoadType>::ImplementImageMetricLoad;
  DispatcherType::RegisterVisitor((ImageLoadType*)0, fp);
  DispatcherType2::RegisterVisitor((ImageLoadType*)0, fp);


  AppType::Pointer app = AppType::New();


  // Parse the input file and set up the app
  std::ifstream inputStream( paramname, std::ios::in );

  if ( !inputStream.is_open() )
    {
    std::cout << "Can't open parameter file: " << argv[1] << std::endl;
    return -1;
    }

  const unsigned int maxChar = 512;
  char lineBuffer[maxChar];
  char buffer[maxChar];

  // get the IBSR "20Normal_T1" directory name
  inputStream.getline( lineBuffer, maxChar, '\n' );
  
  if ( sscanf( lineBuffer, "%s", buffer ) != 1 )
    {
    std::cout << "Can't find image directory name." << std::endl;
    return -1;
{'fraction_non_alphanumeric': 0.14470932664157257, 'fraction_numerical': 0.010177052837027743, 'mean_word_length': 4.087943262411348, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6988826', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2030, 'n_words': 478}