Skip to content

BUG: Fix crashing issue with string constants. Add CPR/CRC Binary EBSD Reader #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# set project's name
project(EbsdLibProj VERSION 1.0.33)
project(EbsdLibProj VERSION 1.0.34)

# ---------- Setup output Directories -------------------------
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
Expand Down
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
18 changes: 0 additions & 18 deletions Source/EbsdLib/Core/EbsdLibConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,6 @@ inline const std::string GBCD("GBCD");

namespace NumericTypes
{
namespace Names
{
inline const std::string Int8("signed int 8 bit");
inline const std::string UInt8("unsigned int 8 bit");
inline const std::string Int16("signed int 16 bit");
inline const std::string UInt16("unsigned int 16 bit");
inline const std::string Int32("signed int 32 bit");
inline const std::string UInt32("unsigned int 32 bit");
inline const std::string Int64("signed int 64 bit");
inline const std::string UInt64("unsigned int 64 bit");
inline const std::string Float("Float 32 bit");
inline const std::string Double("Double 64 bit");
inline const std::string Bool("Bool");
inline const std::string SizeT("size_t");
} // namespace Names

enum class Type : int32_t
{
Expand All @@ -105,9 +90,6 @@ enum class Type : int32_t
UnknownNumType
};

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

/** @brief RefFrameZDir defined for the Stacking order of images into a 3D Volume */
Expand Down
Loading
Loading