Skip to content

Commit

Permalink
READER: Implement Aztec .cpr/.crc reader for EBSD data.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Oct 29, 2024
1 parent c8d33e2 commit 1efb5c6
Show file tree
Hide file tree
Showing 23 changed files with 1,383 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
"VCPKG_HOST_TRIPLET": {
"type": "STRING",
"value": "arm64-osx-dynamic"
},
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Debug"
}
},
"environment": {
Expand Down
105 changes: 105 additions & 0 deletions Source/Apps/ParseAztecProject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

#include "EbsdLib/IO/HKL/CprReader.h"
#include "EbsdLib/LaueOps/LaueOps.h"

#include <iostream>

namespace detail
{
// const std::string k_CprPath = "/Volumes/OWC_Express_1M2/DREAM3D_Troubleshoot_Data/Benjamin_Layer1/Layer1.cpr";
const std::string k_CprPath = "/Volumes/OWC_Express_1M2/CPR_CRC_Test_Data/dg7kv5mcv3-1/17NZ42_Dauphinetwinnedsample_nearlyuntwinnedgrains.cpr";

} // namespace detail

std::string ConvertLaueGroupToString(int idx)
{
switch(idx)
{
case 0:
return "Hexagonal_High";
case 1:
return "Cubic_High";
case 2:
return "Hexagonal_Low";
case 3:
return "Cubic_Low";
case 4:
return "Triclinic";
case 5:
return "Monoclinic";
case 6:
return "OrthoRhombic";
case 7:
return "Tetragonal_Low";
case 8:
return "Tetragonal_High";
case 9:
return "Trigonal_Low";
case 10:
return "Trigonal_High";
case 11:
return "UnknownCrystalStructure";
}
return "Undefined";
}

// -----------------------------------------------------------------------------
int main(int argc, char* argv[])
{

// if(argc != 3)
// {
// std::cout << "Program .cpr and .crc files as input." << std::endl;
// return 1;
// }

CprReader reader;
reader.setFileName(detail::k_CprPath);
int error = reader.readHeaderOnly();
if(error < 0)
{
std::cout << "Reading Header Failed: " << error << "\n";
return 1;
}
// reader.printHeader(std::cout);
// Write out a compatible DREAM3D "Ensemble" File
auto phases = reader.getPhaseVector();
std::cout << "[EnsembleInfo]\n"
<< "Number_Phases=" << phases.size() << std::endl;
size_t idx = 0;
for(const auto& phase : phases)
{
std::cout << std::endl;
std::cout << "[" << ++idx << "]\n"
<< "CrystalStructure=" << ConvertLaueGroupToString(phase->determineOrientationOpsIndex()) << "\n"
<< "PhaseType=PrimaryPhase\n";
}

error = reader.readFile();
if(error < 0)
{
std::cout << reader.getErrorMessage() << error << "\n";
return 2;
}

// Dump all the data to the command line
// std::cout << "Phase,Bands,Error,Euler1,Euler2,Euler3,MAD,BC,BS\n";
// uint8_t* phasePtr = reader.getPhasePointer();
// uint8_t* bandsPtr = reader.getBandCountPointer();
// uint8_t* errorPtr = reader.getErrorPointer();
// float* phi1Ptr = reader.getEuler1Pointer();
// float* phiPtr = reader.getEuler2Pointer();
// float* phi2Ptr = reader.getEuler3Pointer();
// float* madPtr = reader.getMeanAngularDeviationPointer();
// uint8_t* bcPtr = reader.getBandContrastPointer();
// uint8_t* bsPtr = reader.getBandSlopePointer();
//
// size_t numScanPoints = reader.getNumberOfElements();
// for(size_t i = 0; i < numScanPoints; i++)
// {
// std::cout << static_cast<int>(phasePtr[i]) << "," << static_cast<int>(bandsPtr[i]) << "," << static_cast<int>(errorPtr[i]) << "," << phi1Ptr[i] << "," << phiPtr[i] << "," << phi2Ptr[i] << ","
// << madPtr[i] << "," << static_cast<int>(bcPtr[i]) << "," << static_cast<int>(bsPtr[i]) << std::endl;
// }

return 0;
}
4 changes: 4 additions & 0 deletions Source/Apps/SourceList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ target_include_directories(generate_ipf_legends
PRIVATE
"${EbsdLibProj_SOURCE_DIR}/3rdParty/canvas_ity/src")

add_executable(ParseAztecProject ${EbsdLibProj_SOURCE_DIR}/Source/Apps/ParseAztecProject.cpp)
target_link_libraries(ParseAztecProject PUBLIC EbsdLib)
target_include_directories(ParseAztecProject PUBLIC ${EbsdLibProj_SOURCE_DIR}/Source)


if(EbsdLib_INSTALL_FILES)
install(FILES
Expand Down
2 changes: 1 addition & 1 deletion Source/Apps/make_ipf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GenerateIPFColorsImpl
std::vector<size_t> laueOpsIndex(m_PhaseInfos.size());
for(size_t i = 0; i < laueOpsIndex.size(); i++)
{
laueOpsIndex[i] = m_PhaseInfos[i]->determineLaueGroup();
laueOpsIndex[i] = m_PhaseInfos[i]->determineOrientationOpsIndex();
}

size_t totalPoints = m_CellEulerAngles.size() / 3;
Expand Down
3 changes: 1 addition & 2 deletions Source/EbsdLib/IO/AngleFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
#pragma once

#include <memory>
#include <vector>

#include <string>
#include <vector>

#include "EbsdLib/Core/EbsdDataArray.hpp"
#include "EbsdLib/EbsdLib.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/EbsdLib/IO/BrukerNano/H5EspritReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader
/**
* @brief Returns the name of the class for H5EspritReader
*/
std::string getNameOfClass() const;
std::string getNameOfClass() const override;
/**
* @brief Returns the name of the class for H5EspritReader
*/
Expand Down
2 changes: 1 addition & 1 deletion Source/EbsdLib/IO/EbsdReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EbsdLib_EXPORT EbsdReader
/**
* @brief Returns the name of the class for EbsdReader
*/
std::string getNameOfClass() const;
virtual std::string getNameOfClass() const;
/**
* @brief Returns the name of the class for EbsdReader
*/
Expand Down
Loading

0 comments on commit 1efb5c6

Please sign in to comment.