Skip to content

Commit e377ffe

Browse files
authored
READER: Implement Aztec .cpr/.crc reader for EBSD data. (#27)
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent c8d33e2 commit e377ffe

23 files changed

+1383
-16
lines changed

CMakePresets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@
128128
"VCPKG_HOST_TRIPLET": {
129129
"type": "STRING",
130130
"value": "arm64-osx-dynamic"
131+
},
132+
"CMAKE_BUILD_TYPE": {
133+
"type": "STRING",
134+
"value": "Debug"
131135
}
132136
},
133137
"environment": {

Source/Apps/ParseAztecProject.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
2+
#include "EbsdLib/IO/HKL/CprReader.h"
3+
#include "EbsdLib/LaueOps/LaueOps.h"
4+
5+
#include <iostream>
6+
7+
namespace detail
8+
{
9+
// const std::string k_CprPath = "/Volumes/OWC_Express_1M2/DREAM3D_Troubleshoot_Data/Benjamin_Layer1/Layer1.cpr";
10+
const std::string k_CprPath = "/Volumes/OWC_Express_1M2/CPR_CRC_Test_Data/dg7kv5mcv3-1/17NZ42_Dauphinetwinnedsample_nearlyuntwinnedgrains.cpr";
11+
12+
} // namespace detail
13+
14+
std::string ConvertLaueGroupToString(int idx)
15+
{
16+
switch(idx)
17+
{
18+
case 0:
19+
return "Hexagonal_High";
20+
case 1:
21+
return "Cubic_High";
22+
case 2:
23+
return "Hexagonal_Low";
24+
case 3:
25+
return "Cubic_Low";
26+
case 4:
27+
return "Triclinic";
28+
case 5:
29+
return "Monoclinic";
30+
case 6:
31+
return "OrthoRhombic";
32+
case 7:
33+
return "Tetragonal_Low";
34+
case 8:
35+
return "Tetragonal_High";
36+
case 9:
37+
return "Trigonal_Low";
38+
case 10:
39+
return "Trigonal_High";
40+
case 11:
41+
return "UnknownCrystalStructure";
42+
}
43+
return "Undefined";
44+
}
45+
46+
// -----------------------------------------------------------------------------
47+
int main(int argc, char* argv[])
48+
{
49+
50+
// if(argc != 3)
51+
// {
52+
// std::cout << "Program .cpr and .crc files as input." << std::endl;
53+
// return 1;
54+
// }
55+
56+
CprReader reader;
57+
reader.setFileName(detail::k_CprPath);
58+
int error = reader.readHeaderOnly();
59+
if(error < 0)
60+
{
61+
std::cout << "Reading Header Failed: " << error << "\n";
62+
return 1;
63+
}
64+
// reader.printHeader(std::cout);
65+
// Write out a compatible DREAM3D "Ensemble" File
66+
auto phases = reader.getPhaseVector();
67+
std::cout << "[EnsembleInfo]\n"
68+
<< "Number_Phases=" << phases.size() << std::endl;
69+
size_t idx = 0;
70+
for(const auto& phase : phases)
71+
{
72+
std::cout << std::endl;
73+
std::cout << "[" << ++idx << "]\n"
74+
<< "CrystalStructure=" << ConvertLaueGroupToString(phase->determineOrientationOpsIndex()) << "\n"
75+
<< "PhaseType=PrimaryPhase\n";
76+
}
77+
78+
error = reader.readFile();
79+
if(error < 0)
80+
{
81+
std::cout << reader.getErrorMessage() << error << "\n";
82+
return 2;
83+
}
84+
85+
// Dump all the data to the command line
86+
// std::cout << "Phase,Bands,Error,Euler1,Euler2,Euler3,MAD,BC,BS\n";
87+
// uint8_t* phasePtr = reader.getPhasePointer();
88+
// uint8_t* bandsPtr = reader.getBandCountPointer();
89+
// uint8_t* errorPtr = reader.getErrorPointer();
90+
// float* phi1Ptr = reader.getEuler1Pointer();
91+
// float* phiPtr = reader.getEuler2Pointer();
92+
// float* phi2Ptr = reader.getEuler3Pointer();
93+
// float* madPtr = reader.getMeanAngularDeviationPointer();
94+
// uint8_t* bcPtr = reader.getBandContrastPointer();
95+
// uint8_t* bsPtr = reader.getBandSlopePointer();
96+
//
97+
// size_t numScanPoints = reader.getNumberOfElements();
98+
// for(size_t i = 0; i < numScanPoints; i++)
99+
// {
100+
// std::cout << static_cast<int>(phasePtr[i]) << "," << static_cast<int>(bandsPtr[i]) << "," << static_cast<int>(errorPtr[i]) << "," << phi1Ptr[i] << "," << phiPtr[i] << "," << phi2Ptr[i] << ","
101+
// << madPtr[i] << "," << static_cast<int>(bcPtr[i]) << "," << static_cast<int>(bsPtr[i]) << std::endl;
102+
// }
103+
104+
return 0;
105+
}

Source/Apps/SourceList.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ target_include_directories(generate_ipf_legends
2626
PRIVATE
2727
"${EbsdLibProj_SOURCE_DIR}/3rdParty/canvas_ity/src")
2828

29+
add_executable(ParseAztecProject ${EbsdLibProj_SOURCE_DIR}/Source/Apps/ParseAztecProject.cpp)
30+
target_link_libraries(ParseAztecProject PUBLIC EbsdLib)
31+
target_include_directories(ParseAztecProject PUBLIC ${EbsdLibProj_SOURCE_DIR}/Source)
32+
2933

3034
if(EbsdLib_INSTALL_FILES)
3135
install(FILES

Source/Apps/make_ipf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class GenerateIPFColorsImpl
4949
std::vector<size_t> laueOpsIndex(m_PhaseInfos.size());
5050
for(size_t i = 0; i < laueOpsIndex.size(); i++)
5151
{
52-
laueOpsIndex[i] = m_PhaseInfos[i]->determineLaueGroup();
52+
laueOpsIndex[i] = m_PhaseInfos[i]->determineOrientationOpsIndex();
5353
}
5454

5555
size_t totalPoints = m_CellEulerAngles.size() / 3;

Source/EbsdLib/IO/AngleFileLoader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
#pragma once
3737

3838
#include <memory>
39-
#include <vector>
40-
4139
#include <string>
40+
#include <vector>
4241

4342
#include "EbsdLib/Core/EbsdDataArray.hpp"
4443
#include "EbsdLib/EbsdLib.h"

Source/EbsdLib/IO/BrukerNano/H5EspritReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader
6565
/**
6666
* @brief Returns the name of the class for H5EspritReader
6767
*/
68-
std::string getNameOfClass() const;
68+
std::string getNameOfClass() const override;
6969
/**
7070
* @brief Returns the name of the class for H5EspritReader
7171
*/

Source/EbsdLib/IO/EbsdReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class EbsdLib_EXPORT EbsdReader
6666
/**
6767
* @brief Returns the name of the class for EbsdReader
6868
*/
69-
std::string getNameOfClass() const;
69+
virtual std::string getNameOfClass() const;
7070
/**
7171
* @brief Returns the name of the class for EbsdReader
7272
*/

0 commit comments

Comments
 (0)