Skip to content

Commit

Permalink
READER: Implement Aztec .cpr/.crc reader for EBSD data. (#27)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Oct 30, 2024
1 parent c8d33e2 commit 358e3ec
Show file tree
Hide file tree
Showing 28 changed files with 1,426 additions and 29 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
112 changes: 112 additions & 0 deletions Source/Apps/ParseAztecProject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

#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 = "/Users/Shared/Data/CPR_CRC_Test_Data/dg7kv5mcv3-1/dg7kv5mcv3-1/17NZ41B_untwinnedquartzsample.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";
}

std::cout << "\n\nField Names\n";
auto fieldParsers = reader.createFieldParsers(detail::k_CprPath);
for(const auto& parser : fieldParsers)
{
std::cout << parser.FieldDefinition.FieldName << "\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
9 changes: 4 additions & 5 deletions Source/EbsdLib/Core/EbsdLibConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include "EbsdLib/Core/StringLiteral.hpp"


/**
* @file EbsdConstants.h
* @brief This file contains many constants that are generic to the EBSD library
Expand Down Expand Up @@ -108,9 +107,10 @@ enum class Type : int32_t
UnknownNumType
};

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

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

} // namespace EbsdLib

3 changes: 1 addition & 2 deletions Source/EbsdLib/Core/StringLiteral.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once


#include <stdexcept>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -209,7 +208,7 @@ using StringLiteral = BasicStringLiteral<char>;
using WStringLiteral = BasicStringLiteral<wchar_t>;
using String16Literal = BasicStringLiteral<char16_t>;
using String32Literal = BasicStringLiteral<char32_t>;
} // namespace nx::core
} // namespace EbsdLib

#if 0
template <class CharT>
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/EspritPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::string EspritPhase::getMaterialName()
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
unsigned int EspritPhase::determineLaueGroup()
unsigned int EspritPhase::determineOrientationOpsIndex()
{
int sg = getIT();

Expand Down
2 changes: 1 addition & 1 deletion Source/EbsdLib/IO/BrukerNano/EspritPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EbsdLib_EXPORT EspritPhase
/**
* @brief Returns the type of crystal structure for this phase.
*/
unsigned int determineLaueGroup();
unsigned int determineOrientationOpsIndex();

protected:
EspritPhase();
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
8 changes: 4 additions & 4 deletions Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

#define EBSD_VOLREADER_READ_HEADER(fileId, path, var) \
err = H5Lite::readScalarDataset(fileId, path.c_str(), var); \
err = H5Lite::readScalarDataset(fileId, path.c_str(), var); \
if(err < 0) \
{ \
std::cout << "H5EbsdVolumeInfo Error: Could not load header value for " << path.str(); \
std::cout << "H5EbsdVolumeInfo Error: Could not load header value for " << path.str(); \
err = H5Utilities::closeFile(fileId); \
return err; \
}

#define EBSD_VOLREADER_READ_VECTOR3_HEADER(fileId, path, var, type) \
{ \
err = H5Lite::readPointerDataset(fileId, path.c_str(), var.data()); \
err = H5Lite::readPointerDataset(fileId, path.c_str(), var.data()); \
if(err < 0) \
{ \
std::cout << "H5EbsdVolumeInfo Error: Could not load header (as vector) for " << path.str(); \
std::cout << "H5EbsdVolumeInfo Error: Could not load header (as vector) for " << path.str(); \
err = H5Utilities::closeFile(fileId); \
return err; \
} \
Expand Down
Loading

0 comments on commit 358e3ec

Please sign in to comment.