Skip to content
Snippets Groups Projects
Unverified Commit 9d9a615c authored by Simon Heybrock's avatar Simon Heybrock Committed by GitHub
Browse files

Merge pull request #26804 from mantidproject/v20_nexus_geometry_parser_fixes

V20 nexus geometry parser fixes
parents 8f975cf8 f900f905
No related merge requests found
...@@ -155,10 +155,21 @@ private: ...@@ -155,10 +155,21 @@ private:
auto nCharacters = dataType.getSize(); auto nCharacters = dataType.getSize();
std::vector<char> value(nCharacters); std::vector<char> value(nCharacters);
data.read(value.data(), dataType, data.getSpace()); data.read(value.data(), dataType, data.getSpace());
return std::string(value.begin(), value.end()); auto str = std::string(value.begin(), value.end());
str.erase(std::find(str.begin(), str.end(), '\0'), str.end());
return str;
} }
} }
// Provided to support invalid or null-termination character strings
std::string readOrSubsitute(const std::string &dataset, const Group &group,
std::string &substitue) {
auto read = get1DStringDataset(dataset, group);
if (read.empty())
read = substitue;
return read;
}
/** Open subgroups of parent group /** Open subgroups of parent group
* If firstEntryOnly=true, only the first match is returned as a vector of * If firstEntryOnly=true, only the first match is returned as a vector of
* size 1. * size 1.
...@@ -589,7 +600,7 @@ private: ...@@ -589,7 +600,7 @@ private:
Group sourceGroup = utilities::findGroupOrThrow(instrumentGroup, NX_SOURCE); Group sourceGroup = utilities::findGroupOrThrow(instrumentGroup, NX_SOURCE);
std::string sourceName = "Unspecfied"; std::string sourceName = "Unspecfied";
if (utilities::findDataset(sourceGroup, "name")) if (utilities::findDataset(sourceGroup, "name"))
sourceName = get1DStringDataset("name", sourceGroup); sourceName = readOrSubsitute("name", sourceGroup, sourceName);
auto sourceTransformations = getTransformations(file, sourceGroup); auto sourceTransformations = getTransformations(file, sourceGroup);
auto defaultPos = Eigen::Vector3d(0.0, 0.0, 0.0); auto defaultPos = Eigen::Vector3d(0.0, 0.0, 0.0);
builder.addSource(sourceName, sourceTransformations * defaultPos); builder.addSource(sourceName, sourceTransformations * defaultPos);
...@@ -605,7 +616,7 @@ private: ...@@ -605,7 +616,7 @@ private:
sampleTransforms * Eigen::Vector3d(0.0, 0.0, 0.0); sampleTransforms * Eigen::Vector3d(0.0, 0.0, 0.0);
std::string sampleName = "Unspecified"; std::string sampleName = "Unspecified";
if (utilities::findDataset(sampleGroup, "name")) if (utilities::findDataset(sampleGroup, "name"))
sampleName = get1DStringDataset("name", sampleGroup); sampleName = readOrSubsitute("name", sampleGroup, sampleName);
builder.addSample(sampleName, samplePos); builder.addSample(sampleName, samplePos);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment