Skip to content

Commit c61a730

Browse files
authored
BUG: Fix crashing issue with string constants. Add CPR/CRC Binary EBSD Reader (#28)
* VERSION: Update to 1.0.34 * BUG: Fix crashing due to use of std::string as a constant in headers. (#26) * COMP: Add missing #include directive for tbb task_group * READER: Implement Aztec .cpr/.crc reader for EBSD data. (#27) * Fix Xcode 16 crash on start up. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net> --------- Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent ce9a0fd commit c61a730

38 files changed

+1669
-37
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1515
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1616

1717
# set project's name
18-
project(EbsdLibProj VERSION 1.0.33)
18+
project(EbsdLibProj VERSION 1.0.34)
1919

2020
# ---------- Setup output Directories -------------------------
2121
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY

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: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 = "/Users/Shared/Data/CPR_CRC_Test_Data/dg7kv5mcv3-1/dg7kv5mcv3-1/17NZ41B_untwinnedquartzsample.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+
std::cout << "\n\nField Names\n";
79+
auto fieldParsers = reader.createFieldParsers(detail::k_CprPath);
80+
for(const auto& parser : fieldParsers)
81+
{
82+
std::cout << parser.FieldDefinition.FieldName << "\n";
83+
}
84+
85+
error = reader.readFile();
86+
if(error < 0)
87+
{
88+
std::cout << reader.getErrorMessage() << error << "\n";
89+
return 2;
90+
}
91+
92+
// Dump all the data to the command line
93+
// std::cout << "Phase,Bands,Error,Euler1,Euler2,Euler3,MAD,BC,BS\n";
94+
// uint8_t* phasePtr = reader.getPhasePointer();
95+
// uint8_t* bandsPtr = reader.getBandCountPointer();
96+
// uint8_t* errorPtr = reader.getErrorPointer();
97+
// float* phi1Ptr = reader.getEuler1Pointer();
98+
// float* phiPtr = reader.getEuler2Pointer();
99+
// float* phi2Ptr = reader.getEuler3Pointer();
100+
// float* madPtr = reader.getMeanAngularDeviationPointer();
101+
// uint8_t* bcPtr = reader.getBandContrastPointer();
102+
// uint8_t* bsPtr = reader.getBandSlopePointer();
103+
//
104+
// size_t numScanPoints = reader.getNumberOfElements();
105+
// for(size_t i = 0; i < numScanPoints; i++)
106+
// {
107+
// std::cout << static_cast<int>(phasePtr[i]) << "," << static_cast<int>(bandsPtr[i]) << "," << static_cast<int>(errorPtr[i]) << "," << phi1Ptr[i] << "," << phiPtr[i] << "," << phi2Ptr[i] << ","
108+
// << madPtr[i] << "," << static_cast<int>(bcPtr[i]) << "," << static_cast<int>(bsPtr[i]) << std::endl;
109+
// }
110+
111+
return 0;
112+
}

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: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,6 @@ inline const std::string GBCD("GBCD");
7272

7373
namespace NumericTypes
7474
{
75-
namespace Names
76-
{
77-
inline const std::string Int8("signed int 8 bit");
78-
inline const std::string UInt8("unsigned int 8 bit");
79-
inline const std::string Int16("signed int 16 bit");
80-
inline const std::string UInt16("unsigned int 16 bit");
81-
inline const std::string Int32("signed int 32 bit");
82-
inline const std::string UInt32("unsigned int 32 bit");
83-
inline const std::string Int64("signed int 64 bit");
84-
inline const std::string UInt64("unsigned int 64 bit");
85-
inline const std::string Float("Float 32 bit");
86-
inline const std::string Double("Double 64 bit");
87-
inline const std::string Bool("Bool");
88-
inline const std::string SizeT("size_t");
89-
} // namespace Names
9075

9176
enum class Type : int32_t
9277
{
@@ -105,9 +90,6 @@ enum class Type : int32_t
10590
UnknownNumType
10691
};
10792

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

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

0 commit comments

Comments
 (0)