Skip to content

Commit 3fc5c63

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

28 files changed

+1409
-29
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/Core/EbsdLibConstants.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
#include "EbsdLib/Core/StringLiteral.hpp"
4242

43-
4443
/**
4544
* @file EbsdConstants.h
4645
* @brief This file contains many constants that are generic to the EBSD library
@@ -108,9 +107,10 @@ enum class Type : int32_t
108107
UnknownNumType
109108
};
110109

111-
inline std::string SupportedTypeList(NumericTypes::Names::Int8.str() + ", " + NumericTypes::Names::UInt8.str() + ", " + NumericTypes::Names::Int16.str() + ", " + NumericTypes::Names::UInt16.str() + ", " +
112-
NumericTypes::Names::Int32.str() + ", " + NumericTypes::Names::UInt32.str() + ", " + NumericTypes::Names::Int64.str() + ", " + NumericTypes::Names::UInt64.str() + ", " +
113-
NumericTypes::Names::Float.str() + ", " + NumericTypes::Names::Double.str() + ", " + NumericTypes::Names::Bool.str() + ", " + NumericTypes::Names::SizeT.str() );
110+
inline std::string SupportedTypeList(NumericTypes::Names::Int8.str() + ", " + NumericTypes::Names::UInt8.str() + ", " + NumericTypes::Names::Int16.str() + ", " + NumericTypes::Names::UInt16.str() +
111+
", " + NumericTypes::Names::Int32.str() + ", " + NumericTypes::Names::UInt32.str() + ", " + NumericTypes::Names::Int64.str() + ", " +
112+
NumericTypes::Names::UInt64.str() + ", " + NumericTypes::Names::Float.str() + ", " + NumericTypes::Names::Double.str() + ", " + NumericTypes::Names::Bool.str() +
113+
", " + NumericTypes::Names::SizeT.str());
114114
} // namespace NumericTypes
115115

116116
/** @brief RefFrameZDir defined for the Stacking order of images into a 3D Volume */
@@ -295,4 +295,3 @@ inline constexpr double BP[6] = {0.0, 1.0, 0.5773502691896260, 0.414213562373095
295295
namespace LPs = LambertParametersType;
296296

297297
} // namespace EbsdLib
298-

Source/EbsdLib/Core/StringLiteral.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
43
#include <stdexcept>
54
#include <string>
65
#include <string_view>
@@ -209,7 +208,7 @@ using StringLiteral = BasicStringLiteral<char>;
209208
using WStringLiteral = BasicStringLiteral<wchar_t>;
210209
using String16Literal = BasicStringLiteral<char16_t>;
211210
using String32Literal = BasicStringLiteral<char32_t>;
212-
} // namespace nx::core
211+
} // namespace EbsdLib
213212

214213
#if 0
215214
template <class CharT>

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/EspritPhase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ std::string EspritPhase::getMaterialName()
5858
// -----------------------------------------------------------------------------
5959
//
6060
// -----------------------------------------------------------------------------
61-
unsigned int EspritPhase::determineLaueGroup()
61+
unsigned int EspritPhase::determineOrientationOpsIndex()
6262
{
6363
int sg = getIT();
6464

Source/EbsdLib/IO/BrukerNano/EspritPhase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class EbsdLib_EXPORT EspritPhase
109109
/**
110110
* @brief Returns the type of crystal structure for this phase.
111111
*/
112-
unsigned int determineLaueGroup();
112+
unsigned int determineOrientationOpsIndex();
113113

114114
protected:
115115
EspritPhase();

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
*/

0 commit comments

Comments
 (0)