Skip to content
Snippets Groups Projects
ParseInputFile.h 961 B
Newer Older
samuel.hayden's avatar
samuel.hayden committed
#pragma once
#include <fstream>
#include <vector>

#include "ErrorCodes.h"
#include "gp_Pnt.hxx"
samuel.hayden's avatar
samuel.hayden committed

class ParseInputFile
{
private:
	friend class DetermineLatticeType;
samuel.hayden's avatar
samuel.hayden committed

	bool _hasCells;		// Cells line defined
	bool _hasRadii;		// nRadii > 0
	bool _hasCellSize;	// Cell size given
	bool _hasPositions;	// Cell positions defined
	bool _hasCellType;	// Cell type defined
samuel.hayden's avatar
samuel.hayden committed

	/* Parsed Data */
	std::string _cellType;			// Type of unit cell
	size_t _nx, _ny, _nz;			// nCells
	double _cx, _cy, _cz;			// cell size
	std::vector<double> _radii;		// Cell radii
	std::vector<gp_Pnt> _points;	// Cell positions
samuel.hayden's avatar
samuel.hayden committed

private:
	std::vector<ErrorCodes> _errors;
samuel.hayden's avatar
samuel.hayden committed

	bool parseFile(const std::string filepath);
	void parseRadii(std::fstream& file, size_t nCells);
	void parsePositions(std::fstream& file, size_t nPositions);
samuel.hayden's avatar
samuel.hayden committed

public:
	ParseInputFile(const ParseCommandLine& cmdln);
samuel.hayden's avatar
samuel.hayden committed

	bool hasErrors() { return _errors.size() > 0; }
	void dumpErrors();
samuel.hayden's avatar
samuel.hayden committed
};