@@ -81,6 +81,13 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader
81
81
auto & imageGeom = m_DataStructure.getDataRefAs <ImageGeom>(DataPath ({currentScanName}));
82
82
imageGeom.setUnits (IGeometry::LengthUnit::Micrometer);
83
83
copyDataResults = copyRawEbsdData (currentScanName);
84
+
85
+ if (copyDataResults.invalid ())
86
+ {
87
+ return copyDataResults;
88
+ }
89
+
90
+ copyDataResults = updateOrigin (currentScanName);
84
91
}
85
92
86
93
if (copyDataResults.invalid ())
@@ -123,10 +130,11 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader
123
130
}
124
131
125
132
// These arrays are purposely created using the AngFile constant names for BOTH the Oim and the Esprit readers!
126
- auto & crystalStructures = m_DataStructure.getDataRefAs <UInt32Array>(imagePath.createChildPath (m_InputValues->CellEnsembleAttributeMatrixName ).createChildPath (EbsdLib::AngFile::CrystalStructures));
127
- auto & materialNames = m_DataStructure.getDataRefAs <StringArray>(imagePath.createChildPath (m_InputValues->CellEnsembleAttributeMatrixName ).createChildPath (EbsdLib::AngFile::MaterialName));
133
+ const DataPath cellEnsembleAM = imagePath.createChildPath (m_InputValues->CellEnsembleAttributeMatrixName );
134
+ auto & crystalStructures = m_DataStructure.getDataRefAs <UInt32Array>(cellEnsembleAM.createChildPath (EbsdLib::AngFile::CrystalStructures));
135
+ auto & materialNames = m_DataStructure.getDataRefAs <StringArray>(cellEnsembleAM.createChildPath (EbsdLib::AngFile::MaterialName));
128
136
auto & latticeConstantsArray =
129
- m_DataStructure.getDataRefAs <Float32Array>(imagePath. createChildPath (m_InputValues-> CellEnsembleAttributeMatrixName ) .createChildPath (EbsdLib::AngFile::LatticeConstants));
137
+ m_DataStructure.getDataRefAs <Float32Array>(cellEnsembleAM .createChildPath (EbsdLib::AngFile::LatticeConstants));
130
138
Float32Array::store_type* latticeConstants = latticeConstantsArray.getDataStore ();
131
139
132
140
crystalStructures[0 ] = EbsdLib::CrystalStructure::UnknownCrystalStructure;
@@ -157,6 +165,23 @@ class ORIENTATIONANALYSIS_EXPORT IEbsdOemReader
157
165
158
166
virtual Result<> copyRawEbsdData (int index) = 0;
159
167
virtual Result<> copyRawEbsdData (const std::string& scanName) = 0;
168
+ virtual Result<> updateOrigin (const std::string& scanName)
169
+ {
170
+ const DataPath imagePath ({scanName});
171
+
172
+ auto & imageGeom = m_DataStructure.getDataRefAs <ImageGeom>(imagePath);
173
+ const usize totalCells = imageGeom.getNumberOfCells ();
174
+
175
+ const auto * xPos = reinterpret_cast <float32*>(m_Reader->getPointerByName (EbsdLib::Ang::XPosition));
176
+ const auto * yPos = reinterpret_cast <float32*>(m_Reader->getPointerByName (EbsdLib::Ang::YPosition));
177
+
178
+ float32 minX = *std::min_element (xPos, xPos + totalCells);
179
+ float32 minY = *std::min_element (yPos, yPos + totalCells);
180
+
181
+ imageGeom.setOrigin (minX, minY, 0 .0f );
182
+
183
+ return {};
184
+ }
160
185
161
186
protected:
162
187
std::shared_ptr<T> m_Reader;
0 commit comments