diff --git a/src/opatIO/private/opatIO.cpp b/src/opatIO/private/opatIO.cpp index bdbf45b..cfc648a 100644 --- a/src/opatIO/private/opatIO.cpp +++ b/src/opatIO/private/opatIO.cpp @@ -171,7 +171,11 @@ void OpatIO::LookupEpsilon() { for (int j = 1; j < static_cast(header.numTables); j++) { epsilon = std::min(epsilon, std::fabs(tableIDToIndex.at(j).at(i) - tableIDToIndex.at(j-1).at(i))); } - indexEpsilon.at(i) = epsilon * 0.1; + if (epsilon < 1e-8) { + indexEpsilon.at(i) = 1e-8; + } else { + indexEpsilon.at(i) = epsilon * 0.1; + } } } diff --git a/tests/meson.build b/tests/meson.build index 0c045fa..6a7379f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -16,4 +16,5 @@ subdir('network') # Subdirectories for sandbox tests subdir('dobj_sandbox') +subdir('opatIO_sandbox') diff --git a/tests/opatIO_sandbox/GS98hz.opat b/tests/opatIO_sandbox/GS98hz.opat new file mode 100644 index 0000000..43e5baf Binary files /dev/null and b/tests/opatIO_sandbox/GS98hz.opat differ diff --git a/tests/opatIO_sandbox/meson.build b/tests/opatIO_sandbox/meson.build new file mode 100644 index 0000000..095c09a --- /dev/null +++ b/tests/opatIO_sandbox/meson.build @@ -0,0 +1 @@ +executable('tryGS98', 'opacity.cpp', dependencies: [opatio_dep]) \ No newline at end of file diff --git a/tests/opatIO_sandbox/opacity.cpp b/tests/opatIO_sandbox/opacity.cpp new file mode 100644 index 0000000..72ddb04 --- /dev/null +++ b/tests/opatIO_sandbox/opacity.cpp @@ -0,0 +1,28 @@ +#include +#include +//#include +#include "opatIO.h" + + +int main() { + + std::string FILENAME = "GS98hz.opat"; + OpatIO opatIO(FILENAME); + Header header = opatIO.getHeader(); + std::cout << header.version << std::endl; + std::cout << header.comment << std::endl; + std::cout << header.numTables << std::endl; + + std::vector tableIndex = opatIO.getTableIndex(); + + //print out the X,Z pairs in the table + for (size_t i=0; i< tableIndex.size()-1; i++){ + std::cout << "Table [" << i << "]: {" << tableIndex[i].index.at(0) << ", " + << tableIndex[i].index.at(1) << "}" << std::endl; + } + + //find the table index corresponding to X=0.1, Z=0.001 + std::vector index = {0.1, 0.001}; + OPATTable tab = opatIO.getTable(index); + +}