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

Library   : Image Registration Toolkit (IRTK)
Module    : $Id$
Copyright : Imperial College, Department of Computing
Visual Information Processing (VIP), 2009 onwards
Date      : $Date$
Version   : $Revision$
Changes   : $Author$

=========================================================================*/

#include <irtkImage.h>
#include <irtkImageFunction.h>

#ifdef HAS_VTK



char *input_name = NULL, *output_name = NULL;

void usage(){
	cerr << "Usage: vtk2txt [input] [output] " << endl;
	exit(1);
}

int main(int argc, char **argv)
{
    int i;
    double point[3];

	if (argc < 3) {
		usage();
	}

	// Parse filenames
	input_name = argv[1];
	argv++;
	argc--;
	output_name = argv[1];
	argv++;
	argc--;

	// Read model
	vtkPolyDataReader *reader = vtkPolyDataReader::New();
	reader->SetFileName(input_name);
	reader->Modified();
	reader->Update();
	vtkPolyData *model = vtkPolyData::New();
	model = reader->GetOutput();
	model->Update();

    ofstream fout(output_name,ios::app);

    for (i = 0; i < model->GetNumberOfPoints(); i++) {
        model->GetPoints()->GetPoint (i, point);

        fout << point[0] << " " << point[1] << " " << point[2] << endl;
    }

    fout.close();
		
}

#else

#include <irtkImage.h>

int main( int argc, char *argv[] )
{
	cerr << argv[0] << " this program needs to be compiled with vtk enabled." << endl;
	return 0;
}

#endif<commit_msg>added scalar<commit_after>/*=========================================================================

Library   : Image Registration Toolkit (IRTK)
Module    : $Id$
Copyright : Imperial College, Department of Computing
Visual Information Processing (VIP), 2009 onwards
Date      : $Date$
Version   : $Revision$
Changes   : $Author$

=========================================================================*/

#include <irtkImage.h>
#include <irtkImageFunction.h>

#ifdef HAS_VTK



char *input_name = NULL, *output_name = NULL;

void usage(){
	cerr << "Usage: vtk2txt [input] [output] " << endl;
	exit(1);
}

int main(int argc, char **argv)
{
	int i;
	double point[3];

	if (argc < 3) {
		usage();
	}

	// Parse filenames
	input_name = argv[1];
	argv++;
	argc--;
	output_name = argv[1];
	argv++;
	argc--;

	// Read model
	vtkPolyDataReader *reader = vtkPolyDataReader::New();
	reader->SetFileName(input_name);
	reader->Modified();
	reader->Update();
	vtkPolyData *model = vtkPolyData::New();
	model = reader->GetOutput();
	model->Update();

	// Read scalar if there's scalar
	vtkDoubleArray *array = NULL;
	if(model->GetPointData()->HasArray("DistanceProfile")){
		array = (vtkDoubleArray *)model->GetPointData()->GetArray("DistanceProfile");
	}else if(model->GetPointData()->HasArray("WallThickness")){
		array = (vtkDoubleArray *)model->GetPointData()->GetArray("WallThickness");
	}
	ofstream fout(output_name,ios::app);

	for (i = 0; i < model->GetNumberOfPoints(); i++) {
		model->GetPoints()->GetPoint (i, point);

		fout << point[0] << " " << point[1] << " " << point[2];
		// if there is scalar output scalar
		if(array != NULL){
			fout  << " " << *array->GetTuple(i);
		}
		fout << endl;
	}

	fout.close();

}

#else

#include <irtkImage.h>

int main( int argc, char *argv[] )
{
	cerr << argv[0] << " this program needs to be compiled with vtk enabled." << endl;
	return 0;
}

#endif
{'fraction_non_alphanumeric': 0.2474747474747475, 'fraction_numerical': 0.009506833036244802, 'mean_word_length': 4.361464968152866, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2813710', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1105, 'n_words': 276}