47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#include "common.h"
|
|
|
|
#include <kisstype/spectra.h>
|
|
#include <eisgenerator/translators.h>
|
|
#include <iostream>
|
|
|
|
bool saveData(const std::string& exportName, const ModelData& data, const std::filesystem::path& outDir, const std::filesystem::path& originFile)
|
|
{
|
|
std::filesystem::path filename;
|
|
std::string modelStrWithoutParams = data.modelStr;
|
|
eis::purgeEisParamBrackets(modelStrWithoutParams);
|
|
size_t classIndex = 0;
|
|
|
|
do
|
|
{
|
|
filename.assign(exportName);
|
|
filename.concat("_");
|
|
filename.concat(modelStrWithoutParams);
|
|
filename.concat("_");
|
|
filename.concat(std::to_string(classIndex));
|
|
filename.concat(".csv");
|
|
++classIndex;
|
|
} while(std::filesystem::exists(outDir/filename));
|
|
|
|
try
|
|
{
|
|
eis::Spectra(data.data, data.modelStr, data.id + ", \"" + originFile.filename().string() + "\"").saveToDisk(outDir/filename);
|
|
return true;
|
|
}
|
|
catch(...)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool checkDir(const std::filesystem::path& outDir)
|
|
{
|
|
if(!std::filesystem::is_directory(outDir))
|
|
{
|
|
if(!std::filesystem::create_directory(outDir))
|
|
{
|
|
std::cerr<<outDir<<" dose not exist and can not be created\n";
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|