From 9cae327de38c5c5a9936083ef2da50569d154a6e Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 11 Nov 2025 10:34:42 -0500 Subject: [PATCH 1/2] ENH: Rewrite Orientation Class to make it easier to convert between representations --- CMakeLists.txt | 2 +- README.md | 4 +- Source/Apps/gen_sym_code.cpp | 12 +- Source/Apps/rotconvert.cpp | 719 +---------- Source/EbsdLib/Core/EbsdStringLiteral.hpp | 6 +- Source/EbsdLib/Core/Orientation.hpp | 4 + .../EbsdLib/Core/OrientationRepresentation.h | 48 - .../Core/OrientationRepresentation.hpp | 474 +++++++ .../Core/OrientationTransformation.hpp | 66 +- Source/EbsdLib/Core/Quaternion.hpp | 7 +- Source/EbsdLib/Core/SourceList.cmake | 2 +- Source/EbsdLib/IO/AngleFileLoader.cpp | 20 +- Source/EbsdLib/LaueOps/CubicLowOps.cpp | 58 +- Source/EbsdLib/LaueOps/CubicLowOps.h | 20 +- Source/EbsdLib/LaueOps/CubicOps.cpp | 89 +- Source/EbsdLib/LaueOps/CubicOps.h | 22 +- Source/EbsdLib/LaueOps/HexagonalLowOps.cpp | 64 +- Source/EbsdLib/LaueOps/HexagonalLowOps.h | 20 +- Source/EbsdLib/LaueOps/HexagonalOps.cpp | 56 +- Source/EbsdLib/LaueOps/HexagonalOps.h | 20 +- Source/EbsdLib/LaueOps/LaueOps.cpp | 47 +- Source/EbsdLib/LaueOps/LaueOps.h | 40 +- Source/EbsdLib/LaueOps/MonoclinicOps.cpp | 56 +- Source/EbsdLib/LaueOps/MonoclinicOps.h | 20 +- Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp | 57 +- Source/EbsdLib/LaueOps/OrthoRhombicOps.h | 20 +- Source/EbsdLib/LaueOps/SO3Sampler.cpp | 38 +- Source/EbsdLib/LaueOps/SO3Sampler.h | 13 +- Source/EbsdLib/LaueOps/TetragonalLowOps.cpp | 56 +- Source/EbsdLib/LaueOps/TetragonalLowOps.h | 20 +- Source/EbsdLib/LaueOps/TetragonalOps.cpp | 57 +- Source/EbsdLib/LaueOps/TetragonalOps.h | 20 +- Source/EbsdLib/LaueOps/TriclinicOps.cpp | 56 +- Source/EbsdLib/LaueOps/TriclinicOps.h | 20 +- Source/EbsdLib/LaueOps/TrigonalLowOps.cpp | 57 +- Source/EbsdLib/LaueOps/TrigonalLowOps.h | 22 +- Source/EbsdLib/LaueOps/TrigonalOps.cpp | 57 +- Source/EbsdLib/LaueOps/TrigonalOps.h | 20 +- Source/EbsdLib/Math/ArrayHelpers.hpp | 2 +- Source/EbsdLib/Math/Matrix3X1.hpp | 6 + Source/EbsdLib/Math/Matrix3X3.hpp | 4 +- .../OrientationMath/OrientationConverter.hpp | 327 ++--- Source/EbsdLib/Texture/StatsGen.hpp | 8 +- Source/EbsdLib/Texture/Texture.hpp | 17 +- Source/EbsdLib/Utilities/CanvasUtilities.hpp | 2 +- Source/Test/CMakeLists.txt | 9 +- Source/Test/ConvertToFundamentalZoneTest.cpp | 9 +- Source/Test/GenerateFunctionList.h | 160 ++- Source/Test/ODFTest.cpp | 22 +- Source/Test/OrientationArrayTest.cpp | 1096 ----------------- Source/Test/OrientationConverterTest.cpp | 4 +- ...OrientationRepresentationTransformTest.cpp | 563 +++++++++ Source/Test/OrientationTest.cpp | 1036 ---------------- Source/Test/OrientationTransformationTest.cpp | 656 ---------- Source/Test/OrientationTransformsTest.cpp | 190 +-- Source/Test/QuaternionTest.cpp | 1 - Source/Test/SO3SamplerTest.cpp | 38 +- 57 files changed, 1881 insertions(+), 4658 deletions(-) delete mode 100644 Source/EbsdLib/Core/OrientationRepresentation.h create mode 100644 Source/EbsdLib/Core/OrientationRepresentation.hpp delete mode 100644 Source/Test/OrientationArrayTest.cpp create mode 100644 Source/Test/OrientationRepresentationTransformTest.cpp delete mode 100644 Source/Test/OrientationTest.cpp delete mode 100644 Source/Test/OrientationTransformationTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 69e6acc2..0e539eb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # set project's name -project(EbsdLibProj VERSION 1.0.41) +project(EbsdLibProj VERSION 1.0.42) # ---------- Setup output Directories ------------------------- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY diff --git a/README.md b/README.md index e74a2e95..831034c1 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Please have a look at the unit tests for examples on using the various readers. ## Crystallographic Classes -| # | Point Group (H–M) | Rotation Point Group | Space Group No(s). | Schoenflies | Crystal system | Laue class | Laue Ops | -|---:|-------------------|----------------------|--------------------|---------------|----------------|-------------|------------------| +| Point Group | (H–M) | Rotation Point Group | Space Group No(s). | Schoenflies | Crystal system | Laue class | Laue Ops | +|----------------------|----------------------|--------------------|---------------|----------------|-------------|------------------| | 1 | 1 | 1 | 1 | C₁ | Triclinic | (\bar{1}) | TriclinicOps | | 2 | (\bar{1}) | 1 | 2 | C(_i) | Triclinic | (\bar{1}) | | | 3 | 2 | 2 | 3–5 | C₂ | Monoclinic | 2/m | | diff --git a/Source/Apps/gen_sym_code.cpp b/Source/Apps/gen_sym_code.cpp index 82fb9bc5..ae0118eb 100644 --- a/Source/Apps/gen_sym_code.cpp +++ b/Source/Apps/gen_sym_code.cpp @@ -151,7 +151,7 @@ std::vector InitRotationPointGroup(int rotPointGroup) return sym_ops; } -void Print3x3(const OrientationD& m) +void Print3x3(const OrientationMatrixDType& m) { std::cout << std::fixed; std::cout << std::setprecision(16); @@ -175,7 +175,7 @@ void PrintQuat(const QuatD& q, bool sv) } } -void PrintRod(const OrientationD& q) +void PrintRod(const RodriguesDType& q) { std::cout << std::fixed; std::cout << std::setprecision(16); @@ -214,10 +214,10 @@ int main(int argc, char* argv[]) } std::cout << "};\n\n"; - std::cout << "static const std::vector RodSym = {\n"; + std::cout << "static const std::vector RodSym = {\n"; for(const auto& symOp : symOPs) { - auto ro = OrientationTransformation::qu2ro(symOp); + auto ro = QuaternionDType(symOp).toRodrigues(); PrintRod(ro); std::cout << ",\n"; } @@ -226,7 +226,7 @@ int main(int argc, char* argv[]) std::cout << "static const double MatSym[k_SymOpsCount][3][3] = {\n"; for(const auto& symOp : symOPs) { - auto om = OrientationTransformation::qu2om(symOp); + auto om = QuaternionDType(symOp).toOrientationMatrix(); Print3x3(om); std::cout << " \n"; } @@ -235,6 +235,4 @@ int main(int argc, char* argv[]) } return -1; - - return 0; } diff --git a/Source/Apps/rotconvert.cpp b/Source/Apps/rotconvert.cpp index 5d52746d..4e6a2c39 100644 --- a/Source/Apps/rotconvert.cpp +++ b/Source/Apps/rotconvert.cpp @@ -6,7 +6,7 @@ #include #include -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" @@ -113,259 +113,6 @@ void GenerateLogicBlock() std::cout << std::endl; } -//-------------------------------------------------------------------------------- -void eu2om(const OrientationD& input) -{ - OrientationD om = OrientationTransformation::eu2om({input[0], input[1], input[2]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void eu2ax(const OrientationD& input) -{ - OrientationD ax = OrientationTransformation::eu2ax({input[0], input[1], input[2]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void eu2ro(const OrientationD& input) -{ - OrientationD ro = OrientationTransformation::eu2ro({input[0], input[1], input[2]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void eu2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::eu2qu({input[0], input[1], input[2]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void eu2ho(const OrientationD& input) -{ - OrientationD ho = OrientationTransformation::eu2ho({input[0], input[1], input[2]}); - OrientationPrinters::Print_HO(ho); -} -//-------------------------------------------------------------------------------- -void eu2cu(const OrientationD& input) -{ - OrientationD cu = OrientationTransformation::eu2cu({input[0], input[1], input[2]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void om2eu(const OrientationD& input) -{ - OrientationD eu = OrientationTransformation::om2eu({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void om2ax(const OrientationD& input) -{ - OrientationD ax = OrientationTransformation::om2ax({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void om2ro(const OrientationD& input) -{ - OrientationD ro = OrientationTransformation::om2ro({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void om2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::om2qu({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void om2ho(const OrientationD& input) -{ - OrientationD ho = OrientationTransformation::om2ho({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_HO(ho); -} -//-------------------------------------------------------------------------------- -void om2cu(const OrientationD& input) -{ - OrientationD cu = OrientationTransformation::om2cu({input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void ax2eu(const OrientationD& input) -{ - OrientationD eu = OrientationTransformation::ax2eu({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void ax2om(const OrientationD& input) -{ - OrientationD om = OrientationTransformation::ax2om({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void ax2ro(const OrientationD& input) -{ - OrientationD ro = OrientationTransformation::ax2ro({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void ax2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::ax2qu({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void ax2ho(const OrientationD& input) -{ - OrientationD ho = OrientationTransformation::ax2ho({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_HO(ho); -} -//-------------------------------------------------------------------------------- -void ax2cu(const OrientationD& input) -{ - OrientationD cu = OrientationTransformation::ax2cu({input[0], input[1], input[2], input[3]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void ro2eu(const OrientationD& input) -{ - OrientationD eu = OrientationTransformation::ro2eu({input[0], input[1], input[2]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void ro2om(const OrientationD& input) -{ - OrientationD om = OrientationTransformation::ro2om({input[0], input[1], input[2]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void ro2ax(const OrientationD& input) -{ - OrientationD ax = OrientationTransformation::ro2ax({input[0], input[1], input[2]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void ro2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::ro2qu({input[0], input[1], input[2]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void ro2ho(const OrientationD& input) -{ - OrientationD ho = OrientationTransformation::ro2ho({input[0], input[1], input[2]}); - OrientationPrinters::Print_HO(ho); -} -//-------------------------------------------------------------------------------- -void ro2cu(const OrientationD& input) -{ - OrientationD cu = OrientationTransformation::ro2cu({input[0], input[1], input[2]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void qu2eu(const QuatD& input) -{ - OrientationD eu = OrientationTransformation::qu2eu({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void qu2om(const QuatD& input) -{ - OrientationD om = OrientationTransformation::qu2om({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void qu2ax(const QuatD& input) -{ - OrientationD ax = OrientationTransformation::qu2ax({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void qu2ro(const QuatD& input) -{ - OrientationD ro = OrientationTransformation::qu2ro({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void qu2ho(const QuatD& input) -{ - OrientationD ho = OrientationTransformation::qu2ho({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_HO(ho); -} -//-------------------------------------------------------------------------------- -void qu2cu(const QuatD& input) -{ - OrientationD cu = OrientationTransformation::qu2cu({input[0], input[1], input[2], input[4]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void ho2eu(const OrientationD& input) -{ - OrientationD eu = OrientationTransformation::ho2eu({input[0], input[1], input[2]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void ho2om(const OrientationD& input) -{ - OrientationD om = OrientationTransformation::ho2om({input[0], input[1], input[2]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void ho2ax(const OrientationD& input) -{ - OrientationD ax = OrientationTransformation::ho2ax({input[0], input[1], input[2]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void ho2ro(const OrientationD& input) -{ - OrientationD ro = OrientationTransformation::ho2ro({input[0], input[1], input[2]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void ho2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::ho2qu({input[0], input[1], input[2]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void ho2cu(const OrientationD& input) -{ - OrientationD cu = OrientationTransformation::ho2cu({input[0], input[1], input[2]}); - OrientationPrinters::Print_CU(cu); -} -//-------------------------------------------------------------------------------- -void cu2eu(const OrientationD& input) -{ - OrientationD eu = OrientationTransformation::cu2eu({input[0], input[1], input[2]}); - OrientationPrinters::Print_EU(eu); -} -//-------------------------------------------------------------------------------- -void cu2om(const OrientationD& input) -{ - OrientationD om = OrientationTransformation::cu2om({input[0], input[1], input[2]}); - OrientationPrinters::Print_OM(om); -} -//-------------------------------------------------------------------------------- -void cu2ax(const OrientationD& input) -{ - OrientationD ax = OrientationTransformation::cu2ax({input[0], input[1], input[2]}); - OrientationPrinters::Print_AX(ax); -} -//-------------------------------------------------------------------------------- -void cu2ro(const OrientationD& input) -{ - OrientationD ro = OrientationTransformation::cu2ro({input[0], input[1], input[2]}); - OrientationPrinters::Print_RO(ro); -} -//-------------------------------------------------------------------------------- -void cu2qu(const OrientationD& input) -{ - QuatD qu = OrientationTransformation::cu2qu({input[0], input[1], input[2]}); - OrientationPrinters::Print_QU(qu); -} -//-------------------------------------------------------------------------------- -void cu2ho(const OrientationD& input) -{ - OrientationD ho = OrientationTransformation::cu2ho({input[0], input[1], input[2]}); - OrientationPrinters::Print_HO(ho); -} - // ----------------------------------------------------------------------------- int main(int argc, char* argv[]) { @@ -409,469 +156,5 @@ int main(int argc, char* argv[]) double* repPtr = array.data(); - if(conversion == "eu2om") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2om(eu); - } - else if(conversion == "eu2ax") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2ax(eu); - } - else if(conversion == "eu2ro") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2ro(eu); - } - else if(conversion == "eu2qu") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2qu(eu); - } - else if(conversion == "eu2ho") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2ho(eu); - } - else if(conversion == "eu2cu") - { - OrientationD eu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::eu_check(eu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - eu2cu(eu); - } - else if(conversion == "om2eu") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2eu(om); - } - else if(conversion == "om2ax") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2ax(om); - } - else if(conversion == "om2ro") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2ro(om); - } - else if(conversion == "om2qu") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2qu(om); - } - else if(conversion == "om2ho") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2ho(om); - } - else if(conversion == "om2cu") - { - OrientationD om(array.data(), 9); - OrientationTransformation::ResultType res = OrientationTransformation::om_check(om); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - om2cu(om); - } - else if(conversion == "ax2eu") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2eu(ax); - } - else if(conversion == "ax2om") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2om(ax); - } - else if(conversion == "ax2ro") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2ro(ax); - } - else if(conversion == "ax2qu") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2qu(ax); - } - else if(conversion == "ax2ho") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2ho(ax); - } - else if(conversion == "ax2cu") - { - OrientationD ax(array.data(), 4); - OrientationTransformation::ResultType res = OrientationTransformation::ax_check(ax); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ax2cu(ax); - } - else if(conversion == "ro2eu") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2eu(ro); - } - else if(conversion == "ro2om") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2om(ro); - } - else if(conversion == "ro2ax") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2ax(ro); - } - else if(conversion == "ro2qu") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2qu(ro); - } - else if(conversion == "ro2ho") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2ho(ro); - } - else if(conversion == "ro2cu") - { - OrientationD ro(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ro_check(ro); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ro2cu(ro); - } - else if(conversion == "qu2eu") - { - - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2eu(qu); - } - else if(conversion == "qu2om") - { - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2om(qu); - } - else if(conversion == "qu2ax") - { - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2ax(qu); - } - else if(conversion == "qu2ro") - { - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2ro(qu); - } - else if(conversion == "qu2ho") - { - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2ho(qu); - } - else if(conversion == "qu2cu") - { - QuatD qu(repPtr[0], repPtr[2], repPtr[3], repPtr[4]); - OrientationTransformation::ResultType res = OrientationTransformation::qu_check(qu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - qu2cu(qu); - } - else if(conversion == "ho2eu") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2eu(ho); - } - else if(conversion == "ho2om") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2om(ho); - } - else if(conversion == "ho2ax") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2ax(ho); - } - else if(conversion == "ho2ro") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2ro(ho); - } - else if(conversion == "ho2qu") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2qu(ho); - } - else if(conversion == "ho2cu") - { - OrientationD ho(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::ho_check(ho); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - ho2cu(ho); - } - else if(conversion == "cu2eu") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2eu(cu); - } - else if(conversion == "cu2om") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2om(cu); - } - else if(conversion == "cu2ax") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2ax(cu); - } - else if(conversion == "cu2ro") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2ro(cu); - } - else if(conversion == "cu2qu") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2qu(cu); - } - else if(conversion == "cu2ho") - { - OrientationD cu(array.data(), 3); - OrientationTransformation::ResultType res = OrientationTransformation::cu_check(cu); - if(res.result < 0) - { - std::cout << res.msg << std::endl; - return 1; - } - cu2ho(cu); - } - return 0; } diff --git a/Source/EbsdLib/Core/EbsdStringLiteral.hpp b/Source/EbsdLib/Core/EbsdStringLiteral.hpp index ecfe5628..f9614f1d 100644 --- a/Source/EbsdLib/Core/EbsdStringLiteral.hpp +++ b/Source/EbsdLib/Core/EbsdStringLiteral.hpp @@ -9,8 +9,7 @@ namespace EbsdLib { -namespace detail -{ + /** * @brief Returns true if the given character array is null-terminated. * @tparam T @@ -22,7 +21,6 @@ constexpr bool HasNullTerminator(const T (&string)[Size]) noexcept { return string[Size - 1] == static_cast('\0'); } -} // namespace detail /** * @brief BasicEbsdStringLiteral is meant to be a safe container for a string literal allowing for easy access to its size/length. @@ -52,7 +50,7 @@ class BasicEbsdStringLiteral : m_String(string) , m_Size(Size) { - if(!detail::HasNullTerminator(string)) + if(!HasNullTerminator(string)) { throw std::runtime_error("BasicEbsdStringLiteral must be null-terminated"); } diff --git a/Source/EbsdLib/Core/Orientation.hpp b/Source/EbsdLib/Core/Orientation.hpp index 792f9b15..36e3e7f1 100644 --- a/Source/EbsdLib/Core/Orientation.hpp +++ b/Source/EbsdLib/Core/Orientation.hpp @@ -41,6 +41,9 @@ #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Math/Matrix3X3.hpp" +namespace ebsdlib::deprecated +{ + /** * @brief The Orientation class encapsulates one of many types of rotation representations * Bunge Euler Angles (3x1), Orientation Matrix (3x3), Rodrigues-Frank Vector (1x4), @@ -800,3 +803,4 @@ class Orientation using OrientationType = Orientation; using OrientationD = Orientation; using OrientationF = Orientation; +} // namespace ebsdlib::deprecated diff --git a/Source/EbsdLib/Core/OrientationRepresentation.h b/Source/EbsdLib/Core/OrientationRepresentation.h deleted file mode 100644 index 55e36ad2..00000000 --- a/Source/EbsdLib/Core/OrientationRepresentation.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2020 BlueQuartz Software, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the names of any of the BlueQuartz Software contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once - -namespace OrientationRepresentation -{ -enum class Type : int -{ - Euler = 0, - OrientationMatrix, - Quaternion, - AxisAngle, - Rodrigues, - Homochoric, - Cubochoric, - Stereographic, - Unknown -}; -} diff --git a/Source/EbsdLib/Core/OrientationRepresentation.hpp b/Source/EbsdLib/Core/OrientationRepresentation.hpp new file mode 100644 index 00000000..6b120266 --- /dev/null +++ b/Source/EbsdLib/Core/OrientationRepresentation.hpp @@ -0,0 +1,474 @@ +/* ============================================================================ + * Copyright (c) 2025 BlueQuartz Software, LLC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * Neither the names of any of the BlueQuartz Software contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#pragma once + +#include "EbsdLib/Core/OrientationTransformation.hpp" +#include "EbsdLib/Core/Quaternion.hpp" +#include "EbsdLib/EbsdLib.h" +#include "EbsdLib/Math/Matrix3X1.hpp" +#include "EbsdLib/Math/Matrix3X3.hpp" + +#include +#include + +namespace EbsdLib +{ + +#define REP_SHIM_TO_QUAT_DEF(FROM) \ + template \ + static Quaternion qu(const InputType& e, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) \ + { \ + Quaternion qu = OrientationTransformation::FROM##2##qu>(e, layout); \ + return Orientation(qu[0], qu[1], qu[2], qu[3]); \ + } + +#define REP_SHIM_FROM_QUAT_DEF(TO) \ + template \ + static OutputType TO(const InputType& qu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) \ + { \ + Quaternion quat(qu[0], qu[1], qu[2], qu[3]); \ + return OrientationTransformation::qu2##TO, OutputType>(quat, layout); \ + } + +#define REP_SHIM_DEF(FROM, TO) \ + template \ + static OutputType TO(const InputType& orientation) \ + { \ + return OrientationTransformation::FROM##2##TO(orientation); \ + } + +#define REP_SHIM_NO_OP(NAME) \ + template \ + static OutputType NAME(const InputType& orientation) \ + { \ + return orientation; \ + } + +#define ORIENTATION_REP_TO_METHOD_DEF(NAME, FUNC) \ + Orientation to##NAME() const \ + { \ + auto result = RepresentationType::template FUNC(m_Array); \ + return Orientation(result); \ + } + +struct QuaternionRep +{ + static constexpr size_t s_NumComponents = 4; + + REP_SHIM_FROM_QUAT_DEF(eu); + REP_SHIM_FROM_QUAT_DEF(om); + REP_SHIM_NO_OP(qu) + REP_SHIM_FROM_QUAT_DEF(ax); + REP_SHIM_FROM_QUAT_DEF(ro); + REP_SHIM_FROM_QUAT_DEF(ho); + REP_SHIM_FROM_QUAT_DEF(cu); + REP_SHIM_FROM_QUAT_DEF(st); +}; // quaternion + +struct EulerRep +{ + static constexpr size_t s_NumComponents = 3; + REP_SHIM_NO_OP(eu); + REP_SHIM_DEF(eu, om); + REP_SHIM_DEF(eu, qu) + REP_SHIM_DEF(eu, ax); + REP_SHIM_DEF(eu, ro); + REP_SHIM_DEF(eu, ho); + REP_SHIM_DEF(eu, cu); + REP_SHIM_DEF(eu, st); + +}; // euler angles + +struct OrientationMatrixRep +{ + static constexpr size_t s_NumComponents = 9; + REP_SHIM_DEF(om, eu); + REP_SHIM_NO_OP(om); + REP_SHIM_DEF(om, qu) + REP_SHIM_DEF(om, ax); + REP_SHIM_DEF(om, ro); + REP_SHIM_DEF(om, ho); + REP_SHIM_DEF(om, cu); + REP_SHIM_DEF(om, st); + +}; // orientation matrix + +struct AxisAngleRep +{ + static constexpr size_t s_NumComponents = 4; + REP_SHIM_DEF(ax, eu); + REP_SHIM_DEF(ax, om); + REP_SHIM_DEF(ax, qu) + REP_SHIM_NO_OP(ax); + REP_SHIM_DEF(ax, ro); + REP_SHIM_DEF(ax, ho); + REP_SHIM_DEF(ax, cu); + REP_SHIM_DEF(ax, st); +}; +struct RodriguesRep +{ + static constexpr size_t s_NumComponents = 4; + REP_SHIM_DEF(ro, eu); + REP_SHIM_DEF(ro, om); + REP_SHIM_DEF(ro, qu) + REP_SHIM_DEF(ro, ax); + REP_SHIM_NO_OP(ro); + REP_SHIM_DEF(ro, ho); + REP_SHIM_DEF(ro, cu); + REP_SHIM_DEF(ro, st); +}; +struct HomochoricRep +{ + static constexpr size_t s_NumComponents = 3; + REP_SHIM_DEF(ho, eu); + REP_SHIM_DEF(ho, om); + REP_SHIM_DEF(ho, qu) + REP_SHIM_DEF(ho, ax); + REP_SHIM_DEF(ho, ro); + REP_SHIM_NO_OP(ho); + REP_SHIM_DEF(ho, cu); + REP_SHIM_DEF(ho, st); +}; +struct CubochoricRep +{ + static constexpr size_t s_NumComponents = 3; + REP_SHIM_DEF(cu, eu); + REP_SHIM_DEF(cu, om); + REP_SHIM_DEF(cu, qu) + REP_SHIM_DEF(cu, ax); + REP_SHIM_DEF(cu, ro); + REP_SHIM_DEF(cu, ho); + REP_SHIM_NO_OP(cu); + REP_SHIM_DEF(cu, st); +}; +struct StereographicRep +{ + static constexpr size_t s_NumComponents = 3; + REP_SHIM_DEF(st, eu); + REP_SHIM_DEF(st, om); + REP_SHIM_DEF(st, qu) + REP_SHIM_DEF(st, ax); + REP_SHIM_DEF(st, ro); + REP_SHIM_DEF(st, ho); + REP_SHIM_DEF(st, cu); + REP_SHIM_NO_OP(st); +}; + +/** + * + * @tparam T The primitive type (float or double) + * @tparam RepresentationType The 'Representation' struct + */ +template +class Orientation +{ + +public: + using StorageType = std::vector; + + using size_type = size_t; + using value_type = T; + using reference = T&; + + using QuaternionType = Quaternion; + + Orientation() + { + m_Array.resize(RepresentationType::s_NumComponents); + } + + template >* = nullptr> + Orientation(T r0c0, T r0c1, T r0c2, T r1c0, T r1c1, T r1c2, T r2c0, T r2c1, T r2c2) + : m_Array({ + r0c0, + r0c1, + r0c2, + r1c0, + r1c1, + r1c2, + r2c0, + r2c1, + r2c2, + }) + { + } + + template >* = nullptr> + Orientation(const Matrix3X3& mat) + : m_Array({mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], mat[8]}) + { + } + + template || std::is_same_v || std::is_same_v>* = nullptr> + Orientation(T i, T j, T k, T w) + : m_Array({i, j, k, w}) + { + } + + template >* = nullptr> + explicit Orientation(const Quaternion& quat) + : m_Array({quat.x(), quat.y(), quat.z(), quat.w()}) + { + } + + template >* = nullptr> + explicit Orientation(const Quaternion& quat) + : m_Array({quat.x(), quat.y(), quat.z(), quat.w()}) + { + } + + template || std::is_same_v || std::is_same_v || + std::is_same_v>* = nullptr> + Orientation(T x, T y, T z) + : m_Array({x, y, z}) + { + } + + template || std::is_same_v || std::is_same_v || + std::is_same_v>* = nullptr> + Orientation(const Matrix3X1& mat) + : m_Array({mat[0], mat[1], mat[2]}) + { + } + + Orientation(const Orientation& rhs) + : m_Array(rhs.m_Array) + { + } + + Orientation(Orientation&& rhs) + : m_Array(std::move(rhs.m_Array)) + { + } + + Orientation(size_t size) + : m_Array() + { + if(RepresentationType::s_NumComponents != size) + { + throw std::runtime_error("Number of components of OrientationRep does not match 'size' argument"); + } + m_Array.resize(RepresentationType::s_NumComponents); + } + + Orientation(const StorageType& input) + : m_Array(input) + { + if(RepresentationType::s_NumComponents != m_Array.size()) + { + throw std::runtime_error("Number of components of OrientationRep does not match 'size' argument"); + } + } + + Orientation(const T* ptr) + { + m_Array.resize(RepresentationType::s_NumComponents); + m_Array.assign(ptr, ptr + RepresentationType::s_NumComponents); + } + + Orientation& operator=(const Orientation& rhs) // Copy Assignment + { + m_Array = rhs.m_Array; + return *this; + } + + Orientation& operator=(Orientation&& rhs) // Move Assignment + { + m_Array = std::move(rhs.m_Array); + return *this; + } + + reference operator[](size_type index) + { + return m_Array[index]; + } + + const T& operator[](size_type index) const + { + return m_Array[index]; + } + + size_t size() const + { + return RepresentationType::s_NumComponents; + } + + const T* data() const + { + return m_Array.data(); + } + + void copyTo(T* destination) const + { + std::copy(m_Array.begin(), m_Array.end(), destination); + } + + Orientation operator-(const Orientation& rhs) const + { + StorageType result_vec(m_Array.size()); + std::transform(m_Array.begin(), m_Array.end(), rhs.m_Array.begin(), result_vec.begin(), std::minus()); + return Orientation(result_vec); + } + + bool isWithinTolerance(const Orientation& rhs, T tolerance) const + { + auto result = *this - rhs; + auto it = std::find_if(result.m_Array.begin(), result.m_Array.end(), [tolerance](T num) { return std::abs(num) > tolerance; }); + return it == result.m_Array.end(); + } + + template >* = nullptr> + T w() const + { + return m_Array[3]; + } + template >* = nullptr> + T x() const + { + return m_Array[0]; + } + template >* = nullptr> + T y() const + { + return m_Array[1]; + } + template >* = nullptr> + T z() const + { + return m_Array[2]; + } + + ORIENTATION_REP_TO_METHOD_DEF(Euler, eu) + ORIENTATION_REP_TO_METHOD_DEF(OrientationMatrix, om) + ORIENTATION_REP_TO_METHOD_DEF(Quaternion, qu) + ORIENTATION_REP_TO_METHOD_DEF(AxisAngle, ax) + ORIENTATION_REP_TO_METHOD_DEF(Rodrigues, ro) + ORIENTATION_REP_TO_METHOD_DEF(Homochoric, ho) + ORIENTATION_REP_TO_METHOD_DEF(Cubochoric, cu) + ORIENTATION_REP_TO_METHOD_DEF(Stereographic, st) + + QuaternionType toQuat() const + { + Orientation quRep = toQuaternion(); + return QuaternionType{quRep[0], quRep[1], quRep[2], quRep[3]}; + } + + template >* = nullptr> + Matrix3X3 toGMatrixObj() const + { + return {m_Array[0], m_Array[1], m_Array[2], m_Array[3], m_Array[4], m_Array[5], m_Array[6], m_Array[7], m_Array[8]}; + } + + template >* = nullptr> + Eigen::Matrix toEigenGMatrix() const + { + Eigen::Matrix g1; + g1(0, 0) = m_Array[0]; + g1(0, 1) = m_Array[1]; + g1(0, 2) = m_Array[2]; + g1(1, 0) = m_Array[3]; + g1(1, 1) = m_Array[4]; + g1(1, 2) = m_Array[5]; + g1(2, 0) = m_Array[6]; + g1(2, 1) = m_Array[7]; + g1(2, 2) = m_Array[8]; + return g1; + } + +private: + StorageType m_Array; +}; + +using EulerDType = Orientation; +using OrientationMatrixDType = Orientation; +using QuaternionDType = Orientation; +using AxisAngleDType = Orientation; +using RodriguesDType = Orientation; +using HomochoricDType = Orientation; +using CubochoricDType = Orientation; +using StereographicDType = Orientation; + +using EulerFType = Orientation; +using OrientationMatrixFType = Orientation; +using QuaternionFType = Orientation; +using AxisAngleFType = Orientation; +using RodriguesFType = Orientation; +using HomochoricFType = Orientation; +using CubochoricFType = Orientation; +using StereographicFType = Orientation; + +inline std::ostream& operator<<(std::ostream& os, const EulerDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "EU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +inline std::ostream& operator<<(std::ostream& os, const OrientationMatrixDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "OM: / " << obj[0] << ", " << obj[1] << ", " << obj[2] << "\\\n"; + os << std::setw(3) << std::setprecision(16) << "OM: | " << obj[3] << ", " << obj[4] << ", " << obj[5] << "|\n"; + os << std::setw(3) << std::setprecision(16) << "OM: \\ " << obj[6] << ", " << obj[7] << ", " << obj[8] << "/\n"; + return os; +} + +inline std::ostream& operator<<(std::ostream& os, const QuaternionDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "QU: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} +inline std::ostream& operator<<(std::ostream& os, const AxisAngleDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "AX: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} +inline std::ostream& operator<<(std::ostream& os, const RodriguesDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "RO: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} +inline std::ostream& operator<<(std::ostream& os, const HomochoricDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "HO: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} +inline std::ostream& operator<<(std::ostream& os, const CubochoricDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "CU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} +inline std::ostream& operator<<(std::ostream& os, const StereographicDType& obj) +{ + os << std::setw(3) << std::setprecision(16) << "ST: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +} // namespace EbsdLib diff --git a/Source/EbsdLib/Core/OrientationTransformation.hpp b/Source/EbsdLib/Core/OrientationTransformation.hpp index 44c158aa..c82c89dd 100644 --- a/Source/EbsdLib/Core/OrientationTransformation.hpp +++ b/Source/EbsdLib/Core/OrientationTransformation.hpp @@ -127,6 +127,24 @@ namespace LPs = EbsdLib::LambertParametersType; namespace RConst = Rotations::Constants; namespace DConst = EbsdLib::Constants; +namespace OrientationRepresentation +{ +enum class Type : int +{ + Euler = 0, + OrientationMatrix, + Quaternion, + AxisAngle, + Rodrigues, + Homochoric, + Cubochoric, + Stereographic, + Unknown +}; +} + +using namespace EbsdLib; + /** * @brief The OrientationTransformation namespace * template parameter InputType can be one of std::vector, std::vector or OrientationArray @@ -151,7 +169,7 @@ struct ResultType // std::cout << func << "::" << msg << std::endl; //} /* ################################################################### -Original Fotran codes written by Dr. Marc De Graef. +Original Fortran codes written by Dr. Marc De Graef. * MODULE: rotations * @@ -401,13 +419,18 @@ ResultType cu_check(const InputType& cu) ValueType maxValue = static_cast(LPs::ap / 2.0); bool maxValueHit = false; - std::for_each(cu.begin(), cu.end(), [&](const ValueType& v) { - ValueType value = std::fabs(v); - if(value > maxValue) - { - maxValueHit = true; - } - }); + if(std::abs(cu[0]) > maxValue) + { + maxValueHit = true; + } + if(std::abs(cu[1]) > maxValue) + { + maxValueHit = true; + } + if(std::abs(cu[2]) > maxValue) + { + maxValueHit = true; + } if(maxValueHit) { @@ -1185,7 +1208,7 @@ OutputType ho2ax(const InputType& h) OutputValueType hm = hmag; InputType hn = h; OutputValueType sqrRtHMag = static_cast(1.0 / sqrt(hmag)); - OMHelperType::scalarMultiply(hn, sqrRtHMag); // In place scalar multiply + ArrayHelpers::scalarMultiply(hn, sqrRtHMag); // In place scalar multiply OutputValueType s = static_cast(LPs::tfit[0] + LPs::tfit[1] * hmag); for(int i = 2; i < 16; i++) { @@ -1310,8 +1333,10 @@ OutputType om2qu(const InputType& om, typename Quaternion(om); - InputType oax = eu2ax(eu); + using EulerType = std::vector; + using AxisAngleType = std::vector; + EulerType eu = om2eu(om); + AxisAngleType oax = eu2ax(eu); if(oax[0] * res[x] < 0.0) { @@ -1586,13 +1611,13 @@ OutputType ro2ho(const InputType& r) { OutputType res(3); using value_type = typename OutputType::value_type; - using OMHelperType = ArrayHelpers; + using OMHelperType = ArrayHelpers; value_type f = 0.0; value_type rv = OMHelperType::sumofSquares(r); if(rv == 0.0) { - OMHelperType::splat(res, 0.0); + ArrayHelpers::splat(res, 0.0); return res; } if(r[3] == std::numeric_limits::infinity()) @@ -1788,9 +1813,8 @@ template OutputType ho2cu(const InputType& q) { int ierr = -1; - OutputType res(3); - res = ModifiedLambertProjection3D::LambertBallToCube(q, ierr); - return res; + InputType res = ModifiedLambertProjection3D::LambertBallToCube(q, ierr); + return {res[0], res[1], res[2]}; } /**: cu2ho @@ -1809,9 +1833,8 @@ template OutputType cu2ho(const InputType& cu) { int ierr = 0; - OutputType res(3); - res = ModifiedLambertProjection3D::LambertCubeToBall(cu, ierr); - return res; + InputType res = ModifiedLambertProjection3D::LambertCubeToBall(cu, ierr); + return {res[0], res[1], res[2]}; } /**: ro2om @@ -1883,8 +1906,9 @@ OutputType eu2ho(const InputType& eu) template OutputType om2ro(const InputType& om) { - OutputType eu = om2eu(om); // Convert the OM to Euler - return eu2ro(eu); // Convert Euler to Rodrigues + using EulerType = std::vector; + EulerType eu = om2eu(om); // Convert the OM to Euler + return eu2ro(eu); // Convert Euler to Rodrigues } /**: om2ho diff --git a/Source/EbsdLib/Core/Quaternion.hpp b/Source/EbsdLib/Core/Quaternion.hpp index 59d62293..1773585b 100644 --- a/Source/EbsdLib/Core/Quaternion.hpp +++ b/Source/EbsdLib/Core/Quaternion.hpp @@ -40,6 +40,8 @@ #include #include +namespace EbsdLib +{ template class Quaternion { @@ -594,6 +596,7 @@ class Quaternion T m_Z = 0.0; T m_W = 1.0; }; +} // namespace EbsdLib -using QuatD = Quaternion; -using QuatF = Quaternion; +using QuatD = EbsdLib::Quaternion; +using QuatF = EbsdLib::Quaternion; diff --git a/Source/EbsdLib/Core/SourceList.cmake b/Source/EbsdLib/Core/SourceList.cmake index e3fbb703..dfcf2c7e 100644 --- a/Source/EbsdLib/Core/SourceList.cmake +++ b/Source/EbsdLib/Core/SourceList.cmake @@ -9,7 +9,7 @@ set(EbsdLib_${DIR_NAME}_HDRS ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/EbsdTransform.h ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Orientation.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationMath.h - ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationRepresentation.h + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationRepresentation.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationTransformation.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Quaternion.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/EbsdStringLiteral.hpp diff --git a/Source/EbsdLib/IO/AngleFileLoader.cpp b/Source/EbsdLib/IO/AngleFileLoader.cpp index eaabfe8f..250f214e 100644 --- a/Source/EbsdLib/IO/AngleFileLoader.cpp +++ b/Source/EbsdLib/IO/AngleFileLoader.cpp @@ -41,7 +41,7 @@ #include #include -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/Math/EbsdLibMath.h" @@ -170,7 +170,7 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() } tokens = EbsdStringUtils::split(buf, (*(getDelimiter().c_str()))); - OrientationF euler(3); + EbsdLib::EulerDType euler(3); if(m_AngleRepresentation == EulerAngles) { euler[0] = std::stof(tokens[0]); @@ -181,24 +181,14 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() } else if(m_AngleRepresentation == QuaternionAngles) { - QuatF quat(4); - - quat.x() = std::stof(tokens[0]); - quat.y() = std::stof(tokens[1]); - quat.z() = std::stof(tokens[2]); - quat.w() = std::stof(tokens[3]); - - euler = OrientationTransformation::qu2eu(quat); + euler = + EbsdLib::QuaternionDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2]), std::stof(tokens[3])).toEuler(); // OrientationTransformation::qu2eu(quat); weight = std::stof(tokens[4]); sigma = std::stof(tokens[5]); } else if(m_AngleRepresentation == RodriguezAngles) { - Orientation rod(4, 0.0); - rod[0] = std::stof(tokens[0]); - rod[1] = std::stof(tokens[1]); - rod[2] = std::stof(tokens[2]); - euler = OrientationTransformation::ro2eu(rod); + euler = EbsdLib::RodriguesDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2])).toEuler(); // OrientationTransformation::ro2eu(rod); weight = std::stof(tokens[3]); sigma = std::stof(tokens[4]); } diff --git a/Source/EbsdLib/LaueOps/CubicLowOps.cpp b/Source/EbsdLib/LaueOps/CubicLowOps.cpp index 0e8a52ea..4b6c35ad 100644 --- a/Source/EbsdLib/LaueOps/CubicLowOps.cpp +++ b/Source/EbsdLib/LaueOps/CubicLowOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -89,7 +89,7 @@ static const std::vector QuatSym ={ QuatD(0.5, 0.5, -0.5, 0.5), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {1.0, 0.0, 0.0, 10000000000000.0}, {0.0, 1.0, 0.0, 10000000000000.0}, @@ -248,27 +248,17 @@ bool CubicLowOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool CubicLowOps::isInsideFZ(const OrientationD& rod) const +bool CubicLowOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } // ----------------------------------------------------------------------------- -OrientationD CubicLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType CubicLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(CubicLow::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF CubicLowOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(CubicLow::QuatSym, q1, q2); - return axisAngle; -} - QuatD CubicLowOps::getQuatSymOp(int32_t i) const { return CubicLow::QuatSym[i]; @@ -323,7 +313,7 @@ void CubicLowOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicLowOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType CubicLowOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(CubicLow::RodSym, rod); } @@ -331,10 +321,10 @@ OrientationType CubicLowOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicLowOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType CubicLowOps::getMDFFZRod(const RodriguesDType& inRod) const { - OrientationType rod = _calcRodNearestOrigin(CubicLow::RodSym, inRod); - auto ax = OrientationTransformation::ro2ax(rod); + RodriguesDType rod = _calcRodNearestOrigin(CubicLow::RodSym, inRod); + auto ax = rod.toAxisAngle(); double n1 = ax[0]; double n2 = ax[1], n3 = ax[2], w = ax[3]; @@ -383,7 +373,7 @@ OrientationType CubicLowOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } QuatD CubicLowOps::getNearestQuat(const QuatD& q1, const QuatD& q2) const @@ -406,13 +396,13 @@ QuatD CubicLowOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int CubicLowOps::getMisoBin(const OrientationType& rod) const +int CubicLowOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - auto ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = CubicLow::OdfDimInitValue[0]; dim[1] = CubicLow::OdfDimInitValue[1]; @@ -430,7 +420,7 @@ int CubicLowOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicLowOps::determineEulerAngles(double random[3], int choose) const +EulerDType CubicLowOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -449,28 +439,26 @@ OrientationType CubicLowOps::determineEulerAngles(double random[3], int choose) _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - auto ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - auto eu = OrientationTransformation::ro2eu(ro); - return eu; + return ro.toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicLowOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType CubicLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(CubicLow::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = CubicLow::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicLowOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType CubicLowOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -488,8 +476,7 @@ OrientationType CubicLowOps::determineRodriguesVector(double random[3], int choo phi[2] = static_cast(choose / (CubicLow::OdfNumBins[0] * CubicLow::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - auto ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -497,13 +484,13 @@ OrientationType CubicLowOps::determineRodriguesVector(double random[3], int choo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int CubicLowOps::getOdfBin(const OrientationType& rod) const +int CubicLowOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - auto ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = CubicLow::OdfDimInitValue[0]; dim[1] = CubicLow::OdfDimInitValue[1]; @@ -622,8 +609,7 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/CubicLowOps.h b/Source/EbsdLib/LaueOps/CubicLowOps.h index e23a7d7a..fd4f9349 100644 --- a/Source/EbsdLib/LaueOps/CubicLowOps.h +++ b/Source/EbsdLib/LaueOps/CubicLowOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& synea) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& synea) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -258,7 +258,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/CubicOps.cpp b/Source/EbsdLib/LaueOps/CubicOps.cpp index e6aa52a5..41465924 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.cpp +++ b/Source/EbsdLib/LaueOps/CubicOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Math/GeometryMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" @@ -108,7 +108,7 @@ static const std::vector QuatSym ={ QuatD(0.5, 0.5, -0.5, 0.5), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {1.0, 0.0, 0.0, 10000000000000.0}, {0.0, 1.0, 0.0, 10000000000000.0}, @@ -328,7 +328,7 @@ bool CubicOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool CubicOps::isInsideFZ(const OrientationD& rod) const +bool CubicOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } @@ -336,25 +336,15 @@ bool CubicOps::isInsideFZ(const OrientationD& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationD CubicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType CubicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(CubicHigh::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF CubicOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(CubicHigh::QuatSym, q1, q2); - return axisAngle; -} - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationD CubicOps::calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const +AxisAngleDType CubicOps::calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const { double wmin = 9999999.0f; //,na,nb,nc; QuatD qco; @@ -604,7 +594,7 @@ OrientationD CubicOps::calculateMisorientationInternal(const std::vector& } wmin = 2.0f * wmin; - OrientationD axisAngle(n1, n2, n3, wmin); + AxisAngleDType axisAngle(n1, n2, n3, wmin); return axisAngle; } @@ -662,7 +652,7 @@ void CubicOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType CubicOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(CubicHigh::RodSym, rod); } @@ -670,13 +660,13 @@ OrientationType CubicOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType CubicOps::getMDFFZRod(const RodriguesDType& inRod) const { double w, n1, n2, n3; double FZw, FZn1, FZn2, FZn3; - OrientationType rod = _calcRodNearestOrigin(CubicHigh::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + RodriguesDType rod = _calcRodNearestOrigin(CubicHigh::RodSym, inRod); + AxisAngleDType ax = rod.toAxisAngle(); n1 = ax[0]; n2 = ax[1], n3 = ax[2], w = ax[3]; @@ -724,7 +714,7 @@ OrientationType CubicOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } QuatD CubicOps::getNearestQuat(const QuatD& q1, const QuatD& q2) const @@ -747,13 +737,13 @@ QuatD CubicOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int CubicOps::getMisoBin(const OrientationType& rod) const +int CubicOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = CubicHigh::OdfDimInitValue[0]; dim[1] = CubicHigh::OdfDimInitValue[1]; @@ -771,7 +761,7 @@ int CubicOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicOps::determineEulerAngles(double random[3], int choose) const +EulerDType CubicOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -790,28 +780,27 @@ OrientationType CubicOps::determineEulerAngles(double random[3], int choose) con _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType CubicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(CubicHigh::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = CubicHigh::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType CubicOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType CubicOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -829,8 +818,7 @@ OrientationType CubicOps::determineRodriguesVector(double random[3], int choose) phi[2] = static_cast(choose / (CubicHigh::OdfNumBins[0] * CubicHigh::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -838,13 +826,13 @@ OrientationType CubicOps::determineRodriguesVector(double random[3], int choose) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int CubicOps::getOdfBin(const OrientationType& rod) const +int CubicOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = CubicHigh::OdfDimInitValue[0]; dim[1] = CubicHigh::OdfDimInitValue[1]; @@ -1050,11 +1038,8 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const double planeMisalignment = 0, directionMisalignment = 0; int ss1 = 0, ss2 = 0; - EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); - EbsdLib::Matrix3X3D g1 = g.transpose(); - - g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); - EbsdLib::Matrix3X3D g2 = g.transpose(); + EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); + EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); for(int i = 0; i < 12; i++) { @@ -1147,11 +1132,8 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS double maxF1 = 0.0; double F1 = 0.0; - EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); - EbsdLib::Matrix3X3D g1 = g.transpose(); - - g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); - EbsdLib::Matrix3X3D g2 = g.transpose(); + EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); + EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); EbsdMatrixMath::Normalize3x1(LD); @@ -1230,11 +1212,8 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m double maxF1spt = 0.0; double F1spt = 0.0f; - EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); - EbsdLib::Matrix3X3D g1 = g.transpose(); - - g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); - EbsdLib::Matrix3X3D g2 = g.transpose(); + EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); + EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); EbsdMatrixMath::Normalize3x1(LD); @@ -1321,11 +1300,8 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS double maxF7 = 0.0; double F7 = 0.0f; - EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(q1).data()); - EbsdLib::Matrix3X3D g1 = g.transpose(); - - g = EbsdLib::Matrix3X3D(OrientationTransformation::qu2om(q2).data()); - EbsdLib::Matrix3X3D g2 = g.transpose(); + EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); + EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); EbsdMatrixMath::Normalize3x1(LD); @@ -1413,9 +1389,8 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/LaueOps/CubicOps.h b/Source/EbsdLib/LaueOps/CubicOps.h index 02e85654..d727b922 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.h +++ b/Source/EbsdLib/LaueOps/CubicOps.h @@ -141,7 +141,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -149,7 +149,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -164,19 +164,19 @@ class EbsdLib_EXPORT CubicOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& synea) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& synea) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; @@ -304,7 +304,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; /** * @brief generates a misorientation coloring legend @@ -325,7 +325,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param q2 * @return */ - OrientationD calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const override; /** * @brief area preserving projection of volume preserving transformation (for C. Shuch and S. Patala coloring legend generation) diff --git a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp index b9cef754..e920c949 100644 --- a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -85,7 +85,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 0.0, 0.5, -sq32), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 0.5773502691896258}, {0.0, 0.0, 1.0, 1.7320508075688767}, @@ -216,26 +216,16 @@ bool HexagonalLowOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool HexagonalLowOps::isInsideFZ(const OrientationD& rod) const +bool HexagonalLowOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } -OrientationD HexagonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType HexagonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(HexagonalLow::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF HexagonalLowOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(HexagonalLow::QuatSym, q1, q2); - return axisAngle; -} - QuatD HexagonalLowOps::getQuatSymOp(int32_t i) const { return HexagonalLow::QuatSym[i]; @@ -290,7 +280,7 @@ void HexagonalLowOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalLowOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType HexagonalLowOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(HexagonalLow::RodSym, rod); } @@ -298,15 +288,15 @@ OrientationType HexagonalLowOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalLowOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType HexagonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { double w = 0.0, n1 = 0.0, n2 = 0.0, n3 = 0.0; double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; double n1n2mag = 0.0; - OrientationType rod = _calcRodNearestOrigin(HexagonalLow::RodSym, inRod); + RodriguesDType rod = _calcRodNearestOrigin(HexagonalLow::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = rod.toAxisAngle(); n1 = ax[0]; n2 = ax[1], n3 = ax[2], w = ax[3]; @@ -347,7 +337,7 @@ OrientationType HexagonalLowOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, w)); + return AxisAngleDType(FZn1, FZn2, FZn3, w).toRodrigues(); } QuatD HexagonalLowOps::getNearestQuat(const QuatD& q1, const QuatD& q2) const @@ -373,13 +363,13 @@ QuatD HexagonalLowOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexagonalLowOps::getMisoBin(const OrientationType& rod) const +int HexagonalLowOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = HexagonalLow::OdfDimInitValue[0]; dim[1] = HexagonalLow::OdfDimInitValue[1]; @@ -397,7 +387,7 @@ int HexagonalLowOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalLowOps::determineEulerAngles(double random[3], int choose) const +EulerDType HexagonalLowOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -416,28 +406,27 @@ OrientationType HexagonalLowOps::determineEulerAngles(double random[3], int choo _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalLowOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType HexagonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(HexagonalLow::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = HexagonalLow::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalLowOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType HexagonalLowOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -455,8 +444,7 @@ OrientationType HexagonalLowOps::determineRodriguesVector(double random[3], int phi[2] = static_cast(choose / (HexagonalLow::OdfNumBins[0] * HexagonalLow::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -464,13 +452,13 @@ OrientationType HexagonalLowOps::determineRodriguesVector(double random[3], int // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexagonalLowOps::getOdfBin(const OrientationType& rod) const +int HexagonalLowOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = HexagonalLow::OdfDimInitValue[0]; dim[1] = HexagonalLow::OdfDimInitValue[1]; @@ -1128,8 +1116,7 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -1177,13 +1164,12 @@ class GenerateSphereCoordsImpl std::vector GenerateSphereCoordsUsingReferenceDirection(EbsdLib::FloatArrayType::Pointer& eulers, const EbsdLib::Matrix3X1F& referenceDirection) { std::vector allCoords(eulers->getNumberOfTuples() * 2); - EbsdLib::Matrix3X1F direction = referenceDirection.normalize(); + EbsdLib::Matrix3X1D direction = referenceDirection.normalize().to(); for(size_t i = 0; i < eulers->getNumberOfTuples(); ++i) { - OrientationF eu(eulers->getValue(i * 3), eulers->getValue(i * 3 + 1), eulers->getValue(i * 3 + 2)); - auto om = OrientationTransformation::eu2om(eu); - EbsdLib::Matrix3X3F g = om.toGMatrixObj().transpose(); + OrientationMatrixDType om = EulerDType(eulers->getValue(i * 3), eulers->getValue(i * 3 + 1), eulers->getValue(i * 3 + 2)).toOrientationMatrix(); + EbsdLib::Matrix3X3D g = om.toGMatrixObj().transpose(); allCoords[i * 2] = g * direction; allCoords[i * 2 + 1] = allCoords[i * 2] * -1.0; } diff --git a/Source/EbsdLib/LaueOps/HexagonalLowOps.h b/Source/EbsdLib/LaueOps/HexagonalLowOps.h index 41887ed3..6d137574 100644 --- a/Source/EbsdLib/LaueOps/HexagonalLowOps.h +++ b/Source/EbsdLib/LaueOps/HexagonalLowOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -258,7 +258,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/HexagonalOps.cpp b/Source/EbsdLib/LaueOps/HexagonalOps.cpp index b9724f28..5d6119f4 100644 --- a/Source/EbsdLib/LaueOps/HexagonalOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalOps.cpp @@ -40,7 +40,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorUtilities.h" @@ -92,7 +92,7 @@ static const std::vector QuatSym ={ QuatD(-sq32, 0.5, 0.0, 0.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 0.5773502691896258}, {0.0, 0.0, 1.0, 1.7320508075688767}, @@ -256,26 +256,17 @@ bool HexagonalOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool HexagonalOps::isInsideFZ(const OrientationD& rod) const +bool HexagonalOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } // ----------------------------------------------------------------------------- -OrientationD HexagonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType HexagonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(HexagonalHigh::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF HexagonalOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(HexagonalHigh::QuatSym, q1, q2); - return axisAngle; -} - QuatD HexagonalOps::getQuatSymOp(int32_t i) const { return HexagonalHigh::QuatSym[i]; @@ -333,7 +324,7 @@ void HexagonalOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType HexagonalOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(HexagonalHigh::RodSym, rod); } @@ -341,15 +332,15 @@ OrientationType HexagonalOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType HexagonalOps::getMDFFZRod(const RodriguesDType& inRod) const { double w, n1, n2, n3; double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; double n1n2mag; - OrientationType rod = _calcRodNearestOrigin(HexagonalHigh::RodSym, inRod); + RodriguesDType rod = _calcRodNearestOrigin(HexagonalHigh::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = rod.toAxisAngle(); n1 = ax[0]; n2 = ax[1], n3 = ax[2], w = ax[3]; @@ -391,7 +382,7 @@ OrientationType HexagonalOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, w)); + return AxisAngleDType(FZn1, FZn2, FZn3, w).toRodrigues(); } QuatD HexagonalOps::getNearestQuat(const QuatD& q1, const QuatD& q2) const @@ -417,13 +408,13 @@ QuatD HexagonalOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexagonalOps::getMisoBin(const OrientationType& rod) const +int HexagonalOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = HexagonalHigh::OdfDimInitValue[0]; dim[1] = HexagonalHigh::OdfDimInitValue[1]; @@ -441,7 +432,7 @@ int HexagonalOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalOps::determineEulerAngles(double random[3], int choose) const +EulerDType HexagonalOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -460,28 +451,27 @@ OrientationType HexagonalOps::determineEulerAngles(double random[3], int choose) _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType HexagonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(HexagonalHigh::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = HexagonalHigh::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType HexagonalOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType HexagonalOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -499,8 +489,7 @@ OrientationType HexagonalOps::determineRodriguesVector(double random[3], int cho phi[2] = static_cast(choose / (HexagonalHigh::OdfNumBins[0] * HexagonalHigh::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -508,13 +497,13 @@ OrientationType HexagonalOps::determineRodriguesVector(double random[3], int cho // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int HexagonalOps::getOdfBin(const OrientationType& rod) const +int HexagonalOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = HexagonalHigh::OdfDimInitValue[0]; dim[1] = HexagonalHigh::OdfDimInitValue[1]; @@ -1172,8 +1161,7 @@ class GenerateSphereCoordsImpl // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/HexagonalOps.h b/Source/EbsdLib/LaueOps/HexagonalOps.h index 27efcc71..455f2ea5 100644 --- a/Source/EbsdLib/LaueOps/HexagonalOps.h +++ b/Source/EbsdLib/LaueOps/HexagonalOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -258,7 +258,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/LaueOps.cpp b/Source/EbsdLib/LaueOps/LaueOps.cpp index 14728de5..04615399 100644 --- a/Source/EbsdLib/LaueOps/LaueOps.cpp +++ b/Source/EbsdLib/LaueOps/LaueOps.cpp @@ -165,20 +165,22 @@ EbsdLib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degTo double eta = 0.0f; double _rgb[3] = {0.0, 0.0, 0.0}; - OrientationType eu(eulers, 3); + EulerDType eu(eulers[0], eulers[1], eulers[2]); if(degToRad) { eu[0] = eu[0] * EbsdLib::Constants::k_DegToRadD; eu[1] = eu[1] * EbsdLib::Constants::k_DegToRadD; eu[2] = eu[2] * EbsdLib::Constants::k_DegToRadD; } - OrientationType om(9); // Reusable for the loop - QuatD q1 = OrientationTransformation::eu2qu(eu); + OrientationMatrixDType om; // Reusable for the loop + QuatD q1 = eu.toQuat(); for(int j = 0; j < getNumSymOps(); j++) { - QuatD qu = getQuatSymOp(j) * q1; - EbsdLib::Matrix3X3D g(OrientationTransformation::qu2om(qu).data()); + // QuatD qu = getQuatSymOp(j) * q1; + QuaternionDType qu(getQuatSymOp(j) * q1); + om = qu.toOrientationMatrix(); + EbsdLib::Matrix3X3D g(om.data()); EbsdLib::Matrix3X1D p = (g * refDirection).normalize(); if(!getHasInversion() && p[2] < 0) @@ -227,9 +229,9 @@ EbsdLib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degTo } // ----------------------------------------------------------------------------- -void LaueOps::RodriguesComposition(OrientationD sigma, OrientationD& rod) +void LaueOps::RodriguesComposition(RodriguesDType sigma, RodriguesDType& rod) { - OrientationD rho(3), rhomis(3); + std::array rho; rho[0] = -rod[0] * rod[3]; rho[1] = -rod[1] * rod[3]; rho[2] = -rod[2] * rod[3]; @@ -246,6 +248,7 @@ void LaueOps::RodriguesComposition(OrientationD sigma, OrientationD& rod) } else { + std::array rhomis; rhomis[0] = (rho[0] - sigma[0] + (rho[1] * sigma[2] - rho[2] * sigma[1])) / denom; rhomis[1] = (rho[1] - sigma[1] + (rho[2] * sigma[0] - rho[0] * sigma[2])) / denom; rhomis[2] = (rho[2] - sigma[2] + (rho[0] * sigma[1] - rho[1] * sigma[0])) / denom; @@ -269,7 +272,7 @@ void LaueOps::RodriguesComposition(OrientationD sigma, OrientationD& rod) } // ----------------------------------------------------------------------------- -bool LaueOps::InsideCyclicFZ(const OrientationD& rod, FZType fzType, AxisOrderingType order) +bool LaueOps::InsideCyclicFZ(const RodriguesDType& rod, FZType fzType, AxisOrderingType order) { bool res = false; bool doM = false; @@ -343,7 +346,7 @@ bool LaueOps::InsideCyclicFZ(const OrientationD& rod, FZType fzType, AxisOrderin } // ----------------------------------------------------------------------------- -bool LaueOps::InsideDihedralFZ(const OrientationD& rod, const AxisOrderingType order) +bool LaueOps::InsideDihedralFZ(const RodriguesDType& rod, const AxisOrderingType order) { constexpr double eps = 1.0e-10; @@ -408,7 +411,7 @@ bool LaueOps::InsideDihedralFZ(const OrientationD& rod, const AxisOrderingType o } // ----------------------------------------------------------------------------- -bool LaueOps::InsideCubicFZ(const OrientationD& rod, const FZType fzType) +bool LaueOps::InsideCubicFZ(const RodriguesDType& rod, const FZType fzType) { bool res = false; bool c1 = false; @@ -444,7 +447,7 @@ bool LaueOps::InsideCubicFZ(const OrientationD& rod, const FZType fzType) } // ----------------------------------------------------------------------------- -bool LaueOps::IsInsideFZ(const OrientationD& rod, FZType fzType, AxisOrderingType order) +bool LaueOps::IsInsideFZ(const RodriguesDType& rod, FZType fzType, AxisOrderingType order) { bool insideFZ = false; // dealing with 180 rotations is needed only for @@ -484,14 +487,14 @@ bool LaueOps::IsInsideFZ(const OrientationD& rod, FZType fzType, AxisOrderingTyp bool LaueOps::IsInsideFZ(const QuatD& quat, FZType fzType, AxisOrderingType order) { - const OrientationD rod = OrientationTransformation::qu2ro(quat.getPositiveOrientation()); + const RodriguesDType rod = QuaternionDType(quat.getPositiveOrientation()).toRodrigues(); return IsInsideFZ(rod, fzType, order); } // ----------------------------------------------------------------------------- -OrientationD LaueOps::calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const +AxisAngleDType LaueOps::calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const { - OrientationD axisAngleMin(0.0, 0.0, 0.0, std::numeric_limits::max()); + AxisAngleDType axisAngleMin(0.0, 0.0, 0.0, std::numeric_limits::max()); const QuatD qr = q1 * (q2.conjugate()); size_t numsym = quatsym.size(); // Loop through all the symmetry operators and find the Axis Angle with the smallest angular part. @@ -508,7 +511,7 @@ OrientationD LaueOps::calculateMisorientationInternal(const std::vector& qc.w() = 1.0; } - OrientationD axisAngle = OrientationTransformation::qu2ax(qc); + AxisAngleDType axisAngle = QuaternionDType(qc).toAxisAngle(); if(axisAngle[3] > EbsdLib::Constants::k_PiD) { axisAngle[3] = EbsdLib::Constants::k_2PiD - axisAngle[3]; @@ -539,14 +542,14 @@ OrientationD LaueOps::calculateMisorientationInternal(const std::vector& // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType LaueOps::_calcRodNearestOrigin(const std::vector& rodsym, const OrientationType& inRod) const +RodriguesDType LaueOps::_calcRodNearestOrigin(const std::vector& rodsym, const RodriguesDType& inRod) const { double denom = 0.0f, dist = 0.0f; double smallestdist = 100000000.0f; double rc1 = 0.0f, rc2 = 0.0f, rc3 = 0.0f; - OrientationType outRod(4, 0.0f); + RodriguesDType outRod; // Turn into an actual 3 Comp Rodrigues Vector - OrientationType rod = inRod; + RodriguesDType rod = inRod; rod[0] *= rod[3]; rod[1] *= rod[3]; rod[2] *= rod[3]; @@ -616,7 +619,7 @@ QuatD LaueOps::ConvertToFZ(const std::vector& quatsym, const QuatD& qr, F { // Ensure the Quaternion is Normalized and the Scalar Part is positive QuatD normalizedQuat = qr.getPositiveOrientation(); - OrientationD rod = OrientationTransformation::qu2ro(normalizedQuat); + RodriguesDType rod = QuaternionDType(normalizedQuat).toRodrigues(); if(IsInsideFZ(rod, fzType, order)) { @@ -628,7 +631,7 @@ QuatD LaueOps::ConvertToFZ(const std::vector& quatsym, const QuatD& qr, F { QuatD qc = quatsym[i] * qr; normalizedQuat = qc.getPositiveOrientation(); - rod = OrientationTransformation::qu2ro(normalizedQuat); + rod = QuaternionDType(normalizedQuat).toRodrigues(); if(normalizedQuat.w() < 1.0E5 && IsInsideFZ(rod, fzType, order)) { @@ -640,7 +643,7 @@ QuatD LaueOps::ConvertToFZ(const std::vector& quatsym, const QuatD& qr, F return {std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()}; } -int LaueOps::_calcMisoBin(double dim[3], double bins[3], double step[3], const OrientationType& ho) const +int LaueOps::_calcMisoBin(double dim[3], double bins[3], double step[3], const HomochoricDType& ho) const { int miso1bin = static_cast((ho[0] + dim[0]) / step[0]); int miso2bin = static_cast((ho[1] + dim[1]) / step[1]); @@ -682,7 +685,7 @@ void LaueOps::_calcDetermineHomochoricValues(double random[3], double init[3], d // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int LaueOps::_calcODFBin(double dim[3], double bins[3], double step[3], const OrientationType& ho) const +int LaueOps::_calcODFBin(double dim[3], double bins[3], double step[3], const HomochoricDType& ho) const { int g1euler1bin = static_cast((ho[0] + dim[0]) / step[0]); int g1euler2bin = static_cast((ho[1] + dim[1]) / step[1]); diff --git a/Source/EbsdLib/LaueOps/LaueOps.h b/Source/EbsdLib/LaueOps/LaueOps.h index bc165b93..821048ca 100644 --- a/Source/EbsdLib/LaueOps/LaueOps.h +++ b/Source/EbsdLib/LaueOps/LaueOps.h @@ -39,7 +39,7 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" @@ -157,7 +157,7 @@ class EbsdLib_EXPORT LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const = 0; + virtual EbsdLib::AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const = 0; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -165,7 +165,7 @@ class EbsdLib_EXPORT LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const = 0; + // virtual AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const = 0; /** * @brief getQuatSymOp Returns the symmetry operator at index i @@ -197,14 +197,14 @@ class EbsdLib_EXPORT LaueOps * @param rod * @return */ - virtual OrientationType getODFFZRod(const OrientationType& rod) const = 0; + virtual RodriguesDType getODFFZRod(const RodriguesDType& rod) const = 0; /** * @brief getMDFFZRod * @param rod * @return */ - virtual OrientationType getMDFFZRod(const OrientationType& rod) const = 0; + virtual RodriguesDType getMDFFZRod(const RodriguesDType& rod) const = 0; virtual QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const = 0; virtual QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const = 0; @@ -221,19 +221,19 @@ class EbsdLib_EXPORT LaueOps * @param rod * @return */ - virtual int getMisoBin(const OrientationType& rod) const = 0; + virtual int getMisoBin(const RodriguesDType& rod) const = 0; virtual bool inUnitTriangle(double eta, double chi) const = 0; - virtual OrientationType determineEulerAngles(double random[3], int choose) const = 0; + virtual EulerDType determineEulerAngles(double random[3], int choose) const = 0; - virtual OrientationType randomizeEulerAngles(const OrientationType& euler) const = 0; + virtual EulerDType randomizeEulerAngles(const EulerDType& euler) const = 0; virtual size_t getRandomSymmetryOperatorIndex(int numSymOps) const; - virtual OrientationType determineRodriguesVector(double random[3], int choose) const = 0; + virtual RodriguesDType determineRodriguesVector(double random[3], int choose) const = 0; - virtual int getOdfBin(const OrientationType& rod) const = 0; + virtual int getOdfBin(const RodriguesDType& rod) const = 0; virtual void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const = 0; @@ -249,7 +249,7 @@ class EbsdLib_EXPORT LaueOps virtual void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const = 0; - static void RodriguesComposition(OrientationD sigma, OrientationD& rod); + static void RodriguesComposition(RodriguesDType sigma, RodriguesDType& rod); /** * @brief @@ -375,7 +375,7 @@ class EbsdLib_EXPORT LaueOps * @param order The Axis Ordering Type * @return */ - static bool InsideCyclicFZ(const OrientationD& rod, FZType fzType, AxisOrderingType order); + static bool InsideCyclicFZ(const RodriguesDType& rod, FZType fzType, AxisOrderingType order); /** * @brief Determines if the given 4 component Rodrigues Vector is inside a dihedral fundamental zone @@ -383,7 +383,7 @@ class EbsdLib_EXPORT LaueOps * @param order The Axis Ordering Type * @return */ - static bool InsideDihedralFZ(const OrientationD& rod, AxisOrderingType order); + static bool InsideDihedralFZ(const RodriguesDType& rod, AxisOrderingType order); /** * @brief Determines if the given 4 component Rodrigues Vector is inside a cubic fundamental zone @@ -391,7 +391,7 @@ class EbsdLib_EXPORT LaueOps * @param fzType The Fundamental Zone type * @return */ - static bool InsideCubicFZ(const OrientationD& rod, FZType fzType); + static bool InsideCubicFZ(const RodriguesDType& rod, FZType fzType); /** * @brief Determines if the given 4 component Rodrigues Vector is inside the fundamental zone @@ -400,7 +400,7 @@ class EbsdLib_EXPORT LaueOps * @param order The Axis Ordering Type * @return */ - static bool IsInsideFZ(const OrientationD& rod, FZType fzType, AxisOrderingType order); + static bool IsInsideFZ(const RodriguesDType& rod, FZType fzType, AxisOrderingType order); /** * @brief Determines if the given Quaternion Vector is inside the fundamental zone. @@ -426,7 +426,7 @@ class EbsdLib_EXPORT LaueOps * @param rod Input Rodrigues Vector * @return */ - virtual bool isInsideFZ(const OrientationD& rod) const = 0; + virtual bool isInsideFZ(const RodriguesDType& rod) const = 0; protected: LaueOps(); @@ -438,7 +438,7 @@ class EbsdLib_EXPORT LaueOps * @param q2 Input Quaternion 2 * @return Returns Axis-Angle W form. */ - virtual OrientationD calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const; + virtual AxisAngleDType calculateMisorientationInternal(const std::vector& quatsym, const QuatD& q1, const QuatD& q2) const; /** * @brief @@ -446,7 +446,7 @@ class EbsdLib_EXPORT LaueOps * @param rod * @return */ - OrientationType _calcRodNearestOrigin(const std::vector& rodsym, const OrientationType& rod) const; + RodriguesDType _calcRodNearestOrigin(const std::vector& rodsym, const RodriguesDType& rod) const; /** * @brief @@ -465,7 +465,7 @@ class EbsdLib_EXPORT LaueOps * @param homochoric * @return */ - int _calcMisoBin(double dim[3], double bins[3], double step[3], const OrientationType& homochoric) const; + int _calcMisoBin(double dim[3], double bins[3], double step[3], const HomochoricDType& homochoric) const; /** * @brief @@ -487,7 +487,7 @@ class EbsdLib_EXPORT LaueOps * @param homochoric * @return */ - int _calcODFBin(double dim[3], double bins[3], double step[3], const OrientationType& homochoric) const; + int _calcODFBin(double dim[3], double bins[3], double step[3], const HomochoricDType& homochoric) const; /** * @brief Generates an IPF Color for a given Euler and Reference Direction. This should be called from the subclass so the diff --git a/Source/EbsdLib/LaueOps/MonoclinicOps.cpp b/Source/EbsdLib/LaueOps/MonoclinicOps.cpp index 8e671e3e..25d0fb60 100644 --- a/Source/EbsdLib/LaueOps/MonoclinicOps.cpp +++ b/Source/EbsdLib/LaueOps/MonoclinicOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -78,7 +78,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 1.0, 0.0, 0.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 1.0, 0.0, 10000000000000.0}, }; @@ -189,7 +189,7 @@ bool MonoclinicOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool MonoclinicOps::isInsideFZ(const OrientationD& rod) const +bool MonoclinicOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } @@ -197,21 +197,11 @@ bool MonoclinicOps::isInsideFZ(const OrientationD& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationD MonoclinicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType MonoclinicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(Monoclinic::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF MonoclinicOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(Monoclinic::QuatSym, q1, q2); - return axisAngle; -} - QuatD MonoclinicOps::getQuatSymOp(int32_t i) const { return Monoclinic::QuatSym[i]; @@ -266,7 +256,7 @@ void MonoclinicOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType MonoclinicOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType MonoclinicOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(Monoclinic::RodSym, rod); } @@ -274,7 +264,7 @@ OrientationType MonoclinicOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType MonoclinicOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType MonoclinicOps::getMDFFZRod(const RodriguesDType& inRod) const { throw EbsdLib::method_not_implemented("MonoclinicOps::getMDFFZRod not implemented"); // /// FIXME: Are we missing code for MonoclinicOps MDF FZ Rodrigues calculation? @@ -283,12 +273,12 @@ OrientationType MonoclinicOps::getMDFFZRod(const OrientationType& inRod) const // double FZw = 0.0, FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0; // // OrientationType rod = LaueOps::_calcRodNearestOrigin(Monoclinic::RodSym, inRod); - // OrientationType ax = OrientationTransformation::ro2ax(rod); + // AxisAngleDType ax = rod.toAxisAngle(); // n1 = ax[0]; // n2 = ax[1], n3 = ax[2], w = ax[3]; // // - // return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + // return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -315,13 +305,13 @@ QuatD MonoclinicOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int MonoclinicOps::getMisoBin(const OrientationType& rod) const +int MonoclinicOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - auto ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = Monoclinic::OdfDimInitValue[0]; dim[1] = Monoclinic::OdfDimInitValue[1]; @@ -339,7 +329,7 @@ int MonoclinicOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType MonoclinicOps::determineEulerAngles(double random[3], int choose) const +EulerDType MonoclinicOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -359,28 +349,26 @@ OrientationType MonoclinicOps::determineEulerAngles(double random[3], int choose _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - auto ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - auto eu = OrientationTransformation::ro2eu(ro); - return eu; + return ro.toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType MonoclinicOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType MonoclinicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(Monoclinic::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = Monoclinic::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType MonoclinicOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType MonoclinicOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -398,8 +386,7 @@ OrientationType MonoclinicOps::determineRodriguesVector(double random[3], int ch phi[2] = static_cast(choose / (Monoclinic::OdfNumBins[0] * Monoclinic::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - auto ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -407,13 +394,13 @@ OrientationType MonoclinicOps::determineRodriguesVector(double random[3], int ch // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int MonoclinicOps::getOdfBin(const OrientationType& rod) const +int MonoclinicOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - auto ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = Monoclinic::OdfDimInitValue[0]; dim[1] = Monoclinic::OdfDimInitValue[1]; @@ -531,8 +518,7 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/MonoclinicOps.h b/Source/EbsdLib/LaueOps/MonoclinicOps.h index 64615b12..59393e5e 100644 --- a/Source/EbsdLib/LaueOps/MonoclinicOps.h +++ b/Source/EbsdLib/LaueOps/MonoclinicOps.h @@ -141,7 +141,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -149,7 +149,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -164,19 +164,19 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -257,7 +257,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp b/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp index 441d21e4..9e951121 100644 --- a/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp +++ b/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp @@ -37,7 +37,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -81,7 +81,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 0.0, 1.0, 0.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {1.0, 0.0, 0.0, 10000000000000.0}, {0.0, 1.0, 0.0, 10000000000000.0}, @@ -201,26 +201,16 @@ bool OrthoRhombicOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool OrthoRhombicOps::isInsideFZ(const OrientationD& rod) const +bool OrthoRhombicOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } -OrientationD OrthoRhombicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType OrthoRhombicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(OrthoRhombic::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF OrthoRhombicOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(OrthoRhombic::QuatSym, q1, q2); - return axisAngle; -} - QuatD OrthoRhombicOps::getQuatSymOp(int32_t i) const { return OrthoRhombic::QuatSym[i]; @@ -275,7 +265,7 @@ void OrthoRhombicOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType OrthoRhombicOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType OrthoRhombicOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(OrthoRhombic::RodSym, rod); } @@ -283,14 +273,14 @@ OrientationType OrthoRhombicOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType OrthoRhombicOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType OrthoRhombicOps::getMDFFZRod(const RodriguesDType& inRod) const { throw EbsdLib::method_not_implemented("OrthoRhombicOps::getMDFFZRod not implemented"); double FZn1 = 0.0f, FZn2 = 0.0f, FZn3 = 0.0f, FZw = 0.0f; - OrientationType rod = _calcRodNearestOrigin(OrthoRhombic::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + RodriguesDType rod = _calcRodNearestOrigin(OrthoRhombic::RodSym, inRod); + AxisAngleDType ax = rod.toAxisAngle(); // double n1 = ax[0]; // double n2 = ax[1]; // double n3 = ax[2]; @@ -298,7 +288,7 @@ OrientationType OrthoRhombicOps::getMDFFZRod(const OrientationType& inRod) const /// FIXME: Are we missing code for OrthoRhombic MDF FZ Rodrigues calculation? - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -325,12 +315,12 @@ QuatD OrthoRhombicOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int OrthoRhombicOps::getMisoBin(const OrientationType& rod) const +int OrthoRhombicOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = OrthoRhombic::OdfDimInitValue[0]; dim[1] = OrthoRhombic::OdfDimInitValue[1]; @@ -348,7 +338,7 @@ int OrthoRhombicOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType OrthoRhombicOps::determineEulerAngles(double random[3], int choose) const +EulerDType OrthoRhombicOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -367,28 +357,27 @@ OrientationType OrthoRhombicOps::determineEulerAngles(double random[3], int choo _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType OrthoRhombicOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType OrthoRhombicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(OrthoRhombic::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = OrthoRhombic::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType OrthoRhombicOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType OrthoRhombicOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -406,8 +395,7 @@ OrientationType OrthoRhombicOps::determineRodriguesVector(double random[3], int phi[2] = static_cast(choose / (OrthoRhombic::OdfNumBins[0] * OrthoRhombic::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -415,13 +403,13 @@ OrientationType OrthoRhombicOps::determineRodriguesVector(double random[3], int // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int OrthoRhombicOps::getOdfBin(const OrientationType& rod) const +int OrthoRhombicOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = OrthoRhombic::OdfDimInitValue[0]; dim[1] = OrthoRhombic::OdfDimInitValue[1]; @@ -538,8 +526,7 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/OrthoRhombicOps.h b/Source/EbsdLib/LaueOps/OrthoRhombicOps.h index a8eb0125..1117d6bd 100644 --- a/Source/EbsdLib/LaueOps/OrthoRhombicOps.h +++ b/Source/EbsdLib/LaueOps/OrthoRhombicOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -259,7 +259,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/SO3Sampler.cpp b/Source/EbsdLib/LaueOps/SO3Sampler.cpp index f2831725..bfc39928 100644 --- a/Source/EbsdLib/LaueOps/SO3Sampler.cpp +++ b/Source/EbsdLib/LaueOps/SO3Sampler.cpp @@ -32,29 +32,24 @@ #include "SO3Sampler.h" #include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/Core/EbsdMacros.h" #include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Math/ArrayHelpers.hpp" -#include "EbsdLib/Math/EbsdLibMath.h" - -using OrientationType = Orientation; namespace { -const int AnorthicType = 0; // Triclinic -const int CyclicType = 1; -const int DihedralType = 2; -const int TetrahedralType = 3; -const int OctahedralType = 4; +constexpr int AnorthicType = 0; // Triclinic +constexpr int CyclicType = 1; +constexpr int DihedralType = 2; +constexpr int TetrahedralType = 3; +constexpr int OctahedralType = 4; } // namespace namespace { -const int NoAxisOrder = 0; -const int TwoFoldAxisOrder = 2; -const int ThreeFoldAxisOrder = 3; -const int FourFoldAxisOrder = 4; -const int SixFoldAxisOrder = 6; +constexpr int NoAxisOrder = 0; +constexpr int TwoFoldAxisOrder = 2; +constexpr int ThreeFoldAxisOrder = 3; +constexpr int FourFoldAxisOrder = 4; +constexpr int SixFoldAxisOrder = 6; } // namespace // Following numbers are coefficients used to calculate the exponential of a matrix @@ -177,7 +172,7 @@ SO3Sampler::~SO3Sampler() = default; //> @date 01/01/15 MDG 1.0 new routine, needed for dictionary indexing approach //> @date 06/04/15 MDG 1.1 corrected infty to inftyd (double precision infinity) //-------------------------------------------------------------------------- -bool SO3Sampler::IsinsideFZ(double* rod, int FZtype, int FZorder) +bool SO3Sampler::IsinsideFZ(const EbsdLib::RodriguesDType& rod, int FZtype, int FZorder) { bool insideFZ = false; // dealing with 180 rotations is needed only for @@ -230,7 +225,7 @@ bool SO3Sampler::IsinsideFZ(double* rod, int FZtype, int FZorder) //> @date 10/02/14 MDG 2.0 rewrite //> @date 06/04/15 MDG 2.1 corrected infty to inftyd (double precision infinity) //-------------------------------------------------------------------------- -bool SO3Sampler::insideCyclicFZ(double* rod, int order) +bool SO3Sampler::insideCyclicFZ(const EbsdLib::RodriguesDType& rod, int order) { bool insideFZ = false; @@ -264,7 +259,7 @@ bool SO3Sampler::insideCyclicFZ(double* rod, int order) //> @date 05/12/14 MDG 1.0 original //> @date 10/02/14 MDG 2.0 rewrite //-------------------------------------------------------------------------- -bool SO3Sampler::insideDihedralFZ(double* rod, int order) +bool SO3Sampler::insideDihedralFZ(const EbsdLib::RodriguesDType& rod, int order) { bool res = false, c1 = false, c2 = false; @@ -325,7 +320,7 @@ bool SO3Sampler::insideDihedralFZ(double* rod, int order) //> @date 01/03/15 MDG 2.1 correction of boundary error; simplification of octahedral planes //> @date 06/04/15 MDG 2.2 simplified handling of components of r //-------------------------------------------------------------------------- -bool SO3Sampler::insideCubicFZ(double* rod, int ot) +bool SO3Sampler::insideCubicFZ(const EbsdLib::RodriguesDType& rod, int ot) { bool res = false, c1 = false, c2 = false; std::vector r(3); @@ -440,12 +435,11 @@ SO3Sampler::OrientationListArrayType SO3Sampler::SampleRFZ(int nsteps, int pgnum z = static_cast(k) * delta; // convert to Rodrigues representation - OrientationType cu(x, y, z); - OrientationType rod = OrientationTransformation::cu2ro(cu); + EbsdLib::RodriguesDType rod = EbsdLib::CubochoricDType(x, y, z).toRodrigues(); // If insideFZ=true, then add this point to the linked list FZlist and keep // track of how many points there are on this list - bool b = IsinsideFZ(rod.data(), FZtype, FZorder); + bool b = IsinsideFZ(rod, FZtype, FZorder); if(b) { FZlist.push_back(rod); diff --git a/Source/EbsdLib/LaueOps/SO3Sampler.h b/Source/EbsdLib/LaueOps/SO3Sampler.h index 89968e6b..ea1b1e24 100644 --- a/Source/EbsdLib/LaueOps/SO3Sampler.h +++ b/Source/EbsdLib/LaueOps/SO3Sampler.h @@ -35,7 +35,7 @@ #include #include -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdLibMath.h" @@ -69,7 +69,7 @@ class EbsdLib_EXPORT SO3Sampler /** * @brief OrientationListArrayType */ - using OrientationListArrayType = std::list; + using OrientationListArrayType = std::list; // sampler routine OrientationListArrayType SampleRFZ(int nsteps, int pgnum); @@ -81,7 +81,7 @@ class EbsdLib_EXPORT SO3Sampler * @param FZorder * @return */ - bool IsinsideFZ(double* rod, int FZtype, int FZorder); + bool IsinsideFZ(const EbsdLib::RodriguesDType& rod, int FZtype, int FZorder); /** * @brief insideCubicFZ @@ -89,7 +89,7 @@ class EbsdLib_EXPORT SO3Sampler * @param symType * @return */ - bool insideCubicFZ(double* rod, int symType); + bool insideCubicFZ(const EbsdLib::RodriguesDType& rod, int symType); /** * @brief insideCyclicFZ @@ -97,7 +97,7 @@ class EbsdLib_EXPORT SO3Sampler * @param order * @return */ - bool insideCyclicFZ(double* rod, int order); + bool insideCyclicFZ(const EbsdLib::RodriguesDType& rod, int order); /** * @brief insideDihedralFZ @@ -105,9 +105,8 @@ class EbsdLib_EXPORT SO3Sampler * @param order * @return */ - bool insideDihedralFZ(double* rod, int order); + bool insideDihedralFZ(const EbsdLib::RodriguesDType& rod, int order); -private: protected: SO3Sampler(); diff --git a/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp b/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp index 4ca871d8..def43016 100644 --- a/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp @@ -37,7 +37,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -79,7 +79,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 0.0, -0.7071067811865476, 0.7071067811865476), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 10000000000000.0}, {0.0, 0.0, 1.0, 1.0}, @@ -200,25 +200,16 @@ bool TetragonalLowOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool TetragonalLowOps::isInsideFZ(const OrientationD& rod) const +bool TetragonalLowOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } -OrientationD TetragonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType TetragonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(TetragonalLow::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF TetragonalLowOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(TetragonalLow::QuatSym, q1, q2); - return axisAngle; -} - QuatD TetragonalLowOps::getQuatSymOp(int32_t i) const { return TetragonalLow::QuatSym[i]; @@ -273,26 +264,26 @@ void TetragonalLowOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalLowOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType TetragonalLowOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(TetragonalLow::RodSym, rod); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalLowOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType TetragonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; - OrientationType rod = _calcRodNearestOrigin(TetragonalLow::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + RodriguesDType rod = _calcRodNearestOrigin(TetragonalLow::RodSym, inRod); + AxisAngleDType ax = rod.toAxisAngle(); FZn1 = std::fabs(ax[0]); FZn2 = std::fabs(ax[1]); FZn3 = std::fabs(ax[2]); FZw = ax[3]; - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -318,13 +309,13 @@ QuatD TetragonalLowOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TetragonalLowOps::getMisoBin(const OrientationType& rod) const +int TetragonalLowOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TetragonalLow::OdfDimInitValue[0]; dim[1] = TetragonalLow::OdfDimInitValue[1]; @@ -342,7 +333,7 @@ int TetragonalLowOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalLowOps::determineEulerAngles(double random[3], int choose) const +EulerDType TetragonalLowOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -361,28 +352,27 @@ OrientationType TetragonalLowOps::determineEulerAngles(double random[3], int cho _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalLowOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType TetragonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TetragonalLow::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = TetragonalLow::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalLowOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType TetragonalLowOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -400,8 +390,7 @@ OrientationType TetragonalLowOps::determineRodriguesVector(double random[3], int phi[2] = static_cast(choose / (TetragonalLow::OdfNumBins[0] * TetragonalLow::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -409,13 +398,13 @@ OrientationType TetragonalLowOps::determineRodriguesVector(double random[3], int // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TetragonalLowOps::getOdfBin(const OrientationType& rod) const +int TetragonalLowOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TetragonalLow::OdfDimInitValue[0]; dim[1] = TetragonalLow::OdfDimInitValue[1]; @@ -533,8 +522,7 @@ class GenerateSphereCoordsImpl for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/TetragonalLowOps.h b/Source/EbsdLib/LaueOps/TetragonalLowOps.h index 2736ad17..cdb4d798 100644 --- a/Source/EbsdLib/LaueOps/TetragonalLowOps.h +++ b/Source/EbsdLib/LaueOps/TetragonalLowOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -259,7 +259,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/TetragonalOps.cpp b/Source/EbsdLib/LaueOps/TetragonalOps.cpp index d83b6ba2..a3d0f3fc 100644 --- a/Source/EbsdLib/LaueOps/TetragonalOps.cpp +++ b/Source/EbsdLib/LaueOps/TetragonalOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -85,7 +85,7 @@ static const std::vector QuatSym ={ QuatD(-0.7071067811865476, 0.7071067811865476, 0.0, 0.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 10000000000000.0}, {0.0, 0.0, 1.0, 1.0}, @@ -226,27 +226,17 @@ bool TetragonalOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool TetragonalOps::isInsideFZ(const OrientationD& rod) const +bool TetragonalOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } // ----------------------------------------------------------------------------- -OrientationD TetragonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType TetragonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(TetragonalHigh::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF TetragonalOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(TetragonalHigh::QuatSym, q1, q2); - return axisAngle; -} - QuatD TetragonalOps::getQuatSymOp(int32_t i) const { return TetragonalHigh::QuatSym[i]; @@ -301,7 +291,7 @@ void TetragonalOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType TetragonalOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(TetragonalHigh::RodSym, rod); } @@ -309,20 +299,20 @@ OrientationType TetragonalOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType TetragonalOps::getMDFFZRod(const RodriguesDType& inRod) const { double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; - OrientationType rod = _calcRodNearestOrigin(TetragonalHigh::RodSym, inRod); + RodriguesDType rod = _calcRodNearestOrigin(TetragonalHigh::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = rod.toAxisAngle(); FZn1 = std::fabs(ax[0]); FZn2 = std::fabs(ax[1]); FZn3 = std::fabs(ax[2]); FZw = ax[3]; - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -348,13 +338,13 @@ QuatD TetragonalOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TetragonalOps::getMisoBin(const OrientationType& rod) const +int TetragonalOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TetragonalHigh::OdfDimInitValue[0]; dim[1] = TetragonalHigh::OdfDimInitValue[1]; @@ -372,7 +362,7 @@ int TetragonalOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalOps::determineEulerAngles(double random[3], int choose) const +EulerDType TetragonalOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -391,28 +381,27 @@ OrientationType TetragonalOps::determineEulerAngles(double random[3], int choose _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType TetragonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TetragonalHigh::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = TetragonalHigh::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TetragonalOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType TetragonalOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -430,8 +419,7 @@ OrientationType TetragonalOps::determineRodriguesVector(double random[3], int ch phi[2] = static_cast(choose / (TetragonalHigh::OdfNumBins[0] * TetragonalHigh::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -439,13 +427,13 @@ OrientationType TetragonalOps::determineRodriguesVector(double random[3], int ch // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TetragonalOps::getOdfBin(const OrientationType& rod) const +int TetragonalOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TetragonalHigh::OdfDimInitValue[0]; dim[1] = TetragonalHigh::OdfDimInitValue[1]; @@ -562,8 +550,7 @@ class GenerateSphereCoordsImpl // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/TetragonalOps.h b/Source/EbsdLib/LaueOps/TetragonalOps.h index 90ceeaf9..1d747527 100644 --- a/Source/EbsdLib/LaueOps/TetragonalOps.h +++ b/Source/EbsdLib/LaueOps/TetragonalOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -259,7 +259,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/TriclinicOps.cpp b/Source/EbsdLib/LaueOps/TriclinicOps.cpp index 7e4733f8..a94f3ad9 100644 --- a/Source/EbsdLib/LaueOps/TriclinicOps.cpp +++ b/Source/EbsdLib/LaueOps/TriclinicOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -79,7 +79,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 0.0, 0.0, 1.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, }; @@ -186,7 +186,7 @@ bool TriclinicOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool TriclinicOps::isInsideFZ(const OrientationD& rod) const +bool TriclinicOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } @@ -194,20 +194,11 @@ bool TriclinicOps::isInsideFZ(const OrientationD& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationD TriclinicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType TriclinicOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(Triclinic::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF TriclinicOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(Triclinic::QuatSym, q1, q2); - return axisAngle; -} - QuatD TriclinicOps::getQuatSymOp(int32_t i) const { return Triclinic::QuatSym[i]; @@ -261,7 +252,7 @@ void TriclinicOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TriclinicOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType TriclinicOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(Triclinic::RodSym, rod); } @@ -269,16 +260,16 @@ OrientationType TriclinicOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TriclinicOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType TriclinicOps::getMDFFZRod(const RodriguesDType& inRod) const { throw EbsdLib::method_not_implemented("TriclinicOps::getMDFFZRod not implemented"); - OrientationType rod = LaueOps::_calcRodNearestOrigin(Triclinic::RodSym, inRod); + RodriguesDType rod = LaueOps::_calcRodNearestOrigin(Triclinic::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = rod.toAxisAngle(); /// FIXME: Are we missing code for TriclinicOps MDF FZ Rodrigues calculation? - return OrientationTransformation::ax2ro(ax); + return ax.toRodrigues(); } // ----------------------------------------------------------------------------- @@ -304,13 +295,13 @@ QuatD TriclinicOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TriclinicOps::getMisoBin(const OrientationType& rod) const +int TriclinicOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = Triclinic::OdfDimInitValue[0]; dim[1] = Triclinic::OdfDimInitValue[1]; @@ -328,7 +319,7 @@ int TriclinicOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TriclinicOps::determineEulerAngles(double random[3], int choose) const +EulerDType TriclinicOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -347,28 +338,27 @@ OrientationType TriclinicOps::determineEulerAngles(double random[3], int choose) _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TriclinicOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType TriclinicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(Triclinic::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = Triclinic::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TriclinicOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType TriclinicOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -386,8 +376,7 @@ OrientationType TriclinicOps::determineRodriguesVector(double random[3], int cho phi[2] = static_cast(choose / (Triclinic::OdfNumBins[0] * Triclinic::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -395,13 +384,13 @@ OrientationType TriclinicOps::determineRodriguesVector(double random[3], int cho // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TriclinicOps::getOdfBin(const OrientationType& rod) const +int TriclinicOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = Triclinic::OdfDimInitValue[0]; dim[1] = Triclinic::OdfDimInitValue[1]; @@ -519,8 +508,7 @@ class GenerateSphereCoordsImpl // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/TriclinicOps.h b/Source/EbsdLib/LaueOps/TriclinicOps.h index 49301197..0bdaf48b 100644 --- a/Source/EbsdLib/LaueOps/TriclinicOps.h +++ b/Source/EbsdLib/LaueOps/TriclinicOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -259,7 +259,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp b/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp index 2b01cbce..66177972 100644 --- a/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -83,7 +83,7 @@ static const std::vector QuatSym ={ QuatD(0.0, 0.0, sq32, -0.5), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 1.7320508075688767}, {0.0, 0.0, sq32, 10000000000000.0}, @@ -198,26 +198,16 @@ bool TrigonalLowOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool TrigonalLowOps::isInsideFZ(const OrientationD& rod) const +bool TrigonalLowOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } -OrientationD TrigonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType TrigonalLowOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(TrigonalLow::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF TrigonalLowOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(TrigonalLow::QuatSym, q1, q2); - return axisAngle; -} - QuatD TrigonalLowOps::getQuatSymOp(int32_t i) const { return TrigonalLow::QuatSym[i]; @@ -271,7 +261,7 @@ void TrigonalLowOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalLowOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType TrigonalLowOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(TrigonalLow::RodSym, rod); } @@ -279,13 +269,13 @@ OrientationType TrigonalLowOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalLowOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType TrigonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; float n1n2mag = 0.0f; - OrientationType rod = _calcRodNearestOrigin(TrigonalLow::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + RodriguesDType rod = _calcRodNearestOrigin(TrigonalLow::RodSym, inRod); + AxisAngleDType ax = rod.toAxisAngle(); float denom = static_cast(std::sqrt(ax[0] * ax[0] + ax[1] * ax[1] + ax[2] * ax[2])); ax[0] = ax[0] / denom; @@ -323,7 +313,7 @@ OrientationType TrigonalLowOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -349,13 +339,13 @@ QuatD TrigonalLowOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TrigonalLowOps::getMisoBin(const OrientationType& rod) const +int TrigonalLowOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TrigonalLow::OdfDimInitValue[0]; dim[1] = TrigonalLow::OdfDimInitValue[1]; @@ -373,7 +363,7 @@ int TrigonalLowOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalLowOps::determineEulerAngles(double random[3], int choose) const +EulerDType TrigonalLowOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -392,28 +382,27 @@ OrientationType TrigonalLowOps::determineEulerAngles(double random[3], int choos _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalLowOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType TrigonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TrigonalLow::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = TrigonalLow::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalLowOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType TrigonalLowOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -431,8 +420,7 @@ OrientationType TrigonalLowOps::determineRodriguesVector(double random[3], int c phi[2] = static_cast(choose / (TrigonalLow::OdfNumBins[0] * TrigonalLow::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } @@ -440,13 +428,13 @@ OrientationType TrigonalLowOps::determineRodriguesVector(double random[3], int c // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TrigonalLowOps::getOdfBin(const OrientationType& rod) const +int TrigonalLowOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TrigonalLow::OdfDimInitValue[0]; dim[1] = TrigonalLow::OdfDimInitValue[1]; @@ -564,8 +552,7 @@ class GenerateSphereCoordsImpl // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/TrigonalLowOps.h b/Source/EbsdLib/LaueOps/TrigonalLowOps.h index 9e133af5..0b59a4f7 100644 --- a/Source/EbsdLib/LaueOps/TrigonalLowOps.h +++ b/Source/EbsdLib/LaueOps/TrigonalLowOps.h @@ -37,7 +37,7 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" @@ -143,7 +143,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -151,7 +151,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -166,19 +166,19 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -261,7 +261,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/LaueOps/TrigonalOps.cpp b/Source/EbsdLib/LaueOps/TrigonalOps.cpp index 7da9c631..fd3799be 100644 --- a/Source/EbsdLib/LaueOps/TrigonalOps.cpp +++ b/Source/EbsdLib/LaueOps/TrigonalOps.cpp @@ -38,7 +38,7 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" @@ -84,7 +84,7 @@ static const std::vector QuatSym ={ QuatD(-0.5, sq32, 0.0, 0.0), }; -static const std::vector RodSym = { +static const std::vector RodSym = { {0.0, 0.0, 1.0, 0.0}, {0.0, 0.0, 1.0, 1.7320508075688767}, {0.0, 0.0, sq32, 10000000000000.0}, @@ -213,26 +213,16 @@ bool TrigonalOps::isInsideFZ(const QuatD& quat) const } // ----------------------------------------------------------------------------- -bool TrigonalOps::isInsideFZ(const OrientationD& rod) const +bool TrigonalOps::isInsideFZ(const RodriguesDType& rod) const { return IsInsideFZ(rod, getFZType(), getAxisOrderingType()); } -OrientationD TrigonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const +AxisAngleDType TrigonalOps::calculateMisorientation(const QuatD& q1, const QuatD& q2) const { return calculateMisorientationInternal(TrigonalHigh::QuatSym, q1, q2); } -// ----------------------------------------------------------------------------- -OrientationF TrigonalOps::calculateMisorientation(const QuatF& q1f, const QuatF& q2f) const - -{ - QuatD q1 = q1f.to(); - QuatD q2 = q2f.to(); - OrientationD axisAngle = calculateMisorientationInternal(TrigonalHigh::QuatSym, q1, q2); - return axisAngle; -} - // ----------------------------------------------------------------------------- QuatD TrigonalOps::getQuatSymOp(int32_t i) const { @@ -287,7 +277,7 @@ void TrigonalOps::getMatSymOp(int i, float g[3][3]) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalOps::getODFFZRod(const OrientationType& rod) const +RodriguesDType TrigonalOps::getODFFZRod(const RodriguesDType& rod) const { return _calcRodNearestOrigin(TrigonalHigh::RodSym, rod); } @@ -295,15 +285,15 @@ OrientationType TrigonalOps::getODFFZRod(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalOps::getMDFFZRod(const OrientationType& inRod) const +RodriguesDType TrigonalOps::getMDFFZRod(const RodriguesDType& inRod) const { double w = 0.0, n1 = 0.0, n2 = 0.0, n3 = 0.0; double FZn1 = 0.0, FZn2 = 0.0, FZn3 = 0.0, FZw = 0.0; double n1n2mag = 0.0f; - OrientationType rod = _calcRodNearestOrigin(TrigonalHigh::RodSym, inRod); + RodriguesDType rod = _calcRodNearestOrigin(TrigonalHigh::RodSym, inRod); - OrientationType ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = rod.toAxisAngle(); n1 = ax[0]; n2 = ax[1], n3 = ax[2], w = ax[3]; @@ -344,7 +334,7 @@ OrientationType TrigonalOps::getMDFFZRod(const OrientationType& inRod) const } } - return OrientationTransformation::ax2ro(OrientationType(FZn1, FZn2, FZn3, FZw)); + return AxisAngleDType(FZn1, FZn2, FZn3, FZw).toRodrigues(); } // ----------------------------------------------------------------------------- @@ -370,13 +360,13 @@ QuatD TrigonalOps::getFZQuat(const QuatD& qr) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int TrigonalOps::getMisoBin(const OrientationType& rod) const +int TrigonalOps::getMisoBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TrigonalHigh::OdfDimInitValue[0]; dim[1] = TrigonalHigh::OdfDimInitValue[1]; @@ -394,7 +384,7 @@ int TrigonalOps::getMisoBin(const OrientationType& rod) const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalOps::determineEulerAngles(double random[3], int choose) const +EulerDType TrigonalOps::determineEulerAngles(double random[3], int choose) const { double init[3]; double step[3]; @@ -413,28 +403,27 @@ OrientationType TrigonalOps::determineEulerAngles(double random[3], int choose) _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getODFFZRod(ro); - OrientationType eu = OrientationTransformation::ro2eu(ro); + EulerDType eu = ro.toEuler(); return eu; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalOps::randomizeEulerAngles(const OrientationType& synea) const +EulerDType TrigonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TrigonalHigh::k_SymOpsCount); - QuatD quat = OrientationTransformation::eu2qu(synea); + QuatD quat = synea.toQuat(); QuatD qc = TrigonalHigh::QuatSym[symOp] * quat; - return OrientationTransformation::qu2eu(qc); + return QuaternionDType(qc).toEuler(); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -OrientationType TrigonalOps::determineRodriguesVector(double random[3], int choose) const +RodriguesDType TrigonalOps::determineRodriguesVector(double random[3], int choose) const { double init[3]; double step[3]; @@ -452,19 +441,18 @@ OrientationType TrigonalOps::determineRodriguesVector(double random[3], int choo phi[2] = static_cast(choose / (TrigonalHigh::OdfNumBins[0] * TrigonalHigh::OdfNumBins[1])); _calcDetermineHomochoricValues(random, init, step, phi, h1, h2, h3); - OrientationType ho(h1, h2, h3); - OrientationType ro = OrientationTransformation::ho2ro(ho); + RodriguesDType ro = HomochoricDType(h1, h2, h3).toRodrigues(); ro = getMDFFZRod(ro); return ro; } -int TrigonalOps::getOdfBin(const OrientationType& rod) const +int TrigonalOps::getOdfBin(const RodriguesDType& rod) const { double dim[3]; double bins[3]; double step[3]; - OrientationType ho = OrientationTransformation::ro2ho(rod); + HomochoricDType ho = rod.toHomochoric(); dim[0] = TrigonalHigh::OdfDimInitValue[0]; dim[1] = TrigonalHigh::OdfDimInitValue[1]; @@ -582,8 +570,7 @@ class GenerateSphereCoordsImpl // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - OrientationType eu(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)); - EbsdLib::Matrix3X3D g(OrientationTransformation::eu2om(eu).data()); + EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); diff --git a/Source/EbsdLib/LaueOps/TrigonalOps.h b/Source/EbsdLib/LaueOps/TrigonalOps.h index 1828c7b0..77e24503 100644 --- a/Source/EbsdLib/LaueOps/TrigonalOps.h +++ b/Source/EbsdLib/LaueOps/TrigonalOps.h @@ -142,7 +142,7 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationD calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; + AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const override; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -150,7 +150,7 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual OrientationF calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // AxisAngleFType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -165,19 +165,19 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; - OrientationType getODFFZRod(const OrientationType& rod) const override; - OrientationType getMDFFZRod(const OrientationType& rod) const override; + RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; + RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; QuatD getNearestQuat(const QuatD& q1, const QuatD& q2) const override; QuatF getNearestQuat(const QuatF& q1f, const QuatF& q2f) const override; QuatD getFZQuat(const QuatD& qr) const override; - int getMisoBin(const OrientationType& rod) const override; + int getMisoBin(const RodriguesDType& rod) const override; bool inUnitTriangle(double eta, double chi) const override; - OrientationType determineEulerAngles(double random[3], int choose) const override; - OrientationType randomizeEulerAngles(const OrientationType& euler) const override; - OrientationType determineRodriguesVector(double random[3], int choose) const override; - int getOdfBin(const OrientationType& rod) const override; + EulerDType determineEulerAngles(double random[3], int choose) const override; + EulerDType randomizeEulerAngles(const EulerDType& euler) const override; + RodriguesDType determineRodriguesVector(double random[3], int choose) const override; + int getOdfBin(const RodriguesDType& rod) const override; void getSchmidFactorAndSS(double load[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; void getSchmidFactorAndSS(double load[3], double plane[3], double direction[3], double& schmidfactor, double angleComps[2], int& slipsys) const override; double getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const override; @@ -260,7 +260,7 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param rod Input Rodrigues Vector * @return */ - bool isInsideFZ(const OrientationD& rod) const override; + bool isInsideFZ(const RodriguesDType& rod) const override; protected: public: diff --git a/Source/EbsdLib/Math/ArrayHelpers.hpp b/Source/EbsdLib/Math/ArrayHelpers.hpp index be62fb34..2b1acbdd 100644 --- a/Source/EbsdLib/Math/ArrayHelpers.hpp +++ b/Source/EbsdLib/Math/ArrayHelpers.hpp @@ -22,7 +22,7 @@ class ArrayHelpers public: virtual ~ArrayHelpers() = default; - static void splat(T& a, const K val) + static void splat(T& a, K val) { size_t size = a.size(); for(size_t i = 0; i < size; i++) diff --git a/Source/EbsdLib/Math/Matrix3X1.hpp b/Source/EbsdLib/Math/Matrix3X1.hpp index 7aaf4e5c..c7a78561 100644 --- a/Source/EbsdLib/Math/Matrix3X1.hpp +++ b/Source/EbsdLib/Math/Matrix3X1.hpp @@ -47,6 +47,12 @@ class Matrix3X1 ~Matrix3X1() = default; + template + Matrix3X1 to() const + { + return Matrix3X1(m_Data[0], m_Data[1], m_Data[2]); + } + /** * @brief Returns a reference to the value at index * @param index diff --git a/Source/EbsdLib/Math/Matrix3X3.hpp b/Source/EbsdLib/Math/Matrix3X3.hpp index 3e22b577..4bf7c98e 100644 --- a/Source/EbsdLib/Math/Matrix3X3.hpp +++ b/Source/EbsdLib/Math/Matrix3X3.hpp @@ -24,10 +24,10 @@ class Matrix3X3 Matrix3X3() = default; /** - * @brief Copies the values from the pointer. + * @brief Copies the values from the pointer. Assumes row major ordering. * @param ptr */ - Matrix3X3(T* ptr) + Matrix3X3(const T* ptr) : m_Data(std::array{ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], ptr[8]}) { } diff --git a/Source/EbsdLib/OrientationMath/OrientationConverter.hpp b/Source/EbsdLib/OrientationMath/OrientationConverter.hpp index 407ff697..2e82db95 100644 --- a/Source/EbsdLib/OrientationMath/OrientationConverter.hpp +++ b/Source/EbsdLib/OrientationMath/OrientationConverter.hpp @@ -42,8 +42,7 @@ #include #include "EbsdLib/Core/EbsdSetGetMacros.h" -#include "EbsdLib/Core/Orientation.hpp" -#include "EbsdLib/Core/OrientationRepresentation.h" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdLibMath.h" @@ -305,137 +304,6 @@ class OrientationConverter DataArrayPointerType m_OutputData; }; -/** - * @brief This macro is used to create a functor that wraps a paricular conversion - * method with a functor class so it can be passed to the parallel algorithms - */ - -#define OC_CONVERTOR_FUNCTOR(CLASSNAME, INSTRIDE, OUTSTRIDE, CONVERSION_METHOD) \ - template \ - class CLASSNAME \ - { \ - public: \ - CLASSNAME() = default; \ - void operator()(InputType* input, InputType* output) \ - { \ - using OrientationInputType = Orientation; \ - OrientationInputType inputOrientation(input, INSTRIDE); \ - OrientationInputType outputOrientation(output, OUTSTRIDE); \ - outputOrientation = OrientationTransformation::CONVERSION_METHOD(inputOrientation); \ - } \ - }; - -#define OC_CONVERTOR_FUNCTOR_2QU(CLASSNAME, INSTRIDE, OUTSTRIDE, CONVERSION_METHOD) \ - template \ - class CLASSNAME \ - { \ - public: \ - CLASSNAME() = default; \ - void operator()(NumericType* input, NumericType* output) \ - { \ - using InputType = Orientation; \ - using OutputType = Quaternion; \ - InputType inputOrientation(input, INSTRIDE); \ - OrientationTransformation::CONVERSION_METHOD(inputOrientation).copyInto(output, Quaternion::Order::VectorScalar); \ - } \ - }; - -#define OC_QU2_CONVERTOR_FUNCTOR(CLASSNAME, INSTRIDE, OUTSTRIDE, CONVERSION_METHOD) \ - template \ - class CLASSNAME \ - { \ - public: \ - CLASSNAME() = default; \ - void operator()(NumericType* input, NumericType* output) \ - { \ - using QuaternionType = Quaternion; \ - using OutputType = Orientation; \ - QuaternionType inputQuat(input[0], input[1], input[2], input[3]); \ - OutputType outputOrientation = OrientationTransformation::CONVERSION_METHOD(inputQuat); \ - outputOrientation.copyInto(output, OUTSTRIDE); \ - } \ - }; - -/** - * @brief This contains all the functors that represent all possible conversion routines - * between orientation representations - */ -namespace Convertors -{ -/* Euler Functors */ -OC_CONVERTOR_FUNCTOR(Eu2Om, 3, 9, eu2om) -OC_CONVERTOR_FUNCTOR_2QU(Eu2Qu, 3, 4, eu2qu) -OC_CONVERTOR_FUNCTOR(Eu2Ax, 3, 4, eu2ax) -OC_CONVERTOR_FUNCTOR(Eu2Ro, 3, 4, eu2ro) -OC_CONVERTOR_FUNCTOR(Eu2Ho, 3, 3, eu2ho) -OC_CONVERTOR_FUNCTOR(Eu2Cu, 3, 3, eu2cu) -OC_CONVERTOR_FUNCTOR(Eu2St, 3, 3, eu2st) - -/* OrientationMatrix Functors */ -OC_CONVERTOR_FUNCTOR(Om2Eu, 9, 3, om2eu) -OC_CONVERTOR_FUNCTOR_2QU(Om2Qu, 9, 4, om2qu) -OC_CONVERTOR_FUNCTOR(Om2Ax, 9, 4, om2ax) -OC_CONVERTOR_FUNCTOR(Om2Ro, 9, 4, om2ro) -OC_CONVERTOR_FUNCTOR(Om2Ho, 9, 3, om2ho) -OC_CONVERTOR_FUNCTOR(Om2Cu, 9, 3, om2cu) -OC_CONVERTOR_FUNCTOR(Om2St, 9, 3, om2st) - -/* Quaterion Functors */ -OC_QU2_CONVERTOR_FUNCTOR(Qu2Eu, 4, 3, qu2eu) -OC_QU2_CONVERTOR_FUNCTOR(Qu2Om, 4, 9, qu2om) -OC_QU2_CONVERTOR_FUNCTOR(Qu2Ax, 4, 4, qu2ax) -OC_QU2_CONVERTOR_FUNCTOR(Qu2Ro, 4, 4, qu2ro) -OC_QU2_CONVERTOR_FUNCTOR(Qu2Ho, 4, 3, qu2ho) -OC_QU2_CONVERTOR_FUNCTOR(Qu2Cu, 4, 3, qu2cu) -OC_QU2_CONVERTOR_FUNCTOR(Qu2St, 4, 3, qu2st) - -/* AxisAngles Functors */ -OC_CONVERTOR_FUNCTOR(Ax2Eu, 4, 3, ax2eu) -OC_CONVERTOR_FUNCTOR(Ax2Om, 4, 9, ax2om) -OC_CONVERTOR_FUNCTOR_2QU(Ax2Qu, 4, 4, ax2qu) -OC_CONVERTOR_FUNCTOR(Ax2Ro, 4, 4, ax2ro) -OC_CONVERTOR_FUNCTOR(Ax2Ho, 4, 3, ax2ho) -OC_CONVERTOR_FUNCTOR(Ax2Cu, 4, 3, ax2cu) -OC_CONVERTOR_FUNCTOR(Ax2St, 4, 3, ax2st) - -/* Rodrigues Functors */ -OC_CONVERTOR_FUNCTOR(Ro2Eu, 4, 3, ro2eu) -OC_CONVERTOR_FUNCTOR(Ro2Om, 4, 9, ro2om) -OC_CONVERTOR_FUNCTOR_2QU(Ro2Qu, 4, 4, ro2qu) -OC_CONVERTOR_FUNCTOR(Ro2Ax, 4, 4, ro2ax) -OC_CONVERTOR_FUNCTOR(Ro2Ho, 4, 3, ro2ho) -OC_CONVERTOR_FUNCTOR(Ro2Cu, 4, 3, ro2cu) -OC_CONVERTOR_FUNCTOR(Ro2St, 4, 3, ro2st) - -/* Homochoric Functors */ -OC_CONVERTOR_FUNCTOR(Ho2Eu, 3, 3, ho2eu) -OC_CONVERTOR_FUNCTOR(Ho2Om, 3, 9, ho2om) -OC_CONVERTOR_FUNCTOR_2QU(Ho2Qu, 3, 4, ho2qu) -OC_CONVERTOR_FUNCTOR(Ho2Ax, 3, 4, ho2ax) -OC_CONVERTOR_FUNCTOR(Ho2Ro, 3, 4, ho2ro) -OC_CONVERTOR_FUNCTOR(Ho2Cu, 3, 3, ho2cu) -OC_CONVERTOR_FUNCTOR(Ho2St, 3, 3, ho2st) - -/* Cubochoric Functors */ -OC_CONVERTOR_FUNCTOR(Cu2Eu, 3, 3, cu2eu) -OC_CONVERTOR_FUNCTOR(Cu2Om, 3, 9, cu2om) -OC_CONVERTOR_FUNCTOR_2QU(Cu2Qu, 3, 4, cu2qu) -OC_CONVERTOR_FUNCTOR(Cu2Ax, 3, 4, cu2ax) -OC_CONVERTOR_FUNCTOR(Cu2Ro, 3, 4, cu2ro) -OC_CONVERTOR_FUNCTOR(Cu2Ho, 3, 3, cu2ho) -OC_CONVERTOR_FUNCTOR(Cu2St, 3, 3, cu2st) - -/* Stereographic Functors */ -OC_CONVERTOR_FUNCTOR(St2Eu, 3, 3, st2eu) -OC_CONVERTOR_FUNCTOR(St2Om, 3, 9, st2om) -OC_CONVERTOR_FUNCTOR_2QU(St2Qu, 3, 4, st2qu) -OC_CONVERTOR_FUNCTOR(St2Ax, 3, 4, st2ax) -OC_CONVERTOR_FUNCTOR(St2Ro, 3, 4, st2ro) -OC_CONVERTOR_FUNCTOR(St2Ho, 3, 3, st2ho) -OC_CONVERTOR_FUNCTOR(St2Cu, 3, 3, st2cu) - -} // namespace Convertors - /** * @brief This templated class is a functor class that is used for * the TBB classes to use to parallelize the conversion of orientation @@ -486,44 +354,62 @@ class ConvertRepresentation size_t m_OutStride = 0; }; -/** - * @brief OC_CONVERT_BODY Generates the body of method that will perform the conversion - */ -#ifdef EbsdLib_USE_PARALLEL_ALGORITHMS +#define OC_TBB_IMPL(TO_REP) \ + template \ + class to##TO_REP##Convertor \ + { \ + public: \ + to##TO_REP##Convertor(T* inputPtr, T* outputPtr) \ + : m_Input(inputPtr) \ + , m_Output(outputPtr) \ + { \ + } \ + void operator()(const tbb::blocked_range& r) const \ + { \ + InputType inputInstance; \ + OutputType outputInstance; \ + size_t inStride = inputInstance.size(); \ + size_t outStride = outputInstance.size(); \ + for(size_t i = r.begin(); i < r.end(); ++i) \ + { \ + size_t inOffset = i * inStride; \ + size_t outOffset = i * outStride; \ + inputInstance = InputType(m_Input + inOffset); \ + outputInstance = inputInstance.to##TO_REP(); \ + outputInstance.copyTo(m_Output + outOffset); \ + } \ + } \ + \ + private: \ + T* m_Input = nullptr; \ + T* m_Output = nullptr; \ + }; + +OC_TBB_IMPL(Euler) +OC_TBB_IMPL(OrientationMatrix) +OC_TBB_IMPL(Quaternion) +OC_TBB_IMPL(AxisAngle) +OC_TBB_IMPL(Rodrigues) +OC_TBB_IMPL(Homochoric) +OC_TBB_IMPL(Cubochoric) +OC_TBB_IMPL(Stereographic) -#define OC_CONVERT_BODY(OUTSTRIDE, OUT_ARRAY_NAME, CONVERSION_METHOD, FUNCTOR) \ +#define OC_CONVERT_BODY_PREAMBLE(FROM_REP, TO_REP) \ sanityCheckInputData(); \ DataArrayPointerType input = this->getInputData(); \ T* inPtr = input->getPointer(0); \ size_t nTuples = this->getInputData()->getNumberOfTuples(); \ - int inStride = input->getNumberOfComponents(); \ - size_t outStride = OUTSTRIDE; \ + Orientation outputInstance; \ + size_t outStride = outputInstance.size(); \ std::vector cDims = {outStride}; \ - DataArrayPointerType output = DataArrayType::CreateArray(nTuples, cDims, #OUT_ARRAY_NAME, true); \ + DataArrayPointerType output = DataArrayType::CreateArray(nTuples, cDims, #TO_REP, true); \ output->initializeWithZeros(); /* Initialize the array with Zeros */ \ T* outPtr = output->getPointer(0); \ - tbb::parallel_for(tbb::blocked_range(0, nTuples), ConvertRepresentation>(inPtr, outPtr, inStride, outStride), tbb::auto_partitioner()); \ - this->setOutputData(output); - -#else - -#define OC_CONVERT_BODY(OUTSTRIDE, OUT_ARRAY_NAME, CONVERSION_METHOD, FUNCTOR) \ - sanityCheckInputData(); \ - DataArrayPointerType input = this->getInputData(); \ - T* inPtr = input->getPointer(0); \ - size_t nTuples = this->getInputData()->getNumberOfTuples(); \ - int inStride = input->getNumberOfComponents(); \ - size_t outStride = OUTSTRIDE; \ - std::vector cDims = {outStride}; /* Create the n component (nx1) based array.*/ \ - DataArrayPointerType output = DataArrayType::CreateArray(nTuples, cDims, #OUT_ARRAY_NAME, true); \ - output->initializeWithZeros(); /* Intialize the array with Zeros */ \ - T* outPtr = output->getPointer(0); \ - ConvertRepresentation> serial(inPtr, outPtr, inStride, outStride); \ - serial.convert(0, nTuples); \ + using FROM_REP##Type = Orientation; \ + using TO_REP##Type = Orientation; \ + tbb::parallel_for(tbb::blocked_range(0, nTuples), to##TO_REP##Convertor(inPtr, outPtr), tbb::auto_partitioner()); \ this->setOutputData(output); -#endif - /* ============================================================================= * * ===========================================================================*/ @@ -578,8 +464,6 @@ class EulerSanityCheck size_t m_Stride = 0; }; -// ----------------------------------------------------------------------------- -// // ----------------------------------------------------------------------------- template class EulerConverter : public OrientationConverter @@ -603,37 +487,37 @@ class EulerConverter : public OrientationConverter void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, eu2om, Eu2Om) + OC_CONVERT_BODY_PREAMBLE(Euler, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternion, eu2qu, Eu2Qu) + OC_CONVERT_BODY_PREAMBLE(Euler, Quaternion); } void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, eu2ax, Eu2Ax) + OC_CONVERT_BODY_PREAMBLE(Euler, AxisAngle); } void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, eu2ro, Eu2Ro) + OC_CONVERT_BODY_PREAMBLE(Euler, Rodrigues); } void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, eu2ho, Eu2Ho) + OC_CONVERT_BODY_PREAMBLE(Euler, Homochoric) } void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, eu2cu, Eu2Cu) + OC_CONVERT_BODY_PREAMBLE(Euler, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, eu2st, Eu2St) + OC_CONVERT_BODY_PREAMBLE(Euler, Stereographic) } void sanityCheckInputData() override @@ -729,10 +613,10 @@ class OrientationMatrixSanityCheck for(size_t i = start; i < end; ++i) { - using Orientation_Type = Orientation; + using Orientation_Type = Orientation; using ResultType = OrientationTransformation::ResultType; - Orientation_Type oaType(inPtr, 9); + Orientation_Type oaType(inPtr); ResultType res = OrientationTransformation::om_check(oaType); if(res.result <= 0) @@ -786,8 +670,7 @@ class OrientationMatrixConverter : public OrientationConverter void toEulers() override { - sanityCheckInputData(); - OC_CONVERT_BODY(3, Eulers, om2eu, Om2Eu) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Euler); } void toOrientationMatrix() override @@ -800,36 +683,36 @@ class OrientationMatrixConverter : public OrientationConverter void toQuaternion() override { sanityCheckInputData(); - OC_CONVERT_BODY(4, Quaternion, om2qu, Om2Qu) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Quaternion); } void toAxisAngle() override { sanityCheckInputData(); - OC_CONVERT_BODY(4, AxisAngle, om2ax, Om2Ax) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, AxisAngle); } void toRodrigues() override { sanityCheckInputData(); - OC_CONVERT_BODY(4, Rodrigues, om2ro, Om2Ro) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Rodrigues); } void toHomochoric() override { sanityCheckInputData(); - OC_CONVERT_BODY(3, Homochoric, om2ho, Om2Ho) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Homochoric) } void toCubochoric() override { sanityCheckInputData(); - OC_CONVERT_BODY(3, Cubochoric, om2cu, Om2Cu) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, om2st, Om2St) + OC_CONVERT_BODY_PREAMBLE(OrientationMatrix, Stereographic) } void sanityCheckInputData() override @@ -957,12 +840,12 @@ class QuaternionConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, qu2eu, Qu2Eu) + OC_CONVERT_BODY_PREAMBLE(Quaternion, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, qu2om, Qu2Om) + OC_CONVERT_BODY_PREAMBLE(Quaternion, OrientationMatrix); } void toQuaternion() override @@ -975,27 +858,27 @@ class QuaternionConverter : public OrientationConverter void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, qu2ax, Qu2Ax) + OC_CONVERT_BODY_PREAMBLE(Quaternion, AxisAngle); } void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, qu2ro, Qu2Ro) + OC_CONVERT_BODY_PREAMBLE(Quaternion, Rodrigues); } void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, qu2ho, Qu2Ho) + OC_CONVERT_BODY_PREAMBLE(Quaternion, Homochoric) } void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, qu2cu, Qu2Cu) + OC_CONVERT_BODY_PREAMBLE(Quaternion, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, qu2st, Qu2St) + OC_CONVERT_BODY_PREAMBLE(Quaternion, Stereographic) } void sanityCheckInputData() override @@ -1120,17 +1003,17 @@ class AxisAngleConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, ax2eu, Ax2Eu) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, ax2om, Ax2Om) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternions, ax2qu, Ax2Qu) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Quaternion); } void toAxisAngle() override @@ -1143,22 +1026,22 @@ class AxisAngleConverter : public OrientationConverter void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, ax2ro, Ax2Ro) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Rodrigues); } void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, ax2ho, Ax2Ho) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Homochoric) } void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, ax2cu, Ax2Cu) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, ax2st, Ax2St) + OC_CONVERT_BODY_PREAMBLE(AxisAngle, Stereographic) } void sanityCheckInputData() override @@ -1284,22 +1167,22 @@ class RodriguesConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, ro2eu, Ro2Eu) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, ro2om, Ro2Om) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternions, ro2qu, Ro2Qu) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, Quaternion); } void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, ro2ax, Ro2Ax) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, AxisAngle); } void toRodrigues() override @@ -1312,17 +1195,17 @@ class RodriguesConverter : public OrientationConverter void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, ro2ho, Ro2Ho) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, Homochoric) } void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, ro2cu, Ro2Cu) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, ro2st, Ro2St) + OC_CONVERT_BODY_PREAMBLE(Rodrigues, Stereographic) } void sanityCheckInputData() override @@ -1448,27 +1331,27 @@ class HomochoricConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, ho2eu, Ho2Eu) + OC_CONVERT_BODY_PREAMBLE(Homochoric, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, ho2om, Ho2Om) + OC_CONVERT_BODY_PREAMBLE(Homochoric, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternions, ho2qu, Ho2Qu) + OC_CONVERT_BODY_PREAMBLE(Homochoric, Quaternion); } void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, ho2ax, Ho2Ax) + OC_CONVERT_BODY_PREAMBLE(Homochoric, AxisAngle); } void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, ho2ro, Ho2Ro) + OC_CONVERT_BODY_PREAMBLE(Homochoric, Rodrigues); } void toHomochoric() override @@ -1481,12 +1364,12 @@ class HomochoricConverter : public OrientationConverter void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, ho2cu, Ho2Cu) + OC_CONVERT_BODY_PREAMBLE(Homochoric, Cubochoric) } void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, ho2st, Ho2St) + OC_CONVERT_BODY_PREAMBLE(Homochoric, Stereographic) } void sanityCheckInputData() override @@ -1613,32 +1496,32 @@ class CubochoricConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, cu2eu, Cu2Eu) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, cu2om, Cu2Om) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternions, cu2qu, Cu2Qu) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, Quaternion); } void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, cu2ax, Cu2Ax) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, AxisAngle); } void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, cu2ro, Cu2Ro) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, Rodrigues); } void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, cu2ho, Cu2Ho) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, Homochoric) } void toCubochoric() override @@ -1651,7 +1534,7 @@ class CubochoricConverter : public OrientationConverter void toStereographic() override { - OC_CONVERT_BODY(3, Stereographic, cu2st, Cu2St) + OC_CONVERT_BODY_PREAMBLE(Cubochoric, Stereographic) } void sanityCheckInputData() override @@ -1777,37 +1660,37 @@ class StereographicConverter : public OrientationConverter void toEulers() override { - OC_CONVERT_BODY(3, Eulers, st2eu, St2Eu) + OC_CONVERT_BODY_PREAMBLE(Stereographic, Euler); } void toOrientationMatrix() override { - OC_CONVERT_BODY(9, OrientationMatrix, st2om, St2Om) + OC_CONVERT_BODY_PREAMBLE(Stereographic, OrientationMatrix); } void toQuaternion() override { - OC_CONVERT_BODY(4, Quaternions, st2qu, St2Qu) + OC_CONVERT_BODY_PREAMBLE(Stereographic, Quaternion); } void toAxisAngle() override { - OC_CONVERT_BODY(4, AxisAngle, st2ax, St2Ax) + OC_CONVERT_BODY_PREAMBLE(Stereographic, AxisAngle); } void toRodrigues() override { - OC_CONVERT_BODY(4, Rodrigues, st2ro, St2Ro) + OC_CONVERT_BODY_PREAMBLE(Stereographic, Rodrigues); } void toHomochoric() override { - OC_CONVERT_BODY(3, Homochoric, st2ho, St2Ho) + OC_CONVERT_BODY_PREAMBLE(Stereographic, Homochoric) } void toCubochoric() override { - OC_CONVERT_BODY(3, Cubochoric, st2cu, St2Cu) + OC_CONVERT_BODY_PREAMBLE(Stereographic, Cubochoric) } void toStereographic() override diff --git a/Source/EbsdLib/Texture/StatsGen.hpp b/Source/EbsdLib/Texture/StatsGen.hpp index 5c2fa7d6..52f7c476 100644 --- a/Source/EbsdLib/Texture/StatsGen.hpp +++ b/Source/EbsdLib/Texture/StatsGen.hpp @@ -277,13 +277,14 @@ class StatsGen randx3[0] = distribution(generator); randx3[1] = distribution(generator); randx3[2] = distribution(generator); - OrientationD eu = ops.determineEulerAngles(randx3.data(), choose); + EulerDType eu = ops.determineEulerAngles(randx3.data(), choose); eulers[3 * i + 0] = eu[0]; eulers[3 * i + 1] = eu[1]; eulers[3 * i + 2] = eu[2]; } return err; } + #if 0 /** @@ -482,7 +483,7 @@ class StatsGen randx3[0] = distribution(generator); randx3[1] = distribution(generator); randx3[2] = distribution(generator); - OrientationD eu = ops.determineEulerAngles(randx3.data(), choose); + EulerDType eu = ops.determineEulerAngles(randx3.data(), choose); eulers[3 * i + 0] = eu[0]; eulers[3 * i + 1] = eu[1]; eulers[3 * i + 2] = eu[2]; @@ -548,8 +549,7 @@ class StatsGen // Create a random rod vector randx3 = {distribution(generator), distribution(generator), distribution(generator)}; - OrientationD rod = ops.determineRodriguesVector(randx3.data(), choose); - OrientationD ax = OrientationTransformation::ro2ax(rod); + AxisAngleDType ax = ops.determineRodriguesVector(randx3.data(), choose).toAxisAngle(); float w = static_cast(ax[3] * radtodeg); size_t index = static_cast(w * 0.2f); diff --git a/Source/EbsdLib/Texture/Texture.hpp b/Source/EbsdLib/Texture/Texture.hpp index d1b45b8a..a7b82d3b 100644 --- a/Source/EbsdLib/Texture/Texture.hpp +++ b/Source/EbsdLib/Texture/Texture.hpp @@ -43,7 +43,7 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" @@ -101,8 +101,7 @@ class Texture // Use double precision for the calculations for(size_t i = 0; i < numEntries; i++) { - OrientationF eu(e1s[i], e2s[i], e3s[i]); - OrientationD rod = OrientationTransformation::eu2ro(eu); + RodriguesDType rod = EulerDType(e1s[i], e2s[i], e3s[i]).toRodrigues(); rod = ops.getODFFZRod(rod); bin = ops.getOdfBin(rod); @@ -243,8 +242,7 @@ class Texture int aSize = static_cast(numEntries); for(int i = 0; i < aSize; i++) { - OrientationD ax(axes[3 * i], axes[3 * i + 1], axes[3 * i + 2], angles[i]); - OrientationD rod = OrientationTransformation::ax2ro(ax); + RodriguesDType rod = AxisAngleDType(axes[3 * i], axes[3 * i + 1], axes[3 * i + 2], angles[i]).toRodrigues(); rod = orientationOps.getMDFFZRod(rod); mbin = orientationOps.getMisoBin(rod); @@ -275,14 +273,13 @@ class Texture } // This is used to create a random Homochoric vector std::array randx3 = {distribution(generator), distribution(generator), distribution(generator)}; - OrientationD eu = orientationOps.determineEulerAngles(randx3.data(), choose1); - QuatD q1 = OrientationTransformation::eu2qu(eu); + EulerDType eu = orientationOps.determineEulerAngles(randx3.data(), choose1); + QuatD q1 = eu.toQuat(); randx3 = {distribution(generator), distribution(generator), distribution(generator)}; eu = orientationOps.determineEulerAngles(randx3.data(), choose2); - QuatD q2 = OrientationTransformation::eu2qu(eu); - OrientationD ax = orientationOps.calculateMisorientation(q1, q2); - OrientationD ro = OrientationTransformation::ax2ro(ax); + QuatD q2 = eu.toQuat(); + RodriguesDType ro = orientationOps.calculateMisorientation(q1, q2).toRodrigues(); ro = orientationOps.getMDFFZRod(ro); // <==== THIS IS NOT IMPELMENTED FOR ALL LAUE CLASSES mbin = orientationOps.getMisoBin(ro); diff --git a/Source/EbsdLib/Utilities/CanvasUtilities.hpp b/Source/EbsdLib/Utilities/CanvasUtilities.hpp index cc0d1c94..67016ffd 100644 --- a/Source/EbsdLib/Utilities/CanvasUtilities.hpp +++ b/Source/EbsdLib/Utilities/CanvasUtilities.hpp @@ -9,7 +9,7 @@ namespace EbsdLib { -using Point3DType = EbsdLib::Matrix3X1; +using Point3DType = EbsdLib::Matrix3X1; /** * @brief diff --git a/Source/Test/CMakeLists.txt b/Source/Test/CMakeLists.txt index 8cab3661..f2aafccc 100644 --- a/Source/Test/CMakeLists.txt +++ b/Source/Test/CMakeLists.txt @@ -82,21 +82,26 @@ endif() # they will show up in IDEs set(TEST_NAMES ${TEST_NAMES} - OrientationTest - OrientationArrayTest + OrientationConverterTest + OrientationTransformsTest QuaternionTest AngImportTest + CtfReaderTest ODFTest SO3SamplerTest + TextureTest + ConvertToFundamentalZoneTest + + OrientationRepresentationTransformTest ) diff --git a/Source/Test/ConvertToFundamentalZoneTest.cpp b/Source/Test/ConvertToFundamentalZoneTest.cpp index e2c07943..d6e9a4fd 100644 --- a/Source/Test/ConvertToFundamentalZoneTest.cpp +++ b/Source/Test/ConvertToFundamentalZoneTest.cpp @@ -33,7 +33,6 @@ * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include "EbsdLib/Core/OrientationRepresentation.h" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" @@ -88,7 +87,7 @@ class ConvertToFundamentalZoneTest #endif } - static OrientationD convertRodrigues(const std::array& rod) + static RodriguesDType convertRodrigues(const std::array& rod) { const float length = sqrt(rod[0] * rod[0] + rod[1] * rod[1] + rod[2] * rod[2]); return {rod[0] / length, rod[1] / length, rod[2] / length, length}; @@ -108,7 +107,7 @@ class ConvertToFundamentalZoneTest { // OrientationD testRod = OrientationTransformation::qu2ro(Detail::k_InputQuat); std::array rod = detail::k_TestRodrigues[testIdx]; - OrientationD testRod = convertRodrigues(rod); + RodriguesDType testRod = convertRodrigues(rod); bool isInside = LaueOps::IsInsideFZ(testRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); DREAM3D_REQUIRE_EQUAL(isInside, testValues[testIdx]) @@ -121,9 +120,9 @@ class ConvertToFundamentalZoneTest if(!isInside) { - QuatD quat = OrientationTransformation::ro2qu(testRod); + QuatD quat = testRod.toQuat(); QuatD fzQuat = ops[opsIdx]->getFZQuat(quat); - OrientationD fzRod = OrientationTransformation::qu2ro(fzQuat); + RodriguesDType fzRod = QuaternionDType(fzQuat).toRodrigues(); isInside = LaueOps::IsInsideFZ(fzRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); DREAM3D_REQUIRE_EQUAL(isInside, true); } diff --git a/Source/Test/GenerateFunctionList.h b/Source/Test/GenerateFunctionList.h index e79887bd..b90c8e0d 100644 --- a/Source/Test/GenerateFunctionList.h +++ b/Source/Test/GenerateFunctionList.h @@ -1,8 +1,11 @@ #pragma once +#include "EbsdLib/OrientationMath/OrientationConverter.hpp" +#include "EbsdLib/Utilities/EbsdStringUtils.hpp" + +#include "TestPrintFunctions.h" + #include -#include -#include #include #include @@ -116,3 +119,156 @@ class GenerateFunctionList GenerateFunctionList& operator=(const GenerateFunctionList&) = delete; // Copy Assignment Not Implemented GenerateFunctionList& operator=(GenerateFunctionList&&) = delete; // Move Assignment Not Implemented }; + +namespace generate_test_data +{ + +// ----------------------------------------------------------------------------- +template +std::shared_ptr> generateRepresentation(int32_t inputType, int32_t outputType, typename EbsdDataArray::Pointer inputOrientations) +{ + // using ArrayType = typename EbsdDataArray::Pointer; + using OCType = OrientationConverter, T>; + + std::vector converters(s_NumReps); + + converters[0] = EulerConverter, T>::New(); + converters[1] = OrientationMatrixConverter, T>::New(); + converters[2] = QuaternionConverter, T>::New(); + converters[3] = AxisAngleConverter, T>::New(); + converters[4] = RodriguesConverter, T>::New(); + converters[5] = HomochoricConverter, T>::New(); + converters[6] = CubochoricConverter, T>::New(); + converters[7] = StereographicConverter, T>::New(); + + std::vector ocTypes = OCType::GetOrientationTypes(); + + converters[inputType]->setInputData(inputOrientations); + converters[inputType]->convertRepresentationTo(ocTypes[outputType]); + + return converters[inputType]->getOutputData(); +} + +// ----------------------------------------------------------------------------- +std::string ExecuteConvertFilter(std::map::Pointer>& attrMat, GenerateFunctionList::EntryType& entry, int e, const std::string& outputName) +{ + std::string inputName = outputName; + + if(e == 0) + { + inputName = k_InputNames[entry[e]]; + } + EbsdDataArray::Pointer inputData = attrMat[inputName]; + EbsdDataArray::Pointer outputData = generateRepresentation(entry[e], entry[e + 1], inputData); + std::string nextOutputName = EbsdStringUtils::number(e) + std::string("_") + k_InputNames[entry[e]] + std::string("2") + k_InputNames[entry[e + 1]]; + attrMat[nextOutputName] = outputData; + + return nextOutputName; +} + +// ----------------------------------------------------------------------------- +template +void GenerateEulers(size_t nSteps, std::map::Pointer>& attrMat) +{ + std::vector cDims = {3}; + + T phi1_min = static_cast(0.0); + T phi1_max = DConst::k_2PiD; + T phi1_delta = (phi1_max - phi1_min) / static_cast(nSteps); + + T phi_min = static_cast(0.0); + T phi_max = DConst::k_PiD; + T phi_delta = (phi_max - phi_min) / static_cast(nSteps); + + T phi2_min = static_cast(0.0); + T phi2_max = DConst::k_2PiD; + T phi2_delta = (phi2_max - phi2_min) / static_cast(nSteps); + + size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); + typename EbsdDataArray::Pointer eulers = EbsdDataArray::CreateArray(nStepsCubed, cDims, k_InputNames[0], true); + + size_t counter = 0; + for(size_t i = 0; i <= nSteps; i++) + { + for(size_t j = 0; j <= nSteps; j++) + { + for(size_t k = 0; k <= nSteps; k++) + { + // std::cout << "Euler[" << counter << "]: " + // << (phi1_min+i*phi1_delta)*DConst::k_180OverPi << ", " + // << (phi_min+j*phi_delta)*DConst::k_180OverPi << ", " + // << (phi2_min+k*phi2_delta)*DConst::k_180OverPi << std::endl; + + eulers->setComponent(counter, 0, phi1_min + i * phi1_delta); + eulers->setComponent(counter, 1, phi_min + j * phi_delta); + eulers->setComponent(counter, 2, phi2_min + k * phi2_delta); + + T one80Check = phi1_min + i * phi1_delta + phi2_min + k * phi2_delta; + if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) + { + eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); + eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); + } + + one80Check = fmod(one80Check, EbsdLib::Constants::k_2PiD); + if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) + { + eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); + eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); + } + + counter++; + } + } + } + + typename EulerConverter, T>::Pointer euConv = EulerConverter, T>::New(); + euConv->setInputData(eulers); + + euConv->toOrientationMatrix(); + typename EbsdDataArray::Pointer om = euConv->getOutputData(); + om->setName(k_InputNames[1]); + attrMat[k_InputNames[1]] = om; + + // Create an Orientation matrix from the Eulers and then transform BACK to Eulers to transform + // the values of the Eulers into the convention set forth in the Rotations Paper. + typename OrientationMatrixConverter, T>::Pointer omConv = OrientationMatrixConverter, T>::New(); + omConv->setInputData(om); + omConv->toEulers(); + eulers = omConv->getOutputData(); + eulers->setName(k_InputNames[0]); + euConv->setInputData(eulers); + + attrMat[k_InputNames[0]] = eulers; + + euConv->toQuaternion(); + typename EbsdDataArray::Pointer q = euConv->getOutputData(); + q->setName(k_InputNames[2]); + attrMat[k_InputNames[2]] = q; + + euConv->toAxisAngle(); + typename EbsdDataArray::Pointer ax = euConv->getOutputData(); + ax->setName(k_InputNames[3]); + attrMat[k_InputNames[3]] = ax; + + euConv->toRodrigues(); + typename EbsdDataArray::Pointer ro = euConv->getOutputData(); + ro->setName(k_InputNames[4]); + attrMat[k_InputNames[4]] = ro; + + euConv->toHomochoric(); + typename EbsdDataArray::Pointer ho = euConv->getOutputData(); + ho->setName(k_InputNames[5]); + attrMat[k_InputNames[5]] = ho; + + euConv->toCubochoric(); + typename EbsdDataArray::Pointer cu = euConv->getOutputData(); + cu->setName(k_InputNames[6]); + attrMat[k_InputNames[6]] = cu; + + euConv->toStereographic(); + typename EbsdDataArray::Pointer st = euConv->getOutputData(); + st->setName(k_InputNames[7]); + attrMat[k_InputNames[7]] = st; +} +} // namespace generate_test_data diff --git a/Source/Test/ODFTest.cpp b/Source/Test/ODFTest.cpp index 42df39d9..2ff80a8e 100644 --- a/Source/Test/ODFTest.cpp +++ b/Source/Test/ODFTest.cpp @@ -63,8 +63,6 @@ class ODFTest ODFTest() = default; ~ODFTest() = default; - EBSD_GET_NAME_OF_CLASS_DECL(ODFTest) - // ----------------------------------------------------------------------------- template void Print_Coord(const T* om) @@ -105,26 +103,30 @@ class ODFTest float PHI = 180.0f; float phi2 = 0.0f; - float ga[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}; - OrientationTransformation::eu2om(OrientationF(phi1, PHI, phi2)).toGMatrix(ga); + // float ga[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}; + + Matrix3X3 ga = EulerFType(phi1, PHI, phi2).toOrientationMatrix().toGMatrixObj<>(); - float coordsRotated[3] = {0.0f, 0.0f, 0.0f}; - float coords[3] = {0.0f, 0.0f, 0.0f}; + // OrientationTransformation::eu2om(OrientationF(phi1, PHI, phi2)).toGMatrix(ga); + + Matrix3X1 coordsRotated = {0.0f, 0.0f, 0.0f}; + Matrix3X1 coords = {0.0f, 0.0f, 0.0f}; float xc = -0.0; float yc = -5.0; float zc = 0.0; coords[0] = coords[0] - xc; coords[1] = coords[1] - yc; coords[2] = coords[2] - zc; - EbsdMatrixMath::Multiply3x3with3x1(ga, coords, coordsRotated); - Print_Coord(coords); - Print_Coord(coordsRotated); + coordsRotated = ga * coords; + + Print_Coord(coords.data()); + Print_Coord(coordsRotated.data()); } void operator()() { - std::cout << "<===== Start " << getNameOfClass() << std::endl; + std::cout << "<===== Start ODF Test" << std::endl; TestRotation(); CubicODFTest(); diff --git a/Source/Test/OrientationArrayTest.cpp b/Source/Test/OrientationArrayTest.cpp deleted file mode 100644 index 64511a9c..00000000 --- a/Source/Test/OrientationArrayTest.cpp +++ /dev/null @@ -1,1096 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include - -#if __APPLE__ -#include -#endif - -#include -#include -#include -#include - -#include - -#include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" -#include "EbsdLib/EbsdLib.h" -#include "EbsdLib/Math/ArrayHelpers.hpp" -#include "EbsdLib/Math/EbsdLibMath.h" -#include "EbsdLib/Math/EbsdMatrixMath.h" -#include "EbsdLib/OrientationMath/OrientationConverter.hpp" - -#include "TestPrintFunctions.h" -#include "UnitTestSupport.hpp" - -#include "EbsdLib/Test/EbsdLibTestFileLocations.h" - -using namespace EbsdLib::Constants; - -class OrientationArrayTest -{ -public: - OrientationArrayTest() = default; - virtual ~OrientationArrayTest() = default; - - OrientationArrayTest(const OrientationArrayTest&) = delete; // Copy Constructor Not Implemented - OrientationArrayTest(OrientationArrayTest&&) = delete; // Move Constructor Not Implemented - OrientationArrayTest& operator=(const OrientationArrayTest&) = delete; // Copy Assignment Not Implemented - OrientationArrayTest& operator=(OrientationArrayTest&&) = delete; // Move Assignment Not Implemented - - using FOrientArrayType = Orientation; - using FloatVectorType = std::vector; - using FloatQVectorType = std::vector; - using DoubleVectorType = std::vector; - using DoubleQVectorType = std::vector; - - EBSD_GET_NAME_OF_CLASS_DECL(OrientationArrayTest) - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - T transfer_sign(T a, T b) - { - if(a > 0.0 && b > 0.0) - { - return a; - } - if(a < 0.0 && b > 0.0) - { - return -1 * a; - } - - if(a < 0.0 && b < 0.0) - { - return a; - } - - return -1 * a; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestRotArray() - { - FOrientArrayType ro(3); - ro[0] = 2; - ro[1] = 4; - ro[2] = 6; - // float sum = ro.sum(); - // DREAM3D_REQUIRE_EQUAL(sum, 12); - - // DREAM3D_REQUIRE_EQUAL(ro.size(), 3); - - // DREAM3D_REQUIRE_EQUAL(ro.maxval(), 6); - // DREAM3D_REQUIRE_EQUAL(ro.minval(), 2); - - // float pro = ro.product(); - // DREAM3D_REQUIRE_EQUAL(pro, 48); - // sum = result.sum(); - // float max = result.maxval(); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_eu_check() - { - { - OrientationTransformation::ResultType result; - using TestType = FOrientArrayType; - FOrientArrayType eu_r(3); - eu_r[0] = 0.81585413f; - eu_r[1] = 3.00f; - eu_r[2] = 0.8661895f; - result = OrientationTransformation::eu_check(eu_r); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - eu_r[1] = eu_r[1] - EbsdLib::Constants::k_PiF; - result = OrientationTransformation::eu_check(eu_r); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - FloatVectorType eu_v(3); - eu_v[0] = 1.0F; - eu_v[1] = 0.4f; - eu_v[2] = 0.9f; - result = OrientationTransformation::eu_check(eu_v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - eu_v[0] = -1.0; - result = OrientationTransformation::eu_check(eu_v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - { - using TestType = std::vector; - using FloatQVectorType = std::vector; - OrientationTransformation::ResultType result; - FloatQVectorType eu_q(3); - eu_q[0] = 1.0F; - eu_q[1] = 0.4f; - eu_q[2] = 0.9f; - result = OrientationTransformation::eu_check(eu_q); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - eu_q[0] = -1.0; - result = OrientationTransformation::eu_check(eu_q); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ro_check() - { - { - OrientationTransformation::ResultType result; - FOrientArrayType ro(4); - using TestType = FOrientArrayType; - - ro[0] = 1.0F; - ro[1] = 1.0F; - ro[2] = 1.0F; - ro[3] = 1.0F; - EbsdMatrixMath::Normalize3x1(&(ro[0])); - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ro[3] = -1.0; - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - - FloatVectorType ro(4); - ro[0] = 1.0F; - ro[1] = 1.0F; - ro[2] = 1.0F; - ro[3] = 1.0F; - EbsdMatrixMath::Normalize3x1(&(ro[0])); - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ro[3] = -1.0; - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - TestType ro(4); - ro[0] = 1.0f; - ro[1] = 1.0f; - ro[2] = 1.0f; - ro[3] = 1.0f; - EbsdMatrixMath::Normalize3x1(&(ro[0])); - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ro[3] = -1.0; - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ho_check() - { - { - using TestType = FOrientArrayType; - OrientationTransformation::ResultType result; - FOrientArrayType ho(3); - ho[0] = 0.5f; - ho[1] = 0.5f; - ho[2] = 0.5f; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ho[2] = 8.0; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - - FloatVectorType ho(3); - ho[0] = 0.5f; - ho[1] = 0.5f; - ho[2] = 0.5f; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ho[2] = 8.0; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - - OrientationTransformation::ResultType result; - TestType ho(3); - ho[0] = 0.5f; - ho[1] = 0.5f; - ho[2] = 0.5f; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ho[2] = 8.0; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_cu_check() - { - { - using TestType = FOrientArrayType; - OrientationTransformation::ResultType result; - FOrientArrayType v(3); - v[0] = 0.5f; - v[1] = 0.5f; - v[2] = 0.5f; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - v[2] = 8.0; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - FloatVectorType v(3); - v[0] = 0.5f; - v[1] = 0.5f; - v[2] = 0.5f; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - v[2] = 8.0; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - - OrientationTransformation::ResultType result; - FloatQVectorType v(3); - v[0] = 0.5f; - v[1] = 0.5f; - v[2] = 0.5f; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - v[2] = 8.0; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_qu_check() - { - QuatF quat(1.0, 1.0, 1.0, 0.0); - quat = quat.normalize(); - - { - using TestType = FOrientArrayType; - OrientationTransformation::ResultType result; - FOrientArrayType qu(4); - qu[0] = quat.x(); - qu[1] = quat.y(); - qu[2] = quat.z(); - qu[3] = quat.w(); - EbsdMatrixMath::Normalize3x1(&(qu[0])); - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - qu[0] = 1.5f; - qu[1] = 3.0f; - qu[2] = 2.0f; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - qu[0] = -1.0; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - FloatVectorType qu(4); - qu[0] = quat.x(); - qu[1] = quat.y(); - qu[2] = quat.z(); - qu[3] = quat.w(); - EbsdMatrixMath::Normalize3x1(&(qu[0])); - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - qu[0] = 1.5f; - qu[1] = 3.0f; - qu[2] = 2.0f; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - qu[0] = -1.0; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - using TestType = std::vector; - - OrientationTransformation::ResultType result; - TestType qu(4); - qu[0] = quat.x(); - qu[1] = quat.y(); - qu[2] = quat.z(); - qu[3] = quat.w(); - EbsdMatrixMath::Normalize3x1(&(qu[0])); - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - qu[0] = 1.5f; - qu[1] = 3.0f; - qu[2] = 2.0f; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - qu[0] = -1.0; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ax_check() - { - { - using TestType = FOrientArrayType; - OrientationTransformation::ResultType result; - FOrientArrayType ax(4); - ax[0] = 0.0F; - ax[1] = 0.0F; - ax[2] = 1.0F; - ax[3] = EbsdLib::Constants::k_PiF - 0.00001F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[0] = 1.0; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - FloatVectorType ax(4); - ax[0] = 0.0F; - ax[1] = 0.0F; - ax[2] = 1.0F; - ax[3] = EbsdLib::Constants::k_PiF - 0.00001F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[0] = 1.0; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - using TestType = std::vector; - - OrientationTransformation::ResultType result; - TestType ax(4); - ax[0] = 0.0f; - ax[1] = 0.0f; - ax[2] = 1.0f; - ax[3] = EbsdLib::Constants::k_PiF - 0.00001f; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[0] = 1.0F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_om_check() - { - { - using TestType = FOrientArrayType; - OrientationTransformation::ResultType result; - FOrientArrayType ax(9); - ax[0] = 1.0F; - ax[1] = 0.0F; - ax[2] = 0.0F; - ax[3] = 0.0F; - ax[4] = 1.0F; - ax[5] = 0.0F; - ax[6] = 0.0F; - ax[7] = 0.0F; - ax[8] = 1.0F; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[1] = -16.0f; - ax[6] = -12.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -3); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - using TestType = std::vector; - OrientationTransformation::ResultType result; - FloatVectorType ax(9); - ax[0] = 1.0F; - ax[1] = 0.0F; - ax[2] = 0.0F; - ax[3] = 0.0F; - ax[4] = 1.0F; - ax[5] = 0.0F; - ax[6] = 0.0F; - ax[7] = 0.0F; - ax[8] = 1.0F; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[1] = -16.0f; - ax[6] = -12.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -3); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - using TestType = std::vector; - - OrientationTransformation::ResultType result; - TestType ax(9); - ax[0] = 1.0f; - ax[1] = 0.0f; - ax[2] = 0.0f; - ax[3] = 0.0f; - ax[4] = 1.0f; - ax[5] = 0.0f; - ax[6] = 0.0f; - ax[7] = 0.0f; - ax[8] = 1.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[1] = -16.0f; - ax[6] = -12.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -3); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0F; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void GenRotTest(K* in, K omega) - { - T eu(3); - eu[0] = in[0]; - eu[1] = in[1]; - eu[2] = in[2]; - - T res(4); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_GenRot() - { - - std::array eu = {1.0f, 0.0f, 0.0f}; - float omega = EbsdLib::Constants::k_PiOver2F; - GenRotTest(eu.data(), omega); - GenRotTest(eu.data(), omega); - GenRotTest(eu.data(), omega); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void EU_2_XXX(FloatType* in) - { - - using TestType = T; - - T eu(3); - eu[0] = in[0]; - eu[1] = in[1]; - eu[2] = in[2]; - - eu[0] = static_cast(std::fmod(eu[0], EbsdLib::Constants::k_2PiD)); - eu[1] = static_cast(std::fmod(eu[1], EbsdLib::Constants::k_PiD)); - eu[2] = static_cast(std::fmod(eu[2], EbsdLib::Constants::k_2PiD)); - - T res(9); - - typename OrientationTransformation::ResultType result; - result = OrientationTransformation::eu_check(eu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ax = OrientationTransformation::eu2ax(eu); - OrientationPrinters::Print_AX(ax); - result = OrientationTransformation::ax_check(ax); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ro(4); - ro = OrientationTransformation::eu2ro(eu); - OrientationPrinters::Print_RO(ro); - result = OrientationTransformation::ro_check(ro); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ho(3); - ho = OrientationTransformation::eu2ho(eu); - OrientationPrinters::Print_HO(ho); - result = OrientationTransformation::ho_check(ho); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T cu(3); - cu = OrientationTransformation::eu2cu(eu); - OrientationPrinters::Print_CU(cu); - result = OrientationTransformation::cu_check(cu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - cu = OrientationTransformation::ho2cu(ho); - OrientationPrinters::Print_CU(cu); - result = OrientationTransformation::cu_check(cu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - QuatF qu = OrientationTransformation::eu2qu(eu); - OrientationPrinters::Print_QU(qu); - result = OrientationTransformation::qu_check(qu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T om(9); - om = OrientationTransformation::eu2om(eu); - OrientationPrinters::Print_OM(om); - result = OrientationTransformation::om_check(om); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - } - - /* -Starting Test ax2eu eu2ax ----------------------------------------------------- -Total Tuples: 4913 -Delta Failed: 1.99037 DataArray: 'ax Difference' Tuple[263] Comp[1] Value:-1.99037 -eu -0.0000000000000000 2.9452431201934814 3.1415927410125732 -ax --0.0000000435009078 -0.9951847195625305 0.0980171412229538 3.1415927410125732 -0_ax2eu -6.2831850051879883 2.9452428817749023 3.1415922641754150 -1_eu2ax --0.0000000435009078 0.9951847195625305 -0.0980172604322433 3.1415925025939941 ------------------------------------------- -ax2eu eu2ax FAILED -*/ - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void Test_eu2_XXX() - { - using OrientType = Orientation; - using VectorType = std::vector; - using QVectorType = std::vector; - { - K eu[3] = {static_cast(0.3926990816987242L), static_cast(0.0L), static_cast(0.0L)}; - OrientationPrinters::Print_EU(eu); - EU_2_XXX(eu); - EU_2_XXX(eu); - EU_2_XXX(eu); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void OM_2_XXX(K* in) - { - std::cout << " " << std::endl; - T om(9); - for(typename T::size_type i = 0; i < 9; i++) - { - om[i] = in[i]; - } - T res(3); // Just size to 9 as we are going to reuse the variable - // Convert to Euler - res = OrientationTransformation::om2eu(om); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::om2ro(om); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - Quaternion quat = OrientationTransformation::om2qu>(om); - OrientationPrinters::Print_QU>(quat); - - // Convert to Axis Angle - res = OrientationTransformation::om2ax(om); - OrientationPrinters::Print_AX(res); - - // Convert to Homochoric - res = OrientationTransformation::om2ho(om); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::om2cu(om); - OrientationPrinters::Print_CU(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_om2_XXX() - { - /* ----------------------------------------------------- -Euler angles : 90.0000000 0.0000000 0.0000000 -Axis angle pair [n; angle] : -0.0000000 -0.0000000 -1.0000000 ; 90.0000000 -Rodrigues vector : -0.0000000 -0.0000000 -1.0000000 -Homochoric representation : -0.0000000 -0.0000000 -0.7536693 -Cubochoric representation : 0.0000000 0.0000000 -0.6074544 -Quaternion : 0.7071068 -0.0000000 -0.0000000 -0.7071068 - / 0.0000 1.0000 0.0000 \ -Orientation Matrix : | -1.0000 0.0000 0.0000 | - \ 0.0000 0.0000 1.0000 / -*/ - std::cout << "Test_om2_XXX $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; - float om[9] = {0.0000, 1.0000, 0.0000, -1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000}; - OrientationPrinters::Print_OM(om); - OM_2_XXX(om); - OM_2_XXX(om); - OM_2_XXX(om); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void RO_2_XXX(K* in) - { - T ro(9); - for(typename T::size_type i = 0; i < 4; i++) - { - ro[i] = in[i]; - } - - T res(9); // Just size to 9 as we are going to reuse the variable - - // Convert to Euler - res = OrientationTransformation::ro2eu(ro); - OrientationPrinters::Print_EU(res); - - // Convert to Orientation Matrix - res = OrientationTransformation::ro2om(ro); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ro2ax(ro); - OrientationPrinters::Print_AX(res); - - // Convert to Quaternion - - Quaternion quat = OrientationTransformation::ro2qu>(ro); - OrientationPrinters::Print_QU>(quat); - - // Convert to Homochoric - res = OrientationTransformation::ro2ho(ro); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::ro2cu(ro); - OrientationPrinters::Print_CU(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ro2_XXX() - { - std::cout << "Test_ro2_XXX @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl; - float ro[4] = {0.0f, 0.0f, -1.0f, 1.0f}; - OrientationPrinters::Print_RO(ro); - RO_2_XXX(ro); - RO_2_XXX(ro); - RO_2_XXX(ro); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void AX_2_XXX(K* in) - { - T ax(4); - ax[0] = in[0]; - ax[1] = in[1]; - ax[2] = in[2]; - ax[3] = in[3]; - - T res(9); - // Convert to Orientation Matrix - res = OrientationTransformation::ax2om(ax); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ax2eu(ax); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::ax2ro(ax); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - Quaternion quat = OrientationTransformation::ax2qu>(ax); - OrientationPrinters::Print_QU>(quat); - - // Convert to homochoric - res = OrientationTransformation::ax2ho(ax); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::ax2cu(ax); - OrientationPrinters::Print_CU(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ax2_XXX() - { - std::cout << "Test_ax2_XXX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl; - float ax[4] = {0.0F, 0.0F, -1.0F, k_PiOver2F}; - OrientationPrinters::Print_AX(ax); - AX_2_XXX(ax); - AX_2_XXX>(ax); - AX_2_XXX(ax); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void QU_2_XXX(K* in, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) - { - using QuatType = Quaternion; - QuatType qu(in[0], in[1], in[2], in[3]); - - // Convert to Orientation Matrix - T res = OrientationTransformation::qu2om(qu, layout); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::qu2eu(qu, layout); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::qu2ro(qu, layout); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - res = OrientationTransformation::qu2ax(qu, layout); - OrientationPrinters::Print_AX(res); - - // Convert to Homochoric - res = OrientationTransformation::qu2ho(qu, layout); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::qu2cu(qu, layout); - OrientationPrinters::Print_CU(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_qu2_XXX() - { - { - std::cout << "Test_qu2_XXX (SCALAR, ) ***************************************" << std::endl; - float qu[4] = {EbsdLib::Constants::k_1OverRoot2F, 0.0f, 0.0f, -EbsdLib::Constants::k_1OverRoot2F}; - OrientationPrinters::Print_QU({qu[0], qu[1], qu[2], qu[3]}, QuatD::Order::ScalarVector); - QU_2_XXX(qu, QuatF::Order::ScalarVector); - // QU_2_XXX >(qu); - // QU_2_XXX(qu); - } - - { - std::cout << "Test_qu2_XXX (, SCALAR) ***************************************" << std::endl; - float qu[4] = {0.0f, 0.0f, -EbsdLib::Constants::k_1OverRoot2F, EbsdLib::Constants::k_1OverRoot2F}; - OrientationPrinters::Print_QU({qu[0], qu[1], qu[2], qu[3]}); - QU_2_XXX(qu); - // QU_2_XXX >(qu); - // QU_2_XXX(qu); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void HO_2_XXX(K* in) - { - using QuatType = Quaternion; - - T ho(3); - ho[0] = in[0]; - ho[1] = in[1]; - ho[2] = in[2]; - - T res(9); - - // Convert to Euler - res = OrientationTransformation::ho2eu(ho); - OrientationPrinters::Print_EU(res); - - // Convert to Orientation Matrix - res = OrientationTransformation::ho2om(ho); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ho2ax(ho); - OrientationPrinters::Print_AX(res); - - // Convert to Rodriques - res = OrientationTransformation::ho2ro(ho); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - QuatType quat = OrientationTransformation::ho2qu(ho); - OrientationPrinters::Print_QU(quat); - - // Convert to HomoChoric - res = OrientationTransformation::ho2cu(ho); - OrientationPrinters::Print_CU(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ho2_XXX() - { - std::cout << "Test_ho2_XXX &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl; - float ho[3] = {0.000000f, 0.000000f, -0.7536693215f}; - OrientationPrinters::Print_HO(ho); - HO_2_XXX(ho); - HO_2_XXX>(ho); - HO_2_XXX(ho); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestInputs() - { - const float k_PiOver180f = EbsdLib::Constants::k_PiOver180F; - std::vector cDims(1, 3); - EbsdLib::FloatArrayType::Pointer data = EbsdLib::FloatArrayType::CreateArray(2, cDims, "Eulers", true); - data->initializeWithZeros(); - float* fPtr = data->getPointer(0); - fPtr[0] = 90.0F * k_PiOver180f; - fPtr[1] = 0.0F; - fPtr[2] = 0.0F; - fPtr[3] = 90.0F * k_PiOver180f; - fPtr[4] = 0.0F; - fPtr[5] = 0.0F; - - //& Notation - { - FOrientArrayType eu(&(fPtr[0]), 3); // Wrap the pointer with the ¬ation - eu[0] = 45.0F * k_PiOver180f; - eu[1] = 90.0F * k_PiOver180f; - eu[2] = 135.0F * k_PiOver180f; - - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[0]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[1]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[2]); - } - - // Pointer Arithmetic (inputs) - { - FOrientArrayType eu(fPtr + 3, 3); - eu[0] = 135.0F * k_PiOver180f; - eu[1] = 45.0F * k_PiOver180f; - eu[2] = 90.0F * k_PiOver180f; - - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[5]); - } - - // Pointer Arithmetic, placing results directly into an array - { - FOrientArrayType ax(0.0F, 0.0F, -1.0F, EbsdLib::Constants::k_PiOver2F); - FOrientArrayType eu = OrientationTransformation::ax2eu(ax); - eu.copyInto(fPtr + 3, 3); - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[5]); - - bool b = EbsdLibMath::closeEnough(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(b, true) - b = EbsdLibMath::closeEnough(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(b, true) - b = EbsdLibMath::closeEnough(eu[2], fPtr[5]); - DREAM3D_REQUIRE_EQUAL(b, true) - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void QuatTest() - { - QuatF q(-0.5f, -0.5f, -0.5f, 0.5f); - using VecType = std::vector; - VecType qVec = {-0.5f, -0.5f, -0.5f, 0.5f}; - - VecType gVec = OrientationTransformation::qu2om(qVec); - - OrientationPrinters::Print_OM>(gVec); - - float g[3][3]; - - g[0][0] = gVec[0]; - g[0][1] = gVec[1]; - g[0][2] = gVec[2]; - g[1][0] = gVec[3]; - g[1][1] = gVec[4]; - g[1][2] = gVec[5]; - g[2][0] = gVec[6]; - g[2][1] = gVec[7]; - g[2][2] = gVec[8]; - - for(size_t r = 0; r < 3; r++) - { - for(size_t c = 0; c < 3; c++) - { - g[c][r] = gVec[3 * r + c]; - std::cout << c << "," << r << "=" << g[c][r] << std::endl; - } - } - - std::array vg; - std::array v = {1.0F, 0.0F, 0.0F}; - - // Mathematically correct, results unintuitive - std::array vq = q.multiplyByVector(v.data()); - - std::cout << "vq: " << vq[0] << "," << vq[1] << "," << vq[2] << std::endl; - - EbsdMatrixMath::Multiply3x3with3x1(g, v.data(), vg.data()); - std::cout << "vg: " << vg[0] << "," << vg[1] << "," << vg[2] << std::endl; - } - - // ----------------------------------------------------------------------------- - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestRotArray()); - DREAM3D_REGISTER_TEST(Test_eu_check()); - DREAM3D_REGISTER_TEST(Test_ro_check()); - DREAM3D_REGISTER_TEST(Test_ho_check()); - DREAM3D_REGISTER_TEST(Test_cu_check()); - DREAM3D_REGISTER_TEST(Test_qu_check()); - DREAM3D_REGISTER_TEST(Test_ax_check()); - DREAM3D_REGISTER_TEST(Test_om_check()); - - DREAM3D_REGISTER_TEST(Test_GenRot()) - - DREAM3D_REGISTER_TEST(Test_eu2_XXX()); - DREAM3D_REGISTER_TEST(Test_eu2_XXX()); - - DREAM3D_REGISTER_TEST(Test_ax2_XXX()); - DREAM3D_REGISTER_TEST(Test_om2_XXX()); - DREAM3D_REGISTER_TEST(Test_ro2_XXX()); - DREAM3D_REGISTER_TEST(Test_qu2_XXX()); - DREAM3D_REGISTER_TEST(Test_ho2_XXX()); - - DREAM3D_REGISTER_TEST(TestInputs()); - } -}; diff --git a/Source/Test/OrientationConverterTest.cpp b/Source/Test/OrientationConverterTest.cpp index 17a06e04..efa22d2a 100644 --- a/Source/Test/OrientationConverterTest.cpp +++ b/Source/Test/OrientationConverterTest.cpp @@ -97,8 +97,8 @@ class OrientationConverterTest DREAM3D_REQUIRE(delta < 1.0E6); } - OrientationF euler = {302.84f * EbsdLib::Constants::k_PiOver180F, 51.282f * EbsdLib::Constants::k_PiOver180F, 37.969f * EbsdLib::Constants::k_PiOver180F}; - QuatF qOut = OrientationTransformation::eu2qu(euler); + EulerFType euler = {302.84f * EbsdLib::Constants::k_PiOver180F, 51.282f * EbsdLib::Constants::k_PiOver180F, 37.969f * EbsdLib::Constants::k_PiOver180F}; + QuatF qOut = OrientationTransformation::eu2qu(euler); OrientationPrinters::Print_QU(qOut); } diff --git a/Source/Test/OrientationRepresentationTransformTest.cpp b/Source/Test/OrientationRepresentationTransformTest.cpp new file mode 100644 index 00000000..3119d1c2 --- /dev/null +++ b/Source/Test/OrientationRepresentationTransformTest.cpp @@ -0,0 +1,563 @@ + +#include "EbsdLib/Core/EbsdDataArray.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" + +#include "EbsdLib/Test/EbsdLibTestFileLocations.h" +#include "GenerateFunctionList.h" +#include "TestPrintFunctions.h" +#include "UnitTestSupport.hpp" + +#include +#include +#include +#include +#include +#include + +using namespace EbsdLib; + +class OrientationRepresentationTransformTest +{ +public: + OrientationRepresentationTransformTest() = default; + virtual ~OrientationRepresentationTransformTest() = default; + + OrientationRepresentationTransformTest(const OrientationRepresentationTransformTest&) = delete; // Copy Constructor Not Implemented + OrientationRepresentationTransformTest(OrientationRepresentationTransformTest&&) = delete; // Move Constructor Not Implemented + OrientationRepresentationTransformTest& operator=(const OrientationRepresentationTransformTest&) = delete; // Copy Assignment Not Implemented + OrientationRepresentationTransformTest& operator=(OrientationRepresentationTransformTest&&) = delete; // Move Assignment Not Implemented + + EBSD_GET_NAME_OF_CLASS_DECL(OrientationRepresentationTransformTest) + + void Test1() + { + + { + EulerDType euler(0.0, 0.0, 0.0); + QuatD quat = euler.toQuat(); + EulerDType e1 = euler.toOrientationMatrix().toEuler(); + } + + { + QuatD quat = EulerDType(0.0f, 0.0f, 0.0f).toOrientationMatrix().toQuat(); + OrientationPrinters::Print_QU(quat); + } + + { + AxisAngleDType ax = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle(); + OrientationMatrixDType om = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix(); + RodriguesDType ro = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues(); + HomochoricDType ho = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues().toHomochoric(); + CubochoricDType cu = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues().toHomochoric().toCubochoric(); + + QuatD quat = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toQuat(); + } + + AxisAngleDType ax = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle(); + OrientationPrinters::Print_AX(ax); + } + + std::string k_MethodNames[s_NumReps] = {"Euler", "OrientationMatrix", "Quaternion", "AxisAngle", "Rodrigues", "Homochoric", "Cubochoric", "Stereographic"}; + int k_CompDims[s_NumReps] = {3, 9, 4, 4, 4, 3, 3, 3}; + + template + void printVector(const std::vector& vec) + { + std::cout << " GENERATE_TEST_METHOD("; + for(size_t i = 0; i < vec.size(); i++) + { + // std::cout << vec[i]; + std::cout << k_MethodNames[vec[i]] << ""; + if(i < vec.size() - 1) + { + std::cout << ", "; + } + } + std::cout << ");"; + } + + void StartTest() + { + // std::vector functionNames = OrientationConverter::GetOrientationTypeStrings(); + + GenerateFunctionList generator; + std::vector entries = generator.GeneratePermutationsOfCombinations(s_NumReps, 3); + // This outer loop will group the tests based on the first orientation representation + for(int t = 0; t < s_NumReps; t++) + { + std::cout << "void " << k_MethodNames[t] << "Test() {\n"; + std::cout << " TEST_PREAMBLE();\n\n"; + for(auto& entry : entries) + { + if(entry[0] != t) + { + continue; + } + entry.push_back(entry[0]); + { + // RunTestCase(entry, 16); + printVector(entry); + std::cout << "\n"; + } + } + std::cout << "}\n\n"; + } + } + +#define TEST_PREAMBLE() \ + using EbsdDataArrayType = EbsdDataArray; \ + using EbsdDataArrayPointerType = EbsdDataArrayType::Pointer; \ + size_t nSteps = 16; \ + std::map attrMat; \ + generate_test_data::GenerateEulers(nSteps, attrMat); \ + EbsdDataArrayType& inputArray = *(attrMat["eu"]); \ + size_t numTuples = inputArray.getNumberOfTuples(); \ + double tolerance = 1.0E-3; \ + std::string k_EulerStr("Euler"); + +#define GENERATE_TEST_METHOD_EU(TYPE1, TYPE2, TYPE3, TYPE4) \ + { \ + std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ + for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ + { \ + const EulerDType euler = EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ + const TYPE1##DType type1 = euler.to##TYPE1(); \ + const TYPE2##DType type2 = type1.to##TYPE2(); \ + const TYPE3##DType type3 = type2.to##TYPE3(); \ + TYPE4##DType type4 = type3.to##TYPE4().toOrientationMatrix().toEuler(); \ + bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ + if(!withinTolerance) \ + { \ + std::cout << "Index: " << tupleIdx << "\n"; \ + std::cout << type1 << "\n"; \ + std::cout << type4 << "\n"; \ + } \ + DREAM3D_REQUIRED(withinTolerance, ==, true) \ + } \ + } + +#define GENERATE_TEST_METHOD(TYPE1, TYPE2, TYPE3, TYPE4) \ + { \ + std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ + for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ + { \ + const EulerDType euler = EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ + const TYPE1##DType type1 = euler.to##TYPE1(); \ + const TYPE2##DType type2 = type1.to##TYPE2(); \ + const TYPE3##DType type3 = type2.to##TYPE3(); \ + TYPE4##DType type4 = type3.to##TYPE4(); \ + bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ + if(!withinTolerance) \ + { \ + std::cout << "Index: " << tupleIdx << "\n"; \ + std::cout << type1 << "\n"; \ + std::cout << type4 << "\n"; \ + } \ + DREAM3D_REQUIRED(withinTolerance, ==, true) \ + } \ + } + + void EulerTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Cubochoric, Euler); + } + + void OrientationMatrixTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Cubochoric, OrientationMatrix); + } + + void QuaternionTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Quaternion, Euler, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Cubochoric, Quaternion); + } + + void AxisAngleTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(AxisAngle, Euler, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Cubochoric, AxisAngle); + } + + void RodriguesTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Rodrigues, Euler, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Cubochoric, Rodrigues); + } + + void HomochoricTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Homochoric, Euler, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Cubochoric, Homochoric); + } + + void CubochoricTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Cubochoric, Euler, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Homochoric, Cubochoric); + } + + void StereographicTest() + { + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Stereographic, Euler, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Homochoric, Stereographic); + } + + // ----------------------------------------------------------------------------- + void operator()() + { + std::cout << "<===== Start " << getNameOfClass() << std::endl; + + int err = EXIT_SUCCESS; + // DREAM3D_REGISTER_TEST(StartTest()); + + DREAM3D_REGISTER_TEST(Test1()); + + DREAM3D_REGISTER_TEST(EulerTest()); + DREAM3D_REGISTER_TEST(OrientationMatrixTest()); + DREAM3D_REGISTER_TEST(QuaternionTest()); + DREAM3D_REGISTER_TEST(AxisAngleTest()); + DREAM3D_REGISTER_TEST(RodriguesTest()); + DREAM3D_REGISTER_TEST(HomochoricTest()); + DREAM3D_REGISTER_TEST(CubochoricTest()); + DREAM3D_REGISTER_TEST(StereographicTest()); + } +}; diff --git a/Source/Test/OrientationTest.cpp b/Source/Test/OrientationTest.cpp deleted file mode 100644 index b83ab407..00000000 --- a/Source/Test/OrientationTest.cpp +++ /dev/null @@ -1,1036 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include - -#if __APPLE__ -#include -#endif - -#include -#include -#include -#include - -#include - -#include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/Orientation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" -#include "EbsdLib/EbsdLib.h" -#include "EbsdLib/Math/ArrayHelpers.hpp" -#include "EbsdLib/Math/EbsdLibMath.h" -#include "EbsdLib/Math/EbsdMatrixMath.h" - -using namespace EbsdLib::Constants; - -#include "EbsdLib/Test/EbsdLibTestFileLocations.h" -#include "TestPrintFunctions.h" -#include "UnitTestSupport.hpp" - -class OrientationTest -{ -public: - OrientationTest() = default; - virtual ~OrientationTest() = default; - - using FloatVectorType = std::vector; - using DoubleVectorType = std::vector; - - EBSD_GET_NAME_OF_CLASS_DECL(OrientationTest) - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - T transfer_sign(T a, T b) - { - if(a > 0.0 && b > 0.0) - { - return a; - } - if(a < 0.0 && b > 0.0) - { - return -1 * a; - } - - if(a < 0.0 && b < 0.0) - { - return a; - } - - return -1 * a; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestRotArray() - { - OrientationF ro(3); - ro[0] = 2; - ro[1] = 4; - ro[2] = 6; - // float sum = ro.sum(); - // DREAM3D_REQUIRE_EQUAL(sum, 12); - - // DREAM3D_REQUIRE_EQUAL(ro.size(), 3); - - // DREAM3D_REQUIRE_EQUAL(ro.maxval(), 6); - // DREAM3D_REQUIRE_EQUAL(ro.minval(), 2); - - // float pro = ro.product(); - // DREAM3D_REQUIRE_EQUAL(pro, 48); - // sum = result.sum(); - // float max = result.maxval(); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_eu_check() - { - { - - OrientationTransformation::ResultType result; - OrientationF eu_r(3); - eu_r[0] = 0.81585413f; - eu_r[1] = 3.00f; - eu_r[2] = 0.8661895f; - result = OrientationTransformation::eu_check(eu_r); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - eu_r[1] = eu_r[1] - EbsdLib::Constants::k_PiF; - result = OrientationTransformation::eu_check(eu_r); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - { - OrientationTransformation::ResultType result; - FloatVectorType eu_v(3); - eu_v[0] = 1.0f; - eu_v[1] = 0.4f; - eu_v[2] = 0.9f; - result = OrientationTransformation::eu_check(eu_v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - eu_v[0] = -1.0; - result = OrientationTransformation::eu_check(eu_v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ro_check() - { - { - OrientationTransformation::ResultType result; - OrientationF ro(4); - ro[0] = 1.0f; - ro[1] = 1.0f; - ro[2] = 1.0f; - ro[3] = 1.0f; - EbsdMatrixMath::Normalize3x1(&(ro[0])); - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ro[3] = -1.0; - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType ro(4); - ro[0] = 1.0f; - ro[1] = 1.0f; - ro[2] = 1.0f; - ro[3] = 1.0f; - EbsdMatrixMath::Normalize3x1(&(ro[0])); - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ro[3] = -1.0; - result = OrientationTransformation::ro_check(ro); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ho_check() - { - { - OrientationTransformation::ResultType result; - OrientationF ho(3); - ho[0] = 0.5f; - ho[1] = 0.5f; - ho[2] = 0.5f; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ho[2] = 8.0; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType ho(3); - ho[0] = 0.5f; - ho[1] = 0.5f; - ho[2] = 0.5f; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - ho[2] = 8.0; - result = OrientationTransformation::ho_check(ho); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_cu_check() - { - { - OrientationTransformation::ResultType result; - OrientationF v(3); - v[0] = 0.5f; - v[1] = 0.5f; - v[2] = 0.5f; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - v[2] = 8.0; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType v(3); - v[0] = 0.5f; - v[1] = 0.5f; - v[2] = 0.5f; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - v[2] = 8.0; - result = OrientationTransformation::cu_check(v); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_qu_check() - { - QuatF quat(1.0, 1.0, 1.0, 0.0); - quat.normalize(); - - { - OrientationTransformation::ResultType result; - OrientationF qu(4); - qu[0] = quat.x(); - qu[1] = quat.y(); - qu[2] = quat.z(); - qu[3] = quat.w(); - EbsdMatrixMath::Normalize3x1(&(qu[0])); - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - qu[0] = 1.5f; - qu[1] = 3.0f; - qu[2] = 2.0f; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - qu[0] = -1.0; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType qu(4); - qu[0] = quat.x(); - qu[1] = quat.y(); - qu[2] = quat.z(); - qu[3] = quat.w(); - EbsdMatrixMath::Normalize3x1(&(qu[0])); - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - qu[0] = 1.5f; - qu[1] = 3.0f; - qu[2] = 2.0f; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - qu[0] = -1.0; - result = OrientationTransformation::qu_check(qu); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ax_check() - { - { - - OrientationTransformation::ResultType result; - OrientationF ax(4); - ax[0] = 0.0f; - ax[1] = 0.0f; - ax[2] = 1.0f; - ax[3] = EbsdLib::Constants::k_PiF - 0.00001f; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[0] = 1.0; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0f; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType ax(4); - ax[0] = 0.0f; - ax[1] = 0.0f; - ax[2] = 1.0f; - ax[3] = EbsdLib::Constants::k_PiF - 0.00001f; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[0] = 1.0; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0f; - result = OrientationTransformation::ax_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -1); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_om_check() - { - { - - OrientationTransformation::ResultType result; - OrientationF ax(9); - ax[0] = 1.0f; - ax[1] = 0.0f; - ax[2] = 0.0f; - ax[3] = 0.0f; - ax[4] = 1.0f; - ax[5] = 0.0f; - ax[6] = 0.0f; - ax[7] = 0.0f; - ax[8] = 1.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[1] = -16.0f; - ax[6] = -12.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -3); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - - { - OrientationTransformation::ResultType result; - FloatVectorType ax(9); - ax[0] = 1.0f; - ax[1] = 0.0f; - ax[2] = 0.0f; - ax[3] = 0.0f; - ax[4] = 1.0f; - ax[5] = 0.0f; - ax[6] = 0.0f; - ax[7] = 0.0f; - ax[8] = 1.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, 1); - - ax[1] = -16.0f; - ax[6] = -12.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -3); - - ax[3] = EbsdLib::Constants::k_PiF + 1.0f; - result = OrientationTransformation::om_check(ax); - DREAM3D_REQUIRE_EQUAL(result.result, -2); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void GenRotTest(K* in, K omega) - { - T eu(3); - eu[0] = in[0]; - eu[1] = in[1]; - eu[2] = in[2]; - - T res(4); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_GenRot() - { - - float eu[3] = {1.0f, 0.0f, 0.0f}; - float omega = EbsdLib::Constants::k_PiOver2F; - GenRotTest(eu, omega); - GenRotTest(eu, omega); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void EU_2_XXX(K* in) - { - - T eu(3); - eu[0] = in[0]; - eu[1] = in[1]; - eu[2] = in[2]; - - eu[0] = static_cast(std::fmod(eu[0], EbsdLib::Constants::k_2PiD)); - eu[1] = static_cast(std::fmod(eu[1], EbsdLib::Constants::k_PiD)); - eu[2] = static_cast(std::fmod(eu[2], EbsdLib::Constants::k_2PiD)); - - T res(9); - - OrientationTransformation::ResultType result = OrientationTransformation::eu_check(eu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ax = OrientationTransformation::eu2ax(eu); - OrientationPrinters::Print_AX(ax); - result = OrientationTransformation::ax_check(ax); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ro = OrientationTransformation::eu2ro(eu); - OrientationPrinters::Print_RO(ro); - result = OrientationTransformation::ro_check(ro); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T ho = OrientationTransformation::eu2ho(eu); - OrientationPrinters::Print_HO(ho); - result = OrientationTransformation::ho_check(ho); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T cu = OrientationTransformation::eu2cu(eu); - OrientationPrinters::Print_CU(cu); - result = OrientationTransformation::cu_check(cu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; - cu = OrientationTransformation::ho2cu(ho); - OrientationPrinters::Print_CU(cu); - result = OrientationTransformation::cu_check(cu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - Quaternion qu = OrientationTransformation::eu2qu>(eu); - OrientationPrinters::Print_QU>(qu); - result = OrientationTransformation::qu_check(qu); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - - T om = OrientationTransformation::eu2om(eu); - OrientationPrinters::Print_OM(om); - result = OrientationTransformation::om_check(om); - if(result.result <= 0) - { - std::cout << result.msg << std::endl; - } - } - - /* -Starting Test ax2eu eu2ax ----------------------------------------------------- -Total Tuples: 4913 -Delta Failed: 1.99037 DataArray: 'ax Difference' Tuple[263] Comp[1] Value:-1.99037 -eu -0.0000000000000000 2.9452431201934814 3.1415927410125732 -ax --0.0000000435009078 -0.9951847195625305 0.0980171412229538 3.1415927410125732 -0_ax2eu -6.2831850051879883 2.9452428817749023 3.1415922641754150 -1_eu2ax --0.0000000435009078 0.9951847195625305 -0.0980172604322433 3.1415925025939941 ------------------------------------------- -ax2eu eu2ax FAILED -*/ - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void Test_eu2_XXX() - { - using OrientType = Orientation; - using VectorType = std::vector; - // using QVectorType = std::vector; - { - K eu[3] = {static_cast(0.3926990816987242L), static_cast(0.0L), static_cast(0.0L)}; - OrientationPrinters::Print_EU(eu); - EU_2_XXX(eu); - EU_2_XXX(eu); - // EU_2_XXX(eu); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void OM_2_XXX(K* in) - { - std::cout << " " << std::endl; - T om(9); - for(size_t i = 0; i < 9; i++) - { - om[i] = in[i]; - } - - // Convert to Euler - T res = OrientationTransformation::om2eu(om); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::om2ro(om); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - Quaternion qres = OrientationTransformation::om2qu>(om); - OrientationPrinters::Print_QU>(qres, Quaternion::Order::ScalarVector); - - // Convert to Axis Angle - res = OrientationTransformation::om2ax(om); - OrientationPrinters::Print_AX(res); - - // Convert to Homochoric - res = OrientationTransformation::om2ho(om); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::om2cu(om); - OrientationPrinters::Print_CU(res); - - // Convert to Stereographic - res = OrientationTransformation::om2st(om); - OrientationPrinters::Print_ST(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_om2_XXX() - { - /* ----------------------------------------------------- -Euler angles : 90.0000000 0.0000000 0.0000000 -Axis angle pair [n; angle] : -0.0000000 -0.0000000 -1.0000000 ; 90.0000000 -Rodrigues vector : -0.0000000 -0.0000000 -1.0000000 -Homochoric representation : -0.0000000 -0.0000000 -0.7536693 -Cubochoric representation : 0.0000000 0.0000000 -0.6074544 -Quaternion : 0.7071068 -0.0000000 -0.0000000 -0.7071068 - / 0.0000 1.0000 0.0000 \ -Orientation Matrix : | -1.0000 0.0000 0.0000 | - \ 0.0000 0.0000 1.0000 / -*/ - std::cout << "Test_om2_XXX $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; - float om[9] = {0.0000f, 1.0000f, 0.0000f, -1.0000f, 0.0000f, 0.0000f, 0.0000f, 0.0000f, 1.0000f}; - OrientationPrinters::Print_OM(om); - OM_2_XXX(om); - OM_2_XXX(om); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void RO_2_XXX(K* in) - { - T ro(4); - for(size_t i = 0; i < 4; i++) - { - ro[i] = in[i]; - } - - T res(9); // Just size to 9 as we are going to reuse the variable - - // Convert to Euler - res = OrientationTransformation::ro2eu(ro); - OrientationPrinters::Print_EU(res); - - // Convert to Orientation Matrix - res = OrientationTransformation::ro2om(ro); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ro2ax(ro); - OrientationPrinters::Print_AX(res); - - // Convert to Quaternion - Quaternion qres = OrientationTransformation::ro2qu>(ro); - OrientationPrinters::Print_QU>(qres); - - // Convert to Homochoric - res = OrientationTransformation::ro2ho(ro); - OrientationPrinters::Print_HO(res); - - // Convert to CuboChoric - res = OrientationTransformation::ro2cu(ro); - OrientationPrinters::Print_CU(res); - - // Convert to Stereographic - res = OrientationTransformation::ro2st(ro); - OrientationPrinters::Print_ST(res); - - // Convert to Stereographic and back - OrientationPrinters::Print_RO(ro); - OrientationPrinters::Print_ST(res); - res = OrientationTransformation::st2ro(res); - OrientationPrinters::Print_RO(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ro2_XXX() - { - std::cout << "Test_ro2_XXX @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl; - float ro[4] = {0.0f, 0.0f, -1.0f, 1.0f}; - OrientationPrinters::Print_RO(ro); - RO_2_XXX(ro); - RO_2_XXX(ro); - } - - // ----------------------------------------------------------------------------- - template - void ST_2_XXX(K* in) - { - T st(3); - for(size_t i = 0; i < 3; i++) - { - st[i] = in[i]; - } - - T res(9); // Just size to 9 as we are going to reuse the variable - - // Convert to Euler - res = OrientationTransformation::st2eu(st); - OrientationPrinters::Print_EU(res); - - // Convert to Orientation Matrix - res = OrientationTransformation::st2om(st); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::st2ax(st); - OrientationPrinters::Print_AX(res); - - // Convert to Quaternion - Quaternion qres = OrientationTransformation::st2qu>(st); - OrientationPrinters::Print_QU>(qres); - - // Convert to Homochoric - res = OrientationTransformation::st2ho(st); - OrientationPrinters::Print_HO(res); - - // Convert to CuboChoric - res = OrientationTransformation::st2cu(st); - OrientationPrinters::Print_CU(res); - - // Convert to Rodrigues - res = OrientationTransformation::st2ro(st); - OrientationPrinters::Print_RO(res); - } - - // ----------------------------------------------------------------------------- - /* -Stereographic : -0.1989 0.0000 0.0000 -Euler angles : 0.0000000 45.0000000 0.0000000 - / 1.0000 0.0000 0.0000 \ -Orientation Matrix : | 0.0000 0.7071 0.7071 | - \ 0.0000 -0.7071 0.7071/ -Axis angle pair [n; angle] : -1.0000000 0.0000000 0.0000000 ; 45.0000000 -Quaternion : <-0.3826834 0.0000000 0.0000000 > 0.9238795 -Homochoric representation : -0.3886796 0.0000000 0.0000000 -Cubochoric representation : -0.3132742 0.0000000 0.0000000 -Rodrigues vector : -0.4142136 0.0000000 0.0000000 - -Rotation vector map : -0.7854 0.0000 0.0000 - -*/ - void Test_st2_XXX() - { - std::cout << "Test_st2_XXX @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl; - float st[3] = {0.0F, 0.0F, 0.0F}; - OrientationPrinters::Print_ST(st); - ST_2_XXX(st); - ST_2_XXX(st); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void AX_2_XXX(K* in) - { - T ax(4); - ax[0] = in[0]; - ax[1] = in[1]; - ax[2] = in[2]; - ax[3] = in[3]; - - T res(9); - - // Convert to Orientation Matrix - res = OrientationTransformation::ax2om(ax); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ax2eu(ax); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::ax2ro(ax); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - Quaternion qres = OrientationTransformation::ax2qu>(ax); - OrientationPrinters::Print_QU>(qres); - - // Convert to homochoric - res = OrientationTransformation::ax2ho(ax); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::ax2cu(ax); - OrientationPrinters::Print_CU(res); - - // Convert to Stereographic - res = OrientationTransformation::ax2st(ax); - OrientationPrinters::Print_ST(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ax2_XXX() - { - std::cout << "Test_ax2_XXX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl; - float ax[4] = {0.0f, 0.0f, -1.0f, k_PiOver2F}; - OrientationPrinters::Print_AX(ax); - AX_2_XXX(ax); - AX_2_XXX>(ax); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void QU_2_XXX(K* in, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) - { - T qu(4); - qu[0] = in[0]; - qu[1] = in[1]; - qu[2] = in[2]; - qu[3] = in[3]; - - using OrientationType = Orientation; - OrientationType res(9); - - // Convert to Orientation Matrix - res = OrientationTransformation::qu2om(qu, layout); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::qu2eu(qu, layout); - OrientationPrinters::Print_EU(res); - - // Convert to Rodriques - res = OrientationTransformation::qu2ro(qu, layout); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - res = OrientationTransformation::qu2ax(qu, layout); - OrientationPrinters::Print_AX(res); - - // Convert to Homochoric - res = OrientationTransformation::qu2ho(qu, layout); - OrientationPrinters::Print_HO(res); - - // Convert to HomoChoric - res = OrientationTransformation::qu2cu(qu, layout); - OrientationPrinters::Print_CU(res); - - // Convert to Stereographic - res = OrientationTransformation::qu2st(qu, layout); - OrientationPrinters::Print_ST(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_qu2_XXX() - { - { - std::cout << "Test_qu2_XXX (SCALAR, ) ***************************************" << std::endl; - float qu[4] = {EbsdLib::Constants::k_1OverRoot2F, 0.0f, 0.0f, -EbsdLib::Constants::k_1OverRoot2F}; - OrientationPrinters::Print_QU({qu[0], qu[1], qu[2], qu[3]}, QuatF::Order::ScalarVector); - using QuatFType = Quaternion; - QU_2_XXX(qu, QuatF::Order::ScalarVector); - // QU_2_XXX >(qu); - // QU_2_XXX(qu); - } - - { - std::cout << "Test_qu2_XXX (, SCALAR) ***************************************" << std::endl; - float qu[4] = {0.0f, 0.0f, -EbsdLib::Constants::k_1OverRoot2F, EbsdLib::Constants::k_1OverRoot2F}; - OrientationPrinters::Print_QU({qu[0], qu[1], qu[2], qu[3]}); - using QuatFType = Quaternion; - QU_2_XXX(qu); - // QU_2_XXX >(qu); - // QU_2_XXX(qu); - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void HO_2_XXX(K* in) - { - T ho(3); - ho[0] = in[0]; - ho[1] = in[1]; - ho[2] = in[2]; - - T res(9); - - // Convert to Euler - res = OrientationTransformation::ho2eu(ho); - OrientationPrinters::Print_EU(res); - - // Convert to Orientation Matrix - res = OrientationTransformation::ho2om(ho); - OrientationPrinters::Print_OM(res); - - // Convert to Axis Angle - res = OrientationTransformation::ho2ax(ho); - OrientationPrinters::Print_AX(res); - - // Convert to Rodriques - res = OrientationTransformation::ho2ro(ho); - OrientationPrinters::Print_RO(res); - - // Convert to Quaternion - Quaternion qres = OrientationTransformation::ho2qu>(ho); - OrientationPrinters::Print_QU>(qres); - - // Convert to HomoChoric - res = OrientationTransformation::ho2cu(ho); - OrientationPrinters::Print_CU(res); - - // Convert to Stereographic - res = OrientationTransformation::ho2st(ho); - OrientationPrinters::Print_ST(res); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void Test_ho2_XXX() - { - std::cout << "Test_ho2_XXX &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&" << std::endl; - float ho[3] = {0.000000f, 0.000000f, -0.7536693215f}; - OrientationPrinters::Print_HO(ho); - HO_2_XXX(ho); - HO_2_XXX>(ho); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestInputs() - { - std::vector cDims(1, 3); - EbsdLib::FloatArrayType::Pointer data = EbsdLib::FloatArrayType::CreateArray(2, cDims, "Eulers", true); - data->initializeWithZeros(); - float* fPtr = data->getPointer(0); - fPtr[0] = 90.0f * EbsdLib::Constants::k_PiOver180F; - fPtr[1] = 0.0f; - fPtr[2] = 0.0f; - fPtr[3] = 90.0f * EbsdLib::Constants::k_PiOver180F; - fPtr[4] = 0.0f; - fPtr[5] = 0.0f; - - //& Notation - { - OrientationF eu(&(fPtr[0]), 3); // Wrap the pointer with the ¬ation - eu[0] = 45.0f * EbsdLib::Constants::k_PiOver180F; - eu[1] = 90.0f * EbsdLib::Constants::k_PiOver180F; - eu[2] = 135.0f * EbsdLib::Constants::k_PiOver180F; - - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[0]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[1]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[2]); - } - - // Pointer Arithmetic (inputs) - { - OrientationF eu(fPtr + 3, 3); - eu[0] = 135.0f * EbsdLib::Constants::k_PiOver180F; - eu[1] = 45.0f * EbsdLib::Constants::k_PiOver180F; - eu[2] = 90.0f * EbsdLib::Constants::k_PiOver180F; - - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[5]); - } - - // Pointer Arithmetic, placing results directly into an array - { - OrientationF ax(0.0f, 0.0f, -1.0f, EbsdLib::Constants::k_PiOver2F); - OrientationF eu(fPtr + 3, 3); - eu = OrientationTransformation::ax2eu(ax); - - DREAM3D_REQUIRE_EQUAL(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(eu[2], fPtr[5]); - - bool b = EbsdLibMath::closeEnough(eu[0], fPtr[3]); - DREAM3D_REQUIRE_EQUAL(b, true) - b = EbsdLibMath::closeEnough(eu[1], fPtr[4]); - DREAM3D_REQUIRE_EQUAL(b, true) - b = EbsdLibMath::closeEnough(eu[2], fPtr[5]); - DREAM3D_REQUIRE_EQUAL(b, true) - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void QuatTest() - { - QuatF q(-0.5f, -0.5f, -0.5f, 0.5f); - using VecFType = std::vector; - VecFType qVec = {-0.5f, -0.5f, -0.5f, 0.5f}; - VecFType gVec(9, 0); - - gVec = OrientationTransformation::qu2om(qVec); - - OrientationPrinters::Print_OM(gVec); - - float g[3][3]; - - g[0][0] = gVec[0]; - g[0][1] = gVec[1]; - g[0][2] = gVec[2]; - g[1][0] = gVec[3]; - g[1][1] = gVec[4]; - g[1][2] = gVec[5]; - g[2][0] = gVec[6]; - g[2][1] = gVec[7]; - g[2][2] = gVec[8]; - - for(size_t r = 0; r < 3; r++) - { - for(size_t c = 0; c < 3; c++) - { - g[c][r] = gVec[3 * r + c]; - std::cout << c << "," << r << "=" << g[c][r] << std::endl; - } - } - - std::array vq; - std::array vg; - float v[3] = {1.0f, 0.0f, 0.0f}; - - // Mathematically correct, results unintuitive - vq = q.multiplyByVector(v); - - std::cout << "vq: " << vq[0] << "," << vq[1] << "," << vq[2] << std::endl; - - EbsdMatrixMath::Multiply3x3with3x1(g, v, vg.data()); - std::cout << "vg: " << vg[0] << "," << vg[1] << "," << vg[2] << std::endl; - } - - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestRotArray()); - DREAM3D_REGISTER_TEST(Test_eu_check()); - DREAM3D_REGISTER_TEST(Test_ro_check()); - DREAM3D_REGISTER_TEST(Test_ho_check()); - DREAM3D_REGISTER_TEST(Test_cu_check()); - DREAM3D_REGISTER_TEST(Test_qu_check()); - DREAM3D_REGISTER_TEST(Test_ax_check()); - DREAM3D_REGISTER_TEST(Test_om_check()); - - DREAM3D_REGISTER_TEST(Test_GenRot()) - - DREAM3D_REGISTER_TEST(Test_eu2_XXX()); - DREAM3D_REGISTER_TEST(Test_eu2_XXX()); - - DREAM3D_REGISTER_TEST(Test_ax2_XXX()); - DREAM3D_REGISTER_TEST(Test_om2_XXX()); - DREAM3D_REGISTER_TEST(Test_ro2_XXX()); - DREAM3D_REGISTER_TEST(Test_qu2_XXX()); - DREAM3D_REGISTER_TEST(Test_ho2_XXX()); - - DREAM3D_REGISTER_TEST(Test_st2_XXX()); - - DREAM3D_REGISTER_TEST(TestInputs()); - } - -public: - OrientationTest(const OrientationTest&) = delete; // Copy Constructor Not Implemented - OrientationTest(OrientationTest&&) = delete; // Move Constructor Not Implemented - OrientationTest& operator=(const OrientationTest&) = delete; // Copy Assignment Not Implemented - OrientationTest& operator=(OrientationTest&&) = delete; // Move Assignment Not Implemented -}; diff --git a/Source/Test/OrientationTransformationTest.cpp b/Source/Test/OrientationTransformationTest.cpp deleted file mode 100644 index 310fd76d..00000000 --- a/Source/Test/OrientationTransformationTest.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2009-2025 BlueQuartz Software, LLC - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its - * contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The code contained herein was partially funded by the following contracts: - * United States Air Force Prime Contract FA8650-07-D-5800 - * United States Air Force Prime Contract FA8650-10-D-5210 - * United States Prime Contract Navy N00173-07-C-2068 - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include - -#include -#include -#include -#include -#include - -#include "EbsdLib/Common/Observer.h" -#include "EbsdLib/CoreFilters/DataContainerWriter.h" -#include "EbsdLib/DataContainers/DataContainer.h" -#include "EbsdLib/DataContainers/DataContainerArray.h" -#include "EbsdLib/Filtering/AbstractFilter.h" -#include "EbsdLib/Filtering/FilterManager.h" -#include "EbsdLib/Filtering/QMetaObjectUtilities.h" -#include "EbsdLib/Plugin/EbsdLibPluginLoader.h" -#include "EbsdLib/Plugin/IEbsdLibPlugin.h" - -#include "UnitTestSupport.hpp" - -#include "EbsdLib/Core/Orientation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/OrientationMath/OrientationConverter.hpp" - -#include "GenerateFunctionList.h" -#include "OrientationLibTestFileLocations.h" -#include "TestPrintFunctions.h" - -/* - * - -DREAM.3D Testing - - | From/To | e | o | a | r | q | h | c | s | - | - | - | - | - | - | - | - | - | | - | e | # | X | X | X | X | X | | | - | o | X | # | X | X | X | X | | | - | a | X | X | # | X | X | X | | | - | r | X | X | X | # | X | X | | | - | q | X | X | X | X | # | X | | | - | h | X | X | X | X | X | # | | | - | c | | | | | | | # | | - | s | | | | | | | | | - - */ - -class OrientationTransformationTest -{ - bool m_WriteDataFiles = false; - -public: - OrientationTransformationTest() = default; - ~OrientationTransformationTest() = default; - - OrientationTransformationTest(const OrientationTransformationTest&) = delete; // Copy Constructor Not Implemented - OrientationTransformationTest(OrientationTransformationTest&&) = delete; // Move Constructor Not Implemented - OrientationTransformationTest& operator=(const OrientationTransformationTest&) = delete; // Copy Assignment Not Implemented - OrientationTransformationTest& operator=(OrientationTransformationTest&&) = delete; // Move Assignment Not Implemented - - EBSD_GET_NAME_OF_CLASS_DECL(OrientationTransformationTest) - - std::vector DataSetNames; - std::vector DataSetTypes; - - std::string testTempDir() - { - return UnitTest::TestTempDir; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES -// std::fstream::remove(); -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - AbstractFilter::Pointer InstantiateFilter(const std::string& filtName) - { - // Now instantiate the PhWriter Filter from the FilterManager - FilterManager* fm = FilterManager::Instance(); - IFilterFactory::Pointer filterFactory = fm->getFactoryFromClassName(filtName); - if(nullptr == filterFactory.get()) - { - std::stringstream ss; - ss << "The OrientationTransformTest Requires the use of the " << filtName << " filter. Did the plugins load?"; - DREAM3D_TEST_THROW_EXCEPTION(ss.str()) - } - - return filterFactory->create(); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void GenerateEulers(size_t nSteps, const AttributeMatrix::Pointer& attrMat) - { - std::vector cDims(1, 3); - - T phi1_min = static_cast(0.0); - T phi1_max = DConst::k_2Pi; - T phi1_delta = (phi1_max - phi1_min) / static_cast(nSteps); - - T phi_min = static_cast(0.0); - T phi_max = DConst::k_Pi; - T phi_delta = (phi_max - phi_min) / static_cast(nSteps); - - T phi2_min = static_cast(0.0); - T phi2_max = DConst::k_2Pi; - T phi2_delta = (phi2_max - phi2_min) / static_cast(nSteps); - - size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); - typename DataArray::Pointer eulers = DataArray::CreateArray(nStepsCubed, cDims, k_InputNames[0], true); - - size_t counter = 0; - for(int i = 0; i <= nSteps; i++) - { - for(int j = 0; j <= nSteps; j++) - { - for(int k = 0; k <= nSteps; k++) - { - // std::cout << "Euler[" << counter << "]: " - // << (phi1_min+i*phi1_delta)*DConst::k_180OverPi << ", " - // << (phi_min+j*phi_delta)*DConst::k_180OverPi << ", " - // << (phi2_min+k*phi2_delta)*DConst::k_180OverPi << std::endl; - - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta); - eulers->setComponent(counter, 1, phi_min + j * phi_delta); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta); - - T one80Check = phi1_min + i * phi1_delta + phi2_min + k * phi2_delta; - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_Pi), one80Check, static_cast(1.0E-6))) - { - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); - } - - one80Check = fmod(one80Check, EbsdLib::Constants::k_2Pi); - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_Pi), one80Check, static_cast(1.0E-6))) - { - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); - } - - counter++; - } - } - } - - typename EulerConverter::Pointer euConv = EulerConverter::New(); - euConv->setInputData(eulers); - - euConv->toOrientationMatrix(); - typename DataArray::Pointer om = euConv->getOutputData(); - om->setName(k_InputNames[1]); - attrMat->insertOrAssign(om); - - // Create an Orientation matrix from the Eulers and then transform BACK to Eulers to transform - // the values of the Eulers into the convention set forth in the Rotations Paper. - typename OrientationMatrixConverter::Pointer omConv = OrientationMatrixConverter::New(); - omConv->setInputData(om); - omConv->toEulers(); - eulers = omConv->getOutputData(); - eulers->setName(k_InputNames[0]); - euConv->setInputData(eulers); - - attrMat->insertOrAssign(eulers); - - euConv->toQuaternion(); - typename DataArray::Pointer q = euConv->getOutputData(); - q->setName(k_InputNames[2]); - attrMat->insertOrAssign(q); - - euConv->toAxisAngle(); - typename DataArray::Pointer ax = euConv->getOutputData(); - ax->setName(k_InputNames[3]); - attrMat->insertOrAssign(ax); - - euConv->toRodrigues(); - typename DataArray::Pointer ro = euConv->getOutputData(); - ro->setName(k_InputNames[4]); - attrMat->insertOrAssign(ro); - - euConv->toHomochoric(); - typename DataArray::Pointer ho = euConv->getOutputData(); - ho->setName(k_InputNames[5]); - attrMat->insertOrAssign(ho); - - euConv->toCubochoric(); - typename DataArray::Pointer cu = euConv->getOutputData(); - cu->setName(k_InputNames[6]); - attrMat->insertOrAssign(cu); - - euConv->toStereographic(); - typename DataArray::Pointer st = euConv->getOutputData(); - st->setName(k_InputNames[7]); - attrMat->insertOrAssign(st); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - std::string ExecuteConvertFilter(const DataContainerArray::Pointer& dca, GenerateFunctionList::EntryType& entry, int e, const std::string& outputName) - { - - QVariant var; - bool propWasSet; - std::string inputName; - - AbstractFilter::Pointer convFilt = InstantiateFilter("ConvertOrientations"); - DREAM3D_REQUIRE_VALID_POINTER(convFilt.get()) - - convFilt->setDataContainerArray(dca); - - int inputType = entry[e]; - var.setValue(inputType); - propWasSet = convFilt->setProperty("InputType", var); - if(!propWasSet) - { - std::cout << "Unable to set property inputType"; - } - - int outputType = entry[e + 1]; - var.setValue(outputType); - propWasSet = convFilt->setProperty("OutputType", var); - if(!propWasSet) - { - std::cout << "Unable to set property OutputType"; - } - if(e == 0) - { - inputName = k_InputNames[entry[e]]; - } - else - { - inputName = outputName; - } - DataArrayPath dap(DCName, AMName, inputName); - var.setValue(dap); - propWasSet = convFilt->setProperty("InputOrientationArrayPath", var); - if(!propWasSet) - { - std::cout << "Unable to set property InputOrientationArrayPath"; - } - - std::string outName = EbsdStringUtils::number(e) + std::string("_") + k_InputNames[entry[e]] + std::string("2") + k_InputNames[entry[e + 1]]; - DataSetNames.push_back(outName); - DataSetTypes.push_back(entry[e + 1]); - var.setValue(outName); - propWasSet = convFilt->setProperty("OutputOrientationArrayName", var); - if(!propWasSet) - { - std::cout << "Unable to set property OutputOrientationArrayName"; - } - - Observer obs; - obs.connect(convFilt.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); - - convFilt->execute(); - int err = convFilt->getErrorCode(); - DREAM3D_REQUIRED(err, >=, 0) - - return outName; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void CheckRepresentation(K* data, int repType) - { - using OrientationType = Orientation; - - OrientationTransformation::ResultType res; - - OrientationType wrapper(data, k_CompDims[repType]); - switch(repType) - { - case 0: - res = OrientationTransformation::eu_check(wrapper); - break; - case 1: - res = OrientationTransformation::om_check(wrapper); - break; - case 2: - res = OrientationTransformation::qu_check(wrapper); - break; - case 3: - res = OrientationTransformation::ax_check(wrapper); - break; - case 4: - res = OrientationTransformation::ro_check(wrapper); - break; - case 5: - res = OrientationTransformation::ho_check(wrapper); - break; - case 6: - res = OrientationTransformation::cu_check(wrapper); - break; - default: - break; - } - - if(res.result <= 0) - { - std::cout << res.msg << std::endl; - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void RunTestCase(GenerateFunctionList::EntryType& entryRef, size_t nSteps) - { - - using DataArrayType = DataArray; - using DataArrayPointerType = typename DataArrayType::Pointer; - - try - { - DataSetNames.clear(); - DataSetTypes.clear(); - - GenerateFunctionList::EntryType entry = entryRef; - // std::vector funcNames = EulerConverter::GetOrientationTypeStrings(); - - std::stringstream ss; - for(int e = 0; e < entry.size() - 1; e++) - { - ss << k_InputNames[entry[e]] << "2" << k_InputNames[entry[e + 1]]; - if(e != entry.size() - 1) - { - ss << "\t"; - } - } - // std::cout << "####################################################################" << std::endl; - // std::cout << ss.str() << std::endl; - std::string testName = ss.str(); - - SIMPL::unittest::CurrentMethod = ss.str(); - SIMPL::unittest::numTests++; - std::cout << "Starting Test " << ss.str() << " -----------------------------------------------------" << std::endl; - - DataContainerArray::Pointer dca = DataContainerArray::New(); - - DataContainer::Pointer m = DataContainer::New(DCName); - - size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); - - std::vector tDims(1, nStepsCubed); - AttributeMatrix::Pointer attrMat = AttributeMatrix::New(tDims, AMName, AttributeMatrix::Type::Cell); - m->addOrReplaceAttributeMatrix(attrMat); - dca->addOrReplaceDataContainer(m); - - // Make all the starting data - GenerateEulers(nSteps, attrMat); - - bool euCheck = false; - std::string outputName; - - if(entry[0] == 0) - { - // std::cout << "CHECK EULERS!!" << std::endl; - euCheck = true; - entry.push_back(1); // Add an extra conversion to OM for Eulers since there can be ambiguous cases - } - else - { - - for(int e = 0; e < entry.size(); e++) - { - if(entry[e] == 0) - { - GenerateFunctionList::EntryType::iterator iter = entry.begin() + e + 1; - entry.insert(iter, 1); - iter = entry.begin() + e + 2; - entry.insert(iter, 0); - e = e + 2; - } - } - } - - for(int e = 0; e < entry.size() - 1; e++) - { - outputName = ExecuteConvertFilter(dca, entry, e, outputName); - } - - // If we started with Eulers, then we need to convert the original Eulers and - // the final eulers to an Orientation Matrix and back due to ambiguities when - // transforming Eulers. Going to an Orientation Matrix with 4 degrees of freedom - // will give us unique Eulers back which will be numerically equivalent. - - QVariant var; - bool propWasSet; - std::string inputName; - - // Find Difference Map between originals and finals - { - AbstractFilter::Pointer diffMapFilt = InstantiateFilter("FindDifferenceMap"); - DREAM3D_REQUIRE_VALID_POINTER(diffMapFilt.get()); - diffMapFilt->setDataContainerArray(dca); - size_t cDim = entry[0]; - if(euCheck) - { - inputName = k_InputNames[1]; // We converted the ending eulers to an Orientation Matrix so compare against the original OM - cDim = 1; // Use the CompDim from the OM instead of what is coming in - } - else - { - inputName = k_InputNames[entry[0]]; - } - - DataArrayPath dap(DCName, AMName, inputName); - var.setValue(dap); - propWasSet = diffMapFilt->setProperty("FirstInputArrayPath", var); - if(!propWasSet) - { - std::cout << "Unable to set property FirstInputArrayPath"; - } - - dap = DataArrayPath(DCName, AMName, outputName); - var.setValue(dap); - propWasSet = diffMapFilt->setProperty("SecondInputArrayPath", var); - if(!propWasSet) - { - std::cout << "Unable to set property SecondInputArrayPath"; - } - - std::string diffMapArrayName = std::string("%1 Difference").arg(k_InputNames[entry[0]]); - dap = DataArrayPath(DCName, AMName, diffMapArrayName); - var.setValue(dap); - propWasSet = diffMapFilt->setProperty("DifferenceMapArrayPath", var); - if(!propWasSet) - { - std::cout << "Unable to set property DifferenceMapArrayPath"; - } - - // Observer obs; - // obs.connect(diffMapFilt.get(), SIGNAL(messageGenerated(const AbstractMessage::Pointer&)), - // &obs, SLOT(processPipelineMessage(const AbstractMessage::Pointer&))); - - diffMapFilt->execute(); - int err = diffMapFilt->getErrorCode(); - DREAM3D_REQUIRED(err, >=, 0) - - DataArrayPath daPath(DCName, AMName, diffMapArrayName); - std::vector cDims(1, k_CompDims[cDim]); - typename DataArray::Pointer diff = dca->getPrereqArrayFromPath>(diffMapFilt.get(), daPath, cDims); - - size_t tuples = diff->getNumberOfTuples(); - // printf("Total Tuples: %lu\n", tuples); - size_t numErrors = 0; - K thr = 1.0E-3; - for(size_t t = 0; t < tuples; t++) - { - int nComp = diff->getNumberOfComponents(); - if(entry[0] == 4) - { - nComp--; - } // for Rodrigues vectors we only want to compare the first 3 components. - for(int c = 0; c < nComp; c++) - { - K delta = fabs(diff->getComponent(t, c)); - if(delta > thr) - { - numErrors++; - std::cout << "Delta Failed: " << delta << " DataArray: '" << diff->getName() << "' Tuple[" << t << "] Comp[" << c << "] Value:" << diff->getComponent(t, c) << std::endl; - - // Get the AttributeMatrix: - dap = DataArrayPath(DCName, AMName, k_InputNames[0]); - AttributeMatrix::Pointer attrMat = dca->getAttributeMatrix(dap); - - // Print the Euler Angle that we Started with - // cDims[0] = k_CompDims[0]; - DataArrayPointerType data = attrMat->getAttributeArrayAs(k_InputNames[0]); - OrientationPrinters::PrintTuple(data, t); - CheckRepresentation(data->getPointer(t), 0); - - // Print the starting representation - data = attrMat->getAttributeArrayAs(k_InputNames[entry[0]]); - OrientationPrinters::PrintTuple(data, t); - CheckRepresentation(data->getPointer(t), entry[0]); - - // Now print all the intermediate Representations - for(int q = 0; q < DataSetNames.size(); q++) - { - data = attrMat->getAttributeArrayAs(DataSetNames[q]); - OrientationPrinters::PrintTuple(data, t); - CheckRepresentation(data->getPointer(t), DataSetTypes[q]); - } - DREAM3D_REQUIRED(delta, <=, thr) - break; - } - } - } - } - - if(euCheck) - { - // Use original OM when we first generated the Euler Angles - entry.pop_back(); - } - - typename DataArray::Pointer junk = DataArray::CreateArray(1, "Junk", true); - std::string typeName = junk->getTypeAsString(); - if(m_WriteDataFiles) - { - DataContainerWriter::Pointer writer = DataContainerWriter::New(); - - writer->setDataContainerArray(dca); - writer->setWriteXdmfFile(false); - std::string outputFile; - std::stringstream out(outputFile); - - out << UnitTest::TestTempDir << "/OrientationTransformationTest_"; - - for(int e = 0; e < entry.size(); e++) - { - out << k_InputNames[entry[e]]; - if(e < entry.size()) - { - out << "_"; - } - } - out << typeName << ".dream3d"; - writer->setOutputFile(outputFile); - - writer->execute(); - int err = writer->getErrorCode(); - DREAM3D_REQUIRED(err, >=, 0) - } - - { - ss.str(""); - ss << testName << "Type: " << typeName; - TestPassed(ss.str()); - SIMPL::unittest::CurrentMethod = ""; - } - } catch(TestException& e) - { - TestFailed(SIMPL::unittest::CurrentMethod); - std::cout << e.what() << std::endl; - } - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void StartTest() - { - // std::vector functionNames = OrientationConverter::GetOrientationTypeStrings(); - - GenerateFunctionList generator; - std::vector entries = generator.GeneratePermutationsOfCombinations(8, 2); - - // This outer loop will group the tests based on the first orientation representation - for(int t = 0; t < 8; t++) - { - // Start looping on each entry in the function table. - for(std::vector::size_type i = 0; i < entries.size(); i++) - { - - GenerateFunctionList::EntryType entry = entries[i]; - if(entry[0] != t) - { - continue; - } - entry.push_back(entry[0]); - // if (entry[0] == 2 - // && entry[1] == 1 - // ) - { - // RunTestCase(entry, 16); - RunTestCase(entry, 36); - } - } - } - - entries = generator.GeneratePermutationsOfCombinations(8, 3); - // This outer loop will group the tests based on the first orientation representation - for(int t = 0; t < 7; t++) - { - for(std::vector::size_type i = 0; i < entries.size(); i++) - { - GenerateFunctionList::EntryType entry = entries[i]; - if(entry[0] != t) - { - continue; - } - entry.push_back(entry[0]); - // if (entry[0] == 2 - // && entry[1] == 4 - // && entry[2] == 1 - // ) - { - // RunTestCase(entry, 16); - RunTestCase(entry, 36); - } - } - } - } - - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - - StartTest(); - - DREAM3D_REGISTER_TEST(RemoveTestFiles()); - } -}; diff --git a/Source/Test/OrientationTransformsTest.cpp b/Source/Test/OrientationTransformsTest.cpp index e8fbf643..0d22f8f6 100644 --- a/Source/Test/OrientationTransformsTest.cpp +++ b/Source/Test/OrientationTransformsTest.cpp @@ -91,197 +91,38 @@ class OrientationTransformsTest #endif } - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void GenerateEulers(size_t nSteps, std::map::Pointer>& attrMat) - { - std::vector cDims = {3}; - - T phi1_min = static_cast(0.0); - T phi1_max = DConst::k_2PiD; - T phi1_delta = (phi1_max - phi1_min) / static_cast(nSteps); - - T phi_min = static_cast(0.0); - T phi_max = DConst::k_PiD; - T phi_delta = (phi_max - phi_min) / static_cast(nSteps); - - T phi2_min = static_cast(0.0); - T phi2_max = DConst::k_2PiD; - T phi2_delta = (phi2_max - phi2_min) / static_cast(nSteps); - - size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); - typename EbsdDataArray::Pointer eulers = EbsdDataArray::CreateArray(nStepsCubed, cDims, k_InputNames[0], true); - - size_t counter = 0; - for(size_t i = 0; i <= nSteps; i++) - { - for(size_t j = 0; j <= nSteps; j++) - { - for(size_t k = 0; k <= nSteps; k++) - { - // std::cout << "Euler[" << counter << "]: " - // << (phi1_min+i*phi1_delta)*DConst::k_180OverPi << ", " - // << (phi_min+j*phi_delta)*DConst::k_180OverPi << ", " - // << (phi2_min+k*phi2_delta)*DConst::k_180OverPi << std::endl; - - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta); - eulers->setComponent(counter, 1, phi_min + j * phi_delta); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta); - - T one80Check = phi1_min + i * phi1_delta + phi2_min + k * phi2_delta; - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) - { - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); - } - - one80Check = fmod(one80Check, EbsdLib::Constants::k_2PiD); - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) - { - eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); - eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); - } - - counter++; - } - } - } - - typename EulerConverter, T>::Pointer euConv = EulerConverter, T>::New(); - euConv->setInputData(eulers); - - euConv->toOrientationMatrix(); - typename EbsdDataArray::Pointer om = euConv->getOutputData(); - om->setName(k_InputNames[1]); - attrMat[k_InputNames[1]] = om; - - // Create an Orientation matrix from the Eulers and then transform BACK to Eulers to transform - // the values of the Eulers into the convention set forth in the Rotations Paper. - typename OrientationMatrixConverter, T>::Pointer omConv = OrientationMatrixConverter, T>::New(); - omConv->setInputData(om); - omConv->toEulers(); - eulers = omConv->getOutputData(); - eulers->setName(k_InputNames[0]); - euConv->setInputData(eulers); - - attrMat[k_InputNames[0]] = eulers; - - euConv->toQuaternion(); - typename EbsdDataArray::Pointer q = euConv->getOutputData(); - q->setName(k_InputNames[2]); - attrMat[k_InputNames[2]] = q; - - euConv->toAxisAngle(); - typename EbsdDataArray::Pointer ax = euConv->getOutputData(); - ax->setName(k_InputNames[3]); - attrMat[k_InputNames[3]] = ax; - - euConv->toRodrigues(); - typename EbsdDataArray::Pointer ro = euConv->getOutputData(); - ro->setName(k_InputNames[4]); - attrMat[k_InputNames[4]] = ro; - - euConv->toHomochoric(); - typename EbsdDataArray::Pointer ho = euConv->getOutputData(); - ho->setName(k_InputNames[5]); - attrMat[k_InputNames[5]] = ho; - - euConv->toCubochoric(); - typename EbsdDataArray::Pointer cu = euConv->getOutputData(); - cu->setName(k_InputNames[6]); - attrMat[k_InputNames[6]] = cu; - - euConv->toStereographic(); - typename EbsdDataArray::Pointer st = euConv->getOutputData(); - st->setName(k_InputNames[7]); - attrMat[k_InputNames[7]] = st; - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - std::shared_ptr> generateRepresentation(int32_t inputType, int32_t outputType, typename EbsdDataArray::Pointer inputOrientations) - { - // using ArrayType = typename EbsdDataArray::Pointer; - using OCType = OrientationConverter, T>; - - std::vector converters(s_NumReps); - - converters[0] = EulerConverter, T>::New(); - converters[1] = OrientationMatrixConverter, T>::New(); - converters[2] = QuaternionConverter, T>::New(); - converters[3] = AxisAngleConverter, T>::New(); - converters[4] = RodriguesConverter, T>::New(); - converters[5] = HomochoricConverter, T>::New(); - converters[6] = CubochoricConverter, T>::New(); - converters[7] = StereographicConverter, T>::New(); - - std::vector ocTypes = OCType::GetOrientationTypes(); - - converters[inputType]->setInputData(inputOrientations); - converters[inputType]->convertRepresentationTo(ocTypes[outputType]); - - return converters[inputType]->getOutputData(); - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - std::string ExecuteConvertFilter(std::map::Pointer>& attrMat, GenerateFunctionList::EntryType& entry, int e, const std::string& outputName) - { - std::string inputName = outputName; - - if(e == 0) - { - inputName = k_InputNames[entry[e]]; - } - EbsdDataArray::Pointer inputData = attrMat[inputName]; - EbsdDataArray::Pointer outputData = generateRepresentation(entry[e], entry[e + 1], inputData); - std::string nextOutputName = EbsdStringUtils::number(e) + std::string("_") + k_InputNames[entry[e]] + std::string("2") + k_InputNames[entry[e + 1]]; - attrMat[nextOutputName] = outputData; - - return nextOutputName; - } - // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template void CheckRepresentation(K* data, int repType) { - using OrientationType = Orientation; - - typename OrientationTransformation::ResultType res; - - OrientationType wrapper(data, k_CompDims[repType]); + OrientationTransformation::ResultType res; switch(repType) { case 0: - res = OrientationTransformation::eu_check(wrapper); + res = OrientationTransformation::eu_check>({data}); break; case 1: - res = OrientationTransformation::om_check(wrapper); + res = OrientationTransformation::om_check>({data}); break; case 2: - res = OrientationTransformation::qu_check(wrapper); + res = OrientationTransformation::qu_check>({data}); break; case 3: - res = OrientationTransformation::ax_check(wrapper); + res = OrientationTransformation::ax_check>({data}); break; case 4: - res = OrientationTransformation::ro_check(wrapper); + res = OrientationTransformation::ro_check>({data}); break; case 5: - res = OrientationTransformation::ho_check(wrapper); + res = OrientationTransformation::ho_check>({data}); break; case 6: - res = OrientationTransformation::cu_check(wrapper); + res = OrientationTransformation::cu_check>({data}); break; case 7: - res = OrientationTransformation::st_check(wrapper); + res = OrientationTransformation::st_check>({data}); break; default: break; @@ -333,7 +174,7 @@ class OrientationTransformsTest // size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); // Make all the starting data - GenerateEulers(nSteps, attrMat); + generate_test_data::GenerateEulers(nSteps, attrMat); bool euCheck = false; // std::string outputName; @@ -362,7 +203,7 @@ class OrientationTransformsTest std::string outputName; // We need this a bit further down; for(int e = 0; e < entry.size() - 1; e++) { - outputName = ExecuteConvertFilter(attrMat, entry, e, outputName); + outputName = generate_test_data::ExecuteConvertFilter(attrMat, entry, e, outputName); } // If we started with Eulers, then we need to convert the original Eulers and @@ -523,11 +364,7 @@ class OrientationTransformsTest continue; } entry.push_back(entry[0]); - // if (entry[0] == 2 - // && entry[1] == 1 - // ) { - // RunTestCase(entry, 16); RunTestCase(entry, 16); } } @@ -544,12 +381,7 @@ class OrientationTransformsTest continue; } entry.push_back(entry[0]); - // if (entry[0] == 2 - // && entry[1] == 4 - // && entry[2] == 1 - // ) { - // RunTestCase(entry, 16); RunTestCase(entry, 16); } } diff --git a/Source/Test/QuaternionTest.cpp b/Source/Test/QuaternionTest.cpp index ef917900..b4584148 100644 --- a/Source/Test/QuaternionTest.cpp +++ b/Source/Test/QuaternionTest.cpp @@ -39,7 +39,6 @@ #include #include -#include "EbsdLib/Core/OrientationRepresentation.h" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" diff --git a/Source/Test/SO3SamplerTest.cpp b/Source/Test/SO3SamplerTest.cpp index a6669aef..d4cd9e66 100644 --- a/Source/Test/SO3SamplerTest.cpp +++ b/Source/Test/SO3SamplerTest.cpp @@ -31,7 +31,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "EbsdLib/LaueOps/SO3Sampler.h" -#include "EbsdLib/Core/Orientation.hpp" +#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" @@ -43,6 +43,8 @@ #include "EbsdLib/Test/EbsdLibTestFileLocations.h" +#include + class SO3SamplerTest { public: @@ -84,15 +86,15 @@ class SO3SamplerTest { SO3Sampler::Pointer sampler = SO3Sampler::New(); - OrientationD rod(4); + RodriguesDType rod; - OrientationD cu(-0.3217544095666538, 0.2145029397111025, -0.4290058794222050); - rod = OrientationTransformation::cu2ro(cu); + CubochoricDType cu(-0.3217544095666538, 0.2145029397111025, -0.4290058794222050); + rod = cu.toRodrigues(); bool inside = sampler->insideCubicFZ(rod.data(), 4); DREAM3D_REQUIRE_EQUAL(inside, false); - cu = OrientationD(-0.42900587942220514, -0.21450293971110265, 0.42900587942220514); - rod = OrientationTransformation::cu2ro(cu); + cu = CubochoricDType(-0.42900587942220514, -0.21450293971110265, 0.42900587942220514); + rod = cu.toRodrigues(); inside = sampler->insideCubicFZ(rod.data(), 4); DREAM3D_REQUIRE_EQUAL(inside, true); } @@ -103,29 +105,29 @@ class SO3SamplerTest void TestPyramid() { - OrientationD xyz(0, 0, 1); + std::array xyz = {0.0, 0.0, 1.0}; - int pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + int pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 1) - xyz = OrientationD(0, 0, -1); - pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + xyz = {0.0, 0.0, -1.0}; + pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 2) - xyz = OrientationD(1, 0, 0); - pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + xyz = {1.0, 0.0, 0.0}; + pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 3) - xyz = OrientationD(-1, 0, 0); - pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + xyz = {-1.0, 0.0, 0.0}; + pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 4) - xyz = OrientationD(0, 1, 0); - pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + xyz = {0.0, 1.0, 0.0}; + pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 5) - xyz = OrientationD(0, -1, 0); - pSection = ModifiedLambertProjection3D::GetPyramid(xyz); + xyz = {0.0, -1.0, 0.0}; + pSection = ModifiedLambertProjection3D, double>::GetPyramid(xyz); DREAM3D_REQUIRE_EQUAL(pSection, 6) } From 4f39986c47ed886bc05228763bed567075e0aba2 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 13 Nov 2025 22:36:07 -0500 Subject: [PATCH 2/2] ENH: Rewrite Orientation Conversion Classes. Update Namespace to 'ebsdlib' This time using a simple template based superclass that each of the representations will inherit. it will define the basic conversion methods. Namespaces updated for everything to 'ebsdlib' --- CMakeLists.txt | 65 +- CMakePresets.json | 10 +- README.md | 50 +- Source/Apps/ConvertOrientations.cpp | 6 +- Source/Apps/ParseAztecProject.cpp | 2 + Source/Apps/eq_orientations.cpp | 5 +- Source/Apps/gen_sym_code.cpp | 4 +- Source/Apps/generate_ipf_legends.cpp | 40 +- Source/Apps/make_ipf.cpp | 15 +- Source/Apps/rotconvert.cpp | 7 +- Source/EbsdLib/Core/AbstractEbsdFields.cpp | 2 + Source/EbsdLib/Core/AbstractEbsdFields.h | 11 +- Source/EbsdLib/Core/EbsdDataArray.cpp | 32 +- Source/EbsdLib/Core/EbsdDataArray.hpp | 8 +- Source/EbsdLib/Core/EbsdLibConstants.h | 24 +- Source/EbsdLib/Core/EbsdMacros.h | 6 +- Source/EbsdLib/Core/EbsdStringLiteral.hpp | 4 +- Source/EbsdLib/Core/EbsdTransform.cpp | 10 +- Source/EbsdLib/Core/EbsdTransform.h | 2 +- Source/EbsdLib/Core/Orientation.hpp | 25 +- Source/EbsdLib/Core/OrientationMath.cpp | 1 + Source/EbsdLib/Core/OrientationMath.h | 131 +-- .../Core/OrientationRepresentation.hpp | 474 ---------- .../Core/OrientationTransformation.hpp | 233 ++--- Source/EbsdLib/Core/Quaternion.hpp | 602 ------------- Source/EbsdLib/Core/SourceList.cmake | 4 +- Source/EbsdLib/IO/AngleFileLoader.cpp | 36 +- Source/EbsdLib/IO/AngleFileLoader.h | 6 +- .../EbsdLib/IO/BrukerNano/EspritConstants.h | 4 +- Source/EbsdLib/IO/BrukerNano/EspritPhase.cpp | 26 +- Source/EbsdLib/IO/BrukerNano/EspritPhase.h | 4 +- .../EbsdLib/IO/BrukerNano/H5EspritFields.cpp | 36 +- Source/EbsdLib/IO/BrukerNano/H5EspritFields.h | 38 +- .../EbsdLib/IO/BrukerNano/H5EspritReader.cpp | 340 ++++---- Source/EbsdLib/IO/BrukerNano/H5EspritReader.h | 52 +- Source/EbsdLib/IO/EbsdHeaderEntry.h | 4 +- Source/EbsdLib/IO/EbsdImporter.h | 4 + Source/EbsdLib/IO/EbsdReader.cpp | 4 +- Source/EbsdLib/IO/EbsdReader.h | 5 +- Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp | 78 +- Source/EbsdLib/IO/H5EbsdVolumeInfo.h | 5 +- Source/EbsdLib/IO/H5EbsdVolumeReader.cpp | 6 +- Source/EbsdLib/IO/H5EbsdVolumeReader.h | 5 +- Source/EbsdLib/IO/HKL/CprReader.cpp | 238 ++--- Source/EbsdLib/IO/HKL/CprReader.h | 56 +- Source/EbsdLib/IO/HKL/CtfConstants.h | 4 +- Source/EbsdLib/IO/HKL/CtfFields.cpp | 34 +- Source/EbsdLib/IO/HKL/CtfFields.h | 20 +- Source/EbsdLib/IO/HKL/CtfHeaderEntry.h | 3 + Source/EbsdLib/IO/HKL/CtfPhase.cpp | 72 +- Source/EbsdLib/IO/HKL/CtfPhase.h | 5 +- Source/EbsdLib/IO/HKL/CtfReader.cpp | 188 ++-- Source/EbsdLib/IO/HKL/CtfReader.h | 47 +- Source/EbsdLib/IO/HKL/DataParser.hpp | 17 +- Source/EbsdLib/IO/HKL/H5CtfImporter.cpp | 86 +- Source/EbsdLib/IO/HKL/H5CtfImporter.h | 5 +- Source/EbsdLib/IO/HKL/H5CtfReader.cpp | 92 +- Source/EbsdLib/IO/HKL/H5CtfReader.h | 3 + Source/EbsdLib/IO/HKL/H5CtfVolumeReader.cpp | 76 +- Source/EbsdLib/IO/HKL/H5CtfVolumeReader.h | 5 +- Source/EbsdLib/IO/HKL/H5OINAReader.cpp | 168 ++-- Source/EbsdLib/IO/HKL/H5OINAReader.h | 5 +- Source/EbsdLib/IO/TSL/AngConstants.h | 10 +- Source/EbsdLib/IO/TSL/AngFields.cpp | 22 +- Source/EbsdLib/IO/TSL/AngFields.h | 16 +- Source/EbsdLib/IO/TSL/AngHeaderEntry.h | 3 + Source/EbsdLib/IO/TSL/AngPhase.cpp | 152 ++-- Source/EbsdLib/IO/TSL/AngPhase.h | 3 + Source/EbsdLib/IO/TSL/AngReader.cpp | 150 ++-- Source/EbsdLib/IO/TSL/AngReader.h | 41 +- Source/EbsdLib/IO/TSL/H5AngImporter.cpp | 90 +- Source/EbsdLib/IO/TSL/H5AngImporter.h | 3 + Source/EbsdLib/IO/TSL/H5AngReader.cpp | 84 +- Source/EbsdLib/IO/TSL/H5AngReader.h | 3 + Source/EbsdLib/IO/TSL/H5AngVolumeReader.cpp | 74 +- Source/EbsdLib/IO/TSL/H5AngVolumeReader.h | 5 +- Source/EbsdLib/IO/TSL/H5OIMReader.cpp | 174 ++-- Source/EbsdLib/IO/TSL/H5OIMReader.h | 7 +- Source/EbsdLib/LaueOps/CubicLowOps.cpp | 176 ++-- Source/EbsdLib/LaueOps/CubicLowOps.h | 31 +- Source/EbsdLib/LaueOps/CubicOps.cpp | 304 +++---- Source/EbsdLib/LaueOps/CubicOps.h | 33 +- Source/EbsdLib/LaueOps/HexagonalLowOps.cpp | 206 ++--- Source/EbsdLib/LaueOps/HexagonalLowOps.h | 31 +- Source/EbsdLib/LaueOps/HexagonalOps.cpp | 202 ++--- Source/EbsdLib/LaueOps/HexagonalOps.h | 31 +- Source/EbsdLib/LaueOps/LaueOps.cpp | 27 +- Source/EbsdLib/LaueOps/LaueOps.h | 40 +- Source/EbsdLib/LaueOps/MonoclinicOps.cpp | 110 +-- Source/EbsdLib/LaueOps/MonoclinicOps.h | 33 +- Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp | 108 +-- Source/EbsdLib/LaueOps/OrthoRhombicOps.h | 30 +- Source/EbsdLib/LaueOps/SO3Sampler.cpp | 17 +- Source/EbsdLib/LaueOps/SO3Sampler.h | 17 +- Source/EbsdLib/LaueOps/TetragonalLowOps.cpp | 110 +-- Source/EbsdLib/LaueOps/TetragonalLowOps.h | 30 +- Source/EbsdLib/LaueOps/TetragonalOps.cpp | 112 +-- Source/EbsdLib/LaueOps/TetragonalOps.h | 30 +- Source/EbsdLib/LaueOps/TriclinicOps.cpp | 110 +-- Source/EbsdLib/LaueOps/TriclinicOps.h | 30 +- Source/EbsdLib/LaueOps/TrigonalLowOps.cpp | 118 +-- Source/EbsdLib/LaueOps/TrigonalLowOps.h | 32 +- Source/EbsdLib/LaueOps/TrigonalOps.cpp | 114 +-- Source/EbsdLib/LaueOps/TrigonalOps.h | 28 +- Source/EbsdLib/Math/EbsdLibMath.cpp | 31 +- Source/EbsdLib/Math/EbsdLibMath.h | 8 +- Source/EbsdLib/Math/EbsdMatrixMath.cpp | 7 +- Source/EbsdLib/Math/EbsdMatrixMath.h | 3 + Source/EbsdLib/Math/GeometryMath.cpp | 4 +- Source/EbsdLib/Math/GeometryMath.h | 4 +- Source/EbsdLib/Math/Matrix3X1.hpp | 13 +- Source/EbsdLib/Math/Matrix3X3.hpp | 155 +++- Source/EbsdLib/Orientation/AxisAngle.hpp | 255 ++++++ Source/EbsdLib/Orientation/Cubochoric.hpp | 154 ++++ Source/EbsdLib/Orientation/Euler.hpp | 284 ++++++ Source/EbsdLib/Orientation/Homochoric.hpp | 185 ++++ Source/EbsdLib/Orientation/OrientationFwd.hpp | 140 +++ .../EbsdLib/Orientation/OrientationMatrix.hpp | 405 +++++++++ Source/EbsdLib/Orientation/Quaternion.hpp | 815 ++++++++++++++++++ Source/EbsdLib/Orientation/Rodrigues.hpp | 250 ++++++ Source/EbsdLib/Orientation/SourceList.cmake | 26 + Source/EbsdLib/Orientation/Stereographic.hpp | 255 ++++++ .../OrientationMath/OrientationConverter.hpp | 246 ++++-- Source/EbsdLib/SourceList.cmake | 8 +- Source/EbsdLib/Texture/StatsGen.hpp | 3 + Source/EbsdLib/Texture/Texture.hpp | 15 +- Source/EbsdLib/Texture/TexturePreset.cpp | 32 +- Source/EbsdLib/Texture/TexturePreset.h | 3 + Source/EbsdLib/Utilities/CanvasUtilities.cpp | 70 +- Source/EbsdLib/Utilities/CanvasUtilities.hpp | 12 +- Source/EbsdLib/Utilities/ColorTable.cpp | 2 +- Source/EbsdLib/Utilities/ColorTable.h | 24 +- Source/EbsdLib/Utilities/ColorUtilities.cpp | 18 +- Source/EbsdLib/Utilities/ColorUtilities.h | 10 +- .../ComputeStereographicProjection.cpp | 4 +- .../ComputeStereographicProjection.h | 27 +- Source/EbsdLib/Utilities/FiraSansRegular.hpp | 4 +- Source/EbsdLib/Utilities/Fonts.cpp | 4 +- Source/EbsdLib/Utilities/Fonts.hpp | 4 +- Source/EbsdLib/Utilities/LambertUtilities.cpp | 16 +- Source/EbsdLib/Utilities/LambertUtilities.h | 4 +- Source/EbsdLib/Utilities/LatoBold.hpp | 4 +- Source/EbsdLib/Utilities/LatoRegular.hpp | 4 +- .../Utilities/ModifiedLambertProjection.cpp | 28 +- .../Utilities/ModifiedLambertProjection.h | 17 +- .../Utilities/ModifiedLambertProjection3D.hpp | 5 +- .../ModifiedLambertProjectionArray.cpp | 20 +- .../ModifiedLambertProjectionArray.h | 7 +- Source/EbsdLib/Utilities/PoleFigureData.cpp | 2 + Source/EbsdLib/Utilities/PoleFigureData.h | 4 +- .../EbsdLib/Utilities/PoleFigureUtilities.cpp | 46 +- .../EbsdLib/Utilities/PoleFigureUtilities.h | 23 +- Source/EbsdLib/Utilities/ToolTipGenerator.cpp | 2 +- Source/EbsdLib/Utilities/ToolTipGenerator.h | 4 +- Source/Test/AngImportTest.cpp | 210 ++--- Source/Test/AngleFileLoaderTest.cpp | 82 +- Source/Test/CMakeLists.txt | 182 +--- Source/Test/ConvertToFundamentalZoneTest.cpp | 105 +-- Source/Test/CtfReaderTest.cpp | 371 ++++---- Source/Test/EbsdLib_test_main.cpp | 4 + Source/Test/EdaxOIMReaderTest.cpp | 147 ++-- Source/Test/GenerateFunctionList.h | 22 +- Source/Test/H5EspritReaderTest.cpp | 360 ++++---- Source/Test/H5OINAReaderTest.cpp | 82 -- Source/Test/IPFLegendTest.cpp | 118 +-- Source/Test/Not_Used/H5OINAReaderTest.cpp | 48 ++ .../OrientationTransformsTest.cpp | 39 +- Source/Test/{ => Not_Used}/SO3SamplerTest.cpp | 9 +- Source/Test/{ => Not_Used}/TestMain.cpp.in | 0 .../Test/{ => Not_Used}/TestPrintFunctions.h | 16 +- Source/Test/ODFTest.cpp | 165 ++-- Source/Test/OrientationConverterTest.cpp | 232 +++-- Source/Test/OrientationMathTest.cpp | 49 -- ...OrientationRepresentationTransformTest.cpp | 563 ------------ Source/Test/OrientationTest.cpp | 578 +++++++++++++ Source/Test/QuaternionTest.cpp | 626 +++++++------- Source/Test/TestFileLocations.h.in | 37 +- Source/Test/TextureTest.cpp | 291 +++---- Source/Test/UnitTestSupport.hpp | 120 +-- cmake/Utility.cmake | 543 ++++++++++++ vcpkg-configuration.json | 10 +- vcpkg.json | 11 + 182 files changed, 8572 insertions(+), 6611 deletions(-) delete mode 100644 Source/EbsdLib/Core/OrientationRepresentation.hpp delete mode 100644 Source/EbsdLib/Core/Quaternion.hpp create mode 100644 Source/EbsdLib/Orientation/AxisAngle.hpp create mode 100644 Source/EbsdLib/Orientation/Cubochoric.hpp create mode 100644 Source/EbsdLib/Orientation/Euler.hpp create mode 100644 Source/EbsdLib/Orientation/Homochoric.hpp create mode 100644 Source/EbsdLib/Orientation/OrientationFwd.hpp create mode 100644 Source/EbsdLib/Orientation/OrientationMatrix.hpp create mode 100644 Source/EbsdLib/Orientation/Quaternion.hpp create mode 100644 Source/EbsdLib/Orientation/Rodrigues.hpp create mode 100644 Source/EbsdLib/Orientation/SourceList.cmake create mode 100644 Source/EbsdLib/Orientation/Stereographic.hpp create mode 100644 Source/Test/EbsdLib_test_main.cpp delete mode 100644 Source/Test/H5OINAReaderTest.cpp create mode 100644 Source/Test/Not_Used/H5OINAReaderTest.cpp rename Source/Test/{ => Not_Used}/OrientationTransformsTest.cpp (93%) rename Source/Test/{ => Not_Used}/SO3SamplerTest.cpp (95%) rename Source/Test/{ => Not_Used}/TestMain.cpp.in (100%) rename Source/Test/{ => Not_Used}/TestPrintFunctions.h (93%) delete mode 100644 Source/Test/OrientationMathTest.cpp delete mode 100644 Source/Test/OrientationRepresentationTransformTest.cpp create mode 100644 Source/Test/OrientationTest.cpp create mode 100644 cmake/Utility.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e539eb9..dbb6ab25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,44 @@ +cmake_minimum_required(VERSION 3.26) + cmake_policy(SET CMP0002 NEW) cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0079 NEW) cmake_policy(SET CMP0077 NEW) +cmake_policy(SET CMP0080 NEW) # ``BundleUtilities`` cannot be included at configure time. + +# resolves symlinks before collapsing ../ components. +if(CMAKE_VERSION VERSION_GREATER "3.28.0") + cmake_policy(SET CMP0152 NEW) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/cmake/Utility.cmake) + + +# ------------------------------------------------------------------------------ +# is building unit tests enabled +# ------------------------------------------------------------------------------ +option(EbsdLib_BUILD_TESTS "Enable building tests" ON) +enable_vcpkg_manifest_feature(TEST_VAR EbsdLib_BUILD_TESTS FEATURE "tests") + +# ------------------------------------------------------------------------------ +# are multithreading algorithms enabled +# ------------------------------------------------------------------------------ +option(EbsdLib_ENABLE_MULTICORE "Enable multicore support" ON) +enable_vcpkg_manifest_feature(TEST_VAR EbsdLib_ENABLE_MULTICORE FEATURE "parallel") + + +option(EbsdLib_DISABLE_MSVC_WARNINGS ON) +option(BUILD_SHARED_LIBS "Build Shared Libs" ON) + +# Extra Variables that need to be set before all the configured files are generated. +option(EbsdLib_ENABLE_HDF5 "Enable HDF5 Support in the EbsdLibProj" ON) + +option(EbsdLib_BUILD_H5SUPPORT "Build H5Support Library" OFF) + + +# set project's name +project(EbsdLibProj VERSION 2.0.0) -cmake_minimum_required(VERSION 3.14.0) # Request C++17 standard, using new CMake variables. set(CMAKE_CXX_STANDARD 17) @@ -14,9 +49,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Always write out the compile_commands.json file to help out things like QtCreator and VS Code set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# set project's name -project(EbsdLibProj VERSION 1.0.42) - # ---------- Setup output Directories ------------------------- set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin @@ -38,19 +70,13 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "Single Directory for all static libraries." ) -option(EbsdLib_DISABLE_MSVC_WARNINGS ON) -option(BUILD_SHARED_LIBS "Build Shared Libs" ON) - get_filename_component(EbsdLib_PARENT ${EbsdLibProj_SOURCE_DIR} DIRECTORY CACHE) + #------------------------------------------------------------------------------- # Find the HDF5 Library as we need that. #------------------------------------------------------------------------------- -# Extra Variables that need to be set before all the configured files are generated. -option(EbsdLib_ENABLE_HDF5 "Enable HDF5 Support in the EbsdLibProj" ON) -option(EbsdLib_BUILD_H5SUPPORT "Build H5Support Library" ON) - if(EbsdLib_ENABLE_HDF5) if(EbsdLib_BUILD_H5SUPPORT) if(NOT TARGET H5Support::H5Support) @@ -119,22 +145,25 @@ if(EbsdLib_USE_GHC_FILESYSTEM) find_package(ghcFilesystem REQUIRED NAMES ghc_filesystem ghcFilesystem) endif() -#------------------------------------------------------------------------------- -# Are we using Parallel Algorithms. -#------------------------------------------------------------------------------- -option(EbsdLib_USE_PARALLEL_ALGORITHMS "Enable EBSDLib to use parallel algorithms" ON) -if(EbsdLib_USE_PARALLEL_ALGORITHMS) # If TBB already exists no need to look for it (e.g. EbsdLib is added as a subdirectory in DREAM3D) + +# ------------------------------------------------------------------------------ +# are multithreading algorithms enabled +# ------------------------------------------------------------------------------ +if(EbsdLib_ENABLE_MULTICORE) # If TBB already exists no need to look for it (e.g. EbsdLib is added as a subdirectory in DREAM3D) find_package(TBB CONFIG REQUIRED) get_target_property(tbb_dll_path TBB::tbb IMPORTED_LOCATION_RELEASE) get_filename_component(tbb_dll_path "${tbb_dll_path}" DIRECTORY) get_property(EbsdLib_EXTRA_LIBRARY_DIRS GLOBAL PROPERTY EbsdLib_EXTRA_LIBRARY_DIRS) set_property(GLOBAL PROPERTY EbsdLib_EXTRA_LIBRARY_DIRS ${EbsdLib_EXTRA_LIBRARY_DIRS} ${tbb_dll_path}) + set(EbsdLib_USE_PARALLEL_ALGORITHMS ON) endif() include(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/SourceList.cmake) -option(EbsdLib_ENABLE_TESTING "Enable the unit test" ON) -if(EbsdLib_ENABLE_TESTING) +# ------------------------------------------------------------------------------ +# Build Unit Test +# ------------------------------------------------------------------------------ +if(EbsdLib_BUILD_TESTS) include(${EbsdLibProj_SOURCE_DIR}/Source/Test/CMakeLists.txt) endif() diff --git a/CMakePresets.json b/CMakePresets.json index fbcd53c4..93c115a8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -43,7 +43,7 @@ }, "VCPKG_MANIFEST_FEATURES": { "type": "STRING", - "value": "parallel" + "value": "parallel;tests" }, "EbsdLib_ENABLE_HDF5": { "type": "BOOL", @@ -53,6 +53,14 @@ "type": "BOOL", "value": "OFF" }, + "EbsdLib_BUILD_TESTS": { + "type": "BOOL", + "value": "ON" + }, + "EbsdLib_ENABLE_MULTICORE": { + "type": "BOOL", + "value": "ON" + }, "BUILDNAME": { "type": "STRING", "value": "$env{PRESET_NAME}-$env{BUILD_BUILDNUMBER}-PR$env{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}" diff --git a/README.md b/README.md index 831034c1..fce3e691 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ are typically used through out materials science and engineering domains. The [DREAM.3D](https://dream3d.bluequartz.net) project and [DREAM3D-NX](https://www.dream3d.io) uses this library for all the EBSD processing. -## Supported EBSD OEM Data FilesDirectionalStatsTest +## Supported EBSD OEM Data Files + EDAX/AMETEK: .ang and HDF5 based file formats + Oxford Instruments: .ctf and .h5oina file formats @@ -52,7 +52,7 @@ Please have a look at the unit tests for examples on using the various readers. | 32 | m(\bar{3})m | 432 | 221–230 | O(_h) | Cubic | m(\bar{3})m | CubicOps | -## Orientation TransformationsDirectionalStatsTest +## Orientation Transformations | From/To | Euler | Orientation Matrix | Axis Angle | Rodrigues | Quaternion | Homochoric | Cubochoric | Stereographic | |--------------------|-------|--------------------|------------|-----------|------------|------------|------------|---------------| @@ -69,7 +69,7 @@ Please have a look at the unit tests for examples on using the various readers. lower case letters denote the conversion uses other more basic conversions. For example to go from Euler->Homochoric the conversion process calls the Euler->AxisAngle->OrientationMatrix->Homochoric functions. -In addition to the OrientationTransformation class there are also classes that represent +In addition to the Orientation class there are also classes that represent the 11 Laue classes that allow a user to perform Laue class specific calculations including the generation of an IPF Color which is a prevalent visualization scheme within the EBSD community. Note that each vendor has slightly different algorithms and this @@ -77,50 +77,50 @@ library has selected to align with the AMETEK/EDAX output. The folder Data/IPF_Legend has premade IPF Legends for all the Laue classes. -## Quaternion ConventionDirectionalStatsTest +## Quaternion Convention Please also note that by default EbsdLib organizes Quaternions as Vector-Scalar (X,Y,Z,W). If your quaternions -are laid out as Scalar-Vector (w,x,y,z) there is an extra argument to some functions that you -can set to allow the orientation transformations to accept this layout. +are laid out as Scalar-Vector (w,x,y,z) you will need to reorder your data before +using this library. -## Dependent LibrariesDirectionalStatsTest +## Dependent Libraries EbsdLib is dependent on: + Eigen 3.4 + ## Optional Libraries + HDF5 1.10.4 (HDF5 is optional only if you want the HDF5 functionality) + Qt5 5.15.x (minimum: Optional) -## Rotation ConventionDirectionalStatsTest +## Rotation Convention By convention this library uses **Passive** rotations -## CitationsDirectionalStatsTest +## Citations D Rowenhorst, A D Rollett, G S Rohrer, M Groeber, M Jackson, P J Konijnenberg and M De Graef _et al_ 2015 _Modelling Simul. Mater. Sci. Eng._ **23** 083501 [DOI: https://doi.org/10.1088/0965-0393/23/8/083501](https://doi.org/10.1088/0965-0393/23/8/083501) -## ExamplesDirectionalStatsTest - -If you want to transform an Euler angle into a Quaternion the following works: - - Quaternion quat = OrientationTransformation::eu2qu(Orientation(33.0f, 10.0f, 0.0f)); +## Examples -If you have a *lot* of angles to transform the **Orienation** class can wrap a pointer instead at which point -you can loop over the array of angles. There is also the **OrientationConverter** class that can -mass transform from one representation into another. +If you want to transform an Euler angle into any other representation the following works: -Reading from an AMETEK .ang file is straightforward: +``` +// Note use of Radians for angles +ebsdlib::EulerDType euler(0.707, 1.23, 0.45); +OrientationMatrix om = euler.toOrientationMatrix(); +AxisAngle ax = euler.toAxisAngle(); +Rodrigues rod = euler.toRodrigues(); +Quaternion quat = euler.toQuaternion(); +Homochoric ho = euler.toHomochoric(); +Cubochoric cu = euler.toCubochoric(); +Stereographic stereo = euler.toStereographic(); - AngReader reader; - reader.setFileName(std::string("/path/to/ebsd_scan.ang")); - int32_t err = reader.readFile(); - // All of the data from the .ang file is now in memory. You can access it through the pointers - size_t numElements = reader.getNumberOfElements(); - float* ptr = reader.getPhi1Pointer(); - // The reader will clean up the memory so either tell the reader to Not clean up the pointer or keep the reader in scope. +// To print out any representation, just use the C++ std::out or std::ostream +std::cout << euler << std::endl; +``` diff --git a/Source/Apps/ConvertOrientations.cpp b/Source/Apps/ConvertOrientations.cpp index 0e7c02b9..2c792090 100644 --- a/Source/Apps/ConvertOrientations.cpp +++ b/Source/Apps/ConvertOrientations.cpp @@ -9,9 +9,11 @@ #include "EbsdLib/OrientationMath/OrientationConverter.hpp" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" +using namespace ebsdlib; + using EbsdDoubleArrayType = EbsdDataArray; using EbsdDoubleArrayPointerType = EbsdDoubleArrayType::Pointer; -using OCType = OrientationConverter; +using OCType = OrientationConverter; // ----------------------------------------------------------------------------- template @@ -30,7 +32,7 @@ std::shared_ptr> generateRepresentation(int32_t inputType, int3 converters[5] = HomochoricConverter, T>::New(); converters[6] = CubochoricConverter, T>::New(); - std::vector ocTypes = OCType::GetOrientationTypes(); + std::vector ocTypes = OCType::GetOrientationTypes(); converters[inputType]->setInputData(inputOrientations); converters[inputType]->convertRepresentationTo(ocTypes[outputType]); diff --git a/Source/Apps/ParseAztecProject.cpp b/Source/Apps/ParseAztecProject.cpp index 2ff61bcd..c87bdb14 100644 --- a/Source/Apps/ParseAztecProject.cpp +++ b/Source/Apps/ParseAztecProject.cpp @@ -4,6 +4,8 @@ #include +using namespace ebsdlib; + namespace detail { // const std::string k_CprPath = "/Volumes/OWC_Express_1M2/DREAM3D_Troubleshoot_Data/Benjamin_Layer1/Layer1.cpr"; diff --git a/Source/Apps/eq_orientations.cpp b/Source/Apps/eq_orientations.cpp index 6997ce64..3d81e6fa 100644 --- a/Source/Apps/eq_orientations.cpp +++ b/Source/Apps/eq_orientations.cpp @@ -6,14 +6,13 @@ #include #include -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/OrientationMath/OrientationConverter.hpp" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" -#include "Test/TestPrintFunctions.h" +using namespace ebsdlib; bool quaternionsAreClose(const QuatD& q1, const QuatD& q2, double tolerance = 1e-6) { diff --git a/Source/Apps/gen_sym_code.cpp b/Source/Apps/gen_sym_code.cpp index ae0118eb..c82b7e16 100644 --- a/Source/Apps/gen_sym_code.cpp +++ b/Source/Apps/gen_sym_code.cpp @@ -1,11 +1,11 @@ #include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/Core/OrientationTransformation.hpp" #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include #include @@ -16,6 +16,8 @@ #include #include +using namespace ebsdlib; + const double sq22 = 0.7071067811865475244; // sqrt(2)/2 static double sq32 = std::sqrt(3.0) / 2.0; diff --git a/Source/Apps/generate_ipf_legends.cpp b/Source/Apps/generate_ipf_legends.cpp index 91b09700..938d7520 100644 --- a/Source/Apps/generate_ipf_legends.cpp +++ b/Source/Apps/generate_ipf_legends.cpp @@ -31,14 +31,14 @@ #include #include -using namespace EbsdLib; +using namespace ebsdlib; // const std::string k_Output_Dir(UnitTest::DataDir + "/IPF_Legend/"); const std::string k_Output_Dir(UnitTest::TestTempDir + "/IPF_Legend/"); using EbsdDoubleArrayType = EbsdDataArray; using EbsdDoubleArrayPointerType = EbsdDoubleArrayType::Pointer; -using OCType = OrientationConverter; +using OCType = OrientationConverter; std::map k_AlgorithmIndexMap = {{"eu", 0}, {"om", 1}, {"qu", 2}, {"aa", 3}, {"ro", 4}, {"ho", 5}, {"cu", 6}, {"st", 7}}; @@ -61,7 +61,7 @@ std::shared_ptr> generateRepresentation(int32_t inputType, int3 converters[5] = HomochoricConverter, T>::New(); converters[6] = CubochoricConverter, T>::New(); - std::vector ocTypes = OCType1::GetOrientationTypes(); + std::vector ocTypes = OCType1::GetOrientationTypes(); converters[inputType]->setInputData(inputOrientations); converters[inputType]->convertRepresentationTo(ocTypes[outputType]); @@ -190,7 +190,7 @@ class GenerateIPFColorsImpl std::vector ops = LaueOps::GetAllOrientationOps(); double refDir[3] = {m_ReferenceDir[0], m_ReferenceDir[1], m_ReferenceDir[2]}; double dEuler[3] = {0.0, 0.0, 0.0}; - EbsdLib::Rgb argb = 0x00000000; + ebsdlib::Rgb argb = 0x00000000; int32_t phase = 0; bool calcIPF = false; size_t index = 0; @@ -223,12 +223,12 @@ class GenerateIPFColorsImpl std::cout << "phase > number of phases" << std::endl; } - if(phase < numPhases && calcIPF && phase < EbsdLib::CrystalStructure::LaueGroupEnd) + if(phase < numPhases && calcIPF && phase < ebsdlib::CrystalStructure::LaueGroupEnd) { argb = ops[phase]->generateIPFColor(dEuler, refDir, false); - (*m_CellIPFColors)[index] = static_cast(EbsdLib::RgbColor::dRed(argb)); - (*m_CellIPFColors)[index + 1] = static_cast(EbsdLib::RgbColor::dGreen(argb)); - (*m_CellIPFColors)[index + 2] = static_cast(EbsdLib::RgbColor::dBlue(argb)); + (*m_CellIPFColors)[index] = static_cast(ebsdlib::RgbColor::dRed(argb)); + (*m_CellIPFColors)[index + 1] = static_cast(ebsdlib::RgbColor::dGreen(argb)); + (*m_CellIPFColors)[index + 2] = static_cast(ebsdlib::RgbColor::dBlue(argb)); } } } @@ -292,7 +292,7 @@ void GeneratePoleFigures(LaueOps& ops, int symType) config.order = {0, 1, 2}; config.phaseName = "Generated Quaternions"; - std::vector poleFigures = ops.generatePoleFigure(config); + std::vector poleFigures = ops.generatePoleFigure(config); size_t index = 0; for(auto& poleFigure : poleFigures) { @@ -300,16 +300,16 @@ void GeneratePoleFigures(LaueOps& ops, int symType) // is in the upper left and the +Y points DOWN. But the algorithm used real XY coordinates // without knowledge of which reference frame we are in. // So first mirror the image across the X Axis - poleFigure = EbsdLib::MirrorImage(poleFigure.get(), config.imageDim); + poleFigure = ebsdlib::MirrorImage(poleFigure.get(), config.imageDim); // Overlay the Standard Projection annotations onto the Image if(symType == 1) { - poleFigure = EbsdLib::DrawStandardCubicProjection(poleFigure, config.imageDim, config.imageDim); + poleFigure = ebsdlib::DrawStandardCubicProjection(poleFigure, config.imageDim, config.imageDim); } else if(symType == 2) { - poleFigure = EbsdLib::DrawStandardHexagonalProjection(poleFigure, config.imageDim, config.imageDim); + poleFigure = ebsdlib::DrawStandardHexagonalProjection(poleFigure, config.imageDim, config.imageDim); } ss.str(""); @@ -352,7 +352,7 @@ int main(int argc, char* argv[]) int yStart = 0; int numCols = imageDim * 0.75F; int numRows = imageDim * 0.65F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -412,7 +412,7 @@ int main(int argc, char* argv[]) legend = ops.generateIPFTriangleLegend(imageDim, false); int yCropped = imageDim * 0.6F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, 0, 0, imageDim, yCropped); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, 0, 0, imageDim, yCropped); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), imageDim, yCropped, 3, legend->getPointer(0)); @@ -505,7 +505,7 @@ int main(int argc, char* argv[]) int numCols = imageDim * 0.78F; int numRows = imageDim * 0.6F; legend = ops.generateIPFTriangleLegend(imageDim, false); - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -540,7 +540,7 @@ int main(int argc, char* argv[]) int numCols = imageDim * 0.78F; int numRows = imageDim * 0.6F; legend = ops.generateIPFTriangleLegend(imageDim, false); - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -574,7 +574,7 @@ int main(int argc, char* argv[]) int yStart = 0; int numCols = imageDim * 0.70F; int numRows = imageDim * 0.6F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -608,7 +608,7 @@ int main(int argc, char* argv[]) int yStart = 0; int numCols = imageDim * 0.80F; int numRows = imageDim * 0.5F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -642,7 +642,7 @@ int main(int argc, char* argv[]) int yStart = 0; int numCols = imageDim * 0.70F; int numRows = imageDim * 0.5F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); @@ -676,7 +676,7 @@ int main(int argc, char* argv[]) int yStart = 0; int numCols = imageDim * 0.90F; int numRows = imageDim * 0.65F; - legend = EbsdLib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); + legend = ebsdlib::CropRGBImage(legend, imageDim, imageDim, xStart, yStart, numCols, numRows); ss.str(""); ss << k_Output_Dir << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << "/" << EbsdStringUtils::replace(ops.getSymmetryName(), "/", "_") << ".tiff"; result = TiffWriter::WriteColorImage(ss.str(), numCols, numRows, 3, legend->getPointer(0)); diff --git a/Source/Apps/make_ipf.cpp b/Source/Apps/make_ipf.cpp index 748cf636..ed39943a 100644 --- a/Source/Apps/make_ipf.cpp +++ b/Source/Apps/make_ipf.cpp @@ -16,6 +16,9 @@ class Ang2IPF; using FloatVec3Type = std::array; + +using namespace ebsdlib; + /** * @brief The GenerateIPFColorsImpl class implements a threaded algorithm that computes the IPF * colors for each element in a geometry @@ -40,7 +43,7 @@ class GenerateIPFColorsImpl std::vector ops = LaueOps::GetAllOrientationOps(); double refDir[3] = {m_ReferenceDir[0], m_ReferenceDir[1], m_ReferenceDir[2]}; double dEuler[3] = {0.0, 0.0, 0.0}; - EbsdLib::Rgb argb = 0x00000000; + ebsdlib::Rgb argb = 0x00000000; int32_t phase = 0; bool calcIPF = false; size_t index = 0; @@ -79,12 +82,12 @@ class GenerateIPFColorsImpl size_t currentLaueOpsIndex = laueOpsIndex[phase]; - if(phase < numPhases && calcIPF && currentLaueOpsIndex < EbsdLib::CrystalStructure::LaueGroupEnd) + if(phase < numPhases && calcIPF && currentLaueOpsIndex < ebsdlib::CrystalStructure::LaueGroupEnd) { argb = ops[currentLaueOpsIndex]->generateIPFColor(dEuler, refDir, false); - m_CellIPFColors[index] = static_cast(EbsdLib::RgbColor::dRed(argb)); - m_CellIPFColors[index + 1] = static_cast(EbsdLib::RgbColor::dGreen(argb)); - m_CellIPFColors[index + 2] = static_cast(EbsdLib::RgbColor::dBlue(argb)); + m_CellIPFColors[index] = static_cast(ebsdlib::RgbColor::dRed(argb)); + m_CellIPFColors[index + 1] = static_cast(ebsdlib::RgbColor::dGreen(argb)); + m_CellIPFColors[index + 2] = static_cast(ebsdlib::RgbColor::dBlue(argb)); // std::cout << (int32_t)(m_CellIPFColors[index]) << "\t" << (int32_t)(m_CellIPFColors[index + 1]) << (int32_t)(m_CellIPFColors[index + 2]) << m_CellEulerAngles[index] << "\t" // << m_CellEulerAngles[index + 1] << "\t" << m_CellEulerAngles[index + 2] << std::endl; @@ -150,7 +153,7 @@ class Ang2IPF // Make sure we are dealing with a unit 1 vector. std::array normRefDir = m_ReferenceDir; // Make a copy of the reference Direction - EbsdMatrixMath::Normalize3x1(normRefDir[0], normRefDir[1], normRefDir[2]); + ebsdlib::EbsdMatrixMath::Normalize3x1(normRefDir[0], normRefDir[1], normRefDir[2]); float* phi1Ptr = reader.getPhi1Pointer(false); float* phiPtr = reader.getPhiPointer(false); diff --git a/Source/Apps/rotconvert.cpp b/Source/Apps/rotconvert.cpp index 4e6a2c39..0f429036 100644 --- a/Source/Apps/rotconvert.cpp +++ b/Source/Apps/rotconvert.cpp @@ -6,14 +6,11 @@ #include #include -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" -#include "Test/TestPrintFunctions.h" - std::map counts = {{"eu", 3}, {"om", 9}, {"ax", 4}, {"ro", 3}, {"qu", 4}, {"ho", 3}, {"cu", 3}}; std::vector reps = {"eu", "om", "ax", "ro", "qu", "ho", "cu"}; diff --git a/Source/EbsdLib/Core/AbstractEbsdFields.cpp b/Source/EbsdLib/Core/AbstractEbsdFields.cpp index b0606b71..c975b8f6 100644 --- a/Source/EbsdLib/Core/AbstractEbsdFields.cpp +++ b/Source/EbsdLib/Core/AbstractEbsdFields.cpp @@ -34,6 +34,8 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "AbstractEbsdFields.h" +using namespace ebsdlib; + AbstractEbsdFields::AbstractEbsdFields() = default; AbstractEbsdFields::~AbstractEbsdFields() = default; diff --git a/Source/EbsdLib/Core/AbstractEbsdFields.h b/Source/EbsdLib/Core/AbstractEbsdFields.h index b97a249d..b18760f6 100644 --- a/Source/EbsdLib/Core/AbstractEbsdFields.h +++ b/Source/EbsdLib/Core/AbstractEbsdFields.h @@ -35,13 +35,15 @@ #pragma once -#include -#include - #include "EbsdLib/Core/EbsdLibConstants.h" #include "EbsdLib/Core/EbsdSetGetMacros.h" #include "EbsdLib/EbsdLib.h" +#include +#include + +namespace ebsdlib +{ /** * @brief The AbstractEbsdFields class */ @@ -67,6 +69,5 @@ class EbsdLib_EXPORT AbstractEbsdFields AbstractEbsdFields(AbstractEbsdFields&&) = delete; // Move Constructor Not Implemented AbstractEbsdFields& operator=(const AbstractEbsdFields&) = delete; // Copy Assignment Not Implemented AbstractEbsdFields& operator=(AbstractEbsdFields&&) = delete; // Move Assignment Not Implemented - -private: }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Core/EbsdDataArray.cpp b/Source/EbsdLib/Core/EbsdDataArray.cpp index cc0c62c2..3a44e90e 100644 --- a/Source/EbsdLib/Core/EbsdDataArray.cpp +++ b/Source/EbsdLib/Core/EbsdDataArray.cpp @@ -415,54 +415,54 @@ typename EbsdDataArray::Pointer EbsdDataArray::deepCopy(bool forceNoAlloca * @return */ template -EbsdLib::NumericTypes::Type EbsdDataArray::getType() const +ebsdlib::NumericTypes::Type EbsdDataArray::getType() const { if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Int8; + return ebsdlib::NumericTypes::Type::Int8; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Int16; + return ebsdlib::NumericTypes::Type::Int16; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::UInt16; + return ebsdlib::NumericTypes::Type::UInt16; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::UInt32; + return ebsdlib::NumericTypes::Type::UInt32; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Int64; + return ebsdlib::NumericTypes::Type::Int64; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::UInt64; + return ebsdlib::NumericTypes::Type::UInt64; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Double; + return ebsdlib::NumericTypes::Type::Double; } else if constexpr(std::is_same_v) { - return EbsdLib::NumericTypes::Type::Bool; + return ebsdlib::NumericTypes::Type::Bool; } - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- @@ -1141,11 +1141,11 @@ int EbsdDataArray::writeXdmfAttribute(std::stringstream& out, const int64_t* // ----------------------------------------------------------------------------- template -std::string EbsdDataArray::getInfoString(EbsdLib::InfoStringFormat format) const +std::string EbsdDataArray::getInfoString(ebsdlib::InfoStringFormat format) const { std::string info; std::stringstream ss; - if(format == EbsdLib::HtmlFormat) + if(format == ebsdlib::HtmlFormat) { ss << "\n"; ss << "\n"; @@ -1178,7 +1178,7 @@ std::string EbsdDataArray::getInfoString(EbsdLib::InfoStringFormat format) co ss << "\n"; ss << ""; } - else if(format == EbsdLib::MarkDown) + else if(format == ebsdlib::MarkDown) { ss << "+ Name: " << getName() << "\n"; ss << "+ Type: " << getTypeAsString() << "\n"; diff --git a/Source/EbsdLib/Core/EbsdDataArray.hpp b/Source/EbsdLib/Core/EbsdDataArray.hpp index 43da0703..ee9c1d03 100644 --- a/Source/EbsdLib/Core/EbsdDataArray.hpp +++ b/Source/EbsdLib/Core/EbsdDataArray.hpp @@ -268,7 +268,7 @@ class EbsdDataArray * @return */ - EbsdLib::NumericTypes::Type getType() const; + ebsdlib::NumericTypes::Type getType() const; /** * @brief GetTypeName Returns a string representation of the type of data that is stored by this class. This @@ -524,7 +524,7 @@ class EbsdDataArray * @return Returns a formatted string that contains general infomation about * the instance of the object. */ - std::string getInfoString(EbsdLib::InfoStringFormat format) const; + std::string getInfoString(ebsdlib::InfoStringFormat format) const; /** * @brief @@ -1227,7 +1227,7 @@ extern template class EbsdDataArray; // ----------------------------------------------------------------------------- // Declare our aliases -namespace EbsdLib +namespace ebsdlib { // using BoolArrayType = EbsdDataArray; @@ -1250,4 +1250,4 @@ using FloatArrayType = EbsdDataArray; using DoubleArrayType = EbsdDataArray; // using SizeTArrayType = EbsdDataArray; -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Core/EbsdLibConstants.h b/Source/EbsdLib/Core/EbsdLibConstants.h index f4341e25..76ee7bae 100644 --- a/Source/EbsdLib/Core/EbsdLibConstants.h +++ b/Source/EbsdLib/Core/EbsdLibConstants.h @@ -59,7 +59,7 @@ * @file EbsdConstants.h * @brief This file contains many constants that are generic to the EBSD library */ -namespace EbsdLib +namespace ebsdlib { using Rgb = uint32_t; @@ -188,28 +188,28 @@ namespace Utils { inline std::string getStringForEnum(uint32_t v) { - if(EbsdLib::RefFrameZDir::LowtoHigh == v) + if(ebsdlib::RefFrameZDir::LowtoHigh == v) { - return EbsdLib::StackingOrder::LowToHigh; + return ebsdlib::StackingOrder::LowToHigh; } - if(EbsdLib::RefFrameZDir::HightoLow == v) + if(ebsdlib::RefFrameZDir::HightoLow == v) { - return EbsdLib::StackingOrder::HighToLow; + return ebsdlib::StackingOrder::HighToLow; } - return EbsdLib::StackingOrder::UnknownStackingOrder; + return ebsdlib::StackingOrder::UnknownStackingOrder; } inline int32_t getEnumForString(const std::string& v) { - if(EbsdLib::StackingOrder::LowToHigh == v) + if(ebsdlib::StackingOrder::LowToHigh == v) { - return EbsdLib::RefFrameZDir::LowtoHigh; + return ebsdlib::RefFrameZDir::LowtoHigh; } - if(EbsdLib::StackingOrder::HighToLow == v) + if(ebsdlib::StackingOrder::HighToLow == v) { - return EbsdLib::RefFrameZDir::HightoLow; + return ebsdlib::RefFrameZDir::HightoLow; } - return EbsdLib::RefFrameZDir::UnknownRefFrameZDirection; + return ebsdlib::RefFrameZDir::UnknownRefFrameZDirection; } } // namespace Utils } // namespace StackingOrder @@ -293,4 +293,4 @@ inline constexpr double BP[12] = { // Condense some of the namespaces to same some typing later on. namespace LPs = LambertParametersType; -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Core/EbsdMacros.h b/Source/EbsdLib/Core/EbsdMacros.h index 462c7b4f..a1c7c86c 100644 --- a/Source/EbsdLib/Core/EbsdMacros.h +++ b/Source/EbsdLib/Core/EbsdMacros.h @@ -40,7 +40,7 @@ #include #include -namespace EbsdLib +namespace ebsdlib { class method_not_implemented : public std::exception { @@ -96,7 +96,7 @@ class method_not_implemented : public std::exception void operator=(const method_not_implemented&) = delete; // Move assignment Not Implemented }; -} // namespace EbsdLib +} // namespace ebsdlib /** @brief This macro is used to shorten the code needed to go from std::string to QString. Helpful in other codes that use * QString instead of std::string @@ -110,7 +110,7 @@ class method_not_implemented : public std::exception { \ std::stringstream assert_message; \ assert_message << __FILE__ << "(" << __LINE__ << ")" << getNameOfClass() << ": Method is not implemented."; \ - throw EbsdLib::method_not_implemented(assert_message.str()); \ + throw ebsdlib::method_not_implemented(assert_message.str()); \ } /** diff --git a/Source/EbsdLib/Core/EbsdStringLiteral.hpp b/Source/EbsdLib/Core/EbsdStringLiteral.hpp index f9614f1d..32d07475 100644 --- a/Source/EbsdLib/Core/EbsdStringLiteral.hpp +++ b/Source/EbsdLib/Core/EbsdStringLiteral.hpp @@ -7,7 +7,7 @@ // #include // #include -namespace EbsdLib +namespace ebsdlib { /** @@ -213,7 +213,7 @@ using EbsdStringLiteral = BasicEbsdStringLiteral; using WEbsdStringLiteral = BasicEbsdStringLiteral; using String16Literal = BasicEbsdStringLiteral; using String32Literal = BasicEbsdStringLiteral; -} // namespace EbsdLib +} // namespace ebsdlib #if 0 template diff --git a/Source/EbsdLib/Core/EbsdTransform.cpp b/Source/EbsdLib/Core/EbsdTransform.cpp index 4f4afb5e..c10802e6 100644 --- a/Source/EbsdLib/Core/EbsdTransform.cpp +++ b/Source/EbsdLib/Core/EbsdTransform.cpp @@ -42,7 +42,7 @@ EbsdTransform::EbsdTransform() = default; -EbsdLib::EbsdToSampleCoordinateMapping EbsdTransform::IdentifyStandardTransformation(const std::array& sampleTransformation, const std::array& eulerTransformation) +ebsdlib::EbsdToSampleCoordinateMapping EbsdTransform::IdentifyStandardTransformation(const std::array& sampleTransformation, const std::array& eulerTransformation) { // TSL/EDAX @@ -51,7 +51,7 @@ EbsdLib::EbsdToSampleCoordinateMapping EbsdTransform::IdentifyStandardTransforma && eulerTransformation[0] == 90.0f && eulerTransformation[1] == 0.0f && eulerTransformation[2] == 0.0f && eulerTransformation[3] == 1.0f) { - return EbsdLib::TSLdefault; + return ebsdlib::TSLdefault; } if(sampleTransformation[0] == 180.0f // HKL @@ -60,7 +60,7 @@ EbsdLib::EbsdToSampleCoordinateMapping EbsdTransform::IdentifyStandardTransforma && eulerTransformation[0] == 0.0f && eulerTransformation[1] == 0.0f && eulerTransformation[2] == 0.0f && eulerTransformation[3] == 1.0f) { - return EbsdLib::HKLdefault; + return ebsdlib::HKLdefault; } if(sampleTransformation[0] == 0.0f // HEDM @@ -69,10 +69,10 @@ EbsdLib::EbsdToSampleCoordinateMapping EbsdTransform::IdentifyStandardTransforma && eulerTransformation[0] == 0.0f && eulerTransformation[1] == 0.0f && eulerTransformation[2] == 0.0f && eulerTransformation[3] == 1.0f) { - return EbsdLib::HEDMdefault; + return ebsdlib::HEDMdefault; } - return EbsdLib::UnknownCoordinateMapping; + return ebsdlib::UnknownCoordinateMapping; } // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/Core/EbsdTransform.h b/Source/EbsdLib/Core/EbsdTransform.h index ee69912d..edcd9b9e 100644 --- a/Source/EbsdLib/Core/EbsdTransform.h +++ b/Source/EbsdLib/Core/EbsdTransform.h @@ -71,7 +71,7 @@ class EbsdLib_EXPORT EbsdTransform * @param eulerTransformation * @return */ - static EbsdLib::EbsdToSampleCoordinateMapping IdentifyStandardTransformation(const std::array& sampleTransformation, const std::array& eulerTransformation); + static ebsdlib::EbsdToSampleCoordinateMapping IdentifyStandardTransformation(const std::array& sampleTransformation, const std::array& eulerTransformation); public: EbsdTransform(const EbsdTransform&) = delete; // Copy Constructor Not Implemented diff --git a/Source/EbsdLib/Core/Orientation.hpp b/Source/EbsdLib/Core/Orientation.hpp index 36e3e7f1..a1715ce7 100644 --- a/Source/EbsdLib/Core/Orientation.hpp +++ b/Source/EbsdLib/Core/Orientation.hpp @@ -191,7 +191,7 @@ class Orientation * @brief Orientation Copy constructor * @param gMatrix */ - explicit Orientation(const EbsdLib::Matrix3X3& gMatrix) + explicit Orientation(const ebsdlib::Matrix3X3& gMatrix) : m_Size(9) { allocate(); @@ -579,28 +579,7 @@ class Orientation return std::equal(begin(range1), end(range1), begin(range2)); } - /** - * @brief toGMatrix Copies the internal values into the 3x3 "G" Matrix - * @param g - */ - void toGMatrix(T g[3][3]) const - { - if(m_Size != 9) - { - throw std::out_of_range("Orientation subscript out of range"); - } - g[0][0] = m_Array[0]; - g[0][1] = m_Array[1]; - g[0][2] = m_Array[2]; - g[1][0] = m_Array[3]; - g[1][1] = m_Array[4]; - g[1][2] = m_Array[5]; - g[2][0] = m_Array[6]; - g[2][1] = m_Array[7]; - g[2][2] = m_Array[8]; - } - - EbsdLib::Matrix3X3 toGMatrixObj() const + ebsdlib::Matrix3X3 toGMatrix() const { if(m_Size != 9) { diff --git a/Source/EbsdLib/Core/OrientationMath.cpp b/Source/EbsdLib/Core/OrientationMath.cpp index 7a386861..463116e5 100644 --- a/Source/EbsdLib/Core/OrientationMath.cpp +++ b/Source/EbsdLib/Core/OrientationMath.cpp @@ -36,6 +36,7 @@ #include "OrientationMath.h" #include +using namespace ebsdlib; // ----------------------------------------------------------------------------- // diff --git a/Source/EbsdLib/Core/OrientationMath.h b/Source/EbsdLib/Core/OrientationMath.h index 04d581c9..6ad19b4e 100644 --- a/Source/EbsdLib/Core/OrientationMath.h +++ b/Source/EbsdLib/Core/OrientationMath.h @@ -39,6 +39,8 @@ #include "EbsdLib/EbsdLib.h" +namespace ebsdlib +{ /** * @class OrientationMath OrientationMath.h DREAM3DLib/Common/OrientationMath.h * @brief This class performs Crystallographic Misorientation Calculations @@ -54,70 +56,70 @@ class EbsdLib_EXPORT OrientationMath virtual ~OrientationMath(); #if 0 - /** - * @brief EulertoMatActive This function converts an Euler Angle triplet (Bunge) - * into a ACTIVE Orientation Matrix. This is taking a Crystal Coordinate - * system and transforming it to the Sample Coordinate System (C->S). Note that to convert - * from an ACTIVE to PASSIVE or PASSIVE to ACTIVE is just the transpose of the Orientation Maxtrix - * @param ea1 - * @param ea2 - * @param ea3 - * @param g - */ - static void EulertoMatActive(float ea1, float ea2, float ea3, float g[3][3]); - - /** - * @brief ChangeAxisReferenceFrame - * @param q - * @param n1 - * @param n2 - * @param n3 - */ - static void ChangeAxisReferenceFrame(QuatF& q, float& n1, float& n2, float& n3); - - /** - * @brief MatrixMisorientation - * @param g1 - * @param g2 - * @return - */ - static float MatrixMisorientation(float g1[3][3], float g2[3][3]); - - /** - * @brief MultiplyQuaternionVector Multiplies a Vector by a quaternion putting the result into 'outVec' - * @param inQuat Input Quaternion - * @param inVec Input Vector (XYZ) - * @param outVec Resulting vector - */ - static void MultiplyQuaternionVector(QuatF& inQuat, float inVec[3], float outVec[3]); - - /** - * @brief Does a passive Rotation of the coordinate system defined by w,n1,n2,n3 of the point xyz using Quaternion - * math to perform the rotation - * @param angle - * @param xAxis - * @param yAxis - * @param zAxis - * @param x - * @param y - * @param z - * @return The returned Quaternion is a "pure" Vector quaterion with a Zero value for the scalar (w) portion - */ - static QuatF PassiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z); - - /** - * @brief Does an active Rotation of (xyz) in using the Axis-Angle w,n1,n2,n3 using Quaternion math to perform - * the rotation - * @param angle - * @param xAxis - * @param yAxis - * @param zAxis - * @param x - * @param y - * @param z - * @return The returned Quaternion is a "pure" Vector quaterion with a Zero value for the scalar (w) portion - */ - static QuatF ActiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z); + /** + * @brief EulertoMatActive This function converts an Euler Angle triplet (Bunge) + * into a ACTIVE Orientation Matrix. This is taking a Crystal Coordinate + * system and transforming it to the Sample Coordinate System (C->S). Note that to convert + * from an ACTIVE to PASSIVE or PASSIVE to ACTIVE is just the transpose of the Orientation Maxtrix + * @param ea1 + * @param ea2 + * @param ea3 + * @param g + */ + static void EulertoMatActive(float ea1, float ea2, float ea3, float g[3][3]); + + /** + * @brief ChangeAxisReferenceFrame + * @param q + * @param n1 + * @param n2 + * @param n3 + */ + static void ChangeAxisReferenceFrame(QuatF& q, float& n1, float& n2, float& n3); + + /** + * @brief MatrixMisorientation + * @param g1 + * @param g2 + * @return + */ + static float MatrixMisorientation(float g1[3][3], float g2[3][3]); + + /** + * @brief MultiplyQuaternionVector Multiplies a Vector by a quaternion putting the result into 'outVec' + * @param inQuat Input Quaternion + * @param inVec Input Vector (XYZ) + * @param outVec Resulting vector + */ + static void MultiplyQuaternionVector(QuatF& inQuat, float inVec[3], float outVec[3]); + + /** + * @brief Does a passive Rotation of the coordinate system defined by w,n1,n2,n3 of the point xyz using Quaternion + * math to perform the rotation + * @param angle + * @param xAxis + * @param yAxis + * @param zAxis + * @param x + * @param y + * @param z + * @return The returned Quaternion is a "pure" Vector quaterion with a Zero value for the scalar (w) portion + */ + static QuatF PassiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z); + + /** + * @brief Does an active Rotation of (xyz) in using the Axis-Angle w,n1,n2,n3 using Quaternion math to perform + * the rotation + * @param angle + * @param xAxis + * @param yAxis + * @param zAxis + * @param x + * @param y + * @param z + * @return The returned Quaternion is a "pure" Vector quaterion with a Zero value for the scalar (w) portion + */ + static QuatF ActiveRotation(float angle, float xAxis, float yAxis, float zAxis, float x, float y, float z); #endif /** @@ -175,3 +177,4 @@ class EbsdLib_EXPORT OrientationMath OrientationMath& operator=(const OrientationMath&) = delete; // Copy Assignment Not Implemented OrientationMath& operator=(OrientationMath&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Core/OrientationRepresentation.hpp b/Source/EbsdLib/Core/OrientationRepresentation.hpp deleted file mode 100644 index 6b120266..00000000 --- a/Source/EbsdLib/Core/OrientationRepresentation.hpp +++ /dev/null @@ -1,474 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2025 BlueQuartz Software, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the names of any of the BlueQuartz Software contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#pragma once - -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" -#include "EbsdLib/EbsdLib.h" -#include "EbsdLib/Math/Matrix3X1.hpp" -#include "EbsdLib/Math/Matrix3X3.hpp" - -#include -#include - -namespace EbsdLib -{ - -#define REP_SHIM_TO_QUAT_DEF(FROM) \ - template \ - static Quaternion qu(const InputType& e, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) \ - { \ - Quaternion qu = OrientationTransformation::FROM##2##qu>(e, layout); \ - return Orientation(qu[0], qu[1], qu[2], qu[3]); \ - } - -#define REP_SHIM_FROM_QUAT_DEF(TO) \ - template \ - static OutputType TO(const InputType& qu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) \ - { \ - Quaternion quat(qu[0], qu[1], qu[2], qu[3]); \ - return OrientationTransformation::qu2##TO, OutputType>(quat, layout); \ - } - -#define REP_SHIM_DEF(FROM, TO) \ - template \ - static OutputType TO(const InputType& orientation) \ - { \ - return OrientationTransformation::FROM##2##TO(orientation); \ - } - -#define REP_SHIM_NO_OP(NAME) \ - template \ - static OutputType NAME(const InputType& orientation) \ - { \ - return orientation; \ - } - -#define ORIENTATION_REP_TO_METHOD_DEF(NAME, FUNC) \ - Orientation to##NAME() const \ - { \ - auto result = RepresentationType::template FUNC(m_Array); \ - return Orientation(result); \ - } - -struct QuaternionRep -{ - static constexpr size_t s_NumComponents = 4; - - REP_SHIM_FROM_QUAT_DEF(eu); - REP_SHIM_FROM_QUAT_DEF(om); - REP_SHIM_NO_OP(qu) - REP_SHIM_FROM_QUAT_DEF(ax); - REP_SHIM_FROM_QUAT_DEF(ro); - REP_SHIM_FROM_QUAT_DEF(ho); - REP_SHIM_FROM_QUAT_DEF(cu); - REP_SHIM_FROM_QUAT_DEF(st); -}; // quaternion - -struct EulerRep -{ - static constexpr size_t s_NumComponents = 3; - REP_SHIM_NO_OP(eu); - REP_SHIM_DEF(eu, om); - REP_SHIM_DEF(eu, qu) - REP_SHIM_DEF(eu, ax); - REP_SHIM_DEF(eu, ro); - REP_SHIM_DEF(eu, ho); - REP_SHIM_DEF(eu, cu); - REP_SHIM_DEF(eu, st); - -}; // euler angles - -struct OrientationMatrixRep -{ - static constexpr size_t s_NumComponents = 9; - REP_SHIM_DEF(om, eu); - REP_SHIM_NO_OP(om); - REP_SHIM_DEF(om, qu) - REP_SHIM_DEF(om, ax); - REP_SHIM_DEF(om, ro); - REP_SHIM_DEF(om, ho); - REP_SHIM_DEF(om, cu); - REP_SHIM_DEF(om, st); - -}; // orientation matrix - -struct AxisAngleRep -{ - static constexpr size_t s_NumComponents = 4; - REP_SHIM_DEF(ax, eu); - REP_SHIM_DEF(ax, om); - REP_SHIM_DEF(ax, qu) - REP_SHIM_NO_OP(ax); - REP_SHIM_DEF(ax, ro); - REP_SHIM_DEF(ax, ho); - REP_SHIM_DEF(ax, cu); - REP_SHIM_DEF(ax, st); -}; -struct RodriguesRep -{ - static constexpr size_t s_NumComponents = 4; - REP_SHIM_DEF(ro, eu); - REP_SHIM_DEF(ro, om); - REP_SHIM_DEF(ro, qu) - REP_SHIM_DEF(ro, ax); - REP_SHIM_NO_OP(ro); - REP_SHIM_DEF(ro, ho); - REP_SHIM_DEF(ro, cu); - REP_SHIM_DEF(ro, st); -}; -struct HomochoricRep -{ - static constexpr size_t s_NumComponents = 3; - REP_SHIM_DEF(ho, eu); - REP_SHIM_DEF(ho, om); - REP_SHIM_DEF(ho, qu) - REP_SHIM_DEF(ho, ax); - REP_SHIM_DEF(ho, ro); - REP_SHIM_NO_OP(ho); - REP_SHIM_DEF(ho, cu); - REP_SHIM_DEF(ho, st); -}; -struct CubochoricRep -{ - static constexpr size_t s_NumComponents = 3; - REP_SHIM_DEF(cu, eu); - REP_SHIM_DEF(cu, om); - REP_SHIM_DEF(cu, qu) - REP_SHIM_DEF(cu, ax); - REP_SHIM_DEF(cu, ro); - REP_SHIM_DEF(cu, ho); - REP_SHIM_NO_OP(cu); - REP_SHIM_DEF(cu, st); -}; -struct StereographicRep -{ - static constexpr size_t s_NumComponents = 3; - REP_SHIM_DEF(st, eu); - REP_SHIM_DEF(st, om); - REP_SHIM_DEF(st, qu) - REP_SHIM_DEF(st, ax); - REP_SHIM_DEF(st, ro); - REP_SHIM_DEF(st, ho); - REP_SHIM_DEF(st, cu); - REP_SHIM_NO_OP(st); -}; - -/** - * - * @tparam T The primitive type (float or double) - * @tparam RepresentationType The 'Representation' struct - */ -template -class Orientation -{ - -public: - using StorageType = std::vector; - - using size_type = size_t; - using value_type = T; - using reference = T&; - - using QuaternionType = Quaternion; - - Orientation() - { - m_Array.resize(RepresentationType::s_NumComponents); - } - - template >* = nullptr> - Orientation(T r0c0, T r0c1, T r0c2, T r1c0, T r1c1, T r1c2, T r2c0, T r2c1, T r2c2) - : m_Array({ - r0c0, - r0c1, - r0c2, - r1c0, - r1c1, - r1c2, - r2c0, - r2c1, - r2c2, - }) - { - } - - template >* = nullptr> - Orientation(const Matrix3X3& mat) - : m_Array({mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], mat[8]}) - { - } - - template || std::is_same_v || std::is_same_v>* = nullptr> - Orientation(T i, T j, T k, T w) - : m_Array({i, j, k, w}) - { - } - - template >* = nullptr> - explicit Orientation(const Quaternion& quat) - : m_Array({quat.x(), quat.y(), quat.z(), quat.w()}) - { - } - - template >* = nullptr> - explicit Orientation(const Quaternion& quat) - : m_Array({quat.x(), quat.y(), quat.z(), quat.w()}) - { - } - - template || std::is_same_v || std::is_same_v || - std::is_same_v>* = nullptr> - Orientation(T x, T y, T z) - : m_Array({x, y, z}) - { - } - - template || std::is_same_v || std::is_same_v || - std::is_same_v>* = nullptr> - Orientation(const Matrix3X1& mat) - : m_Array({mat[0], mat[1], mat[2]}) - { - } - - Orientation(const Orientation& rhs) - : m_Array(rhs.m_Array) - { - } - - Orientation(Orientation&& rhs) - : m_Array(std::move(rhs.m_Array)) - { - } - - Orientation(size_t size) - : m_Array() - { - if(RepresentationType::s_NumComponents != size) - { - throw std::runtime_error("Number of components of OrientationRep does not match 'size' argument"); - } - m_Array.resize(RepresentationType::s_NumComponents); - } - - Orientation(const StorageType& input) - : m_Array(input) - { - if(RepresentationType::s_NumComponents != m_Array.size()) - { - throw std::runtime_error("Number of components of OrientationRep does not match 'size' argument"); - } - } - - Orientation(const T* ptr) - { - m_Array.resize(RepresentationType::s_NumComponents); - m_Array.assign(ptr, ptr + RepresentationType::s_NumComponents); - } - - Orientation& operator=(const Orientation& rhs) // Copy Assignment - { - m_Array = rhs.m_Array; - return *this; - } - - Orientation& operator=(Orientation&& rhs) // Move Assignment - { - m_Array = std::move(rhs.m_Array); - return *this; - } - - reference operator[](size_type index) - { - return m_Array[index]; - } - - const T& operator[](size_type index) const - { - return m_Array[index]; - } - - size_t size() const - { - return RepresentationType::s_NumComponents; - } - - const T* data() const - { - return m_Array.data(); - } - - void copyTo(T* destination) const - { - std::copy(m_Array.begin(), m_Array.end(), destination); - } - - Orientation operator-(const Orientation& rhs) const - { - StorageType result_vec(m_Array.size()); - std::transform(m_Array.begin(), m_Array.end(), rhs.m_Array.begin(), result_vec.begin(), std::minus()); - return Orientation(result_vec); - } - - bool isWithinTolerance(const Orientation& rhs, T tolerance) const - { - auto result = *this - rhs; - auto it = std::find_if(result.m_Array.begin(), result.m_Array.end(), [tolerance](T num) { return std::abs(num) > tolerance; }); - return it == result.m_Array.end(); - } - - template >* = nullptr> - T w() const - { - return m_Array[3]; - } - template >* = nullptr> - T x() const - { - return m_Array[0]; - } - template >* = nullptr> - T y() const - { - return m_Array[1]; - } - template >* = nullptr> - T z() const - { - return m_Array[2]; - } - - ORIENTATION_REP_TO_METHOD_DEF(Euler, eu) - ORIENTATION_REP_TO_METHOD_DEF(OrientationMatrix, om) - ORIENTATION_REP_TO_METHOD_DEF(Quaternion, qu) - ORIENTATION_REP_TO_METHOD_DEF(AxisAngle, ax) - ORIENTATION_REP_TO_METHOD_DEF(Rodrigues, ro) - ORIENTATION_REP_TO_METHOD_DEF(Homochoric, ho) - ORIENTATION_REP_TO_METHOD_DEF(Cubochoric, cu) - ORIENTATION_REP_TO_METHOD_DEF(Stereographic, st) - - QuaternionType toQuat() const - { - Orientation quRep = toQuaternion(); - return QuaternionType{quRep[0], quRep[1], quRep[2], quRep[3]}; - } - - template >* = nullptr> - Matrix3X3 toGMatrixObj() const - { - return {m_Array[0], m_Array[1], m_Array[2], m_Array[3], m_Array[4], m_Array[5], m_Array[6], m_Array[7], m_Array[8]}; - } - - template >* = nullptr> - Eigen::Matrix toEigenGMatrix() const - { - Eigen::Matrix g1; - g1(0, 0) = m_Array[0]; - g1(0, 1) = m_Array[1]; - g1(0, 2) = m_Array[2]; - g1(1, 0) = m_Array[3]; - g1(1, 1) = m_Array[4]; - g1(1, 2) = m_Array[5]; - g1(2, 0) = m_Array[6]; - g1(2, 1) = m_Array[7]; - g1(2, 2) = m_Array[8]; - return g1; - } - -private: - StorageType m_Array; -}; - -using EulerDType = Orientation; -using OrientationMatrixDType = Orientation; -using QuaternionDType = Orientation; -using AxisAngleDType = Orientation; -using RodriguesDType = Orientation; -using HomochoricDType = Orientation; -using CubochoricDType = Orientation; -using StereographicDType = Orientation; - -using EulerFType = Orientation; -using OrientationMatrixFType = Orientation; -using QuaternionFType = Orientation; -using AxisAngleFType = Orientation; -using RodriguesFType = Orientation; -using HomochoricFType = Orientation; -using CubochoricFType = Orientation; -using StereographicFType = Orientation; - -inline std::ostream& operator<<(std::ostream& os, const EulerDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "EU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const OrientationMatrixDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "OM: / " << obj[0] << ", " << obj[1] << ", " << obj[2] << "\\\n"; - os << std::setw(3) << std::setprecision(16) << "OM: | " << obj[3] << ", " << obj[4] << ", " << obj[5] << "|\n"; - os << std::setw(3) << std::setprecision(16) << "OM: \\ " << obj[6] << ", " << obj[7] << ", " << obj[8] << "/\n"; - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const QuaternionDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "QU: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; - return os; -} -inline std::ostream& operator<<(std::ostream& os, const AxisAngleDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "AX: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; - return os; -} -inline std::ostream& operator<<(std::ostream& os, const RodriguesDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "RO: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; - return os; -} -inline std::ostream& operator<<(std::ostream& os, const HomochoricDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "HO: " << obj[0] << ", " << obj[1] << ", " << obj[2]; - return os; -} -inline std::ostream& operator<<(std::ostream& os, const CubochoricDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "CU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; - return os; -} -inline std::ostream& operator<<(std::ostream& os, const StereographicDType& obj) -{ - os << std::setw(3) << std::setprecision(16) << "ST: " << obj[0] << ", " << obj[1] << ", " << obj[2]; - return os; -} - -} // namespace EbsdLib diff --git a/Source/EbsdLib/Core/OrientationTransformation.hpp b/Source/EbsdLib/Core/OrientationTransformation.hpp index c82c89dd..db50bfc5 100644 --- a/Source/EbsdLib/Core/OrientationTransformation.hpp +++ b/Source/EbsdLib/Core/OrientationTransformation.hpp @@ -35,9 +35,10 @@ #pragma once -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdMatrixMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/ModifiedLambertProjection3D.hpp" #if __APPLE__ @@ -88,62 +89,13 @@ | c | - | - | - | - | - | X | # | */ -/** - * The Orientation codes are written in such a way that the value of -1 indicates - * an Active Rotation and +1 indicates a passive rotation. - * - * DO NOT UNDER ANY CIRCUMSTANCE CHANGE THESE VARIABLES. THERE WILL BE BAD - * CONSEQUENCES IF THESE ARE CHANGED. EVERY PIECE OF CODE THAT RELIES ON THESE - * FUNCTIONS WILL BREAK. IN ADDITION, THE QUATERNION ARITHMETIC WILL NO LONGER - * BE CONSISTENT WITH ROTATION ARITHMETIC. - * - * YOU HAVE BEEN WARNED. - * - * Adam Morawiec's book uses Passive rotations. - **/ -#ifndef DREAM3D_PASSIVE_ROTATION -// #define DREAM3D_ACTIVE_ROTATION -1.0 -#define DREAM3D_PASSIVE_ROTATION 1 -#endif - -#ifndef ROTATIONS_CONSTANTS -#define ROTATIONS_CONSTANTS -namespace Rotations::Constants -{ -#if DREAM3D_PASSIVE_ROTATION -static const float epsijk = 1.0f; -static const double epsijkd = 1.0; -#elif DREAM3D_ACTIVE_ROTATION -static const float epsijk = -1.0f; -static const double epsijkd = -1.0; -#endif -} // namespace Rotations::Constants - -#endif - // Add some shortened namespace alias // Condense some of the namespaces to same some typing later on. -namespace LPs = EbsdLib::LambertParametersType; +namespace LPs = ebsdlib::LambertParametersType; namespace RConst = Rotations::Constants; -namespace DConst = EbsdLib::Constants; - -namespace OrientationRepresentation -{ -enum class Type : int -{ - Euler = 0, - OrientationMatrix, - Quaternion, - AxisAngle, - Rodrigues, - Homochoric, - Cubochoric, - Stereographic, - Unknown -}; -} +namespace DConst = ebsdlib::constants; -using namespace EbsdLib; +using namespace ebsdlib; /** * @brief The OrientationTransformation namespace @@ -319,17 +271,17 @@ ResultType eu_check(const T& eu) ResultType res; res.result = 1; - if((eu[0] < 0.0) || (eu[0] > (EbsdLib::Constants::k_2PiD))) + if((eu[0] < 0.0) || (eu[0] > (ebsdlib::constants::k_2PiD))) { res.msg = "rotations:eu_check:: phi1 Euler angle outside of valid range [0,2pi]"; res.result = -1; } - if((eu[1] < 0.0) || (eu[1] > EbsdLib::Constants::k_PiD)) + if((eu[1] < 0.0) || (eu[1] > ebsdlib::constants::k_PiD)) { res.msg = "rotations:eu_check:: Phi Euler angle outside of valid range [0,pi]"; res.result = -2; } - if((eu[2] < 0.0) || (eu[2] > (EbsdLib::Constants::k_2PiD))) + if((eu[2] < 0.0) || (eu[2] > (ebsdlib::constants::k_2PiD))) { res.msg = "rotations:eu_check:: phi2 Euler angle outside of valid range [0,2pi]"; res.result = -3; @@ -452,14 +404,14 @@ ResultType cu_check(const InputType& cu) * @date 9/30/14 MDG 1.0 original */ template -ResultType qu_check(const InputType& qu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +ResultType qu_check(const InputType& qu, typename Quat::Order layout = Quat::Order::VectorScalar) { using SizeType = typename InputType::size_type; SizeType w = 0; SizeType x = 1; SizeType y = 2; SizeType z = 3; - if(layout == Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -503,7 +455,7 @@ ResultType ax_check(const InputType& ax) using value_type = typename InputType::value_type; ResultType res; res.result = 1; - if((ax[3] < 0.0) || (ax[3] > EbsdLib::Constants::k_PiD)) + if((ax[3] < 0.0) || (ax[3] > ebsdlib::constants::k_PiD)) { res.msg = "rotations:ax_check: angle must be in range [0,pi]"; res.result = -1; @@ -586,7 +538,7 @@ ResultType om_check(const InputType& om) } ValueType r = fabs(det - static_cast(1.0L)); - if(!EbsdLibMath::closeEnough(r, static_cast(0.0L), threshold)) + if(!ebsdlib::math::closeEnough(r, static_cast(0.0L), threshold)) { ss << "rotations:om_check: Determinant (" << det << ") of rotation matrix must be unity (1.0)"; res.msg = ss.str(); @@ -650,9 +602,9 @@ ResultType om_check(const InputType& om) assert(false); } - axang[0] = -RConst::epsijk * av[0]; - axang[1] = -RConst::epsijk * av[1]; - axang[2] = -RConst::epsijk * av[2]; + axang[0] = -ebsdlib::orientations::epsijk * av[0]; + axang[1] = -ebsdlib::orientations::epsijk * av[1]; + axang[2] = -ebsdlib::orientations::epsijk * av[2]; axang[3] = omega; s = sqrt(sumofSquares(av)); @@ -793,9 +745,9 @@ OutputType eu2ax(const InputType& e) value_type sig = static_cast(0.5 * (e[0] + e[2])); value_type del = static_cast(0.5 * (e[0] - e[2])); value_type tau = static_cast(std::sqrt(t * t + sin(sig) * sin(sig))); - if(EbsdLibMath::closeEnough(sig, static_cast(EbsdLib::Constants::k_PiOver2D), static_cast(1.0E-6L))) + if(ebsdlib::math::closeEnough(sig, static_cast(ebsdlib::constants::k_PiOver2D), static_cast(1.0E-6L))) { - alpha = static_cast(EbsdLib::Constants::k_PiD); + alpha = static_cast(ebsdlib::constants::k_PiD); } else { @@ -812,9 +764,9 @@ OutputType eu2ax(const InputType& e) else { //! passive axis-angle pair so a minus sign in front - res[0] = static_cast(-RConst::epsijkd * t * cos(del) / tau); - res[1] = static_cast(-RConst::epsijkd * t * sin(del) / tau); - res[2] = static_cast(-RConst::epsijkd * sin(sig) / tau); + res[0] = static_cast(-ebsdlib::orientations::epsijkd * t * cos(del) / tau); + res[1] = static_cast(-ebsdlib::orientations::epsijkd * t * sin(del) / tau); + res[2] = static_cast(-ebsdlib::orientations::epsijkd * sin(sig) / tau); res[3] = alpha; if(alpha < 0.0) @@ -849,15 +801,15 @@ OutputType eu2ro(const InputType& e) using OutputValueType = typename OutputType::value_type; typename OutputType::value_type t = res[3]; - if(std::fabs(t - EbsdLib::Constants::k_PiD) < thr) + if(std::fabs(t - ebsdlib::constants::k_PiD) < thr) { res[3] = std::numeric_limits::infinity(); return res; } - if(EbsdLibMath::closeEnough(t, static_cast(0.0), thr)) // Are we close to Zero + if(ebsdlib::math::closeEnough(t, static_cast(0.0), thr)) // Are we close to Zero { - res = {0.0, 0.0, Rotations::Constants::epsijk, 0.0}; + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; } else { @@ -875,7 +827,7 @@ OutputType eu2ro(const InputType& e) * @note verified 8/5/13 * * @param e 3 Euler angles in radians - * @param Quaternion can be of form Scalar or Scalar in memory. The + * @param Quat can be of form Scalar or Scalar in memory. The * default is (Scalar, ) * * @date 8/04/13 MDG 1.0 original @@ -883,7 +835,7 @@ OutputType eu2ro(const InputType& e) */ template -OutputType eu2qu(const InputType& e, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType eu2qu(const InputType& e, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType res(4); using SizeType = typename OutputType::size_type; @@ -891,7 +843,7 @@ OutputType eu2qu(const InputType& e, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -918,9 +870,9 @@ OutputType eu2qu(const InputType& e, typename Quaternion(std::fabs(o[8]), static_cast(1.0), static_cast(1.0E-6)); + bool close = ebsdlib::math::closeEnough(std::fabs(o[8]), static_cast(1.0), static_cast(1.0E-6)); if(!close) { res[1] = acos(o[8]); @@ -962,7 +914,7 @@ OutputType om2eu(const InputType& o) } else { - close = EbsdLibMath::closeEnough(o[8], static_cast(1.0), static_cast(1.0E-6)); + close = ebsdlib::math::closeEnough(o[8], static_cast(1.0), static_cast(1.0E-6)); if(close) { res[0] = atan2(o[1], o[0]); @@ -972,7 +924,7 @@ OutputType om2eu(const InputType& o) else { res[0] = static_cast(-atan2(-o[1], o[0])); - res[1] = static_cast(EbsdLib::Constants::k_PiD); + res[1] = static_cast(ebsdlib::constants::k_PiD); res[2] = 0.0; } } @@ -1030,7 +982,7 @@ OutputType ax2om(const InputType& a) int _02 = 2; int _20 = 6; // Check to see if we need to transpose - if(Rotations::Constants::epsijk == 1.0L) + if(ebsdlib::orientations::epsijk == 1.0L) { _01 = 3; _10 = 1; @@ -1057,7 +1009,7 @@ OutputType ax2om(const InputType& a) * * @author Marc De Graef, Carnegie Mellon University * - * @brief Quaternion to Euler angles [Morawiec page 40, with errata !!!! ] + * @brief Quat to Euler angles [Morawiec page 40, with errata !!!! ] * * @param q quaternion * @@ -1065,7 +1017,7 @@ OutputType ax2om(const InputType& a) * @date 8/04/13 MDG 1.0 original */ template -OutputType qu2eu(const InputType& q, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2eu(const InputType& q, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType res(3); @@ -1087,7 +1039,7 @@ OutputType qu2eu(const InputType& q, typename Quaternion(EbsdLib::Constants::k_PiD); + Phi = static_cast(ebsdlib::constants::k_PiD); phi2 = 0.0; // arbitrarily due to degeneracy phi1 = static_cast(atan2(2.0 * qq.x() * qq.y(), qq.x() * qq.x() - qq.y() * qq.y())); } } else { - if(RConst::epsijk == 1.0) + if(ebsdlib::orientations::epsijk == 1.0) { Phi = static_cast(atan2(2.0 * chi, q03 - q12)); chi = static_cast(1.0 / chi); @@ -1219,10 +1171,10 @@ OutputType ho2ax(const InputType& h) res[0] = hn[0]; res[1] = hn[1]; res[2] = hn[2]; - OutputValueType delta = static_cast(std::fabs(s - EbsdLib::Constants::k_PiD)); + OutputValueType delta = static_cast(std::fabs(s - ebsdlib::constants::k_PiD)); if(delta < thr) { - res[3] = static_cast(EbsdLib::Constants::k_PiD); + res[3] = static_cast(ebsdlib::constants::k_PiD); } else { @@ -1245,7 +1197,7 @@ OutputType ho2ax(const InputType& h) * @date 8/18/14 MDG 2.0 new version */ template -OutputType om2qu(const InputType& om, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType om2qu(const InputType& om, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType res(4); using SizeType = typename OutputType::size_type; @@ -1253,7 +1205,7 @@ OutputType om2qu(const InputType& om, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1272,25 +1224,25 @@ OutputType om2qu(const InputType& om, typename Quaternion(om[0] + om[4] + om[8] + 1.0); - if(EbsdLibMath::closeEnough(std::fabs(s), static_cast(0.0), thr)) // Are we close to Zero + if(ebsdlib::math::closeEnough(std::fabs(s), static_cast(0.0), thr)) // Are we close to Zero { s = 0.0; } s = sqrt(s); s1 = static_cast(om[0] - om[4] - om[8] + 1.0); - if(EbsdLibMath::closeEnough(std::fabs(s1), static_cast(0.0), thr)) // Are we close to Zero + if(ebsdlib::math::closeEnough(std::fabs(s1), static_cast(0.0), thr)) // Are we close to Zero { s1 = 0.0; } s1 = sqrt(s1); s2 = static_cast(-om[0] + om[4] - om[8] + 1.0); - if(EbsdLibMath::closeEnough(std::fabs(s2), static_cast(0.0), thr)) // Are we close to Zero + if(ebsdlib::math::closeEnough(std::fabs(s2), static_cast(0.0), thr)) // Are we close to Zero { s2 = 0.0; } s2 = sqrt(s2); s3 = static_cast(-om[0] - om[4] + om[8] + 1.0); - if(EbsdLibMath::closeEnough(std::fabs(s3), static_cast(0.0), thr)) // Are we close to Zero + if(ebsdlib::math::closeEnough(std::fabs(s3), static_cast(0.0), thr)) // Are we close to Zero { s3 = 0.0; } @@ -1304,23 +1256,23 @@ OutputType om2qu(const InputType& om, typename Quaternion(&(res[0]), s); + ebsdlib::EbsdMatrixMath::Divide4x1withConstant(&(res[0]), s); } /* we need to do a quick test here to make sure that the @@ -1364,7 +1316,7 @@ OutputType om2qu(const InputType& om, typename Quaternion -OutputType qu2ax(const InputType& q, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2ax(const InputType& q, typename Quat::Order layout = Quat::Order::VectorScalar) { using OutputValueType = typename OutputType::value_type; OutputType res(4); @@ -1373,7 +1325,7 @@ OutputType qu2ax(const InputType& q, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1381,7 +1333,7 @@ OutputType qu2ax(const InputType& q, typename Quaternion= 0.0 typename OutputType::value_type sign = 1.0; @@ -1430,7 +1382,7 @@ OutputType qu2ax(const InputType& q, typename Quaternion(ta, static_cast(0.0L), threshold)) + if(ebsdlib::math::closeEnough(ta, static_cast(0.0L), threshold)) { - res = {0.0, 0.0, Rotations::Constants::epsijk, 0.0}; + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; return res; } @@ -1526,15 +1478,15 @@ OutputType ax2ro(const InputType& ax) using OutputValueType = typename OutputType::value_type; OutputValueType threshold = 1.0E-7f; - if(EbsdLibMath::closeEnough(ax[3], static_cast(0.0L), threshold)) + if(ebsdlib::math::closeEnough(ax[3], static_cast(0.0L), threshold)) { - res = {0.0, 0.0, Rotations::Constants::epsijk, 0.0}; + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; return res; } res[0] = ax[0]; res[1] = ax[1]; res[2] = ax[2]; - if(fabs(ax[3] - EbsdLib::Constants::k_PiD) < threshold) + if(fabs(ax[3] - ebsdlib::constants::k_PiD) < threshold) { res[3] = std::numeric_limits::infinity(); } @@ -1558,7 +1510,7 @@ OutputType ax2ro(const InputType& ax) * @date 7/23/14 MDG 1.1 explicit transformation */ template -OutputType ax2qu(const InputType& r, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType ax2qu(const InputType& r, typename Quat::Order layout = Quat::Order::VectorScalar) { using OutputValueType = typename OutputType::value_type; OutputType res(4); @@ -1567,7 +1519,7 @@ OutputType ax2qu(const InputType& r, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1622,7 +1574,7 @@ OutputType ro2ho(const InputType& r) } if(r[3] == std::numeric_limits::infinity()) { - f = static_cast(0.75 * EbsdLib::Constants::k_PiD); + f = static_cast(0.75 * ebsdlib::constants::k_PiD); } else { @@ -1650,7 +1602,7 @@ OutputType ro2ho(const InputType& r) * @date 6/03/13 MDG 1.0 original */ template -OutputType qu2om(const InputType& r, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2om(const InputType& r, typename Quat::Order layout = Quat::Order::VectorScalar) { using OutputValueType = typename OutputType::value_type; OutputType res(9); @@ -1659,7 +1611,7 @@ OutputType qu2om(const InputType& r, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1676,7 +1628,7 @@ OutputType qu2om(const InputType& r, typename Quaternion(2.0 * (r[y] * r[x] + r[w] * r[z])); res[7] = static_cast(2.0 * (r[z] * r[y] + r[w] * r[x])); res[2] = static_cast(2.0 * (r[x] * r[z] + r[w] * r[y])); - if(Rotations::Constants::epsijk != 1.0) + if(ebsdlib::orientations::epsijk != 1.0) { using value_type = typename OutputType::value_type; using RotationMatrixType = Eigen::Matrix; @@ -1701,7 +1653,7 @@ OutputType qu2om(const InputType& r, typename Quaternion -OutputType qu2ro(const InputType& q, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2ro(const InputType& q, typename Quat::Order layout = Quat::Order::VectorScalar) { using ValueType = typename OutputType::value_type; OutputType res(4); @@ -1710,7 +1662,7 @@ OutputType qu2ro(const InputType& q, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1728,12 +1680,12 @@ OutputType qu2ro(const InputType& q, typename Quaternion::infinity(); return res; } - // ValueType s = EbsdMatrixMath::Magnitude3x1(&(res[0])); + // ValueType s = ebsdlib::EbsdMatrixMath::Magnitude3x1(&(res[0])); ValueType s = ArrayHelpers::sqrtSumOfSquares(res); if(s < thr) { - res = {0.0, 0.0, Rotations::Constants::epsijk, 0.0}; + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; return res; } @@ -1757,7 +1709,7 @@ OutputType qu2ro(const InputType& q, typename Quaternion -OutputType qu2ho(const InputType& q, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2ho(const InputType& q, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType res(3); using value_type = typename OutputType::value_type; @@ -1768,7 +1720,7 @@ OutputType qu2ho(const InputType& q, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -1961,7 +1913,7 @@ OutputType ax2eu(const InputType& ax) * @date 8/12/13 MDG 1.0 original */ template -OutputType ro2qu(const InputType& ro, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType ro2qu(const InputType& ro, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType ax = ro2ax(ro); return ax2qu(ax, layout); @@ -2033,7 +1985,7 @@ OutputType ho2ro(const InputType& ho) * @date 8/12/13 MDG 1.0 original */ template -OutputType ho2qu(const InputType& ho, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType ho2qu(const InputType& ho, typename Quat::Order layout = Quat::Order::VectorScalar) { InputType ax = ho2ax(ho); return ax2qu(ax, layout); @@ -2129,7 +2081,7 @@ OutputType ro2cu(const InputType& ro) * @date 8/12/13 MDG 1.0 original */ template -OutputType qu2cu(const InputType& qu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2cu(const InputType& qu, typename Quat::Order layout = Quat::Order::VectorScalar) { OutputType ho = qu2ho(qu, layout); return ho2cu(ho); @@ -2229,17 +2181,17 @@ OutputType cu2ro(const InputType& cu) */ template -OutputType cu2qu(const InputType& cu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType cu2qu(const InputType& cu, typename Quat::Order layout = Quat::Order::VectorScalar) { InputType ho = cu2ho(cu); // Convert the Cuborchoric to Homochoric - return ho2qu(ho); // Convert Homochoric to Quaternion + return ho2qu(ho); // Convert Homochoric to Quat } /*********************************************************************************************************************** * Stereographic Coordinates Section **********************************************************************************************************************/ template -OutputType qu2st(const InputType& qu, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType qu2st(const InputType& qu, typename Quat::Order layout = Quat::Order::VectorScalar) { using SizeType = typename OutputType::size_type; @@ -2247,7 +2199,7 @@ OutputType qu2st(const InputType& qu, typename Quaternion::Order::VectorScalar) + if(layout == Quat::Order::VectorScalar) { w = 3; x = 0; @@ -2269,7 +2221,7 @@ OutputType qu2st(const InputType& qu, typename Quaternion OutputType eu2st(const InputType& eu) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = eu2qu(eu); return qu2st(qu); } @@ -2277,7 +2229,7 @@ OutputType eu2st(const InputType& eu) template OutputType om2st(const InputType& om) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = om2qu(om); return qu2st(qu); } @@ -2285,7 +2237,7 @@ OutputType om2st(const InputType& om) template OutputType ax2st(const InputType& aa) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = ax2qu(aa); return qu2st(qu); } @@ -2293,7 +2245,7 @@ OutputType ax2st(const InputType& aa) template OutputType ro2st(const InputType& ro) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = ro2qu(ro); return qu2st(qu); } @@ -2301,7 +2253,7 @@ OutputType ro2st(const InputType& ro) template OutputType ho2st(const InputType& ho) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = ho2qu(ho); return qu2st(qu); } @@ -2309,7 +2261,7 @@ OutputType ho2st(const InputType& ho) template OutputType cu2st(const InputType& cu) { - using QuatType = Quaternion; + using QuatType = Quat; QuatType qu = cu2qu(cu); return qu2st(qu); } @@ -2326,10 +2278,9 @@ OutputType st2ax(const InputType& st) { InputType tmp = st; ArrayHelpers::scalarDivide(tmp, l); - OutputType ax(4); - if(EbsdLibMath::closeEnough(l, static_cast(1.0L), threshold)) + if(ebsdlib::math::closeEnough(l, static_cast(1.0L), threshold)) { - res = {tmp[0], tmp[1], tmp[2], static_cast(EbsdLib::Constants::k_PiD)}; + res = {tmp[0], tmp[1], tmp[2], static_cast(ebsdlib::constants::k_PiD)}; } else { @@ -2347,10 +2298,10 @@ OutputType st2eu(const InputType& st) } template -OutputType st2qu(const InputType& st, typename Quaternion::Order layout = Quaternion::Order::VectorScalar) +OutputType st2qu(const InputType& st, typename Quat::Order layout = Quat::Order::VectorScalar) { InputType ax = st2ax(st); // Convert to Axis-Angle - return ax2qu(ax, layout); // Convert to Quaternion + return ax2qu(ax, layout); // Convert to Quat } template @@ -2366,9 +2317,9 @@ OutputType st2om(const InputType& st) InputType tmp = st; ArrayHelpers::scalarDivide(tmp, l); InputType ax(4); - if(EbsdLibMath::closeEnough(l, static_cast(1.0L), threshold)) + if(ebsdlib::math::closeEnough(l, static_cast(1.0L), threshold)) { - ax = {tmp[0], tmp[1], tmp[2], static_cast(EbsdLib::Constants::k_PiD)}; + ax = {tmp[0], tmp[1], tmp[2], static_cast(ebsdlib::constants::k_PiD)}; } else { @@ -2392,7 +2343,7 @@ OutputType st2ro(const InputType& st) InputType tmp = st; ArrayHelpers::scalarDivide(tmp, l); - if(EbsdLibMath::closeEnough(l, static_cast(1.0L), threshold)) + if(ebsdlib::math::closeEnough(l, static_cast(1.0L), threshold)) { res = {tmp[0], tmp[1], tmp[2], static_cast(std::numeric_limits::infinity())}; } diff --git a/Source/EbsdLib/Core/Quaternion.hpp b/Source/EbsdLib/Core/Quaternion.hpp deleted file mode 100644 index 1773585b..00000000 --- a/Source/EbsdLib/Core/Quaternion.hpp +++ /dev/null @@ -1,602 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2020-2025 BlueQuartz Software, LLC - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its - * contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The code contained herein was partially funded by the following contracts: - * United States Air Force Prime Contract FA8650-15-D-5231 - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#pragma once - -#include "EbsdLib/Math/EbsdMatrixMath.h" - -#include -#include -#include -#include - -namespace EbsdLib -{ -template -class Quaternion -{ -public: - using EnumType = uint32_t; - - static_assert(std::is_floating_point_v, "T must be a floating point type"); // disallow integers - static_assert(std::numeric_limits::has_infinity, "T must have infinity"); // must have ieee infinity - - enum class Order : EnumType - { - ScalarVector = 0, - VectorScalar = 1 - }; - - using size_type = size_t; - using value_type = T; - - Quaternion() = default; - ~Quaternion() = default; - - Quaternion(const Quaternion&) = default; - Quaternion(Quaternion&&) noexcept = default; - Quaternion& operator=(const Quaternion&) = default; - Quaternion& operator=(Quaternion&&) noexcept = default; - - /** - * @brief Creates a Quaternion that is an "Identity" - * @param size This MUST be 4 (this is for historical reasons) - */ - Quaternion(size_type size) - { - if(size != 4) - { - throw std::runtime_error("Quaternion Constructor needs argument of '4' for size."); - } - } - - Quaternion(T x, T y, T z, T w) - : m_X(x) - , m_Y(y) - , m_Z(z) - , m_W(w) - { - } - - // Quaternion(const T* q, Order o = Order::VectorScalar) - // { - // if(o == Order::VectorScalar) - // { - // m_X = q[0]; - // m_Y = q[1]; - // m_Z = q[2]; - // m_W = q[3]; - // } - // else - // { - // m_W = q[0]; - // m_X = q[1]; - // m_Y = q[2]; - // m_Z = q[3]; - // } - // } - - /** - * @brief Converts this quaternion to a Quaternion that uses a different primitve type such as float or double. - */ - template && std::numeric_limits::has_infinity>> - Quaternion to() const - { - return {static_cast(m_X), static_cast(m_Y), static_cast(m_Z), static_cast(m_W)}; - } - - T& x() - { - return m_X; - } - - const T& x() const - { - return m_X; - } - - T& y() - { - return m_Y; - } - - const T& y() const - { - return m_Y; - } - - T& z() - { - return m_Z; - } - - const T& z() const - { - return m_Z; - } - - T& w() - { - return m_W; - } - - const T& w() const - { - return m_W; - } - - /** - * @brief copyInto - * @param target - * @param order - */ - void copyInto(T* target, Order order) const - { - if(order == Order::VectorScalar) - { - target[0] = m_X; - target[1] = m_Y; - target[2] = m_Z; - target[3] = m_W; - } - else - { - target[0] = m_W; - target[1] = m_X; - target[2] = m_Y; - target[3] = m_Z; - } - } - - /** - * @brief Assumes XYZW data layout - * @param index - * @return - */ - T& operator[](size_type index) - { - switch(index) - { - case 0: - return m_X; - case 1: - return m_Y; - case 2: - return m_Z; - case 3: - return m_W; - default: - throw std::out_of_range("Index is out of range for the Quaternions."); - } - } - - /** - * @brief Assumes XYZW data layout - * @param index - * @return - */ - const T& operator[](size_type index) const - { - switch(index) - { - case 0: - return m_X; - case 1: - return m_Y; - case 2: - return m_Z; - case 3: - return m_W; - default: - throw std::out_of_range("Index is out of range for the Quaternions."); - } - } - - /** - * @brief Identity Sets the quaternion q to the identity quaternion (<0,0,0>,1) - * @param q - */ - static Quaternion identity() - { - return {0.0, 0.0, 0.0, 1.0}; - } - - /** - * @brief ElementWiseAbs inline assigns the absolute value of each element to itself (in place) - */ - Quaternion& elementWiseAbs() - { - m_X = std::fabs(m_X); - m_Y = std::fabs(m_Y); - m_Z = std::fabs(m_Z); - m_W = std::fabs(m_W); - return *this; - } - - /** - * @brief ScalarMultiply Multiplies each element in the quaternion by the argument v (in place) - * @param v - */ - Quaternion& scalarMultiply(T v) - { - m_X *= v; - m_Y *= v; - m_Z *= v; - m_W *= v; - return *this; - } - - /** - * @brief ScalarDivide Divides each element in the quaternion by the argument v (in place) - * @param v - */ - Quaternion& scalarDivide(T v) - { - m_X /= v; - m_Y /= v; - m_Z /= v; - m_W /= v; - return *this; - } - - /** - * @brief ScalarAdd Adds value to each element of the vector and scalar part of the Quaternion (in place) - * @param v Input Quat to add elements - */ - Quaternion& scalarAdd(T v) - { - m_X += v; - m_Y += v; - m_Z += v; - m_W += v; - return *this; - } - - /** - * @brief ElementWiseAssign Assigns each element the quaternion (in place) - * @param v Input Quat to add elements - */ - Quaternion& elementWiseAssign(T v) - { - m_X = v; - m_Y = v; - m_Z = v; - m_W = v; - return *this; - } - - /** - * @brief Negate −q = (−a, −v) In Place operation (in place) - */ - Quaternion& negate() - { - m_X = -m_X; - m_Y = -m_Y; - m_Z = -m_Z; - m_W = -m_W; - return *this; - } - - Quaternion operator-() const - { - return {-m_X, -m_Y, -m_Z, -m_W}; - } - - /** - * @brief Add q1 + q2 = (w1+w2, v1+v2) - * @param rhs - * @return out - */ - Quaternion operator+(const Quaternion& rhs) const - { - Quaternion out; - out.x() = rhs.x() + m_X; - out.y() = rhs.y() + m_Y; - out.z() = rhs.z() + m_Z; - out.w() = rhs.w() + m_W; - return out; - } - - /** - * @brief Add q1 - q2 = (w1-w2, v1-v2) - * @param rhs - * @return out - */ - Quaternion operator-(const Quaternion& rhs) const - { - Quaternion out; - out.x() = m_X - rhs.x(); - out.y() = m_Y - rhs.y(); - out.z() = m_Z - rhs.z(); - out.w() = m_W - rhs.w(); - return out; - } - - /** - * @brief Multiply current quaternion by another quaternion returning a third quaternion according to quaternion - * multiplication. Note that Quaternioin multiplication is NOT cummunitive i.e., A * B != B * A - * @param rhs Input Quaternion - * @return - */ - Quaternion operator*(const Quaternion& rhs) const - { - Quaternion out; - out.x() = rhs.x() * m_W + rhs.w() * m_X + rhs.z() * m_Y - rhs.y() * m_Z; - out.y() = rhs.y() * m_W + rhs.w() * m_Y + rhs.x() * m_Z - rhs.z() * m_X; - out.z() = rhs.z() * m_W + rhs.w() * m_Z + rhs.y() * m_X - rhs.x() * m_Y; - /* Verified */ - out.w() = rhs.w() * m_W - rhs.x() * m_X - rhs.y() * m_Y - rhs.z() * m_Z; - return out; - } - - /** - * @brief Add q1 + q2 = (w1+w2, v1+v2) (in place) - * @param rhs - * @return self - */ - Quaternion& operator+=(const Quaternion& rhs) - { - x() += rhs.x(); - y() += rhs.y(); - z() += rhs.z(); - w() += rhs.w(); - return *this; - } - - /** - * @brief Add q1 - q2 = (w1-w2, v1-v2) (in place) - * @param rhs - * @return self - */ - Quaternion& operator-=(const Quaternion& rhs) - { - x() -= rhs.x(); - y() -= rhs.y(); - z() -= rhs.z(); - w() -= rhs.w(); - return *this; - } - - /** - * @brief Multiply current quaternion by another quaternion (in place) - * multiplication. Note that Quaternion multiplication is NOT communicative i.e., A * B != B * A - * @param rhs Input Quaternion - * @return self - */ - Quaternion& operator*=(const Quaternion& rhs) - { - x() = rhs.x() * m_W + rhs.w() * m_X + rhs.z() * m_Y - rhs.y() * m_Z; - y() = rhs.y() * m_W + rhs.w() * m_Y + rhs.x() * m_Z - rhs.z() * m_X; - z() = rhs.z() * m_W + rhs.w() * m_Z + rhs.y() * m_X - rhs.x() * m_Y; - /* Verified */ - w() = rhs.w() * m_W - rhs.x() * m_X - rhs.y() * m_Y - rhs.z() * m_Z; - return *this; - } - - /** - * @brief Computes the dot product between the current quaternion and an input quaternion - * @param rhs Second quaternion to use to compute the dot product - * @return scalar dot product - */ - T dotProduct(const Quaternion& rhs) const - { - T dot = m_X * rhs.x() + m_Y * rhs.y() + m_Z * rhs.z() + m_W * rhs.w(); - // Clamp dot to [-1, 1] to avoid domain errors in acos() - return std::clamp(dot, -1.0, 1.0); - } - - /** - * @brief Conjugate Converts quaternion q into its conjugate - * @return new quaternion that is the conjugate of the current quaternion - */ - Quaternion conjugate() const - { - return {-m_X, -m_Y, -m_Z, m_W}; - } - - /** - * @brief Norm Computes and returns the "norm" of the quaternion (x^2 + y^2 + z^2 + w^2) - * @return - */ - T norm() const - { - return m_X * m_X + m_Y * m_Y + m_Z * m_Z + m_W * m_W; - } - - /** - * @brief Length Computes are returns the "length" of the quaternion which is the square root of the norm. SQRT (x^2 + y^2 + z^2 + w^2) - * @return - */ - T length() const - { - return std::sqrt(norm()); - } - - /** - * @brief Computes the inverse of the Quaternion - * @return - */ - Quaternion inverse() const - { - double normSq = this->norm(); // Use your existing Norm() - if(normSq == 0.0) - { - throw std::runtime_error("Cannot invert a quaternion with zero norm."); - } - Quaternion conj = this->conjugate(); - return Quaternion(conj.x() / normSq, conj.y() / normSq, conj.z() / normSq, conj.w() / normSq); - } - - /** - * @brief check if this is a unit quaternion - * @param tolerance - * @return - */ - bool IsUnit(double tolerance = 1e-6) const - { - return std::abs(this->norm() - 1.0) < tolerance; - } - - /** - * @brief Normalize: Converts the quaternion into its normalized values (x/L, y/L, z/L, w/L) where "L" - * is the "length" of the quaternion - * @return qr - */ - Quaternion normalize() const - { - T l = length(); - return {m_X / l, m_Y / l, m_Z / l, m_W / l}; - } - - /** - * @brief GetMisorientationVector Converts the quaternion into a misorientation vector in the reference frame of the quaternion - * @return misoVec - */ - std::array getMisorientationVector() const - { - std::array misoVec; - - T qw = std::clamp(m_W, static_cast(-1.0), static_cast(1.0)); - T constVal = 0.0; - if(qw == 1.0 || qw == -1.0) - { - constVal = 0.0; - } - else - { - constVal = static_cast(2 * std::acos(qw) / (std::sqrt(1.0 - (qw * qw)))); - } - - misoVec[0] = m_X * constVal; - misoVec[1] = m_Y * constVal; - misoVec[2] = m_Z * constVal; - return misoVec; - } - - /** - * @brief MultiplyQuatVec Rotates a 3d vector 'v' by the quaternion 'q' - * @param v Input Vector - * SIMPLView uses - * PASSIVE rotations by default. - */ - std::array multiplyByVector(const T* v) const - { - T qx2 = m_X * m_X; - T qy2 = m_Y * m_Y; - T qz2 = m_Z * m_Z; - T qw2 = m_W * m_W; - - T qxy = m_X * m_Y; - T qyz = m_Y * m_Z; - T qzx = m_Z * m_X; - - T qxw = m_X * m_W; - T qyw = m_Y * m_W; - T qzw = m_Z * m_W; - - std::array out; - - out[0] = v[0] * (qx2 - qy2 - qz2 + qw2) + 2 * (v[1] * (qxy + qzw) + v[2] * (qzx - qyw)); - out[1] = v[1] * (qy2 - qx2 - qz2 + qw2) + 2 * (v[2] * (qyz + qxw) + v[0] * (qxy - qzw)); - out[2] = v[2] * (qz2 - qx2 - qy2 + qw2) + 2 * (v[0] * (qzx + qyw) + v[1] * (qyz - qxw)); - return out; - } - - /** - * @brief rotateVector ACTIVELY rotates input vector by this quaternion. - * @param inputVector Input vector - * @param p argument: Passive = 1, Active = -1; Default is Passive - * @return Output Vector - */ - std::array rotateVector(const T* inputVector, int32_t p = 1) const - { - std::array rotatedVector = {0.0, 0.0, 0.0}; - T epsijk = static_cast(p); - - std::array r = {epsijk * m_X, epsijk * m_Y, epsijk * m_Z}; - std::array temp = {0.0, 0.0, 0.0}; - EbsdMatrixMath::CrossProduct(r.data(), inputVector, temp.data()); - - temp[0] += m_W * inputVector[0]; - temp[1] += m_W * inputVector[1]; - temp[2] += m_W * inputVector[2]; - - std::array temp2; - EbsdMatrixMath::CrossProduct(r.data(), temp.data(), temp2.data()); - - rotatedVector[0] = static_cast(2.0) * temp2[0] + inputVector[0]; - rotatedVector[1] = static_cast(2.0) * temp2[1] + inputVector[1]; - rotatedVector[2] = static_cast(2.0) * temp2[2] + inputVector[2]; - - return rotatedVector; - } - - /** - * @brief Ensures this quaternion represents an orientation that is located in the northern hemisphere. - * - * NOTE: This is done IN PLACE!! - */ - void positiveOrientation() - { - if(m_W < static_cast(0.0)) - { - m_X = -m_X; - m_Y = -m_Y; - m_Z = -m_Z; - m_W = -m_W; - } - } - - /** - * @brief Returns a new quaternion that represents an orientation that is located in the northern hemisphere - * @return Copy of Quaternion - */ - Quaternion getPositiveOrientation() const - { - if(m_W < static_cast(0.0)) - { - return {-m_X, -m_Y, -m_Z, -m_W}; - } - return {m_X, m_Y, m_Z, m_W}; - } - -private: - T m_X = 0.0; - T m_Y = 0.0; - T m_Z = 0.0; - T m_W = 1.0; -}; -} // namespace EbsdLib - -using QuatD = EbsdLib::Quaternion; -using QuatF = EbsdLib::Quaternion; diff --git a/Source/EbsdLib/Core/SourceList.cmake b/Source/EbsdLib/Core/SourceList.cmake index dfcf2c7e..50b1d4bc 100644 --- a/Source/EbsdLib/Core/SourceList.cmake +++ b/Source/EbsdLib/Core/SourceList.cmake @@ -9,10 +9,8 @@ set(EbsdLib_${DIR_NAME}_HDRS ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/EbsdTransform.h ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Orientation.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationMath.h - ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationRepresentation.hpp ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationTransformation.hpp - ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Quaternion.hpp - ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/EbsdStringLiteral.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/EbsdStringLiteral.hpp ) set(EbsdLib_${DIR_NAME}_SRCS diff --git a/Source/EbsdLib/IO/AngleFileLoader.cpp b/Source/EbsdLib/IO/AngleFileLoader.cpp index 250f214e..866987ea 100644 --- a/Source/EbsdLib/IO/AngleFileLoader.cpp +++ b/Source/EbsdLib/IO/AngleFileLoader.cpp @@ -41,12 +41,17 @@ #include #include -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/AxisAngle.hpp" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/OrientationMatrix.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -66,9 +71,9 @@ AngleFileLoader::~AngleFileLoader() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() +ebsdlib::FloatArrayType::Pointer AngleFileLoader::loadData() { - EbsdLib::FloatArrayType::Pointer angles = EbsdLib::FloatArrayType::NullPointer(); + ebsdlib::FloatArrayType::Pointer angles = ebsdlib::FloatArrayType::NullPointer(); // Make sure the input file variable is not empty if(m_InputFile.empty()) @@ -144,7 +149,7 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() // Allocate enough for the angles std::vector dims(1, 5); - angles = EbsdLib::FloatArrayType::CreateArray(numOrients, dims, "EulerAngles_From_File", true); + angles = ebsdlib::FloatArrayType::CreateArray(numOrients, dims, "EulerAngles_From_File", true); for(int i = 0; i < numOrients; i++) { @@ -170,7 +175,7 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() } tokens = EbsdStringUtils::split(buf, (*(getDelimiter().c_str()))); - EbsdLib::EulerDType euler(3); + ebsdlib::EulerDType euler; if(m_AngleRepresentation == EulerAngles) { euler[0] = std::stof(tokens[0]); @@ -182,13 +187,14 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() else if(m_AngleRepresentation == QuaternionAngles) { euler = - EbsdLib::QuaternionDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2]), std::stof(tokens[3])).toEuler(); // OrientationTransformation::qu2eu(quat); + ebsdlib::QuaternionDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2]), std::stof(tokens[3])).toEuler(); // OrientationTransformation::qu2eu(quat); weight = std::stof(tokens[4]); sigma = std::stof(tokens[5]); } else if(m_AngleRepresentation == RodriguezAngles) { - euler = EbsdLib::RodriguesDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2])).toEuler(); // OrientationTransformation::ro2eu(rod); + euler = ebsdlib::RodriguesDType(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2]), std::stof(tokens[3])) + .toEuler(); // OrientationTransformation::ro2eu(rod); weight = std::stof(tokens[3]); sigma = std::stof(tokens[4]); } @@ -196,16 +202,16 @@ EbsdLib::FloatArrayType::Pointer AngleFileLoader::loadData() // Values in File are in Radians and the user wants them in Degrees if(!m_FileAnglesInDegrees && m_OutputAnglesInDegrees) { - euler[0] = euler[0] * EbsdLib::Constants::k_RadToDegF; - euler[1] = euler[1] * EbsdLib::Constants::k_RadToDegF; - euler[2] = euler[2] * EbsdLib::Constants::k_RadToDegF; + euler[0] = euler[0] * ebsdlib::constants::k_RadToDegF; + euler[1] = euler[1] * ebsdlib::constants::k_RadToDegF; + euler[2] = euler[2] * ebsdlib::constants::k_RadToDegF; } // Values are in Degrees but user wants them in Radians else if(m_FileAnglesInDegrees && !m_OutputAnglesInDegrees) { - euler[0] = euler[0] * EbsdLib::Constants::k_DegToRadF; - euler[1] = euler[1] * EbsdLib::Constants::k_DegToRadF; - euler[2] = euler[2] * EbsdLib::Constants::k_DegToRadF; + euler[0] = euler[0] * ebsdlib::constants::k_DegToRadF; + euler[1] = euler[1] * ebsdlib::constants::k_DegToRadF; + euler[2] = euler[2] * ebsdlib::constants::k_DegToRadF; } // Store the values into our array diff --git a/Source/EbsdLib/IO/AngleFileLoader.h b/Source/EbsdLib/IO/AngleFileLoader.h index 8b16f480..1fe5fbcd 100644 --- a/Source/EbsdLib/IO/AngleFileLoader.h +++ b/Source/EbsdLib/IO/AngleFileLoader.h @@ -41,7 +41,8 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" - +namespace ebsdlib +{ /** * @brief The AngleFileLoader class * @class @@ -166,7 +167,7 @@ class EbsdLib_EXPORT AngleFileLoader */ bool getIgnoreMultipleDelimiters() const; - EbsdLib::FloatArrayType::Pointer loadData(); + ebsdlib::FloatArrayType::Pointer loadData(); protected: AngleFileLoader(); @@ -187,3 +188,4 @@ class EbsdLib_EXPORT AngleFileLoader std::string m_Delimiter = {}; bool m_IgnoreMultipleDelimiters = {}; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/BrukerNano/EspritConstants.h b/Source/EbsdLib/IO/BrukerNano/EspritConstants.h index f37cf0ac..a468e493 100644 --- a/Source/EbsdLib/IO/BrukerNano/EspritConstants.h +++ b/Source/EbsdLib/IO/BrukerNano/EspritConstants.h @@ -33,7 +33,7 @@ #include -namespace EbsdLib +namespace ebsdlib { namespace Esprit { @@ -143,4 +143,4 @@ const std::string SEM_YResolution("SEM YResolution"); const std::string SEM_ZOffset("SEM ZOffset"); } // namespace H5Esprit -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/BrukerNano/EspritPhase.cpp b/Source/EbsdLib/IO/BrukerNano/EspritPhase.cpp index 87ebcd9d..39cb2545 100644 --- a/Source/EbsdLib/IO/BrukerNano/EspritPhase.cpp +++ b/Source/EbsdLib/IO/BrukerNano/EspritPhase.cpp @@ -34,6 +34,8 @@ #include +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -64,56 +66,56 @@ unsigned int EspritPhase::determineOrientationOpsIndex() if(sg >= 1 && sg <= 2) { - return EbsdLib::CrystalStructure::Triclinic; + return ebsdlib::CrystalStructure::Triclinic; } if(sg >= 3 && sg <= 15) { - return EbsdLib::CrystalStructure::Monoclinic; + return ebsdlib::CrystalStructure::Monoclinic; } if(sg >= 16 && sg <= 74) { - return EbsdLib::CrystalStructure::OrthoRhombic; + return ebsdlib::CrystalStructure::OrthoRhombic; } if(sg >= 75 && sg <= 89) { - return EbsdLib::CrystalStructure::Tetragonal_Low; + return ebsdlib::CrystalStructure::Tetragonal_Low; } if(sg >= 90 && sg <= 142) { - return EbsdLib::CrystalStructure::Tetragonal_High; + return ebsdlib::CrystalStructure::Tetragonal_High; } if(sg >= 143 && sg <= 148) { - return EbsdLib::CrystalStructure::Trigonal_Low; + return ebsdlib::CrystalStructure::Trigonal_Low; } if(sg >= 149 && sg <= 167) { - return EbsdLib::CrystalStructure::Trigonal_High; + return ebsdlib::CrystalStructure::Trigonal_High; } if(sg >= 168 && sg <= 176) { - return EbsdLib::CrystalStructure::Hexagonal_Low; + return ebsdlib::CrystalStructure::Hexagonal_Low; } if(sg >= 177 && sg <= 194) { - return EbsdLib::CrystalStructure::Hexagonal_High; + return ebsdlib::CrystalStructure::Hexagonal_High; } if(sg >= 195 && sg <= 206) { - return EbsdLib::CrystalStructure::Cubic_Low; + return ebsdlib::CrystalStructure::Cubic_Low; } if(sg >= 207 && sg <= 230) { - return EbsdLib::CrystalStructure::Cubic_High; + return ebsdlib::CrystalStructure::Cubic_High; } - return EbsdLib::CrystalStructure::UnknownCrystalStructure; + return ebsdlib::CrystalStructure::UnknownCrystalStructure; } // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/IO/BrukerNano/EspritPhase.h b/Source/EbsdLib/IO/BrukerNano/EspritPhase.h index 29b78d12..9ff13d1c 100644 --- a/Source/EbsdLib/IO/BrukerNano/EspritPhase.h +++ b/Source/EbsdLib/IO/BrukerNano/EspritPhase.h @@ -40,7 +40,8 @@ #include "EbsdLib/Core/EbsdLibConstants.h" #include "EbsdLib/Core/EbsdSetGetMacros.h" #include "EbsdLib/EbsdLib.h" - +namespace ebsdlib +{ class EbsdLib_EXPORT EspritPhase { public: @@ -126,3 +127,4 @@ class EbsdLib_EXPORT EspritPhase EspritPhase& operator=(const EspritPhase&) = delete; // Copy Assignment Not Implemented EspritPhase& operator=(EspritPhase&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/BrukerNano/H5EspritFields.cpp b/Source/EbsdLib/IO/BrukerNano/H5EspritFields.cpp index 6fb4cd63..de37fc28 100644 --- a/Source/EbsdLib/IO/BrukerNano/H5EspritFields.cpp +++ b/Source/EbsdLib/IO/BrukerNano/H5EspritFields.cpp @@ -34,6 +34,8 @@ #include "EspritConstants.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,23 +52,23 @@ H5EspritFields::~H5EspritFields() = default; std::vector H5EspritFields::getFieldNames() { std::vector features; - // features.push_back(EbsdLib::H5Esprit::DD); - features.push_back(EbsdLib::H5Esprit::MAD); - // features.push_back(EbsdLib::H5Esprit::MADPhase); - features.push_back(EbsdLib::H5Esprit::NIndexedBands); - // features.push_back(EbsdLib::H5Esprit::PCX); - // features.push_back(EbsdLib::H5Esprit::PCY); - features.push_back(EbsdLib::H5Esprit::PHI); - features.push_back(EbsdLib::H5Esprit::Phase); - features.push_back(EbsdLib::H5Esprit::RadonBandCount); - features.push_back(EbsdLib::H5Esprit::RadonQuality); - features.push_back(EbsdLib::H5Esprit::RawPatterns); - features.push_back(EbsdLib::H5Esprit::XBEAM); - features.push_back(EbsdLib::H5Esprit::YBEAM); - // features.push_back(EbsdLib::H5Esprit::XSAMPLE); - // features.push_back(EbsdLib::H5Esprit::YSAMPLE); - features.push_back(EbsdLib::H5Esprit::phi1); - features.push_back(EbsdLib::H5Esprit::phi2); + // features.push_back(ebsdlib::H5Esprit::DD); + features.push_back(ebsdlib::H5Esprit::MAD); + // features.push_back(ebsdlib::H5Esprit::MADPhase); + features.push_back(ebsdlib::H5Esprit::NIndexedBands); + // features.push_back(ebsdlib::H5Esprit::PCX); + // features.push_back(ebsdlib::H5Esprit::PCY); + features.push_back(ebsdlib::H5Esprit::PHI); + features.push_back(ebsdlib::H5Esprit::Phase); + features.push_back(ebsdlib::H5Esprit::RadonBandCount); + features.push_back(ebsdlib::H5Esprit::RadonQuality); + features.push_back(ebsdlib::H5Esprit::RawPatterns); + features.push_back(ebsdlib::H5Esprit::XBEAM); + features.push_back(ebsdlib::H5Esprit::YBEAM); + // features.push_back(ebsdlib::H5Esprit::XSAMPLE); + // features.push_back(ebsdlib::H5Esprit::YSAMPLE); + features.push_back(ebsdlib::H5Esprit::phi1); + features.push_back(ebsdlib::H5Esprit::phi2); return features; } diff --git a/Source/EbsdLib/IO/BrukerNano/H5EspritFields.h b/Source/EbsdLib/IO/BrukerNano/H5EspritFields.h index fbe75bd9..0b5b4ec6 100644 --- a/Source/EbsdLib/IO/BrukerNano/H5EspritFields.h +++ b/Source/EbsdLib/IO/BrukerNano/H5EspritFields.h @@ -40,7 +40,8 @@ #include "EbsdLib/Core/EbsdSetGetMacros.h" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/BrukerNano/EspritConstants.h" - +namespace ebsdlib +{ /** * @class EspritFields EspritFields.h EbsdLib/IO/HKL/EspritFields.h * @brief This class simply holds the names of the columns that are present in the @@ -69,23 +70,23 @@ class EbsdLib_EXPORT H5EspritFields : public AbstractEbsdFields T getFilterFeatures() { T features; - // features.push_back(EbsdLib::H5Esprit::DD); - features.push_back(EbsdLib::H5Esprit::MAD); - // features.push_back(EbsdLib::H5Esprit::MADPhase); - features.push_back(EbsdLib::H5Esprit::NIndexedBands); - // features.push_back(EbsdLib::H5Esprit::PCX); - // features.push_back(EbsdLib::H5Esprit::PCY); - features.push_back(EbsdLib::H5Esprit::PHI); - features.push_back(EbsdLib::H5Esprit::Phase); - features.push_back(EbsdLib::H5Esprit::RadonBandCount); - features.push_back(EbsdLib::H5Esprit::RadonQuality); - features.push_back(EbsdLib::H5Esprit::RawPatterns); - features.push_back(EbsdLib::H5Esprit::XBEAM); - features.push_back(EbsdLib::H5Esprit::YBEAM); - // features.push_back(EbsdLib::H5Esprit::XSAMPLE); - // features.push_back(EbsdLib::H5Esprit::YSAMPLE); - features.push_back(EbsdLib::H5Esprit::phi1); - features.push_back(EbsdLib::H5Esprit::phi2); + // features.push_back(ebsdlib::H5Esprit::DD); + features.push_back(ebsdlib::H5Esprit::MAD); + // features.push_back(ebsdlib::H5Esprit::MADPhase); + features.push_back(ebsdlib::H5Esprit::NIndexedBands); + // features.push_back(ebsdlib::H5Esprit::PCX); + // features.push_back(ebsdlib::H5Esprit::PCY); + features.push_back(ebsdlib::H5Esprit::PHI); + features.push_back(ebsdlib::H5Esprit::Phase); + features.push_back(ebsdlib::H5Esprit::RadonBandCount); + features.push_back(ebsdlib::H5Esprit::RadonQuality); + features.push_back(ebsdlib::H5Esprit::RawPatterns); + features.push_back(ebsdlib::H5Esprit::XBEAM); + features.push_back(ebsdlib::H5Esprit::YBEAM); + // features.push_back(ebsdlib::H5Esprit::XSAMPLE); + // features.push_back(ebsdlib::H5Esprit::YSAMPLE); + features.push_back(ebsdlib::H5Esprit::phi1); + features.push_back(ebsdlib::H5Esprit::phi2); return features; } @@ -97,3 +98,4 @@ class EbsdLib_EXPORT H5EspritFields : public AbstractEbsdFields private: }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/BrukerNano/H5EspritReader.cpp b/Source/EbsdLib/IO/BrukerNano/H5EspritReader.cpp index 6dfcdbfb..77028f76 100644 --- a/Source/EbsdLib/IO/BrukerNano/H5EspritReader.cpp +++ b/Source/EbsdLib/IO/BrukerNano/H5EspritReader.cpp @@ -42,6 +42,8 @@ #include "EbsdLib/Core/EbsdMacros.h" #include "EbsdLib/IO/BrukerNano/EspritPhase.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- H5EspritReader::H5EspritReader() : m_ReadPatternData(false) @@ -49,31 +51,31 @@ H5EspritReader::H5EspritReader() { m_HeaderMap.clear(); // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::H5Esprit::CameraTilt] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::CameraTilt); - m_HeaderMap[EbsdLib::H5Esprit::KV] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::KV); - m_HeaderMap[EbsdLib::H5Esprit::MADMax] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::MADMax); - m_HeaderMap[EbsdLib::H5Esprit::Magnification] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::Magnification); - m_HeaderMap[EbsdLib::H5Esprit::MapStepFactor] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::MapStepFactor); - m_HeaderMap[EbsdLib::H5Esprit::MaxRadonBandCount] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::MaxRadonBandCount); - m_HeaderMap[EbsdLib::H5Esprit::MinIndexedBands] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::MinIndexedBands); - m_HeaderMap[EbsdLib::H5Esprit::NCOLS] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::NCOLS); - m_HeaderMap[EbsdLib::H5Esprit::NPoints] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::NPoints); - m_HeaderMap[EbsdLib::H5Esprit::NROWS] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::NROWS); - m_HeaderMap[EbsdLib::H5Esprit::PatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::PatternHeight); - m_HeaderMap[EbsdLib::H5Esprit::PatternWidth] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::PatternWidth); - m_HeaderMap[EbsdLib::H5Esprit::PixelByteCount] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::PixelByteCount); - m_HeaderMap[EbsdLib::H5Esprit::SEPixelSizeX] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::SEPixelSizeX); - m_HeaderMap[EbsdLib::H5Esprit::SEPixelSizeY] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::SEPixelSizeY); - m_HeaderMap[EbsdLib::H5Esprit::SampleTilt] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::SampleTilt); - m_HeaderMap[EbsdLib::H5Esprit::TopClip] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::TopClip); - m_HeaderMap[EbsdLib::H5Esprit::UnClippedPatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::UnClippedPatternHeight); - m_HeaderMap[EbsdLib::H5Esprit::WD] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::WD); - m_HeaderMap[EbsdLib::H5Esprit::XSTEP] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::XSTEP); - m_HeaderMap[EbsdLib::H5Esprit::YSTEP] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::YSTEP); - m_HeaderMap[EbsdLib::H5Esprit::ZOffset] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::ZOffset); - - m_HeaderMap[EbsdLib::H5Esprit::GridType] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::GridType); - m_HeaderMap[EbsdLib::H5Esprit::OriginalFile] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5Esprit::OriginalFile); + m_HeaderMap[ebsdlib::H5Esprit::CameraTilt] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::CameraTilt); + m_HeaderMap[ebsdlib::H5Esprit::KV] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::KV); + m_HeaderMap[ebsdlib::H5Esprit::MADMax] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::MADMax); + m_HeaderMap[ebsdlib::H5Esprit::Magnification] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::Magnification); + m_HeaderMap[ebsdlib::H5Esprit::MapStepFactor] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::MapStepFactor); + m_HeaderMap[ebsdlib::H5Esprit::MaxRadonBandCount] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::MaxRadonBandCount); + m_HeaderMap[ebsdlib::H5Esprit::MinIndexedBands] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::MinIndexedBands); + m_HeaderMap[ebsdlib::H5Esprit::NCOLS] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::NCOLS); + m_HeaderMap[ebsdlib::H5Esprit::NPoints] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::NPoints); + m_HeaderMap[ebsdlib::H5Esprit::NROWS] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::NROWS); + m_HeaderMap[ebsdlib::H5Esprit::PatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::PatternHeight); + m_HeaderMap[ebsdlib::H5Esprit::PatternWidth] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::PatternWidth); + m_HeaderMap[ebsdlib::H5Esprit::PixelByteCount] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::PixelByteCount); + m_HeaderMap[ebsdlib::H5Esprit::SEPixelSizeX] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::SEPixelSizeX); + m_HeaderMap[ebsdlib::H5Esprit::SEPixelSizeY] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::SEPixelSizeY); + m_HeaderMap[ebsdlib::H5Esprit::SampleTilt] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::SampleTilt); + m_HeaderMap[ebsdlib::H5Esprit::TopClip] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::TopClip); + m_HeaderMap[ebsdlib::H5Esprit::UnClippedPatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::UnClippedPatternHeight); + m_HeaderMap[ebsdlib::H5Esprit::WD] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::WD); + m_HeaderMap[ebsdlib::H5Esprit::XSTEP] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::XSTEP); + m_HeaderMap[ebsdlib::H5Esprit::YSTEP] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::YSTEP); + m_HeaderMap[ebsdlib::H5Esprit::ZOffset] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::ZOffset); + + m_HeaderMap[ebsdlib::H5Esprit::GridType] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::GridType); + m_HeaderMap[ebsdlib::H5Esprit::OriginalFile] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5Esprit::OriginalFile); m_PatternDims[0] = -1; m_PatternDims[1] = -1; @@ -84,88 +86,88 @@ H5EspritReader::~H5EspritReader() { // if(m_DDCleanup) // { - // deallocateArrayData(m_DD); + // deallocateArrayData(m_DD); // m_DD = nullptr; // } if(m_MADCleanup) { - deallocateArrayData(m_MAD); + deallocateArrayData(m_MAD); m_MAD = nullptr; } // if(m_MADPhaseCleanup) // { - // deallocateArrayData(m_MADPhase); + // deallocateArrayData(m_MADPhase); // m_MADPhase = nullptr; // } if(m_NIndexedBandsCleanup) { - deallocateArrayData(m_NIndexedBands); + deallocateArrayData(m_NIndexedBands); m_NIndexedBands = nullptr; } // if(m_PCXCleanup) // { - // deallocateArrayData(m_PCX); + // deallocateArrayData(m_PCX); // m_PCX = nullptr; // } // if(m_PCYCleanup) // { - // deallocateArrayData(m_PCY); + // deallocateArrayData(m_PCY); // m_PCY = nullptr; // } if(m_PHICleanup) { - deallocateArrayData(m_PHI); + deallocateArrayData(m_PHI); m_PHI = nullptr; } if(m_PhaseCleanup) { - deallocateArrayData(m_Phase); + deallocateArrayData(m_Phase); m_Phase = nullptr; } if(m_RadonBandCountCleanup) { - deallocateArrayData(m_RadonBandCount); + deallocateArrayData(m_RadonBandCount); m_RadonBandCount = nullptr; } if(m_RadonQualityCleanup) { - deallocateArrayData(m_RadonQuality); + deallocateArrayData(m_RadonQuality); m_RadonQuality = nullptr; } if(m_XBEAMCleanup) { - deallocateArrayData(m_XBEAM); + deallocateArrayData(m_XBEAM); m_XBEAM = nullptr; } if(m_YBEAMCleanup) { - deallocateArrayData(m_YBEAM); + deallocateArrayData(m_YBEAM); m_YBEAM = nullptr; } // if(m_XSAMPLECleanup) // { - // deallocateArrayData(m_XSAMPLE); + // deallocateArrayData(m_XSAMPLE); // m_XSAMPLE = nullptr; // } // if(m_YSAMPLECleanup) // { - // deallocateArrayData(m_YSAMPLE); + // deallocateArrayData(m_YSAMPLE); // m_YSAMPLE = nullptr; // } if(m_phi1Cleanup) { - deallocateArrayData(m_phi1); + deallocateArrayData(m_phi1); m_phi1 = nullptr; } if(m_phi2Cleanup) { - deallocateArrayData(m_phi2); + deallocateArrayData(m_phi2); m_phi2 = nullptr; } if(m_PatternDataCleanup) { - deallocateArrayData(m_PatternData); + deallocateArrayData(m_PatternData); m_PatternData = nullptr; } } @@ -238,7 +240,7 @@ int H5EspritReader::readFile() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5Esprit::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5Esprit::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { std::string str; @@ -308,7 +310,7 @@ int H5EspritReader::readHeaderOnly() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5Esprit::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5Esprit::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { std::string str; @@ -379,7 +381,7 @@ int H5EspritReader::readHeader(hid_t parId) int err = -1; - hid_t gid = H5Gopen(parId, EbsdLib::H5Esprit::Header.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5Esprit::Header.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorCode(-90008); @@ -388,35 +390,35 @@ int H5EspritReader::readHeader(hid_t parId) } H5ScopedGroupSentinel sentinel(gid, false); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::CameraTilt, gid, m_HeaderMap); - ReadH5EbsdHeaderStringData(this, EbsdLib::H5Esprit::GridType, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::KV, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::MADMax, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::Magnification, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::MapStepFactor, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::MaxRadonBandCount, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::MinIndexedBands, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::NCOLS, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::NPoints, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::NROWS, gid, m_HeaderMap); - ReadH5EbsdHeaderStringData(this, EbsdLib::H5Esprit::OriginalFile, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::PixelByteCount, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::SEPixelSizeX, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::SEPixelSizeY, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::SampleTilt, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::TopClip, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::UnClippedPatternHeight, gid, m_HeaderMap); - // ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::WD, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::XSTEP, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::YSTEP, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::ZOffset, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::CameraTilt, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::H5Esprit::GridType, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::KV, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::MADMax, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::Magnification, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::MapStepFactor, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::MaxRadonBandCount, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::MinIndexedBands, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::NCOLS, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::NPoints, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::NROWS, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::H5Esprit::OriginalFile, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::PixelByteCount, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::SEPixelSizeX, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::SEPixelSizeY, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::SampleTilt, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::TopClip, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::UnClippedPatternHeight, gid, m_HeaderMap); + // ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::WD, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::XSTEP, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::YSTEP, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::ZOffset, gid, m_HeaderMap); HDF_ERROR_HANDLER_OFF // Read the Pattern Width - This may not exist - bool patWidthExists = H5Lite::datasetExists(gid, EbsdLib::H5Esprit::PatternWidth); + bool patWidthExists = H5Lite::datasetExists(gid, ebsdlib::H5Esprit::PatternWidth); if(patWidthExists) { - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::PatternWidth, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::PatternWidth, gid, m_HeaderMap); m_PatternDims[1] = getPatternWidth(); } else if(getReadPatternData() && !patWidthExists) @@ -428,10 +430,10 @@ int H5EspritReader::readHeader(hid_t parId) } // Read the Pattern Height - This may not exist - bool patHeightExists = H5Lite::datasetExists(gid, EbsdLib::H5Esprit::PatternHeight); + bool patHeightExists = H5Lite::datasetExists(gid, ebsdlib::H5Esprit::PatternHeight); if(patHeightExists) { - ReadH5EbsdHeaderData(this, EbsdLib::H5Esprit::PatternHeight, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::H5Esprit::PatternHeight, gid, m_HeaderMap); m_PatternDims[0] = getPatternHeight(); } else if(getReadPatternData() && !patHeightExists) @@ -442,7 +444,7 @@ int H5EspritReader::readHeader(hid_t parId) return getErrorCode(); } - bool patternDataExists = H5Lite::datasetExists(parId, EbsdLib::H5Esprit::Data + "/" + EbsdLib::H5Esprit::RawPatterns); + bool patternDataExists = H5Lite::datasetExists(parId, ebsdlib::H5Esprit::Data + "/" + ebsdlib::H5Esprit::RawPatterns); if(getReadPatternData() && !patternDataExists) { setErrorCode(-90018); @@ -452,7 +454,7 @@ int H5EspritReader::readHeader(hid_t parId) } HDF_ERROR_HANDLER_ON - hid_t phasesGid = H5Gopen(gid, EbsdLib::H5Esprit::Phases.c_str(), H5P_DEFAULT); + hid_t phasesGid = H5Gopen(gid, ebsdlib::H5Esprit::Phases.c_str(), H5P_DEFAULT); if(phasesGid < 0) { setErrorCode(-90007); @@ -481,17 +483,17 @@ int H5EspritReader::readHeader(hid_t parId) EspritPhase::Pointer currentPhase = EspritPhase::New(); currentPhase->setPhaseIndex(std::stoi(phaseGroupName)); - READ_PHASE_STRING_DATA("H5EspritReader", pid, EbsdLib::H5Esprit::Formula, Formula, currentPhase) + READ_PHASE_STRING_DATA("H5EspritReader", pid, ebsdlib::H5Esprit::Formula, Formula, currentPhase) - READ_PHASE_HEADER_DATA("H5EspritReader", pid, int32_t, EbsdLib::H5Esprit::IT, IT, currentPhase) + READ_PHASE_HEADER_DATA("H5EspritReader", pid, int32_t, ebsdlib::H5Esprit::IT, IT, currentPhase) - READ_PHASE_HEADER_ARRAY("H5EspritReader", pid, float, EbsdLib::H5Esprit::LatticeConstants, LatticeConstants, currentPhase); + READ_PHASE_HEADER_ARRAY("H5EspritReader", pid, float, ebsdlib::H5Esprit::LatticeConstants, LatticeConstants, currentPhase); - READ_PHASE_STRING_DATA("H5EspritReader", pid, EbsdLib::H5Esprit::Name, Name, currentPhase) + READ_PHASE_STRING_DATA("H5EspritReader", pid, ebsdlib::H5Esprit::Name, Name, currentPhase) - READ_PHASE_HEADER_DATA("H5EspritReader", pid, int32_t, EbsdLib::H5Esprit::Setting, Setting, currentPhase) + READ_PHASE_HEADER_DATA("H5EspritReader", pid, int32_t, ebsdlib::H5Esprit::Setting, Setting, currentPhase) - READ_PHASE_STRING_DATA("H5EspritReader", pid, EbsdLib::H5Esprit::SpaceGroup, SpaceGroup, currentPhase) + READ_PHASE_STRING_DATA("H5EspritReader", pid, ebsdlib::H5Esprit::SpaceGroup, SpaceGroup, currentPhase) phaseVector.push_back(currentPhase); err = H5Gclose(pid); @@ -527,7 +529,7 @@ int H5EspritReader::readData(hid_t parId) setErrorCode(err); return err; } - if(grid.find(EbsdLib::H5Esprit::Isometric) != std::string::npos) + if(grid.find(ebsdlib::H5Esprit::Isometric) != std::string::npos) { // if (nCols > 0) { numElements = nRows * nCols; } if(nColumns > 0) @@ -553,7 +555,7 @@ int H5EspritReader::readData(hid_t parId) return -301; } - hid_t gid = H5Gopen(parId, EbsdLib::H5Esprit::Data.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5Esprit::Data.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorMessage("H5OIMReader Error: Could not open 'Data' Group"); @@ -574,29 +576,29 @@ int H5EspritReader::readData(hid_t parId) return err; } - // ANG_READER_ALLOCATE_AND_READ(DD, EbsdLib::H5Esprit::DD, EbsdLib::H5Esprit::DD_t); - ANG_READER_ALLOCATE_AND_READ(MAD, EbsdLib::H5Esprit::MAD, EbsdLib::H5Esprit::MAD_t); - // ANG_READER_ALLOCATE_AND_READ(MADPhase, EbsdLib::H5Esprit::MADPhase, EbsdLib::H5Esprit::MADPhase_t); - ANG_READER_ALLOCATE_AND_READ(NIndexedBands, EbsdLib::H5Esprit::NIndexedBands, EbsdLib::H5Esprit::NIndexedBands_t); - // ANG_READER_ALLOCATE_AND_READ(PCX, EbsdLib::H5Esprit::PCX, EbsdLib::H5Esprit::PCX_t); - // ANG_READER_ALLOCATE_AND_READ(PCY, EbsdLib::H5Esprit::PCY, EbsdLib::H5Esprit::PCY_t); - ANG_READER_ALLOCATE_AND_READ(PHI, EbsdLib::H5Esprit::PHI, EbsdLib::H5Esprit::PHI_t); - ANG_READER_ALLOCATE_AND_READ(Phase, EbsdLib::H5Esprit::Phase, EbsdLib::H5Esprit::Phase_t); - ANG_READER_ALLOCATE_AND_READ(RadonBandCount, EbsdLib::H5Esprit::RadonBandCount, EbsdLib::H5Esprit::RadonBandCount_t); - ANG_READER_ALLOCATE_AND_READ(RadonQuality, EbsdLib::H5Esprit::RadonQuality, EbsdLib::H5Esprit::RadonQuality_t); - ANG_READER_ALLOCATE_AND_READ(XBEAM, EbsdLib::H5Esprit::XBEAM, EbsdLib::H5Esprit::XBEAM_t); - ANG_READER_ALLOCATE_AND_READ(YBEAM, EbsdLib::H5Esprit::YBEAM, EbsdLib::H5Esprit::YBEAM_t); - // ANG_READER_ALLOCATE_AND_READ(XSAMPLE, EbsdLib::H5Esprit::XSAMPLE, EbsdLib::H5Esprit::XSAMPLE_t); - // ANG_READER_ALLOCATE_AND_READ(YSAMPLE, EbsdLib::H5Esprit::YSAMPLE, EbsdLib::H5Esprit::YSAMPLE_t); - ANG_READER_ALLOCATE_AND_READ(phi1, EbsdLib::H5Esprit::phi1, EbsdLib::H5Esprit::phi1_t); - ANG_READER_ALLOCATE_AND_READ(phi2, EbsdLib::H5Esprit::phi2, EbsdLib::H5Esprit::phi2_t); + // ANG_READER_ALLOCATE_AND_READ(DD, ebsdlib::H5Esprit::DD, ebsdlib::H5Esprit::DD_t); + ANG_READER_ALLOCATE_AND_READ(MAD, ebsdlib::H5Esprit::MAD, ebsdlib::H5Esprit::MAD_t); + // ANG_READER_ALLOCATE_AND_READ(MADPhase, ebsdlib::H5Esprit::MADPhase, ebsdlib::H5Esprit::MADPhase_t); + ANG_READER_ALLOCATE_AND_READ(NIndexedBands, ebsdlib::H5Esprit::NIndexedBands, ebsdlib::H5Esprit::NIndexedBands_t); + // ANG_READER_ALLOCATE_AND_READ(PCX, ebsdlib::H5Esprit::PCX, ebsdlib::H5Esprit::PCX_t); + // ANG_READER_ALLOCATE_AND_READ(PCY, ebsdlib::H5Esprit::PCY, ebsdlib::H5Esprit::PCY_t); + ANG_READER_ALLOCATE_AND_READ(PHI, ebsdlib::H5Esprit::PHI, ebsdlib::H5Esprit::PHI_t); + ANG_READER_ALLOCATE_AND_READ(Phase, ebsdlib::H5Esprit::Phase, ebsdlib::H5Esprit::Phase_t); + ANG_READER_ALLOCATE_AND_READ(RadonBandCount, ebsdlib::H5Esprit::RadonBandCount, ebsdlib::H5Esprit::RadonBandCount_t); + ANG_READER_ALLOCATE_AND_READ(RadonQuality, ebsdlib::H5Esprit::RadonQuality, ebsdlib::H5Esprit::RadonQuality_t); + ANG_READER_ALLOCATE_AND_READ(XBEAM, ebsdlib::H5Esprit::XBEAM, ebsdlib::H5Esprit::XBEAM_t); + ANG_READER_ALLOCATE_AND_READ(YBEAM, ebsdlib::H5Esprit::YBEAM, ebsdlib::H5Esprit::YBEAM_t); + // ANG_READER_ALLOCATE_AND_READ(XSAMPLE, ebsdlib::H5Esprit::XSAMPLE, ebsdlib::H5Esprit::XSAMPLE_t); + // ANG_READER_ALLOCATE_AND_READ(YSAMPLE, ebsdlib::H5Esprit::YSAMPLE, ebsdlib::H5Esprit::YSAMPLE_t); + ANG_READER_ALLOCATE_AND_READ(phi1, ebsdlib::H5Esprit::phi1, ebsdlib::H5Esprit::phi1_t); + ANG_READER_ALLOCATE_AND_READ(phi2, ebsdlib::H5Esprit::phi2, ebsdlib::H5Esprit::phi2_t); if(m_ReadPatternData) { H5T_class_t type_class; std::vector dims; size_t type_size = 0; - err = H5Lite::getDatasetInfo(gid, EbsdLib::H5Esprit::RawPatterns, dims, type_class, type_size); + err = H5Lite::getDatasetInfo(gid, ebsdlib::H5Esprit::RawPatterns, dims, type_class, type_size); if(err >= 0) // Only read the pattern data if the pattern data is available. { totalDataRows = std::accumulate(dims.cbegin(), dims.cend(), static_cast(1), std::multiplies()); @@ -606,7 +608,7 @@ int H5EspritReader::readData(hid_t parId) m_PatternDims[1] = static_cast(dims[2]); m_PatternData = this->allocateArray(totalDataRows); - err = H5Lite::readPointerDataset(gid, EbsdLib::H5Esprit::RawPatterns, m_PatternData); + err = H5Lite::readPointerDataset(gid, ebsdlib::H5Esprit::RawPatterns, m_PatternData); } } err = H5Gclose(gid); @@ -666,87 +668,87 @@ void H5EspritReader::setYDimension(int ydim) // ----------------------------------------------------------------------------- void H5EspritReader::releaseOwnership(const std::string& name) { - // if(name == EbsdLib::H5Esprit::DD) + // if(name == ebsdlib::H5Esprit::DD) // { // m_DD = nullptr; // m_DDCleanup = false; // } - if(name == EbsdLib::H5Esprit::MAD) + if(name == ebsdlib::H5Esprit::MAD) { m_MAD = nullptr; m_MADCleanup = false; } - // if(name == EbsdLib::H5Esprit::MADPhase) + // if(name == ebsdlib::H5Esprit::MADPhase) // { // m_MADPhase = nullptr; // m_MADPhaseCleanup = false; // } - if(name == EbsdLib::H5Esprit::NIndexedBands) + if(name == ebsdlib::H5Esprit::NIndexedBands) { m_NIndexedBands = nullptr; m_NIndexedBandsCleanup = false; } - // if(name == EbsdLib::H5Esprit::PCX) + // if(name == ebsdlib::H5Esprit::PCX) // { // m_PCX = nullptr; // m_PCXCleanup = false; // } - // if(name == EbsdLib::H5Esprit::PCY) + // if(name == ebsdlib::H5Esprit::PCY) // { // m_PCY = nullptr; // m_PCYCleanup = false; // } - if(name == EbsdLib::H5Esprit::PHI) + if(name == ebsdlib::H5Esprit::PHI) { m_PHI = nullptr; m_PHICleanup = false; } - if(name == EbsdLib::H5Esprit::Phase) + if(name == ebsdlib::H5Esprit::Phase) { m_Phase = nullptr; m_PhaseCleanup = false; } - if(name == EbsdLib::H5Esprit::RadonBandCount) + if(name == ebsdlib::H5Esprit::RadonBandCount) { m_RadonBandCount = nullptr; m_RadonBandCountCleanup = false; } - if(name == EbsdLib::H5Esprit::RadonQuality) + if(name == ebsdlib::H5Esprit::RadonQuality) { m_RadonQuality = nullptr; m_RadonQualityCleanup = false; } - if(name == EbsdLib::H5Esprit::RawPatterns) + if(name == ebsdlib::H5Esprit::RawPatterns) { m_PatternData = nullptr; m_PatternDataCleanup = false; } - if(name == EbsdLib::H5Esprit::XBEAM) + if(name == ebsdlib::H5Esprit::XBEAM) { m_XBEAM = nullptr; m_XBEAMCleanup = false; } - if(name == EbsdLib::H5Esprit::YBEAM) + if(name == ebsdlib::H5Esprit::YBEAM) { m_YBEAM = nullptr; m_YBEAMCleanup = false; } - // if(name == EbsdLib::H5Esprit::XSAMPLE) + // if(name == ebsdlib::H5Esprit::XSAMPLE) // { // m_XSAMPLE = nullptr; // m_XSAMPLECleanup = false; // } - // if(name == EbsdLib::H5Esprit::YSAMPLE) + // if(name == ebsdlib::H5Esprit::YSAMPLE) // { // m_YSAMPLE = nullptr; // m_YSAMPLECleanup = false; // } - if(name == EbsdLib::H5Esprit::phi1) + if(name == ebsdlib::H5Esprit::phi1) { m_phi1 = nullptr; m_phi1Cleanup = false; } - if(name == EbsdLib::H5Esprit::phi2) + if(name == ebsdlib::H5Esprit::phi2) { m_phi2 = nullptr; m_phi2Cleanup = false; @@ -758,71 +760,71 @@ void H5EspritReader::releaseOwnership(const std::string& name) // ----------------------------------------------------------------------------- void* H5EspritReader::getPointerByName(const std::string& featureName) { - // if(featureName == EbsdLib::H5Esprit::DD) + // if(featureName == ebsdlib::H5Esprit::DD) // { // return static_cast(m_DD); // } - if(featureName == EbsdLib::H5Esprit::MAD) + if(featureName == ebsdlib::H5Esprit::MAD) { return static_cast(m_MAD); } - // if(featureName == EbsdLib::H5Esprit::MADPhase) + // if(featureName == ebsdlib::H5Esprit::MADPhase) // { // return static_cast(m_MADPhase); // } - if(featureName == EbsdLib::H5Esprit::NIndexedBands) + if(featureName == ebsdlib::H5Esprit::NIndexedBands) { return static_cast(m_NIndexedBands); } - // if(featureName == EbsdLib::H5Esprit::PCX) + // if(featureName == ebsdlib::H5Esprit::PCX) // { // return static_cast(m_PCX); // } - // if(featureName == EbsdLib::H5Esprit::PCY) + // if(featureName == ebsdlib::H5Esprit::PCY) // { // return static_cast(m_PCY); // } - if(featureName == EbsdLib::H5Esprit::PHI) + if(featureName == ebsdlib::H5Esprit::PHI) { return static_cast(m_PHI); } - if(featureName == EbsdLib::H5Esprit::Phase) + if(featureName == ebsdlib::H5Esprit::Phase) { return static_cast(m_Phase); } - if(featureName == EbsdLib::H5Esprit::RadonBandCount) + if(featureName == ebsdlib::H5Esprit::RadonBandCount) { return static_cast(m_RadonBandCount); } - if(featureName == EbsdLib::H5Esprit::RadonQuality) + if(featureName == ebsdlib::H5Esprit::RadonQuality) { return static_cast(m_RadonQuality); } - if(featureName == EbsdLib::H5Esprit::RawPatterns) + if(featureName == ebsdlib::H5Esprit::RawPatterns) { return static_cast(m_PatternData); } - if(featureName == EbsdLib::H5Esprit::XBEAM) + if(featureName == ebsdlib::H5Esprit::XBEAM) { return static_cast(m_XBEAM); } - if(featureName == EbsdLib::H5Esprit::YBEAM) + if(featureName == ebsdlib::H5Esprit::YBEAM) { return static_cast(m_YBEAM); } - // if(featureName == EbsdLib::H5Esprit::XSAMPLE) + // if(featureName == ebsdlib::H5Esprit::XSAMPLE) // { // return static_cast(m_XSAMPLE); // } - // if(featureName == EbsdLib::H5Esprit::YSAMPLE) + // if(featureName == ebsdlib::H5Esprit::YSAMPLE) // { // return static_cast(m_YSAMPLE); // } - if(featureName == EbsdLib::H5Esprit::phi1) + if(featureName == ebsdlib::H5Esprit::phi1) { return static_cast(m_phi1); } - if(featureName == EbsdLib::H5Esprit::phi2) + if(featureName == ebsdlib::H5Esprit::phi2) { return static_cast(m_phi2); } @@ -833,80 +835,80 @@ void* H5EspritReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type H5EspritReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type H5EspritReader::getPointerType(const std::string& featureName) { - // if(featureName == EbsdLib::H5Esprit::DD) + // if(featureName == ebsdlib::H5Esprit::DD) // { - // return EbsdLib::NumericTypes::Type::Float; + // return ebsdlib::NumericTypes::Type::Float; // } - if(featureName == EbsdLib::H5Esprit::MAD) + if(featureName == ebsdlib::H5Esprit::MAD) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - // if(featureName == EbsdLib::H5Esprit::MADPhase) + // if(featureName == ebsdlib::H5Esprit::MADPhase) // { - // return EbsdLib::NumericTypes::Type::Int32; + // return ebsdlib::NumericTypes::Type::Int32; // } - if(featureName == EbsdLib::H5Esprit::NIndexedBands) + if(featureName == ebsdlib::H5Esprit::NIndexedBands) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - // if(featureName == EbsdLib::H5Esprit::PCX) + // if(featureName == ebsdlib::H5Esprit::PCX) // { - // return EbsdLib::NumericTypes::Type::Float; + // return ebsdlib::NumericTypes::Type::Float; // } - // if(featureName == EbsdLib::H5Esprit::PCY) + // if(featureName == ebsdlib::H5Esprit::PCY) // { - // return EbsdLib::NumericTypes::Type::Float; + // return ebsdlib::NumericTypes::Type::Float; // } - if(featureName == EbsdLib::H5Esprit::PHI) + if(featureName == ebsdlib::H5Esprit::PHI) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5Esprit::Phase) + if(featureName == ebsdlib::H5Esprit::Phase) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::H5Esprit::RadonBandCount) + if(featureName == ebsdlib::H5Esprit::RadonBandCount) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::H5Esprit::RadonQuality) + if(featureName == ebsdlib::H5Esprit::RadonQuality) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5Esprit::XBEAM) + if(featureName == ebsdlib::H5Esprit::XBEAM) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::H5Esprit::YBEAM) + if(featureName == ebsdlib::H5Esprit::YBEAM) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - // if(featureName == EbsdLib::H5Esprit::XSAMPLE) + // if(featureName == ebsdlib::H5Esprit::XSAMPLE) // { - // return EbsdLib::NumericTypes::Type::Float; + // return ebsdlib::NumericTypes::Type::Float; // } - // if(featureName == EbsdLib::H5Esprit::YSAMPLE) + // if(featureName == ebsdlib::H5Esprit::YSAMPLE) // { - // return EbsdLib::NumericTypes::Type::Float; + // return ebsdlib::NumericTypes::Type::Float; // } - if(featureName == EbsdLib::H5Esprit::phi1) + if(featureName == ebsdlib::H5Esprit::phi1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5Esprit::phi2) + if(featureName == ebsdlib::H5Esprit::phi2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5Esprit::RawPatterns) + if(featureName == ebsdlib::H5Esprit::RawPatterns) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/IO/BrukerNano/H5EspritReader.h b/Source/EbsdLib/IO/BrukerNano/H5EspritReader.h index 96cdd548..35f8fcb7 100644 --- a/Source/EbsdLib/IO/BrukerNano/H5EspritReader.h +++ b/Source/EbsdLib/IO/BrukerNano/H5EspritReader.h @@ -43,7 +43,8 @@ #include "EbsdLib/IO/BrukerNano/EspritPhase.h" #include "EbsdLib/IO/EbsdReader.h" #include "EbsdLib/IO/TSL/AngHeaderEntry.h" - +namespace ebsdlib +{ /** * @class H5EspritReader H5EspritReader.h EbsdLib/BrukerNano/H5EspritReader.h * @brief @@ -92,19 +93,19 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader EBSD_INSTANCE_2DVECTOR_PROPERTY(int, PatternDims) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumColumns, EbsdLib::H5Esprit::NCOLS) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumColumns, ebsdlib::H5Esprit::NCOLS) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumRows, EbsdLib::H5Esprit::NROWS) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumRows, ebsdlib::H5Esprit::NROWS) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, double, XStep, EbsdLib::H5Esprit::XSTEP) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, double, XStep, ebsdlib::H5Esprit::XSTEP) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, double, YStep, EbsdLib::H5Esprit::YSTEP) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, double, YStep, ebsdlib::H5Esprit::YSTEP) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, Grid, EbsdLib::H5Esprit::GridType) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, Grid, ebsdlib::H5Esprit::GridType) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternWidth, EbsdLib::H5Esprit::PatternWidth) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternWidth, ebsdlib::H5Esprit::PatternWidth) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternHeight, EbsdLib::H5Esprit::PatternHeight) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternHeight, ebsdlib::H5Esprit::PatternHeight) /** * @brief These methods allow the developer to set/get the raw pointer for a given array, release ownership of the memory @@ -129,22 +130,22 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader * void free[NAME]Pointer(); * */ - // EBSD_POINTER_PROPERTY(DD, DD, EbsdLib::H5Esprit::DD_t) - EBSD_POINTER_PROPERTY(MAD, MAD, EbsdLib::H5Esprit::MAD_t) - // EBSD_POINTER_PROPERTY(MADPhase, MADPhase, EbsdLib::H5Esprit::MADPhase_t) - EBSD_POINTER_PROPERTY(NIndexedBands, NIndexedBands, EbsdLib::H5Esprit::NIndexedBands_t) - // EBSD_POINTER_PROPERTY(PCX, PCX, EbsdLib::H5Esprit::PCX_t) - // EBSD_POINTER_PROPERTY(PCY, PCY, EbsdLib::H5Esprit::PCY_t) - EBSD_POINTER_PROPERTY(PHI, PHI, EbsdLib::H5Esprit::PHI_t) - EBSD_POINTER_PROPERTY(Phase, Phase, EbsdLib::H5Esprit::Phase_t) - EBSD_POINTER_PROPERTY(RadonBandCount, RadonBandCount, EbsdLib::H5Esprit::RadonBandCount_t) - EBSD_POINTER_PROPERTY(RadonQuality, RadonQuality, EbsdLib::H5Esprit::RadonQuality_t) - EBSD_POINTER_PROPERTY(XBEAM, XBEAM, EbsdLib::H5Esprit::XBEAM_t) - EBSD_POINTER_PROPERTY(YBEAM, YBEAM, EbsdLib::H5Esprit::YBEAM_t) - // EBSD_POINTER_PROPERTY(XSAMPLE, XSAMPLE, EbsdLib::H5Esprit::XSAMPLE_t) - // EBSD_POINTER_PROPERTY(YSAMPLE, YSAMPLE, EbsdLib::H5Esprit::YSAMPLE_t) - EBSD_POINTER_PROPERTY(phi1, phi1, EbsdLib::H5Esprit::phi1_t) - EBSD_POINTER_PROPERTY(phi2, phi2, EbsdLib::H5Esprit::phi2_t) + // EBSD_POINTER_PROPERTY(DD, DD, ebsdlib::H5Esprit::DD_t) + EBSD_POINTER_PROPERTY(MAD, MAD, ebsdlib::H5Esprit::MAD_t) + // EBSD_POINTER_PROPERTY(MADPhase, MADPhase, ebsdlib::H5Esprit::MADPhase_t) + EBSD_POINTER_PROPERTY(NIndexedBands, NIndexedBands, ebsdlib::H5Esprit::NIndexedBands_t) + // EBSD_POINTER_PROPERTY(PCX, PCX, ebsdlib::H5Esprit::PCX_t) + // EBSD_POINTER_PROPERTY(PCY, PCY, ebsdlib::H5Esprit::PCY_t) + EBSD_POINTER_PROPERTY(PHI, PHI, ebsdlib::H5Esprit::PHI_t) + EBSD_POINTER_PROPERTY(Phase, Phase, ebsdlib::H5Esprit::Phase_t) + EBSD_POINTER_PROPERTY(RadonBandCount, RadonBandCount, ebsdlib::H5Esprit::RadonBandCount_t) + EBSD_POINTER_PROPERTY(RadonQuality, RadonQuality, ebsdlib::H5Esprit::RadonQuality_t) + EBSD_POINTER_PROPERTY(XBEAM, XBEAM, ebsdlib::H5Esprit::XBEAM_t) + EBSD_POINTER_PROPERTY(YBEAM, YBEAM, ebsdlib::H5Esprit::YBEAM_t) + // EBSD_POINTER_PROPERTY(XSAMPLE, XSAMPLE, ebsdlib::H5Esprit::XSAMPLE_t) + // EBSD_POINTER_PROPERTY(YSAMPLE, YSAMPLE, ebsdlib::H5Esprit::YSAMPLE_t) + EBSD_POINTER_PROPERTY(phi1, phi1, ebsdlib::H5Esprit::phi1_t) + EBSD_POINTER_PROPERTY(phi2, phi2, ebsdlib::H5Esprit::phi2_t) /** * @brief releaseOwnership @@ -163,7 +164,7 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; /** * @brief Reads the file @@ -244,3 +245,4 @@ class EbsdLib_EXPORT H5EspritReader : public EbsdReader H5EspritReader& operator=(const H5EspritReader&) = delete; // Copy Assignment Not Implemented H5EspritReader& operator=(H5EspritReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/EbsdHeaderEntry.h b/Source/EbsdLib/IO/EbsdHeaderEntry.h index 01ba43f5..45c04394 100644 --- a/Source/EbsdLib/IO/EbsdHeaderEntry.h +++ b/Source/EbsdLib/IO/EbsdHeaderEntry.h @@ -58,7 +58,8 @@ SuperClass##Type sharedPtr(object); \ return sharedPtr; \ } - +namespace ebsdlib +{ /** * @class EbsdHeaderEntry EbsdHeaderEntry.h EbsdLib/EbsdHeaderEntry.h * @brief This class defines the interface that subclasses need to implement in @@ -121,3 +122,4 @@ class EbsdLib_EXPORT EbsdHeaderEntry EbsdHeaderEntry& operator=(const EbsdHeaderEntry&) = delete; // Copy Assignment Not Implemented EbsdHeaderEntry& operator=(EbsdHeaderEntry&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/EbsdImporter.h b/Source/EbsdLib/IO/EbsdImporter.h index 11639e3f..cf9b905c 100644 --- a/Source/EbsdLib/IO/EbsdImporter.h +++ b/Source/EbsdLib/IO/EbsdImporter.h @@ -42,6 +42,9 @@ #ifdef EbsdLib_ENABLE_HDF5 #include #endif + +namespace ebsdlib +{ /** * @class EbsdImporter EbsdImporter.h EbsdLib/EbsdImporter.h * @brief This class is a pure virtual class that defines the interface that @@ -184,3 +187,4 @@ class EbsdLib_EXPORT EbsdImporter int m_ErrorCode = 0; bool m_Cancel = false; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/EbsdReader.cpp b/Source/EbsdLib/IO/EbsdReader.cpp index 719f4350..ff5af5c0 100644 --- a/Source/EbsdLib/IO/EbsdReader.cpp +++ b/Source/EbsdLib/IO/EbsdReader.cpp @@ -35,12 +35,14 @@ #include "EbsdReader.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- EbsdReader::EbsdReader() : m_ErrorCode(0) -, m_UserZDir(EbsdLib::RefFrameZDir::LowtoHigh) +, m_UserZDir(ebsdlib::RefFrameZDir::LowtoHigh) , m_SampleTransformationAngle(0.0f) , m_EulerTransformationAngle(0.0f) , m_NumFeatures(0) diff --git a/Source/EbsdLib/IO/EbsdReader.h b/Source/EbsdLib/IO/EbsdReader.h index d683615c..83168906 100644 --- a/Source/EbsdLib/IO/EbsdReader.h +++ b/Source/EbsdLib/IO/EbsdReader.h @@ -48,6 +48,8 @@ using namespace H5Support; #endif +namespace ebsdlib +{ /** * @class EbsdReader EbsdReader.h EbsdLib/EbsdReader.h * @brief This class is the super class to read an Ebsd data file. This class is @@ -176,7 +178,7 @@ class EbsdLib_EXPORT EbsdReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - virtual EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) = 0; + virtual ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) = 0; /** * @brief freePointerByName @@ -297,3 +299,4 @@ class EbsdLib_EXPORT EbsdReader std::string m_FileName = {}; std::string m_OriginalHeader = {}; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp b/Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp index ae313131..129d4d1a 100644 --- a/Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp +++ b/Source/EbsdLib/IO/H5EbsdVolumeInfo.cpp @@ -82,6 +82,8 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -155,30 +157,30 @@ int H5EbsdVolumeInfo::readVolumeInfo() m_FileVersion = 0; // Attempt to read the file version number. If it is not there that is OK as early h5ebsd // files did not have this information written. - err = H5Lite::readScalarAttribute(fileId, "/", EbsdLib::H5Ebsd::FileVersionStr, m_FileVersion); + err = H5Lite::readScalarAttribute(fileId, "/", ebsdlib::H5Ebsd::FileVersionStr, m_FileVersion); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::ZStartIndex, m_ZStart); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::ZEndIndex, m_ZEnd); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::ZStartIndex, m_ZStart); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::ZEndIndex, m_ZEnd); m_ZDim = m_ZEnd - m_ZStart + 1; // The range is inclusive (zStart, zEnd) - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::XPoints, m_XDim); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::YPoints, m_YDim); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::XResolution, m_XRes); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::YResolution, m_YRes); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::ZResolution, m_ZRes); - - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::StackingOrder, m_StackingOrder); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::SampleTransformationAngle, m_SampleTransformationAngle); - EBSD_VOLREADER_READ_VECTOR3_HEADER(fileId, EbsdLib::H5Ebsd::SampleTransformationAxis, m_SampleTransformationAxis, float); - EBSD_VOLREADER_READ_HEADER(fileId, EbsdLib::H5Ebsd::EulerTransformationAngle, m_EulerTransformationAngle); - EBSD_VOLREADER_READ_VECTOR3_HEADER(fileId, EbsdLib::H5Ebsd::EulerTransformationAxis, m_EulerTransformationAxis, float); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::XPoints, m_XDim); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::YPoints, m_YDim); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::XResolution, m_XRes); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::YResolution, m_YRes); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::ZResolution, m_ZRes); + + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::StackingOrder, m_StackingOrder); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::SampleTransformationAngle, m_SampleTransformationAngle); + EBSD_VOLREADER_READ_VECTOR3_HEADER(fileId, ebsdlib::H5Ebsd::SampleTransformationAxis, m_SampleTransformationAxis, float); + EBSD_VOLREADER_READ_HEADER(fileId, ebsdlib::H5Ebsd::EulerTransformationAngle, m_EulerTransformationAngle); + EBSD_VOLREADER_READ_VECTOR3_HEADER(fileId, ebsdlib::H5Ebsd::EulerTransformationAxis, m_EulerTransformationAxis, float); // Read the manufacturer from the file m_Manufacturer = ""; std::string data; - err = H5Lite::readStringDataset(fileId, EbsdLib::H5Ebsd::Manufacturer, data); + err = H5Lite::readStringDataset(fileId, ebsdlib::H5Ebsd::Manufacturer, data); if(err < 0) { - std::cout << "H5EbsdVolumeInfo Error: Could not load header value for " << EbsdLib::H5Ebsd::Manufacturer << std::endl; + std::cout << "H5EbsdVolumeInfo Error: Could not load header value for " << ebsdlib::H5Ebsd::Manufacturer << std::endl; err = H5Utilities::closeFile(fileId); return err; } @@ -191,10 +193,10 @@ int H5EbsdVolumeInfo::readVolumeInfo() hid_t gid = H5Gopen(fileId, index.c_str(), H5P_DEFAULT); if(gid > 0) { - hid_t headerId = H5Gopen(gid, EbsdLib::H5Ebsd::Header.c_str(), H5P_DEFAULT); + hid_t headerId = H5Gopen(gid, ebsdlib::H5Ebsd::Header.c_str(), H5P_DEFAULT); if(headerId > 0) { - hid_t phasesGid = H5Gopen(headerId, EbsdLib::H5Ebsd::Phases.c_str(), H5P_DEFAULT); + hid_t phasesGid = H5Gopen(headerId, ebsdlib::H5Ebsd::Phases.c_str(), H5P_DEFAULT); if(phasesGid > 0) { std::list names; @@ -210,7 +212,7 @@ int H5EbsdVolumeInfo::readVolumeInfo() // Now read out the names of the data arrays in the file - hid_t dataGid = H5Gopen(gid, EbsdLib::H5Ebsd::Data.c_str(), H5P_DEFAULT); + hid_t dataGid = H5Gopen(gid, ebsdlib::H5Ebsd::Data.c_str(), H5P_DEFAULT); if(dataGid > 0) { std::list names; @@ -228,34 +230,34 @@ int H5EbsdVolumeInfo::readVolumeInfo() } // we are going to selectively replace some of the data array names with some common names instead - if(m_Manufacturer == EbsdLib::Ang::Manufacturer) + if(m_Manufacturer == ebsdlib::Ang::Manufacturer) { - if(m_DataArrayNames.count(EbsdLib::Ang::Phi1) != 0 && m_DataArrayNames.count(EbsdLib::Ang::Phi) != 0 && m_DataArrayNames.count(EbsdLib::Ang::Phi2) != 0) + if(m_DataArrayNames.count(ebsdlib::Ang::Phi1) != 0 && m_DataArrayNames.count(ebsdlib::Ang::Phi) != 0 && m_DataArrayNames.count(ebsdlib::Ang::Phi2) != 0) { - m_DataArrayNames.erase(EbsdLib::Ang::Phi1); - m_DataArrayNames.erase(EbsdLib::Ang::Phi); - m_DataArrayNames.erase(EbsdLib::Ang::Phi2); - m_DataArrayNames.insert(EbsdLib::CellData::EulerAngles); + m_DataArrayNames.erase(ebsdlib::Ang::Phi1); + m_DataArrayNames.erase(ebsdlib::Ang::Phi); + m_DataArrayNames.erase(ebsdlib::Ang::Phi2); + m_DataArrayNames.insert(ebsdlib::CellData::EulerAngles); } - if(m_DataArrayNames.count(EbsdLib::Ang::PhaseData) != 0) + if(m_DataArrayNames.count(ebsdlib::Ang::PhaseData) != 0) { - m_DataArrayNames.erase(EbsdLib::Ang::PhaseData); - m_DataArrayNames.insert(EbsdLib::CellData::Phases); + m_DataArrayNames.erase(ebsdlib::Ang::PhaseData); + m_DataArrayNames.insert(ebsdlib::CellData::Phases); } } - else if(m_Manufacturer == EbsdLib::Ctf::Manufacturer) + else if(m_Manufacturer == ebsdlib::Ctf::Manufacturer) { - if(m_DataArrayNames.count(EbsdLib::Ctf::Euler1) != 0 && m_DataArrayNames.count(EbsdLib::Ctf::Euler2) != 0 && m_DataArrayNames.count(EbsdLib::Ctf::Euler3) != 0) + if(m_DataArrayNames.count(ebsdlib::Ctf::Euler1) != 0 && m_DataArrayNames.count(ebsdlib::Ctf::Euler2) != 0 && m_DataArrayNames.count(ebsdlib::Ctf::Euler3) != 0) { - m_DataArrayNames.erase(EbsdLib::Ctf::Euler1); - m_DataArrayNames.erase(EbsdLib::Ctf::Euler2); - m_DataArrayNames.erase(EbsdLib::Ctf::Euler3); - m_DataArrayNames.insert(EbsdLib::CellData::EulerAngles); + m_DataArrayNames.erase(ebsdlib::Ctf::Euler1); + m_DataArrayNames.erase(ebsdlib::Ctf::Euler2); + m_DataArrayNames.erase(ebsdlib::Ctf::Euler3); + m_DataArrayNames.insert(ebsdlib::CellData::EulerAngles); } - if(m_DataArrayNames.count(EbsdLib::Ctf::Phase) != 0) + if(m_DataArrayNames.count(ebsdlib::Ctf::Phase) != 0) { - m_DataArrayNames.erase(EbsdLib::Ctf::Phase); - m_DataArrayNames.insert(EbsdLib::CellData::Phases); + m_DataArrayNames.erase(ebsdlib::Ctf::Phase); + m_DataArrayNames.insert(ebsdlib::CellData::Phases); } } @@ -451,7 +453,7 @@ uint32_t H5EbsdVolumeInfo::getStackingOrder() err = readVolumeInfo(); if(err < 0) { - return EbsdLib::RefFrameZDir::UnknownRefFrameZDirection; + return ebsdlib::RefFrameZDir::UnknownRefFrameZDirection; } } return m_StackingOrder; diff --git a/Source/EbsdLib/IO/H5EbsdVolumeInfo.h b/Source/EbsdLib/IO/H5EbsdVolumeInfo.h index 65dfff35..33ad4b4e 100644 --- a/Source/EbsdLib/IO/H5EbsdVolumeInfo.h +++ b/Source/EbsdLib/IO/H5EbsdVolumeInfo.h @@ -42,6 +42,8 @@ #include "EbsdLib/Core/EbsdSetGetMacros.h" #include "EbsdLib/EbsdLib.h" +namespace ebsdlib +{ /** * @class H5EbsdVolumeInfo H5EbsdVolumeInfo.h EbsdLib/H5EbsdVolumeInfo.h * @brief This is a higher level class that only reads the volume header information @@ -218,7 +220,7 @@ class EbsdLib_EXPORT H5EbsdVolumeInfo float m_ZRes = 0.0f; int m_ZStart = 0; int m_ZEnd = 0; - uint32_t m_StackingOrder = EbsdLib::RefFrameZDir::LowtoHigh; + uint32_t m_StackingOrder = ebsdlib::RefFrameZDir::LowtoHigh; int m_NumPhases = 0; float m_SampleTransformationAngle = 0.0f; std::array m_SampleTransformationAxis = {{0.0f, 0.0f, 1.0f}}; @@ -235,3 +237,4 @@ class EbsdLib_EXPORT H5EbsdVolumeInfo H5EbsdVolumeInfo& operator=(const H5EbsdVolumeInfo&) = delete; // Copy Assignment Not Implemented H5EbsdVolumeInfo& operator=(H5EbsdVolumeInfo&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/H5EbsdVolumeReader.cpp b/Source/EbsdLib/IO/H5EbsdVolumeReader.cpp index 3097d599..2a28fb30 100644 --- a/Source/EbsdLib/IO/H5EbsdVolumeReader.cpp +++ b/Source/EbsdLib/IO/H5EbsdVolumeReader.cpp @@ -35,6 +35,8 @@ #include "H5EbsdVolumeReader.h" #include +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -78,9 +80,9 @@ void* H5EbsdVolumeReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type H5EbsdVolumeReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type H5EbsdVolumeReader::getPointerType(const std::string& featureName) { - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/IO/H5EbsdVolumeReader.h b/Source/EbsdLib/IO/H5EbsdVolumeReader.h index 264ef7a3..f577b019 100644 --- a/Source/EbsdLib/IO/H5EbsdVolumeReader.h +++ b/Source/EbsdLib/IO/H5EbsdVolumeReader.h @@ -43,6 +43,8 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/H5EbsdVolumeInfo.h" +namespace ebsdlib +{ /** * @class H5EbsdVolumeReader H5EbsdVolumeReader EbsdLib/H5EbsdVolumeReader.h * @brief This class defines the C++ interface that subclasses must implement @@ -124,7 +126,7 @@ class EbsdLib_EXPORT H5EbsdVolumeReader : public H5EbsdVolumeInfo * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - virtual EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName); + virtual ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName); /** @brief Allocates the proper amount of memory (after reading the header portion of the file) * and then splats '0' across all the bytes of the memory allocation @@ -163,3 +165,4 @@ class EbsdLib_EXPORT H5EbsdVolumeReader : public H5EbsdVolumeInfo H5EbsdVolumeReader& operator=(const H5EbsdVolumeReader&) = delete; // Copy Assignment Not Implemented H5EbsdVolumeReader& operator=(H5EbsdVolumeReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CprReader.cpp b/Source/EbsdLib/IO/HKL/CprReader.cpp index fa9f5d81..c7376376 100644 --- a/Source/EbsdLib/IO/HKL/CprReader.cpp +++ b/Source/EbsdLib/IO/HKL/CprReader.cpp @@ -15,7 +15,7 @@ #include #include -using namespace EbsdLib; +using namespace ebsdlib; namespace { @@ -39,27 +39,27 @@ enum ColumnNames { // std::array k_FieldByteSize = {0, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1}; // std::array k_FieldNames = {"", "X", "Y", "phi1", "Phi", "phi2", "MAD", "BC", "BS", "Unknown", "Bands", "Error", "ReliabilityIndex"}; -// std::array k_FieldNumericTypes = {EbsdLib::NumericTypes::Type::UnknownNumType, -// EbsdLib::NumericTypes::Type::Float, EbsdLib::NumericTypes::Type::Float, EbsdLib::NumericTypes::Type::Float, -// EbsdLib::NumericTypes::Type::Float, EbsdLib::NumericTypes::Type::Float, EbsdLib::NumericTypes::Type::Float, -// EbsdLib::NumericTypes::Type::UInt8, EbsdLib::NumericTypes::Type::UInt8, EbsdLib::NumericTypes::Type::UInt8, -// EbsdLib::NumericTypes::Type::UInt8, EbsdLib::NumericTypes::Type::UInt8, EbsdLib::NumericTypes::Type::UInt8}; +// std::array k_FieldNumericTypes = {ebsdlib::NumericTypes::Type::UnknownNumType, +// ebsdlib::NumericTypes::Type::Float, ebsdlib::NumericTypes::Type::Float, ebsdlib::NumericTypes::Type::Float, +// ebsdlib::NumericTypes::Type::Float, ebsdlib::NumericTypes::Type::Float, ebsdlib::NumericTypes::Type::Float, +// ebsdlib::NumericTypes::Type::UInt8, ebsdlib::NumericTypes::Type::UInt8, ebsdlib::NumericTypes::Type::UInt8, +// ebsdlib::NumericTypes::Type::UInt8, ebsdlib::NumericTypes::Type::UInt8, ebsdlib::NumericTypes::Type::UInt8}; // // clang-format off -std::array k_FieldDefinitions{CrcFieldDefinition{1, "Phase", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{4, "X", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{4, "Y", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{4, "phi1", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{4, "Phi", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{4, "phi2", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{4, "MAD", EbsdLib::NumericTypes::Type::Float}, - CrcFieldDefinition{1, "BC", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{1, "BS", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{1, "Unknown", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{1, "Bands", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{1, "Error", EbsdLib::NumericTypes::Type::UInt8}, - CrcFieldDefinition{4, "ReliabilityIndex", EbsdLib::NumericTypes::Type::Int32}}; +std::array k_FieldDefinitions{CrcFieldDefinition{1, "Phase", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{4, "X", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{4, "Y", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{4, "phi1", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{4, "Phi", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{4, "phi2", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{4, "MAD", ebsdlib::NumericTypes::Type::Float}, + CrcFieldDefinition{1, "BC", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{1, "BS", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{1, "Unknown", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{1, "Bands", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{1, "Error", ebsdlib::NumericTypes::Type::UInt8}, + CrcFieldDefinition{4, "ReliabilityIndex", ebsdlib::NumericTypes::Type::Int32}}; // clang-format on // Read a complete Scan Point @@ -106,29 +106,29 @@ CprReader::CprReader() { // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::Ctf::ChannelTextFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ChannelTextFile); - m_HeaderMap[EbsdLib::Ctf::Prj] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Prj); - m_HeaderMap[EbsdLib::Ctf::Author] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Author); - m_HeaderMap[EbsdLib::Ctf::JobMode] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::JobMode); - - m_HeaderMap[EbsdLib::Ctf::xCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XCells); - m_HeaderMap[EbsdLib::Ctf::yCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YCells); - // m_HeaderMap[EbsdLib::Ctf::ZCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ZCells); - m_HeaderMap[EbsdLib::Ctf::GridDistX] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XStep); - m_HeaderMap[EbsdLib::Ctf::GridDistY] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YStep); - // m_HeaderMap[EbsdLib::Ctf::ZStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ZStep); - // m_HeaderMap[EbsdLib::Ctf::AcqE1] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE1); - // m_HeaderMap[EbsdLib::Ctf::AcqE2] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE2); - // m_HeaderMap[EbsdLib::Ctf::AcqE3] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE3); - // m_HeaderMap[EbsdLib::Ctf::Euler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Euler); - - m_HeaderMap[EbsdLib::Ctf::Magnification] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Mag); - m_HeaderMap[EbsdLib::Ctf::Coverage] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Coverage); - m_HeaderMap[EbsdLib::Ctf::Device] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Device); - m_HeaderMap[EbsdLib::Ctf::kV] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::kV); - m_HeaderMap[EbsdLib::Ctf::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::TiltAngle); - m_HeaderMap[EbsdLib::Ctf::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::TiltAxis); - m_HeaderMap[EbsdLib::Ctf::NumPhases] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::NumPhases); + m_HeaderMap[ebsdlib::Ctf::ChannelTextFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ChannelTextFile); + m_HeaderMap[ebsdlib::Ctf::Prj] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Prj); + m_HeaderMap[ebsdlib::Ctf::Author] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Author); + m_HeaderMap[ebsdlib::Ctf::JobMode] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::JobMode); + + m_HeaderMap[ebsdlib::Ctf::xCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XCells); + m_HeaderMap[ebsdlib::Ctf::yCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YCells); + // m_HeaderMap[ebsdlib::Ctf::ZCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ZCells); + m_HeaderMap[ebsdlib::Ctf::GridDistX] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XStep); + m_HeaderMap[ebsdlib::Ctf::GridDistY] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YStep); + // m_HeaderMap[ebsdlib::Ctf::ZStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ZStep); + // m_HeaderMap[ebsdlib::Ctf::AcqE1] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE1); + // m_HeaderMap[ebsdlib::Ctf::AcqE2] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE2); + // m_HeaderMap[ebsdlib::Ctf::AcqE3] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE3); + // m_HeaderMap[ebsdlib::Ctf::Euler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Euler); + + m_HeaderMap[ebsdlib::Ctf::Magnification] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Mag); + m_HeaderMap[ebsdlib::Ctf::Coverage] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Coverage); + m_HeaderMap[ebsdlib::Ctf::Device] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Device); + m_HeaderMap[ebsdlib::Ctf::kV] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::kV); + m_HeaderMap[ebsdlib::Ctf::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::TiltAngle); + m_HeaderMap[ebsdlib::Ctf::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::TiltAxis); + m_HeaderMap[ebsdlib::Ctf::NumPhases] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::NumPhases); setXCells(0); setYCells(0); @@ -159,9 +159,9 @@ std::vector CprReader::getPointerNames() const return names; } -std::map CprReader::getPointerTypes() const +std::map CprReader::getPointerTypes() const { - std::map types; + std::map types; for(const auto& entry : m_NamePointerMap) { types[entry.first] = entry.second->getNumericType(); @@ -170,150 +170,150 @@ std::map CprReader::getPointerTypes() } // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type CprReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type CprReader::getPointerType(const std::string& featureName) { // std::cout << "featureName: " << featureName << std::endl; - if(featureName == EbsdLib::Ctf::ReliabilityIndex) + if(featureName == ebsdlib::Ctf::ReliabilityIndex) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Z) + if(featureName == ebsdlib::Ctf::Z) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::Ctf::phi1) + if(featureName == ebsdlib::Ctf::phi1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Phi) + if(featureName == ebsdlib::Ctf::Phi) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::phi2) + if(featureName == ebsdlib::Ctf::phi2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::Ctf::GrainIndex) + if(featureName == ebsdlib::Ctf::GrainIndex) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourR) + if(featureName == ebsdlib::Ctf::GrainRandomColourR) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourG) + if(featureName == ebsdlib::Ctf::GrainRandomColourG) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourB) + if(featureName == ebsdlib::Ctf::GrainRandomColourB) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } // std::cout << "THIS IS NOT GOOD. Feature name: " << featureName << " was not found in the list" << std::endl; - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // // ----------------------------------------------------------------------------- int CprReader::getTypeSize(const std::string& featureName) { - if(featureName == EbsdLib::Ctf::ReliabilityIndex) + if(featureName == ebsdlib::Ctf::ReliabilityIndex) { return 4; } - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { return 1; } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { return 4; } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { return 4; } - if(featureName == EbsdLib::Ctf::Z) + if(featureName == ebsdlib::Ctf::Z) { return 4; } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { return 1; } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { return 1; } - if(featureName == EbsdLib::Ctf::phi1) + if(featureName == ebsdlib::Ctf::phi1) { return 4; } - if(featureName == EbsdLib::Ctf::Phi) + if(featureName == ebsdlib::Ctf::Phi) { return 4; } - if(featureName == EbsdLib::Ctf::phi2) + if(featureName == ebsdlib::Ctf::phi2) { return 4; } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { return 4; } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { return 1; } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { return 1; } - if(featureName == EbsdLib::Ctf::GrainIndex) + if(featureName == ebsdlib::Ctf::GrainIndex) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourR) + if(featureName == ebsdlib::Ctf::GrainRandomColourR) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourG) + if(featureName == ebsdlib::Ctf::GrainRandomColourG) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourB) + if(featureName == ebsdlib::Ctf::GrainRandomColourB) { return 4; } @@ -351,8 +351,8 @@ int CprReader::readHeaderOnly() const std::string sectionName("Phases"); int phaseCount = -1; inipp::get_value(ini.sections[sectionName], "Count", phaseCount); - EbsdHeaderEntry::Pointer p1 = m_HeaderMap[EbsdLib::Ctf::NumPhases]; - auto value = getFieldValue(ini, sectionName, EbsdLib::Ctf::Count); + EbsdHeaderEntry::Pointer p1 = m_HeaderMap[ebsdlib::Ctf::NumPhases]; + auto value = getFieldValue(ini, sectionName, ebsdlib::Ctf::Count); p1->parseValue(value); // std::cout << "Phase Count: " << phaseCount << std::endl; for(int phaseIndex = 1; phaseIndex <= phaseCount; phaseIndex++) @@ -370,7 +370,7 @@ int CprReader::readHeaderOnly() phase->setLatticeConstants(getLatticeConstants(ini, sectionNameStrm.str())); // Laue Group - phase->setLaueGroup(static_cast(getFieldValue(ini, sectionNameStrm.str(), "LaueGroup"))); + phase->setLaueGroup(static_cast(getFieldValue(ini, sectionNameStrm.str(), "LaueGroup"))); // Comment phase->setComment(getFieldValue(ini, sectionNameStrm.str(), "Reference")); @@ -390,31 +390,31 @@ int CprReader::readHeaderOnly() { const std::string sectionName("Job"); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::Magnification, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::Coverage, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::Device, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::kV, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::TiltAngle, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::TiltAxis, m_HeaderMap); - - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::GridDistX, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::GridDistY, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::xCells, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::yCells, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::Magnification, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::Coverage, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::Device, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::kV, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::TiltAngle, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::TiltAxis, m_HeaderMap); + + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::GridDistX, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::GridDistY, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::xCells, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::yCells, m_HeaderMap); setNumberOfElements(getXCells() * getYCells()); } { const std::string sectionName("General"); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::Author, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::JobMode, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::Author, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::JobMode, m_HeaderMap); } { const std::string sectionName("General"); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::Author, m_HeaderMap); - ParseAndStoreHeaderEntry(ini, sectionName, EbsdLib::Ctf::JobMode, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::Author, m_HeaderMap); + ParseAndStoreHeaderEntry(ini, sectionName, ebsdlib::Ctf::JobMode, m_HeaderMap); } return err; @@ -470,7 +470,7 @@ int CprReader::readFile() setErrorCode(-110); return getErrorCode(); } - if(EbsdLib::NumericTypes::Type::UInt8 == parser.FieldDefinition.numericType) + if(ebsdlib::NumericTypes::Type::UInt8 == parser.FieldDefinition.numericType) { UInt8Parser::Pointer dparser = UInt8Parser::New(nullptr, totalScanPoints, parser.FieldDefinition.FieldName, index); didAllocate = dparser->allocateArray(totalScanPoints); @@ -482,7 +482,7 @@ int CprReader::readFile() parser.destinationPtr = reinterpret_cast(dparser->getVoidPointer()); } } - else if(EbsdLib::NumericTypes::Type::Float == parser.FieldDefinition.numericType) + else if(ebsdlib::NumericTypes::Type::Float == parser.FieldDefinition.numericType) { FloatParser::Pointer dparser = FloatParser::New(nullptr, totalScanPoints, parser.FieldDefinition.FieldName, index); didAllocate = dparser->allocateArray(totalScanPoints); @@ -494,7 +494,7 @@ int CprReader::readFile() parser.destinationPtr = reinterpret_cast(dparser->getVoidPointer()); } } - else if(EbsdLib::NumericTypes::Type::Int32 == parser.FieldDefinition.numericType) + else if(ebsdlib::NumericTypes::Type::Int32 == parser.FieldDefinition.numericType) { Int32Parser::Pointer dparser = Int32Parser::New(nullptr, totalScanPoints, parser.FieldDefinition.FieldName, index); didAllocate = dparser->allocateArray(totalScanPoints); @@ -622,7 +622,7 @@ std::vector CprReader::createFieldParsers(const std::string& file fieldNameStrm << "Field" << i; elementName = fieldNameStrm.str(); } - fieldOrder[i].FieldDefinition = {4, elementName, EbsdLib::NumericTypes::Type::Float}; + fieldOrder[i].FieldDefinition = {4, elementName, ebsdlib::NumericTypes::Type::Float}; fieldOrder[i].destinationPtr = nullptr; fieldOrder[i].readOffset = currentOffset; currentOffset += 4; diff --git a/Source/EbsdLib/IO/HKL/CprReader.h b/Source/EbsdLib/IO/HKL/CprReader.h index 88f56068..00a53bd5 100644 --- a/Source/EbsdLib/IO/HKL/CprReader.h +++ b/Source/EbsdLib/IO/HKL/CprReader.h @@ -23,14 +23,14 @@ { \ return static_cast(getPointerByName(#var)); \ } -namespace EbsdLib +namespace ebsdlib { struct CrcFieldDefinition { size_t ByteSize = 0; std::string FieldName; - EbsdLib::NumericTypes::Type numericType = EbsdLib::NumericTypes::Type::UnknownNumType; + ebsdlib::NumericTypes::Type numericType = ebsdlib::NumericTypes::Type::UnknownNumType; }; struct CrcDataParser @@ -48,7 +48,6 @@ struct CrcDataParser } }; -} // namespace EbsdLib /** * @brief This class can parse an Oxford Instruments .cpr/.crc file combination. * @@ -72,28 +71,28 @@ class EbsdLib_EXPORT CprReader : public EbsdReader using CtfIntHeaderType = CtfHeaderEntry; using CtfFloatHeaderType = CtfHeaderEntry; - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Channel, EbsdLib::Ctf::ChannelTextFile) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Prj, EbsdLib::Ctf::Prj) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Author, EbsdLib::Ctf::Author) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, JobMode, EbsdLib::Ctf::JobMode) - - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, XCells, EbsdLib::Ctf::xCells) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, YCells, EbsdLib::Ctf::yCells) - // EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, ZCells, EbsdLib::Ctf::ZCells) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, XStep, EbsdLib::Ctf::GridDistX) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, YStep, EbsdLib::Ctf::GridDistY) - // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, ZStep, EbsdLib::Ctf::ZStep) - // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE1, EbsdLib::Ctf::AcqE1) - // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE2, EbsdLib::Ctf::AcqE2) - // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE3, EbsdLib::Ctf::AcqE3) - // EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Euler, EbsdLib::Ctf::Euler) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Mag, EbsdLib::Ctf::Magnification) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Coverage, EbsdLib::Ctf::Coverage) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Device, EbsdLib::Ctf::Device) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, KV, EbsdLib::Ctf::kV) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAngle, EbsdLib::Ctf::TiltAngle) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAxis, EbsdLib::Ctf::TiltAxis) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, NumPhases, EbsdLib::Ctf::NumPhases) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Channel, ebsdlib::Ctf::ChannelTextFile) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Prj, ebsdlib::Ctf::Prj) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Author, ebsdlib::Ctf::Author) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, JobMode, ebsdlib::Ctf::JobMode) + + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, XCells, ebsdlib::Ctf::xCells) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, YCells, ebsdlib::Ctf::yCells) + // EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, ZCells, ebsdlib::Ctf::ZCells) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, XStep, ebsdlib::Ctf::GridDistX) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, YStep, ebsdlib::Ctf::GridDistY) + // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, ZStep, ebsdlib::Ctf::ZStep) + // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE1, ebsdlib::Ctf::AcqE1) + // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE2, ebsdlib::Ctf::AcqE2) + // EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE3, ebsdlib::Ctf::AcqE3) + // EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Euler, ebsdlib::Ctf::Euler) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Mag, ebsdlib::Ctf::Magnification) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Coverage, ebsdlib::Ctf::Coverage) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Device, ebsdlib::Ctf::Device) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, KV, ebsdlib::Ctf::kV) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAngle, ebsdlib::Ctf::TiltAngle) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAxis, ebsdlib::Ctf::TiltAxis) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, NumPhases, ebsdlib::Ctf::NumPhases) EBSD_INSTANCE_PROPERTY(std::vector, PhaseVector) CPR_READER_PTR_PROP(Phase, Phase, uint8_t) @@ -126,14 +125,14 @@ class EbsdLib_EXPORT CprReader : public EbsdReader * @brief Returns the types of data that each array holds. * @return */ - std::map getPointerTypes() const; + std::map getPointerTypes() const; /** * @brief Returns an enumeration value that depicts the numerical * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; int getTypeSize(const std::string& featureName); @@ -162,7 +161,7 @@ class EbsdLib_EXPORT CprReader : public EbsdReader void printHeader(std::ostream& out); - std::vector createFieldParsers(const std::string& filename); + std::vector createFieldParsers(const std::string& filename); private: int m_SingleSliceRead = -1; @@ -175,3 +174,4 @@ class EbsdLib_EXPORT CprReader : public EbsdReader CprReader& operator=(const CprReader&) = delete; // Copy Assignment Not Implemented CprReader& operator=(CprReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CtfConstants.h b/Source/EbsdLib/IO/HKL/CtfConstants.h index 95116629..dcdf002c 100644 --- a/Source/EbsdLib/IO/HKL/CtfConstants.h +++ b/Source/EbsdLib/IO/HKL/CtfConstants.h @@ -40,7 +40,7 @@ #define DECLARE_STRING_CONST(var) const std::string var(#var); -namespace EbsdLib +namespace ebsdlib { namespace H5Aztec @@ -278,4 +278,4 @@ const std::string ProcessedPatterns("Processed Patterns"); } // namespace H5OINA -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CtfFields.cpp b/Source/EbsdLib/IO/HKL/CtfFields.cpp index 0a55d90e..b041caf3 100644 --- a/Source/EbsdLib/IO/HKL/CtfFields.cpp +++ b/Source/EbsdLib/IO/HKL/CtfFields.cpp @@ -34,6 +34,8 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "CtfFields.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -50,22 +52,22 @@ CtfFields::~CtfFields() = default; std::vector CtfFields::getFieldNames() { std::vector features; - features.push_back(EbsdLib::Ctf::Phase); - features.push_back(EbsdLib::Ctf::X); - features.push_back(EbsdLib::Ctf::Y); - features.push_back(EbsdLib::Ctf::Z); - features.push_back(EbsdLib::Ctf::Bands); - features.push_back(EbsdLib::Ctf::Error); - features.push_back(EbsdLib::Ctf::Euler1); - features.push_back(EbsdLib::Ctf::Euler2); - features.push_back(EbsdLib::Ctf::Euler3); - features.push_back(EbsdLib::Ctf::MAD); - features.push_back(EbsdLib::Ctf::BC); - features.push_back(EbsdLib::Ctf::BS); - features.push_back(EbsdLib::Ctf::GrainIndex); - features.push_back(EbsdLib::Ctf::GrainRandomColourR); - features.push_back(EbsdLib::Ctf::GrainRandomColourG); - features.push_back(EbsdLib::Ctf::GrainRandomColourB); + features.push_back(ebsdlib::Ctf::Phase); + features.push_back(ebsdlib::Ctf::X); + features.push_back(ebsdlib::Ctf::Y); + features.push_back(ebsdlib::Ctf::Z); + features.push_back(ebsdlib::Ctf::Bands); + features.push_back(ebsdlib::Ctf::Error); + features.push_back(ebsdlib::Ctf::Euler1); + features.push_back(ebsdlib::Ctf::Euler2); + features.push_back(ebsdlib::Ctf::Euler3); + features.push_back(ebsdlib::Ctf::MAD); + features.push_back(ebsdlib::Ctf::BC); + features.push_back(ebsdlib::Ctf::BS); + features.push_back(ebsdlib::Ctf::GrainIndex); + features.push_back(ebsdlib::Ctf::GrainRandomColourR); + features.push_back(ebsdlib::Ctf::GrainRandomColourG); + features.push_back(ebsdlib::Ctf::GrainRandomColourB); return features; } diff --git a/Source/EbsdLib/IO/HKL/CtfFields.h b/Source/EbsdLib/IO/HKL/CtfFields.h index 83a58f28..e0e7ea70 100644 --- a/Source/EbsdLib/IO/HKL/CtfFields.h +++ b/Source/EbsdLib/IO/HKL/CtfFields.h @@ -44,6 +44,8 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/HKL/CtfConstants.h" +namespace ebsdlib +{ /** * @class CtfFields CtfFields.h EbsdLib/IO/HKL/CtfFields.h * @brief This class simply holds the names of the columns that are present in the @@ -72,22 +74,20 @@ class EbsdLib_EXPORT CtfFields : public AbstractEbsdFields T getFilterFeatures() { T features; - features.push_back(EbsdLib::Ctf::Bands); - features.push_back(EbsdLib::Ctf::Error); + features.push_back(ebsdlib::Ctf::Bands); + features.push_back(ebsdlib::Ctf::Error); - features.push_back(EbsdLib::Ctf::MAD); - features.push_back(EbsdLib::Ctf::BC); - features.push_back(EbsdLib::Ctf::BS); - features.push_back(EbsdLib::Ctf::X); - features.push_back(EbsdLib::Ctf::Y); + features.push_back(ebsdlib::Ctf::MAD); + features.push_back(ebsdlib::Ctf::BC); + features.push_back(ebsdlib::Ctf::BS); + features.push_back(ebsdlib::Ctf::X); + features.push_back(ebsdlib::Ctf::Y); return features; } -public: CtfFields(const CtfFields&) = delete; // Copy Constructor Not Implemented CtfFields(CtfFields&&) = delete; // Move Constructor Not Implemented CtfFields& operator=(const CtfFields&) = delete; // Copy Assignment Not Implemented CtfFields& operator=(CtfFields&&) = delete; // Move Assignment Not Implemented - -private: }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CtfHeaderEntry.h b/Source/EbsdLib/IO/HKL/CtfHeaderEntry.h index ef055cc9..8edf7220 100644 --- a/Source/EbsdLib/IO/HKL/CtfHeaderEntry.h +++ b/Source/EbsdLib/IO/HKL/CtfHeaderEntry.h @@ -51,6 +51,8 @@ using namespace H5Support; #endif +namespace ebsdlib +{ class Int32HeaderParser { public: @@ -271,3 +273,4 @@ class CtfStringHeaderEntry : public EbsdHeaderEntry CtfStringHeaderEntry& operator=(const CtfStringHeaderEntry&) = delete; // Copy Assignment Not Implemented CtfStringHeaderEntry& operator=(CtfStringHeaderEntry&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CtfPhase.cpp b/Source/EbsdLib/IO/HKL/CtfPhase.cpp index bfe4d4cf..193ab817 100644 --- a/Source/EbsdLib/IO/HKL/CtfPhase.cpp +++ b/Source/EbsdLib/IO/HKL/CtfPhase.cpp @@ -38,12 +38,14 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- CtfPhase::CtfPhase() : m_PhaseIndex(-1) -, m_LaueGroup(EbsdLib::Ctf::LaueGroupTable::LG_Cubic_Low) +, m_LaueGroup(ebsdlib::Ctf::LaueGroupTable::LG_Cubic_Low) , m_SpaceGroup(0) , m_PhaseName("-1") { @@ -96,7 +98,7 @@ void CtfPhase::parsePhase(const std::string& line) m_PhaseName = tokens[2]; // 4th set is the Symmetry group - m_LaueGroup = static_cast(std::stoi(tokens[3])); + m_LaueGroup = static_cast(std::stoi(tokens[3])); if(tokens.size() == 5) { @@ -116,14 +118,14 @@ void CtfPhase::parsePhase(const std::string& line) // ----------------------------------------------------------------------------- void CtfPhase::printSelf(std::ostream& stream) { - stream << EbsdLib::Ctf::LatticeConstants << " " << m_LatticeConstants[0] << ", " << m_LatticeConstants[1] << ", " << m_LatticeConstants[2] << " " << m_LatticeConstants[3] << ", " + stream << ebsdlib::Ctf::LatticeConstants << " " << m_LatticeConstants[0] << ", " << m_LatticeConstants[1] << ", " << m_LatticeConstants[2] << " " << m_LatticeConstants[3] << ", " << m_LatticeConstants[4] << ", " << m_LatticeConstants[5] << std::endl; - stream << EbsdLib::Ctf::PhaseName << " " << m_PhaseName << std::endl; - stream << EbsdLib::Ctf::LaueGroup << " " << m_LaueGroup << std::endl; - stream << EbsdLib::Ctf::SpaceGroup << " " << m_SpaceGroup << " " << LaueOps::GetOrientationOpsFromSpaceGroupNumber(m_SpaceGroup)->getSymmetryName() << std::endl; - stream << EbsdLib::Ctf::Internal1 << " " << m_Internal1 << std::endl; - stream << EbsdLib::Ctf::Internal2 << " " << m_Internal2 << std::endl; - stream << EbsdLib::Ctf::Comment << " " << m_Comment << std::endl; + stream << ebsdlib::Ctf::PhaseName << " " << m_PhaseName << std::endl; + stream << ebsdlib::Ctf::LaueGroup << " " << m_LaueGroup << std::endl; + stream << ebsdlib::Ctf::SpaceGroup << " " << m_SpaceGroup << " " << LaueOps::GetOrientationOpsFromSpaceGroupNumber(m_SpaceGroup)->getSymmetryName() << std::endl; + stream << ebsdlib::Ctf::Internal1 << " " << m_Internal1 << std::endl; + stream << ebsdlib::Ctf::Internal2 << " " << m_Internal2 << std::endl; + stream << ebsdlib::Ctf::Comment << " " << m_Comment << std::endl; } // ----------------------------------------------------------------------------- @@ -131,38 +133,38 @@ void CtfPhase::printSelf(std::ostream& stream) // ----------------------------------------------------------------------------- unsigned int CtfPhase::determineOrientationOpsIndex() { - EbsdLib::Ctf::LaueGroupTable symmetry = getLaueGroup(); + ebsdlib::Ctf::LaueGroupTable symmetry = getLaueGroup(); switch(symmetry) { - case EbsdLib::Ctf::LG_Triclinic: - return EbsdLib::CrystalStructure::Triclinic; - case EbsdLib::Ctf::LG_Monoclinic: - return EbsdLib::CrystalStructure::Monoclinic; - case EbsdLib::Ctf::LG_Orthorhombic: - return EbsdLib::CrystalStructure::OrthoRhombic; - case EbsdLib::Ctf::LG_Tetragonal_Low: - return EbsdLib::CrystalStructure::Tetragonal_Low; - case EbsdLib::Ctf::LG_Tetragonal_High: - return EbsdLib::CrystalStructure::Tetragonal_High; - case EbsdLib::Ctf::LG_Trigonal_Low: - return EbsdLib::CrystalStructure::Trigonal_Low; - case EbsdLib::Ctf::LG_Trigonal_High: - return EbsdLib::CrystalStructure::Trigonal_High; - case EbsdLib::Ctf::LG_Hexagonal_Low: - return EbsdLib::CrystalStructure::Hexagonal_Low; - case EbsdLib::Ctf::LG_Hexagonal_High: - return EbsdLib::CrystalStructure::Hexagonal_High; - case EbsdLib::Ctf::LG_Cubic_Low: - return EbsdLib::CrystalStructure::Cubic_Low; - case EbsdLib::Ctf::LG_Cubic_High: - return EbsdLib::CrystalStructure::Cubic_High; - case EbsdLib::Ctf::UnknownSymmetry: - return EbsdLib::CrystalStructure::UnknownCrystalStructure; + case ebsdlib::Ctf::LG_Triclinic: + return ebsdlib::CrystalStructure::Triclinic; + case ebsdlib::Ctf::LG_Monoclinic: + return ebsdlib::CrystalStructure::Monoclinic; + case ebsdlib::Ctf::LG_Orthorhombic: + return ebsdlib::CrystalStructure::OrthoRhombic; + case ebsdlib::Ctf::LG_Tetragonal_Low: + return ebsdlib::CrystalStructure::Tetragonal_Low; + case ebsdlib::Ctf::LG_Tetragonal_High: + return ebsdlib::CrystalStructure::Tetragonal_High; + case ebsdlib::Ctf::LG_Trigonal_Low: + return ebsdlib::CrystalStructure::Trigonal_Low; + case ebsdlib::Ctf::LG_Trigonal_High: + return ebsdlib::CrystalStructure::Trigonal_High; + case ebsdlib::Ctf::LG_Hexagonal_Low: + return ebsdlib::CrystalStructure::Hexagonal_Low; + case ebsdlib::Ctf::LG_Hexagonal_High: + return ebsdlib::CrystalStructure::Hexagonal_High; + case ebsdlib::Ctf::LG_Cubic_Low: + return ebsdlib::CrystalStructure::Cubic_Low; + case ebsdlib::Ctf::LG_Cubic_High: + return ebsdlib::CrystalStructure::Cubic_High; + case ebsdlib::Ctf::UnknownSymmetry: + return ebsdlib::CrystalStructure::UnknownCrystalStructure; default: break; } - return EbsdLib::CrystalStructure::UnknownCrystalStructure; + return ebsdlib::CrystalStructure::UnknownCrystalStructure; } // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/IO/HKL/CtfPhase.h b/Source/EbsdLib/IO/HKL/CtfPhase.h index 305f6521..a9d4f8b7 100644 --- a/Source/EbsdLib/IO/HKL/CtfPhase.h +++ b/Source/EbsdLib/IO/HKL/CtfPhase.h @@ -46,6 +46,8 @@ #include "CtfConstants.h" +namespace ebsdlib +{ /** * @class CtfPhase CtfPhase.h EbsdLib/IO/HKL/CtfPhase.h * @brief This class holds all the values for a "Phase" header block in an HKL .ctf file @@ -88,7 +90,7 @@ class EbsdLib_EXPORT CtfPhase */ std::string getPhaseName() const; - EBSD_INSTANCE_PROPERTY(EbsdLib::Ctf::LaueGroupTable, LaueGroup) // <== Laue Group + EBSD_INSTANCE_PROPERTY(ebsdlib::Ctf::LaueGroupTable, LaueGroup) // <== Laue Group EBSD_INSTANCE_PROPERTY(int, SpaceGroup) /** @@ -155,3 +157,4 @@ class EbsdLib_EXPORT CtfPhase std::string m_Internal2 = {}; std::string m_Comment = {}; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/CtfReader.cpp b/Source/EbsdLib/IO/HKL/CtfReader.cpp index 09b44ff7..d4ecb8c6 100644 --- a/Source/EbsdLib/IO/HKL/CtfReader.cpp +++ b/Source/EbsdLib/IO/HKL/CtfReader.cpp @@ -50,6 +50,8 @@ // #define TWO_PIf 360.0f // #define ONE_PIf 180.0f +using namespace ebsdlib; + namespace { std::istream& safeGetline(std::istream& is, std::string& t) @@ -96,27 +98,27 @@ CtfReader::CtfReader() { // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::Ctf::ChannelTextFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ChannelTextFile); - m_HeaderMap[EbsdLib::Ctf::Prj] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Prj); - m_HeaderMap[EbsdLib::Ctf::Author] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Author); - m_HeaderMap[EbsdLib::Ctf::JobMode] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::JobMode); - m_HeaderMap[EbsdLib::Ctf::XCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XCells); - m_HeaderMap[EbsdLib::Ctf::YCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YCells); - m_HeaderMap[EbsdLib::Ctf::ZCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ZCells); - m_HeaderMap[EbsdLib::Ctf::XStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XStep); - m_HeaderMap[EbsdLib::Ctf::YStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YStep); - m_HeaderMap[EbsdLib::Ctf::ZStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::ZStep); - m_HeaderMap[EbsdLib::Ctf::AcqE1] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE1); - m_HeaderMap[EbsdLib::Ctf::AcqE2] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE2); - m_HeaderMap[EbsdLib::Ctf::AcqE3] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::AcqE3); - m_HeaderMap[EbsdLib::Ctf::Euler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Euler); - m_HeaderMap[EbsdLib::Ctf::Mag] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Mag); - m_HeaderMap[EbsdLib::Ctf::Coverage] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Coverage); - m_HeaderMap[EbsdLib::Ctf::Device] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::Device); - m_HeaderMap[EbsdLib::Ctf::KV] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::KV); - m_HeaderMap[EbsdLib::Ctf::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::TiltAngle); - m_HeaderMap[EbsdLib::Ctf::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::TiltAxis); - m_HeaderMap[EbsdLib::Ctf::NumPhases] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::NumPhases); + m_HeaderMap[ebsdlib::Ctf::ChannelTextFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ChannelTextFile); + m_HeaderMap[ebsdlib::Ctf::Prj] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Prj); + m_HeaderMap[ebsdlib::Ctf::Author] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Author); + m_HeaderMap[ebsdlib::Ctf::JobMode] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::JobMode); + m_HeaderMap[ebsdlib::Ctf::XCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XCells); + m_HeaderMap[ebsdlib::Ctf::YCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YCells); + m_HeaderMap[ebsdlib::Ctf::ZCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ZCells); + m_HeaderMap[ebsdlib::Ctf::XStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XStep); + m_HeaderMap[ebsdlib::Ctf::YStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YStep); + m_HeaderMap[ebsdlib::Ctf::ZStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::ZStep); + m_HeaderMap[ebsdlib::Ctf::AcqE1] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE1); + m_HeaderMap[ebsdlib::Ctf::AcqE2] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE2); + m_HeaderMap[ebsdlib::Ctf::AcqE3] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::AcqE3); + m_HeaderMap[ebsdlib::Ctf::Euler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Euler); + m_HeaderMap[ebsdlib::Ctf::Mag] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Mag); + m_HeaderMap[ebsdlib::Ctf::Coverage] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Coverage); + m_HeaderMap[ebsdlib::Ctf::Device] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::Device); + m_HeaderMap[ebsdlib::Ctf::KV] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::KV); + m_HeaderMap[ebsdlib::Ctf::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::TiltAngle); + m_HeaderMap[ebsdlib::Ctf::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::TiltAxis); + m_HeaderMap[ebsdlib::Ctf::NumPhases] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::NumPhases); setXCells(0); setYCells(0); @@ -167,75 +169,75 @@ void* CtfReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type CtfReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type CtfReader::getPointerType(const std::string& featureName) { // std::cout << "featureName: " << featureName << std::endl; - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Z) + if(featureName == ebsdlib::Ctf::Z) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::Euler1) + if(featureName == ebsdlib::Ctf::Euler1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Euler2) + if(featureName == ebsdlib::Ctf::Euler2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Euler3) + if(featureName == ebsdlib::Ctf::Euler3) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainIndex) + if(featureName == ebsdlib::Ctf::GrainIndex) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourR) + if(featureName == ebsdlib::Ctf::GrainRandomColourR) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourG) + if(featureName == ebsdlib::Ctf::GrainRandomColourG) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::GrainRandomColourB) + if(featureName == ebsdlib::Ctf::GrainRandomColourB) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } // std::cout << "THIS IS NOT GOOD. Featurename: " << featureName << " was not found in the list" << std::endl; - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- @@ -243,67 +245,67 @@ EbsdLib::NumericTypes::Type CtfReader::getPointerType(const std::string& feature // ----------------------------------------------------------------------------- int CtfReader::getTypeSize(const std::string& featureName) { - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { return 4; } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { return 4; } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { return 4; } - if(featureName == EbsdLib::Ctf::Z) + if(featureName == ebsdlib::Ctf::Z) { return 4; } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { return 4; } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { return 4; } - if(featureName == EbsdLib::Ctf::Euler1) + if(featureName == ebsdlib::Ctf::Euler1) { return 4; } - if(featureName == EbsdLib::Ctf::Euler2) + if(featureName == ebsdlib::Ctf::Euler2) { return 4; } - if(featureName == EbsdLib::Ctf::Euler3) + if(featureName == ebsdlib::Ctf::Euler3) { return 4; } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { return 4; } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { return 4; } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { return 4; } - if(featureName == EbsdLib::Ctf::GrainIndex) + if(featureName == ebsdlib::Ctf::GrainIndex) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourR) + if(featureName == ebsdlib::Ctf::GrainRandomColourR) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourG) + if(featureName == ebsdlib::Ctf::GrainRandomColourG) { return 4; } - if(featureName == EbsdLib::Ctf::GrainRandomColourB) + if(featureName == ebsdlib::Ctf::GrainRandomColourB) { return 4; } @@ -316,67 +318,67 @@ int CtfReader::getTypeSize(const std::string& featureName) DataParser::Pointer CtfReader::getParser(const std::string& featureName, void* ptr, size_t size) { // These are defaulted to a "3D" CTF file with Feature IDS already determined and their colors - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { return Int32Parser::New(static_cast(ptr), size, featureName, 0); } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { return FloatParser::New(static_cast(ptr), size, featureName, 1); } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { return FloatParser::New(static_cast(ptr), size, featureName, 2); } - if(featureName == EbsdLib::Ctf::Z) + if(featureName == ebsdlib::Ctf::Z) { return FloatParser::New(static_cast(ptr), size, featureName, 3); } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { return Int32Parser::New(static_cast(ptr), size, featureName, 4); } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { return Int32Parser::New(static_cast(ptr), size, featureName, 5); } - if(featureName == EbsdLib::Ctf::Euler1) + if(featureName == ebsdlib::Ctf::Euler1) { return FloatParser::New(static_cast(ptr), size, featureName, 6); } - if(featureName == EbsdLib::Ctf::Euler2) + if(featureName == ebsdlib::Ctf::Euler2) { return FloatParser::New(static_cast(ptr), size, featureName, 7); } - if(featureName == EbsdLib::Ctf::Euler3) + if(featureName == ebsdlib::Ctf::Euler3) { return FloatParser::New(static_cast(ptr), size, featureName, 8); } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { return FloatParser::New(static_cast(ptr), size, featureName, 9); } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { return Int32Parser::New(static_cast(ptr), size, featureName, 10); } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { return Int32Parser::New(static_cast(ptr), size, featureName, 11); } - if(featureName == EbsdLib::Ctf::GrainIndex) + if(featureName == ebsdlib::Ctf::GrainIndex) { return Int32Parser::New(static_cast(ptr), size, featureName, 12); } - if(featureName == EbsdLib::Ctf::GrainRandomColourR) + if(featureName == ebsdlib::Ctf::GrainRandomColourR) { return Int32Parser::New(static_cast(ptr), size, featureName, 13); } - if(featureName == EbsdLib::Ctf::GrainRandomColourG) + if(featureName == ebsdlib::Ctf::GrainRandomColourG) { return Int32Parser::New(static_cast(ptr), size, featureName, 14); } - if(featureName == EbsdLib::Ctf::GrainRandomColourB) + if(featureName == ebsdlib::Ctf::GrainRandomColourB) { return Int32Parser::New(static_cast(ptr), size, featureName, 15); } @@ -522,7 +524,7 @@ int CtfReader::readData(std::ifstream& in) EbsdStringUtils::StringTokenType tokens = EbsdStringUtils::split(buf, '\t'); // Tokenize the array with a tab - EbsdLib::NumericTypes::Type pType = EbsdLib::NumericTypes::Type::UnknownNumType; + ebsdlib::NumericTypes::Type pType = ebsdlib::NumericTypes::Type::UnknownNumType; int32_t size = static_cast(tokens.size()); bool didAllocate = false; for(int32_t i = 0; i < size; ++i) @@ -537,7 +539,7 @@ int CtfReader::readData(std::ifstream& in) setErrorMessage(ss.str()); return -110; } - if(EbsdLib::NumericTypes::Type::Int32 == pType) + if(ebsdlib::NumericTypes::Type::Int32 == pType) { Int32Parser::Pointer dparser = Int32Parser::New(nullptr, totalScanPoints, name, i); didAllocate = dparser->allocateArray(totalScanPoints); @@ -548,7 +550,7 @@ int CtfReader::readData(std::ifstream& in) m_NamePointerMap[name] = dparser; } } - else if(EbsdLib::NumericTypes::Type::Float == pType) + else if(ebsdlib::NumericTypes::Type::Float == pType) { FloatParser::Pointer dparser = FloatParser::New(nullptr, totalScanPoints, name, i); didAllocate = dparser->allocateArray(totalScanPoints); @@ -679,7 +681,7 @@ int CtfReader::parseHeaderLines(std::vector& headerLines) PRINT_HTML_TABLE_ROW(p) } } - else if(line.find(EbsdLib::Ctf::NumPhases) == 0) + else if(line.find(ebsdlib::Ctf::NumPhases) == 0) { std::string key = tabTokens[0]; EbsdHeaderEntry::Pointer p = m_HeaderMap[key]; @@ -741,8 +743,8 @@ int CtfReader::parseHeaderLines(std::vector& headerLines) // std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper); // std::cout << "#define ANG_" << upper << " \"" << line[0] << "\"" << std::endl; // std::cout << "const std::string " << line[0] << "(ANG_" << upper << ");" << std::endl; - // std::cout << "angInstanceProperty(AngHeaderEntry. float, " << line[0] << "EbsdLib::Ctf::" << line[0] << std::endl; - // std::cout << "m_Headermap[EbsdLib::Ctf::" << line[0] << "] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::" << line[0] << ");" << std::endl; + // std::cout << "angInstanceProperty(AngHeaderEntry. float, " << line[0] << "ebsdlib::Ctf::" << line[0] << std::endl; + // std::cout << "m_Headermap[ebsdlib::Ctf::" << line[0] << "] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::" << line[0] << ");" << std::endl; } else { diff --git a/Source/EbsdLib/IO/HKL/CtfReader.h b/Source/EbsdLib/IO/HKL/CtfReader.h index 5b024b52..2c4bc974 100644 --- a/Source/EbsdLib/IO/HKL/CtfReader.h +++ b/Source/EbsdLib/IO/HKL/CtfReader.h @@ -56,6 +56,8 @@ return static_cast(getPointerByName(#var)); \ } +namespace ebsdlib +{ /** * @class CtfReader CtfReader.h EbsdLib/IO/HKL/CtfReader.h * @brief This class is a self contained HKL .ctf file reader and will read a @@ -81,27 +83,27 @@ class EbsdLib_EXPORT CtfReader : public EbsdReader static std::string ClassName(); using CtfIntHeaderType = CtfHeaderEntry; using CtfFloatHeaderType = CtfHeaderEntry; - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Channel, EbsdLib::Ctf::ChannelTextFile) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Prj, EbsdLib::Ctf::Prj) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Author, EbsdLib::Ctf::Author) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, JobMode, EbsdLib::Ctf::JobMode) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, XCells, EbsdLib::Ctf::XCells) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, YCells, EbsdLib::Ctf::YCells) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, ZCells, EbsdLib::Ctf::ZCells) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, XStep, EbsdLib::Ctf::XStep) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, YStep, EbsdLib::Ctf::YStep) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, ZStep, EbsdLib::Ctf::ZStep) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE1, EbsdLib::Ctf::AcqE1) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE2, EbsdLib::Ctf::AcqE2) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE3, EbsdLib::Ctf::AcqE3) - EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Euler, EbsdLib::Ctf::Euler) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Mag, EbsdLib::Ctf::Mag) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Coverage, EbsdLib::Ctf::Coverage) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Device, EbsdLib::Ctf::Device) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, KV, EbsdLib::Ctf::KV) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAngle, EbsdLib::Ctf::TiltAngle) - EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAxis, EbsdLib::Ctf::TiltAxis) - EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, NumPhases, EbsdLib::Ctf::NumPhases) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Channel, ebsdlib::Ctf::ChannelTextFile) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Prj, ebsdlib::Ctf::Prj) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Author, ebsdlib::Ctf::Author) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, JobMode, ebsdlib::Ctf::JobMode) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, XCells, ebsdlib::Ctf::XCells) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, YCells, ebsdlib::Ctf::YCells) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, ZCells, ebsdlib::Ctf::ZCells) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, XStep, ebsdlib::Ctf::XStep) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, YStep, ebsdlib::Ctf::YStep) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, ZStep, ebsdlib::Ctf::ZStep) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE1, ebsdlib::Ctf::AcqE1) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE2, ebsdlib::Ctf::AcqE2) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, AcqE3, ebsdlib::Ctf::AcqE3) + EBSDHEADER_INSTANCE_PROPERTY(CtfStringHeaderEntry, std::string, Euler, ebsdlib::Ctf::Euler) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Mag, ebsdlib::Ctf::Mag) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Coverage, ebsdlib::Ctf::Coverage) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, Device, ebsdlib::Ctf::Device) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, KV, ebsdlib::Ctf::KV) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAngle, ebsdlib::Ctf::TiltAngle) + EBSDHEADER_INSTANCE_PROPERTY(CtfFloatHeaderType, float, TiltAxis, ebsdlib::Ctf::TiltAxis) + EBSDHEADER_INSTANCE_PROPERTY(CtfIntHeaderType, int, NumPhases, ebsdlib::Ctf::NumPhases) EBSD_INSTANCE_PROPERTY(std::vector, PhaseVector) CTF_READER_PTR_PROP(Phase, Phase, int) @@ -135,7 +137,7 @@ class EbsdLib_EXPORT CtfReader : public EbsdReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; int getTypeSize(const std::string& featureName); DataParser::Pointer getParser(const std::string& featureName, void* ptr, size_t size); @@ -219,3 +221,4 @@ class EbsdLib_EXPORT CtfReader : public EbsdReader CtfReader& operator=(const CtfReader&) = delete; // Copy Assignment Not Implemented CtfReader& operator=(CtfReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/DataParser.hpp b/Source/EbsdLib/IO/HKL/DataParser.hpp index 3554954a..a304f905 100644 --- a/Source/EbsdLib/IO/HKL/DataParser.hpp +++ b/Source/EbsdLib/IO/HKL/DataParser.hpp @@ -40,6 +40,8 @@ #include "EbsdLib/Core/EbsdMacros.h" #include "EbsdLib/Core/EbsdSetGetMacros.h" +namespace ebsdlib +{ class DataParser { public: @@ -101,7 +103,7 @@ class DataParser { } - virtual EbsdLib::NumericTypes::Type getNumericType() const = 0; + virtual ebsdlib::NumericTypes::Type getNumericType() const = 0; protected: DataParser() @@ -149,9 +151,9 @@ class UInt8Parser : public DataParser return std::string("UInt8Parser"); } - EbsdLib::NumericTypes::Type getNumericType() const override + ebsdlib::NumericTypes::Type getNumericType() const override { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } int32_t IsA() const override @@ -260,9 +262,9 @@ class Int32Parser : public DataParser return std::string("Int32Parser"); } - EbsdLib::NumericTypes::Type getNumericType() const override + ebsdlib::NumericTypes::Type getNumericType() const override { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } int32_t IsA() const override @@ -369,9 +371,9 @@ class FloatParser : public DataParser return std::string("FloatParser"); } - EbsdLib::NumericTypes::Type getNumericType() const override + ebsdlib::NumericTypes::Type getNumericType() const override { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } int32_t IsA() const override @@ -550,3 +552,4 @@ class NumericParser : public DataParser NumericParser& operator=(const NumericParser&) = delete; // Copy Assignment Not Implemented NumericParser& operator=(NumericParser&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/H5CtfImporter.cpp b/Source/EbsdLib/IO/HKL/H5CtfImporter.cpp index d3f209db..38aaec7c 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfImporter.cpp +++ b/Source/EbsdLib/IO/HKL/H5CtfImporter.cpp @@ -46,6 +46,8 @@ using namespace H5Support; +using namespace ebsdlib; + #define AIM_STRING std::string #define CHECK_FOR_CANCELED(AClass) \ @@ -192,22 +194,22 @@ int H5CtfImporter::importFile(hid_t fileId, int64_t z, const std::string& ctfFil H5T_class_t type_class; size_t type_size = 0; hid_t attr_type = -1; - err = H5Lite::getAttributeInfo(fileId, "/", EbsdLib::H5Aztec::FileVersionStr, dims, type_class, type_size, attr_type); + err = H5Lite::getAttributeInfo(fileId, "/", ebsdlib::H5Aztec::FileVersionStr, dims, type_class, type_size, attr_type); if(attr_type < 0) // The attr_type variable was never set which means the attribute was NOT there { // The file version does not exist so write it to the file - err = H5Lite::writeScalarAttribute(fileId, std::string("/"), EbsdLib::H5Aztec::FileVersionStr, m_FileVersion); + err = H5Lite::writeScalarAttribute(fileId, std::string("/"), ebsdlib::H5Aztec::FileVersionStr, m_FileVersion); } else { H5Aclose(attr_type); } - err = H5Lite::getAttributeInfo(fileId, "/", EbsdLib::H5Aztec::EbsdLibVersionStr, dims, type_class, type_size, attr_type); + err = H5Lite::getAttributeInfo(fileId, "/", ebsdlib::H5Aztec::EbsdLibVersionStr, dims, type_class, type_size, attr_type); if(attr_type < 0) // The attr_type variable was never set which means the attribute was NOT there { // The file version does not exist so write it to the file - err = H5Lite::writeStringAttribute(fileId, std::string("/"), EbsdLib::H5Aztec::EbsdLibVersionStr, EbsdLib::Version::Complete()); + err = H5Lite::writeStringAttribute(fileId, std::string("/"), ebsdlib::H5Aztec::EbsdLibVersionStr, ebsdlib::Version::Complete()); } else { @@ -247,7 +249,7 @@ int H5CtfImporter::writeSliceData(hid_t fileId, CtfReader& reader, int z, int ac return -1; } - hid_t gid = H5Utilities::createGroup(ctfGroup, EbsdLib::H5Aztec::Header); + hid_t gid = H5Utilities::createGroup(ctfGroup, ebsdlib::H5Aztec::Header); if(gid < 0) { std::stringstream ss; @@ -259,39 +261,39 @@ int H5CtfImporter::writeSliceData(hid_t fileId, CtfReader& reader, int z, int ac return -1; } - WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Prj, EbsdLib::Ctf::Prj); - WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Author, EbsdLib::Ctf::Author); - WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, JobMode, EbsdLib::Ctf::JobMode); - WRITE_EBSD_HEADER_DATA(reader, int, XCells, EbsdLib::Ctf::XCells) + WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Prj, ebsdlib::Ctf::Prj); + WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Author, ebsdlib::Ctf::Author); + WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, JobMode, ebsdlib::Ctf::JobMode); + WRITE_EBSD_HEADER_DATA(reader, int, XCells, ebsdlib::Ctf::XCells) xDim = reader.getXCells(); - WRITE_EBSD_HEADER_DATA(reader, int, YCells, EbsdLib::Ctf::YCells) + WRITE_EBSD_HEADER_DATA(reader, int, YCells, ebsdlib::Ctf::YCells) yDim = reader.getYCells(); - WRITE_EBSD_HEADER_DATA(reader, float, XStep, EbsdLib::Ctf::XStep) + WRITE_EBSD_HEADER_DATA(reader, float, XStep, ebsdlib::Ctf::XStep) xRes = reader.getXStep(); - WRITE_EBSD_HEADER_DATA(reader, float, YStep, EbsdLib::Ctf::YStep) + WRITE_EBSD_HEADER_DATA(reader, float, YStep, ebsdlib::Ctf::YStep) yRes = reader.getYStep(); float* zPtr = reader.getZPointer(); if(nullptr != zPtr) { - WRITE_EBSD_HEADER_DATA(reader, int, ZCells, EbsdLib::Ctf::ZCells) + WRITE_EBSD_HEADER_DATA(reader, int, ZCells, ebsdlib::Ctf::ZCells) zDim = reader.getZCells(); - WRITE_EBSD_HEADER_DATA(reader, float, ZStep, EbsdLib::Ctf::ZStep) + WRITE_EBSD_HEADER_DATA(reader, float, ZStep, ebsdlib::Ctf::ZStep) zRes = reader.getZStep(); } - WRITE_EBSD_HEADER_DATA(reader, float, AcqE1, EbsdLib::Ctf::AcqE1); - WRITE_EBSD_HEADER_DATA(reader, float, AcqE2, EbsdLib::Ctf::AcqE2); - WRITE_EBSD_HEADER_DATA(reader, float, AcqE3, EbsdLib::Ctf::AcqE3); - WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Euler, EbsdLib::Ctf::Euler); - WRITE_EBSD_HEADER_DATA(reader, int, Mag, EbsdLib::Ctf::Mag); - WRITE_EBSD_HEADER_DATA(reader, int, Coverage, EbsdLib::Ctf::Coverage); - WRITE_EBSD_HEADER_DATA(reader, int, Device, EbsdLib::Ctf::Device); - WRITE_EBSD_HEADER_DATA(reader, int, KV, EbsdLib::Ctf::KV); - WRITE_EBSD_HEADER_DATA(reader, float, TiltAngle, EbsdLib::Ctf::TiltAngle); - WRITE_EBSD_HEADER_DATA(reader, float, TiltAxis, EbsdLib::Ctf::TiltAxis) - - hid_t phasesGid = H5Utilities::createGroup(gid, EbsdLib::H5Aztec::Phases); + WRITE_EBSD_HEADER_DATA(reader, float, AcqE1, ebsdlib::Ctf::AcqE1); + WRITE_EBSD_HEADER_DATA(reader, float, AcqE2, ebsdlib::Ctf::AcqE2); + WRITE_EBSD_HEADER_DATA(reader, float, AcqE3, ebsdlib::Ctf::AcqE3); + WRITE_EBSD_HEADER_STRING_DATA(reader, std::string, Euler, ebsdlib::Ctf::Euler); + WRITE_EBSD_HEADER_DATA(reader, int, Mag, ebsdlib::Ctf::Mag); + WRITE_EBSD_HEADER_DATA(reader, int, Coverage, ebsdlib::Ctf::Coverage); + WRITE_EBSD_HEADER_DATA(reader, int, Device, ebsdlib::Ctf::Device); + WRITE_EBSD_HEADER_DATA(reader, int, KV, ebsdlib::Ctf::KV); + WRITE_EBSD_HEADER_DATA(reader, float, TiltAngle, ebsdlib::Ctf::TiltAngle); + WRITE_EBSD_HEADER_DATA(reader, float, TiltAxis, ebsdlib::Ctf::TiltAxis) + + hid_t phasesGid = H5Utilities::createGroup(gid, ebsdlib::H5Aztec::Phases); if(phasesGid < 0) { std::stringstream ss; @@ -308,14 +310,14 @@ int H5CtfImporter::writeSliceData(hid_t fileId, CtfReader& reader, int z, int ac err = H5Gclose(phasesGid); std::string ctfCompleteHeader = reader.getOriginalHeader(); - err = H5Lite::writeStringDataset(gid, EbsdLib::H5Aztec::OriginalHeader, ctfCompleteHeader); - err = H5Lite::writeStringDataset(gid, EbsdLib::H5Aztec::OriginalFile, reader.getFileName()); + err = H5Lite::writeStringDataset(gid, ebsdlib::H5Aztec::OriginalHeader, ctfCompleteHeader); + err = H5Lite::writeStringDataset(gid, ebsdlib::H5Aztec::OriginalFile, reader.getFileName()); // Close the "Header" group err = H5Gclose(gid); // Create the "Data" group - gid = H5Utilities::createGroup(ctfGroup, EbsdLib::H5Aztec::Data); + gid = H5Utilities::createGroup(ctfGroup, ebsdlib::H5Aztec::Data); if(gid < 0) { std::stringstream ss; @@ -332,13 +334,13 @@ int H5CtfImporter::writeSliceData(hid_t fileId, CtfReader& reader, int z, int ac int32_t rank = 1; hsize_t dims[1] = {static_cast(reader.getXCells() * reader.getYCells())}; - EbsdLib::NumericTypes::Type numType = EbsdLib::NumericTypes::Type::UnknownNumType; + ebsdlib::NumericTypes::Type numType = ebsdlib::NumericTypes::Type::UnknownNumType; std::vector columnNames = reader.getColumnNames(); for(const std::string& name : columnNames) // for (int32_t i = 0; i < columnNames.size(); ++i) { numType = reader.getPointerType(name); - if(numType == EbsdLib::NumericTypes::Type::Int32) + if(numType == ebsdlib::NumericTypes::Type::Int32) { int32_t* dataPtr = static_cast(reader.getPointerByName(name)); if(nullptr == dataPtr) @@ -348,7 +350,7 @@ int H5CtfImporter::writeSliceData(hid_t fileId, CtfReader& reader, int z, int ac dataPtr = dataPtr + (actualSlice * dims[0]); // Put the pointer at the proper offset into the larger array WRITE_EBSD_DATA_ARRAY(reader, int, gid, name); } - else if(numType == EbsdLib::NumericTypes::Type::Float) + else if(numType == ebsdlib::NumericTypes::Type::Float) { float* dataPtr = static_cast(reader.getPointerByName(name)); if(nullptr == dataPtr) @@ -433,31 +435,31 @@ int H5CtfImporter::writePhaseData(CtfReader& reader, hid_t phasesGid) int32_t rank = 1; hsize_t dims[1] = {0}; std::vector phases = reader.getPhaseVector(); - EbsdLib::Ctf::LaueGroupStrings laueGroupStrings; + ebsdlib::Ctf::LaueGroupStrings laueGroupStrings; for(const CtfPhase::Pointer& phase : phases) // for (std::vector::iterator phase = phases.begin(); phase != phases.end(); ++phase ) { CtfPhase* p = phase.get(); hid_t pid = H5Utilities::createGroup(phasesGid, EbsdStringUtils::number(phase->getPhaseIndex())); - WRITE_PHASE_DATA_ARRAY(phase, float, pid, LatticeConstants, EbsdLib::Ctf::LatticeConstants); - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, PhaseName, EbsdLib::Ctf::PhaseName) - WRITE_PHASE_HEADER_DATA(phase, int, LaueGroup, EbsdLib::Ctf::LaueGroup) + WRITE_PHASE_DATA_ARRAY(phase, float, pid, LatticeConstants, ebsdlib::Ctf::LatticeConstants); + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, PhaseName, ebsdlib::Ctf::PhaseName) + WRITE_PHASE_HEADER_DATA(phase, int, LaueGroup, ebsdlib::Ctf::LaueGroup) - err = H5Lite::writeStringAttribute(pid, EbsdLib::Ctf::LaueGroup, "Name", laueGroupStrings.getString(p->getLaueGroup())); + err = H5Lite::writeStringAttribute(pid, ebsdlib::Ctf::LaueGroup, "Name", laueGroupStrings.getString(p->getLaueGroup())); if(err < 0) { std::stringstream ss; - ss << "H5CtfImporter Error: Could not write Ctf Attribute 'Name' to Dataset '" << EbsdLib::Ctf::LaueGroup << "'"; + ss << "H5CtfImporter Error: Could not write Ctf Attribute 'Name' to Dataset '" << ebsdlib::Ctf::LaueGroup << "'"; progressMessage(ss.str(), 100); err = H5Gclose(pid); return -1; } - WRITE_PHASE_HEADER_DATA(phase, int, SpaceGroup, EbsdLib::Ctf::SpaceGroup) - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Internal1, EbsdLib::Ctf::Internal1) - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Internal2, EbsdLib::Ctf::Internal2) - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Comment, EbsdLib::Ctf::Comment) + WRITE_PHASE_HEADER_DATA(phase, int, SpaceGroup, ebsdlib::Ctf::SpaceGroup) + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Internal1, ebsdlib::Ctf::Internal1) + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Internal2, ebsdlib::Ctf::Internal2) + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Comment, ebsdlib::Ctf::Comment) err = H5Gclose(pid); } return err; diff --git a/Source/EbsdLib/IO/HKL/H5CtfImporter.h b/Source/EbsdLib/IO/HKL/H5CtfImporter.h index be8ced25..d0e36175 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfImporter.h +++ b/Source/EbsdLib/IO/HKL/H5CtfImporter.h @@ -45,6 +45,8 @@ #include "EbsdLib/IO/HKL/CtfPhase.h" #include "EbsdLib/IO/HKL/CtfReader.h" +namespace ebsdlib +{ /** * @class H5CtfImporter H5CtfImporter.h EbsdLib/IO/HKL/H5CtfImporter.h * @brief This class will read a series of .ctf files and store the values into @@ -134,7 +136,7 @@ class EbsdLib_EXPORT H5CtfImporter : public EbsdImporter float yRes = 1.0f; float zRes = 1.0f; int m_NumSlicesImported = 1; - int m_FileVersion = EbsdLib::H5Aztec::FileVersion; + int m_FileVersion = ebsdlib::H5Aztec::FileVersion; public: H5CtfImporter(const H5CtfImporter&) = delete; // Copy Constructor Not Implemented @@ -142,3 +144,4 @@ class EbsdLib_EXPORT H5CtfImporter : public EbsdImporter H5CtfImporter& operator=(const H5CtfImporter&) = delete; // Copy Assignment Not Implemented H5CtfImporter& operator=(H5CtfImporter&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/H5CtfReader.cpp b/Source/EbsdLib/IO/HKL/H5CtfReader.cpp index 0d91cf0a..a2f0a795 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfReader.cpp +++ b/Source/EbsdLib/IO/HKL/H5CtfReader.cpp @@ -45,6 +45,8 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -222,32 +224,32 @@ int H5CtfReader::readHeader(hid_t parId) std::string sBuf; std::stringstream ss(sBuf); int err = -1; - hid_t gid = H5Gopen(parId, EbsdLib::H5Aztec::Header.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5Aztec::Header.c_str(), H5P_DEFAULT); if(gid < 0) { std::cout << "H5CtfReader Error: Could not open 'Header' Group"; return -1; } - READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Prj, EbsdLib::Ctf::Prj, gid) - READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Author, EbsdLib::Ctf::Author, gid) - READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, JobMode, EbsdLib::Ctf::JobMode, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, XCells, EbsdLib::Ctf::XCells, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, YCells, EbsdLib::Ctf::YCells, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, XStep, EbsdLib::Ctf::XStep, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, YStep, EbsdLib::Ctf::YStep, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE1, EbsdLib::Ctf::AcqE1, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE2, EbsdLib::Ctf::AcqE2, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE3, EbsdLib::Ctf::AcqE3, gid) - READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Euler, EbsdLib::Ctf::Euler, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Mag, EbsdLib::Ctf::Mag, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Coverage, EbsdLib::Ctf::Coverage, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Device, EbsdLib::Ctf::Device, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, KV, EbsdLib::Ctf::KV, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, TiltAngle, EbsdLib::Ctf::TiltAngle, gid) - READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, TiltAxis, EbsdLib::Ctf::TiltAxis, gid) - - hid_t phasesGid = H5Gopen(gid, EbsdLib::H5Aztec::Phases.c_str(), H5P_DEFAULT); + READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Prj, ebsdlib::Ctf::Prj, gid) + READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Author, ebsdlib::Ctf::Author, gid) + READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, JobMode, ebsdlib::Ctf::JobMode, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, XCells, ebsdlib::Ctf::XCells, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, YCells, ebsdlib::Ctf::YCells, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, XStep, ebsdlib::Ctf::XStep, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, YStep, ebsdlib::Ctf::YStep, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE1, ebsdlib::Ctf::AcqE1, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE2, ebsdlib::Ctf::AcqE2, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, AcqE3, ebsdlib::Ctf::AcqE3, gid) + READ_EBSD_HEADER_STRING_DATA("H5CtfReader", CtfStringHeaderEntry, std::string, Euler, ebsdlib::Ctf::Euler, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Mag, ebsdlib::Ctf::Mag, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Coverage, ebsdlib::Ctf::Coverage, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, Device, ebsdlib::Ctf::Device, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfIntHeaderType, int, KV, ebsdlib::Ctf::KV, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, TiltAngle, ebsdlib::Ctf::TiltAngle, gid) + READ_EBSD_HEADER_DATA("H5CtfReader", CtfFloatHeaderType, float, TiltAxis, ebsdlib::Ctf::TiltAxis, gid) + + hid_t phasesGid = H5Gopen(gid, ebsdlib::H5Aztec::Phases.c_str(), H5P_DEFAULT); if(phasesGid < 0) { setErrorCode(-90007); @@ -273,13 +275,13 @@ int H5CtfReader::readHeader(hid_t parId) hid_t pid = H5Gopen(phasesGid, phaseGroupName.c_str(), H5P_DEFAULT); CtfPhase::Pointer m_CurrentPhase = CtfPhase::New(); - READ_PHASE_HEADER_ARRAY("H5CtfReader", pid, float, EbsdLib::Ctf::LatticeConstants, LatticeConstants, m_CurrentPhase); - READ_PHASE_STRING_DATA("H5CtfReader", pid, EbsdLib::Ctf::PhaseName, PhaseName, m_CurrentPhase) - READ_PHASE_HEADER_DATA_CAST("H5CtfReader", pid, EbsdLib::Ctf::LaueGroupTable, int, EbsdLib::Ctf::LaueGroup, LaueGroup, m_CurrentPhase) - READ_PHASE_HEADER_DATA_CAST("H5CtfReader", pid, int, int, EbsdLib::Ctf::SpaceGroup, SpaceGroup, m_CurrentPhase) - READ_PHASE_STRING_DATA("H5CtfReader", pid, EbsdLib::Ctf::Internal1, Internal1, m_CurrentPhase) - READ_PHASE_STRING_DATA("H5CtfReader", pid, EbsdLib::Ctf::Internal2, Internal2, m_CurrentPhase) - READ_PHASE_STRING_DATA("H5CtfReader", pid, EbsdLib::Ctf::Comment, Comment, m_CurrentPhase) + READ_PHASE_HEADER_ARRAY("H5CtfReader", pid, float, ebsdlib::Ctf::LatticeConstants, LatticeConstants, m_CurrentPhase); + READ_PHASE_STRING_DATA("H5CtfReader", pid, ebsdlib::Ctf::PhaseName, PhaseName, m_CurrentPhase) + READ_PHASE_HEADER_DATA_CAST("H5CtfReader", pid, ebsdlib::Ctf::LaueGroupTable, int, ebsdlib::Ctf::LaueGroup, LaueGroup, m_CurrentPhase) + READ_PHASE_HEADER_DATA_CAST("H5CtfReader", pid, int, int, ebsdlib::Ctf::SpaceGroup, SpaceGroup, m_CurrentPhase) + READ_PHASE_STRING_DATA("H5CtfReader", pid, ebsdlib::Ctf::Internal1, Internal1, m_CurrentPhase) + READ_PHASE_STRING_DATA("H5CtfReader", pid, ebsdlib::Ctf::Internal2, Internal2, m_CurrentPhase) + READ_PHASE_STRING_DATA("H5CtfReader", pid, ebsdlib::Ctf::Comment, Comment, m_CurrentPhase) // For HKL Imports, the phase index is the HDF5 Group Name for this phase so // convert the phaseGroupName string variable into an integer @@ -290,7 +292,7 @@ int H5CtfReader::readHeader(hid_t parId) } std::string completeHeader; - err = H5Lite::readStringDataset(gid, EbsdLib::H5Aztec::OriginalHeader, completeHeader); + err = H5Lite::readStringDataset(gid, ebsdlib::H5Aztec::OriginalHeader, completeHeader); if(err < 0) { setErrorCode(-90010); @@ -319,7 +321,7 @@ int H5CtfReader::readData(hid_t parId) return -1; } - hid_t gid = H5Gopen(parId, EbsdLib::H5Aztec::Data.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5Aztec::Data.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorMessage("H5CtfReader Error: Could not open 'Data' Group"); @@ -342,23 +344,23 @@ int H5CtfReader::readData(hid_t parId) } // This data _SHOULD_ always be present in the file - ANG_READER_ALLOCATE_AND_READ(Phase, EbsdLib::Ctf::Phase, int); - ANG_READER_ALLOCATE_AND_READ(X, EbsdLib::Ctf::X, float); - ANG_READER_ALLOCATE_AND_READ(Y, EbsdLib::Ctf::Y, float); - ANG_READER_ALLOCATE_AND_READ(BandCount, EbsdLib::Ctf::Bands, int); - ANG_READER_ALLOCATE_AND_READ(Error, EbsdLib::Ctf::Error, int); - ANG_READER_ALLOCATE_AND_READ(Euler1, EbsdLib::Ctf::Euler1, float); - ANG_READER_ALLOCATE_AND_READ(Euler2, EbsdLib::Ctf::Euler2, float); - ANG_READER_ALLOCATE_AND_READ(Euler3, EbsdLib::Ctf::Euler3, float); - ANG_READER_ALLOCATE_AND_READ(MeanAngularDeviation, EbsdLib::Ctf::MAD, float); - ANG_READER_ALLOCATE_AND_READ(BandContrast, EbsdLib::Ctf::BC, int); - ANG_READER_ALLOCATE_AND_READ(BandSlope, EbsdLib::Ctf::BS, int); + ANG_READER_ALLOCATE_AND_READ(Phase, ebsdlib::Ctf::Phase, int); + ANG_READER_ALLOCATE_AND_READ(X, ebsdlib::Ctf::X, float); + ANG_READER_ALLOCATE_AND_READ(Y, ebsdlib::Ctf::Y, float); + ANG_READER_ALLOCATE_AND_READ(BandCount, ebsdlib::Ctf::Bands, int); + ANG_READER_ALLOCATE_AND_READ(Error, ebsdlib::Ctf::Error, int); + ANG_READER_ALLOCATE_AND_READ(Euler1, ebsdlib::Ctf::Euler1, float); + ANG_READER_ALLOCATE_AND_READ(Euler2, ebsdlib::Ctf::Euler2, float); + ANG_READER_ALLOCATE_AND_READ(Euler3, ebsdlib::Ctf::Euler3, float); + ANG_READER_ALLOCATE_AND_READ(MeanAngularDeviation, ebsdlib::Ctf::MAD, float); + ANG_READER_ALLOCATE_AND_READ(BandContrast, ebsdlib::Ctf::BC, int); + ANG_READER_ALLOCATE_AND_READ(BandSlope, ebsdlib::Ctf::BS, int); // This data is optional in the file. - ANG_READER_ALLOCATE_AND_READ(Z, EbsdLib::Ctf::Z, float); - ANG_READER_ALLOCATE_AND_READ(GrainIndex, EbsdLib::Ctf::GrainIndex, int); - ANG_READER_ALLOCATE_AND_READ(GrainRandomColourR, EbsdLib::Ctf::GrainRandomColourR, int); - ANG_READER_ALLOCATE_AND_READ(GrainRandomColourG, EbsdLib::Ctf::GrainRandomColourG, int); - ANG_READER_ALLOCATE_AND_READ(GrainRandomColourB, EbsdLib::Ctf::GrainRandomColourB, int); + ANG_READER_ALLOCATE_AND_READ(Z, ebsdlib::Ctf::Z, float); + ANG_READER_ALLOCATE_AND_READ(GrainIndex, ebsdlib::Ctf::GrainIndex, int); + ANG_READER_ALLOCATE_AND_READ(GrainRandomColourR, ebsdlib::Ctf::GrainRandomColourR, int); + ANG_READER_ALLOCATE_AND_READ(GrainRandomColourG, ebsdlib::Ctf::GrainRandomColourG, int); + ANG_READER_ALLOCATE_AND_READ(GrainRandomColourB, ebsdlib::Ctf::GrainRandomColourB, int); err = H5Gclose(gid); diff --git a/Source/EbsdLib/IO/HKL/H5CtfReader.h b/Source/EbsdLib/IO/HKL/H5CtfReader.h index b7e0d244..c2c6056b 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfReader.h +++ b/Source/EbsdLib/IO/HKL/H5CtfReader.h @@ -45,6 +45,8 @@ #include "EbsdLib/IO/HKL/CtfPhase.h" #include "EbsdLib/IO/HKL/CtfReader.h" +namespace ebsdlib +{ /** * @class H5CtfReader H5CtfReader EbsdLib/IO/HKL/H5CtfReader.h * @brief @@ -190,3 +192,4 @@ class EbsdLib_EXPORT H5CtfReader : public CtfReader H5CtfReader& operator=(const H5CtfReader&) = delete; // Copy Assignment Not Implemented H5CtfReader& operator=(H5CtfReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.cpp b/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.cpp index 0553cc75..caf6ef54 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.cpp +++ b/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.cpp @@ -46,6 +46,8 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -59,7 +61,7 @@ H5CtfVolumeReader::~H5CtfVolumeReader() } #define H5CTFREADER_ALLOCATE_ARRAY(name, type) \ - if(readAllArrays == true || arrayNames.find(EbsdLib::Ctf::name) != arrayNames.end()) \ + if(readAllArrays == true || arrayNames.find(ebsdlib::Ctf::name) != arrayNames.end()) \ { \ auto _##name = allocateArray(numElements); \ if(nullptr != _##name) \ @@ -116,47 +118,47 @@ void H5CtfVolumeReader::deletePointers() // ----------------------------------------------------------------------------- void* H5CtfVolumeReader::getPointerByName(const std::string& featureName) { - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { return static_cast(m_Phase); } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { return static_cast(m_X); } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { return static_cast(m_Y); } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { return static_cast(m_Bands); } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { return static_cast(m_Error); } - if(featureName == EbsdLib::Ctf::Euler1) + if(featureName == ebsdlib::Ctf::Euler1) { return static_cast(m_Euler1); } - if(featureName == EbsdLib::Ctf::Euler2) + if(featureName == ebsdlib::Ctf::Euler2) { return static_cast(m_Euler2); } - if(featureName == EbsdLib::Ctf::Euler3) + if(featureName == ebsdlib::Ctf::Euler3) { return static_cast(m_Euler3); } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { return static_cast(m_MAD); } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { return static_cast(m_BC); } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { return static_cast(m_BS); } @@ -166,53 +168,53 @@ void* H5CtfVolumeReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type H5CtfVolumeReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type H5CtfVolumeReader::getPointerType(const std::string& featureName) { - if(featureName == EbsdLib::Ctf::Phase) + if(featureName == ebsdlib::Ctf::Phase) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::X) + if(featureName == ebsdlib::Ctf::X) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Y) + if(featureName == ebsdlib::Ctf::Y) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Bands) + if(featureName == ebsdlib::Ctf::Bands) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::Error) + if(featureName == ebsdlib::Ctf::Error) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::Euler1) + if(featureName == ebsdlib::Ctf::Euler1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Euler2) + if(featureName == ebsdlib::Ctf::Euler2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::Euler3) + if(featureName == ebsdlib::Ctf::Euler3) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::MAD) + if(featureName == ebsdlib::Ctf::MAD) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ctf::BC) + if(featureName == ebsdlib::Ctf::BC) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ctf::BS) + if(featureName == ebsdlib::Ctf::BS) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- @@ -355,7 +357,7 @@ int H5CtfVolumeReader::loadData(int64_t xpoints, int64_t ypoints, int64_t zpoint ystartspot = static_cast((ypointstemp - ypointsslice) / 2); // If no stacking order preference was passed, read it from the file and use that value - if(ZDir == EbsdLib::RefFrameZDir::UnknownRefFrameZDirection) + if(ZDir == ebsdlib::RefFrameZDir::UnknownRefFrameZDirection) { ZDir = getStackingOrder(); } diff --git a/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.h b/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.h index 2bcddbe0..5a1a3676 100644 --- a/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.h +++ b/Source/EbsdLib/IO/HKL/H5CtfVolumeReader.h @@ -45,6 +45,8 @@ #include "EbsdLib/IO/H5EbsdVolumeReader.h" #include "EbsdLib/IO/HKL/CtfPhase.h" +namespace ebsdlib +{ /** * @class H5CtfVolumeReader H5CtfVolumeReader.h Reconstruction/EbsdSupport/H5CtfVolumeReader.h * @brief This class loads EBSD data from an HDF5 based file. @@ -131,7 +133,7 @@ class EbsdLib_EXPORT H5CtfVolumeReader : public H5EbsdVolumeReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; /** @brief Allocates the proper amount of memory (after reading the header portion of the file) * and then splats '0' across all the bytes of the memory allocation @@ -195,3 +197,4 @@ class EbsdLib_EXPORT H5CtfVolumeReader : public H5EbsdVolumeReader H5CtfVolumeReader& operator=(const H5CtfVolumeReader&) = delete; // Copy Assignment Not Implemented H5CtfVolumeReader& operator=(H5CtfVolumeReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/HKL/H5OINAReader.cpp b/Source/EbsdLib/IO/HKL/H5OINAReader.cpp index d9840fc7..6e1c99bb 100644 --- a/Source/EbsdLib/IO/HKL/H5OINAReader.cpp +++ b/Source/EbsdLib/IO/HKL/H5OINAReader.cpp @@ -49,30 +49,32 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- H5OINAReader::H5OINAReader() { m_HeaderMap.clear(); // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::H5OINA::AcquisitionData] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::AcquisitionData); - m_HeaderMap[EbsdLib::H5OINA::AcquisitionSpeed] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::AcquisitionSpeed); - m_HeaderMap[EbsdLib::H5OINA::AcquisitionTime] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::AcquisitionTime); - m_HeaderMap[EbsdLib::H5OINA::BeamVoltage] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::BeamVoltage); - m_HeaderMap[EbsdLib::H5OINA::DetectorOrientationEuler] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::DetectorOrientationEuler); - m_HeaderMap[EbsdLib::H5OINA::Magnification] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::Magnification); - m_HeaderMap[EbsdLib::H5OINA::ProjectFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::ProjectFile); - m_HeaderMap[EbsdLib::H5OINA::ProjectLabel] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::ProjectLabel); - m_HeaderMap[EbsdLib::H5OINA::ProjectNotes] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::ProjectNotes); - m_HeaderMap[EbsdLib::H5OINA::ScanningRotationAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::ScanningRotationAngle); - m_HeaderMap[EbsdLib::H5OINA::SiteNotes] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::SiteNotes); - m_HeaderMap[EbsdLib::H5OINA::SpecimenOrientationEuler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::SpecimenOrientationEuler); - m_HeaderMap[EbsdLib::H5OINA::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::TiltAxis); - m_HeaderMap[EbsdLib::H5OINA::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::H5OINA::TiltAngle); - - m_HeaderMap[EbsdLib::Ctf::XCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XCells); - m_HeaderMap[EbsdLib::Ctf::XStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::XStep); - m_HeaderMap[EbsdLib::Ctf::YCells] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YCells); - m_HeaderMap[EbsdLib::Ctf::YStep] = CtfHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ctf::YStep); + m_HeaderMap[ebsdlib::H5OINA::AcquisitionData] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::AcquisitionData); + m_HeaderMap[ebsdlib::H5OINA::AcquisitionSpeed] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::AcquisitionSpeed); + m_HeaderMap[ebsdlib::H5OINA::AcquisitionTime] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::AcquisitionTime); + m_HeaderMap[ebsdlib::H5OINA::BeamVoltage] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::BeamVoltage); + m_HeaderMap[ebsdlib::H5OINA::DetectorOrientationEuler] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::DetectorOrientationEuler); + m_HeaderMap[ebsdlib::H5OINA::Magnification] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::Magnification); + m_HeaderMap[ebsdlib::H5OINA::ProjectFile] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::ProjectFile); + m_HeaderMap[ebsdlib::H5OINA::ProjectLabel] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::ProjectLabel); + m_HeaderMap[ebsdlib::H5OINA::ProjectNotes] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::ProjectNotes); + m_HeaderMap[ebsdlib::H5OINA::ScanningRotationAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::ScanningRotationAngle); + m_HeaderMap[ebsdlib::H5OINA::SiteNotes] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::SiteNotes); + m_HeaderMap[ebsdlib::H5OINA::SpecimenOrientationEuler] = CtfStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::SpecimenOrientationEuler); + m_HeaderMap[ebsdlib::H5OINA::TiltAxis] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::TiltAxis); + m_HeaderMap[ebsdlib::H5OINA::TiltAngle] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::H5OINA::TiltAngle); + + m_HeaderMap[ebsdlib::Ctf::XCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XCells); + m_HeaderMap[ebsdlib::Ctf::XStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::XStep); + m_HeaderMap[ebsdlib::Ctf::YCells] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YCells); + m_HeaderMap[ebsdlib::Ctf::YStep] = CtfHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ctf::YStep); } // ----------------------------------------------------------------------------- @@ -115,39 +117,39 @@ void H5OINAReader::setYDimension(int ydim) void* H5OINAReader::getPointerByName(const std::string& featureName) { void* ptr = nullptr; - if(featureName == EbsdLib::H5OINA::BandContrast) + if(featureName == ebsdlib::H5OINA::BandContrast) { return m_BandContrast.data(); } - if(featureName == EbsdLib::H5OINA::BandSlope) + if(featureName == ebsdlib::H5OINA::BandSlope) { return m_BandSlope.data(); } - if(featureName == EbsdLib::H5OINA::Bands) + if(featureName == ebsdlib::H5OINA::Bands) { return m_Bands.data(); } - if(featureName == EbsdLib::H5OINA::Error) + if(featureName == ebsdlib::H5OINA::Error) { return m_Error.data(); } - if(featureName == EbsdLib::H5OINA::Euler) + if(featureName == ebsdlib::H5OINA::Euler) { return m_Euler.data(); } - if(featureName == EbsdLib::H5OINA::MeanAngularDeviation) + if(featureName == ebsdlib::H5OINA::MeanAngularDeviation) { return m_MeanAngularDeviation.data(); } - if(featureName == EbsdLib::H5OINA::Phase) + if(featureName == ebsdlib::H5OINA::Phase) { return m_Phase.data(); } - if(featureName == EbsdLib::H5OINA::X) + if(featureName == ebsdlib::H5OINA::X) { return m_X.data(); } - if(featureName == EbsdLib::H5OINA::Y) + if(featureName == ebsdlib::H5OINA::Y) { return m_Y.data(); } @@ -158,48 +160,48 @@ void* H5OINAReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type H5OINAReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type H5OINAReader::getPointerType(const std::string& featureName) { // std::cout << "featureName: " << featureName << std::endl; - if(featureName == EbsdLib::H5OINA::BandContrast) + if(featureName == ebsdlib::H5OINA::BandContrast) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::H5OINA::BandSlope) + if(featureName == ebsdlib::H5OINA::BandSlope) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::H5OINA::Bands) + if(featureName == ebsdlib::H5OINA::Bands) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::H5OINA::Error) + if(featureName == ebsdlib::H5OINA::Error) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::H5OINA::Euler) + if(featureName == ebsdlib::H5OINA::Euler) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5OINA::MeanAngularDeviation) + if(featureName == ebsdlib::H5OINA::MeanAngularDeviation) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5OINA::Phase) + if(featureName == ebsdlib::H5OINA::Phase) { - return EbsdLib::NumericTypes::Type::UInt8; + return ebsdlib::NumericTypes::Type::UInt8; } - if(featureName == EbsdLib::H5OINA::X) + if(featureName == ebsdlib::H5OINA::X) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::H5OINA::Y) + if(featureName == ebsdlib::H5OINA::Y) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } // std::cout << "THIS IS NOT GOOD. Featurename: " << featureName << " was not found in the list" << std::endl; - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } void H5OINAReader::setReadPatternData(bool value) @@ -243,7 +245,7 @@ int H5OINAReader::readFile() return err; } - err = H5Support::H5Lite::readStringDataset(fileId, EbsdLib::H5OINA::FormatVersion, m_OINAVersion); + err = H5Support::H5Lite::readStringDataset(fileId, ebsdlib::H5OINA::FormatVersion, m_OINAVersion); if(err < 0) { } @@ -261,7 +263,7 @@ int H5OINAReader::readFile() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5OINA::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5OINA::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { std::string str; @@ -311,11 +313,11 @@ int H5OINAReader::readFile() // { // void* oldArray = getPointerByName(arrayName); // - // if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Float) + // if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Float) // { // CopyTupleUsingIndexList(oldArray, indexMap); // } - // else if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Int32) + // else if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Int32) // { // CopyTupleUsingIndexList(oldArray, indexMap); // } @@ -375,9 +377,9 @@ int H5OINAReader::readHeaderOnly() } // Read and parse the OINA Format Version. - if(H5Lite::datasetExists(fileId, EbsdLib::H5OINA::FormatVersion)) + if(H5Lite::datasetExists(fileId, ebsdlib::H5OINA::FormatVersion)) { - err = H5Lite::readStringDataset(fileId, EbsdLib::H5OINA::FormatVersion, m_OINAVersion); + err = H5Lite::readStringDataset(fileId, ebsdlib::H5OINA::FormatVersion, m_OINAVersion); } hid_t gid = H5Gopen(fileId, m_HDF5Path.c_str(), H5P_DEFAULT); @@ -392,7 +394,7 @@ int H5OINAReader::readHeaderOnly() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5OINA::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5OINA::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { setErrorMessage("H5OINAReader Error: Could not open 'EBSD' Group"); @@ -483,7 +485,7 @@ int H5OINAReader::readHeader(hid_t parId) using CtfHeaderIntType = CtfHeaderEntry; int err = -1; - hid_t gid = H5Gopen(parId, EbsdLib::H5OINA::Header.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OINA::Header.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorCode(-90008); @@ -492,28 +494,28 @@ int H5OINAReader::readHeader(hid_t parId) } H5ScopedGroupSentinel sentinel(gid, false); - ReadH5OINAHeaderScalarValue(this, EbsdLib::H5OINA::XCells, gid, m_XCells); - ReadH5OINAHeaderScalarValue(this, EbsdLib::H5OINA::XStep, gid, m_XStep); - ReadH5OINAHeaderScalarValue(this, EbsdLib::H5OINA::YCells, gid, m_YCells); - ReadH5OINAHeaderScalarValue(this, EbsdLib::H5OINA::YStep, gid, m_YStep); + ReadH5OINAHeaderScalarValue(this, ebsdlib::H5OINA::XCells, gid, m_XCells); + ReadH5OINAHeaderScalarValue(this, ebsdlib::H5OINA::XStep, gid, m_XStep); + ReadH5OINAHeaderScalarValue(this, ebsdlib::H5OINA::YCells, gid, m_YCells); + ReadH5OINAHeaderScalarValue(this, ebsdlib::H5OINA::YStep, gid, m_YStep); setNumberOfElements(getXCells() * getYCells()); // Figure out the Format version - if(m_OINAVersion.find(EbsdLib::H5OINA::FormatVersion_2) != std::string::npos) + if(m_OINAVersion.find(ebsdlib::H5OINA::FormatVersion_2) != std::string::npos) { } - if(m_OINAVersion.find(EbsdLib::H5OINA::FormatVersion_3) != std::string::npos) + if(m_OINAVersion.find(ebsdlib::H5OINA::FormatVersion_3) != std::string::npos) { } - if(m_OINAVersion.find(EbsdLib::H5OINA::FormatVersion_4) != std::string::npos) + if(m_OINAVersion.find(ebsdlib::H5OINA::FormatVersion_4) != std::string::npos) { } - if(m_OINAVersion.find(EbsdLib::H5OINA::FormatVersion_5) != std::string::npos) + if(m_OINAVersion.find(ebsdlib::H5OINA::FormatVersion_5) != std::string::npos) { } - hid_t phasesGid = H5Gopen(gid, EbsdLib::H5OINA::Phases.c_str(), H5P_DEFAULT); + hid_t phasesGid = H5Gopen(gid, ebsdlib::H5OINA::Phases.c_str(), H5P_DEFAULT); if(phasesGid < 0) { setErrorCode(-90007); @@ -543,22 +545,22 @@ int H5OINAReader::readHeader(hid_t parId) CtfPhase::Pointer currentPhase = CtfPhase::New(); currentPhase->setPhaseIndex(std::stoi(phaseGroupName)); - READ_PHASE_STRING_DATA("H5OINAReader", pid, EbsdLib::H5OINA::PhaseName, PhaseName, currentPhase) + READ_PHASE_STRING_DATA("H5OINAReader", pid, ebsdlib::H5OINA::PhaseName, PhaseName, currentPhase) std::vector latticeConstants; - err = H5Support::H5Lite::readVectorDataset(pid, EbsdLib::H5OINA::LatticeDimensions, latticeConstants); + err = H5Support::H5Lite::readVectorDataset(pid, ebsdlib::H5OINA::LatticeDimensions, latticeConstants); std::vector latticeAngles; - err = H5Support::H5Lite::readVectorDataset(pid, EbsdLib::H5OINA::LatticeAngles, latticeAngles); + err = H5Support::H5Lite::readVectorDataset(pid, ebsdlib::H5OINA::LatticeAngles, latticeAngles); currentPhase->setLatticeConstants({latticeConstants[0], latticeConstants[1], latticeConstants[2], latticeAngles[0], latticeAngles[1], latticeAngles[1]}); int laueGroup = 0; - err = H5Support::H5Lite::readScalarDataset(pid, EbsdLib::H5OINA::LaueGroup, laueGroup); - currentPhase->setLaueGroup(static_cast(laueGroup)); + err = H5Support::H5Lite::readScalarDataset(pid, ebsdlib::H5OINA::LaueGroup, laueGroup); + currentPhase->setLaueGroup(static_cast(laueGroup)); int spaceGroup = 0; - err = H5Support::H5Lite::readScalarDataset(pid, EbsdLib::H5OINA::SpaceGroup, spaceGroup); + err = H5Support::H5Lite::readScalarDataset(pid, ebsdlib::H5OINA::SpaceGroup, spaceGroup); currentPhase->setSpaceGroup(spaceGroup); phaseVector.push_back(currentPhase); @@ -619,7 +621,7 @@ int H5OINAReader::readData(hid_t parId) return -301; } - hid_t gid = H5Gopen(parId, EbsdLib::H5OINA::Data.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OINA::Data.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorMessage("H5OINAReader Error: Could not open 'Data' Group"); @@ -640,47 +642,47 @@ int H5OINAReader::readData(hid_t parId) return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::BandContrast, m_BandContrast); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::BandContrast, m_BandContrast); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::BandSlope, m_BandSlope); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::BandSlope, m_BandSlope); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::Bands, m_Bands); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::Bands, m_Bands); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::Error, m_Error); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::Error, m_Error); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::Euler, m_Euler); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::Euler, m_Euler); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::MeanAngularDeviation, m_MeanAngularDeviation); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::MeanAngularDeviation, m_MeanAngularDeviation); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::Phase, m_Phase); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::Phase, m_Phase); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::X, m_X); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::X, m_X); if(err < 0) { return err; } - err = AllocateAndReadData(this, gid, EbsdLib::H5OINA::Y, m_Y); + err = AllocateAndReadData(this, gid, ebsdlib::H5OINA::Y, m_Y); if(err < 0) { return err; @@ -690,7 +692,7 @@ int H5OINAReader::readData(hid_t parId) // H5T_class_t type_class; // std::vector dims; // size_t type_size = 0; - // err = H5Lite::getDatasetInfo(gid, EbsdLib::Ctf::PatternData, dims, type_class, type_size); + // err = H5Lite::getDatasetInfo(gid, ebsdlib::Ctf::PatternData, dims, type_class, type_size); // if(err >= 0) // Only read the pattern data if the pattern data is available. // { // totalDataRows = 1; // Calculate the total number of elements to allocate for the pattern data @@ -703,7 +705,7 @@ int H5OINAReader::readData(hid_t parId) // m_PatternDims[1] = static_cast(dims[2]); // // m_PatternData = this->allocateArray(totalDataRows); - // err = H5Lite::readPointerDataset(gid, EbsdLib::Ctf::PatternData, m_PatternData); + // err = H5Lite::readPointerDataset(gid, ebsdlib::Ctf::PatternData, m_PatternData); // } // } err = H5Gclose(gid); diff --git a/Source/EbsdLib/IO/HKL/H5OINAReader.h b/Source/EbsdLib/IO/HKL/H5OINAReader.h index c6ef77d0..c85c9a39 100644 --- a/Source/EbsdLib/IO/HKL/H5OINAReader.h +++ b/Source/EbsdLib/IO/HKL/H5OINAReader.h @@ -70,6 +70,8 @@ public: return m_##name.data(); \ } +namespace ebsdlib +{ class EbsdLib_EXPORT H5OINAReader : public EbsdReader { @@ -136,7 +138,7 @@ class EbsdLib_EXPORT H5OINAReader : public EbsdReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; /** * @brief Returns the name of the class for H5OINAReader @@ -252,3 +254,4 @@ class EbsdLib_EXPORT H5OINAReader : public EbsdReader std::set m_ArrayNames; bool m_ReadAllArrays = true; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/AngConstants.h b/Source/EbsdLib/IO/TSL/AngConstants.h index ad0b4672..49de8f28 100644 --- a/Source/EbsdLib/IO/TSL/AngConstants.h +++ b/Source/EbsdLib/IO/TSL/AngConstants.h @@ -129,7 +129,7 @@ enum ANG_READ_FLAG ANG_HEADER_ONLY }; -namespace EbsdLib +namespace ebsdlib { namespace H5OIM @@ -374,13 +374,13 @@ const std::string ColumnHeaders(COLUMN_HEADERS); const std::string ColumnUnits(COLUMN_UNITS); } // namespace Ang -} // namespace EbsdLib +} // namespace ebsdlib #if 1 // ----------------------------------------------------------------------------- // These are the lower case versions of the constants for the ANG file // ----------------------------------------------------------------------------- -#define ANG_TEM_PIXPERUM_LOWER "teEbsdLib::Constants::k_Pixperum" +#define ANG_TEM_PIXPERUM_LOWER "teebsdlib::constants::k_Pixperum" #define ANG_X_STAR_LOWER "x-star" #define ANG_Y_STAR_LOWER "y-star" #define ANG_Z_STAR_LOWER "z-star" @@ -422,7 +422,7 @@ const std::string ColumnUnits(COLUMN_UNITS); #define ANG_SEM_SIGNAL_LOWER "sem signal" #define ANG_FIT_LOWER "fit" -namespace EbsdLib +namespace ebsdlib { namespace Ang @@ -483,5 +483,5 @@ const std::string MaterialName("MaterialName"); const std::string LatticeConstants("LatticeConstants"); const std::string BravaisLattice("BravaisLattice"); } // namespace AngFile -} // namespace EbsdLib +} // namespace ebsdlib #endif diff --git a/Source/EbsdLib/IO/TSL/AngFields.cpp b/Source/EbsdLib/IO/TSL/AngFields.cpp index 2cac7e32..202e2f29 100644 --- a/Source/EbsdLib/IO/TSL/AngFields.cpp +++ b/Source/EbsdLib/IO/TSL/AngFields.cpp @@ -35,6 +35,8 @@ #include "AngFields.h" #include "AngConstants.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -51,16 +53,16 @@ AngFields::~AngFields() = default; std::vector AngFields::getFieldNames() { std::vector features; - features.push_back(EbsdLib::Ang::Phi1); - features.push_back(EbsdLib::Ang::Phi); - features.push_back(EbsdLib::Ang::Phi2); - features.push_back(EbsdLib::Ang::XPosition); - features.push_back(EbsdLib::Ang::YPosition); - features.push_back(EbsdLib::Ang::ImageQuality); - features.push_back(EbsdLib::Ang::ConfidenceIndex); - features.push_back(EbsdLib::Ang::PhaseData); - features.push_back(EbsdLib::Ang::SEMSignal); - features.push_back(EbsdLib::Ang::Fit); + features.push_back(ebsdlib::Ang::Phi1); + features.push_back(ebsdlib::Ang::Phi); + features.push_back(ebsdlib::Ang::Phi2); + features.push_back(ebsdlib::Ang::XPosition); + features.push_back(ebsdlib::Ang::YPosition); + features.push_back(ebsdlib::Ang::ImageQuality); + features.push_back(ebsdlib::Ang::ConfidenceIndex); + features.push_back(ebsdlib::Ang::PhaseData); + features.push_back(ebsdlib::Ang::SEMSignal); + features.push_back(ebsdlib::Ang::Fit); return features; } diff --git a/Source/EbsdLib/IO/TSL/AngFields.h b/Source/EbsdLib/IO/TSL/AngFields.h index 12b3d88f..deda0ead 100644 --- a/Source/EbsdLib/IO/TSL/AngFields.h +++ b/Source/EbsdLib/IO/TSL/AngFields.h @@ -44,6 +44,8 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/TSL/AngConstants.h" +namespace ebsdlib +{ /** * @class AngFields AngFields.h EbsdLib/IO/TSL/AngFields.h * @brief This class simply holds the names of the columns that are present in the @@ -65,18 +67,18 @@ class EbsdLib_EXPORT AngFields : public AbstractEbsdFields { T features; - features.push_back(EbsdLib::Ang::ImageQuality); - features.push_back(EbsdLib::Ang::ConfidenceIndex); - features.push_back(EbsdLib::Ang::SEMSignal); - features.push_back(EbsdLib::Ang::Fit); - features.push_back(EbsdLib::Ang::XPosition); - features.push_back(EbsdLib::Ang::YPosition); + features.push_back(ebsdlib::Ang::ImageQuality); + features.push_back(ebsdlib::Ang::ConfidenceIndex); + features.push_back(ebsdlib::Ang::SEMSignal); + features.push_back(ebsdlib::Ang::Fit); + features.push_back(ebsdlib::Ang::XPosition); + features.push_back(ebsdlib::Ang::YPosition); return features; } -public: AngFields(const AngFields&) = delete; // Copy Constructor Not Implemented AngFields(AngFields&&) = delete; // Move Constructor Not Implemented AngFields& operator=(const AngFields&) = delete; // Copy Assignment Not Implemented AngFields& operator=(AngFields&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/AngHeaderEntry.h b/Source/EbsdLib/IO/TSL/AngHeaderEntry.h index f80637d5..14f851bf 100644 --- a/Source/EbsdLib/IO/TSL/AngHeaderEntry.h +++ b/Source/EbsdLib/IO/TSL/AngHeaderEntry.h @@ -50,6 +50,8 @@ using namespace H5Support; #endif +namespace ebsdlib +{ /** * @class AngHeaderEntry AngHeaderEntry.h EbsdLib/IO/TSL/AngHeaderEntry.h * @brief Header entry that holds an integer or decimal type value @@ -200,3 +202,4 @@ class AngStringHeaderEntry : public EbsdHeaderEntry AngStringHeaderEntry& operator=(const AngStringHeaderEntry&) = delete; // Copy Assignment Not Implemented AngStringHeaderEntry& operator=(AngStringHeaderEntry&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/AngPhase.cpp b/Source/EbsdLib/IO/TSL/AngPhase.cpp index 53bbf2c1..e7d11f16 100644 --- a/Source/EbsdLib/IO/TSL/AngPhase.cpp +++ b/Source/EbsdLib/IO/TSL/AngPhase.cpp @@ -41,13 +41,15 @@ #include "EbsdLib/IO/TSL/AngConstants.h" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" +using namespace ebsdlib; + HKLFamily::HKLFamily() = default; HKLFamily::~HKLFamily() = default; // ----------------------------------------------------------------------------- void HKLFamily::printSelf(std::stringstream& stream) const { - stream << EbsdLib::Ang::HKLFamilies; + stream << ebsdlib::Ang::HKLFamilies; stream << " " << h << " " << k << " " << l << " " << diffractionIntensity << " " << (int)(s1) << " " << (int)(s2) << "\n"; } @@ -232,9 +234,9 @@ void AngPhase::parseCategories(std::vector& tokens) m_Categories.clear(); try { - if(tokens[0].size() != EbsdLib::Ang::Categories.size()) + if(tokens[0].size() != ebsdlib::Ang::Categories.size()) { - tokens[0] = EbsdStringUtils::replace(tokens[0], EbsdLib::Ang::Categories, ""); + tokens[0] = EbsdStringUtils::replace(tokens[0], ebsdlib::Ang::Categories, ""); m_Categories.push_back(std::stoi(tokens.at(0))); } for(size_t i = 1; i < tokens.size(); ++i) @@ -256,13 +258,13 @@ void AngPhase::parseCategories(std::vector& tokens) // ----------------------------------------------------------------------------- void AngPhase::printSelf(std::stringstream& stream) { - stream << EbsdLib::Ang::Phase << ": " << m_PhaseIndex << std::string("\n"); - stream << EbsdLib::Ang::MaterialName << ": " << m_MaterialName << std::string("\n"); - stream << EbsdLib::Ang::Formula << ": " << m_Formula << std::string("\n"); - // stream << EbsdLib::Ang::Info << ": " << m_Info << std::string("\n"); - stream << EbsdLib::Ang::Symmetry << ": " << m_Symmetry << std::string("\n"); + stream << ebsdlib::Ang::Phase << ": " << m_PhaseIndex << std::string("\n"); + stream << ebsdlib::Ang::MaterialName << ": " << m_MaterialName << std::string("\n"); + stream << ebsdlib::Ang::Formula << ": " << m_Formula << std::string("\n"); + // stream << ebsdlib::Ang::Info << ": " << m_Info << std::string("\n"); + stream << ebsdlib::Ang::Symmetry << ": " << m_Symmetry << std::string("\n"); - stream << EbsdLib::Ang::LatticeConstants; + stream << ebsdlib::Ang::LatticeConstants; for(const auto& latticeConstant : m_LatticeConstants) { @@ -270,14 +272,14 @@ void AngPhase::printSelf(std::stringstream& stream) } stream << std::string("\n"); - stream << EbsdLib::Ang::NumberFamilies << ": " << m_NumberFamilies << std::string("\n"); + stream << ebsdlib::Ang::NumberFamilies << ": " << m_NumberFamilies << std::string("\n"); for(const auto& family : m_HKLFamilies) { family->printSelf(stream); } - stream << EbsdLib::Ang::Categories; + stream << ebsdlib::Ang::Categories; for(const auto& category : m_Categories) { stream << " " << category; @@ -291,86 +293,86 @@ void AngPhase::printSelf(std::stringstream& stream) unsigned int AngPhase::determineOrientationOpsIndex() { uint32_t symmetry = getSymmetry(); - unsigned int crystal_structure = EbsdLib::CrystalStructure::UnknownCrystalStructure; + unsigned int crystal_structure = ebsdlib::CrystalStructure::UnknownCrystalStructure; switch(symmetry) { - case EbsdLib::Ang::PhaseSymmetry::Cubic: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_O: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_Td: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_Oh: - crystal_structure = EbsdLib::CrystalStructure::Cubic_High; + case ebsdlib::Ang::PhaseSymmetry::Cubic: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_O: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_Td: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_Oh: + crystal_structure = ebsdlib::CrystalStructure::Cubic_High; break; - case EbsdLib::Ang::PhaseSymmetry::Tetrahedral: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_T: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_Th: - crystal_structure = EbsdLib::CrystalStructure::Cubic_Low; + case ebsdlib::Ang::PhaseSymmetry::Tetrahedral: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_T: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_Th: + crystal_structure = ebsdlib::CrystalStructure::Cubic_Low; break; - case EbsdLib::Ang::PhaseSymmetry::DiTetragonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D4: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C4v: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D2d: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D4h: - crystal_structure = EbsdLib::CrystalStructure::Tetragonal_High; + case ebsdlib::Ang::PhaseSymmetry::DiTetragonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D4: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C4v: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D2d: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D4h: + crystal_structure = ebsdlib::CrystalStructure::Tetragonal_High; break; - case EbsdLib::Ang::PhaseSymmetry::Tetragonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C4: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_S4: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C4h: - crystal_structure = EbsdLib::CrystalStructure::Tetragonal_Low; + case ebsdlib::Ang::PhaseSymmetry::Tetragonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C4: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_S4: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C4h: + crystal_structure = ebsdlib::CrystalStructure::Tetragonal_Low; break; - case EbsdLib::Ang::PhaseSymmetry::Orthorhombic: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D2: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2v: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D2h: - crystal_structure = EbsdLib::CrystalStructure::OrthoRhombic; + case ebsdlib::Ang::PhaseSymmetry::Orthorhombic: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D2: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2v: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D2h: + crystal_structure = ebsdlib::CrystalStructure::OrthoRhombic; break; - case EbsdLib::Ang::PhaseSymmetry::Monoclinic_c: - case EbsdLib::Ang::PhaseSymmetry::Monoclinic_b: - case EbsdLib::Ang::PhaseSymmetry::Monoclinic_a: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2_c: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C1h_c: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2h_c: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2_b: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C1h_b: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2h_b: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2_a: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C1h_a: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C2h_a: - crystal_structure = EbsdLib::CrystalStructure::Monoclinic; + case ebsdlib::Ang::PhaseSymmetry::Monoclinic_c: + case ebsdlib::Ang::PhaseSymmetry::Monoclinic_b: + case ebsdlib::Ang::PhaseSymmetry::Monoclinic_a: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2_c: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C1h_c: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2h_c: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2_b: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C1h_b: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2h_b: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2_a: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C1h_a: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C2h_a: + crystal_structure = ebsdlib::CrystalStructure::Monoclinic; break; - case EbsdLib::Ang::PhaseSymmetry::Triclinic: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C1: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_S2: - crystal_structure = EbsdLib::CrystalStructure::Triclinic; + case ebsdlib::Ang::PhaseSymmetry::Triclinic: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C1: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_S2: + crystal_structure = ebsdlib::CrystalStructure::Triclinic; break; - case EbsdLib::Ang::PhaseSymmetry::DiHexagonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D6: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C6v: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D3h: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D6h: - crystal_structure = EbsdLib::CrystalStructure::Hexagonal_High; + case ebsdlib::Ang::PhaseSymmetry::DiHexagonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D6: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C6v: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D3h: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D6h: + crystal_structure = ebsdlib::CrystalStructure::Hexagonal_High; break; - case EbsdLib::Ang::PhaseSymmetry::Hexagonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C6: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C3h: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C6h: - crystal_structure = EbsdLib::CrystalStructure::Hexagonal_Low; + case ebsdlib::Ang::PhaseSymmetry::Hexagonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C6: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C3h: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C6h: + crystal_structure = ebsdlib::CrystalStructure::Hexagonal_Low; break; - case EbsdLib::Ang::PhaseSymmetry::DiTrigonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D3: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C3v: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_D3d: - crystal_structure = EbsdLib::CrystalStructure::Trigonal_High; + case ebsdlib::Ang::PhaseSymmetry::DiTrigonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D3: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C3v: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_D3d: + crystal_structure = ebsdlib::CrystalStructure::Trigonal_High; break; - case EbsdLib::Ang::PhaseSymmetry::Trigonal: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_C3: - case EbsdLib::Ang::PhaseSymmetry::k_Sym_S6: - crystal_structure = EbsdLib::CrystalStructure::Trigonal_Low; + case ebsdlib::Ang::PhaseSymmetry::Trigonal: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_C3: + case ebsdlib::Ang::PhaseSymmetry::k_Sym_S6: + crystal_structure = ebsdlib::CrystalStructure::Trigonal_Low; break; default: - crystal_structure = EbsdLib::CrystalStructure::UnknownCrystalStructure; + crystal_structure = ebsdlib::CrystalStructure::UnknownCrystalStructure; } return crystal_structure; } diff --git a/Source/EbsdLib/IO/TSL/AngPhase.h b/Source/EbsdLib/IO/TSL/AngPhase.h index c94d70cd..012c3899 100644 --- a/Source/EbsdLib/IO/TSL/AngPhase.h +++ b/Source/EbsdLib/IO/TSL/AngPhase.h @@ -42,6 +42,8 @@ #include "EbsdLib/Core/EbsdSetGetMacros.h" #include "EbsdLib/EbsdLib.h" +namespace ebsdlib +{ // #pragma pack(push, r1, 1) /* push current alignment to stack. set alignment to 1 byte boundary */ /*! * @struct HKLFamily_t is used to write the HKL Family to an HDF5 file using a @@ -224,3 +226,4 @@ class EbsdLib_EXPORT AngPhase }; // #pragma pack(pop, r1) +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/AngReader.cpp b/Source/EbsdLib/IO/TSL/AngReader.cpp index e1944446..9e05fb5b 100644 --- a/Source/EbsdLib/IO/TSL/AngReader.cpp +++ b/Source/EbsdLib/IO/TSL/AngReader.cpp @@ -46,6 +46,8 @@ #include #include +using namespace ebsdlib; + namespace { @@ -113,26 +115,26 @@ AngReader::AngReader() m_ReadHexGrid = false; // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::Ang::TEMPIXPerUM] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::TEMPIXPerUM); - m_HeaderMap[EbsdLib::Ang::XStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::XStar); - m_HeaderMap[EbsdLib::Ang::YStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::YStar); - m_HeaderMap[EbsdLib::Ang::ZStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZStar); - m_HeaderMap[EbsdLib::Ang::WorkingDistance] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::WorkingDistance); - m_HeaderMap[EbsdLib::Ang::Grid] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::Grid); - m_HeaderMap[EbsdLib::Ang::XStep] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::XStep); - m_HeaderMap[EbsdLib::Ang::YStep] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::YStep); - m_HeaderMap[EbsdLib::Ang::ZStep] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZStep); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - m_HeaderMap[EbsdLib::Ang::ZPos] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZPos); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - m_HeaderMap[EbsdLib::Ang::ZMax] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZMax); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - m_HeaderMap[EbsdLib::Ang::NColsOdd] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::NColsOdd); - m_HeaderMap[EbsdLib::Ang::NColsEven] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::NColsEven); - m_HeaderMap[EbsdLib::Ang::NRows] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::NRows); - m_HeaderMap[EbsdLib::Ang::OPERATOR] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::OPERATOR); - m_HeaderMap[EbsdLib::Ang::SAMPLEID] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::SAMPLEID); - m_HeaderMap[EbsdLib::Ang::SCANID] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::SCANID); - m_HeaderMap[EbsdLib::Ang::ColumnCount] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ColumnCount); - m_HeaderMap[EbsdLib::Ang::ColumnHeaders] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ColumnHeaders); - m_HeaderMap[EbsdLib::Ang::ColumnUnits] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ColumnUnits); + m_HeaderMap[ebsdlib::Ang::TEMPIXPerUM] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::TEMPIXPerUM); + m_HeaderMap[ebsdlib::Ang::XStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::XStar); + m_HeaderMap[ebsdlib::Ang::YStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::YStar); + m_HeaderMap[ebsdlib::Ang::ZStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZStar); + m_HeaderMap[ebsdlib::Ang::WorkingDistance] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::WorkingDistance); + m_HeaderMap[ebsdlib::Ang::Grid] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::Grid); + m_HeaderMap[ebsdlib::Ang::XStep] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::XStep); + m_HeaderMap[ebsdlib::Ang::YStep] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::YStep); + m_HeaderMap[ebsdlib::Ang::ZStep] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZStep); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + m_HeaderMap[ebsdlib::Ang::ZPos] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZPos); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + m_HeaderMap[ebsdlib::Ang::ZMax] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZMax); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + m_HeaderMap[ebsdlib::Ang::NColsOdd] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::NColsOdd); + m_HeaderMap[ebsdlib::Ang::NColsEven] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::NColsEven); + m_HeaderMap[ebsdlib::Ang::NRows] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::NRows); + m_HeaderMap[ebsdlib::Ang::OPERATOR] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::OPERATOR); + m_HeaderMap[ebsdlib::Ang::SAMPLEID] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::SAMPLEID); + m_HeaderMap[ebsdlib::Ang::SCANID] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::SCANID); + m_HeaderMap[ebsdlib::Ang::ColumnCount] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ColumnCount); + m_HeaderMap[ebsdlib::Ang::ColumnHeaders] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ColumnHeaders); + m_HeaderMap[ebsdlib::Ang::ColumnUnits] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ColumnUnits); // Give these values some defaults setNumOddCols(-1); @@ -204,43 +206,43 @@ AngReader::~AngReader() // ----------------------------------------------------------------------------- void* AngReader::getPointerByName(const std::string& featureName) { - if(featureName == EbsdLib::Ang::Phi1) + if(featureName == ebsdlib::Ang::Phi1) { return static_cast(m_Phi1); } - if(featureName == EbsdLib::Ang::Phi) + if(featureName == ebsdlib::Ang::Phi) { return static_cast(m_Phi); } - if(featureName == EbsdLib::Ang::Phi2) + if(featureName == ebsdlib::Ang::Phi2) { return static_cast(m_Phi2); } - if(featureName == EbsdLib::Ang::ImageQuality) + if(featureName == ebsdlib::Ang::ImageQuality) { return static_cast(m_Iq); } - if(featureName == EbsdLib::Ang::ConfidenceIndex) + if(featureName == ebsdlib::Ang::ConfidenceIndex) { return static_cast(m_Ci); } - if(featureName == EbsdLib::Ang::PhaseData) + if(featureName == ebsdlib::Ang::PhaseData) { return static_cast(m_PhaseData); } - if(featureName == EbsdLib::Ang::XPosition) + if(featureName == ebsdlib::Ang::XPosition) { return static_cast(m_X); } - if(featureName == EbsdLib::Ang::YPosition) + if(featureName == ebsdlib::Ang::YPosition) { return static_cast(m_Y); } - if(featureName == EbsdLib::Ang::SEMSignal) + if(featureName == ebsdlib::Ang::SEMSignal) { return static_cast(m_SEMSignal); } - if(featureName == EbsdLib::Ang::Fit) + if(featureName == ebsdlib::Ang::Fit) { return static_cast(m_Fit); } @@ -250,49 +252,49 @@ void* AngReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type AngReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type AngReader::getPointerType(const std::string& featureName) { - if(featureName == EbsdLib::Ang::Phi1) + if(featureName == ebsdlib::Ang::Phi1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Phi) + if(featureName == ebsdlib::Ang::Phi) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Phi2) + if(featureName == ebsdlib::Ang::Phi2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::ImageQuality) + if(featureName == ebsdlib::Ang::ImageQuality) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::ConfidenceIndex) + if(featureName == ebsdlib::Ang::ConfidenceIndex) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::PhaseData) + if(featureName == ebsdlib::Ang::PhaseData) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ang::XPosition) + if(featureName == ebsdlib::Ang::XPosition) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::YPosition) + if(featureName == ebsdlib::Ang::YPosition) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::SEMSignal) + if(featureName == ebsdlib::Ang::SEMSignal) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Fit) + if(featureName == ebsdlib::Ang::Fit) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- @@ -396,7 +398,7 @@ int AngReader::readFile() } std::vector indexMap; std::string grid = getGrid(); - if(grid.find(EbsdLib::Ang::SquareGrid) == 0) + if(grid.find(ebsdlib::Ang::SquareGrid) == 0) { std::pair result = fixOrderOfData(indexMap); @@ -412,11 +414,11 @@ int AngReader::readFile() { void* oldArray = getPointerByName(arrayName); - if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Float) + if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Float) { CopyTupleUsingIndexList(oldArray, indexMap); } - else if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Int32) + else if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Int32) { CopyTupleUsingIndexList(oldArray, indexMap); } @@ -451,7 +453,7 @@ void AngReader::readData(std::ifstream& in, std::string& buf) setErrorMessage("NumRows Sanity Check not correct. Check the entry for NROWS in the .ang file"); return; } - if(grid.find(EbsdLib::Ang::SquareGrid) == 0) + if(grid.find(ebsdlib::Ang::SquareGrid) == 0) { if(nOddCols > 0) { @@ -466,13 +468,13 @@ void AngReader::readData(std::ifstream& in, std::string& buf) totalDataPoints = 0; } } - else if(grid.find(EbsdLib::Ang::HexGrid) == 0 && !m_ReadHexGrid) + else if(grid.find(ebsdlib::Ang::HexGrid) == 0 && !m_ReadHexGrid) { setErrorCode(-400); setErrorMessage("Ang Files with Hex Grids Are NOT currently supported - Try converting them to Square Grid with the Hex2Sqr Converter filter."); return; } - else if(grid.find(EbsdLib::Ang::HexGrid) == 0 && m_ReadHexGrid) + else if(grid.find(ebsdlib::Ang::HexGrid) == 0 && m_ReadHexGrid) { bool evenRow = false; totalDataPoints = 0; @@ -659,22 +661,22 @@ void AngReader::parseHeaderLine(std::string& buf) word = EbsdStringUtils::chop(word, 1); } - if(buf == EbsdLib::Ang::NotesStart) + if(buf == ebsdlib::Ang::NotesStart) { m_InsideNotes = true; - m_Notes = "# " + EbsdLib::Ang::NotesStart + "\r\n"; + m_Notes = "# " + ebsdlib::Ang::NotesStart + "\r\n"; } - else if(buf == EbsdLib::Ang::NotesEnd) + else if(buf == ebsdlib::Ang::NotesEnd) { m_InsideNotes = false; } - if(buf == EbsdLib::Ang::ColumnNotesStart) + if(buf == ebsdlib::Ang::ColumnNotesStart) { m_InsideColumnNotes = true; - m_ColumnNotes = "# " + EbsdLib::Ang::ColumnNotesStart + "\r\n"; + m_ColumnNotes = "# " + ebsdlib::Ang::ColumnNotesStart + "\r\n"; } - else if(buf == EbsdLib::Ang::ColumnNotesEnd) + else if(buf == ebsdlib::Ang::ColumnNotesEnd) { m_InsideColumnNotes = false; } @@ -684,7 +686,7 @@ void AngReader::parseHeaderLine(std::string& buf) // parsing data for the phase then stick the Phase instance into the header // map or stick it into a vector and stick the vector into // the map under the "Phase" key - if(word == EbsdLib::Ang::Phase && !m_InsideNotes) + if(word == ebsdlib::Ang::Phase && !m_InsideNotes) { m_CurrentPhase = AngPhase::New(); try @@ -701,21 +703,21 @@ void AngReader::parseHeaderLine(std::string& buf) // Parsing the phase is complete, now add it to the vector of Phases m_PhaseVector.push_back(m_CurrentPhase); } - else if(word == EbsdLib::Ang::MaterialName && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::MaterialName && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { m_CurrentPhase->parseMaterialName(tokens); } } - else if(word == EbsdLib::Ang::Formula && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::Formula && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { m_CurrentPhase->parseFormula(tokens); } } - else if(word == EbsdLib::Ang::Symmetry && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::Symmetry && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { @@ -732,14 +734,14 @@ void AngReader::parseHeaderLine(std::string& buf) } } } - else if(word == EbsdLib::Ang::LatticeConstants && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::LatticeConstants && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { m_CurrentPhase->parseLatticeConstants(tokens); } } - else if(word == EbsdLib::Ang::NumberFamilies && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::NumberFamilies && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { @@ -756,14 +758,14 @@ void AngReader::parseHeaderLine(std::string& buf) } } } - else if(word == EbsdLib::Ang::HKLFamilies && m_CurrentPhase.get() != nullptr) + else if(word == ebsdlib::Ang::HKLFamilies && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { m_CurrentPhase->parseHKLFamilies(tokens); } } - else if(word.find(EbsdLib::Ang::Categories) == 0 && m_CurrentPhase.get() != nullptr) + else if(word.find(ebsdlib::Ang::Categories) == 0 && m_CurrentPhase.get() != nullptr) { if(tokens.size() > 1) { @@ -783,8 +785,8 @@ void AngReader::parseHeaderLine(std::string& buf) std::cout << "#define ANG_" << upper << " \"" << word << "\"" << std::endl; std::cout << "const std::string " << word << "(ANG_" << upper << ");" << std::endl; - std::cout << "EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, " << word << "EbsdLib::Ang::" << word << ")" << std::endl; - std::cout << "m_HeaderMap[EbsdLib::Ang::" << word << "] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::" << word << ");" << std::endl; + std::cout << "EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, " << word << "ebsdlib::Ang::" << word << ")" << std::endl; + std::cout << "m_HeaderMap[ebsdlib::Ang::" << word << "] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::" << word << ");" << std::endl; #endif #if 0 std::cout << "\n " << word << "\n " << "H5T_STRING" << "\n"; diff --git a/Source/EbsdLib/IO/TSL/AngReader.h b/Source/EbsdLib/IO/TSL/AngReader.h index 390e36fb..5c07e527 100644 --- a/Source/EbsdLib/IO/TSL/AngReader.h +++ b/Source/EbsdLib/IO/TSL/AngReader.h @@ -49,6 +49,8 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/EbsdReader.h" +namespace ebsdlib +{ /** * @class AngReader AngReader.h EbsdLib/IO/TSL/AngReader.h * @brief This class is a self contained TSL OIM .ang file reader and will read a @@ -65,39 +67,39 @@ class EbsdLib_EXPORT AngReader : public EbsdReader /** @brief Header Values from the TSL ang file */ - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, TEMpixPerum, EbsdLib::Ang::TEMPIXPerUM) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, TEMpixPerum, ebsdlib::Ang::TEMPIXPerUM) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, XStar, EbsdLib::Ang::XStar) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, XStar, ebsdlib::Ang::XStar) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, YStar, EbsdLib::Ang::YStar) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, YStar, ebsdlib::Ang::YStar) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, ZStar, EbsdLib::Ang::ZStar) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, ZStar, ebsdlib::Ang::ZStar) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, WorkingDistance, EbsdLib::Ang::WorkingDistance) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, WorkingDistance, ebsdlib::Ang::WorkingDistance) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, Grid, EbsdLib::Ang::Grid) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, Grid, ebsdlib::Ang::Grid) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, XStep, EbsdLib::Ang::XStep) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, XStep, ebsdlib::Ang::XStep) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, YStep, EbsdLib::Ang::YStep) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, float, YStep, ebsdlib::Ang::YStep) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumOddCols, EbsdLib::Ang::NColsOdd) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumOddCols, ebsdlib::Ang::NColsOdd) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumEvenCols, EbsdLib::Ang::NColsEven) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumEvenCols, ebsdlib::Ang::NColsEven) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumRows, EbsdLib::Ang::NRows) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, NumRows, ebsdlib::Ang::NRows) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, OIMOperator, EbsdLib::Ang::OPERATOR) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, OIMOperator, ebsdlib::Ang::OPERATOR) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, SampleID, EbsdLib::Ang::SAMPLEID) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, SampleID, ebsdlib::Ang::SAMPLEID) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, SCANID, EbsdLib::Ang::SCANID) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, SCANID, ebsdlib::Ang::SCANID) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, VERSION, EbsdLib::Ang::Version) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, VERSION, ebsdlib::Ang::Version) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, ColumnCount, EbsdLib::Ang::ColumnCount) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, ColumnHeaders, EbsdLib::Ang::ColumnHeaders) - EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, ColumnUnits, EbsdLib::Ang::ColumnUnits) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, ColumnCount, ebsdlib::Ang::ColumnCount) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, ColumnHeaders, ebsdlib::Ang::ColumnHeaders) + EBSDHEADER_INSTANCE_PROPERTY(AngStringHeaderEntry, std::string, ColumnUnits, ebsdlib::Ang::ColumnUnits) EBSD_INSTANCE_PROPERTY(std::vector, PhaseVector) @@ -151,7 +153,7 @@ class EbsdLib_EXPORT AngReader : public EbsdReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; /** * @brief Reads the complete TSL .ang file. @@ -219,3 +221,4 @@ class EbsdLib_EXPORT AngReader : public EbsdReader AngReader& operator=(const AngReader&) = delete; // Copy Assignment Not Implemented AngReader& operator=(AngReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/H5AngImporter.cpp b/Source/EbsdLib/IO/TSL/H5AngImporter.cpp index bbe0aba1..b0c331fc 100644 --- a/Source/EbsdLib/IO/TSL/H5AngImporter.cpp +++ b/Source/EbsdLib/IO/TSL/H5AngImporter.cpp @@ -43,6 +43,8 @@ using namespace H5Support; +using namespace ebsdlib; + #define AIM_STRING std::string #define CHECK_FOR_CANCELED(AClass) \ @@ -59,7 +61,7 @@ H5AngImporter::H5AngImporter() , yDim(0) , xRes(0) , yRes(0) -, m_FileVersion(EbsdLib::H5OIM::FileVersion) +, m_FileVersion(ebsdlib::H5OIM::FileVersion) { } @@ -205,22 +207,22 @@ int H5AngImporter::importFile(hid_t fileId, int64_t z, const std::string& angFil H5T_class_t type_class; size_t type_size = 0; hid_t attr_type = -1; - err = H5Lite::getAttributeInfo(fileId, "/", EbsdLib::H5OIM::FileVersionStr, dims, type_class, type_size, attr_type); + err = H5Lite::getAttributeInfo(fileId, "/", ebsdlib::H5OIM::FileVersionStr, dims, type_class, type_size, attr_type); if(attr_type < 0) // The attr_type variable was never set which means the attribute was NOT there { // The file version does not exist so write it to the file - err = H5Lite::writeScalarAttribute(fileId, std::string("/"), EbsdLib::H5OIM::FileVersionStr, m_FileVersion); + err = H5Lite::writeScalarAttribute(fileId, std::string("/"), ebsdlib::H5OIM::FileVersionStr, m_FileVersion); } else { H5Aclose(attr_type); } - err = H5Lite::getAttributeInfo(fileId, "/", EbsdLib::H5OIM::EbsdLibVersionStr, dims, type_class, type_size, attr_type); + err = H5Lite::getAttributeInfo(fileId, "/", ebsdlib::H5OIM::EbsdLibVersionStr, dims, type_class, type_size, attr_type); if(attr_type < 0) // The attr_type variable was never set which means the attribute was NOT there { // The file version does not exist so write it to the file - err = H5Lite::writeStringAttribute(fileId, std::string("/"), EbsdLib::H5OIM::EbsdLibVersionStr, EbsdLib::Version::Complete()); + err = H5Lite::writeStringAttribute(fileId, std::string("/"), ebsdlib::H5OIM::EbsdLibVersionStr, ebsdlib::Version::Complete()); } else { @@ -240,7 +242,7 @@ int H5AngImporter::importFile(hid_t fileId, int64_t z, const std::string& angFil return -1; } - hid_t gid = H5Utilities::createGroup(angGroup, EbsdLib::H5OIM::Header); + hid_t gid = H5Utilities::createGroup(angGroup, ebsdlib::H5OIM::Header); if(gid < 0) { ss.str(""); @@ -252,40 +254,40 @@ int H5AngImporter::importFile(hid_t fileId, int64_t z, const std::string& angFil setErrorCode(-600); return -1; } - WRITE_ANG_HEADER_DATA(reader, float, TEMpixPerum, EbsdLib::Ang::TEMPIXPerUM) - WRITE_ANG_HEADER_DATA(reader, float, XStar, EbsdLib::Ang::XStar) - WRITE_ANG_HEADER_DATA(reader, float, YStar, EbsdLib::Ang::YStar) - WRITE_ANG_HEADER_DATA(reader, float, ZStar, EbsdLib::Ang::ZStar) - WRITE_ANG_HEADER_DATA(reader, float, WorkingDistance, EbsdLib::Ang::WorkingDistance) + WRITE_ANG_HEADER_DATA(reader, float, TEMpixPerum, ebsdlib::Ang::TEMPIXPerUM) + WRITE_ANG_HEADER_DATA(reader, float, XStar, ebsdlib::Ang::XStar) + WRITE_ANG_HEADER_DATA(reader, float, YStar, ebsdlib::Ang::YStar) + WRITE_ANG_HEADER_DATA(reader, float, ZStar, ebsdlib::Ang::ZStar) + WRITE_ANG_HEADER_DATA(reader, float, WorkingDistance, ebsdlib::Ang::WorkingDistance) - hid_t phasesGid = H5Utilities::createGroup(gid, EbsdLib::H5OIM::Phases); + hid_t phasesGid = H5Utilities::createGroup(gid, ebsdlib::H5OIM::Phases); err = writePhaseData(reader, phasesGid); // Close this group err = H5Gclose(phasesGid); - WRITE_ANG_HEADER_STRING_DATA(reader, std::string, Grid, EbsdLib::Ang::Grid) - WRITE_ANG_HEADER_DATA(reader, float, XStep, EbsdLib::Ang::XStep) + WRITE_ANG_HEADER_STRING_DATA(reader, std::string, Grid, ebsdlib::Ang::Grid) + WRITE_ANG_HEADER_DATA(reader, float, XStep, ebsdlib::Ang::XStep) xRes = reader.getXStep(); - WRITE_ANG_HEADER_DATA(reader, float, YStep, EbsdLib::Ang::YStep) + WRITE_ANG_HEADER_DATA(reader, float, YStep, ebsdlib::Ang::YStep) yRes = reader.getYStep(); - WRITE_ANG_HEADER_DATA(reader, int, NumOddCols, EbsdLib::Ang::NColsOdd) - WRITE_ANG_HEADER_DATA(reader, int, NumEvenCols, EbsdLib::Ang::NColsEven) + WRITE_ANG_HEADER_DATA(reader, int, NumOddCols, ebsdlib::Ang::NColsOdd) + WRITE_ANG_HEADER_DATA(reader, int, NumEvenCols, ebsdlib::Ang::NColsEven) xDim = reader.getNumEvenCols(); - WRITE_ANG_HEADER_DATA(reader, int, NumRows, EbsdLib::Ang::NRows) + WRITE_ANG_HEADER_DATA(reader, int, NumRows, ebsdlib::Ang::NRows) yDim = reader.getNumRows(); - WRITE_ANG_HEADER_STRING_DATA(reader, std::string, OIMOperator, EbsdLib::Ang::OPERATOR) - WRITE_ANG_HEADER_STRING_DATA(reader, std::string, SampleID, EbsdLib::Ang::SAMPLEID) - WRITE_ANG_HEADER_STRING_DATA(reader, std::string, SCANID, EbsdLib::Ang::SCANID) + WRITE_ANG_HEADER_STRING_DATA(reader, std::string, OIMOperator, ebsdlib::Ang::OPERATOR) + WRITE_ANG_HEADER_STRING_DATA(reader, std::string, SampleID, ebsdlib::Ang::SAMPLEID) + WRITE_ANG_HEADER_STRING_DATA(reader, std::string, SCANID, ebsdlib::Ang::SCANID) std::string angCompleteHeader = reader.getOriginalHeader(); - err = H5Lite::writeStringDataset(gid, EbsdLib::H5OIM::OriginalHeader, angCompleteHeader); - err = H5Lite::writeStringDataset(gid, EbsdLib::H5OIM::OriginalFile, angFile); + err = H5Lite::writeStringDataset(gid, ebsdlib::H5OIM::OriginalHeader, angCompleteHeader); + err = H5Lite::writeStringDataset(gid, ebsdlib::H5OIM::OriginalFile, angFile); // Close the "Header" group err = H5Gclose(gid); // Create the "Data" group - gid = H5Utilities::createGroup(angGroup, EbsdLib::H5OIM::Data); + gid = H5Utilities::createGroup(angGroup, ebsdlib::H5OIM::Data); if(gid < 0) { ss.str(""); @@ -301,16 +303,16 @@ int H5AngImporter::importFile(hid_t fileId, int64_t z, const std::string& angFil int32_t rank = 1; hsize_t dims[1] = {static_cast(reader.getNumEvenCols() * reader.getNumRows())}; - WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi1, EbsdLib::Ang::Phi1); - WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi, EbsdLib::Ang::Phi); - WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi2, EbsdLib::Ang::Phi2); - WRITE_ANG_DATA_ARRAY(reader, float, gid, XPosition, EbsdLib::Ang::XPosition); - WRITE_ANG_DATA_ARRAY(reader, float, gid, YPosition, EbsdLib::Ang::YPosition); - WRITE_ANG_DATA_ARRAY(reader, float, gid, ImageQuality, EbsdLib::Ang::ImageQuality); - WRITE_ANG_DATA_ARRAY(reader, float, gid, ConfidenceIndex, EbsdLib::Ang::ConfidenceIndex); - WRITE_ANG_DATA_ARRAY(reader, int, gid, PhaseData, EbsdLib::Ang::PhaseData); - WRITE_ANG_DATA_ARRAY(reader, float, gid, SEMSignal, EbsdLib::Ang::SEMSignal); - WRITE_ANG_DATA_ARRAY(reader, float, gid, Fit, EbsdLib::Ang::Fit); + WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi1, ebsdlib::Ang::Phi1); + WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi, ebsdlib::Ang::Phi); + WRITE_ANG_DATA_ARRAY(reader, float, gid, Phi2, ebsdlib::Ang::Phi2); + WRITE_ANG_DATA_ARRAY(reader, float, gid, XPosition, ebsdlib::Ang::XPosition); + WRITE_ANG_DATA_ARRAY(reader, float, gid, YPosition, ebsdlib::Ang::YPosition); + WRITE_ANG_DATA_ARRAY(reader, float, gid, ImageQuality, ebsdlib::Ang::ImageQuality); + WRITE_ANG_DATA_ARRAY(reader, float, gid, ConfidenceIndex, ebsdlib::Ang::ConfidenceIndex); + WRITE_ANG_DATA_ARRAY(reader, int, gid, PhaseData, ebsdlib::Ang::PhaseData); + WRITE_ANG_DATA_ARRAY(reader, float, gid, SEMSignal, ebsdlib::Ang::SEMSignal); + WRITE_ANG_DATA_ARRAY(reader, float, gid, Fit, ebsdlib::Ang::Fit); // Close the "Data" group err = H5Gclose(gid); @@ -382,30 +384,30 @@ int H5AngImporter::writePhaseData(AngReader& reader, hid_t phasesGid) for(AngPhase::Pointer& phase : phases) { hid_t pid = H5Utilities::createGroup(phasesGid, EbsdStringUtils::number(phase->getPhaseIndex())); - WRITE_PHASE_HEADER_DATA(phase, int, PhaseIndex, EbsdLib::Ang::Phase) - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, MaterialName, EbsdLib::Ang::MaterialName) - WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Formula, EbsdLib::Ang::Formula) - // WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Info, EbsdLib::Ang::Info) - WRITE_PHASE_HEADER_DATA(phase, int, Symmetry, EbsdLib::Ang::Symmetry) - WRITE_PHASE_DATA_ARRAY(phase, float, pid, LatticeConstants, EbsdLib::Ang::LatticeConstants) - WRITE_PHASE_HEADER_DATA(phase, int, NumberFamilies, EbsdLib::Ang::NumberFamilies) + WRITE_PHASE_HEADER_DATA(phase, int, PhaseIndex, ebsdlib::Ang::Phase) + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, MaterialName, ebsdlib::Ang::MaterialName) + WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Formula, ebsdlib::Ang::Formula) + // WRITE_PHASE_HEADER_STRING_DATA(phase, std::string, Info, ebsdlib::Ang::Info) + WRITE_PHASE_HEADER_DATA(phase, int, Symmetry, ebsdlib::Ang::Symmetry) + WRITE_PHASE_DATA_ARRAY(phase, float, pid, LatticeConstants, ebsdlib::Ang::LatticeConstants) + WRITE_PHASE_HEADER_DATA(phase, int, NumberFamilies, ebsdlib::Ang::NumberFamilies) // Create a Group for the HKLFamilies if(phase->getNumberFamilies() > 0) { - hid_t hklGid = H5Utilities::createGroup(pid, EbsdLib::Ang::HKLFamilies); + hid_t hklGid = H5Utilities::createGroup(pid, ebsdlib::Ang::HKLFamilies); err = writeHKLFamilies(phase.get(), hklGid); if(err < 0) { ss.str(""); - ss << "H5AngImporter Error: Could not write Ang HKL Families to the HDF5 file with data set name '" << EbsdLib::Ang::HKLFamilies << "'"; + ss << "H5AngImporter Error: Could not write Ang HKL Families to the HDF5 file with data set name '" << ebsdlib::Ang::HKLFamilies << "'"; progressMessage(ss.str(), 100); err = H5Gclose(hklGid); return -1; } err = H5Gclose(hklGid); } - WRITE_PHASE_DATA_ARRAY(phase, int, pid, Categories, EbsdLib::Ang::Categories) + WRITE_PHASE_DATA_ARRAY(phase, int, pid, Categories, ebsdlib::Ang::Categories) err = H5Gclose(pid); } return err; diff --git a/Source/EbsdLib/IO/TSL/H5AngImporter.h b/Source/EbsdLib/IO/TSL/H5AngImporter.h index ec51df82..8f0a1aab 100644 --- a/Source/EbsdLib/IO/TSL/H5AngImporter.h +++ b/Source/EbsdLib/IO/TSL/H5AngImporter.h @@ -49,6 +49,8 @@ #include "EbsdLib/IO/EbsdImporter.h" #include "EbsdLib/IO/TSL/AngReader.h" +namespace ebsdlib +{ /** * @class H5AngImporter H5AngImporter.h EbsdLib/IO/TSL/H5AngImporter.h * @brief This class will read a series of .ang files and store the values into @@ -148,3 +150,4 @@ class EbsdLib_EXPORT H5AngImporter : public EbsdImporter H5AngImporter& operator=(const H5AngImporter&) = delete; // Copy Assignment Not Implemented H5AngImporter& operator=(H5AngImporter&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/H5AngReader.cpp b/Source/EbsdLib/IO/TSL/H5AngReader.cpp index 013a0eeb..849809b1 100644 --- a/Source/EbsdLib/IO/TSL/H5AngReader.cpp +++ b/Source/EbsdLib/IO/TSL/H5AngReader.cpp @@ -52,6 +52,8 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -170,7 +172,7 @@ int H5AngReader::readHeaderOnly() int H5AngReader::readHeader(hid_t parId) { int err = -1; - hid_t gid = H5Gopen(parId, EbsdLib::H5OIM::Header.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OIM::Header.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorCode(-90008); @@ -178,22 +180,22 @@ int H5AngReader::readHeader(hid_t parId) return -1; } - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, TEMPIXPerUM, EbsdLib::Ang::TEMPIXPerUM, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, XStar, EbsdLib::Ang::XStar, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, YStar, EbsdLib::Ang::YStar, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, ZStar, EbsdLib::Ang::ZStar, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, WorkingDistance, EbsdLib::Ang::WorkingDistance, gid) - READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, Grid, EbsdLib::Ang::Grid, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, XStep, EbsdLib::Ang::XStep, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, YStep, EbsdLib::Ang::YStep, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumOddCols, EbsdLib::Ang::NColsOdd, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumEvenCols, EbsdLib::Ang::NColsEven, gid) - READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumRows, EbsdLib::Ang::NRows, gid) - READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, OIMOperator, EbsdLib::Ang::OPERATOR, gid) - READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, SampleID, EbsdLib::Ang::SAMPLEID, gid) - READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, SCANID, EbsdLib::Ang::SCANID, gid) - - hid_t phasesGid = H5Gopen(gid, EbsdLib::H5OIM::Phases.c_str(), H5P_DEFAULT); + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, TEMPIXPerUM, ebsdlib::Ang::TEMPIXPerUM, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, XStar, ebsdlib::Ang::XStar, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, YStar, ebsdlib::Ang::YStar, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, ZStar, ebsdlib::Ang::ZStar, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, WorkingDistance, ebsdlib::Ang::WorkingDistance, gid) + READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, Grid, ebsdlib::Ang::Grid, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, XStep, ebsdlib::Ang::XStep, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, float, YStep, ebsdlib::Ang::YStep, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumOddCols, ebsdlib::Ang::NColsOdd, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumEvenCols, ebsdlib::Ang::NColsEven, gid) + READ_EBSD_HEADER_DATA("H5AngReader", AngHeaderEntry, int, NumRows, ebsdlib::Ang::NRows, gid) + READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, OIMOperator, ebsdlib::Ang::OPERATOR, gid) + READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, SampleID, ebsdlib::Ang::SAMPLEID, gid) + READ_EBSD_HEADER_STRING_DATA("H5AngReader", AngStringHeaderEntry, std::string, SCANID, ebsdlib::Ang::SCANID, gid) + + hid_t phasesGid = H5Gopen(gid, ebsdlib::H5OIM::Phases.c_str(), H5P_DEFAULT); if(phasesGid < 0) { setErrorCode(-90007); @@ -219,17 +221,17 @@ int H5AngReader::readHeader(hid_t parId) hid_t pid = H5Gopen(phasesGid, phaseGroupName.c_str(), H5P_DEFAULT); AngPhase::Pointer currentPhase = AngPhase::New(); - READ_PHASE_HEADER_DATA("H5AngReader", pid, int, EbsdLib::Ang::Phase, PhaseIndex, currentPhase) - READ_PHASE_STRING_DATA("H5AngReader", pid, EbsdLib::Ang::MaterialName, MaterialName, currentPhase) - READ_PHASE_STRING_DATA("H5AngReader", pid, EbsdLib::Ang::Formula, Formula, currentPhase) - // READ_PHASE_STRING_DATA("H5AngReader", pid, EbsdLib::Ang::Info, Info, m_CurrentPhase) - READ_PHASE_HEADER_DATA_CAST("H5AngReader", pid, uint32_t, int, EbsdLib::Ang::Symmetry, Symmetry, currentPhase) - READ_PHASE_HEADER_ARRAY("H5AngReader", pid, float, EbsdLib::Ang::LatticeConstants, LatticeConstants, currentPhase) - READ_PHASE_HEADER_DATA("H5AngReader", pid, int, EbsdLib::Ang::NumberFamilies, NumberFamilies, currentPhase) + READ_PHASE_HEADER_DATA("H5AngReader", pid, int, ebsdlib::Ang::Phase, PhaseIndex, currentPhase) + READ_PHASE_STRING_DATA("H5AngReader", pid, ebsdlib::Ang::MaterialName, MaterialName, currentPhase) + READ_PHASE_STRING_DATA("H5AngReader", pid, ebsdlib::Ang::Formula, Formula, currentPhase) + // READ_PHASE_STRING_DATA("H5AngReader", pid, ebsdlib::Ang::Info, Info, m_CurrentPhase) + READ_PHASE_HEADER_DATA_CAST("H5AngReader", pid, uint32_t, int, ebsdlib::Ang::Symmetry, Symmetry, currentPhase) + READ_PHASE_HEADER_ARRAY("H5AngReader", pid, float, ebsdlib::Ang::LatticeConstants, LatticeConstants, currentPhase) + READ_PHASE_HEADER_DATA("H5AngReader", pid, int, ebsdlib::Ang::NumberFamilies, NumberFamilies, currentPhase) if(currentPhase->getNumberFamilies() > 0) { - hid_t hklGid = H5Gopen(pid, EbsdLib::Ang::HKLFamilies.c_str(), H5P_DEFAULT); + hid_t hklGid = H5Gopen(pid, ebsdlib::Ang::HKLFamilies.c_str(), H5P_DEFAULT); // Only read the HKL Families if they are there. Trying to open the group will tell us if there // are any families to read @@ -244,16 +246,16 @@ int H5AngReader::readHeader(hid_t parId) } } /* The 'Categories' header may actually be missing from certain types of .ang files */ - if(H5Lite::datasetExists(pid, EbsdLib::Ang::Categories)) + if(H5Lite::datasetExists(pid, ebsdlib::Ang::Categories)) { - READ_PHASE_HEADER_ARRAY("H5AngReader", pid, int, EbsdLib::Ang::Categories, Categories, currentPhase) + READ_PHASE_HEADER_ARRAY("H5AngReader", pid, int, ebsdlib::Ang::Categories, Categories, currentPhase) } m_Phases.push_back(currentPhase); err = H5Gclose(pid); } std::string completeHeader; - err = H5Lite::readStringDataset(gid, EbsdLib::H5OIM::OriginalHeader, completeHeader); + err = H5Lite::readStringDataset(gid, ebsdlib::H5OIM::OriginalHeader, completeHeader); if(err < 0) { setErrorCode(-90010); @@ -331,7 +333,7 @@ int H5AngReader::readData(hid_t parId) setErrorCode(err); return err; } - if(grid.find(EbsdLib::Ang::SquareGrid) == 0) + if(grid.find(ebsdlib::Ang::SquareGrid) == 0) { // if (nCols > 0) { numElements = nRows * nCols; } if(nOddCols > 0) @@ -347,7 +349,7 @@ int H5AngReader::readData(hid_t parId) totalDataRows = 0; } } - else if(grid.find(EbsdLib::Ang::HexGrid) == 0) + else if(grid.find(ebsdlib::Ang::HexGrid) == 0) { setErrorCode(-90400); setErrorMessage("Ang Files with Hex Grids Are NOT currently supported. Please convert them to Square Grid files first"); @@ -360,7 +362,7 @@ int H5AngReader::readData(hid_t parId) return -300; } - hid_t gid = H5Gopen(parId, EbsdLib::H5OIM::Data.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OIM::Data.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorMessage("H5AngReader Error: Could not open 'Data' Group"); @@ -382,21 +384,21 @@ int H5AngReader::readData(hid_t parId) } // Initialize new pointers - ANG_READER_ALLOCATE_AND_READ(Phi1, EbsdLib::Ang::Phi1, float); - ANG_READER_ALLOCATE_AND_READ(Phi, EbsdLib::Ang::Phi, float); - ANG_READER_ALLOCATE_AND_READ(Phi2, EbsdLib::Ang::Phi2, float); - ANG_READER_ALLOCATE_AND_READ(ImageQuality, EbsdLib::Ang::ImageQuality, float); - ANG_READER_ALLOCATE_AND_READ(ConfidenceIndex, EbsdLib::Ang::ConfidenceIndex, float); - ANG_READER_ALLOCATE_AND_READ(PhaseData, EbsdLib::Ang::PhaseData, int); - ANG_READER_ALLOCATE_AND_READ(XPosition, EbsdLib::Ang::XPosition, float); - ANG_READER_ALLOCATE_AND_READ(YPosition, EbsdLib::Ang::YPosition, float); - ANG_READER_ALLOCATE_AND_READ(Fit, EbsdLib::Ang::Fit, float); + ANG_READER_ALLOCATE_AND_READ(Phi1, ebsdlib::Ang::Phi1, float); + ANG_READER_ALLOCATE_AND_READ(Phi, ebsdlib::Ang::Phi, float); + ANG_READER_ALLOCATE_AND_READ(Phi2, ebsdlib::Ang::Phi2, float); + ANG_READER_ALLOCATE_AND_READ(ImageQuality, ebsdlib::Ang::ImageQuality, float); + ANG_READER_ALLOCATE_AND_READ(ConfidenceIndex, ebsdlib::Ang::ConfidenceIndex, float); + ANG_READER_ALLOCATE_AND_READ(PhaseData, ebsdlib::Ang::PhaseData, int); + ANG_READER_ALLOCATE_AND_READ(XPosition, ebsdlib::Ang::XPosition, float); + ANG_READER_ALLOCATE_AND_READ(YPosition, ebsdlib::Ang::YPosition, float); + ANG_READER_ALLOCATE_AND_READ(Fit, ebsdlib::Ang::Fit, float); if(err < 0) { setNumFeatures(9); } - ANG_READER_ALLOCATE_AND_READ(SEMSignal, EbsdLib::Ang::SEMSignal, float); + ANG_READER_ALLOCATE_AND_READ(SEMSignal, ebsdlib::Ang::SEMSignal, float); if(err < 0) { setNumFeatures(8); diff --git a/Source/EbsdLib/IO/TSL/H5AngReader.h b/Source/EbsdLib/IO/TSL/H5AngReader.h index 6216d9e4..c9485ca5 100644 --- a/Source/EbsdLib/IO/TSL/H5AngReader.h +++ b/Source/EbsdLib/IO/TSL/H5AngReader.h @@ -47,6 +47,8 @@ #include "AngPhase.h" #include "AngReader.h" +namespace ebsdlib +{ /** * @class H5AngReader H5AngReader.h EbsdLib/IO/TSL/H5AngReader.h * @brief @@ -203,3 +205,4 @@ class EbsdLib_EXPORT H5AngReader : public AngReader H5AngReader& operator=(const H5AngReader&) = delete; // Copy Assignment Not Implemented H5AngReader& operator=(H5AngReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/H5AngVolumeReader.cpp b/Source/EbsdLib/IO/TSL/H5AngVolumeReader.cpp index f9a82bdf..fd2c3037 100644 --- a/Source/EbsdLib/IO/TSL/H5AngVolumeReader.cpp +++ b/Source/EbsdLib/IO/TSL/H5AngVolumeReader.cpp @@ -46,6 +46,8 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -73,7 +75,7 @@ H5AngVolumeReader::~H5AngVolumeReader() } #define H5ANGREADER_ALLOCATE_ARRAY(name, type) \ - if(readAllArrays == true || arrayNames.find(EbsdLib::Ang::name) != arrayNames.end()) \ + if(readAllArrays == true || arrayNames.find(ebsdlib::Ang::name) != arrayNames.end()) \ { \ auto _##name = allocateArray(numElements); \ if(nullptr != _##name) \ @@ -127,43 +129,43 @@ void H5AngVolumeReader::deletePointers() // ----------------------------------------------------------------------------- void* H5AngVolumeReader::getPointerByName(const std::string& featureName) { - if(featureName == EbsdLib::Ang::Phi1) + if(featureName == ebsdlib::Ang::Phi1) { return static_cast(m_Phi1); } - if(featureName == EbsdLib::Ang::Phi) + if(featureName == ebsdlib::Ang::Phi) { return static_cast(m_Phi); } - if(featureName == EbsdLib::Ang::Phi2) + if(featureName == ebsdlib::Ang::Phi2) { return static_cast(m_Phi2); } - if(featureName == EbsdLib::Ang::ImageQuality) + if(featureName == ebsdlib::Ang::ImageQuality) { return static_cast(m_Iq); } - if(featureName == EbsdLib::Ang::ConfidenceIndex) + if(featureName == ebsdlib::Ang::ConfidenceIndex) { return static_cast(m_Ci); } - if(featureName == EbsdLib::Ang::PhaseData) + if(featureName == ebsdlib::Ang::PhaseData) { return static_cast(m_PhaseData); } - if(featureName == EbsdLib::Ang::XPosition) + if(featureName == ebsdlib::Ang::XPosition) { return static_cast(m_X); } - if(featureName == EbsdLib::Ang::YPosition) + if(featureName == ebsdlib::Ang::YPosition) { return static_cast(m_Y); } - if(featureName == EbsdLib::Ang::SEMSignal) + if(featureName == ebsdlib::Ang::SEMSignal) { return static_cast(m_SEMSignal); } - if(featureName == EbsdLib::Ang::Fit) + if(featureName == ebsdlib::Ang::Fit) { return static_cast(m_Fit); } @@ -173,49 +175,49 @@ void* H5AngVolumeReader::getPointerByName(const std::string& featureName) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::NumericTypes::Type H5AngVolumeReader::getPointerType(const std::string& featureName) +ebsdlib::NumericTypes::Type H5AngVolumeReader::getPointerType(const std::string& featureName) { - if(featureName == EbsdLib::Ang::Phi1) + if(featureName == ebsdlib::Ang::Phi1) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Phi) + if(featureName == ebsdlib::Ang::Phi) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Phi2) + if(featureName == ebsdlib::Ang::Phi2) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::ImageQuality) + if(featureName == ebsdlib::Ang::ImageQuality) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::ConfidenceIndex) + if(featureName == ebsdlib::Ang::ConfidenceIndex) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::PhaseData) + if(featureName == ebsdlib::Ang::PhaseData) { - return EbsdLib::NumericTypes::Type::Int32; + return ebsdlib::NumericTypes::Type::Int32; } - if(featureName == EbsdLib::Ang::XPosition) + if(featureName == ebsdlib::Ang::XPosition) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::YPosition) + if(featureName == ebsdlib::Ang::YPosition) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::SEMSignal) + if(featureName == ebsdlib::Ang::SEMSignal) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - if(featureName == EbsdLib::Ang::Fit) + if(featureName == ebsdlib::Ang::Fit) { - return EbsdLib::NumericTypes::Type::Float; + return ebsdlib::NumericTypes::Type::Float; } - return EbsdLib::NumericTypes::Type::UnknownNumType; + return ebsdlib::NumericTypes::Type::UnknownNumType; } // ----------------------------------------------------------------------------- @@ -361,15 +363,15 @@ int H5AngVolumeReader::loadData(int64_t xpoints, int64_t ypoints, int64_t zpoint ystop = ypointsslice; // If no stacking order preference was passed, read it from the file and use that value - if(ZDir == EbsdLib::RefFrameZDir::UnknownRefFrameZDirection) + if(ZDir == ebsdlib::RefFrameZDir::UnknownRefFrameZDirection) { ZDir = getStackingOrder(); } - if(ZDir == EbsdLib::RefFrameZDir::LowtoHigh) + if(ZDir == ebsdlib::RefFrameZDir::LowtoHigh) { zval = slice; } - if(ZDir == EbsdLib::RefFrameZDir::HightoLow) + if(ZDir == ebsdlib::RefFrameZDir::HightoLow) { zval = static_cast((zpoints - 1) - slice); } diff --git a/Source/EbsdLib/IO/TSL/H5AngVolumeReader.h b/Source/EbsdLib/IO/TSL/H5AngVolumeReader.h index fb572cf8..9361c948 100644 --- a/Source/EbsdLib/IO/TSL/H5AngVolumeReader.h +++ b/Source/EbsdLib/IO/TSL/H5AngVolumeReader.h @@ -44,6 +44,8 @@ #include "EbsdLib/IO/H5EbsdVolumeReader.h" #include "EbsdLib/IO/TSL/AngPhase.h" +namespace ebsdlib +{ /** * @class H5AngVolumeReader H5AngVolumeReader.h Reconstruction/EbsdSupport/H5AngVolumeReader.h * @brief This class loads OIM data from an HDF5 based file. @@ -118,7 +120,7 @@ class EbsdLib_EXPORT H5AngVolumeReader : public H5EbsdVolumeReader * primitive type that the data is stored as (Int, Float, etc). * @param featureName The name of the feature. */ - EbsdLib::NumericTypes::Type getPointerType(const std::string& featureName) override; + ebsdlib::NumericTypes::Type getPointerType(const std::string& featureName) override; /** @brief Allocates the proper amount of memory (after reading the header portion of the file) * and then splats '0' across all the bytes of the memory allocation @@ -184,3 +186,4 @@ class EbsdLib_EXPORT H5AngVolumeReader : public H5EbsdVolumeReader } } }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/IO/TSL/H5OIMReader.cpp b/Source/EbsdLib/IO/TSL/H5OIMReader.cpp index 84388ebb..5e378148 100644 --- a/Source/EbsdLib/IO/TSL/H5OIMReader.cpp +++ b/Source/EbsdLib/IO/TSL/H5OIMReader.cpp @@ -54,31 +54,33 @@ using namespace H5Support; +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- H5OIMReader::H5OIMReader() { // Initialize the map of header key to header value - m_HeaderMap[EbsdLib::Ang::TEMPIXPerUM] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::TEMPIXPerUM); - m_HeaderMap[EbsdLib::Ang::XStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::XStar); - m_HeaderMap[EbsdLib::Ang::YStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::YStar); - m_HeaderMap[EbsdLib::Ang::ZStar] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZStar); - m_HeaderMap[EbsdLib::Ang::Working_Distance] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::Working_Distance); - m_HeaderMap[EbsdLib::Ang::GridType] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::GridType); - m_HeaderMap[EbsdLib::Ang::StepX] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::StepX); - m_HeaderMap[EbsdLib::Ang::StepY] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::StepY); - // m_HeaderMap[EbsdLib::Ang::ZStep] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZStep); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - // m_HeaderMap[EbsdLib::Ang::ZPos] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZPos); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - // m_HeaderMap[EbsdLib::Ang::ZMax] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ZMax); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed - m_HeaderMap[EbsdLib::Ang::nColumns] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::nColumns); - m_HeaderMap[EbsdLib::Ang::nRows] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::nRows); - m_HeaderMap[EbsdLib::Ang::Operator] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::Operator); - m_HeaderMap[EbsdLib::Ang::SampleID] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::SampleID); - m_HeaderMap[EbsdLib::Ang::ScanID] = AngStringHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::ScanID); - - m_HeaderMap[EbsdLib::Ang::PatternWidth] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::PatternWidth); - m_HeaderMap[EbsdLib::Ang::PatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(EbsdLib::Ang::PatternHeight); + m_HeaderMap[ebsdlib::Ang::TEMPIXPerUM] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::TEMPIXPerUM); + m_HeaderMap[ebsdlib::Ang::XStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::XStar); + m_HeaderMap[ebsdlib::Ang::YStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::YStar); + m_HeaderMap[ebsdlib::Ang::ZStar] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZStar); + m_HeaderMap[ebsdlib::Ang::Working_Distance] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::Working_Distance); + m_HeaderMap[ebsdlib::Ang::GridType] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::GridType); + m_HeaderMap[ebsdlib::Ang::StepX] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::StepX); + m_HeaderMap[ebsdlib::Ang::StepY] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::StepY); + // m_HeaderMap[ebsdlib::Ang::ZStep] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZStep); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + // m_HeaderMap[ebsdlib::Ang::ZPos] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZPos); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + // m_HeaderMap[ebsdlib::Ang::ZMax] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ZMax); // NOT actually in the file>::NewEbsdHeaderEntry(); , but may be needed + m_HeaderMap[ebsdlib::Ang::nColumns] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::nColumns); + m_HeaderMap[ebsdlib::Ang::nRows] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::nRows); + m_HeaderMap[ebsdlib::Ang::Operator] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::Operator); + m_HeaderMap[ebsdlib::Ang::SampleID] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::SampleID); + m_HeaderMap[ebsdlib::Ang::ScanID] = AngStringHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::ScanID); + + m_HeaderMap[ebsdlib::Ang::PatternWidth] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::PatternWidth); + m_HeaderMap[ebsdlib::Ang::PatternHeight] = AngHeaderEntry::NewEbsdHeaderEntry(ebsdlib::Ang::PatternHeight); m_PatternDims[0] = 0; m_PatternDims[1] = 0; @@ -132,7 +134,7 @@ int H5OIMReader::readFile() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5OIM::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5OIM::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { std::string str; @@ -170,7 +172,7 @@ int H5OIMReader::readFile() std::vector indexMap; std::string grid = getGrid(); - if(grid.find(EbsdLib::Ang::SquareGrid) == 0) + if(grid.find(ebsdlib::Ang::SquareGrid) == 0) { std::pair result = fixOrderOfData(indexMap); @@ -185,11 +187,11 @@ int H5OIMReader::readFile() { void* oldArray = getPointerByName(arrayName); - if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Float) + if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Float) { CopyTupleUsingIndexList(oldArray, indexMap); } - else if(getPointerType(arrayName) == EbsdLib::NumericTypes::Type::Int32) + else if(getPointerType(arrayName) == ebsdlib::NumericTypes::Type::Int32) { CopyTupleUsingIndexList(oldArray, indexMap); } @@ -249,14 +251,14 @@ int H5OIMReader::readHeaderOnly() } // Read and parse the OIM Analysis version that created the file. - if(H5Lite::datasetExists(fileId, EbsdLib::H5OIM::Version7)) + if(H5Lite::datasetExists(fileId, ebsdlib::H5OIM::Version7)) { - err = H5Lite::readStringDataset(fileId, EbsdLib::H5OIM::Version7, m_OIMVersion); + err = H5Lite::readStringDataset(fileId, ebsdlib::H5OIM::Version7, m_OIMVersion); } // Read and parse the OIM Analysis version that created the file. - if(H5Lite::datasetExists(fileId, EbsdLib::H5OIM::Version8)) + if(H5Lite::datasetExists(fileId, ebsdlib::H5OIM::Version8)) { - err = H5Lite::readStringDataset(fileId, EbsdLib::H5OIM::Version8, m_OIMVersion); + err = H5Lite::readStringDataset(fileId, ebsdlib::H5OIM::Version8, m_OIMVersion); } hid_t gid = H5Gopen(fileId, m_HDF5Path.c_str(), H5P_DEFAULT); if(gid < 0) @@ -270,7 +272,7 @@ int H5OIMReader::readHeaderOnly() } sentinel.addGroupId(gid); - hid_t ebsdGid = H5Gopen(gid, EbsdLib::H5OIM::EBSD.c_str(), H5P_DEFAULT); + hid_t ebsdGid = H5Gopen(gid, ebsdlib::H5OIM::EBSD.c_str(), H5P_DEFAULT); if(ebsdGid < 0) { setErrorMessage("H5OIMReader Error: Could not open 'EBSD' Group"); @@ -317,7 +319,7 @@ int H5OIMReader::readHeader(hid_t parId) using AngHeaderIntType = AngHeaderEntry; int err = -1; - hid_t gid = H5Gopen(parId, EbsdLib::H5OIM::Header.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OIM::Header.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorCode(-90008); @@ -326,47 +328,47 @@ int H5OIMReader::readHeader(hid_t parId) } H5ScopedGroupSentinel sentinel(gid, false); - // std::string path = EbsdLib::H5OIM::PatternCenterCalibration + "/" + EbsdLib::Ang::XStar; - hid_t patternCenterCalibrationGid = H5Gopen(gid, EbsdLib::H5OIM::PatternCenterCalibration.c_str(), H5P_DEFAULT); + // std::string path = ebsdlib::H5OIM::PatternCenterCalibration + "/" + ebsdlib::Ang::XStar; + hid_t patternCenterCalibrationGid = H5Gopen(gid, ebsdlib::H5OIM::PatternCenterCalibration.c_str(), H5P_DEFAULT); if(patternCenterCalibrationGid < 0) { setErrorCode(-90008); setErrorMessage("H5OIMReader Error: Could not open 'Pattern Center Calibration' Group"); return -1; } - ReadH5EbsdHeaderData(this, EbsdLib::Ang::XStar, patternCenterCalibrationGid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::YStar, patternCenterCalibrationGid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::ZStar, patternCenterCalibrationGid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::XStar, patternCenterCalibrationGid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::YStar, patternCenterCalibrationGid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::ZStar, patternCenterCalibrationGid, m_HeaderMap); err = H5Gclose(patternCenterCalibrationGid); patternCenterCalibrationGid = -1; - ReadH5EbsdHeaderData(this, EbsdLib::Ang::Working_Distance, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::StepX, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::StepY, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::nColumns, gid, m_HeaderMap); - ReadH5EbsdHeaderData(this, EbsdLib::Ang::nRows, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::Working_Distance, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::StepX, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::StepY, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::nColumns, gid, m_HeaderMap); + ReadH5EbsdHeaderData(this, ebsdlib::Ang::nRows, gid, m_HeaderMap); { - AngHeaderIntType::Pointer intValuePtr = std::dynamic_pointer_cast(m_HeaderMap[EbsdLib::Ang::nColumns]); + AngHeaderIntType::Pointer intValuePtr = std::dynamic_pointer_cast(m_HeaderMap[ebsdlib::Ang::nColumns]); setNumOddCols(intValuePtr->getValue()); setNumEvenCols(intValuePtr->getValue()); - intValuePtr = std::dynamic_pointer_cast(m_HeaderMap[EbsdLib::Ang::nRows]); + intValuePtr = std::dynamic_pointer_cast(m_HeaderMap[ebsdlib::Ang::nRows]); setNumRows(intValuePtr->getValue()); - AngHeaderFloatType::Pointer floatValuePtr = std::dynamic_pointer_cast(m_HeaderMap[EbsdLib::Ang::StepX]); + AngHeaderFloatType::Pointer floatValuePtr = std::dynamic_pointer_cast(m_HeaderMap[ebsdlib::Ang::StepX]); setXStep(floatValuePtr->getValue()); - floatValuePtr = std::dynamic_pointer_cast(m_HeaderMap[EbsdLib::Ang::StepY]); + floatValuePtr = std::dynamic_pointer_cast(m_HeaderMap[ebsdlib::Ang::StepY]); setYStep(floatValuePtr->getValue()); } HDF_ERROR_HANDLER_OFF int value = 0; - if(H5Lite::datasetExists(gid, EbsdLib::Ang::PatternWidth)) + if(H5Lite::datasetExists(gid, ebsdlib::Ang::PatternWidth)) { // Read the Pattern Width - This may not exist - err = H5Lite::readScalarDataset(gid, EbsdLib::Ang::PatternWidth, value); - EbsdHeaderEntry::Pointer p = m_HeaderMap[EbsdLib::Ang::PatternWidth]; + err = H5Lite::readScalarDataset(gid, ebsdlib::Ang::PatternWidth, value); + EbsdHeaderEntry::Pointer p = m_HeaderMap[ebsdlib::Ang::PatternWidth]; AngHeaderIntType::Pointer c = std::dynamic_pointer_cast(p); c->setValue(value); m_PatternDims[1] = value; @@ -374,10 +376,10 @@ int H5OIMReader::readHeader(hid_t parId) // Read the Pattern Height - This may not exist value = 0; - if(H5Lite::datasetExists(gid, EbsdLib::Ang::PatternHeight)) + if(H5Lite::datasetExists(gid, ebsdlib::Ang::PatternHeight)) { - err = H5Lite::readScalarDataset(gid, EbsdLib::Ang::PatternHeight, value); - EbsdHeaderEntry::Pointer p = m_HeaderMap[EbsdLib::Ang::PatternHeight]; + err = H5Lite::readScalarDataset(gid, ebsdlib::Ang::PatternHeight, value); + EbsdHeaderEntry::Pointer p = m_HeaderMap[ebsdlib::Ang::PatternHeight]; AngHeaderIntType::Pointer c = std::dynamic_pointer_cast(p); c->setValue(value); m_PatternDims[0] = value; @@ -385,21 +387,21 @@ int H5OIMReader::readHeader(hid_t parId) HDF_ERROR_HANDLER_ON // Version 7/8 - ReadH5EbsdHeaderStringData(this, EbsdLib::Ang::GridType, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::Ang::GridType, gid, m_HeaderMap); { - AngStringHeaderEntry::Pointer strValuePtr = std::dynamic_pointer_cast(m_HeaderMap[EbsdLib::Ang::GridType]); + AngStringHeaderEntry::Pointer strValuePtr = std::dynamic_pointer_cast(m_HeaderMap[ebsdlib::Ang::GridType]); setGrid(strValuePtr->getValue()); } // Version 7 Only - if(m_OIMVersion.find(EbsdLib::H5OIM::OIMAnalysisVersion7) != std::string::npos) + if(m_OIMVersion.find(ebsdlib::H5OIM::OIMAnalysisVersion7) != std::string::npos) { - ReadH5EbsdHeaderStringData(this, EbsdLib::Ang::Operator, gid, m_HeaderMap); - ReadH5EbsdHeaderStringData(this, EbsdLib::Ang::SampleID, gid, m_HeaderMap); - ReadH5EbsdHeaderStringData(this, EbsdLib::Ang::ScanID, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::Ang::Operator, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::Ang::SampleID, gid, m_HeaderMap); + ReadH5EbsdHeaderStringData(this, ebsdlib::Ang::ScanID, gid, m_HeaderMap); } - hid_t phasesGid = H5Gopen(gid, EbsdLib::H5OIM::Phase.c_str(), H5P_DEFAULT); + hid_t phasesGid = H5Gopen(gid, ebsdlib::H5OIM::Phase.c_str(), H5P_DEFAULT); if(phasesGid < 0) { setErrorCode(-90007); @@ -428,24 +430,24 @@ int H5OIMReader::readHeader(hid_t parId) AngPhase::Pointer currentPhase = AngPhase::New(); currentPhase->setPhaseIndex(std::stoi(phaseGroupName)); - READ_PHASE_STRING_DATA("H5OIMReader", pid, EbsdLib::Ang::MaterialName, MaterialName, currentPhase) - READ_PHASE_STRING_DATA("H5OIMReader", pid, EbsdLib::Ang::Formula, Formula, currentPhase) - // READ_PHASE_STRING_DATA("H5OIMReader", pid, EbsdLib::Ang::Info, Info, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, int32_t, EbsdLib::Ang::Symmetry, Symmetry, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, int32_t, EbsdLib::Ang::NumberFamilies, NumberFamilies, currentPhase) + READ_PHASE_STRING_DATA("H5OIMReader", pid, ebsdlib::Ang::MaterialName, MaterialName, currentPhase) + READ_PHASE_STRING_DATA("H5OIMReader", pid, ebsdlib::Ang::Formula, Formula, currentPhase) + // READ_PHASE_STRING_DATA("H5OIMReader", pid, ebsdlib::Ang::Info, Info, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, int32_t, ebsdlib::Ang::Symmetry, Symmetry, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, int32_t, ebsdlib::Ang::NumberFamilies, NumberFamilies, currentPhase) std::vector fillerValues(6, 0.0); currentPhase->setLatticeConstants(fillerValues); - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantA, LatticeConstantA, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantB, LatticeConstantB, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantC, LatticeConstantC, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantAlpha, LatticeConstantAlpha, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantBeta, LatticeConstantBeta, currentPhase) - READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, EbsdLib::Ang::LatticeConstantGamma, LatticeConstantGamma, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantA, LatticeConstantA, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantB, LatticeConstantB, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantC, LatticeConstantC, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantAlpha, LatticeConstantAlpha, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantBeta, LatticeConstantBeta, currentPhase) + READ_PHASE_HEADER_DATA("H5OIMReader", pid, float, ebsdlib::Ang::LatticeConstantGamma, LatticeConstantGamma, currentPhase) if(currentPhase->getNumberFamilies() > 0) { - // hid_t hklGid = H5Gopen(pid, EbsdLib::Ang::HKLFamilies.c_str(), H5P_DEFAULT); + // hid_t hklGid = H5Gopen(pid, ebsdlib::Ang::HKLFamilies.c_str(), H5P_DEFAULT); // Only read the HKL Families if they are there. Trying to open the group will tell us if there // are any families to read @@ -457,9 +459,9 @@ int H5OIMReader::readHeader(hid_t parId) } } /* The 'Categories' header may actually be missing from certain types of .ang files */ - if(H5Lite::datasetExists(pid, EbsdLib::Ang::Categories)) + if(H5Lite::datasetExists(pid, ebsdlib::Ang::Categories)) { - READ_PHASE_HEADER_ARRAY("H5OIMReader", pid, int, EbsdLib::Ang::Categories, Categories, currentPhase) + READ_PHASE_HEADER_ARRAY("H5OIMReader", pid, int, ebsdlib::Ang::Categories, Categories, currentPhase) } phaseVector.push_back(currentPhase); err = H5Gclose(pid); @@ -494,7 +496,7 @@ int H5OIMReader::readHKLFamilies(hid_t hklGid, const AngPhase::Pointer& phase) H5Tinsert(memtype, "Show bands", HOFFSET(HKLFamily_t, s2), H5T_NATIVE_CHAR); // Create dataspace & dataset - hid_t dataset = H5Dopen(hklGid, EbsdLib::Ang::HKL_Families.c_str(), H5P_DEFAULT); + hid_t dataset = H5Dopen(hklGid, ebsdlib::Ang::HKL_Families.c_str(), H5P_DEFAULT); hid_t dataspace = H5Dget_space(dataset); int rank = H5Sget_simple_extent_ndims(dataspace); if(rank == 1) @@ -555,7 +557,7 @@ int H5OIMReader::readData(hid_t parId) setErrorCode(err); return err; } - if(grid.find(EbsdLib::Ang::SquareGrid) == 0) + if(grid.find(ebsdlib::Ang::SquareGrid) == 0) { // if (nCols > 0) { numElements = nRows * nCols; } if(nColumns > 0) @@ -567,7 +569,7 @@ int H5OIMReader::readData(hid_t parId) totalDataRows = 0; } } - else if(grid.find(EbsdLib::Ang::HexGrid) == 0) + else if(grid.find(ebsdlib::Ang::HexGrid) == 0) { setErrorCode(-90400); setErrorMessage("Ang Files with Hex Grids Are NOT currently supported. Please convert them to Square Grid files first"); @@ -587,7 +589,7 @@ int H5OIMReader::readData(hid_t parId) return -301; } - hid_t gid = H5Gopen(parId, EbsdLib::H5OIM::Data.c_str(), H5P_DEFAULT); + hid_t gid = H5Gopen(parId, ebsdlib::H5OIM::Data.c_str(), H5P_DEFAULT); if(gid < 0) { setErrorMessage("H5OIMReader Error: Could not open 'Data' Group"); @@ -608,22 +610,22 @@ int H5OIMReader::readData(hid_t parId) return err; } - ANG_READER_ALLOCATE_AND_READ(Phi1, EbsdLib::Ang::Phi1, float); - ANG_READER_ALLOCATE_AND_READ(Phi, EbsdLib::Ang::Phi, float); - ANG_READER_ALLOCATE_AND_READ(Phi2, EbsdLib::Ang::Phi2, float); - ANG_READER_ALLOCATE_AND_READ(ImageQuality, EbsdLib::Ang::IQ, float); - ANG_READER_ALLOCATE_AND_READ(ConfidenceIndex, EbsdLib::Ang::CI, float); - ANG_READER_ALLOCATE_AND_READ(PhaseData, EbsdLib::Ang::Phase, int); - ANG_READER_ALLOCATE_AND_READ(XPosition, EbsdLib::Ang::XPosition, float); - ANG_READER_ALLOCATE_AND_READ(YPosition, EbsdLib::Ang::YPosition, float); - ANG_READER_ALLOCATE_AND_READ(Fit, EbsdLib::Ang::Fit, float); + ANG_READER_ALLOCATE_AND_READ(Phi1, ebsdlib::Ang::Phi1, float); + ANG_READER_ALLOCATE_AND_READ(Phi, ebsdlib::Ang::Phi, float); + ANG_READER_ALLOCATE_AND_READ(Phi2, ebsdlib::Ang::Phi2, float); + ANG_READER_ALLOCATE_AND_READ(ImageQuality, ebsdlib::Ang::IQ, float); + ANG_READER_ALLOCATE_AND_READ(ConfidenceIndex, ebsdlib::Ang::CI, float); + ANG_READER_ALLOCATE_AND_READ(PhaseData, ebsdlib::Ang::Phase, int); + ANG_READER_ALLOCATE_AND_READ(XPosition, ebsdlib::Ang::XPosition, float); + ANG_READER_ALLOCATE_AND_READ(YPosition, ebsdlib::Ang::YPosition, float); + ANG_READER_ALLOCATE_AND_READ(Fit, ebsdlib::Ang::Fit, float); if(err < 0) { setNumFeatures(9); } - ANG_READER_ALLOCATE_AND_READ(SEMSignal, EbsdLib::Ang::SEMSignal, float); + ANG_READER_ALLOCATE_AND_READ(SEMSignal, ebsdlib::Ang::SEMSignal, float); if(err < 0) { setNumFeatures(8); @@ -634,7 +636,7 @@ int H5OIMReader::readData(hid_t parId) H5T_class_t type_class; std::vector dims; size_t type_size = 0; - err = H5Lite::getDatasetInfo(gid, EbsdLib::Ang::PatternData, dims, type_class, type_size); + err = H5Lite::getDatasetInfo(gid, ebsdlib::Ang::PatternData, dims, type_class, type_size); if(err >= 0) // Only read the pattern data if the pattern data is available. { totalDataRows = 1; // Calculate the total number of elements to allocate for the pattern data @@ -647,7 +649,7 @@ int H5OIMReader::readData(hid_t parId) m_PatternDims[1] = static_cast(dims[2]); m_PatternData = this->allocateArray(totalDataRows); - err = H5Lite::readPointerDataset(gid, EbsdLib::Ang::PatternData, m_PatternData); + err = H5Lite::readPointerDataset(gid, ebsdlib::Ang::PatternData, m_PatternData); } } err = H5Gclose(gid); diff --git a/Source/EbsdLib/IO/TSL/H5OIMReader.h b/Source/EbsdLib/IO/TSL/H5OIMReader.h index d8afd7ab..4726d253 100644 --- a/Source/EbsdLib/IO/TSL/H5OIMReader.h +++ b/Source/EbsdLib/IO/TSL/H5OIMReader.h @@ -48,6 +48,8 @@ #include "AngPhase.h" #include "AngReader.h" +namespace ebsdlib +{ /** * @class H5OIMReader H5OIMReader.h EbsdLib/IO/TSL/H5OIMReader.h * @brief @@ -128,9 +130,9 @@ class EbsdLib_EXPORT H5OIMReader : public AngReader EBSD_INSTANCE_2DVECTOR_PROPERTY(int, PatternDims) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternWidth, EbsdLib::Ang::PatternWidth) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternWidth, ebsdlib::Ang::PatternWidth) - EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternHeight, EbsdLib::Ang::PatternHeight) + EBSDHEADER_INSTANCE_PROPERTY(AngHeaderEntry, int, PatternHeight, ebsdlib::Ang::PatternHeight) /** * @brief Reads the file @@ -205,3 +207,4 @@ class EbsdLib_EXPORT H5OIMReader : public AngReader H5OIMReader& operator=(const H5OIMReader&) = delete; // Copy Assignment Not Implemented H5OIMReader& operator=(H5OIMReader&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/CubicLowOps.cpp b/Source/EbsdLib/LaueOps/CubicLowOps.cpp index 4b6c35ad..9be7efc6 100644 --- a/Source/EbsdLib/LaueOps/CubicLowOps.cpp +++ b/Source/EbsdLib/LaueOps/CubicLowOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -52,14 +53,15 @@ #include #include #endif +using namespace ebsdlib; namespace CubicLow { static const std::array OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (EbsdLib::Constants::k_PiOver2D - std::sin(EbsdLib::Constants::k_PiOver2D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver2D - std::sin(EbsdLib::Constants::k_PiOver2D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver2D - std::sin(EbsdLib::Constants::k_PiOver2D))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0]) / 2.0, OdfDimInitValue[1] / static_cast(OdfNumBins[1]) / 2.0, OdfDimInitValue[2] / static_cast(OdfNumBins[2]) / 2.0}; @@ -271,13 +273,13 @@ void CubicLowOps::getRodSymOp(int i, double* r) const r[2] = CubicLow::RodSym[i][2]; } -EbsdLib::Matrix3X3D CubicLowOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D CubicLowOps::getMatSymOpD(int i) const { return {CubicLow::MatSym[i][0][0], CubicLow::MatSym[i][0][1], CubicLow::MatSym[i][0][2], CubicLow::MatSym[i][1][0], CubicLow::MatSym[i][1][1], CubicLow::MatSym[i][1][2], CubicLow::MatSym[i][2][0], CubicLow::MatSym[i][2][1], CubicLow::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F CubicLowOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F CubicLowOps::getMatSymOpF(int i) const { return {static_cast(CubicLow::MatSym[i][0][0]), static_cast(CubicLow::MatSym[i][0][1]), static_cast(CubicLow::MatSym[i][0][2]), static_cast(CubicLow::MatSym[i][1][0]), static_cast(CubicLow::MatSym[i][1][1]), static_cast(CubicLow::MatSym[i][1][2]), @@ -450,7 +452,7 @@ EulerDType CubicLowOps::determineEulerAngles(double random[3], int choose) const EulerDType CubicLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(CubicLow::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = CubicLow::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -587,13 +589,13 @@ namespace CubicLow { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -604,12 +606,12 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -639,44 +641,44 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // 011 Family - direction[0] = EbsdLib::Constants::k_1OverRoot2D; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = ebsdlib::constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36)); std::transform(m_xyz011->getPointer(i * 36), m_xyz011->getPointer(i * 36 + 3), m_xyz011->getPointer(i * 36 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = ebsdlib::constants::k_1OverRoot2D; direction[1] = 0.0; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 6)); std::transform(m_xyz011->getPointer(i * 36 + 6), m_xyz011->getPointer(i * 36 + 9), m_xyz011->getPointer(i * 36 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = 0.0; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 12)); std::transform(m_xyz011->getPointer(i * 36 + 12), m_xyz011->getPointer(i * 36 + 15), m_xyz011->getPointer(i * 36 + 15), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot2D; - direction[1] = -EbsdLib::Constants::k_1OverRoot2D; + direction[0] = -ebsdlib::constants::k_1OverRoot2D; + direction[1] = -ebsdlib::constants::k_1OverRoot2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 18)); std::transform(m_xyz011->getPointer(i * 36 + 18), m_xyz011->getPointer(i * 36 + 21), m_xyz011->getPointer(i * 36 + 21), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot2D; + direction[0] = -ebsdlib::constants::k_1OverRoot2D; direction[1] = 0.0; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 24)); std::transform(m_xyz011->getPointer(i * 36 + 24), m_xyz011->getPointer(i * 36 + 27), m_xyz011->getPointer(i * 36 + 27), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = 0.0; - direction[1] = -EbsdLib::Constants::k_1OverRoot2D; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[1] = -ebsdlib::constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 30)); std::transform(m_xyz011->getPointer(i * 36 + 30), m_xyz011->getPointer(i * 36 + 33), m_xyz011->getPointer(i * 36 + 33), // write to the next triplet in memory @@ -684,30 +686,30 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // 111 Family - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24)); std::transform(m_xyz111->getPointer(i * 24), m_xyz111->getPointer(i * 24 + 3), m_xyz111->getPointer(i * 24 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = -ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 6)); std::transform(m_xyz111->getPointer(i * 24 + 6), m_xyz111->getPointer(i * 24 + 9), m_xyz111->getPointer(i * 24 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = -EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = -ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 12)); std::transform(m_xyz111->getPointer(i * 24 + 12), m_xyz111->getPointer(i * 24 + 15), m_xyz111->getPointer(i * 24 + 15), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = -EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = -ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 18)); std::transform(m_xyz111->getPointer(i * 24 + 18), m_xyz111->getPointer(i * 24 + 21), m_xyz111->getPointer(i * 24 + 21), // write to the next triplet in memory @@ -727,7 +729,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CubicLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void CubicLowOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -762,19 +764,19 @@ void CubicLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers // ----------------------------------------------------------------------------- std::array CubicLowOps::getIpfColorAngleLimits(double eta) const { - double etaDeg = eta * EbsdLib::Constants::k_180OverPiD; + double etaDeg = eta * ebsdlib::constants::k_180OverPiD; double chiMax; if(etaDeg > 45.0) { - chiMax = sqrt(1.0 / (2.0 + tan(0.5 * EbsdLib::Constants::k_PiD - eta) * tan(0.5 * EbsdLib::Constants::k_PiD - eta))); + chiMax = sqrt(1.0 / (2.0 + tan(0.5 * ebsdlib::constants::k_PiD - eta) * tan(0.5 * ebsdlib::constants::k_PiD - eta))); } else { chiMax = sqrt(1.0 / (2.0 + tan(eta) * tan(eta))); } - EbsdLibMath::bound(chiMax, -1.0, 1.0); + ebsdlib::math::bound(chiMax, -1.0, 1.0); chiMax = acos(chiMax); - return {CubicLow::k_EtaMin * EbsdLib::Constants::k_DegToRadD, CubicLow::k_EtaMax * EbsdLib::Constants::k_DegToRadD, chiMax}; + return {CubicLow::k_EtaMin * ebsdlib::constants::k_DegToRadD, CubicLow::k_EtaMax * ebsdlib::constants::k_DegToRadD, chiMax}; } // ----------------------------------------------------------------------------- @@ -782,29 +784,29 @@ std::array CubicLowOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool CubicLowOps::inUnitTriangle(double eta, double chi) const { - double etaDeg = eta * EbsdLib::Constants::k_180OverPiD; + double etaDeg = eta * ebsdlib::constants::k_180OverPiD; double chiMax; if(etaDeg > 45.0) { - chiMax = sqrt(1.0 / (2.0 + tan(0.5 * EbsdLib::Constants::k_PiD - eta) * tan(0.5 * EbsdLib::Constants::k_PiD - eta))); + chiMax = sqrt(1.0 / (2.0 + tan(0.5 * ebsdlib::constants::k_PiD - eta) * tan(0.5 * ebsdlib::constants::k_PiD - eta))); } else { chiMax = sqrt(1.0 / (2.0 + tan(eta) * tan(eta))); } - EbsdLibMath::bound(chiMax, -1.0, 1.0); + ebsdlib::math::bound(chiMax, -1.0, 1.0); chiMax = acos(chiMax); - return !(eta < CubicLow::k_EtaMin || eta > (CubicLow::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); + return !(eta < CubicLow::k_EtaMin || eta > (CubicLow::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); } // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb CubicLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -814,7 +816,7 @@ EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicLowOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb CubicLowOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * CubicLow::OdfDimInitValue[0]; double range2 = 2.0f * CubicLow::OdfDimInitValue[1]; @@ -831,7 +833,7 @@ EbsdLib::Rgb CubicLowOps::generateRodriguesColor(double r1, double r2, double r3 green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -845,7 +847,7 @@ std::array CubicLowOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector CubicLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector CubicLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -869,11 +871,11 @@ std::vector CubicLowOps::generatePoleFigure(Po // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicLow::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -882,9 +884,9 @@ std::vector CubicLowOps::generatePoleFigure(Po // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -957,11 +959,11 @@ std::vector CubicLowOps::generatePoleFigure(Po config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -1001,11 +1003,11 @@ std::vector CubicLowOps::generatePoleFigure(Po namespace { -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicLowOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicLowOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); auto* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0 / static_cast(imageDim); @@ -1030,8 +1032,8 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicLowOps* ops, int ima double sumSquares = (x * x) + (y * y); - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0f) { @@ -1083,7 +1085,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float { float radius = 1.0; // Work with a Unit Circle. float angle = angles[idx]; - float rads = angle * EbsdLib::Constants::k_DegToRadF; + float rads = angle * ebsdlib::constants::k_DegToRadF; float x = radius * (cos(rads)); float y = radius * (sin(rads)); @@ -1109,7 +1111,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -1121,7 +1123,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); } } @@ -1132,9 +1134,9 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line {0.0, 1.0, 1.0}, // Vertical Meridian Line {-1.0, 1.0, 0.0}, // Upper Left to Lower Right @@ -1146,7 +1148,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); + ebsdlib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); } if(!drawFullCircle) @@ -1155,34 +1157,34 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(label.c_str()); float x = figureCenter[0] + fontWidth * 0.20F; float y = fontPtSize * 3.0F; - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); x = figureCenter[0]; y = figureCenter[1] + fontPtSize; label = "[001]"; - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); x = figureCenter[0] + static_cast(legendWidth) * 0.85F; y = figureCenter[1] + fontPtSize; label = "[101]"; - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); x = figureCenter[0] + static_cast(legendWidth) * 0.75F; y = figureCenter[1] - static_cast(legendHeight) * 0.75F; label = "[111]"; - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); label = "[011]"; x = figureCenter[0] - context.measure_text(label.c_str()); y = figureCenter[1] - static_cast(legendHeight) * 0.85F; - EbsdLib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); + ebsdlib::WriteText(context, label, {x, y}, static_cast(fontPtSize)); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1216,19 +1218,19 @@ EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int canv std::array figureCenter = {figureOrigin[0] + static_cast(halfWidth), figureOrigin[1] + static_cast(halfHeight)}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1250,7 +1252,7 @@ EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int canv // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5F); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5F); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5F); if(generateEntirePlane) { @@ -1265,12 +1267,12 @@ EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int canv } // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/CubicLowOps.h b/Source/EbsdLib/LaueOps/CubicLowOps.h index fd4f9349..6ac82c1c 100644 --- a/Source/EbsdLib/LaueOps/CubicLowOps.h +++ b/Source/EbsdLib/LaueOps/CubicLowOps.h @@ -39,9 +39,9 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" -#include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class CubicLowOps CubicLowOps.h DREAM3DLib/Common/LaueOps/CubicLowOps.h * @brief @@ -150,7 +150,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +162,8 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +185,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const override; /** * @brief * @param eta Optional input value only needed for the "Cubic" Laue classes @@ -197,9 +197,9 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -210,18 +210,18 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double phi1, double phi, double phi2, double dir0, double dir1, double dir2, bool degToRad) const override; + ebsdlib::Rgb generateIPFColor(double phi1, double phi, double phi2, double dir0, double dir1, double dir2, bool degToRad) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -229,10 +229,10 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -244,7 +244,7 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -267,3 +267,4 @@ class EbsdLib_EXPORT CubicLowOps : public LaueOps CubicLowOps& operator=(const CubicLowOps&) = delete; // Copy Assignment Not Implemented CubicLowOps& operator=(CubicLowOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/CubicOps.cpp b/Source/EbsdLib/LaueOps/CubicOps.cpp index 41465924..1647bd94 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.cpp +++ b/Source/EbsdLib/LaueOps/CubicOps.cpp @@ -38,9 +38,14 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Math/EbsdMatrixMath.h" #include "EbsdLib/Math/GeometryMath.h" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/OrientationMatrix.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -52,14 +57,15 @@ #include #include #endif +using namespace ebsdlib; namespace CubicHigh { static const std::array OdfNumBins = {18, 18, 18}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (EbsdLib::Constants::k_PiOver4D - std::sin(EbsdLib::Constants::k_PiOver4D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver4D - std::sin(EbsdLib::Constants::k_PiOver4D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver4D - std::sin(EbsdLib::Constants::k_PiOver4D))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -531,9 +537,9 @@ AxisAngleDType CubicOps::calculateMisorientationInternal(const std::vector wmin) + if(((qco.z() + qco.w()) / (ebsdlib::constants::k_Sqrt2D)) > wmin) { - wmin = ((qco.z() + qco.w()) / (EbsdLib::Constants::k_Sqrt2D)); + wmin = ((qco.z() + qco.w()) / (ebsdlib::constants::k_Sqrt2D)); type = 2; } if(((qco.x() + qco.y() + qco.z() + qco.w()) / 2) > wmin) @@ -544,13 +550,13 @@ AxisAngleDType CubicOps::calculateMisorientationInternal(const std::vector 1.0) { // wmin = 1.0; - wmin = EbsdLib::Constants::k_ACos1D; + wmin = ebsdlib::constants::k_ACos1D; sin_wmin_over_2 = std::sin(wmin); } else @@ -570,9 +576,9 @@ AxisAngleDType CubicOps::calculateMisorientationInternal(const std::vector(CubicHigh::MatSym[i][0][0]), static_cast(CubicHigh::MatSym[i][0][1]), static_cast(CubicHigh::MatSym[i][0][2]), static_cast(CubicHigh::MatSym[i][1][0]), static_cast(CubicHigh::MatSym[i][1][1]), static_cast(CubicHigh::MatSym[i][1][2]), @@ -792,7 +798,7 @@ EulerDType CubicOps::determineEulerAngles(double random[3], int choose) const EulerDType CubicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(CubicHigh::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = CubicHigh::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -1025,12 +1031,12 @@ void CubicOps::getSchmidFactorAndSS(double load[3], double plane[3], double dire double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const { - EbsdLib::Matrix3X1D hkl1; - EbsdLib::Matrix3X1D uvw1; - EbsdLib::Matrix3X1D hkl2; - EbsdLib::Matrix3X1D uvw2; - EbsdLib::Matrix3X1D slipDirection; - EbsdLib::Matrix3X1D slipPlane; + ebsdlib::Matrix3X1D hkl1; + ebsdlib::Matrix3X1D uvw1; + ebsdlib::Matrix3X1D hkl2; + ebsdlib::Matrix3X1D uvw2; + ebsdlib::Matrix3X1D slipDirection; + ebsdlib::Matrix3X1D slipPlane; double schmidFactor1 = 0, schmidFactor2 = 0, maxSchmidFactor = 0; double directionComponent1 = 0, planeComponent1 = 0; @@ -1038,8 +1044,8 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const double planeMisalignment = 0, directionMisalignment = 0; int ss1 = 0, ss2 = 0; - EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); - EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); + ebsdlib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrix().transpose(); + ebsdlib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrix().transpose(); for(int i = 0; i < 12; i++) { @@ -1053,8 +1059,8 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const uvw1 = g1 * slipDirection; hkl1 = hkl1.normalize(); uvw1 = uvw1.normalize(); - directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); - planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); + directionComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); + planeComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); schmidFactor1 = directionComponent1 * planeComponent1; if(schmidFactor1 > maxSchmidFactor) { @@ -1090,8 +1096,8 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const hkl2 = hkl2.normalize(); uvw2 = uvw2.normalize(); - directionComponent2 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw2.data())); - planeComponent2 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl2.data())); + directionComponent2 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, uvw2.data())); + planeComponent2 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, hkl2.data())); schmidFactor2 = directionComponent2 * planeComponent2; if(schmidFactor2 > maxSchmidFactor) { @@ -1111,19 +1117,19 @@ double CubicOps::getmPrime(const QuatD& q1, const QuatD& q2, double LD[3]) const hkl2 = hkl2.normalize(); uvw2 = uvw2.normalize(); - planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data())); - directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); + planeMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data())); + directionMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); return planeMisalignment * directionMisalignment; } double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const { - EbsdLib::Matrix3X1D hkl1; - EbsdLib::Matrix3X1D uvw1; - EbsdLib::Matrix3X1D hkl2; - EbsdLib::Matrix3X1D uvw2; - EbsdLib::Matrix3X1D slipDirection; - EbsdLib::Matrix3X1D slipPlane; + ebsdlib::Matrix3X1D hkl1; + ebsdlib::Matrix3X1D uvw1; + ebsdlib::Matrix3X1D hkl2; + ebsdlib::Matrix3X1D uvw2; + ebsdlib::Matrix3X1D slipDirection; + ebsdlib::Matrix3X1D slipPlane; double directionMisalignment = 0, totalDirectionMisalignment = 0; double schmidFactor1 = 0, maxSchmidFactor = 0; @@ -1132,10 +1138,10 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS double maxF1 = 0.0; double F1 = 0.0; - EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); - EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); + ebsdlib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrix().transpose(); + ebsdlib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrix().transpose(); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); if(maxSF) { @@ -1153,8 +1159,8 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS uvw1 = g1 * slipDirection; hkl1 = hkl1.normalize(); uvw1 = uvw1.normalize(); - directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); - planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); + directionComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); + planeComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); schmidFactor1 = directionComponent1 * planeComponent1; if(schmidFactor1 > maxSchmidFactor || !maxSF) { @@ -1176,7 +1182,7 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS hkl2 = hkl2.normalize(); uvw2 = uvw2.normalize(); - directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); + directionMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } F1 = schmidFactor1 * directionComponent1 * totalDirectionMisalignment; @@ -1198,12 +1204,12 @@ double CubicOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const { - EbsdLib::Matrix3X1D hkl1; - EbsdLib::Matrix3X1D uvw1; - EbsdLib::Matrix3X1D hkl2; - EbsdLib::Matrix3X1D uvw2; - EbsdLib::Matrix3X1D slipDirection; - EbsdLib::Matrix3X1D slipPlane; + ebsdlib::Matrix3X1D hkl1; + ebsdlib::Matrix3X1D uvw1; + ebsdlib::Matrix3X1D hkl2; + ebsdlib::Matrix3X1D uvw2; + ebsdlib::Matrix3X1D slipDirection; + ebsdlib::Matrix3X1D slipPlane; double directionMisalignment = 0, totalDirectionMisalignment = 0; double planeMisalignment = 0, totalPlaneMisalignment = 0; @@ -1212,10 +1218,10 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m double maxF1spt = 0.0; double F1spt = 0.0f; - EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); - EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); + ebsdlib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrix().transpose(); + ebsdlib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrix().transpose(); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); if(maxSF) { @@ -1235,8 +1241,8 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m hkl1 = hkl1.normalize(); uvw1 = uvw1.normalize(); - directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); - planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); + directionComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); + planeComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); schmidFactor1 = directionComponent1 * planeComponent1; if(schmidFactor1 > maxSchmidFactor || !maxSF) { @@ -1260,8 +1266,8 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m hkl2 = hkl2.normalize(); uvw2 = uvw2.normalize(); - directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); - planeMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data())); + directionMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); + planeMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(hkl1.data(), hkl2.data())); totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; totalPlaneMisalignment = totalPlaneMisalignment + planeMisalignment; } @@ -1284,12 +1290,12 @@ double CubicOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool m double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const { - EbsdLib::Matrix3X1D hkl1; - EbsdLib::Matrix3X1D uvw1; - EbsdLib::Matrix3X1D hkl2; - EbsdLib::Matrix3X1D uvw2; - EbsdLib::Matrix3X1D slipDirection; - EbsdLib::Matrix3X1D slipPlane; + ebsdlib::Matrix3X1D hkl1; + ebsdlib::Matrix3X1D uvw1; + ebsdlib::Matrix3X1D hkl2; + ebsdlib::Matrix3X1D uvw2; + ebsdlib::Matrix3X1D slipDirection; + ebsdlib::Matrix3X1D slipPlane; double directionMisalignment = 0, totalDirectionMisalignment = 0; double schmidFactor1 = 0.0, maxSchmidFactor = 0.0; @@ -1300,10 +1306,10 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS double maxF7 = 0.0; double F7 = 0.0f; - EbsdLib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrixObj<>().transpose(); - EbsdLib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrixObj<>().transpose(); + ebsdlib::Matrix3X3D g1 = QuaternionDType(q1).toOrientationMatrix().toGMatrix().transpose(); + ebsdlib::Matrix3X3D g2 = QuaternionDType(q2).toOrientationMatrix().toGMatrix().transpose(); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); for(int i = 0; i < 12; i++) { @@ -1317,8 +1323,8 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS uvw1 = g1 * slipDirection; hkl1 = hkl1.normalize(); uvw1 = uvw1.normalize(); - directionComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); - planeComponent1 = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); + directionComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, uvw1.data())); + planeComponent1 = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(LD, hkl1.data())); schmidFactor1 = directionComponent1 * planeComponent1; if(schmidFactor1 > maxSchmidFactor || !maxSF) { @@ -1340,7 +1346,7 @@ double CubicOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxS hkl2 = hkl2.normalize(); uvw2 = uvw2.normalize(); - directionMisalignment = std::fabs(EbsdLib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); + directionMisalignment = std::fabs(ebsdlib::GeometryMath::CosThetaBetweenVectors(uvw1.data(), uvw2.data())); totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } F7 = directionComponent1 * directionComponent1 * totalDirectionMisalignment; @@ -1367,13 +1373,13 @@ namespace CubicHigh { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) : m_Eulers(eulers) , m_xyz001(xyz001) , m_xyz011(xyz011) @@ -1384,13 +1390,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); // ----------------------------------------------------------------------------- @@ -1419,44 +1425,44 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // 011 Family - direction[0] = EbsdLib::Constants::k_1OverRoot2D; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = ebsdlib::constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36)); std::transform(m_xyz011->getPointer(i * 36), m_xyz011->getPointer(i * 36 + 3), m_xyz011->getPointer(i * 36 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = ebsdlib::constants::k_1OverRoot2D; direction[1] = 0.0; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 6)); std::transform(m_xyz011->getPointer(i * 36 + 6), m_xyz011->getPointer(i * 36 + 9), m_xyz011->getPointer(i * 36 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = 0.0; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 12)); std::transform(m_xyz011->getPointer(i * 36 + 12), m_xyz011->getPointer(i * 36 + 15), m_xyz011->getPointer(i * 36 + 15), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot2D; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = -ebsdlib::constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 18)); std::transform(m_xyz011->getPointer(i * 36 + 18), m_xyz011->getPointer(i * 36 + 21), m_xyz011->getPointer(i * 36 + 21), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot2D; + direction[0] = -ebsdlib::constants::k_1OverRoot2D; direction[1] = 0.0; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 24)); std::transform(m_xyz011->getPointer(i * 36 + 24), m_xyz011->getPointer(i * 36 + 27), m_xyz011->getPointer(i * 36 + 27), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = 0.0; - direction[1] = -EbsdLib::Constants::k_1OverRoot2D; - direction[2] = EbsdLib::Constants::k_1OverRoot2D; + direction[1] = -ebsdlib::constants::k_1OverRoot2D; + direction[2] = ebsdlib::constants::k_1OverRoot2D; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 36 + 30)); std::transform(m_xyz011->getPointer(i * 36 + 30), m_xyz011->getPointer(i * 36 + 33), m_xyz011->getPointer(i * 36 + 33), // write to the next triplet in memory @@ -1464,30 +1470,30 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // 111 Family - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24)); std::transform(m_xyz111->getPointer(i * 24), m_xyz111->getPointer(i * 24 + 3), m_xyz111->getPointer(i * 24 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = -ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 6)); std::transform(m_xyz111->getPointer(i * 24 + 6), m_xyz111->getPointer(i * 24 + 9), m_xyz111->getPointer(i * 24 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = -EbsdLib::Constants::k_1OverRoot3D; - direction[2] = EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = -ebsdlib::constants::k_1OverRoot3D; + direction[2] = ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 12)); std::transform(m_xyz111->getPointer(i * 24 + 12), m_xyz111->getPointer(i * 24 + 15), m_xyz111->getPointer(i * 24 + 15), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = EbsdLib::Constants::k_1OverRoot3D; - direction[1] = EbsdLib::Constants::k_1OverRoot3D; - direction[2] = -EbsdLib::Constants::k_1OverRoot3D; + direction[0] = ebsdlib::constants::k_1OverRoot3D; + direction[1] = ebsdlib::constants::k_1OverRoot3D; + direction[2] = -ebsdlib::constants::k_1OverRoot3D; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 24 + 18)); std::transform(m_xyz111->getPointer(i * 24 + 18), m_xyz111->getPointer(i * 24 + 21), m_xyz111->getPointer(i * 24 + 21), // write to the next triplet in memory @@ -1507,7 +1513,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void CubicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void CubicOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -1608,7 +1614,7 @@ void TripleSort(T a, T b, T c, T* sorted) * @param z Output */ template -EbsdLib::Matrix3X1 TripletSort(EbsdLib::Matrix3X1& vec) +ebsdlib::Matrix3X1 TripletSort(ebsdlib::Matrix3X1& vec) { T x, y, z; if(vec[0] > vec[1] && vec[0] > vec[2]) @@ -1662,37 +1668,37 @@ EbsdLib::Matrix3X1 TripletSort(EbsdLib::Matrix3X1& vec) bool inUnitTriangleD(double eta, double chi) { - double etaDeg = eta * EbsdLib::Constants::k_180OverPiD; + double etaDeg = eta * ebsdlib::constants::k_180OverPiD; double chiMax; if(etaDeg > 45.0) { - chiMax = sqrt(1.0 / (2.0 + std::tan(0.5 * EbsdLib::Constants::k_PiD - eta) * std::tan(0.5 * EbsdLib::Constants::k_PiD - eta))); + chiMax = sqrt(1.0 / (2.0 + std::tan(0.5 * ebsdlib::constants::k_PiD - eta) * std::tan(0.5 * ebsdlib::constants::k_PiD - eta))); } else { chiMax = sqrt(1.0 / (2.0 + std::tan(eta) * std::tan(eta))); } - EbsdLibMath::bound(chiMax, -1.0, 1.0); + ebsdlib::math::bound(chiMax, -1.0, 1.0); chiMax = acos(chiMax); - return !(eta < 0.0 || eta > (45.0 * EbsdLib::Constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); + return !(eta < 0.0 || eta > (45.0 * ebsdlib::constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); } // ----------------------------------------------------------------------------- std::array CubicOps::getIpfColorAngleLimits(double eta) const { - double etaDeg = eta * EbsdLib::Constants::k_180OverPiD; + double etaDeg = eta * ebsdlib::constants::k_180OverPiD; double chiMax; if(etaDeg > CubicHigh::k_EtaMax) { - chiMax = std::sqrt(1.0 / (2.0 + std::tan(0.5 * EbsdLib::Constants::k_PiD - eta) * std::tan(0.5 * EbsdLib::Constants::k_PiD - eta))); + chiMax = std::sqrt(1.0 / (2.0 + std::tan(0.5 * ebsdlib::constants::k_PiD - eta) * std::tan(0.5 * ebsdlib::constants::k_PiD - eta))); } else { chiMax = std::sqrt(1.0 / (2.0 + std::tan(eta) * std::tan(eta))); } - EbsdLibMath::bound(chiMax, -1.0, 1.0); + ebsdlib::math::bound(chiMax, -1.0, 1.0); chiMax = std::acos(chiMax); - return {CubicHigh::k_EtaMin * EbsdLib::Constants::k_DegToRadD, CubicHigh::k_EtaMax * EbsdLib::Constants::k_DegToRadD, chiMax}; + return {CubicHigh::k_EtaMin * ebsdlib::constants::k_DegToRadD, CubicHigh::k_EtaMax * ebsdlib::constants::k_DegToRadD, chiMax}; } // ----------------------------------------------------------------------------- @@ -1700,25 +1706,25 @@ std::array CubicOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool CubicOps::inUnitTriangle(double eta, double chi) const { - double etaDeg = eta * EbsdLib::Constants::k_180OverPiD; + double etaDeg = eta * ebsdlib::constants::k_180OverPiD; double chiMax; if(etaDeg > CubicHigh::k_EtaMax) { - chiMax = std::sqrt(1.0 / (2.0 + std::tan(0.5 * EbsdLib::Constants::k_PiD - eta) * std::tan(0.5 * EbsdLib::Constants::k_PiD - eta))); + chiMax = std::sqrt(1.0 / (2.0 + std::tan(0.5 * ebsdlib::constants::k_PiD - eta) * std::tan(0.5 * ebsdlib::constants::k_PiD - eta))); } else { chiMax = std::sqrt(1.0 / (2.0 + std::tan(eta) * std::tan(eta))); } - EbsdLibMath::bound(chiMax, -1.0, 1.0); + ebsdlib::math::bound(chiMax, -1.0, 1.0); chiMax = acos(chiMax); - return !(eta < CubicHigh::k_EtaMin || eta > (CubicHigh::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); + return !(eta < CubicHigh::k_EtaMin || eta > (CubicHigh::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0.0 || chi > chiMax); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb CubicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -1726,7 +1732,7 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double* eulers, double* refDir, bool deg // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -1736,7 +1742,7 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb CubicOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb CubicOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * CubicHigh::OdfDimInitValue[0]; double range2 = 2.0f * CubicHigh::OdfDimInitValue[1]; @@ -1748,7 +1754,7 @@ EbsdLib::Rgb CubicOps::generateRodriguesColor(double r1, double r2, double r3) c double green = (r2 + max2) / range2; double blue = (r3 + max3) / range3; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -1762,7 +1768,7 @@ std::array CubicOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector CubicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector CubicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -1787,11 +1793,11 @@ std::vector CubicOps::generatePoleFigure(PoleF // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * CubicHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -1800,9 +1806,9 @@ std::vector CubicOps::generatePoleFigure(PoleF // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -1876,11 +1882,11 @@ std::vector CubicOps::generatePoleFigure(PoleF config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(static_cast(config.imageDim * config.imageDim), dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[static_cast(config.order[0])] = image001; @@ -1930,11 +1936,11 @@ std::vector CubicOps::generatePoleFigure(PoleF namespace { -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double indexConst1 = 0.414f / static_cast(imageDim); @@ -1952,8 +1958,8 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicOps* ops, int imageD double theta = 0.0f; double k_RootOfHalf = sqrtf(0.5f); - EbsdLib::Matrix3X1D orientation(0.0, 0.0, 0.0); - EbsdLib::Rgb color; + ebsdlib::Matrix3X1D orientation(0.0, 0.0, 0.0); + ebsdlib::Rgb color; size_t idx = 0; size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -1976,7 +1982,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicOps* ops, int imageD } double sumSquares = (x * x) + (y * y); - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); red1 = sphericalCoords[0] * (-k_RootOfHalf) + sphericalCoords[2] * k_RootOfHalf; phi = acos(red1); @@ -1992,7 +1998,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const CubicOps* ops, int imageD { color = 0xFFFFFFFF; } - else if(!generateEntirePlane && (phi <= (45.0f * EbsdLib::Constants::k_PiOver180D) || phi >= (90.0f * EbsdLib::Constants::k_PiOver180D) || theta >= (35.26f * EbsdLib::Constants::k_PiOver180D))) + else if(!generateEntirePlane && (phi <= (45.0f * ebsdlib::constants::k_PiOver180D) || phi >= (90.0f * ebsdlib::constants::k_PiOver180D) || theta >= (35.26f * ebsdlib::constants::k_PiOver180D))) { color = 0xFFFFFFFF; } @@ -2074,7 +2080,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -2086,7 +2092,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -2097,9 +2103,9 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line {0.0, 1.0, 1.0}, // Vertical Meridian Line {-1.0, 1.0, 0.0}, // Upper Left to Lower Right @@ -2111,7 +2117,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); + ebsdlib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); } if(!drawFullCircle) @@ -2119,24 +2125,24 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float x = figureCenter[0]; float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); x = figureCenter[0] + legendWidth; y = figureCenter[1] + fontPtSize; label = "[011]"; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); x = figureCenter[0] + legendWidth * 0.90F; y = figureCenter[1] - legendHeight * 0.90F; label = "[111]"; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -2170,19 +2176,19 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int canvasD std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -2204,7 +2210,7 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int canvasD // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); if(generateEntirePlane) { @@ -2219,12 +2225,12 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int canvasD } // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/CubicOps.h b/Source/EbsdLib/LaueOps/CubicOps.h index d727b922..150c1f2c 100644 --- a/Source/EbsdLib/LaueOps/CubicOps.h +++ b/Source/EbsdLib/LaueOps/CubicOps.h @@ -39,9 +39,9 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" -#include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class CubicOps CubicOps.h DREAM3DLib/Common/LaueOps/CubicOps.h * @brief @@ -149,7 +149,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -161,8 +161,8 @@ class EbsdLib_EXPORT CubicOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -231,7 +231,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps */ double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const override; /** * @brief * @param eta Optional input value only needed for the "Cubic" Laue classes @@ -243,9 +243,9 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -256,18 +256,18 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double phi1, double phi, double phi2, double dir0, double dir1, double dir2, bool degToRad) const override; + ebsdlib::Rgb generateIPFColor(double phi1, double phi, double phi2, double dir0, double dir1, double dir2, bool degToRad) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -275,10 +275,10 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -290,7 +290,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -314,7 +314,7 @@ class EbsdLib_EXPORT CubicOps : public LaueOps * @param width of produced image (in pixels) * @return */ - EbsdLib::UInt8ArrayType::Pointer generateMisorientationTriangleLegend(double, int, int, int) const; + ebsdlib::UInt8ArrayType::Pointer generateMisorientationTriangleLegend(double, int, int, int) const; protected: /** @@ -342,3 +342,4 @@ class EbsdLib_EXPORT CubicOps : public LaueOps CubicOps& operator=(const CubicOps&) = delete; // Copy Assignment Not Implemented CubicOps& operator=(CubicOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp index e920c949..d60bb48e 100644 --- a/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalLowOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -52,13 +53,14 @@ #include #include #endif +using namespace ebsdlib; namespace HexagonalLow { static const std::array OdfNumBins = {72, 72, 12}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (EbsdLib::Constants::k_PiD - std::sin(EbsdLib::Constants::k_PiD))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiD - std::sin(EbsdLib::Constants::k_PiD))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD / 6.0) - std::sin(EbsdLib::Constants::k_PiD / 6.0))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD / 6.0) - std::sin(ebsdlib::constants::k_PiD / 6.0))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -238,13 +240,13 @@ void HexagonalLowOps::getRodSymOp(int i, double* r) const r[2] = HexagonalLow::RodSym[i][2]; } -EbsdLib::Matrix3X3D HexagonalLowOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D HexagonalLowOps::getMatSymOpD(int i) const { return {HexagonalLow::MatSym[i][0][0], HexagonalLow::MatSym[i][0][1], HexagonalLow::MatSym[i][0][2], HexagonalLow::MatSym[i][1][0], HexagonalLow::MatSym[i][1][1], HexagonalLow::MatSym[i][1][2], HexagonalLow::MatSym[i][2][0], HexagonalLow::MatSym[i][2][1], HexagonalLow::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F HexagonalLowOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F HexagonalLowOps::getMatSymOpF(int i) const { return {static_cast(HexagonalLow::MatSym[i][0][0]), static_cast(HexagonalLow::MatSym[i][0][1]), static_cast(HexagonalLow::MatSym[i][0][2]), static_cast(HexagonalLow::MatSym[i][1][0]), static_cast(HexagonalLow::MatSym[i][1][1]), static_cast(HexagonalLow::MatSym[i][1][2]), @@ -309,7 +311,7 @@ RodriguesDType HexagonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { n1 = -n1, n2 = -n2, n3 = -n3; } - float angle = static_cast(180.0 * std::atan2(n2, n1) * EbsdLib::Constants::k_1OverPiD); + float angle = static_cast(180.0 * std::atan2(n2, n1) * ebsdlib::constants::k_1OverPiD); if(angle < 0) { angle = angle + 360.0f; @@ -323,7 +325,7 @@ RodriguesDType HexagonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const if(int(angle / 30) % 2 == 0) { FZw = angle - (30.0 * int(angle / 30.0)); - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -331,7 +333,7 @@ RodriguesDType HexagonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { FZw = angle - (30.0 * int(angle / 30.0)); FZw = 30.0f - FZw; - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -418,7 +420,7 @@ EulerDType HexagonalLowOps::determineEulerAngles(double random[3], int choose) c EulerDType HexagonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(HexagonalLow::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = HexagonalLow::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -889,7 +891,7 @@ double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bo QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 if(maxSF == true) { @@ -903,12 +905,12 @@ double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -922,12 +924,12 @@ double HexagonalLowOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } @@ -961,7 +963,7 @@ double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 if(maxSF == true) { @@ -975,12 +977,12 @@ double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -995,15 +997,15 @@ double HexagonalLowOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], slipPlane[0] = CubicSlipPlanes[j][0]; slipPlane[1] = CubicSlipPlanes[j][1]; slipPlane[2] = CubicSlipPlanes[j][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; - directionMisalignment = fabs(EbsdMatrixMath::DotProduct(uvw1,uvw2)); - planeMisalignment = fabs(EbsdMatrixMath::DotProduct(hkl1,hkl2)); + directionMisalignment = fabs(ebsdlib::EbsdMatrixMath::DotProduct(uvw1,uvw2)); + planeMisalignment = fabs(ebsdlib::EbsdMatrixMath::DotProduct(hkl1,hkl2)); totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; totalPlaneMisalignment = totalPlaneMisalignment + planeMisalignment; } @@ -1036,7 +1038,7 @@ double HexagonalLowOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bo QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 /* for(int i=0;i<12;i++) @@ -1047,12 +1049,12 @@ double HexagonalLowOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -1066,12 +1068,12 @@ double HexagonalLowOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[j][0]; slipPlane[1] = CubicSlipPlanes[j][1]; slipPlane[2] = CubicSlipPlanes[j][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } @@ -1094,13 +1096,13 @@ namespace HexagonalLow { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -1111,12 +1113,12 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -1133,7 +1135,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // [10-10], also [210] direction[0] = -0.5; - direction[1] = EbsdLib::Constants::k_Root3Over2D; + direction[1] = ebsdlib::constants::k_Root3Over2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 6)); std::transform(m_xyz011->getPointer(i * 6), m_xyz011->getPointer(i * 6 + 3), @@ -1161,15 +1163,15 @@ class GenerateSphereCoordsImpl }; } // namespace HexagonalLow -std::vector GenerateSphereCoordsUsingReferenceDirection(EbsdLib::FloatArrayType::Pointer& eulers, const EbsdLib::Matrix3X1F& referenceDirection) +std::vector GenerateSphereCoordsUsingReferenceDirection(ebsdlib::FloatArrayType::Pointer& eulers, const ebsdlib::Matrix3X1F& referenceDirection) { - std::vector allCoords(eulers->getNumberOfTuples() * 2); - EbsdLib::Matrix3X1D direction = referenceDirection.normalize().to(); + std::vector allCoords(eulers->getNumberOfTuples() * 2); + ebsdlib::Matrix3X1D direction = referenceDirection.normalize().to(); for(size_t i = 0; i < eulers->getNumberOfTuples(); ++i) { OrientationMatrixDType om = EulerDType(eulers->getValue(i * 3), eulers->getValue(i * 3 + 1), eulers->getValue(i * 3 + 2)).toOrientationMatrix(); - EbsdLib::Matrix3X3D g = om.toGMatrixObj().transpose(); + ebsdlib::Matrix3X3D g = om.toGMatrix().transpose(); allCoords[i * 2] = g * direction; allCoords[i * 2 + 1] = allCoords[i * 2] * -1.0; } @@ -1177,7 +1179,7 @@ std::vector GenerateSphereCoordsUsingReferenceDirection(Eb } // ----------------------------------------------------------------------------- -void HexagonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz0001, EbsdLib::FloatArrayType* xyz1010, EbsdLib::FloatArrayType* xyz1120) const +void HexagonalLowOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz0001, ebsdlib::FloatArrayType* xyz1010, ebsdlib::FloatArrayType* xyz1120) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -1212,7 +1214,7 @@ void HexagonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eu // ----------------------------------------------------------------------------- std::array HexagonalLowOps::getIpfColorAngleLimits(double eta) const { - return {HexagonalLow::k_EtaMin * EbsdLib::Constants::k_DegToRadD, HexagonalLow::k_EtaMax * EbsdLib::Constants::k_DegToRadD, HexagonalLow::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {HexagonalLow::k_EtaMin * ebsdlib::constants::k_DegToRadD, HexagonalLow::k_EtaMax * ebsdlib::constants::k_DegToRadD, HexagonalLow::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -1220,14 +1222,14 @@ std::array HexagonalLowOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool HexagonalLowOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (HexagonalLow::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (HexagonalLow::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (HexagonalLow::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (HexagonalLow::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (HexagonalLow::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (HexagonalLow::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb HexagonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -1235,7 +1237,7 @@ EbsdLib::Rgb HexagonalLowOps::generateIPFColor(double* eulers, double* refDir, b // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb HexagonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -1245,7 +1247,7 @@ EbsdLib::Rgb HexagonalLowOps::generateIPFColor(double phi1, double phi, double p // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb HexagonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0 * HexagonalLow::OdfDimInitValue[0]; double range2 = 2.0 * HexagonalLow::OdfDimInitValue[1]; @@ -1262,7 +1264,7 @@ EbsdLib::Rgb HexagonalLowOps::generateRodriguesColor(double r1, double r2, doubl green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -1276,7 +1278,7 @@ std::array HexagonalLowOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector HexagonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector HexagonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -1300,11 +1302,11 @@ std::vector HexagonalLowOps::generatePoleFigur // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0; @@ -1313,9 +1315,9 @@ std::vector HexagonalLowOps::generatePoleFigur // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -1388,11 +1390,11 @@ std::vector HexagonalLowOps::generatePoleFigur config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -1432,20 +1434,20 @@ std::vector HexagonalLowOps::generatePoleFigur namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalLowOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalLowOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); // Find the slope of the bounding line. - static const double m = std::sin(60.0 * EbsdLib::Constants::k_PiOver180D) / std::cos(60.0 * EbsdLib::Constants::k_PiOver180D); + static const double m = std::sin(60.0 * ebsdlib::constants::k_PiOver180D) / std::cos(60.0 * ebsdlib::constants::k_PiOver180D); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -1459,7 +1461,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalLowOps* ops, int double x = -1.0f + 2.0f * xIndex * xInc; double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white bool xGTyOverM = x < y / m; if(generateEntirePlane) @@ -1489,7 +1491,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalLowOps* ops, int } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } pixelPtr[idx] = color; @@ -1560,7 +1562,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -1572,7 +1574,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -1582,7 +1584,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(label.c_str()); float x = figureCenter[0] - fontWidth; float y = figureCenter[1] - fontPtSize * 0.0F; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } // Draw the [0001] in the center of the image @@ -1592,14 +1594,14 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = halfHeight * 1.5; std::string label("[0001]"); - EbsdLib::WriteText(context, "Discontinuous Colors", {x, y}, fontPtSize); + ebsdlib::WriteText(context, "Discontinuous Colors", {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1632,13 +1634,13 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int } std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Create a Canvas to draw into canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1655,27 +1657,27 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int context.fill(); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); context.draw_image(image->getPointer(0), legendWidth, legendHeight, legendWidth * image->getNumberOfComponents(), figureOrigin[0], figureOrigin[1], static_cast(legendWidth), static_cast(legendHeight)); // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/HexagonalLowOps.h b/Source/EbsdLib/LaueOps/HexagonalLowOps.h index 6d137574..17f6a342 100644 --- a/Source/EbsdLib/LaueOps/HexagonalLowOps.h +++ b/Source/EbsdLib/LaueOps/HexagonalLowOps.h @@ -39,9 +39,9 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" -#include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class HexagonalLowOps HexagonalLowOps.h DREAM3DLib/Common/LaueOps/HexagonalLowOps.h * @brief @@ -150,7 +150,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +162,8 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +185,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief * @param eta Optional input value only needed for the "Cubic" Laue classes @@ -197,9 +197,9 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -210,18 +210,18 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -229,10 +229,10 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -244,7 +244,7 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -267,3 +267,4 @@ class EbsdLib_EXPORT HexagonalLowOps : public LaueOps HexagonalLowOps& operator=(const HexagonalLowOps&) = delete; // Copy Assignment Not Implemented HexagonalLowOps& operator=(HexagonalLowOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/HexagonalOps.cpp b/Source/EbsdLib/LaueOps/HexagonalOps.cpp index 5d6119f4..dbed6940 100644 --- a/Source/EbsdLib/LaueOps/HexagonalOps.cpp +++ b/Source/EbsdLib/LaueOps/HexagonalOps.cpp @@ -40,8 +40,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorUtilities.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -54,14 +55,15 @@ #include #include #endif +using namespace ebsdlib; namespace HexagonalHigh { static const std::array OdfNumBins = {36, 36, 12}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (((EbsdLib::Constants::k_PiOver2D)) - std::sin(((EbsdLib::Constants::k_PiOver2D))))), (1.0 / 3.0)), - std::pow((0.75 * (((EbsdLib::Constants::k_PiOver2D)) - std::sin(((EbsdLib::Constants::k_PiOver2D))))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD / 6.0) - std::sin(EbsdLib::Constants::k_PiD / 6.0))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (((ebsdlib::constants::k_PiOver2D)) - std::sin(((ebsdlib::constants::k_PiOver2D))))), (1.0 / 3.0)), + std::pow((0.75 * (((ebsdlib::constants::k_PiOver2D)) - std::sin(((ebsdlib::constants::k_PiOver2D))))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD / 6.0) - std::sin(ebsdlib::constants::k_PiD / 6.0))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -283,13 +285,13 @@ void HexagonalOps::getRodSymOp(int i, double* r) const r[2] = HexagonalHigh::RodSym[i][2]; } -EbsdLib::Matrix3X3D HexagonalOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D HexagonalOps::getMatSymOpD(int i) const { return {HexagonalHigh::MatSym[i][0][0], HexagonalHigh::MatSym[i][0][1], HexagonalHigh::MatSym[i][0][2], HexagonalHigh::MatSym[i][1][0], HexagonalHigh::MatSym[i][1][1], HexagonalHigh::MatSym[i][1][2], HexagonalHigh::MatSym[i][2][0], HexagonalHigh::MatSym[i][2][1], HexagonalHigh::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F HexagonalOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F HexagonalOps::getMatSymOpF(int i) const { return {static_cast(HexagonalHigh::MatSym[i][0][0]), static_cast(HexagonalHigh::MatSym[i][0][1]), static_cast(HexagonalHigh::MatSym[i][0][2]), static_cast(HexagonalHigh::MatSym[i][1][0]), static_cast(HexagonalHigh::MatSym[i][1][1]), static_cast(HexagonalHigh::MatSym[i][1][2]), @@ -354,7 +356,7 @@ RodriguesDType HexagonalOps::getMDFFZRod(const RodriguesDType& inRod) const n1 = -n1, n2 = -n2, n3 = -n3; } - float angle = static_cast(180.0 * std::atan2(n2, n1) * EbsdLib::Constants::k_1OverPiD); + float angle = static_cast(180.0 * std::atan2(n2, n1) * ebsdlib::constants::k_1OverPiD); if(angle < 0) { angle = angle + 360.0f; @@ -368,7 +370,7 @@ RodriguesDType HexagonalOps::getMDFFZRod(const RodriguesDType& inRod) const if(int(angle / 30) % 2 == 0) { FZw = angle - (30.0f * int(angle / 30.0f)); - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -376,7 +378,7 @@ RodriguesDType HexagonalOps::getMDFFZRod(const RodriguesDType& inRod) const { FZw = angle - (30.0f * int(angle / 30.0f)); FZw = 30.0f - FZw; - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -463,7 +465,7 @@ EulerDType HexagonalOps::determineEulerAngles(double random[3], int choose) cons EulerDType HexagonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(HexagonalHigh::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = HexagonalHigh::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -934,7 +936,7 @@ double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 if(maxSF == true) { @@ -948,12 +950,12 @@ double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -967,12 +969,12 @@ double HexagonalOps::getF1(const QuatD& q1, const QuatD& q2, double LD[3], bool slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } @@ -1006,7 +1008,7 @@ double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bo QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 if(maxSF == true) { @@ -1020,12 +1022,12 @@ double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -1040,15 +1042,15 @@ double HexagonalOps::getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bo slipPlane[0] = CubicSlipPlanes[j][0]; slipPlane[1] = CubicSlipPlanes[j][1]; slipPlane[2] = CubicSlipPlanes[j][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; - directionMisalignment = fabs(EbsdMatrixMath::DotProduct(uvw1,uvw2)); - planeMisalignment = fabs(EbsdMatrixMath::DotProduct(hkl1,hkl2)); + directionMisalignment = fabs(ebsdlib::EbsdMatrixMath::DotProduct(uvw1,uvw2)); + planeMisalignment = fabs(ebsdlib::EbsdMatrixMath::DotProduct(hkl1,hkl2)); totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; totalPlaneMisalignment = totalPlaneMisalignment + planeMisalignment; } @@ -1081,7 +1083,7 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool QuattoMat(q1, g1); QuattoMat(q2, g2); - EbsdMatrixMath::Normalize3x1(LD); + ebsdlib::EbsdMatrixMath::Normalize3x1(LD); // Note the order of multiplication is such that I am actually multiplying by the inverse of g1 and g2 /* for(int i=0;i<12;i++) @@ -1092,12 +1094,12 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool slipPlane[0] = CubicSlipPlanes[i][0]; slipPlane[1] = CubicSlipPlanes[i][1]; slipPlane[2] = CubicSlipPlanes[i][2]; - EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); - EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); - EbsdMatrixMath::Normalize3x1(hkl1); - EbsdMatrixMath::Normalize3x1(uvw1); - directionComponent1 = EbsdMatrixMath::DotProduct(LD,uvw1); - planeComponent1 = EbsdMatrixMath::DotProduct(LD,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipDirection,hkl1); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g1,slipPlane,uvw1); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl1); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw1); + directionComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw1); + planeComponent1 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl1); schmidFactor1 = directionComponent1*planeComponent1; if(schmidFactor1 > maxSchmidFactor || maxSF == false) { @@ -1111,12 +1113,12 @@ double HexagonalOps::getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool slipPlane[0] = CubicSlipPlanes[j][0]; slipPlane[1] = CubicSlipPlanes[j][1]; slipPlane[2] = CubicSlipPlanes[j][2]; - EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); - EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); - EbsdMatrixMath::Normalize3x1(hkl2); - EbsdMatrixMath::Normalize3x1(uvw2); - directionComponent2 = EbsdMatrixMath::DotProduct(LD,uvw2); - planeComponent2 = EbsdMatrixMath::DotProduct(LD,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipDirection,hkl2); + ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(g2,slipPlane,uvw2); + ebsdlib::EbsdMatrixMath::Normalize3x1(hkl2); + ebsdlib::EbsdMatrixMath::Normalize3x1(uvw2); + directionComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,uvw2); + planeComponent2 = ebsdlib::EbsdMatrixMath::DotProduct(LD,hkl2); schmidFactor2 = directionComponent2*planeComponent2; totalDirectionMisalignment = totalDirectionMisalignment + directionMisalignment; } @@ -1138,13 +1140,13 @@ namespace HexagonalHigh { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz0001Coords, EbsdLib::FloatArrayType* xyz1010Coords, EbsdLib::FloatArrayType* xyz1120Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz0001Coords, ebsdlib::FloatArrayType* xyz1010Coords, ebsdlib::FloatArrayType* xyz1120Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz0001Coords) , m_xyz011(xyz1010Coords) @@ -1155,13 +1157,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -1177,7 +1179,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // [10-10], also [210] - direction[0] = EbsdLib::Constants::k_Root3Over2D; + direction[0] = ebsdlib::constants::k_Root3Over2D; direction[1] = 0.5; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 18)); @@ -1191,7 +1193,7 @@ class GenerateSphereCoordsImpl std::transform(m_xyz011->getPointer(i * 18 + 6), m_xyz011->getPointer(i * 18 + 9), m_xyz011->getPointer(i * 18 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_Root3Over2D; + direction[0] = -ebsdlib::constants::k_Root3Over2D; direction[1] = 0.5; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 18 + 12)); @@ -1209,14 +1211,14 @@ class GenerateSphereCoordsImpl m_xyz111->getPointer(i * 18 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = 0.5; - direction[1] = EbsdLib::Constants::k_Root3Over2D; + direction[1] = ebsdlib::constants::k_Root3Over2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 18 + 6)); std::transform(m_xyz111->getPointer(i * 18 + 6), m_xyz111->getPointer(i * 18 + 9), m_xyz111->getPointer(i * 18 + 9), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 direction[0] = -0.5; - direction[1] = EbsdLib::Constants::k_Root3Over2D; + direction[1] = ebsdlib::constants::k_Root3Over2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 18 + 12)); std::transform(m_xyz111->getPointer(i * 18 + 12), m_xyz111->getPointer(i * 18 + 15), @@ -1237,7 +1239,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void HexagonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz0001, EbsdLib::FloatArrayType* xyz1010, EbsdLib::FloatArrayType* xyz1120) const +void HexagonalOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz0001, ebsdlib::FloatArrayType* xyz1010, ebsdlib::FloatArrayType* xyz1120) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -1272,7 +1274,7 @@ void HexagonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* euler // ----------------------------------------------------------------------------- std::array HexagonalOps::getIpfColorAngleLimits(double eta) const { - return {HexagonalHigh::k_EtaMin * EbsdLib::Constants::k_DegToRadD, HexagonalHigh::k_EtaMax * EbsdLib::Constants::k_DegToRadD, HexagonalHigh::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {HexagonalHigh::k_EtaMin * ebsdlib::constants::k_DegToRadD, HexagonalHigh::k_EtaMax * ebsdlib::constants::k_DegToRadD, HexagonalHigh::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -1280,14 +1282,14 @@ std::array HexagonalOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool HexagonalOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (HexagonalHigh::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (HexagonalHigh::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (HexagonalHigh::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (HexagonalHigh::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (HexagonalHigh::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (HexagonalHigh::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb HexagonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -1295,7 +1297,7 @@ EbsdLib::Rgb HexagonalOps::generateIPFColor(double* eulers, double* refDir, bool // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb HexagonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -1305,7 +1307,7 @@ EbsdLib::Rgb HexagonalOps::generateIPFColor(double phi1, double phi, double phi2 // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb HexagonalOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb HexagonalOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * HexagonalHigh::OdfDimInitValue[0]; double range2 = 2.0f * HexagonalHigh::OdfDimInitValue[1]; @@ -1322,7 +1324,7 @@ EbsdLib::Rgb HexagonalOps::generateRodriguesColor(double r1, double r2, double r green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -1336,7 +1338,7 @@ std::array HexagonalOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector HexagonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector HexagonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -1361,11 +1363,11 @@ std::vector HexagonalOps::generatePoleFigure(P // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * HexagonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -1374,9 +1376,9 @@ std::vector HexagonalOps::generatePoleFigure(P // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -1449,11 +1451,11 @@ std::vector HexagonalOps::generatePoleFigure(P config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -1493,19 +1495,19 @@ std::vector HexagonalOps::generatePoleFigure(P namespace { -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); // Find the slope of the bounding line. - static const double m = -1.0F * std::sin(30.0 * EbsdLib::Constants::k_PiOver180D) / std::cos(30.0 * EbsdLib::Constants::k_PiOver180D); + static const double m = -1.0F * std::sin(30.0 * ebsdlib::constants::k_PiOver180D) / std::cos(30.0 * ebsdlib::constants::k_PiOver180D); size_t yScanLineIndex = 0; // We use this to control where the data // is drawn. Otherwise, the image will come out flipped vertically @@ -1522,7 +1524,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalOps* ops, int im double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0f) // Outside unit circle { @@ -1543,7 +1545,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const HexagonalOps* ops, int im } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -1615,7 +1617,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -1627,7 +1629,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -1637,13 +1639,13 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(label.c_str()); float x = figureCenter[0] - fontWidth; float y = figureCenter[1] - fontPtSize * 0.25F; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1676,13 +1678,13 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int can } std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Create a Canvas to draw into canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1699,27 +1701,27 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int can context.fill(); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); context.draw_image(image->getPointer(0), legendWidth, legendHeight, legendWidth * image->getNumberOfComponents(), figureOrigin[0], figureOrigin[1], static_cast(legendWidth), static_cast(legendHeight)); // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/HexagonalOps.h b/Source/EbsdLib/LaueOps/HexagonalOps.h index 455f2ea5..a3953989 100644 --- a/Source/EbsdLib/LaueOps/HexagonalOps.h +++ b/Source/EbsdLib/LaueOps/HexagonalOps.h @@ -39,9 +39,9 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" -#include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class HexagonalOps HexagonalOps.h DREAM3DLib/Common/LaueOps/HexagonalOps.h * @brief @@ -150,7 +150,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +162,8 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +185,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief * @param eta Optional input value only needed for the "Cubic" Laue classes @@ -197,9 +197,9 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -210,18 +210,18 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -229,10 +229,10 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -244,7 +244,7 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -267,3 +267,4 @@ class EbsdLib_EXPORT HexagonalOps : public LaueOps HexagonalOps& operator=(const HexagonalOps&) = delete; // Copy Assignment Not Implemented HexagonalOps& operator=(HexagonalOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/LaueOps.cpp b/Source/EbsdLib/LaueOps/LaueOps.cpp index 04615399..801dc843 100644 --- a/Source/EbsdLib/LaueOps/LaueOps.cpp +++ b/Source/EbsdLib/LaueOps/LaueOps.cpp @@ -48,7 +48,9 @@ #include "EbsdLib/LaueOps/TriclinicOps.h" #include "EbsdLib/LaueOps/TrigonalLowOps.h" #include "EbsdLib/LaueOps/TrigonalOps.h" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/ColorTable.h" +#include "EbsdLib/Utilities/ComputeStereographicProjection.h" #include // for std::max #include @@ -71,6 +73,7 @@ | X | X | CubicLow | 23 | 12 | | X | X | CubicOps | 432 | 24 | */ +using namespace ebsdlib; namespace { @@ -157,10 +160,10 @@ LaueOps::AxisOrderingType LaueOps::getAxisOrderingType() const } // ----------------------------------------------------------------------------- -EbsdLib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degToRad) const { - const EbsdLib::Matrix3X1D refDirection(refDir); + const ebsdlib::Matrix3X1D refDirection(refDir); double chi = 0.0f; double eta = 0.0f; double _rgb[3] = {0.0, 0.0, 0.0}; @@ -168,20 +171,20 @@ EbsdLib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degTo EulerDType eu(eulers[0], eulers[1], eulers[2]); if(degToRad) { - eu[0] = eu[0] * EbsdLib::Constants::k_DegToRadD; - eu[1] = eu[1] * EbsdLib::Constants::k_DegToRadD; - eu[2] = eu[2] * EbsdLib::Constants::k_DegToRadD; + eu[0] = eu[0] * ebsdlib::constants::k_DegToRadD; + eu[1] = eu[1] * ebsdlib::constants::k_DegToRadD; + eu[2] = eu[2] * ebsdlib::constants::k_DegToRadD; } OrientationMatrixDType om; // Reusable for the loop - QuatD q1 = eu.toQuat(); + QuatD q1 = eu.toQuaternion(); for(int j = 0; j < getNumSymOps(); j++) { // QuatD qu = getQuatSymOp(j) * q1; QuaternionDType qu(getQuatSymOp(j) * q1); om = qu.toOrientationMatrix(); - EbsdLib::Matrix3X3D g(om.data()); - EbsdLib::Matrix3X1D p = (g * refDirection).normalize(); + ebsdlib::Matrix3X3D g(om.data()); + ebsdlib::Matrix3X1D p = (g * refDirection).normalize(); if(!getHasInversion() && p[2] < 0) { @@ -225,7 +228,7 @@ EbsdLib::Rgb LaueOps::computeIPFColor(double* eulers, double* refDir, bool degTo _rgb[1] = _rgb[1] / max; _rgb[2] = _rgb[2] / max; - return EbsdLib::RgbColor::dRgb(static_cast(_rgb[0] * 255), static_cast(_rgb[1] * 255), static_cast(_rgb[2] * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(_rgb[0] * 255), static_cast(_rgb[1] * 255), static_cast(_rgb[2] * 255), 255); } // ----------------------------------------------------------------------------- @@ -512,9 +515,9 @@ AxisAngleDType LaueOps::calculateMisorientationInternal(const std::vector } AxisAngleDType axisAngle = QuaternionDType(qc).toAxisAngle(); - if(axisAngle[3] > EbsdLib::Constants::k_PiD) + if(axisAngle[3] > ebsdlib::constants::k_PiD) { - axisAngle[3] = EbsdLib::Constants::k_2PiD - axisAngle[3]; + axisAngle[3] = ebsdlib::constants::k_2PiD - axisAngle[3]; } if(axisAngle[3] < axisAngleMin[3]) { @@ -858,7 +861,7 @@ std::string LaueOps::ClassName() } //----------------------------------------------------------------------------- -EbsdLib::Rgb LaueOps::generateMisorientationColor(const QuatD& q, const QuatD& refFrame) const +ebsdlib::Rgb LaueOps::generateMisorientationColor(const QuatD& q, const QuatD& refFrame) const { throw std::runtime_error("LaueOps::generateMisorientationColor is not implemented."); } diff --git a/Source/EbsdLib/LaueOps/LaueOps.h b/Source/EbsdLib/LaueOps/LaueOps.h index 821048ca..322873e7 100644 --- a/Source/EbsdLib/LaueOps/LaueOps.h +++ b/Source/EbsdLib/LaueOps/LaueOps.h @@ -39,13 +39,17 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/Matrix3X3.hpp" +#include "EbsdLib/Orientation/AxisAngle.hpp" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" #include "EbsdLib/Utilities/PoleFigureUtilities.h" +namespace ebsdlib +{ /* * @class LaueOps LaueOps.h OrientationLib/LaueOps/LaueOps.h * @brief @@ -73,7 +77,7 @@ class EbsdLib_EXPORT LaueOps /** * @brief GetAllOrientationOps This method returns a vector of each type of LaueOps placed such that the - * index into the vector is the value of the constant at EbsdLib::CrystalStructure::*** + * index into the vector is the value of the constant at ebsdlib::CrystalStructure::*** * @return Vector of LaueOps subclasses. */ static std::vector GetAllOrientationOps(); @@ -157,7 +161,7 @@ class EbsdLib_EXPORT LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - virtual EbsdLib::AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const = 0; + virtual ebsdlib::AxisAngleDType calculateMisorientation(const QuatD& q1, const QuatD& q2) const = 0; /** * @brief calculateMisorientation Finds the misorientation between 2 quaternions and returns the result as an Axis Angle value @@ -189,8 +193,8 @@ class EbsdLib_EXPORT LaueOps */ virtual void getMatSymOp(int i, double g[3][3]) const = 0; virtual void getMatSymOp(int i, float g[3][3]) const = 0; - virtual EbsdLib::Matrix3X3F getMatSymOpF(int i) const = 0; - virtual EbsdLib::Matrix3X3D getMatSymOpD(int i) const = 0; + virtual ebsdlib::Matrix3X3F getMatSymOpF(int i) const = 0; + virtual ebsdlib::Matrix3X3D getMatSymOpD(int i) const = 0; /** * @brief getODFFZRod @@ -247,7 +251,7 @@ class EbsdLib_EXPORT LaueOps virtual double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const = 0; - virtual void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const = 0; + virtual void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const = 0; static void RodriguesComposition(RodriguesDType sigma, RodriguesDType& rod); @@ -265,7 +269,7 @@ class EbsdLib_EXPORT LaueOps * @param convertDegrees Are the input angles in Degrees * @return rgb [output] The pointer to store the RGB value */ - virtual EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const = 0; + virtual ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const = 0; /** * @brief generateIPFColor Generates an ARGB Color from an Euler Angle and Reference Direction @@ -278,7 +282,7 @@ class EbsdLib_EXPORT LaueOps * @param convertDegrees Are the input angles in Degrees * @return rgb [output] The pointer to store the RGB value */ - virtual EbsdLib::Rgb generateIPFColor(double e0, double e1, double e2, double dir0, double dir1, double dir2, bool convertDegrees) const = 0; + virtual ebsdlib::Rgb generateIPFColor(double e0, double e1, double e2, double dir0, double dir1, double dir2, bool convertDegrees) const = 0; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector @@ -287,24 +291,24 @@ class EbsdLib_EXPORT LaueOps * @param r3 Third component of the Rodrigues Vector * @return rgb [output] The pointer to store the RGB value */ - virtual EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const = 0; + virtual ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const = 0; /** * @brief generateMisorientationColor Generates a color based on the method developed by C. Schuh and S. Patala. * @param q A Quaternion representing the crystal direction * @param refFrame A Quaternion representing the sample reference direction - * @return A EbsdLib::Rgb value + * @return A ebsdlib::Rgb value */ - virtual EbsdLib::Rgb generateMisorientationColor(const QuatD& q, const QuatD& refFrame) const; + virtual ebsdlib::Rgb generateMisorientationColor(const QuatD& q, const QuatD& refFrame) const; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler * angles that are passed in. * @param config The Pole Figure configuration struct - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - virtual std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const = 0; + virtual std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const = 0; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -316,7 +320,7 @@ class EbsdLib_EXPORT LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - virtual EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const = 0; + virtual ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const = 0; enum class FZType : int32_t { @@ -497,7 +501,7 @@ class EbsdLib_EXPORT LaueOps * @param deg2Rad * @return */ - EbsdLib::Rgb computeIPFColor(double* eulers, double* refDir, bool degToRad) const; + ebsdlib::Rgb computeIPFColor(double* eulers, double* refDir, bool degToRad) const; /** * @brief Converts in input Quaternion into a version that is inside the fundamental zone. @@ -545,7 +549,7 @@ constexpr std::array FZoarray = {LaueOps::AxisOrd LaueOps::AxisOrderingType::None, LaueOps::AxisOrderingType::None, LaueOps::AxisOrderingType::None}; } // namespace laue_ops - +} // namespace ebsdlib /* * @brief Master Table of Crystallographic Information * This is formatted as a MarkDown with LaTeX formatting diff --git a/Source/EbsdLib/LaueOps/MonoclinicOps.cpp b/Source/EbsdLib/LaueOps/MonoclinicOps.cpp index 25d0fb60..042bd859 100644 --- a/Source/EbsdLib/LaueOps/MonoclinicOps.cpp +++ b/Source/EbsdLib/LaueOps/MonoclinicOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -51,15 +52,16 @@ #include #include #endif +using namespace ebsdlib; namespace Monoclinic { static const std::array OdfNumBins = {72, 36, 72}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.7f * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.7f * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0]) / 2.0, OdfDimInitValue[1] / static_cast(OdfNumBins[1]) / 2.0, OdfDimInitValue[2] / static_cast(OdfNumBins[2]) / 2.0}; @@ -214,13 +216,13 @@ void MonoclinicOps::getRodSymOp(int i, double* r) const r[2] = Monoclinic::RodSym[i][2]; } -EbsdLib::Matrix3X3D MonoclinicOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D MonoclinicOps::getMatSymOpD(int i) const { return {Monoclinic::MatSym[i][0][0], Monoclinic::MatSym[i][0][1], Monoclinic::MatSym[i][0][2], Monoclinic::MatSym[i][1][0], Monoclinic::MatSym[i][1][1], Monoclinic::MatSym[i][1][2], Monoclinic::MatSym[i][2][0], Monoclinic::MatSym[i][2][1], Monoclinic::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F MonoclinicOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F MonoclinicOps::getMatSymOpF(int i) const { return {static_cast(Monoclinic::MatSym[i][0][0]), static_cast(Monoclinic::MatSym[i][0][1]), static_cast(Monoclinic::MatSym[i][0][2]), static_cast(Monoclinic::MatSym[i][1][0]), static_cast(Monoclinic::MatSym[i][1][1]), static_cast(Monoclinic::MatSym[i][1][2]), @@ -266,7 +268,7 @@ RodriguesDType MonoclinicOps::getODFFZRod(const RodriguesDType& rod) const // ----------------------------------------------------------------------------- RodriguesDType MonoclinicOps::getMDFFZRod(const RodriguesDType& inRod) const { - throw EbsdLib::method_not_implemented("MonoclinicOps::getMDFFZRod not implemented"); + throw ebsdlib::method_not_implemented("MonoclinicOps::getMDFFZRod not implemented"); // /// FIXME: Are we missing code for MonoclinicOps MDF FZ Rodrigues calculation? // double w = 0.0, n1 = 0.0, n2 = 0.0, n3 = 0.0; @@ -360,7 +362,7 @@ EulerDType MonoclinicOps::determineEulerAngles(double random[3], int choose) con EulerDType MonoclinicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(Monoclinic::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = Monoclinic::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -496,13 +498,13 @@ namespace Monoclinic { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -513,12 +515,12 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -566,7 +568,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void MonoclinicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void MonoclinicOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -595,7 +597,7 @@ void MonoclinicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eule // ----------------------------------------------------------------------------- std::array MonoclinicOps::getIpfColorAngleLimits(double eta) const { - return {Monoclinic::k_EtaMin * EbsdLib::Constants::k_DegToRadD, Monoclinic::k_EtaMax * EbsdLib::Constants::k_DegToRadD, Monoclinic::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {Monoclinic::k_EtaMin * ebsdlib::constants::k_DegToRadD, Monoclinic::k_EtaMax * ebsdlib::constants::k_DegToRadD, Monoclinic::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -603,14 +605,14 @@ std::array MonoclinicOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool MonoclinicOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (Monoclinic::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (Monoclinic::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (Monoclinic::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (Monoclinic::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (Monoclinic::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (Monoclinic::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb MonoclinicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb MonoclinicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -618,7 +620,7 @@ EbsdLib::Rgb MonoclinicOps::generateIPFColor(double* eulers, double* refDir, boo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb MonoclinicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb MonoclinicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -628,7 +630,7 @@ EbsdLib::Rgb MonoclinicOps::generateIPFColor(double phi1, double phi, double phi // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb MonoclinicOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb MonoclinicOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * Monoclinic::OdfDimInitValue[0]; double range2 = 2.0f * Monoclinic::OdfDimInitValue[1]; @@ -645,7 +647,7 @@ EbsdLib::Rgb MonoclinicOps::generateRodriguesColor(double r1, double r2, double green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -659,7 +661,7 @@ std::array MonoclinicOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector MonoclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector MonoclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -684,11 +686,11 @@ std::vector MonoclinicOps::generatePoleFigure( // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Monoclinic::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -697,9 +699,9 @@ std::vector MonoclinicOps::generatePoleFigure( // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -772,11 +774,11 @@ std::vector MonoclinicOps::generatePoleFigure( config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -817,18 +819,18 @@ std::vector MonoclinicOps::generatePoleFigure( namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const MonoclinicOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const MonoclinicOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims = {4ULL}; // ARGB std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); // This is an ARGB Array - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); auto* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -844,7 +846,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const MonoclinicOps* ops, int i double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0 || (!generateEntirePlane && y < 0.0F)) // Outside unit circle { @@ -852,7 +854,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const MonoclinicOps* ops, int i } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -922,7 +924,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; @@ -935,7 +937,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -955,12 +957,12 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float x = figureCenter[0]; float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } if(drawFullCircle) { - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line {0.0, 1.0, 1.0}, // Vertical Meridian Line {-1.0, 1.0, 0.0}, // Upper Left to Lower Right @@ -972,14 +974,14 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); + ebsdlib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1012,19 +1014,19 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int ca std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1046,18 +1048,18 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int ca // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/MonoclinicOps.h b/Source/EbsdLib/LaueOps/MonoclinicOps.h index 59393e5e..5218213e 100644 --- a/Source/EbsdLib/LaueOps/MonoclinicOps.h +++ b/Source/EbsdLib/LaueOps/MonoclinicOps.h @@ -34,14 +34,14 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma once -#include - #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" -#include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" +#include +namespace ebsdlib +{ /** * @class MonoclinicOps MonoclinicOps.h DREAM3DLib/Common/LaueOps/MonoclinicOps.h * @brief @@ -149,7 +149,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -161,8 +161,8 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -184,7 +184,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief * @param eta Optional input value only needed for the "Cubic" Laue classes @@ -196,9 +196,9 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -209,18 +209,18 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -228,10 +228,10 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -243,7 +243,7 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -266,3 +266,4 @@ class EbsdLib_EXPORT MonoclinicOps : public LaueOps MonoclinicOps& operator=(const MonoclinicOps&) = delete; // Copy Assignment Not Implemented MonoclinicOps& operator=(MonoclinicOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp b/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp index 9e951121..87491d10 100644 --- a/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp +++ b/Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp @@ -37,8 +37,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -53,14 +54,15 @@ #endif #define EBSD_LIB_GENERATE_ENTIRE_CIRCLE +using namespace ebsdlib; namespace OrthoRhombic { static const std::array OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -223,13 +225,13 @@ void OrthoRhombicOps::getRodSymOp(int i, double* r) const r[2] = OrthoRhombic::RodSym[i][2]; } -EbsdLib::Matrix3X3D OrthoRhombicOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D OrthoRhombicOps::getMatSymOpD(int i) const { return {OrthoRhombic::MatSym[i][0][0], OrthoRhombic::MatSym[i][0][1], OrthoRhombic::MatSym[i][0][2], OrthoRhombic::MatSym[i][1][0], OrthoRhombic::MatSym[i][1][1], OrthoRhombic::MatSym[i][1][2], OrthoRhombic::MatSym[i][2][0], OrthoRhombic::MatSym[i][2][1], OrthoRhombic::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F OrthoRhombicOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F OrthoRhombicOps::getMatSymOpF(int i) const { return {static_cast(OrthoRhombic::MatSym[i][0][0]), static_cast(OrthoRhombic::MatSym[i][0][1]), static_cast(OrthoRhombic::MatSym[i][0][2]), static_cast(OrthoRhombic::MatSym[i][1][0]), static_cast(OrthoRhombic::MatSym[i][1][1]), static_cast(OrthoRhombic::MatSym[i][1][2]), @@ -275,7 +277,7 @@ RodriguesDType OrthoRhombicOps::getODFFZRod(const RodriguesDType& rod) const // ----------------------------------------------------------------------------- RodriguesDType OrthoRhombicOps::getMDFFZRod(const RodriguesDType& inRod) const { - throw EbsdLib::method_not_implemented("OrthoRhombicOps::getMDFFZRod not implemented"); + throw ebsdlib::method_not_implemented("OrthoRhombicOps::getMDFFZRod not implemented"); double FZn1 = 0.0f, FZn2 = 0.0f, FZn3 = 0.0f, FZw = 0.0f; @@ -369,7 +371,7 @@ EulerDType OrthoRhombicOps::determineEulerAngles(double random[3], int choose) c EulerDType OrthoRhombicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(OrthoRhombic::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = OrthoRhombic::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -504,13 +506,13 @@ namespace OrthoRhombic { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -521,12 +523,12 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -574,7 +576,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void OrthoRhombicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void OrthoRhombicOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -603,7 +605,7 @@ void OrthoRhombicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eu // ----------------------------------------------------------------------------- std::array OrthoRhombicOps::getIpfColorAngleLimits(double eta) const { - return {OrthoRhombic::k_EtaMin * EbsdLib::Constants::k_DegToRadD, OrthoRhombic::k_EtaMax * EbsdLib::Constants::k_DegToRadD, OrthoRhombic::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {OrthoRhombic::k_EtaMin * ebsdlib::constants::k_DegToRadD, OrthoRhombic::k_EtaMax * ebsdlib::constants::k_DegToRadD, OrthoRhombic::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -611,14 +613,14 @@ std::array OrthoRhombicOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool OrthoRhombicOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (OrthoRhombic::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (OrthoRhombic::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (OrthoRhombic::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (OrthoRhombic::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (OrthoRhombic::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (OrthoRhombic::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb OrthoRhombicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -626,7 +628,7 @@ EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double* eulers, double* refDir, b // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb OrthoRhombicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -636,7 +638,7 @@ EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double phi1, double phi, double p // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb OrthoRhombicOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb OrthoRhombicOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * OrthoRhombic::OdfDimInitValue[0]; double range2 = 2.0f * OrthoRhombic::OdfDimInitValue[1]; @@ -653,7 +655,7 @@ EbsdLib::Rgb OrthoRhombicOps::generateRodriguesColor(double r1, double r2, doubl green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -667,7 +669,7 @@ std::array OrthoRhombicOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector OrthoRhombicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector OrthoRhombicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -691,10 +693,10 @@ std::vector OrthoRhombicOps::generatePoleFigur // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. std::vector dims(1, 3); - std::vector coords(3); - coords[0] = EbsdLib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize0, dims, label0 + std::string("001_Coords"), true); - coords[1] = EbsdLib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize1, dims, label1 + std::string("100_Coords"), true); - coords[2] = EbsdLib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize2, dims, label2 + std::string("010_Coords"), true); + std::vector coords(3); + coords[0] = ebsdlib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize0, dims, label0 + std::string("001_Coords"), true); + coords[1] = ebsdlib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize1, dims, label1 + std::string("100_Coords"), true); + coords[2] = ebsdlib::FloatArrayType::CreateArray(numOrientations * OrthoRhombic::symSize2, dims, label2 + std::string("010_Coords"), true); config.sphereRadius = 1.0; @@ -703,9 +705,9 @@ std::vector OrthoRhombicOps::generatePoleFigur // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity100 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity010 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity100 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity010 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -778,11 +780,11 @@ std::vector OrthoRhombicOps::generatePoleFigur config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image100 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image010 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image100 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image010 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -822,16 +824,16 @@ std::vector OrthoRhombicOps::generatePoleFigur namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const OrthoRhombicOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const OrthoRhombicOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -847,7 +849,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const OrthoRhombicOps* ops, int double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0) // Outside unit circle { color = 0xFFFFFFFF; @@ -862,7 +864,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const OrthoRhombicOps* ops, int } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -934,7 +936,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -946,7 +948,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -956,13 +958,13 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -996,19 +998,19 @@ EbsdLib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1030,18 +1032,18 @@ EbsdLib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/OrthoRhombicOps.h b/Source/EbsdLib/LaueOps/OrthoRhombicOps.h index 1117d6bd..20df3cff 100644 --- a/Source/EbsdLib/LaueOps/OrthoRhombicOps.h +++ b/Source/EbsdLib/LaueOps/OrthoRhombicOps.h @@ -41,7 +41,8 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class OrthoRhombicOps OrthoRhombicOps.h DREAM3DLib/Common/LaueOps/OrthoRhombicOps.h * @brief @@ -150,7 +151,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +163,8 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +186,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -198,9 +199,9 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -211,18 +212,18 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -230,10 +231,10 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -245,7 +246,7 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -268,3 +269,4 @@ class EbsdLib_EXPORT OrthoRhombicOps : public LaueOps OrthoRhombicOps& operator=(const OrthoRhombicOps&) = delete; // Copy Assignment Not Implemented OrthoRhombicOps& operator=(OrthoRhombicOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/SO3Sampler.cpp b/Source/EbsdLib/LaueOps/SO3Sampler.cpp index bfc39928..d5c9d659 100644 --- a/Source/EbsdLib/LaueOps/SO3Sampler.cpp +++ b/Source/EbsdLib/LaueOps/SO3Sampler.cpp @@ -32,7 +32,10 @@ #include "SO3Sampler.h" #include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/Core/OrientationTransformation.hpp" +#include "EbsdLib/Orientation/Cubochoric.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +#include "EbsdLib/Utilities/ComputeStereographicProjection.h" namespace { @@ -52,6 +55,8 @@ constexpr int FourFoldAxisOrder = 4; constexpr int SixFoldAxisOrder = 6; } // namespace +using namespace ebsdlib; + // Following numbers are coefficients used to calculate the exponential of a matrix // The following two arrays are used to determine the FZtype (FZtarray) and primary rotation axis order (FZoarray) @@ -172,7 +177,7 @@ SO3Sampler::~SO3Sampler() = default; //> @date 01/01/15 MDG 1.0 new routine, needed for dictionary indexing approach //> @date 06/04/15 MDG 1.1 corrected infty to inftyd (double precision infinity) //-------------------------------------------------------------------------- -bool SO3Sampler::IsinsideFZ(const EbsdLib::RodriguesDType& rod, int FZtype, int FZorder) +bool SO3Sampler::IsinsideFZ(const ebsdlib::RodriguesDType& rod, int FZtype, int FZorder) { bool insideFZ = false; // dealing with 180 rotations is needed only for @@ -225,7 +230,7 @@ bool SO3Sampler::IsinsideFZ(const EbsdLib::RodriguesDType& rod, int FZtype, int //> @date 10/02/14 MDG 2.0 rewrite //> @date 06/04/15 MDG 2.1 corrected infty to inftyd (double precision infinity) //-------------------------------------------------------------------------- -bool SO3Sampler::insideCyclicFZ(const EbsdLib::RodriguesDType& rod, int order) +bool SO3Sampler::insideCyclicFZ(const ebsdlib::RodriguesDType& rod, int order) { bool insideFZ = false; @@ -259,7 +264,7 @@ bool SO3Sampler::insideCyclicFZ(const EbsdLib::RodriguesDType& rod, int order) //> @date 05/12/14 MDG 1.0 original //> @date 10/02/14 MDG 2.0 rewrite //-------------------------------------------------------------------------- -bool SO3Sampler::insideDihedralFZ(const EbsdLib::RodriguesDType& rod, int order) +bool SO3Sampler::insideDihedralFZ(const ebsdlib::RodriguesDType& rod, int order) { bool res = false, c1 = false, c2 = false; @@ -320,7 +325,7 @@ bool SO3Sampler::insideDihedralFZ(const EbsdLib::RodriguesDType& rod, int order) //> @date 01/03/15 MDG 2.1 correction of boundary error; simplification of octahedral planes //> @date 06/04/15 MDG 2.2 simplified handling of components of r //-------------------------------------------------------------------------- -bool SO3Sampler::insideCubicFZ(const EbsdLib::RodriguesDType& rod, int ot) +bool SO3Sampler::insideCubicFZ(const ebsdlib::RodriguesDType& rod, int ot) { bool res = false, c1 = false, c2 = false; std::vector r(3); @@ -435,7 +440,7 @@ SO3Sampler::OrientationListArrayType SO3Sampler::SampleRFZ(int nsteps, int pgnum z = static_cast(k) * delta; // convert to Rodrigues representation - EbsdLib::RodriguesDType rod = EbsdLib::CubochoricDType(x, y, z).toRodrigues(); + ebsdlib::RodriguesDType rod = ebsdlib::CubochoricDType(x, y, z).toRodrigues(); // If insideFZ=true, then add this point to the linked list FZlist and keep // track of how many points there are on this list diff --git a/Source/EbsdLib/LaueOps/SO3Sampler.h b/Source/EbsdLib/LaueOps/SO3Sampler.h index ea1b1e24..66e02d6b 100644 --- a/Source/EbsdLib/LaueOps/SO3Sampler.h +++ b/Source/EbsdLib/LaueOps/SO3Sampler.h @@ -35,10 +35,12 @@ #include #include -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdLibMath.h" - +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +namespace ebsdlib +{ /** * @brief The SO3Sampler class */ @@ -69,7 +71,7 @@ class EbsdLib_EXPORT SO3Sampler /** * @brief OrientationListArrayType */ - using OrientationListArrayType = std::list; + using OrientationListArrayType = std::list; // sampler routine OrientationListArrayType SampleRFZ(int nsteps, int pgnum); @@ -81,7 +83,7 @@ class EbsdLib_EXPORT SO3Sampler * @param FZorder * @return */ - bool IsinsideFZ(const EbsdLib::RodriguesDType& rod, int FZtype, int FZorder); + bool IsinsideFZ(const ebsdlib::RodriguesDType& rod, int FZtype, int FZorder); /** * @brief insideCubicFZ @@ -89,7 +91,7 @@ class EbsdLib_EXPORT SO3Sampler * @param symType * @return */ - bool insideCubicFZ(const EbsdLib::RodriguesDType& rod, int symType); + bool insideCubicFZ(const ebsdlib::RodriguesDType& rod, int symType); /** * @brief insideCyclicFZ @@ -97,7 +99,7 @@ class EbsdLib_EXPORT SO3Sampler * @param order * @return */ - bool insideCyclicFZ(const EbsdLib::RodriguesDType& rod, int order); + bool insideCyclicFZ(const ebsdlib::RodriguesDType& rod, int order); /** * @brief insideDihedralFZ @@ -105,7 +107,7 @@ class EbsdLib_EXPORT SO3Sampler * @param order * @return */ - bool insideDihedralFZ(const EbsdLib::RodriguesDType& rod, int order); + bool insideDihedralFZ(const ebsdlib::RodriguesDType& rod, int order); protected: SO3Sampler(); @@ -116,3 +118,4 @@ class EbsdLib_EXPORT SO3Sampler SO3Sampler& operator=(const SO3Sampler&) = delete; // Copy Assignment Not Implemented SO3Sampler& operator=(SO3Sampler&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp b/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp index def43016..c6ad690a 100644 --- a/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/TetragonalLowOps.cpp @@ -37,8 +37,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -51,14 +52,15 @@ #include #include #endif +using namespace ebsdlib; namespace TetragonalLow { static const std::array OdfNumBins = {72, 72, 18}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver4D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver4D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -222,13 +224,13 @@ void TetragonalLowOps::getRodSymOp(int i, double* r) const r[2] = TetragonalLow::RodSym[i][2]; } -EbsdLib::Matrix3X3D TetragonalLowOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D TetragonalLowOps::getMatSymOpD(int i) const { return {TetragonalLow::MatSym[i][0][0], TetragonalLow::MatSym[i][0][1], TetragonalLow::MatSym[i][0][2], TetragonalLow::MatSym[i][1][0], TetragonalLow::MatSym[i][1][1], TetragonalLow::MatSym[i][1][2], TetragonalLow::MatSym[i][2][0], TetragonalLow::MatSym[i][2][1], TetragonalLow::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F TetragonalLowOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F TetragonalLowOps::getMatSymOpF(int i) const { return {static_cast(TetragonalLow::MatSym[i][0][0]), static_cast(TetragonalLow::MatSym[i][0][1]), static_cast(TetragonalLow::MatSym[i][0][2]), static_cast(TetragonalLow::MatSym[i][1][0]), static_cast(TetragonalLow::MatSym[i][1][1]), static_cast(TetragonalLow::MatSym[i][1][2]), @@ -364,7 +366,7 @@ EulerDType TetragonalLowOps::determineEulerAngles(double random[3], int choose) EulerDType TetragonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TetragonalLow::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = TetragonalLow::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -500,13 +502,13 @@ namespace TetragonalLow { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -517,12 +519,12 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -570,7 +572,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TetragonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void TetragonalLowOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -599,7 +601,7 @@ void TetragonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* e // ----------------------------------------------------------------------------- std::array TetragonalLowOps::getIpfColorAngleLimits(double eta) const { - return {TetragonalLow::k_EtaMin * EbsdLib::Constants::k_DegToRadD, TetragonalLow::k_EtaMax * EbsdLib::Constants::k_DegToRadD, TetragonalLow::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {TetragonalLow::k_EtaMin * ebsdlib::constants::k_DegToRadD, TetragonalLow::k_EtaMax * ebsdlib::constants::k_DegToRadD, TetragonalLow::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -607,14 +609,14 @@ std::array TetragonalLowOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool TetragonalLowOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (TetragonalLow::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (TetragonalLow::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (TetragonalLow::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (TetragonalLow::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (TetragonalLow::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (TetragonalLow::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb TetragonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -622,7 +624,7 @@ EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double* eulers, double* refDir, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb TetragonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -632,7 +634,7 @@ EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double phi1, double phi, double // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb TetragonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * TetragonalLow::OdfDimInitValue[0]; double range2 = 2.0f * TetragonalLow::OdfDimInitValue[1]; @@ -649,7 +651,7 @@ EbsdLib::Rgb TetragonalLowOps::generateRodriguesColor(double r1, double r2, doub green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -663,7 +665,7 @@ std::array TetragonalLowOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector TetragonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector TetragonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -688,11 +690,11 @@ std::vector TetragonalLowOps::generatePoleFigu // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -701,9 +703,9 @@ std::vector TetragonalLowOps::generatePoleFigu // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -776,11 +778,11 @@ std::vector TetragonalLowOps::generatePoleFigu config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -820,16 +822,16 @@ std::vector TetragonalLowOps::generatePoleFigu namespace { -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalLowOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalLowOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -845,7 +847,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalLowOps* ops, in double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0) // Outside unit circle { @@ -861,7 +863,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalLowOps* ops, in } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -933,7 +935,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -945,7 +947,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -955,7 +957,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } // Draw the [0001] in the center of the image @@ -965,11 +967,11 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(label.c_str()); float x = figureCenter[0] + fontWidth * 0.20F; float y = fontPtSize * 3.0F; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } if(drawFullCircle) { - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line {0.0, 1.0, 1.0}, // Vertical Meridian Line {-1.0, 1.0, 0.0}, // Upper Left to Lower Right @@ -981,14 +983,14 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); + ebsdlib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1022,19 +1024,19 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1056,18 +1058,18 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/TetragonalLowOps.h b/Source/EbsdLib/LaueOps/TetragonalLowOps.h index cdb4d798..52d1bd89 100644 --- a/Source/EbsdLib/LaueOps/TetragonalLowOps.h +++ b/Source/EbsdLib/LaueOps/TetragonalLowOps.h @@ -41,7 +41,8 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class TetragonalLowOps TetragonalLowOps.h DREAM3DLib/Common/LaueOps/TetragonalLowOps.h * @brief @@ -150,7 +151,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +163,8 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +186,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -198,9 +199,9 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -211,18 +212,18 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -230,10 +231,10 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -245,7 +246,7 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -268,3 +269,4 @@ class EbsdLib_EXPORT TetragonalLowOps : public LaueOps TetragonalLowOps& operator=(const TetragonalLowOps&) = delete; // Copy Assignment Not Implemented TetragonalLowOps& operator=(TetragonalLowOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/TetragonalOps.cpp b/Source/EbsdLib/LaueOps/TetragonalOps.cpp index a3d0f3fc..372eccf7 100644 --- a/Source/EbsdLib/LaueOps/TetragonalOps.cpp +++ b/Source/EbsdLib/LaueOps/TetragonalOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -52,14 +53,15 @@ #include #include #endif +using namespace ebsdlib; namespace TetragonalHigh { static const std::array OdfNumBins = {36, 36, 18}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver2D)-std::sin((EbsdLib::Constants::k_PiOver2D)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiOver4D)-std::sin((EbsdLib::Constants::k_PiOver4D)))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiOver4D)-std::sin((ebsdlib::constants::k_PiOver4D)))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -249,13 +251,13 @@ void TetragonalOps::getRodSymOp(int i, double* r) const r[2] = TetragonalHigh::RodSym[i][2]; } -EbsdLib::Matrix3X3D TetragonalOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D TetragonalOps::getMatSymOpD(int i) const { return {TetragonalHigh::MatSym[i][0][0], TetragonalHigh::MatSym[i][0][1], TetragonalHigh::MatSym[i][0][2], TetragonalHigh::MatSym[i][1][0], TetragonalHigh::MatSym[i][1][1], TetragonalHigh::MatSym[i][1][2], TetragonalHigh::MatSym[i][2][0], TetragonalHigh::MatSym[i][2][1], TetragonalHigh::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F TetragonalOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F TetragonalOps::getMatSymOpF(int i) const { return {static_cast(TetragonalHigh::MatSym[i][0][0]), static_cast(TetragonalHigh::MatSym[i][0][1]), static_cast(TetragonalHigh::MatSym[i][0][2]), static_cast(TetragonalHigh::MatSym[i][1][0]), static_cast(TetragonalHigh::MatSym[i][1][1]), static_cast(TetragonalHigh::MatSym[i][1][2]), @@ -393,7 +395,7 @@ EulerDType TetragonalOps::determineEulerAngles(double random[3], int choose) con EulerDType TetragonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TetragonalHigh::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = TetragonalHigh::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -527,13 +529,13 @@ namespace TetragonalHigh { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -544,13 +546,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -583,15 +585,15 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // 111 Family - direction[0] = EbsdLib::Constants::k_1OverRoot2D; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = ebsdlib::constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; direction[2] = 0; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 12)); std::transform(m_xyz111->getPointer(i * 12), m_xyz111->getPointer(i * 12 + 3), m_xyz111->getPointer(i * 12 + 3), // write to the next triplet in memory [](float value) { return value * -1.0F; }); // Multiply each value by -1.0 - direction[0] = -EbsdLib::Constants::k_1OverRoot2D; - direction[1] = EbsdLib::Constants::k_1OverRoot2D; + direction[0] = -ebsdlib::constants::k_1OverRoot2D; + direction[1] = ebsdlib::constants::k_1OverRoot2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 12 + 6)); std::transform(m_xyz111->getPointer(i * 12 + 6), m_xyz111->getPointer(i * 12 + 9), @@ -611,7 +613,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TetragonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void TetragonalOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -646,7 +648,7 @@ void TetragonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eule // ----------------------------------------------------------------------------- std::array TetragonalOps::getIpfColorAngleLimits(double eta) const { - return {TetragonalHigh::k_EtaMin * EbsdLib::Constants::k_DegToRadD, TetragonalHigh::k_EtaMax * EbsdLib::Constants::k_DegToRadD, TetragonalHigh::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {TetragonalHigh::k_EtaMin * ebsdlib::constants::k_DegToRadD, TetragonalHigh::k_EtaMax * ebsdlib::constants::k_DegToRadD, TetragonalHigh::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -654,14 +656,14 @@ std::array TetragonalOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool TetragonalOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (TetragonalHigh::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (TetragonalHigh::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (TetragonalHigh::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (TetragonalHigh::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (TetragonalHigh::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (TetragonalHigh::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb TetragonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -669,7 +671,7 @@ EbsdLib::Rgb TetragonalOps::generateIPFColor(double* eulers, double* refDir, boo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb TetragonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -679,7 +681,7 @@ EbsdLib::Rgb TetragonalOps::generateIPFColor(double phi1, double phi, double phi // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TetragonalOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb TetragonalOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * TetragonalHigh::OdfDimInitValue[0]; double range2 = 2.0f * TetragonalHigh::OdfDimInitValue[1]; @@ -696,7 +698,7 @@ EbsdLib::Rgb TetragonalOps::generateRodriguesColor(double r1, double r2, double green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -710,7 +712,7 @@ std::array TetragonalOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector TetragonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector TetragonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -735,11 +737,11 @@ std::vector TetragonalOps::generatePoleFigure( // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TetragonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -748,9 +750,9 @@ std::vector TetragonalOps::generatePoleFigure( // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -823,11 +825,11 @@ std::vector TetragonalOps::generatePoleFigure( config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -867,16 +869,16 @@ std::vector TetragonalOps::generatePoleFigure( namespace { -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -892,7 +894,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalOps* ops, int i double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if((!generateEntirePlane && x < y) || sumSquares > 1.0 || (!generateEntirePlane && y < 0.0F)) // Outside unit circle { @@ -904,7 +906,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TetragonalOps* ops, int i } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -976,7 +978,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -988,7 +990,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -998,14 +1000,14 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] + fontPtSize; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer TetragonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer TetragonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1039,19 +1041,19 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalOps::generateIPFTriangleLegend(int ca std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1073,18 +1075,18 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalOps::generateIPFTriangleLegend(int ca // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/TetragonalOps.h b/Source/EbsdLib/LaueOps/TetragonalOps.h index 1d747527..9c378eb2 100644 --- a/Source/EbsdLib/LaueOps/TetragonalOps.h +++ b/Source/EbsdLib/LaueOps/TetragonalOps.h @@ -41,7 +41,8 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class TetragonalOps TetragonalOps.h DREAM3DLib/Common/LaueOps/TetragonalOps.h * @brief @@ -150,7 +151,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +163,8 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +186,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -198,9 +199,9 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -211,18 +212,18 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -230,10 +231,10 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -245,7 +246,7 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -268,3 +269,4 @@ class EbsdLib_EXPORT TetragonalOps : public LaueOps TetragonalOps& operator=(const TetragonalOps&) = delete; // Copy Assignment Not Implemented TetragonalOps& operator=(TetragonalOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/TriclinicOps.cpp b/Source/EbsdLib/LaueOps/TriclinicOps.cpp index a94f3ad9..aea92c3b 100644 --- a/Source/EbsdLib/LaueOps/TriclinicOps.cpp +++ b/Source/EbsdLib/LaueOps/TriclinicOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -54,14 +55,15 @@ #include #include #endif +using namespace ebsdlib; namespace Triclinic { static const std::array OdfNumBins = {72, 72, 72}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD)-std::sin((EbsdLib::Constants::k_PiD)))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -211,13 +213,13 @@ void TriclinicOps::getRodSymOp(int i, double* r) const r[2] = Triclinic::RodSym[i][2]; } -EbsdLib::Matrix3X3D TriclinicOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D TriclinicOps::getMatSymOpD(int i) const { return {Triclinic::MatSym[i][0][0], Triclinic::MatSym[i][0][1], Triclinic::MatSym[i][0][2], Triclinic::MatSym[i][1][0], Triclinic::MatSym[i][1][1], Triclinic::MatSym[i][1][2], Triclinic::MatSym[i][2][0], Triclinic::MatSym[i][2][1], Triclinic::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F TriclinicOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F TriclinicOps::getMatSymOpF(int i) const { return {static_cast(Triclinic::MatSym[i][0][0]), static_cast(Triclinic::MatSym[i][0][1]), static_cast(Triclinic::MatSym[i][0][2]), static_cast(Triclinic::MatSym[i][1][0]), static_cast(Triclinic::MatSym[i][1][1]), static_cast(Triclinic::MatSym[i][1][2]), @@ -262,7 +264,7 @@ RodriguesDType TriclinicOps::getODFFZRod(const RodriguesDType& rod) const // ----------------------------------------------------------------------------- RodriguesDType TriclinicOps::getMDFFZRod(const RodriguesDType& inRod) const { - throw EbsdLib::method_not_implemented("TriclinicOps::getMDFFZRod not implemented"); + throw ebsdlib::method_not_implemented("TriclinicOps::getMDFFZRod not implemented"); RodriguesDType rod = LaueOps::_calcRodNearestOrigin(Triclinic::RodSym, inRod); @@ -350,7 +352,7 @@ EulerDType TriclinicOps::determineEulerAngles(double random[3], int choose) cons EulerDType TriclinicOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(Triclinic::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = Triclinic::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -485,13 +487,13 @@ namespace TriclinicHigh { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -502,13 +504,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -556,7 +558,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TriclinicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void TriclinicOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -591,7 +593,7 @@ void TriclinicOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* euler // ----------------------------------------------------------------------------- std::array TriclinicOps::getIpfColorAngleLimits(double eta) const { - return {Triclinic::k_EtaMin * EbsdLib::Constants::k_DegToRadD, Triclinic::k_EtaMax * EbsdLib::Constants::k_DegToRadD, Triclinic::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {Triclinic::k_EtaMin * ebsdlib::constants::k_DegToRadD, Triclinic::k_EtaMax * ebsdlib::constants::k_DegToRadD, Triclinic::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -599,14 +601,14 @@ std::array TriclinicOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool TriclinicOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (Triclinic::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (Triclinic::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (Triclinic::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (Triclinic::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (Triclinic::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (Triclinic::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TriclinicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb TriclinicOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -614,7 +616,7 @@ EbsdLib::Rgb TriclinicOps::generateIPFColor(double* eulers, double* refDir, bool // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TriclinicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb TriclinicOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -624,7 +626,7 @@ EbsdLib::Rgb TriclinicOps::generateIPFColor(double phi1, double phi, double phi2 // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TriclinicOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb TriclinicOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * Triclinic::OdfDimInitValue[0]; double range2 = 2.0f * Triclinic::OdfDimInitValue[1]; @@ -641,7 +643,7 @@ EbsdLib::Rgb TriclinicOps::generateRodriguesColor(double r1, double r2, double r green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -655,7 +657,7 @@ std::array TriclinicOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector TriclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector TriclinicOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -680,11 +682,11 @@ std::vector TriclinicOps::generatePoleFigure(P // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * Triclinic::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -693,9 +695,9 @@ std::vector TriclinicOps::generatePoleFigure(P // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -768,10 +770,10 @@ std::vector TriclinicOps::generatePoleFigure(P config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -811,16 +813,16 @@ std::vector TriclinicOps::generatePoleFigure(P namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TriclinicOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const TriclinicOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 0.0); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -837,7 +839,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TriclinicOps* ops, int im double y = -1.0f + 2.0f * yIndex * yInc; double sumSquares = (x * x) + (y * y); - EbsdLib::Rgb color = 0xFFFFFFFF; // Default to white + ebsdlib::Rgb color = 0xFFFFFFFF; // Default to white if(sumSquares > 1.0) // Outside unit circle { @@ -845,7 +847,7 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TriclinicOps* ops, int im } else { - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); color = ops->generateIPFColor(k_Orientation.data(), sphericalCoords.data(), false); } @@ -915,7 +917,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float // float penWidth = 1.0f; // context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); // context.set_line_width(penWidth); - // EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + // ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); // } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -927,7 +929,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -937,12 +939,12 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float y = figureCenter[1] - fontPtSize * 0.2F; std::string label("[001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } if(drawFullCircle) { - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line {0.0, 1.0, 1.0}, // Vertical Meridian Line {-1.0, 1.0, 0.0}, // Upper Left to Lower Right @@ -954,7 +956,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); + ebsdlib::DrawStereographicLines(context, directions, numPoints, halfWidth, figureOrigin); } } @@ -962,7 +964,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer TriclinicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer TriclinicOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -995,19 +997,19 @@ EbsdLib::UInt8ArrayType::Pointer TriclinicOps::generateIPFTriangleLegend(int can std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; // Create the actual Legend which will come back as ARGB values - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); // Create a 2D Canvas to draw into now that the Legend is in the proper form canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1029,18 +1031,18 @@ EbsdLib::UInt8ArrayType::Pointer TriclinicOps::generateIPFTriangleLegend(int can // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); // Remove the Alpha channel from the final image - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/TriclinicOps.h b/Source/EbsdLib/LaueOps/TriclinicOps.h index 0bdaf48b..6a52cfb3 100644 --- a/Source/EbsdLib/LaueOps/TriclinicOps.h +++ b/Source/EbsdLib/LaueOps/TriclinicOps.h @@ -41,7 +41,8 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class TriclinicOps TriclinicOps.h DREAM3DLib/Common/LaueOps/TriclinicOps.h * @brief @@ -150,7 +151,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -162,8 +163,8 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +186,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -198,9 +199,9 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -211,18 +212,18 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -230,10 +231,10 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -245,7 +246,7 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -268,3 +269,4 @@ class EbsdLib_EXPORT TriclinicOps : public LaueOps TriclinicOps& operator=(const TriclinicOps&) = delete; // Copy Assignment Not Implemented TriclinicOps& operator=(TriclinicOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp b/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp index 66177972..65295f67 100644 --- a/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp +++ b/Source/EbsdLib/LaueOps/TrigonalLowOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -53,14 +54,15 @@ #endif #include +using namespace ebsdlib; namespace TrigonalLow { static const std::array OdfNumBins = {72, 72, 24}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (EbsdLib::Constants::k_PiD - std::sin(EbsdLib::Constants::k_PiD))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiD - std::sin(EbsdLib::Constants::k_PiD))), (1.0 / 3.0)), - std::pow((0.75 * ((EbsdLib::Constants::k_PiD / 6.0) - std::sin(EbsdLib::Constants::k_PiD / 6.0))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)), + std::pow((0.75 * ((ebsdlib::constants::k_PiD / 6.0) - std::sin(ebsdlib::constants::k_PiD / 6.0))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -220,13 +222,13 @@ void TrigonalLowOps::getRodSymOp(int i, double* r) const r[2] = TrigonalLow::RodSym[i][2]; } -EbsdLib::Matrix3X3D TrigonalLowOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D TrigonalLowOps::getMatSymOpD(int i) const { return {TrigonalLow::MatSym[i][0][0], TrigonalLow::MatSym[i][0][1], TrigonalLow::MatSym[i][0][2], TrigonalLow::MatSym[i][1][0], TrigonalLow::MatSym[i][1][1], TrigonalLow::MatSym[i][1][2], TrigonalLow::MatSym[i][2][0], TrigonalLow::MatSym[i][2][1], TrigonalLow::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F TrigonalLowOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F TrigonalLowOps::getMatSymOpF(int i) const { return {static_cast(TrigonalLow::MatSym[i][0][0]), static_cast(TrigonalLow::MatSym[i][0][1]), static_cast(TrigonalLow::MatSym[i][0][2]), static_cast(TrigonalLow::MatSym[i][1][0]), static_cast(TrigonalLow::MatSym[i][1][1]), static_cast(TrigonalLow::MatSym[i][1][2]), @@ -285,7 +287,7 @@ RodriguesDType TrigonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { ax[0] = -ax[0], ax[1] = -ax[1], ax[2] = -ax[2]; } - float angle = static_cast(180.0 * std::atan2(ax[1], ax[0]) * EbsdLib::Constants::k_1OverPiD); + float angle = static_cast(180.0 * std::atan2(ax[1], ax[0]) * ebsdlib::constants::k_1OverPiD); if(angle < 0) { angle = angle + 360.0f; @@ -299,7 +301,7 @@ RodriguesDType TrigonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const if(int(angle / 60) % 2 == 0) { FZw = angle - (60.0f * int(angle / 60.0f)); - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -307,7 +309,7 @@ RodriguesDType TrigonalLowOps::getMDFFZRod(const RodriguesDType& inRod) const { FZw = angle - (60.0f * int(angle / 60.0f)); FZw = 60.0f - FZw; - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -394,7 +396,7 @@ EulerDType TrigonalLowOps::determineEulerAngles(double random[3], int choose) co EulerDType TrigonalLowOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TrigonalLow::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = TrigonalLow::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -529,13 +531,13 @@ namespace TrigonalLow { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -546,13 +548,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -569,7 +571,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // [-1-120] Family direction[0] = -0.5; - direction[1] = EbsdLib::Constants::k_Root3Over2D; + direction[1] = ebsdlib::constants::k_Root3Over2D; direction[2] = 0.0; (gTranspose * direction).copyInto(m_xyz011->getPointer(i * 6)); std::transform(m_xyz011->getPointer(i * 6), m_xyz011->getPointer(i * 6 + 3), @@ -600,7 +602,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TrigonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void TrigonalLowOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -635,7 +637,7 @@ void TrigonalLowOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eul // ----------------------------------------------------------------------------- std::array TrigonalLowOps::getIpfColorAngleLimits(double eta) const { - return {TrigonalLow::k_EtaMin * EbsdLib::Constants::k_DegToRadD, TrigonalLow::k_EtaMax * EbsdLib::Constants::k_DegToRadD, TrigonalLow::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {TrigonalLow::k_EtaMin * ebsdlib::constants::k_DegToRadD, TrigonalLow::k_EtaMax * ebsdlib::constants::k_DegToRadD, TrigonalLow::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -643,14 +645,14 @@ std::array TrigonalLowOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool TrigonalLowOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (TrigonalLow::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (TrigonalLow::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (TrigonalLow::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (TrigonalLow::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (TrigonalLow::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (TrigonalLow::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb TrigonalLowOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -658,7 +660,7 @@ EbsdLib::Rgb TrigonalLowOps::generateIPFColor(double* eulers, double* refDir, bo // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb TrigonalLowOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -668,7 +670,7 @@ EbsdLib::Rgb TrigonalLowOps::generateIPFColor(double phi1, double phi, double ph // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb TrigonalLowOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * TrigonalLow::OdfDimInitValue[0]; double range2 = 2.0f * TrigonalLow::OdfDimInitValue[1]; @@ -685,7 +687,7 @@ EbsdLib::Rgb TrigonalLowOps::generateRodriguesColor(double r1, double r2, double green = green / max1; blue = blue / max2; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -699,7 +701,7 @@ std::array TrigonalLowOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector TrigonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector TrigonalLowOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -724,11 +726,11 @@ std::vector TrigonalLowOps::generatePoleFigure // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalLow::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -737,9 +739,9 @@ std::vector TrigonalLowOps::generatePoleFigure // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -812,11 +814,11 @@ std::vector TrigonalLowOps::generatePoleFigure config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -857,19 +859,19 @@ std::vector TrigonalLowOps::generatePoleFigure namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalLowOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalLowOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 00.0 * EbsdLib::Constants::k_PiOver180D); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 00.0 * ebsdlib::constants::k_PiOver180D); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); // Find the slope of the bounding line. - static const double m = std::sin(60.0 * EbsdLib::Constants::k_PiOver180D) / std::cos(60.0 * EbsdLib::Constants::k_PiOver180D); + static const double m = std::sin(60.0 * ebsdlib::constants::k_PiOver180D) / std::cos(60.0 * ebsdlib::constants::k_PiOver180D); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -887,8 +889,8 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalLowOps* ops, int x = -1.0f + 2.0f * xIndex * xInc; y = -1.0f + 2.0f * yIndex * yInc; } - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); - EbsdLib::Rgb color = 0xFFFFFFFF; + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); + ebsdlib::Rgb color = 0xFFFFFFFF; double sumSquares = (x * x) + (y * y); if(sumSquares > 1.0f) @@ -949,7 +951,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float { radius = 1.0F; float angle = angles[idx]; - float rads = angle * EbsdLib::Constants::k_PiOver180F; + float rads = angle * ebsdlib::constants::k_PiOver180F; float x = radius * (cos(rads)); float y = radius * (sin(rads)); @@ -975,7 +977,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -987,7 +989,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -996,7 +998,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float x = figureCenter[0]; float y = figureCenter[1] - fontPtSize * 0.2F; std::string label("[0001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } // Draw the [0001] in the center of the image @@ -1006,14 +1008,14 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(label.c_str()); float x = figureOrigin[0] + margins[3]; float y = fontPtSize * 3.0F; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer TrigonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer TrigonalLowOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1046,13 +1048,13 @@ EbsdLib::UInt8ArrayType::Pointer TrigonalLowOps::generateIPFTriangleLegend(int c } std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Create a Canvas to draw into canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1069,27 +1071,27 @@ EbsdLib::UInt8ArrayType::Pointer TrigonalLowOps::generateIPFTriangleLegend(int c context.fill(); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); context.draw_image(image->getPointer(0), legendWidth, legendHeight, legendWidth * image->getNumberOfComponents(), figureOrigin[0], figureOrigin[1], static_cast(legendWidth), static_cast(legendHeight)); // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/TrigonalLowOps.h b/Source/EbsdLib/LaueOps/TrigonalLowOps.h index 0b59a4f7..1839dd1f 100644 --- a/Source/EbsdLib/LaueOps/TrigonalLowOps.h +++ b/Source/EbsdLib/LaueOps/TrigonalLowOps.h @@ -37,12 +37,13 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +#include "EbsdLib/Orientation/OrientationFwd.hpp" +namespace ebsdlib +{ /** * @class TrigonalLowOps TrigonalLowOps.h DREAM3DLib/Common/LaueOps/TrigonalLowOps.h * @brief @@ -151,7 +152,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param q2 Input Quaternion * @return Axis Angle Representation */ - // EbsdLib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; + // ebsdlib::AxisAngleDType calculateMisorientation(const QuatF& q1, const QuatF& q2) const override; QuatD getQuatSymOp(int i) const override; void getRodSymOp(int i, double* r) const override; @@ -163,8 +164,8 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -186,7 +187,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -200,9 +201,9 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -213,18 +214,18 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -232,10 +233,10 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -247,7 +248,7 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -270,3 +271,4 @@ class EbsdLib_EXPORT TrigonalLowOps : public LaueOps TrigonalLowOps& operator=(const TrigonalLowOps&) = delete; // Copy Assignment Not Implemented TrigonalLowOps& operator=(TrigonalLowOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/LaueOps/TrigonalOps.cpp b/Source/EbsdLib/LaueOps/TrigonalOps.cpp index fd3799be..33896038 100644 --- a/Source/EbsdLib/LaueOps/TrigonalOps.cpp +++ b/Source/EbsdLib/LaueOps/TrigonalOps.cpp @@ -38,8 +38,9 @@ // Include this FIRST because there is a needed define for some compiles // to expose some of the constants needed below #include "EbsdLib/Core/EbsdMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/CanvasUtilities.hpp" #include "EbsdLib/Utilities/ColorTable.h" #include "EbsdLib/Utilities/ComputeStereographicProjection.h" @@ -52,14 +53,15 @@ #include #include #endif +using namespace ebsdlib; namespace TrigonalHigh { static const std::array OdfNumBins = {36, 36, 24}; // Represents a 5Deg bin -static const std::array OdfDimInitValue = {std::pow((0.75 * (EbsdLib::Constants::k_PiOver2D - std::sin(EbsdLib::Constants::k_PiOver2D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver2D - std::sin(EbsdLib::Constants::k_PiOver2D))), (1.0 / 3.0)), - std::pow((0.75 * (EbsdLib::Constants::k_PiOver3D - std::sin(EbsdLib::Constants::k_PiOver3D))), (1.0 / 3.0))}; +static const std::array OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)), + std::pow((0.75 * (ebsdlib::constants::k_PiOver3D - std::sin(ebsdlib::constants::k_PiOver3D))), (1.0 / 3.0))}; static const std::array OdfDimStepValue = {OdfDimInitValue[0] / static_cast(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast(OdfNumBins[1] / 2), OdfDimInitValue[2] / static_cast(OdfNumBins[2] / 2)}; @@ -236,13 +238,13 @@ void TrigonalOps::getRodSymOp(int i, double* r) const r[2] = TrigonalHigh::RodSym[i][2]; } -EbsdLib::Matrix3X3D TrigonalOps::getMatSymOpD(int i) const +ebsdlib::Matrix3X3D TrigonalOps::getMatSymOpD(int i) const { return {TrigonalHigh::MatSym[i][0][0], TrigonalHigh::MatSym[i][0][1], TrigonalHigh::MatSym[i][0][2], TrigonalHigh::MatSym[i][1][0], TrigonalHigh::MatSym[i][1][1], TrigonalHigh::MatSym[i][1][2], TrigonalHigh::MatSym[i][2][0], TrigonalHigh::MatSym[i][2][1], TrigonalHigh::MatSym[i][2][2]}; } -EbsdLib::Matrix3X3F TrigonalOps::getMatSymOpF(int i) const +ebsdlib::Matrix3X3F TrigonalOps::getMatSymOpF(int i) const { return {static_cast(TrigonalHigh::MatSym[i][0][0]), static_cast(TrigonalHigh::MatSym[i][0][1]), static_cast(TrigonalHigh::MatSym[i][0][2]), static_cast(TrigonalHigh::MatSym[i][1][0]), static_cast(TrigonalHigh::MatSym[i][1][1]), static_cast(TrigonalHigh::MatSym[i][1][2]), @@ -306,7 +308,7 @@ RodriguesDType TrigonalOps::getMDFFZRod(const RodriguesDType& inRod) const { n1 = -n1, n2 = -n2, n3 = -n3; } - float angle = static_cast(180.0 * std::atan2(n2, n1) * EbsdLib::Constants::k_1OverPiD); + float angle = static_cast(180.0 * std::atan2(n2, n1) * ebsdlib::constants::k_1OverPiD); if(angle < 0) { angle = angle + 360.0f; @@ -320,7 +322,7 @@ RodriguesDType TrigonalOps::getMDFFZRod(const RodriguesDType& inRod) const if(int(angle / 60) % 2 == 0) { FZw = angle - (60.0f * int(angle / 60.0f)); - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -328,7 +330,7 @@ RodriguesDType TrigonalOps::getMDFFZRod(const RodriguesDType& inRod) const { FZw = angle - (60.0f * int(angle / 60.0f)); FZw = 60.0f - FZw; - FZw = FZw * EbsdLib::Constants::k_PiOver180D; + FZw = FZw * ebsdlib::constants::k_PiOver180D; FZn1 = n1n2mag * std::cos(FZw); FZn2 = n1n2mag * std::sin(FZw); } @@ -415,7 +417,7 @@ EulerDType TrigonalOps::determineEulerAngles(double random[3], int choose) const EulerDType TrigonalOps::randomizeEulerAngles(const EulerDType& synea) const { size_t symOp = getRandomSymmetryOperatorIndex(TrigonalHigh::k_SymOpsCount); - QuatD quat = synea.toQuat(); + QuatD quat = synea.toQuaternion(); QuatD qc = TrigonalHigh::QuatSym[symOp] * quat; return QuaternionDType(qc).toEuler(); } @@ -547,13 +549,13 @@ namespace TrigonalHigh { class GenerateSphereCoordsImpl { - EbsdLib::FloatArrayType* m_Eulers; - EbsdLib::FloatArrayType* m_xyz001; - EbsdLib::FloatArrayType* m_xyz011; - EbsdLib::FloatArrayType* m_xyz111; + ebsdlib::FloatArrayType* m_Eulers; + ebsdlib::FloatArrayType* m_xyz001; + ebsdlib::FloatArrayType* m_xyz011; + ebsdlib::FloatArrayType* m_xyz111; public: - GenerateSphereCoordsImpl(EbsdLib::FloatArrayType* eulerAngles, EbsdLib::FloatArrayType* xyz001Coords, EbsdLib::FloatArrayType* xyz011Coords, EbsdLib::FloatArrayType* xyz111Coords) + GenerateSphereCoordsImpl(ebsdlib::FloatArrayType* eulerAngles, ebsdlib::FloatArrayType* xyz001Coords, ebsdlib::FloatArrayType* xyz011Coords, ebsdlib::FloatArrayType* xyz111Coords) : m_Eulers(eulerAngles) , m_xyz001(xyz001Coords) , m_xyz011(xyz011Coords) @@ -564,13 +566,13 @@ class GenerateSphereCoordsImpl void generate(size_t start, size_t end) const { - EbsdLib::Matrix3X3D gTranspose; - EbsdLib::Matrix3X1D direction(0.0, 0.0, 0.0); + ebsdlib::Matrix3X3D gTranspose; + ebsdlib::Matrix3X1D direction(0.0, 0.0, 0.0); // Generate all the Coordinates for(size_t i = start; i < end; ++i) { - EbsdLib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); + ebsdlib::Matrix3X3D g(EulerDType(m_Eulers->getValue(i * 3), m_Eulers->getValue(i * 3 + 1), m_Eulers->getValue(i * 3 + 2)).toOrientationMatrix().data()); gTranspose = g.transpose(); @@ -596,7 +598,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // [1-100] - direction[0] = EbsdLib::Constants::k_Root3Over2D; + direction[0] = ebsdlib::constants::k_Root3Over2D; direction[1] = -0.5; direction[2] = 0; (gTranspose * direction).copyInto(m_xyz111->getPointer(i * 6)); @@ -618,7 +620,7 @@ class GenerateSphereCoordsImpl // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TrigonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* xyz001, EbsdLib::FloatArrayType* xyz011, EbsdLib::FloatArrayType* xyz111) const +void TrigonalOps::generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* xyz001, ebsdlib::FloatArrayType* xyz011, ebsdlib::FloatArrayType* xyz111) const { size_t nOrientations = eulers->getNumberOfTuples(); @@ -653,7 +655,7 @@ void TrigonalOps::generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers // ----------------------------------------------------------------------------- std::array TrigonalOps::getIpfColorAngleLimits(double eta) const { - return {TrigonalHigh::k_EtaMin * EbsdLib::Constants::k_DegToRadD, TrigonalHigh::k_EtaMax * EbsdLib::Constants::k_DegToRadD, TrigonalHigh::k_ChiMax * EbsdLib::Constants::k_DegToRadD}; + return {TrigonalHigh::k_EtaMin * ebsdlib::constants::k_DegToRadD, TrigonalHigh::k_EtaMax * ebsdlib::constants::k_DegToRadD, TrigonalHigh::k_ChiMax * ebsdlib::constants::k_DegToRadD}; } // ----------------------------------------------------------------------------- @@ -661,14 +663,14 @@ std::array TrigonalOps::getIpfColorAngleLimits(double eta) const // ----------------------------------------------------------------------------- bool TrigonalOps::inUnitTriangle(double eta, double chi) const { - return !(eta < (TrigonalHigh::k_EtaMin * EbsdLib::Constants::k_PiOver180D) || eta > (TrigonalHigh::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0 || - chi > (TrigonalHigh::k_ChiMax * EbsdLib::Constants::k_PiOver180D)); + return !(eta < (TrigonalHigh::k_EtaMin * ebsdlib::constants::k_PiOver180D) || eta > (TrigonalHigh::k_EtaMax * ebsdlib::constants::k_PiOver180D) || chi < 0 || + chi > (TrigonalHigh::k_ChiMax * ebsdlib::constants::k_PiOver180D)); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const +ebsdlib::Rgb TrigonalOps::generateIPFColor(double* eulers, double* refDir, bool degToRad) const { return computeIPFColor(eulers, refDir, degToRad); } @@ -676,7 +678,7 @@ EbsdLib::Rgb TrigonalOps::generateIPFColor(double* eulers, double* refDir, bool // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const +ebsdlib::Rgb TrigonalOps::generateIPFColor(double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const { double eulers[3] = {phi1, phi, phi2}; double refDir[3] = {refDir0, refDir1, refDir2}; @@ -686,7 +688,7 @@ EbsdLib::Rgb TrigonalOps::generateIPFColor(double phi1, double phi, double phi2, // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb TrigonalOps::generateRodriguesColor(double r1, double r2, double r3) const +ebsdlib::Rgb TrigonalOps::generateRodriguesColor(double r1, double r2, double r3) const { double range1 = 2.0f * TrigonalHigh::OdfDimInitValue[0]; double range2 = 2.0f * TrigonalHigh::OdfDimInitValue[1]; @@ -698,7 +700,7 @@ EbsdLib::Rgb TrigonalOps::generateRodriguesColor(double r1, double r2, double r3 double green = (r2 + max2) / range2; double blue = (r3 + max3) / range3; - return EbsdLib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(red * 255), static_cast(green * 255), static_cast(blue * 255), 255); } // ----------------------------------------------------------------------------- @@ -712,7 +714,7 @@ std::array TrigonalOps::getDefaultPoleFigureNames() const // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector TrigonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const +std::vector TrigonalOps::generatePoleFigure(PoleFigureConfiguration_t& config) const { std::array labels = getDefaultPoleFigureNames(); std::string label0 = labels[0]; @@ -737,11 +739,11 @@ std::vector TrigonalOps::generatePoleFigure(Po // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for CUBIC ONLY, <001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize0, dims, label0 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <011> Family - EbsdLib::FloatArrayType::Pointer xyz011 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz011 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize1, dims, label1 + std::string("xyzCoords"), true); // this is size for CUBIC ONLY, <111> Family - EbsdLib::FloatArrayType::Pointer xyz111 = EbsdLib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); + ebsdlib::FloatArrayType::Pointer xyz111 = ebsdlib::FloatArrayType::CreateArray(numOrientations * TrigonalHigh::symSize2, dims, label2 + std::string("xyzCoords"), true); config.sphereRadius = 1.0f; @@ -750,9 +752,9 @@ std::vector TrigonalOps::generatePoleFigure(Po // These arrays hold the "intensity" images which eventually get converted to an actual Color RGB image // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere - EbsdLib::DoubleArrayType::Pointer intensity001 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity011 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); - EbsdLib::DoubleArrayType::Pointer intensity111 = EbsdLib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity001 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label0 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity011 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label1 + "_Intensity_Image", true); + ebsdlib::DoubleArrayType::Pointer intensity111 = ebsdlib::DoubleArrayType::CreateArray(config.imageDim * config.imageDim, label2 + "_Intensity_Image", true); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS bool doParallel = true; @@ -825,11 +827,11 @@ std::vector TrigonalOps::generatePoleFigure(Po config.maxScale = max; dims[0] = 4; - EbsdLib::UInt8ArrayType::Pointer image001 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); - EbsdLib::UInt8ArrayType::Pointer image011 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); - EbsdLib::UInt8ArrayType::Pointer image111 = EbsdLib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); + ebsdlib::UInt8ArrayType::Pointer image001 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label0, true); + ebsdlib::UInt8ArrayType::Pointer image011 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label1, true); + ebsdlib::UInt8ArrayType::Pointer image111 = ebsdlib::UInt8ArrayType::CreateArray(config.imageDim * config.imageDim, dims, label2, true); - std::vector poleFigures(3); + std::vector poleFigures(3); if(config.order.size() == 3) { poleFigures[config.order[0]] = image001; @@ -869,19 +871,19 @@ std::vector TrigonalOps::generatePoleFigure(Po namespace { // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalOps* ops, int imageDim, bool generateEntirePlane) +ebsdlib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalOps* ops, int imageDim, bool generateEntirePlane) { std::vector dims(1, 4); std::string arrayName = EbsdStringUtils::replace(ops->getSymmetryName(), "/", "_"); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true); uint32_t* pixelPtr = reinterpret_cast(image->getPointer(0)); - static EbsdLib::Matrix3X1D k_Orientation(0.0, 0.0, 00.0 * EbsdLib::Constants::k_PiOver180D); + static ebsdlib::Matrix3X1D k_Orientation(0.0, 0.0, 00.0 * ebsdlib::constants::k_PiOver180D); double xInc = 1.0f / static_cast(imageDim); double yInc = 1.0f / static_cast(imageDim); // Find the slope of the bounding line. - static const double m = std::sin(30.0 * EbsdLib::Constants::k_PiOver180D) / std::cos(30.0 * EbsdLib::Constants::k_PiOver180D); + static const double m = std::sin(30.0 * ebsdlib::constants::k_PiOver180D) / std::cos(30.0 * ebsdlib::constants::k_PiOver180D); size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically // Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from @@ -899,8 +901,8 @@ EbsdLib::UInt8ArrayType::Pointer CreateIPFLegend(const TrigonalOps* ops, int ima x = -1.0f + 2.0f * xIndex * xInc; y = -1.0f + 2.0f * yIndex * yInc; } - auto sphericalCoords = Stereographic::Utils::StereoToSpherical(x, y).normalize(); - EbsdLib::Rgb color = 0xFFFFFFFF; + auto sphericalCoords = stereographic::utils::StereoToSpherical(x, y).normalize(); + ebsdlib::Rgb color = 0xFFFFFFFF; double sumSquares = (x * x) + (y * y); if(sumSquares > 1.0f) // Outside unit circle @@ -988,7 +990,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float penWidth = 1.0f; context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); } std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -1000,7 +1002,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); if(drawAngle[idx] || drawFullCircle) { - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } @@ -1011,13 +1013,13 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float float fontWidth = context.measure_text(fontWidthString.c_str()); float x = figureCenter[0] - fontWidth * 0.5; float y = figureCenter[1] - fontPtSize * 0.25; - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } } } // namespace // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer TrigonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const +ebsdlib::UInt8ArrayType::Pointer TrigonalOps::generateIPFTriangleLegend(int canvasDim, bool generateEntirePlane) const { // Figure out the Legend Pixel Size const float fontPtSize = static_cast(canvasDim) / 24.0f; @@ -1050,13 +1052,13 @@ EbsdLib::UInt8ArrayType::Pointer TrigonalOps::generateIPFTriangleLegend(int canv } std::array figureCenter = {figureOrigin[0] + halfWidth, figureOrigin[1] + halfHeight}; - EbsdLib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); + ebsdlib::UInt8ArrayType::Pointer image = CreateIPFLegend(this, legendHeight, generateEntirePlane); // Create a Canvas to draw into canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -1073,27 +1075,27 @@ EbsdLib::UInt8ArrayType::Pointer TrigonalOps::generateIPFTriangleLegend(int canv context.fill(); // Convert from ARGB to RGBA which is what canvas_itk wants - image = EbsdLib::ConvertColorOrder(image.get(), legendHeight); + image = ebsdlib::ConvertColorOrder(image.get(), legendHeight); // We need to mirror across the X Axis because the image was drawn with +Y pointing down - image = EbsdLib::MirrorImage(image.get(), legendHeight); + image = ebsdlib::MirrorImage(image.get(), legendHeight); context.draw_image(image->getPointer(0), legendWidth, legendHeight, legendWidth * image->getNumberOfComponents(), figureOrigin[0], figureOrigin[1], static_cast(legendWidth), static_cast(legendHeight)); // Draw Title of Legend context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize * 1.5); - EbsdLib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); + ebsdlib::WriteText(context, getSymmetryName(), {margins[0], static_cast(fontPtSize * 1.5)}, fontPtSize * 1.5); context.set_font(latoRegular.data(), static_cast(latoRegular.size()), fontPtSize); DrawFullCircleAnnotations(context, canvasDim, fontPtSize, margins, figureOrigin, figureCenter, generateEntirePlane); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } diff --git a/Source/EbsdLib/LaueOps/TrigonalOps.h b/Source/EbsdLib/LaueOps/TrigonalOps.h index 77e24503..e976dab9 100644 --- a/Source/EbsdLib/LaueOps/TrigonalOps.h +++ b/Source/EbsdLib/LaueOps/TrigonalOps.h @@ -41,7 +41,8 @@ #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" - +namespace ebsdlib +{ /** * @class TrigonalOps TrigonalOps.h DREAM3DLib/Common/LaueOps/TrigonalOps.h * @brief @@ -162,8 +163,8 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps */ void getMatSymOp(int i, double g[3][3]) const override; void getMatSymOp(int i, float g[3][3]) const override; - EbsdLib::Matrix3X3F getMatSymOpF(int i) const override; - EbsdLib::Matrix3X3D getMatSymOpD(int i) const override; + ebsdlib::Matrix3X3F getMatSymOpF(int i) const override; + ebsdlib::Matrix3X3D getMatSymOpD(int i) const override; RodriguesDType getODFFZRod(const RodriguesDType& rod) const override; RodriguesDType getMDFFZRod(const RodriguesDType& rod) const override; @@ -185,7 +186,7 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps double getF1spt(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; double getF7(const QuatD& q1, const QuatD& q2, double LD[3], bool maxSF) const override; - void generateSphereCoordsFromEulers(EbsdLib::FloatArrayType* eulers, EbsdLib::FloatArrayType* c1, EbsdLib::FloatArrayType* c2, EbsdLib::FloatArrayType* c3) const override; + void generateSphereCoordsFromEulers(ebsdlib::FloatArrayType* eulers, ebsdlib::FloatArrayType* c1, ebsdlib::FloatArrayType* c2, ebsdlib::FloatArrayType* c3) const override; /** * @brief @@ -199,9 +200,9 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param eulers Pointer to the 3 component Euler Angle * @param refDir Pointer to the 3 Component Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double* eulers, double* refDir, bool convertDegrees) const override; /** * @brief generateIPFColor Generates an ARGB Color from a Euler Angle and Reference Direction @@ -212,18 +213,18 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param dir1 Second component of the Reference Direction * @param dir2 Third component of the Reference Direction * @param convertDegrees Are the input angles in Degrees - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; + ebsdlib::Rgb generateIPFColor(double e0, double e1, double phi2, double dir0, double dir1, double dir2, bool convertDegrees) const override; /** * @brief generateRodriguesColor Generates an RGB Color from a Rodrigues Vector * @param r1 First component of the Rodrigues Vector * @param r2 Second component of the Rodrigues Vector * @param r3 Third component of the Rodrigues Vector - * @return Returns the ARGB Quadruplet EbsdLib::Rgb + * @return Returns the ARGB Quadruplet ebsdlib::Rgb */ - EbsdLib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; + ebsdlib::Rgb generateRodriguesColor(double r1, double r2, double r3) const override; /** * @brief generatePoleFigure This method will generate a number of pole figures for this crystal symmetry and the Euler @@ -231,10 +232,10 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @param eulers The Euler Angles to generate the pole figure from. * @param imageSize The size in Pixels of the final RGB Image. * @param numColors The number of colors to use in the RGB Image. Less colors can give the effect of contouring. - * @return A std::vector of EbsdLib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize + * @return A std::vector of ebsdlib::UInt8ArrayType pointers where each one represents a 2D RGB array that can be used to initialize * an image object from other libraries and written out to disk. */ - std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; + std::vector generatePoleFigure(PoleFigureConfiguration_t& config) const override; /** * @brief Returns the names for each of the three standard pole figures that are generated. For example @@ -246,7 +247,7 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps * @brief generateStandardTriangle Generates an RGBA array that is a color "Standard" IPF Triangle Legend used for IPF Color Maps. * @return */ - EbsdLib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; + ebsdlib::UInt8ArrayType::Pointer generateIPFTriangleLegend(int imageDim, bool generateEntirePlane) const override; /** * @brief Returns if the given Quaternion is within the Rodrigues Fundamental Zone (RFZ) @@ -269,3 +270,4 @@ class EbsdLib_EXPORT TrigonalOps : public LaueOps TrigonalOps& operator=(const TrigonalOps&) = delete; // Copy Assignment Not Implemented TrigonalOps& operator=(TrigonalOps&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Math/EbsdLibMath.cpp b/Source/EbsdLib/Math/EbsdLibMath.cpp index 3f29f9a5..270f8dde 100644 --- a/Source/EbsdLib/Math/EbsdLibMath.cpp +++ b/Source/EbsdLib/Math/EbsdLibMath.cpp @@ -34,13 +34,14 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "EbsdLibMath.h" + #include static const float k_MachineEpsilon = 5E-16f; // static const float k_MaxRealNumber = 1E300; // static const float k_MinRealNumber = 1E-300; -float EbsdLibMath::Gamma(float x) +float ebsdlib::math::Gamma(float x) { int i, k, m; float ga, gr, r, z; @@ -118,14 +119,14 @@ float EbsdLibMath::Gamma(float x) ga *= r; if(x < 0.0f) { - ga = -1 * EbsdLib::Constants::k_PiF / (x * ga * sinf(EbsdLib::Constants::k_PiF * x)); + ga = -1 * ebsdlib::constants::k_PiF / (x * ga * sinf(ebsdlib::constants::k_PiF * x)); } } } return ga; } -float EbsdLibMath::gammastirf(float x) +float ebsdlib::math::gammastirf(float x) { float result; float y; @@ -153,7 +154,7 @@ float EbsdLibMath::gammastirf(float x) result = 2.50662827463100050242f * y * w; return result; } -float EbsdLibMath::LnGamma(float x, float& sgngam) +float ebsdlib::math::LnGamma(float x, float& sgngam) { float result; float a; @@ -192,7 +193,7 @@ float EbsdLibMath::LnGamma(float x, float& sgngam) p = p + 1; z = p - q; } - z = q * sinf(EbsdLib::Constants::k_PiF * z); + z = q * sinf(ebsdlib::constants::k_PiF * z); result = logpi - log(z) - w; return result; } @@ -270,7 +271,7 @@ float EbsdLibMath::LnGamma(float x, float& sgngam) return result; } -float EbsdLibMath::erf(float x) +float ebsdlib::math::erf(float x) { float result; float xsq; @@ -312,7 +313,7 @@ float EbsdLibMath::erf(float x) result = s * (1 - erfc(x)); return result; } -float EbsdLibMath::erfc(float x) +float ebsdlib::math::erfc(float x) { float result; float p; @@ -325,7 +326,7 @@ float EbsdLibMath::erfc(float x) } if(x < 0.5f) { - result = 1.0f - EbsdLibMath::erf(x); + result = 1.0f - ebsdlib::math::erf(x); return result; } if(x >= 10) @@ -354,7 +355,7 @@ float EbsdLibMath::erfc(float x) result = exp(-(x * x)) * p / q; return result; } -float EbsdLibMath::incompletebeta(float a, float b, float x) +float ebsdlib::math::incompletebeta(float a, float b, float x) { constexpr float maxrealnumber = std::numeric_limits::max(); constexpr float minrealnumber = std::numeric_limits::min(); @@ -436,7 +437,7 @@ float EbsdLibMath::incompletebeta(float a, float b, float x) t = t * powf(x, a); t = t / a; t = t * w; - t = t * (EbsdLibMath::Gamma(a + b) / (EbsdLibMath::Gamma(a) * EbsdLibMath::Gamma(b))); + t = t * (ebsdlib::math::Gamma(a + b) / (ebsdlib::math::Gamma(a) * ebsdlib::math::Gamma(b))); if(flag == 1) { if(t <= k_MachineEpsilon) @@ -478,7 +479,7 @@ float EbsdLibMath::incompletebeta(float a, float b, float x) result = t; return result; } -float EbsdLibMath::incompletebetafe(float a, float b, float x, float big, float biginv) +float ebsdlib::math::incompletebetafe(float a, float b, float x, float big, float biginv) { float result; float xk; @@ -578,7 +579,7 @@ float EbsdLibMath::incompletebetafe(float a, float b, float x, float big, float result = ans; return result; } -float EbsdLibMath::incompletebetafe2(float a, float b, float x, float big, float biginv) +float ebsdlib::math::incompletebetafe2(float a, float b, float x, float big, float biginv) { float result; float xk; @@ -680,7 +681,7 @@ float EbsdLibMath::incompletebetafe2(float a, float b, float x, float big, float result = ans; return result; } -float EbsdLibMath::incompletebetaps(float a, float b, float x, float maxgam) +float ebsdlib::math::incompletebetaps(float a, float b, float x, float maxgam) { float result; float s; @@ -715,7 +716,7 @@ float EbsdLibMath::incompletebetaps(float a, float b, float x, float maxgam) u = a * log(x); if((a + b) < maxgam && fabs(u) < log(maxrealnumber)) { - t = EbsdLibMath::Gamma(a + b) / (EbsdLibMath::Gamma(a) * EbsdLibMath::Gamma(b)); + t = ebsdlib::math::Gamma(a + b) / (ebsdlib::math::Gamma(a) * ebsdlib::math::Gamma(b)); s = s * t * powf(x, a); } else @@ -734,7 +735,7 @@ float EbsdLibMath::incompletebetaps(float a, float b, float x, float maxgam) return result; } -std::vector EbsdLibMath::linspace(double minVal, double maxVal, int dim) +std::vector ebsdlib::math::linspace(double minVal, double maxVal, int dim) { std::vector result; if(dim == 1) diff --git a/Source/EbsdLib/Math/EbsdLibMath.h b/Source/EbsdLib/Math/EbsdLibMath.h index fe4553e7..00ce4b51 100644 --- a/Source/EbsdLib/Math/EbsdLibMath.h +++ b/Source/EbsdLib/Math/EbsdLibMath.h @@ -145,7 +145,7 @@ #define _MATH_DEFINES_DEFINED #endif -namespace EbsdLib::Constants +namespace ebsdlib::constants { // In C++ 20, can be replaced with header @@ -335,9 +335,9 @@ inline constexpr double k_Cos_ThreeEightPiD = k_Cos_ThreeEightPi; inline constexpr float k_Sin_ThreeEightPiF = k_Sin_ThreeEightPi; inline constexpr double k_Sin_ThreeEightPiD = k_Sin_ThreeEightPi; -} // namespace EbsdLib::Constants +} // namespace ebsdlib::constants -namespace EbsdLibMath +namespace ebsdlib::math { EbsdLib_EXPORT float Gamma(float); @@ -410,4 +410,4 @@ K transfer_sign(K a, K b) return -1 * a; } -}; // namespace EbsdLibMath +}; // namespace ebsdlib::math diff --git a/Source/EbsdLib/Math/EbsdMatrixMath.cpp b/Source/EbsdLib/Math/EbsdMatrixMath.cpp index ef8b8cea..baa06641 100644 --- a/Source/EbsdLib/Math/EbsdMatrixMath.cpp +++ b/Source/EbsdLib/Math/EbsdMatrixMath.cpp @@ -36,21 +36,22 @@ #include "EbsdMatrixMath.h" #include "EbsdLib/Math/EbsdLibMath.h" +using namespace ebsdlib; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdMatrixMath::EbsdMatrixMath() = default; +ebsdlib::EbsdMatrixMath::EbsdMatrixMath() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdMatrixMath::~EbsdMatrixMath() = default; +ebsdlib::EbsdMatrixMath::~EbsdMatrixMath() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void EbsdMatrixMath::Multiply3x3with3x1(const double g1[3][3], const double g2[3], float outMat[3]) +void ebsdlib::EbsdMatrixMath::Multiply3x3with3x1(const double g1[3][3], const double g2[3], float outMat[3]) { outMat[0] = static_cast(g1[0][0] * g2[0] + g1[0][1] * g2[1] + g1[0][2] * g2[2]); outMat[1] = static_cast(g1[1][0] * g2[0] + g1[1][1] * g2[1] + g1[1][2] * g2[2]); diff --git a/Source/EbsdLib/Math/EbsdMatrixMath.h b/Source/EbsdLib/Math/EbsdMatrixMath.h index 3b01c90d..f555c6dd 100644 --- a/Source/EbsdLib/Math/EbsdMatrixMath.h +++ b/Source/EbsdLib/Math/EbsdMatrixMath.h @@ -44,6 +44,8 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdLibMath.h" +namespace ebsdlib +{ /* * @class EbsdMatrixMath EbsdMatrixMath.h DREAM3DLib/Common/EbsdMatrixMath.h * @brief This class performs Crystallographic Misorientation Calculations @@ -633,3 +635,4 @@ class EbsdLib_EXPORT EbsdMatrixMath EbsdMatrixMath& operator=(const EbsdMatrixMath&) = delete; // Copy Assignment Not Implemented EbsdMatrixMath& operator=(EbsdMatrixMath&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Math/GeometryMath.cpp b/Source/EbsdLib/Math/GeometryMath.cpp index bd351a9b..fdbb0a9b 100644 --- a/Source/EbsdLib/Math/GeometryMath.cpp +++ b/Source/EbsdLib/Math/GeometryMath.cpp @@ -37,7 +37,7 @@ #include -namespace EbsdLib +namespace ebsdlib { // ----------------------------------------------------------------------------- @@ -62,4 +62,4 @@ double GeometryMath::CosThetaBetweenVectors(const double a[3], const double b[3] } return (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) / (norm1 * norm2); } -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Math/GeometryMath.h b/Source/EbsdLib/Math/GeometryMath.h index 0efb9e5d..07485c14 100644 --- a/Source/EbsdLib/Math/GeometryMath.h +++ b/Source/EbsdLib/Math/GeometryMath.h @@ -37,7 +37,7 @@ #include "EbsdLib/EbsdLib.h" -namespace EbsdLib +namespace ebsdlib { /* * @class GeometryMath GeometryMath.h DREAM3DLib/Common/GeometryMath.h @@ -61,4 +61,4 @@ EbsdLib_EXPORT float CosThetaBetweenVectors(const float a[3], const float b[3]); EbsdLib_EXPORT double CosThetaBetweenVectors(const double a[3], const double b[3]); } // namespace GeometryMath -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Math/Matrix3X1.hpp b/Source/EbsdLib/Math/Matrix3X1.hpp index c7a78561..cd9b35b1 100644 --- a/Source/EbsdLib/Math/Matrix3X1.hpp +++ b/Source/EbsdLib/Math/Matrix3X1.hpp @@ -3,7 +3,7 @@ #include #include -namespace EbsdLib +namespace ebsdlib { /** * @brief 3x1 Matrix as a row. @@ -332,4 +332,13 @@ class Matrix3X1 using Matrix3X1F = Matrix3X1; using Matrix3X1D = Matrix3X1; -} // namespace EbsdLib + +template +inline std::ostream& operator<<(std::ostream& os, const Matrix3X1& obj) +{ + os << "<" << obj[0] << ", " << obj[1] << ", " << obj[2] << ">"; + + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Math/Matrix3X3.hpp b/Source/EbsdLib/Math/Matrix3X3.hpp index 4bf7c98e..9c830eb4 100644 --- a/Source/EbsdLib/Math/Matrix3X3.hpp +++ b/Source/EbsdLib/Math/Matrix3X3.hpp @@ -1,11 +1,14 @@ #pragma once +#include "EbsdLib/Math/EbsdLibMath.h" #include "Matrix3X1.hpp" +#include + +#include #include -#include -namespace EbsdLib +namespace ebsdlib { /** * @brief 3X3 Matrix that is row major, i.e., the data is laid out in memory as follows: @@ -27,7 +30,7 @@ class Matrix3X3 * @brief Copies the values from the pointer. Assumes row major ordering. * @param ptr */ - Matrix3X3(const T* ptr) + explicit Matrix3X3(const T* ptr) : m_Data(std::array{ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], ptr[8]}) { } @@ -49,25 +52,6 @@ class Matrix3X3 { } - /** - * @brief Creates a 3x3 Matrix from the "C" style 2D Matrix. This assumes the data - * is properly row major, i.e., the fastest moving dimension is the second. So to - * be clear, the each row is rastered before the next row. - * @param g - */ - Matrix3X3(const T g[3][3]) - { - m_Data[0] = g[0][0]; - m_Data[1] = g[0][1]; - m_Data[2] = g[0][2]; - m_Data[3] = g[1][0]; - m_Data[4] = g[1][1]; - m_Data[5] = g[1][2]; - m_Data[6] = g[2][0]; - m_Data[7] = g[2][1]; - m_Data[8] = g[2][2]; - } - Matrix3X3(const Matrix3X3&) = default; // Copy Constructor Default Implemented Matrix3X3(Matrix3X3&&) noexcept = default; // Move Constructor Default Implemented Matrix3X3& operator=(const Matrix3X3&) = default; // Copy Assignment Default Implemented @@ -75,6 +59,81 @@ class Matrix3X3 ~Matrix3X3() = default; + const T& operator()(size_t row, size_t col) const + { + if(row > 2 || col > 2) + { + throw std::out_of_range("Matrix3X3::operator() Row or Column out of range"); + } + return m_Data[row * 3 + col]; + } + T& operator()(size_t row, size_t col) + { + if(row > 2 || col > 2) + { + throw std::out_of_range("Matrix3X3::operator() Row or Column out of range"); + } + return m_Data[row * 3 + col]; + } + /** + * + * @param latticeParameters The lattice Parameters in the order, a, b, c, alpha, beta, gamma. Note that alpha, beta, gamma are all stored as degrees. + * @return + */ + static Matrix3X3 DirectStructureMatrix(std::array latticeParameters) + { + /* This code is take from EMsoftOO/mod_crystallography.f90 - computeMatrices() function */ + + T a = latticeParameters[0]; + T b = latticeParameters[1]; + T c = latticeParameters[2]; + T alpha = latticeParameters[3]; + T beta = latticeParameters[4]; + T gamma = latticeParameters[5]; + + // auxiliary variables for the various tensors + double pirad = ebsdlib::constants::k_PiOver180D; + double ca = std::cos(pirad * alpha); + double cb = std::cos(pirad * beta); + double cg = std::cos(pirad * gamma); + double sg = std::sin(pirad * gamma); + + // cell volume via the determinant of dmt + T det = (a * b * c) * (a * b * c) * (1.0 - ca * ca - cb * cb - cg * cg + 1.0 * ca * cb * cg); + T vol = std::sqrt(det); + + Matrix3X3 dsm; + dsm(0, 0) = a; + dsm(0, 1) = b * cg; + dsm(0, 2) = c * cb; + dsm(1, 0) = 0.0; + dsm(1, 1) = b * sg; + dsm(1, 2) = -c * (cb * cg - ca) / sg; + dsm(2, 0) = 0.0; + dsm(2, 1) = 0.0; + dsm(2, 2) = vol / (a * b * sg); + return dsm; + } + + /** + * @brief Converts to an Eigen Row Major Matrix3x3 + * @return + */ + Eigen::Matrix toEigenMatrix() const + { + Eigen::Matrix g1; + g1(0, 0) = (*this)[0]; + g1(0, 1) = (*this)[1]; + g1(0, 2) = (*this)[2]; + g1(1, 0) = (*this)[3]; + g1(1, 1) = (*this)[4]; + g1(1, 2) = (*this)[5]; + g1(2, 0) = (*this)[6]; + g1(2, 1) = (*this)[7]; + g1(2, 2) = (*this)[8]; + return g1; + } + /** * @brief Returns a reference to the value at index * @param index @@ -204,7 +263,7 @@ class Matrix3X3 * @param rhs * @return a 3x1 Matrix */ - std::array operator*(const std::array& rhs) + std::array operator*(const std::array& rhs) const { std::array outMat; outMat[0] = m_Data[0] * rhs[0] + m_Data[1] * rhs[1] + m_Data[2] * rhs[2]; @@ -213,11 +272,31 @@ class Matrix3X3 return outMat; } + /** + * @brief Returns a colum vector as a Matrix3X1 + * @param col + * @return + */ + Matrix3X1 col(size_t col) const + { + return {m_Data[col], m_Data[col + 3], m_Data[col + 6]}; + } + + /** + * @breif returns a row as a Matrix3x1 + * @param row + * @return + */ + Matrix3X1 row(size_t row) const + { + return {m_Data[row * 3], m_Data[row * 3 + 1], m_Data[row * 3 + 2]}; + } + /** * @brief Multiplies each element of a 3x1 matrix by a scalar value and returns the result * @param scalar to multiply each element by. */ - SelfType operator*(T scalar) + SelfType operator*(T scalar) const { return { m_Data[0] * scalar, m_Data[1] * scalar, m_Data[2] * scalar, m_Data[3] * scalar, m_Data[4] * scalar, m_Data[5] * scalar, m_Data[6] * scalar, m_Data[7] * scalar, m_Data[8] * scalar, @@ -229,7 +308,6 @@ class Matrix3X3 * @param g * @param outMat */ - SelfType transpose() const { SelfType outMat; @@ -249,7 +327,7 @@ class Matrix3X3 * @brief Inverts the 3x3 matrix and returns the result * @return outMat */ - SelfType invert() + SelfType invert() const { SelfType adjoint = this->adjoint(); T oneOverDeterminant = 1.0 / this->determinant(); @@ -260,8 +338,7 @@ class Matrix3X3 * @brief Calculates the Adjoint matrix of the 3x3 matrix returns the result * @return outMat */ - - SelfType adjoint() + SelfType adjoint() const { SelfType temp = this->cofactor(); return temp.transpose(); @@ -271,7 +348,6 @@ class Matrix3X3 * @brief Calculates the cofactor matrix and returns the result * @return outMat */ - SelfType cofactor() const { SelfType temp = this->minors(); @@ -296,7 +372,6 @@ class Matrix3X3 * @brief Calculates the matrix of minors of the 3x3 matrix and places the result into outMat * @return outMat */ - SelfType minors() const { SelfType outMat; @@ -317,8 +392,7 @@ class Matrix3X3 * @param g 3x3 Vector * @return */ - - float determinant() + float determinant() const { return (m_Data[0] * (m_Data[4] * m_Data[8] - m_Data[5] * m_Data[7])) - (m_Data[1] * (m_Data[3] * m_Data[8] - m_Data[5] * m_Data[6])) + (m_Data[2] * (m_Data[3] * m_Data[7] - m_Data[4] * m_Data[6])); @@ -328,17 +402,15 @@ class Matrix3X3 * @brief Initializes the 3x3 matrix to the "Identity" matrix * @param g */ - - SelfType identity() + static SelfType Identity() { return {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; } /** - * @brief Performs an "in place" normalization of the 3x1 vector. + * @brief Performs normalization of the 3x3 vector. * @param g */ - SelfType normalize() const { T denom = m_Data[0] * m_Data[0] + m_Data[3] * m_Data[3] + m_Data[6] * m_Data[6]; @@ -434,4 +506,13 @@ class Matrix3X3 using Matrix3X3F = Matrix3X3; using Matrix3X3D = Matrix3X3; -} // namespace EbsdLib +template +inline std::ostream& operator<<(std::ostream& os, const Matrix3X3& obj) +{ + os << std::setw(3) << std::setprecision(16) << "| " << obj[0] << ", " << obj[1] << ", " << obj[2] << " |\n"; + os << std::setw(3) << std::setprecision(16) << "| " << obj[3] << ", " << obj[4] << ", " << obj[5] << " |\n"; + os << std::setw(3) << std::setprecision(16) << "| " << obj[6] << ", " << obj[7] << ", " << obj[8] << " |"; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/AxisAngle.hpp b/Source/EbsdLib/Orientation/AxisAngle.hpp new file mode 100644 index 00000000..0247fb1c --- /dev/null +++ b/Source/EbsdLib/Orientation/AxisAngle.hpp @@ -0,0 +1,255 @@ +// AxisAngle.h +#pragma once + +#include "EbsdLib/Orientation/Cubochoric.hpp" +#include "EbsdLib/Orientation/Homochoric.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +#include "EbsdLib/Orientation/Stereographic.hpp" + +#include +#include + +namespace ebsdlib +{ + +/** + * @brief This class represents an orientation as an Axis-Angle pair. The data is stored in a + * flat 4x1 vector where the first three elements are the axis and the last element is + * the rotation around that axis in radians. + * + * @tparam T Either double or float + */ +template +class AxisAngle : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = AxisAngle; + using value_type = T; + + AxisAngle() = default; + + AxisAngle(T x, T y, T z, T w) + : OrientationBase({x, y, z, w}) + { + } + + explicit AxisAngle(const std::array& d) + : OrientationBase(d) + { + } + + explicit AxisAngle(const T* mat) + : OrientationBase({mat[0], mat[1], mat[2], mat[3]}) + { + } + + const T& x() const + { + return (*this)[0]; + } + T& x() + { + return (*this)[0]; + } + + const T& y() const + { + return (*this)[1]; + } + T& y() + { + return (*this)[1]; + } + + const T& z() const + { + return (*this)[2]; + } + T& z() + { + return (*this)[2]; + } + + const T& w() const + { + return (*this)[3]; + } + T& w() + { + return (*this)[3]; + } + + ResultType isValid() const + { + ResultType res; + res.result = 1; + if((w() < 0.0) || (w() > constants::k_PiD)) + { + res.msg = "Axis Angle Error: angle must be in range [0,pi]"; + res.result = -1; + return res; + } + T eps = std::numeric_limits::epsilon(); + + T r = std::sqrt(x() * x() + y() * y() + z() * z()); + T absv = static_cast(fabs(r - 1.0)); + + if(absv > eps) + { + std::stringstream oss; + oss << std::setprecision(16) << "Axis Angle Error: axis-angle axis vector must have unit norm. " << r << " Difference is: " << absv << " eps: " << eps; + res.msg = oss.str(); + res.result = -2; + } + return res; + } + + Euler toEuler() const + { + return toOrientationMatrix().toEuler(); + } + + OrientationMatrix toOrientationMatrix() const + { + using OutputType = OrientationMatrix; + + OutputType res; + value_type q = 0.0L; + value_type c = 0.0L; + value_type s = 0.0L; + value_type omc = 0.0L; + + c = cos((*this)[3]); + s = sin((*this)[3]); + + omc = static_cast(1.0 - c); + + res[0] = x() * x() * omc + c; + res[4] = y() * y() * omc + c; + res[8] = z() * z() * omc + c; + int _01 = 1; + int _10 = 3; + int _12 = 5; + int _21 = 7; + int _02 = 2; + int _20 = 6; + // Check to see if we need to transpose + if(ebsdlib::orientations::epsijk == 1.0L) + { + _01 = 3; + _10 = 1; + _12 = 7; + _21 = 5; + _02 = 6; + _20 = 2; + } + + q = omc * x() * (*this)[1]; + res[_01] = q + s * (*this)[2]; + res[_10] = q - s * (*this)[2]; + q = omc * y() * (*this)[2]; + res[_12] = q + s * (*this)[0]; + res[_21] = q - s * (*this)[0]; + q = omc * z() * (*this)[0]; + res[_02] = q - s * (*this)[1]; + res[_20] = q + s * (*this)[1]; + + return res; + } + + AxisAngle toAxisAngle() const + { + return *this; + } + + Rodrigues toRodrigues() const + { + using OutputType = Rodrigues; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + + OutputValueType threshold = 1.0E-7f; + if(math::closeEnough((*this)[3], static_cast(0.0L), threshold)) + { + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; + return res; + } + res[0] = (*this)[0]; + res[1] = (*this)[1]; + res[2] = (*this)[2]; + if(fabs((*this)[3] - constants::k_PiD) < threshold) + { + res[3] = std::numeric_limits::infinity(); + } + else + { + res[3] = static_cast(tan((*this)[3] * 0.5)); + } + return res; + } + + Quaternion toQuaternion() const + { + using OutputType = Quaternion; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + + if((*this)[3] == 0.0) + { + res.w() = 1.0; + res.x() = 0.0; + res.y() = 0.0; + res.z() = 0.0; + } + else + { + typename OutputType::value_type c = static_cast(cos((*this)[3] * 0.5)); + typename OutputType::value_type s = static_cast(sin((*this)[3] * 0.5)); + res.w() = c; + res.x() = x() * s; + res.y() = y() * s; + res.z() = z() * s; + } + return res; + } + + Homochoric toHomochoric() const + { + using OutputType = Homochoric; + + OutputType res; + typename OutputType::value_type f = static_cast(0.75 * ((*this)[3] - sin((*this)[3]))); + f = static_cast(pow(f, (1.0 / 3.0))); + res[0] = x() * f; + res[1] = y() * f; + res[2] = z() * f; + return res; + } + + Cubochoric toCubochoric() const + { + return toHomochoric().toCubochoric(); + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using AxisAngleDType = AxisAngle; +using AxisAngleFType = AxisAngle; + +template +std::ostream& operator<<(std::ostream& os, const AxisAngle& obj) +{ + os << std::setw(3) << std::setprecision(16) << "AX: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/Cubochoric.hpp b/Source/EbsdLib/Orientation/Cubochoric.hpp new file mode 100644 index 00000000..40d6ab72 --- /dev/null +++ b/Source/EbsdLib/Orientation/Cubochoric.hpp @@ -0,0 +1,154 @@ +// Cubochoric.h +#pragma once + +#include "EbsdLib/Orientation/Homochoric.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Utilities/ModifiedLambertProjection3D.hpp" + +#include + +namespace ebsdlib +{ +/** + * @brief This class represents an orientation as a Cubochoric representation. + * + * @tparam T Either double or float + */ +template +class Cubochoric : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = Cubochoric; + using value_type = T; + + Cubochoric() = default; + + Cubochoric(T x, T y, T z) + : OrientationBase({x, y, z}) + { + } + + explicit Cubochoric(const std::array& d) + : OrientationBase(d) + { + } + + explicit Cubochoric(const T* cu) + : OrientationBase({cu[0], cu[1], cu[2]}) + { + } + + T& x() + { + return (*this)[0]; + } + const T& x() const + { + return (*this)[0]; + } + + T& y() + { + return (*this)[1]; + } + const T& y() const + { + return (*this)[1]; + } + + T& z() + { + return (*this)[2]; + } + const T& z() const + { + return (*this)[2]; + } + + ResultType isValid() const + { + using ValueType = value_type; + ResultType res; + res.result = 1; + + ValueType maxValue = static_cast(LPs::ap / 2.0); + bool maxValueHit = false; + + if(std::abs(x()) > maxValue) + { + maxValueHit = true; + } + if(std::abs(y()) > maxValue) + { + maxValueHit = true; + } + if(std::abs(z()) > maxValue) + { + maxValueHit = true; + } + + if(maxValueHit) + { + res.msg = "Cubochoric Error: cubochoric vector outside cube"; + res.result = -1; + } + return res; + } + + Euler toEuler() const + { + return toHomochoric().toEuler(); + } + + OrientationMatrix toOrientationMatrix() const + { + return toHomochoric().toOrientationMatrix(); + } + + AxisAngle toAxisAngle() const + { + return toHomochoric().toAxisAngle(); + } + + Rodrigues toRodrigues() const + { + return toHomochoric().toRodrigues(); + } + + Quaternion toQuaternion() const + { + return toHomochoric().toQuaternion(); + } + + Homochoric toHomochoric() const + { + int ierr = 0; + std::vector temp = {x(), y(), z()}; + std::vector res = ModifiedLambertProjection3D, typename SelfType::value_type>::LambertCubeToBall(temp, ierr); + return {res[0], res[1], res[2]}; + } + + Cubochoric toCubochoric() const + { + return *this; + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using CubochoricDType = Cubochoric; +using CubochoricFType = Cubochoric; + +template +std::ostream& operator<<(std::ostream& os, const Cubochoric& obj) +{ + os << std::setw(3) << std::setprecision(16) << "CU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/Euler.hpp b/Source/EbsdLib/Orientation/Euler.hpp new file mode 100644 index 00000000..4d6641f6 --- /dev/null +++ b/Source/EbsdLib/Orientation/Euler.hpp @@ -0,0 +1,284 @@ +// Euler.h +#pragma once + +#include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" + +#include + +namespace ebsdlib +{ +/** + * @brief This class represents an orientation as a Bunge Euler representation (ZXZ). + * + * @tparam T Either double or float + */ +template +class Euler : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = Euler; + using value_type = T; + + Euler() = default; + + Euler(T phi1, T PHI, T phi2) + : OrientationBase({phi1, PHI, phi2}) + { + } + + explicit Euler(const std::array& d) + : OrientationBase(d) + { + } + + explicit Euler(const T* eu) + : OrientationBase({eu[0], eu[1], eu[2]}) + { + } + + ResultType isValid() const + { + ResultType res; + res.result = 1; + + if((e0() < 0.0) || (e0() > (constants::k_2PiD))) + { + res.msg = "Euler Error: phi1 Euler angle outside of valid range [0,2pi]"; + res.result = -1; + } + if((e1() < 0.0) || (e1() > constants::k_PiD)) + { + res.msg = "Euler Error: Phi Euler angle outside of valid range [0,pi]"; + res.result = -2; + } + if((e2() < 0.0) || (e2() > (constants::k_2PiD))) + { + res.msg = "Euler Error: phi2 Euler angle outside of valid range [0,2pi]"; + res.result = -3; + } + return res; + } + + T& e0() + { + return (*this)[0]; + } + T& e1() + { + return (*this)[1]; + } + T& e2() + { + return (*this)[2]; + } + + const T& e0() const + { + return (*this)[0]; + } + const T& e1() const + { + return (*this)[1]; + } + const T& e2() const + { + return (*this)[2]; + } + + SelfType toEuler() const + { + return *this; + } + + OrientationMatrix toOrientationMatrix() const + { + using OutputType = OrientationMatrix; + using ValueType = typename OutputType::value_type; + + OutputType om; + ValueType eps = 1.0E-7f; + + ValueType c1 = cos(e0()); + ValueType c = cos(e1()); + ValueType c2 = cos(e2()); + ValueType s1 = sin(e0()); + ValueType s = sin(e1()); + ValueType s2 = sin(e2()); + om[0] = c1 * c2 - s1 * s2 * c; + om[1] = s1 * c2 + c1 * s2 * c; + om[2] = s2 * s; + om[3] = -c1 * s2 - s1 * c2 * c; + om[4] = -s1 * s2 + c1 * c2 * c; + om[5] = c2 * s; + om[6] = s1 * s; + om[7] = -c1 * s; + om[8] = c; + for(size_t i = 0; i < 9; i++) + { + if(fabs(om[i]) < eps) + { + om[i] = 0.0; + } + } + return om; + } + + AxisAngle toAxisAngle() const + { + using OutputType = AxisAngle; + using OutputValueType = value_type; + + OutputType res; + + auto thr = static_cast(1.0E-6); + auto alpha = static_cast(0.0); + auto t = static_cast(tan(e1() * 0.5)); + auto sig = static_cast(0.5 * (e0() + e2())); + auto del = static_cast(0.5 * (e0() - e2())); + auto tau = static_cast(std::sqrt(t * t + sin(sig) * sin(sig))); + if(math::closeEnough(sig, static_cast(constants::k_PiOver2D), static_cast(1.0E-6L))) + { + alpha = static_cast(constants::k_PiD); + } + else + { + alpha = static_cast(2.0 * atan(tau / cos(sig))); //! return a default identity axis-angle pair + } + + if(fabs(alpha) < thr) + { + res[0] = 0.0; + res[1] = 0.0; + res[2] = 1.0; + res[3] = 0.0; + } + else + { + //! passive axis-angle pair so a minus sign in front + res[0] = static_cast(-ebsdlib::orientations::epsijkd * t * cos(del) / tau); + res[1] = static_cast(-ebsdlib::orientations::epsijkd * t * sin(del) / tau); + res[2] = static_cast(-ebsdlib::orientations::epsijkd * sin(sig) / tau); + res[3] = alpha; + + if(alpha < 0.0) + { + res[0] = -res[0]; + res[1] = -res[1]; + res[2] = -res[2]; + res[3] = -res[3]; + } + } + + return res; + } + + Rodrigues toRodrigues() const + { + using OutputType = Rodrigues; + using OutputValueType = typename OutputType::value_type; + + typename OutputType::value_type thr = 1.0E-6f; + + AxisAngle res = toAxisAngle(); + using OutputValueType = typename OutputType::value_type; + typename OutputType::value_type t = res[3]; + + if(std::fabs(t - constants::k_PiD) < thr) + { + res[3] = std::numeric_limits::infinity(); + return {res[0], res[1], res[2], res[3]}; + } + + if(math::closeEnough(t, static_cast(0.0), thr)) // Are we close to Zero + { + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; + } + else + { + res[3] = static_cast(tan(t * 0.5)); + } + + return {res[0], res[1], res[2], res[3]}; + } + + Quaternion toQuaternion() const + { + using OutputType = Quaternion; + using OutputValueType = value_type; + + std::array ee = {0.0f, 0.0f, 0.0f}; + OutputValueType cPhi = 0.0f; + OutputValueType cp = 0.0f; + OutputValueType cm = 0.0f; + OutputValueType sPhi = 0.0f; + OutputValueType sp = 0.0f; + OutputValueType sm = 0.0f; + + ee[0] = static_cast(0.5 * e0()); + ee[1] = static_cast(0.5 * e1()); + ee[2] = static_cast(0.5 * e2()); + + cPhi = cos(ee[1]); + sPhi = sin(ee[1]); + cm = cos(ee[0] - ee[2]); + sm = sin(ee[0] - ee[2]); + cp = cos(ee[0] + ee[2]); + sp = sin(ee[0] + ee[2]); + + Quaternion res; + res.w() = cPhi * cp; + res.x() = -ebsdlib::orientations::epsijk * sPhi * cm; + res.y() = -ebsdlib::orientations::epsijk * sPhi * sm; + res.z() = -ebsdlib::orientations::epsijk * cPhi * sp; + + if(res.w() < 0.0) + { + res = res.negate(); + } + + if(res.x() == -0.0) + { + res.x() = -res.x(); + } + if(res.y() == -0.0) + { + res.y() = -res.y(); + } + if(res.z() == -0.0) + { + res.z() = -res.z(); + } + + return res; + } + + Homochoric toHomochoric() const + { + return toAxisAngle().toHomochoric(); + } + + Cubochoric toCubochoric() const + { + return toHomochoric().toCubochoric(); + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using EulerDType = Euler; +using EulerFType = Euler; + +template +std::ostream& operator<<(std::ostream& os, const Euler& obj) +{ + os << std::setw(3) << std::setprecision(16) << "EU: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/Homochoric.hpp b/Source/EbsdLib/Orientation/Homochoric.hpp new file mode 100644 index 00000000..f3a87146 --- /dev/null +++ b/Source/EbsdLib/Orientation/Homochoric.hpp @@ -0,0 +1,185 @@ +// Homochoric.h +#pragma once +#include "OrientationFwd.hpp" + +#include "EbsdLib/Math/ArrayHelpers.hpp" +#include "EbsdLib/Orientation/AxisAngle.hpp" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/OrientationMatrix.hpp" +#include "EbsdLib/Utilities/ModifiedLambertProjection3D.hpp" + +#include + +namespace ebsdlib +{ +/** + * @brief This class represents an orientation as a Homochoric representation. + * + * @tparam T Either double or float + */ +template +class Homochoric : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = Homochoric; + using value_type = T; + + Homochoric() = default; + + Homochoric(T x, T y, T z) + : OrientationBase({x, y, z}) + { + } + + explicit Homochoric(const std::array& d) + : OrientationBase(d) + { + } + + explicit Homochoric(const T* ho) + : OrientationBase({ho[0], ho[1], ho[2]}) + { + } + + T& x() + { + return (*this)[0]; + } + const T& x() const + { + return (*this)[0]; + } + + T& y() + { + return (*this)[1]; + } + const T& y() const + { + return (*this)[1]; + } + + T& z() + { + return (*this)[2]; + } + const T& z() const + { + return (*this)[2]; + } + + ResultType isValid() const + { + ResultType res; + res.result = 1; + + value_type r = std::sqrt(x() * x() + y() * y() + z() * z()); + + if(r > static_cast(LPs::R1)) + { + res.msg = "Homochoric Error: homochoric vector outside homochoric ball"; + res.result = -1; + } + return res; + } + + Euler toEuler() const + { + return toAxisAngle().toEuler(); + } + + OrientationMatrix toOrientationMatrix() const + { + return toAxisAngle().toOrientationMatrix(); + } + + AxisAngle toAxisAngle() const + { + using OutputType = AxisAngle; + using OutputValueType = typename OutputType::value_type; + using SizeType = typename OutputType::size_type; + using OMHelperType = ArrayHelpers; + + OutputType res; + + value_type thr = 1.0E-8f; + + typename OutputType::value_type hmag = ArrayHelpers::sumofSquares((*this)); + if(hmag == 0.0) + { + res[0] = 0.0; + res[1] = 0.0; + res[2] = 1.0; + res[3] = 0.0; + } + else + { + OutputValueType hm = hmag; + SelfType hn(*this); + OutputValueType sqrRtHMag = static_cast(1.0 / sqrt(hmag)); + ArrayHelpers::scalarMultiply(hn, sqrRtHMag); // In place scalar multiply + OutputValueType s = static_cast(LambertParametersType::tfit[0] + LambertParametersType::tfit[1] * hmag); + for(int i = 2; i < 16; i++) + { + hm = hm * hmag; + s = static_cast(s + LPs::tfit[i] * hm); + } + s = static_cast(2.0 * acos(s)); + res[0] = hn[0]; + res[1] = hn[1]; + res[2] = hn[2]; + OutputValueType delta = static_cast(std::fabs(s - constants::k_PiD)); + if(delta < thr) + { + res[3] = static_cast(constants::k_PiD); + } + else + { + res[3] = s; + } + } + return res; + } + + Rodrigues toRodrigues() const + { + return toAxisAngle().toRodrigues(); + } + + Quaternion toQuaternion() const + { + return toAxisAngle().toQuaternion(); + } + + Homochoric toHomochoric() const + { + return *this; + } + + Cubochoric toCubochoric() const + { + int ierr = -1; + std::vector temp = {x(), y(), z()}; + std::vector res = ModifiedLambertProjection3D, typename SelfType::value_type>::LambertBallToCube(temp, ierr); + return {res[0], res[1], res[2]}; + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using HomochoricDType = Homochoric; +using HomochoricFType = Homochoric; + +template +std::ostream& operator<<(std::ostream& os, const Homochoric& obj) +{ + os << std::setw(3) << std::setprecision(16) << "HO: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/OrientationFwd.hpp b/Source/EbsdLib/Orientation/OrientationFwd.hpp new file mode 100644 index 00000000..78bd9840 --- /dev/null +++ b/Source/EbsdLib/Orientation/OrientationFwd.hpp @@ -0,0 +1,140 @@ +// OrientationFwd.h +#pragma once + +#include +#include +#include +/** + * The Orientation codes are written in such a way that the value of -1 indicates + * an Active Rotation and +1 indicates a passive rotation. + * + * DO NOT UNDER ANY CIRCUMSTANCE CHANGE THESE VARIABLES. THERE WILL BE BAD + * CONSEQUENCES IF THESE ARE CHANGED. EVERY PIECE OF CODE THAT RELIES ON THESE + * FUNCTIONS WILL BREAK. IN ADDITION, THE QUATERNION ARITHMETIC WILL NO LONGER + * BE CONSISTENT WITH ROTATION ARITHMETIC. + * + * YOU HAVE BEEN WARNED. + * + * Adam Morawiec's book uses Passive rotations. + **/ +#ifndef DREAM3D_PASSIVE_ROTATION +#define DREAM3D_PASSIVE_ROTATION 1 +// #define DREAM3D_ACTIVE_ROTATION -1.0 +#endif + +namespace ebsdlib +{ +namespace orientations +{ +#if DREAM3D_PASSIVE_ROTATION +constexpr float epsijk = 1.0f; +constexpr double epsijkd = 1.0; +#elif DREAM3D_ACTIVE_ROTATION +static const float epsijk = -1.0f; +static const double epsijkd = -1.0; +#endif + +enum class Type : uint8_t +{ + Euler = 0, + OrientationMatrix, + Quaternion, + AxisAngle, + Rodrigues, + Homochoric, + Cubochoric, + Stereographic, + Unknown +}; +} // namespace orientations + +struct ResultType +{ + int result; + std::string msg; +}; + +template +class Euler; + +template +class OrientationMatrix; + +template +class AxisAngle; + +template +class Rodrigues; + +template +class Quaternion; + +template +class Homochoric; + +template +class Cubochoric; + +template +class Stereographic; + +template +class OrientationBase +{ +public: + using value_type = T; + static constexpr std::size_t num_elements = N; + using size_type = size_t; + using reference = T&; + + OrientationBase() = default; + + explicit OrientationBase(const std::array& orientation) + : m_Array(orientation) + { + } + + reference operator[](size_type index) + { + return m_Array[index]; + } + + const T& operator[](size_type index) const + { + return m_Array[index]; + } + + size_t size() const + { + return num_elements; + } + + const T* data() const + { + return m_Array.data(); + } + + std::array underlying() const + { + return m_Array; + } + + bool isWithinTolerance(const OrientationBase& rhs, T tolerance) const + { + std::array result; + std::transform(m_Array.begin(), m_Array.end(), rhs.m_Array.begin(), result.begin(), std::minus()); + + auto position = std::find_if(result.begin(), result.end(), [tolerance](T num) { return std::abs(num) > tolerance; }); + return position == result.end(); + } + + void copyTo(T* destination) const + { + std::copy(m_Array.begin(), m_Array.end(), destination); + } + +protected: + std::array m_Array; +}; + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/OrientationMatrix.hpp b/Source/EbsdLib/Orientation/OrientationMatrix.hpp new file mode 100644 index 00000000..1a63b873 --- /dev/null +++ b/Source/EbsdLib/Orientation/OrientationMatrix.hpp @@ -0,0 +1,405 @@ + + +#pragma once +#include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Math/Matrix3X3.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" + +#include + +#include + +namespace ebsdlib +{ +/** + * @brief This class represents an orientation as a 3x3 Matrix typically referred to as + * an orientation matrix. The data is stored as Row-Major format: + * + * @code + * | 0 1 2 | + * | 3 4 5 | + * | 6 7 8 | + * @endcode + * + * @tparam T Either double or float + */ +template +class OrientationMatrix : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = OrientationMatrix; + using value_type = T; + + OrientationMatrix() = default; + + /** + * @brief Construct an Orientation Matrix from a 3x3 matrix that is row major, i.e., the mat is laid out in memory each row is contiguous + * after the previous row. + * @param m00 + * @param m01 + * @param m02 + * @param m10 + * @param m11 + * @param m12 + * @param m20 + * @param m21 + * @param m22 + */ + OrientationMatrix(T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22) + : OrientationBase({m00, m01, m02, m10, m11, m12, m20, m21, m22}) + { + } + + /** + * @brief Construct an Orientation Matrix from a 3x3 matrix that is row major, i.e., the mat is laid out in memory each row is contiguous + * after the previous row. + * + * @note | r0c0, r0c1, r0c2, r1c0 .... | + * @param mat + */ + explicit OrientationMatrix(const Matrix3X3& mat) + : OrientationBase({mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], mat[8]}) + { + } + + /** + * @brief Construct an Orientation Matrix from a 3x3 matrix that is row major, i.e., the mat is laid out in memory each row is contiguous + * after the previous row. + * + * @note | r0c0, r0c1, r0c2, r1c0 .... | + * @param mat + */ + explicit OrientationMatrix(const std::array& d) + : OrientationBase(d) + { + } + + /** + * @brief Construct an Orientation Matrix from a 3x3 matrix that is row major, i.e., the mat is laid out in memory each row is contiguous + * after the previous row. + * + * @note | r0c0, r0c1, r0c2, r1c0 .... | + * @param mat + */ + explicit OrientationMatrix(const T* mat) + : OrientationBase({mat[0], mat[1], mat[2], mat[3], mat[4], mat[5], mat[6], mat[7], mat[8]}) + { + } + + /** + * @brief Returns the matrix as an EbsdLib::Matrix3x3 which is suitable for matrix calculations. + * @return + */ + Matrix3X3 toGMatrix() const + { + return Matrix3X3{(*this)[0], (*this)[1], (*this)[2], (*this)[3], (*this)[4], (*this)[5], (*this)[6], (*this)[7], (*this)[8]}; + } + + /** + * @brief Returns the matrix as an Eigen 3x3 Matrix that is RowMajor. + * @return + */ + Eigen::Matrix toEigenGMatrix() const + { + Eigen::Matrix g1; + g1(0, 0) = (*this)[0]; + g1(0, 1) = (*this)[1]; + g1(0, 2) = (*this)[2]; + g1(1, 0) = (*this)[3]; + g1(1, 1) = (*this)[4]; + g1(1, 2) = (*this)[5]; + g1(2, 0) = (*this)[6]; + g1(2, 1) = (*this)[7]; + g1(2, 2) = (*this)[8]; + return g1; + } + + /** + * @brief Matrix multiplication of a 3x1 matrix + * @param vec + * @return + */ + Eigen::Matrix operator*(const Eigen::Matrix& vec) const + { + return toEigenGMatrix() * vec; + } + + /** + * @brief Matrix multiplication of a 3x3 matrix + * @param rhs + * @return + */ + Eigen::Matrix operator*(const Eigen::Matrix& rhs) const + { + return toEigenGMatrix() * rhs; + } + + /** + * @brief Matrix multiplication of a 3x3 matrix + * @param rhs + * @return + */ + SelfType operator*(const SelfType& rhs) const + { + Matrix3X3 a(this->data()); + Matrix3X3 b(rhs.data()); + SelfType res(a * b); + return res; + } + + /** + * @brief returns the orientation matrix transposed. This is useful to turn this into an active transformation matrix + * @return + */ + SelfType transpose() const + { + const SelfType& in = *this; + return {in[0], in[3], in[6], in[1], in[4], in[7], in[2], in[5], in[8]}; + } + + /** + * @brief Checks if this Orientation Matrix is crystallographically valid + * @return Result type Struct with an error code and error message + */ + ResultType isValid() const + { + using ValueType = T; + ResultType res; + res.result = 1; + auto threshold = static_cast(1.0E-5L); + using RotationMatrixType = Eigen::Matrix; + using RotationMatrixMapType = Eigen::Map; + RotationMatrixMapType omE(const_cast(this->data())); + + ValueType det = omE.determinant(); + + std::stringstream ss; + if(det < 0.0) + { + ss << "OrientationMatrix Error: Determinant of rotation matrix must be positive: " << det; + res.msg = ss.str(); + res.result = -1; + return res; + } + + ValueType r = fabs(det - static_cast(1.0L)); + if(!math::closeEnough(r, static_cast(0.0L), threshold)) + { + ss << "OrientationMatrix Error: Determinant (" << det << ") of rotation matrix must be unity (1.0)"; + res.msg = ss.str(); + res.result = -2; + return res; + } + + RotationMatrixType abv = (omE * omE.transpose()).cwiseAbs(); + + RotationMatrixType identity; + identity.setIdentity(); + + identity = identity - abv; + identity = identity.cwiseAbs(); + + for(int c = 0; c < 3; c++) + { + for(int rIndex = 0; rIndex < 3; rIndex++) + { + if(identity(rIndex, c) > threshold) + { + std::stringstream ssError; + ssError << "OrientationMatrix Error: OrientationMatrix times transpose must be identity matrix: ("; + ssError << rIndex << ", " << c << ") = " << abv(rIndex, c); + res.msg = ssError.str(); + res.result = -3; + } + } + } + + return res; + } + + Euler toEuler() const + { + using OutputType = Euler; + using OutputValueType = typename OutputType::value_type; + OutputType res; + typename OutputType::value_type zeta = 0.0; + bool close = math::closeEnough(std::fabs((*this)[8]), static_cast(1.0), static_cast(1.0E-6)); + if(!close) + { + res[1] = acos((*this)[8]); + zeta = static_cast(1.0 / sqrt(1.0 - (*this)[8] * (*this)[8])); + res[0] = atan2((*this)[6] * zeta, -(*this)[7] * zeta); + res[2] = atan2((*this)[2] * zeta, (*this)[5] * zeta); + } + else + { + close = math::closeEnough((*this)[8], static_cast(1.0), static_cast(1.0E-6)); + if(close) + { + res[0] = atan2((*this)[1], (*this)[0]); + res[1] = 0.0; + res[2] = 0.0; + } + else + { + res[0] = static_cast(-atan2(-(*this)[1], (*this)[0])); + res[1] = static_cast(constants::k_PiD); + res[2] = 0.0; + } + } + + if(res[0] < 0.0) + { + res[0] = static_cast(fmod(res[0] + 100.0 * constants::k_PiD, constants::k_2PiD)); + } + if(res[1] < 0.0) + { + res[1] = static_cast(fmod(res[1] + 100.0 * constants::k_PiD, constants::k_PiD)); + } + if(res[2] < 0.0) + { + res[2] = static_cast(fmod(res[2] + 100.0 * constants::k_PiD, constants::k_2PiD)); + } + return res; + } + + OrientationMatrix toOrientationMatrix() const + { + return *this; + } + + AxisAngle toAxisAngle() const + { + return toQuaternion().toAxisAngle(); + } + + Rodrigues toRodrigues() const + { + return toEuler().toRodrigues(); + } + + Quaternion toQuaternion() const + { + using OutputType = Quaternion; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + + auto thr = static_cast(1.0E-10L); + if(sizeof(value_type) == 4) + { + thr = static_cast(1.0E-6L); + } + OutputValueType s = 0.0; + OutputValueType s1 = 0.0; + OutputValueType s2 = 0.0; + OutputValueType s3 = 0.0; + + s = static_cast((*this)[0] + (*this)[4] + (*this)[8] + 1.0); + if(math::closeEnough(std::fabs(s), static_cast(0.0), thr)) // Are we close to Zero + { + s = 0.0; + } + s = sqrt(s); + s1 = static_cast((*this)[0] - (*this)[4] - (*this)[8] + 1.0); + if(math::closeEnough(std::fabs(s1), static_cast(0.0), thr)) // Are we close to Zero + { + s1 = 0.0; + } + s1 = sqrt(s1); + s2 = static_cast(-(*this)[0] + (*this)[4] - (*this)[8] + 1.0); + if(math::closeEnough(std::fabs(s2), static_cast(0.0), thr)) // Are we close to Zero + { + s2 = 0.0; + } + s2 = sqrt(s2); + s3 = static_cast(-(*this)[0] - (*this)[4] + (*this)[8] + 1.0); + if(math::closeEnough(std::fabs(s3), static_cast(0.0), thr)) // Are we close to Zero + { + s3 = 0.0; + } + s3 = sqrt(s3); + res.w() = static_cast(s * 0.5); + res.x() = static_cast(s1 * 0.5); + res.y() = static_cast(s2 * 0.5); + res.z() = static_cast(s3 * 0.5); + // printf("res[z]: % 3.16f \n", res[z]); + + // verify the signs (q0 always positive) + if((*this)[7] < (*this)[5]) + { + res.x() = -ebsdlib::orientations::epsijk * res.x(); + } + if((*this)[2] < (*this)[6]) + { + res.y() = -ebsdlib::orientations::epsijk * res.y(); + } + if((*this)[3] < (*this)[1]) + { + res.z() = -ebsdlib::orientations::epsijk * res.z(); + } + // printf("res[z]: % 3.16f \n", res[z]); + + s = res.length(); + + if(s != 0.0) + { + res = res.scalarDivide(s); + } + + /* we need to do a quick test here to make sure that the + ! sign of the vector part is the same as that of the + ! corresponding vector in the axis-angle representation; + ! these two can end up being different, presumably due to rounding + ! issues, but this needs to be further analyzed... + ! This adds a little bit of computation overhead but for now it + ! is the easiest way to make sure the signs are correct. + */ + AxisAngle oax = toEuler().toAxisAngle(); + + if(oax[0] * res.x() < 0.0) + { + res.x() = -res.x(); + } + if(oax[1] * res.y() < 0.0) + { + res.y() = -res.y(); + } + if(oax[2] * res.z() < 0.0) + { + res.z() = -res.z(); + } + return res; + } + + Homochoric toHomochoric() const + { + return toAxisAngle().toHomochoric(); + } + + Cubochoric toCubochoric() const + { + return toHomochoric().toCubochoric(); + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using OrientationMatrixDType = OrientationMatrix; +using OrientationMatrixFType = OrientationMatrix; + +template +std::ostream& operator<<(std::ostream& os, const OrientationMatrix& obj) +{ + os << std::setw(3) << std::setprecision(16) << "OM: / " << obj[0] << ", " << obj[1] << ", " << obj[2] << " \\\n"; + os << std::setw(3) << std::setprecision(16) << "OM: | " << obj[3] << ", " << obj[4] << ", " << obj[5] << " |\n"; + os << std::setw(3) << std::setprecision(16) << "OM: \\ " << obj[6] << ", " << obj[7] << ", " << obj[8] << " /"; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/Quaternion.hpp b/Source/EbsdLib/Orientation/Quaternion.hpp new file mode 100644 index 00000000..f54993ca --- /dev/null +++ b/Source/EbsdLib/Orientation/Quaternion.hpp @@ -0,0 +1,815 @@ +// Quaternion.h +#pragma once + +#include "EbsdLib/Math/ArrayHelpers.hpp" +#include "EbsdLib/Math/Matrix3X1.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" + +#include + +#include + +namespace ebsdlib +{ +/** + * @brief This class represents an orientation as a Quaternion. The order of the quaternion + * is stored as "VECTOR-SCALAR" + * + * @param T Either double or float + */ +template +class Quaternion : public OrientationBase +{ + +public: + static_assert(std::is_floating_point_v, "T must be a floating point type"); // disallow integers + static_assert(std::numeric_limits::has_infinity, "T must have infinity"); // must have ieee infinity + + using SuperType = OrientationBase; + using SelfType = Quaternion; + using size_type = size_t; + using value_type = T; + + using EnumType = uint32_t; + + Quaternion() = default; + + Quaternion(const Quaternion&) = default; // Copy Constructor Not Implemented + Quaternion(Quaternion&&) = default; // Move Constructor Not Implemented + Quaternion& operator=(const Quaternion&) = default; // Copy Assignment Not Implemented + Quaternion& operator=(Quaternion&&) = default; // Move Assignment Not Implemented + + /** + * @brief Constructs a Quaternion Representation which will **ALWAYS** have its layout as Vector-Scalar + * @param x + * @param y + * @param z + * @param w + */ + Quaternion(T x, T y, T z, T w) + : OrientationBase({x, y, z, w}) + { + } + + /** + * @brief Constructs a Quaternion Representation which will **ALWAYS** have its layout as Vector-Scalar + * @param x + * @param y + * @param z + * @param w + */ + explicit Quaternion(const std::array& d) + : OrientationBase(d) + { + } + + /** + * @brief Constructs a Quaternion Representation which will **ALWAYS** have its layout as Vector-Scalar + * @param quat Pointer to a Quaternion in Vector-Scalar order + */ + explicit Quaternion(const T* quat) + : OrientationBase({quat[0], quat[1], quat[2], quat[3]}) + { + } + + /** + * @brief Constructs a Quaternion Representation which will **ALWAYS** have its layout as Vector-Scalar. The incoming 4x1 + * Eigen matrix should have its Quaternion laid out in vector-scalar order + * @param eigenQuat + */ + explicit Quaternion(const Eigen::Matrix& eigenQuat) + : OrientationBase({eigenQuat[0], eigenQuat[1], eigenQuat[2], eigenQuat[3]}) + { + } + + const T& x() const + { + return (*this)[0]; + } + T& x() + { + return (*this)[0]; + } + + const T& y() const + { + return (*this)[1]; + } + T& y() + { + return (*this)[1]; + } + + const T& z() const + { + return (*this)[2]; + } + T& z() + { + return (*this)[2]; + } + + const T& w() const + { + return (*this)[3]; + } + T& w() + { + return (*this)[3]; + } + + /** + * @brief Copies the quaternion into a given pointer + * @param target + * @param order + */ + void copyInto(T* target) const + { + target[0] = x(); + target[1] = y(); + target[2] = z(); + target[3] = w(); + } + + /** + * @brief Returns a Quat which is the identity Quaternion (<0,0,0>,1) + */ + static SelfType identity() + { + return {0.0, 0.0, 0.0, 1.0}; + } + + /** + * @brief ElementWiseAbs inline assigns the absolute value of each element to itself (in place) + */ + SelfType& elementWiseAbs() + { + x() = std::fabs(x()); + y() = std::fabs(y()); + z() = std::fabs(z()); + w() = std::fabs(w()); + return *this; + } + + /** + * @brief ScalarMultiply Multiplies each element in the Quat by the argument v (in place) + * @param v + */ + SelfType& scalarMultiply(T v) + { + x() *= v; + y() *= v; + z() *= v; + w() *= v; + return *this; + } + + /** + * @brief ScalarDivide Divides each element in the Quat by the argument v (in place) + * @param v + */ + SelfType& scalarDivide(T v) + { + x() /= v; + y() /= v; + z() /= v; + w() /= v; + return *this; + } + + /** + * @brief ScalarAdd Adds value to each element of the vector and scalar part of the Quat (in place) + * @param v Input Quat to add elements + */ + SelfType& scalarAdd(T v) + { + x() += v; + y() += v; + z() += v; + w() += v; + return *this; + } + + /** + * @brief ElementWiseAssign Assigns each element the Quat (in place) + * @param v Input Quat to add elements + */ + SelfType& elementWiseAssign(T v) + { + x() = v; + y() = v; + z() = v; + w() = v; + return *this; + } + + /** + * @brief Negate −q = (−a, −v) In Place operation (in place) + */ + SelfType& negate() + { + x() = -x(); + y() = -y(); + z() = -z(); + w() = -w(); + return *this; + } + + /** + * @brief Returns a new Quaternion that is the negative of the current quaternion + * @return + */ + SelfType operator-() const + { + return {-x(), -y(), -z(), -w()}; + } + + /** + * @brief Adds q1 + q2 = (w1+w2, v1+v2) and returns a new Quaternion + * @param rhs + * @return + */ + SelfType operator+(const SelfType& rhs) const + { + SelfType out; + out.x() = rhs.x() + x(); + out.y() = rhs.y() + y(); + out.z() = rhs.z() + z(); + out.w() = rhs.w() + w(); + return out; + } + + /** + * @brief Add q1 - q2 = (w1-w2, v1-v2) and returns a new Quaternion + * @param rhs + * @return out + */ + SelfType operator-(const SelfType& rhs) const + { + SelfType out; + out.x() = x() - rhs.x(); + out.y() = y() - rhs.y(); + out.z() = z() - rhs.z(); + out.w() = w() - rhs.w(); + return out; + } + + /** + * @brief Multiply current Quat by another Quat returning a third Quat according to Quaternion + * multiplication. Note that Quaternion multiplication is NOT communicative i.e., A * B != B * A + * @param rhs Input Quat + * @return + */ + SelfType operator*(const SelfType& rhs) const + { + SelfType out; + out.x() = rhs.x() * w() + rhs.w() * x() + rhs.z() * y() - rhs.y() * z(); + out.y() = rhs.y() * w() + rhs.w() * y() + rhs.x() * z() - rhs.z() * x(); + out.z() = rhs.z() * w() + rhs.w() * z() + rhs.y() * x() - rhs.x() * y(); + out.w() = rhs.w() * w() - rhs.x() * x() - rhs.y() * y() - rhs.z() * z(); + return out; + } + + /** + * @brief Add q1 + q2 = (w1+w2, v1+v2) (in place) + * @param rhs + * @return self + */ + SelfType& operator+=(const SelfType& rhs) + { + x() += rhs.x(); + y() += rhs.y(); + z() += rhs.z(); + w() += rhs.w(); + return *this; + } + + /** + * @brief Add q1 - q2 = (w1-w2, v1-v2) (in place) + * @param rhs + * @return self + */ + SelfType& operator-=(const SelfType& rhs) + { + x() -= rhs.x(); + y() -= rhs.y(); + z() -= rhs.z(); + w() -= rhs.w(); + return *this; + } + + /** + * @brief Multiply current Quat by another Quat (in place) + * multiplication. Note that Quat multiplication is NOT communicative i.e., A * B != B * A + * @param rhs Input Quat + * @return self + */ + SelfType& operator*=(const SelfType& rhs) + { + x() = rhs.x() * w() + rhs.w() * x() + rhs.z() * y() - rhs.y() * z(); + y() = rhs.y() * w() + rhs.w() * y() + rhs.x() * z() - rhs.z() * x(); + z() = rhs.z() * w() + rhs.w() * z() + rhs.y() * x() - rhs.x() * y(); + /* Verified */ + w() = rhs.w() * w() - rhs.x() * x() - rhs.y() * y() - rhs.z() * z(); + return *this; + } + + /** + * @brief Computes the dot product between the current Quat and an input Quat + * + * @note The value returned could possibly be just outside the theoretical range of -1 to 1 which if the + * result is then used in the `acos()` function could give unexpected results + * @param rhs Second Quat to use to compute the dot product + * @return scalar dot product + */ + T dotProduct(const SelfType& rhs) const + { + T dot = x() * rhs.x() + y() * rhs.y() + z() * rhs.z() + w() * rhs.w(); + return dot; + } + + /** + * @brief Conjugate Converts Quat q into its conjugate and returns a new Quaternion<> instance + * @return new Quat that is the conjugate of the current Quat + */ + SelfType conjugate() const + { + return {-x(), -y(), -z(), w()}; + } + + /** + * @brief Norm Computes and returns the "norm" of the Quat (x^2 + y^2 + z^2 + w^2) + * @return + */ + T norm() const + { + return x() * x() + y() * y() + z() * z() + w() * w(); + } + + /** + * @brief Length Computes are returns the "length" of the Quat which is the square root of the norm. SQRT (x^2 + y^2 + z^2 + w^2) + * @return + */ + T length() const + { + return std::sqrt(norm()); + } + + /** + * @brief Computes the inverse of the Quat + * @return + */ + SelfType inverse() const + { + double normSq = this->norm(); // Use your existing Norm() + if(normSq == 0.0) + { + throw std::runtime_error("Cannot invert a Quat with zero norm."); + } + SelfType conj = this->conjugate(); + return SelfType(conj.x() / normSq, conj.y() / normSq, conj.z() / normSq, conj.w() / normSq); + } + + /** + * @brief check if this is a unit Quat + * @param tolerance + * @return + */ + bool isUnit(double tolerance = 1e-6) const + { + return std::abs(this->norm() - 1.0) < tolerance; + } + + /** + * @brief Normalize: Converts the Quat into its normalized values (x/L, y/L, z/L, w/L) where "L" + * is the "length" of the Quat + * @return qr + */ + SelfType normalize() const + { + T len = length(); + return {x() / len, y() / len, z() / len, w() / len}; + } + + /** + * @brief GetMisorientationVector Converts the Quat into a misorientation vector in the reference frame of the Quat + * @return misoVec + */ + Matrix3X1 getMisorientationVector() const + { + T qw = std::clamp(w(), static_cast(-1.0), static_cast(1.0)); + T constVal = 0.0; + if(qw == 1.0 || qw == -1.0) + { + constVal = 0.0; + } + else + { + constVal = static_cast(2 * std::acos(qw) / (std::sqrt(1.0 - (qw * qw)))); + } + + return {x() * constVal, y() * constVal, z() * constVal}; + } + + /** + * @brief Rotates a 3d vector 'v' by the Quaternion + * @param v Input Vector as a pointer. + */ + Matrix3X1 multiplyByVector(const T* v) const + { + T qx2 = x() * x(); + T qy2 = y() * y(); + T qz2 = z() * z(); + T qw2 = w() * w(); + + T qxy = x() * y(); + T qyz = y() * z(); + T qzx = z() * x(); + + T qxw = x() * w(); + T qyw = y() * w(); + T qzw = z() * w(); + + Matrix3X1 out; + + out[0] = v[0] * (qx2 - qy2 - qz2 + qw2) + 2 * (v[1] * (qxy + qzw) + v[2] * (qzx - qyw)); + out[1] = v[1] * (qy2 - qx2 - qz2 + qw2) + 2 * (v[2] * (qyz + qxw) + v[0] * (qxy - qzw)); + out[2] = v[2] * (qz2 - qx2 - qy2 + qw2) + 2 * (v[0] * (qzx + qyw) + v[1] * (qyz - qxw)); + return out; + } + + /** + * @brief rotateVector ACTIVELY rotates input vector by this Quat. + * @param inputVector Input vector + * @param p argument: Passive = 1, Active = -1; Default is Passive + * @return Output Vector + */ + Matrix3X1 rotateVector(const Matrix3X1& inputVector, int32_t p = 1) const + { + Matrix3X1 rotatedVector = {0.0, 0.0, 0.0}; + T epsijk = static_cast(p); + + Matrix3X1 r = {epsijk * x(), epsijk * y(), epsijk * z()}; + Matrix3X1 temp = r.cross(inputVector); + + temp[0] += w() * inputVector[0]; + temp[1] += w() * inputVector[1]; + temp[2] += w() * inputVector[2]; + + Matrix3X1 temp2 = r.cross(temp); + + rotatedVector[0] = static_cast(2.0) * temp2[0] + inputVector[0]; + rotatedVector[1] = static_cast(2.0) * temp2[1] + inputVector[1]; + rotatedVector[2] = static_cast(2.0) * temp2[2] + inputVector[2]; + + return rotatedVector; + } + + /** + * @brief Returns the magnitude of the vector part of the quaternion. + * + * @return + */ + T magnitude() const + { + return std::sqrt(x() * x() + y() * y() + z() * z()); + } + + /** + * @brief Converts this Quaternion to a different primitive type. This can be useful + * if you need to convert from a Quaternion to Quaternion + * @tparam K + * @return + */ + template + Quaternion to() const + { + return Quaternion(static_cast(x()), static_cast(y()), static_cast(z()), static_cast(w())); + } + + /* ***************************************************************************** + * THESE ARE THE CRYSTALLOGRAPHIC ORIENTATION CONVERSION METHODS + * ****************************************************************************/ + /** + * @brief Ensures this Quat represents an orientation that is located in the northern hemisphere. + * + * NOTE: This is done IN PLACE!! + */ + void positiveOrientation() + { + if(w() < static_cast(0.0)) + { + x() = -x(); + y() = -y(); + z() = -z(); + w() = -w(); + } + } + + /** + * @brief Returns a new Quat that represents an orientation that is located in the northern hemisphere + * @return Copy of Quat + */ + SelfType getPositiveOrientation() const + { + if(w() < static_cast(0.0)) + { + return {-x(), -y(), -z(), -w()}; + } + return {x(), y(), z(), w()}; + } + + ResultType isValid() const + { + ResultType res; + res.result = 1; + + if(w() < 0.0) + { + res.msg = "Quaternion Error: quaternion must have positive scalar part"; + res.result = -1; + return res; + } + + value_type eps = std::numeric_limits::epsilon(); + value_type r = length(); + if(fabs(r - 1.0) > eps) + { + res.msg = "Quaternion Error: quaternion must have unit norm"; + res.result = -2; + } + return res; + } + + Euler toEuler() const + { + using OutputType = Euler; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + OutputValueType q12 = 0.0f; + OutputValueType q03 = 0.0f; + OutputValueType chi = 0.0f; + OutputValueType Phi = 0.0f; + OutputValueType phi1 = 0.0f; + OutputValueType phi2 = 0.0f; + + SelfType qq(*this); + + q03 = qq.w() * qq.w() + qq.z() * qq.z(); + q12 = qq.x() * qq.x() + qq.y() * qq.y(); + chi = sqrt(q03 * q12); + if(chi == 0.0) + { + if(q12 == 0.0) + { + if(ebsdlib::orientations::epsijk == 1.0) + { + Phi = 0.0; + phi2 = 0.0; // arbitrarily due to degeneracy + phi1 = static_cast(atan2(-2.0 * qq.w() * qq.z(), qq.w() * qq.w() - qq.z() * qq.z())); + } + else + { + Phi = 0.0; + phi2 = 0.0; // arbitrarily due to degeneracy + phi1 = static_cast(atan2(2.0 * qq.w() * qq.z(), qq.w() * qq.w() - qq.z() * qq.z())); + } + } + else + { + Phi = static_cast(ebsdlib::constants::k_PiD); + phi2 = 0.0; // arbitrarily due to degeneracy + phi1 = static_cast(atan2(2.0 * qq.x() * qq.y(), qq.x() * qq.x() - qq.y() * qq.y())); + } + } + else + { + if(ebsdlib::orientations::epsijk == 1.0) + { + Phi = static_cast(atan2(2.0 * chi, q03 - q12)); + chi = static_cast(1.0 / chi); + phi1 = atan2((-qq.w() * qq.y() + qq.x() * qq.z()) * chi, (-qq.w() * qq.x() - qq.y() * qq.z()) * chi); + phi2 = atan2((qq.w() * qq.y() + qq.x() * qq.z()) * chi, (-qq.w() * qq.x() + qq.y() * qq.z()) * chi); + } + else + { + Phi = static_cast(atan2(2.0 * chi, q03 - q12)); + chi = static_cast(1.0 / chi); + typename OutputType::value_type y1 = (qq.w() * qq.y() + qq.x() * qq.z()) * chi; + typename OutputType::value_type x1 = (qq.w() * qq.x() - qq.y() * qq.z()) * chi; + phi1 = atan2(y1, x1); + y1 = (-qq.w() * qq.y() + qq.x() * qq.z()) * chi; + x1 = (qq.w() * qq.x() + qq.y() * qq.z()) * chi; + phi2 = atan2(y1, x1); + } + } + + res[0] = phi1; + res[1] = Phi; + res[2] = phi2; + + if(res[0] < 0.0) + { + res[0] = static_cast(fmod(res[0] + 100.0 * ebsdlib::constants::k_PiD, ebsdlib::constants::k_2PiD)); + } + if(res[1] < 0.0) + { + res[1] = static_cast(fmod(res[1] + 100.0 * ebsdlib::constants::k_PiD, ebsdlib::constants::k_PiD)); + } + if(res[2] < 0.0) + { + res[2] = static_cast(fmod(res[2] + 100.0 * ebsdlib::constants::k_PiD, ebsdlib::constants::k_2PiD)); + } + + return res; + } + + OrientationMatrix toOrientationMatrix() const + { + using OutputType = OrientationMatrix; + using OutputValueType = typename OutputType::value_type; + + OutputValueType qq = w() * w() - (x() * x() + y() * y() + z() * z()); + + OutputType res; + res[0] = static_cast(qq + 2.0 * x() * x()); + res[4] = static_cast(qq + 2.0 * y() * y()); + res[8] = static_cast(qq + 2.0 * z() * z()); + res[1] = static_cast(2.0 * (x() * y() - w() * z())); + res[5] = static_cast(2.0 * (y() * z() - w() * x())); + res[6] = static_cast(2.0 * (z() * x() - w() * y())); + res[3] = static_cast(2.0 * (y() * x() + w() * z())); + res[7] = static_cast(2.0 * (z() * y() + w() * x())); + res[2] = static_cast(2.0 * (x() * z() + w() * y())); + if(ebsdlib::orientations::epsijkd == -1.0) + { + auto transpose = res.toGMatrix().transpose(); + res = OutputType(transpose); + } + return res; + } + + AxisAngle toAxisAngle() const + { + using OutputType = AxisAngle; + using OutputValueType = typename OutputType::value_type; + + OutputValueType epsijk = ebsdlib::orientations::epsijkd; + SelfType qo(*this); + + // make sure q[0] is >= 0.0 + typename OutputType::value_type sign = 1.0; + if(w() < 0.0) + { + sign = -1.0; + } + qo = qo.scalarMultiply(sign); + + OutputValueType omega = static_cast(2.0 * acos(qo.w())); + // If omega equals zero then return the rotation axis as [001] + OutputValueType eps = static_cast(1.0e-12L); + OutputType res; + if(omega < eps) + { + res[0] = 0.0; + res[1] = 0.0; + res[2] = static_cast(1.0 * epsijk); + res[3] = 0.0; + return res; + } + + if(qo.w() != 0.0) + { + OutputValueType mag = magnitude(); + if(mag == 0.0) + { + res[0] = 0.0; + res[1] = 0.0; + res[2] = static_cast(1.0 * epsijk); + res[3] = 0.0; + } + else + { + mag = static_cast(1.0 / mag); + res[0] = x() * mag; + res[1] = y() * mag; + res[2] = z() * mag; + res[3] = omega; + } + } + else + { + res[0] = x(); + res[1] = y(); + res[2] = z(); + res[3] = ebsdlib::constants::k_PiD; + } + + return res; + } + + Rodrigues toRodrigues() const + { + using OutputType = Rodrigues; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + + T thr = static_cast(1.0E-8L); + res[0] = x(); + res[1] = y(); + res[2] = z(); + res[3] = 0.0; + + if(w() < thr) + { + res[3] = std::numeric_limits::infinity(); + return res; + } + // ValueType s = ebsdlib::EbsdMatrixMath::Magnitude3x1(&(res[0])); + OutputValueType s = ArrayHelpers::sqrtSumOfSquares(res); + + if(s < thr) + { + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; + return res; + } + + res[0] = res[0] / s; + res[1] = res[1] / s; + res[2] = res[2] / s; + res[3] = tan(acos(w())); + return res; + } + + Quaternion toQuaternion() const + { + return *this; + } + + Homochoric toHomochoric() const + { + using OutputType = Homochoric; + using OMHelperType = ArrayHelpers; + + OutputType res; + + value_type s; + value_type f; + + value_type omega = static_cast(2.0 * std::acos(w())); + if(omega == 0.0) + { + OMHelperType::splat(res, 0.0); + } + else + { + res[0] = x(); + res[1] = y(); + res[2] = z(); + s = static_cast(1.0 / std::sqrt(OMHelperType::sumofSquares(res))); + OMHelperType::scalarMultiply(res, s); + f = static_cast(0.75 * (omega - std::sin(omega))); + f = static_cast(std::pow(f, 1.0 / 3.0)); + OMHelperType::scalarMultiply(res, f); + } + return res; + } + + Cubochoric toCubochoric() const + { + return toHomochoric().toCubochoric(); + } + + Stereographic toStereographic() const + { + using OutputType = Stereographic; + + OutputType res = {x(), y(), z()}; + + if(w() != 0.0) + { + res[0] = x() / (1.0f + w()); + res[1] = y() / (1.0f + w()); + res[2] = z() / (1.0f + w()); + } + return res; + } +}; + +using QuaternionDType = Quaternion; +using QuaternionFType = Quaternion; + +using QuatD = Quaternion; +using QuatF = Quaternion; + +template +std::ostream& operator<<(std::ostream& os, const Quaternion& obj) +{ + os << std::setw(3) << std::setprecision(16) << "QU: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/Rodrigues.hpp b/Source/EbsdLib/Orientation/Rodrigues.hpp new file mode 100644 index 00000000..1cbea233 --- /dev/null +++ b/Source/EbsdLib/Orientation/Rodrigues.hpp @@ -0,0 +1,250 @@ +// Rodrigues.h +#pragma once + +#include "EbsdLib/Math/ArrayHelpers.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" + +#include + +namespace ebsdlib +{ + +/** + * @brief This class represents an orientation as a Rodrigues-Frank vector. + * + * @note EbsdLib uses a 4 component Rodrigues vector where the length is stored + * in the 4th component. + * + * @param T Either double or float + */ +template +class Rodrigues : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = Rodrigues; + using value_type = T; + + Rodrigues() = default; + + /** + * @brief Convenience constructor that will convert from a 3 element Rodrigues vector + * to the 4 element Rodrigues vector that EbsdLib uses. + * + * The conversion is: + * length = sprt(x^2 + y^2 + z^2) + * x = x / length + * y = y / length + * z = z / length + * l = length + * + * @param x + * @param y + * @param z + */ + Rodrigues(T x, T y, T z) + : OrientationBase({x, y, z, 0.0}) + { + const T length = sqrtf(x * x + y * y + z * z); + x() = x / length; + y() = y / length; + z() = z / length; + l() = length; + } + + /** + * @brief Constructs a Rodrigues orientation from the 4 components + * @param x + * @param y + * @param z + * @param l The lenght of the Rodrigues vector + */ + Rodrigues(T x, T y, T z, T l) + : OrientationBase({x, y, z, l}) + { + } + /** + * @brief Constructs a Rodrigues orientation from the 4 components + * @param d + */ + explicit Rodrigues(const std::array& d) + : OrientationBase(d) + { + } + + /** + * @brief Constructs a Rodrigues orientation from the 4 components + * @param rod + */ + explicit Rodrigues(const T* rod) + : OrientationBase({rod[0], rod[1], rod[2], rod[3]}) + { + } + + const T& x() const + { + return (*this)[0]; + } + T& x() + { + return (*this)[0]; + } + + const T& y() const + { + return (*this)[1]; + } + T& y() + { + return (*this)[1]; + } + + const T& z() const + { + return (*this)[2]; + } + T& z() + { + return (*this)[2]; + } + + const T& l() const + { + return (*this)[3]; + } + T& l() + { + return (*this)[3]; + } + + ResultType isValid() const + { + auto eps = static_cast(1.0E-6L); + ResultType res; + res.result = 1; + if(l() < 0.0L) + { + res.msg = "Rodrigues Error: Rodrigues-Frank vector has negative length: "; + res.result = -1; + return res; + } + value_type ttl = std::sqrt(x() * x() + y() * y() + z() * z()); + + if(std::fabs(ttl - 1.0) > eps) + { + res.msg = "Rodrigues Error: Rodrigues-Frank axis vector not normalized"; + res.result = -2; + } + return res; + } + + Euler toEuler() const + { + return toOrientationMatrix().toEuler(); + } + + OrientationMatrix toOrientationMatrix() const + { + return toAxisAngle().toOrientationMatrix(); + } + + AxisAngle toAxisAngle() const + { + using OutputType = AxisAngle; + using OutputValueType = typename OutputType::value_type; + + OutputType res; + OutputValueType ta = 0.0L; + OutputValueType angle = 0.0L; + typename OutputType::value_type threshold = 1.0E-6f; + + ta = l(); + if(math::closeEnough(ta, static_cast(0.0L), threshold)) + { + res = {0.0, 0.0, ebsdlib::orientations::epsijk, 0.0}; + return res; + } + + if(ta == std::numeric_limits::infinity()) + { + res[0] = x(); + res[1] = y(); + res[2] = z(); + res[3] = static_cast(constants::k_PiD); + } + else + { + angle = static_cast(2.0L * atan(ta)); + ta = 1.0L / sqrt(x() * x() + y() * y() + z() * z()); + res[0] = x() * ta; + res[1] = y() * ta; + res[2] = z() * ta; + res[3] = angle; + } + return res; + } + + Rodrigues toRodrigues() const + { + return *this; + } + + Quaternion toQuaternion() const + { + return toAxisAngle().toQuaternion(); + } + + Homochoric toHomochoric() const + { + using OutputType = Homochoric; + using OutputValueType = typename OutputType::value_type; + using SizeType = typename OutputType::size_type; + using OMHelperType = ArrayHelpers; + + OutputType res; + OutputValueType f = 0.0; + OutputValueType rv = OMHelperType::sumofSquares(*this); + if(rv == 0.0) + { + ArrayHelpers::splat(res, 0.0); + return res; + } + if(l() == std::numeric_limits::infinity()) + { + f = static_cast(0.75 * constants::k_PiD); + } + else + { + auto t = static_cast(2.0 * std::atan(l())); + f = static_cast(0.75 * (t - std::sin(t))); + } + f = static_cast(pow(f, 1.0 / 3.0)); + res[0] = x() * f; + res[1] = y() * f; + res[2] = z() * f; + return res; + } + + Cubochoric toCubochoric() const + { + return toHomochoric().toCubochoric(); + } + + Stereographic toStereographic() const + { + return toQuaternion().toStereographic(); + } +}; + +using RodriguesDType = Rodrigues; +using RodriguesFType = Rodrigues; + +template +std::ostream& operator<<(std::ostream& os, const Rodrigues& obj) +{ + os << std::setw(3) << std::setprecision(16) << "RO: <" << obj[0] << ", " << obj[1] << ", " << obj[2] << "> " << obj[3]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/Orientation/SourceList.cmake b/Source/EbsdLib/Orientation/SourceList.cmake new file mode 100644 index 00000000..15459673 --- /dev/null +++ b/Source/EbsdLib/Orientation/SourceList.cmake @@ -0,0 +1,26 @@ +set(DIR_NAME Orientation) + +set(EbsdLib_${DIR_NAME}_HDRS + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationFwd.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Euler.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/OrientationMatrix.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/AxisAngle.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Rodrigues.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Quaternion.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Homochoric.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Cubochoric.hpp + ${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/${DIR_NAME}/Stereographic.hpp +) + +set(EbsdLib_${DIR_NAME}_SRCS + +) + +#cmp_IDE_SOURCE_PROPERTIES( "OrientationMath" "${EbsdLib_OrientationMath_HDRS}" "${EbsdLib_OrientationMath_SRCS}" "0") + +if(EbsdLib_INSTALL_FILES) + install(FILES ${EbsdLib_${DIR_NAME}_HDRS} + DESTINATION include/EbsdLib/Orientation + COMPONENT Headers + ) +endif() diff --git a/Source/EbsdLib/Orientation/Stereographic.hpp b/Source/EbsdLib/Orientation/Stereographic.hpp new file mode 100644 index 00000000..194a150d --- /dev/null +++ b/Source/EbsdLib/Orientation/Stereographic.hpp @@ -0,0 +1,255 @@ +#pragma once + +#include "EbsdLib/Math/ArrayHelpers.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" + +#include +#include + +namespace ebsdlib +{ + +/** + * @brief This class represents an orientation as a 3D Stereographic coordinate where the + * coordinate must fall within the unit sphere of radius = 1. This representation + * can be useful if you wish to visualize orientations as 3D points in space such + * as a Rodrigues fundamental zone visualization. + * @tparam T Either double or float + */ +template +class Stereographic : public OrientationBase +{ + +public: + using SuperType = OrientationBase; + using SelfType = Stereographic; + using value_type = T; + + Stereographic() = default; + + Stereographic(T x, T y, T z) + : OrientationBase({x, y, z}) + { + } + + explicit Stereographic(const std::array& d) + : OrientationBase(d) + { + } + + explicit Stereographic(const T* st) + : OrientationBase({st[0], st[1], st[2]}) + { + } + + T& x() + { + return (*this)[0]; + } + const T& x() const + { + return (*this)[0]; + } + + T& y() + { + return (*this)[1]; + } + const T& y() const + { + return (*this)[1]; + } + + T& z() + { + return (*this)[2]; + } + const T& z() const + { + return (*this)[2]; + } + + T dot() const + { + return (x() * x() + y() * y() + z() * z()); + } + + T magnitude() const + { + return std::sqrt(dot()); + } + + ResultType isValid() const + { + using ValueType = value_type; + ResultType res; + res.result = 1; + + value_type epsd = 1.0E15; // std::numeric_limits::epsilon(); + ValueType rd = magnitude(); + if(rd > 1.0 + epsd) + { + std::stringstream oss; + oss << std::setprecision(16) << "Stereographic Error: Stereographic vector must have unit norm <= unity " << rd << " Unity: " << (1.0 + epsd) << " epsd: " << epsd; + res.result = -2; + res.msg = oss.str(); + } + + return res; + } + + Euler toEuler() const + { + return toAxisAngle().toEuler(); + } + + OrientationMatrix toOrientationMatrix() const + { + using OutputType = OrientationMatrix; + using OutputValueType = typename OutputType::value_type; + + auto threshold = static_cast(1.0E-5L); + OutputType res = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; // Init with identity matrix + + OutputValueType l = std::sqrt(ArrayHelpers::sumofSquares(*this)); + if(l > 0.0) + { + SelfType tmp(*this); + ArrayHelpers::scalarDivide(tmp, l); + AxisAngle ax; + if(math::closeEnough(l, static_cast(1.0L), threshold)) + { + ax = AxisAngle(tmp[0], tmp[1], tmp[2], static_cast(constants::k_PiD)); + } + else + { + ax = AxisAngle(tmp[0], tmp[1], tmp[2], static_cast(4.0 * std::atan(l))); + } + res = ax.toOrientationMatrix(); + } + return res; + } + + AxisAngle toAxisAngle() const + { + using OutputType = AxisAngle; + using OutputValueType = typename OutputType::value_type; + + auto threshold = static_cast(1.0E-5L); + OutputType res = {0.0, 0.0, 1.0, 0.0}; + + OutputValueType l = std::sqrt(ArrayHelpers::sumofSquares(*this)); + if(l > 0.0) + { + SelfType tmp(*this); + ArrayHelpers::scalarDivide(tmp, l); + if(math::closeEnough(l, static_cast(1.0L), threshold)) + { + res = {tmp[0], tmp[1], tmp[2], static_cast(constants::k_PiD)}; + } + else + { + res = {tmp[0], tmp[1], tmp[2], static_cast(4.0 * std::atan(l))}; + } + } + return res; + } + + Rodrigues toRodrigues() const + { + using OutputType = Rodrigues; + + using ValueType = typename OutputType::value_type; + auto threshold = static_cast(1.0E-5L); + OutputType res = {0.0, 0.0, 1.0, 0.0}; + ValueType l = std::sqrt(ArrayHelpers::sumofSquares(*this)); + + if(l > 0.0) // ! not the identity rotation + { + SelfType tmp(*this); + ArrayHelpers::scalarDivide(tmp, l); + + if(math::closeEnough(l, static_cast(1.0L), threshold)) + { + res = {tmp[0], tmp[1], tmp[2], static_cast(std::numeric_limits::infinity())}; + } + else + { + res = {tmp[0], tmp[1], tmp[2], static_cast(std::tan(2.0 * std::atan(l)))}; + } + } + return res; + } + + Quaternion toQuaternion() const + { + return toAxisAngle().toQuaternion(); + } + + Homochoric toHomochoric() const + { + using OutputType = Homochoric; + using OutputValueType = typename OutputType::value_type; + + OutputType res = {0.0, 0.0, 0.0}; + OutputValueType l = std::sqrt(ArrayHelpers::sumofSquares(*this)); + + if(l > 0.0) + { + SelfType tmp(*this); + ArrayHelpers::scalarDivide(tmp, l); + + OutputValueType angle = 4.0 * std::atan(l); + OutputValueType temp2 = (3.0 * (angle - std::sin(angle)) / 4.0); + temp2 = std::pow(temp2, (1.0 / 3.0)); + + ArrayHelpers::scalarMultiply(tmp, temp2); + res[0] = tmp[0]; + res[1] = tmp[1]; + res[2] = tmp[2]; + } + return res; + } + + Cubochoric toCubochoric() const + { + using OutputType = Cubochoric; + using OutputValueType = typename OutputType::value_type; + + OutputType res = {0.0, 0.0, 0.0}; + OutputValueType l = std::sqrt(ArrayHelpers::sumofSquares(*this)); + + if(l > 0.0) + { + SelfType tmp(*this); + ArrayHelpers::scalarDivide(tmp, l); + + OutputValueType angle = 4.0 * std::atan(l); + OutputValueType temp2 = (3.0 * (angle - std::sin(angle)) / 4.0); + temp2 = std::pow(temp2, (1.0 / 3.0)); + + ArrayHelpers::scalarMultiply(tmp, temp2); + Homochoric ho(tmp.underlying()); + return ho.toCubochoric(); + } + + return res; + } + + Stereographic toStereographic() const + { + return *this; + } +}; + +using StereographicDType = Stereographic; +using StereographicFType = Stereographic; + +template +std::ostream& operator<<(std::ostream& os, const Stereographic& obj) +{ + os << std::setw(3) << std::setprecision(16) << "ST: " << obj[0] << ", " << obj[1] << ", " << obj[2]; + return os; +} + +} // namespace ebsdlib diff --git a/Source/EbsdLib/OrientationMath/OrientationConverter.hpp b/Source/EbsdLib/OrientationMath/OrientationConverter.hpp index 2e82db95..718e614e 100644 --- a/Source/EbsdLib/OrientationMath/OrientationConverter.hpp +++ b/Source/EbsdLib/OrientationMath/OrientationConverter.hpp @@ -42,8 +42,16 @@ #include #include "EbsdLib/Core/EbsdSetGetMacros.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" +#include "EbsdLib/Orientation/AxisAngle.hpp" +#include "EbsdLib/Orientation/Cubochoric.hpp" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/Homochoric.hpp" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/OrientationMatrix.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +#include "EbsdLib/Orientation/Stereographic.hpp" + #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdLibMath.h" @@ -67,6 +75,8 @@ return std::string(#name); \ } +namespace ebsdlib +{ /** * @brief This is the top level superclass for doing the conversions between orientation * representations @@ -90,9 +100,9 @@ class OrientationConverter * @brief getOrientationRepresentation * @return */ - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Unknown; + return ebsdlib::orientations::Type::Unknown; } /** @@ -100,37 +110,37 @@ class OrientationConverter * @param repType The type of representation to convert to. * @return */ - void convertRepresentationTo(OrientationRepresentation::Type repType) + void convertRepresentationTo(ebsdlib::orientations::Type repType) { - if(repType == OrientationRepresentation::Type::Euler) + if(repType == ebsdlib::orientations::Type::Euler) { toEulers(); } - else if(repType == OrientationRepresentation::Type::OrientationMatrix) + else if(repType == ebsdlib::orientations::Type::OrientationMatrix) { toOrientationMatrix(); } - else if(repType == OrientationRepresentation::Type::Quaternion) + else if(repType == ebsdlib::orientations::Type::Quaternion) { toQuaternion(); } - else if(repType == OrientationRepresentation::Type::AxisAngle) + else if(repType == ebsdlib::orientations::Type::AxisAngle) { toAxisAngle(); } - else if(repType == OrientationRepresentation::Type::Rodrigues) + else if(repType == ebsdlib::orientations::Type::Rodrigues) { toRodrigues(); } - else if(repType == OrientationRepresentation::Type::Homochoric) + else if(repType == ebsdlib::orientations::Type::Homochoric) { toHomochoric(); } - else if(repType == OrientationRepresentation::Type::Cubochoric) + else if(repType == ebsdlib::orientations::Type::Cubochoric) { toCubochoric(); } - else if(repType == OrientationRepresentation::Type::Stereographic) + else if(repType == ebsdlib::orientations::Type::Stereographic) { toStereographic(); } @@ -258,17 +268,17 @@ class OrientationConverter * @brief GetOrientationTypes * @return */ - static std::vector GetOrientationTypes() - { - std::vector ocTypes(8); - ocTypes[0] = OrientationRepresentation::Type::Euler; - ocTypes[1] = OrientationRepresentation::Type::OrientationMatrix; - ocTypes[2] = OrientationRepresentation::Type::Quaternion; - ocTypes[3] = OrientationRepresentation::Type::AxisAngle; - ocTypes[4] = OrientationRepresentation::Type::Rodrigues; - ocTypes[5] = OrientationRepresentation::Type::Homochoric; - ocTypes[6] = OrientationRepresentation::Type::Cubochoric; - ocTypes[7] = OrientationRepresentation::Type::Stereographic; + static std::vector GetOrientationTypes() + { + std::vector ocTypes(8); + ocTypes[0] = ebsdlib::orientations::Type::Euler; + ocTypes[1] = ebsdlib::orientations::Type::OrientationMatrix; + ocTypes[2] = ebsdlib::orientations::Type::Quaternion; + ocTypes[3] = ebsdlib::orientations::Type::AxisAngle; + ocTypes[4] = ebsdlib::orientations::Type::Rodrigues; + ocTypes[5] = ebsdlib::orientations::Type::Homochoric; + ocTypes[6] = ebsdlib::orientations::Type::Cubochoric; + ocTypes[7] = ebsdlib::orientations::Type::Stereographic; return ocTypes; } @@ -287,7 +297,7 @@ class OrientationConverter */ static int GetMaxIndex() { - return static_cast(static_cast(OrientationRepresentation::Type::Unknown) - 1); + return static_cast(static_cast(ebsdlib::orientations::Type::Unknown) - 1); } protected: @@ -386,7 +396,38 @@ class ConvertRepresentation }; OC_TBB_IMPL(Euler) -OC_TBB_IMPL(OrientationMatrix) +// OC_TBB_IMPL(OrientationMatrix) +template +class toOrientationMatrixConvertor +{ +public: + toOrientationMatrixConvertor(T* inputPtr, T* outputPtr) + : m_Input(inputPtr) + , m_Output(outputPtr) + { + } + + void operator()(const tbb::blocked_range& r) const + { + InputType inputInstance; + OutputType outputInstance; + size_t inStride = inputInstance.size(); + size_t outStride = outputInstance.size(); + for(size_t i = r.begin(); i < r.end(); ++i) + { + size_t inOffset = i * inStride; + size_t outOffset = i * outStride; + InputType inputInstance2(m_Input + inOffset); + outputInstance = inputInstance2.toOrientationMatrix(); + outputInstance.copyTo(m_Output + outOffset); + } + } + +private: + T* m_Input = nullptr; + T* m_Output = nullptr; +}; + OC_TBB_IMPL(Quaternion) OC_TBB_IMPL(AxisAngle) OC_TBB_IMPL(Rodrigues) @@ -399,14 +440,14 @@ OC_TBB_IMPL(Stereographic) DataArrayPointerType input = this->getInputData(); \ T* inPtr = input->getPointer(0); \ size_t nTuples = this->getInputData()->getNumberOfTuples(); \ - Orientation outputInstance; \ + ebsdlib::TO_REP outputInstance; \ size_t outStride = outputInstance.size(); \ std::vector cDims = {outStride}; \ DataArrayPointerType output = DataArrayType::CreateArray(nTuples, cDims, #TO_REP, true); \ output->initializeWithZeros(); /* Initialize the array with Zeros */ \ T* outPtr = output->getPointer(0); \ - using FROM_REP##Type = Orientation; \ - using TO_REP##Type = Orientation; \ + using FROM_REP##Type = ebsdlib::FROM_REP; \ + using TO_REP##Type = ebsdlib::TO_REP; \ tbb::parallel_for(tbb::blocked_range(0, nTuples), to##TO_REP##Convertor(inPtr, outPtr), tbb::auto_partitioner()); \ this->setOutputData(output); @@ -431,9 +472,9 @@ class EulerSanityCheck for(size_t i = start; i < end; ++i) { - inPtr[0] = static_cast(std::fmod(inPtr[0], EbsdLib::Constants::k_2PiD)); - inPtr[1] = static_cast(std::fmod(inPtr[1], EbsdLib::Constants::k_PiD)); - inPtr[2] = static_cast(std::fmod(inPtr[2], EbsdLib::Constants::k_2PiD)); + inPtr[0] = static_cast(std::fmod(inPtr[0], ebsdlib::constants::k_2PiD)); + inPtr[1] = static_cast(std::fmod(inPtr[1], ebsdlib::constants::k_PiD)); + inPtr[2] = static_cast(std::fmod(inPtr[2], ebsdlib::constants::k_2PiD)); if(inPtr[0] < 0.0) { @@ -473,9 +514,9 @@ class EulerConverter : public OrientationConverter ~EulerConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Euler; + return ebsdlib::orientations::Type::Euler; } void toEulers() override @@ -487,7 +528,22 @@ class EulerConverter : public OrientationConverter void toOrientationMatrix() override { - OC_CONVERT_BODY_PREAMBLE(Euler, OrientationMatrix); + // OC_CONVERT_BODY_PREAMBLE(Euler, OrientationMatrix); + sanityCheckInputData(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); /* Get a Raw pointer to the chunk of memory */ + size_t nTuples = this->getInputData()->getNumberOfTuples(); + ebsdlib::OrientationMatrix outputInstance; + size_t outStride = outputInstance.size(); + std::vector cDims = {outStride}; + DataArrayPointerType output = DataArrayType::CreateArray(nTuples, cDims, "OrientationMatrix", true); + output->initializeWithZeros(); + T* outPtr = output->getPointer(0); + using EulerType = ebsdlib::Euler; + using OrientationMatrixType = ebsdlib::OrientationMatrix; + tbb::parallel_for(tbb::blocked_range(0, nTuples), toOrientationMatrixConvertor, OrientationMatrix>(inPtr, outPtr), tbb::auto_partitioner()); + this->setOutputData(output); + ; } void toQuaternion() override @@ -613,12 +669,11 @@ class OrientationMatrixSanityCheck for(size_t i = start; i < end; ++i) { - using Orientation_Type = Orientation; - using ResultType = OrientationTransformation::ResultType; + using Orientation_Type = ebsdlib::OrientationMatrix; Orientation_Type oaType(inPtr); - ResultType res = OrientationTransformation::om_check(oaType); + auto res = oaType.isValid(); if(res.result <= 0) { std::cout << res.msg << std::endl; @@ -663,9 +718,9 @@ class OrientationMatrixConverter : public OrientationConverter ~OrientationMatrixConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::OrientationMatrix; + return ebsdlib::orientations::Type::OrientationMatrix; } void toEulers() override @@ -833,9 +888,9 @@ class QuaternionConverter : public OrientationConverter ~QuaternionConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Quaternion; + return ebsdlib::orientations::Type::Quaternion; } void toEulers() override @@ -888,16 +943,16 @@ class QuaternionConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), QuaternionSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + tbb::parallel_for(tbb::blocked_range(0, nTuples), QuaternionSanityCheck(inPtr, inStride), tbb::auto_partitioner()); #else - QuaternionSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + QuaternionSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -996,9 +1051,9 @@ class AxisAngleConverter : public OrientationConverter ~AxisAngleConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::AxisAngle; + return ebsdlib::orientations::Type::AxisAngle; } void toEulers() override @@ -1051,15 +1106,15 @@ class AxisAngleConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), AxisAngleSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + tbb::parallel_for(tbb::blocked_range(0, nTuples), AxisAngleSanityCheck(inPtr, inStride), tbb::auto_partitioner()); #else - AxisAngleSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + AxisAngleSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -1160,9 +1215,9 @@ class RodriguesConverter : public OrientationConverter ~RodriguesConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Rodrigues; + return ebsdlib::orientations::Type::Rodrigues; } void toEulers() override @@ -1215,15 +1270,15 @@ class RodriguesConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), RodriguesSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + tbb::parallel_for(tbb::blocked_range(0, nTuples), RodriguesSanityCheck(inPtr, inStride), tbb::auto_partitioner()); #else - RodriguesSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + RodriguesSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -1324,9 +1379,9 @@ class HomochoricConverter : public OrientationConverter ~HomochoricConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Homochoric; + return ebsdlib::orientations::Type::Homochoric; } void toEulers() override @@ -1379,16 +1434,16 @@ class HomochoricConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), HomochoricSanityCheck(inPtr, inStride), tbb::auto_partitioner()); - } + tbb::parallel_for(tbb::blocked_range(0, nTuples), HomochoricSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + } #else - HomochoricSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + HomochoricSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -1489,9 +1544,9 @@ class CubochoricConverter : public OrientationConverter ~CubochoricConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Cubochoric; + return ebsdlib::orientations::Type::Cubochoric; } void toEulers() override @@ -1544,15 +1599,15 @@ class CubochoricConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), CubochoricSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + tbb::parallel_for(tbb::blocked_range(0, nTuples), CubochoricSanityCheck(inPtr, inStride), tbb::auto_partitioner()); #else - CubochoricSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + CubochoricSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -1653,9 +1708,9 @@ class StereographicConverter : public OrientationConverter ~StereographicConverter() override = default; - OrientationRepresentation::Type getOrientationRepresentation() + ebsdlib::orientations::Type getOrientationRepresentation() { - return OrientationRepresentation::Type::Stereographic; + return ebsdlib::orientations::Type::Stereographic; } void toEulers() override @@ -1708,15 +1763,15 @@ class StereographicConverter : public OrientationConverter * go */ #if 0 - DataArrayPointerType input = this->getInputData(); - T* inPtr = input->getPointer(0); - size_t nTuples = input->getNumberOfTuples(); - int inStride = input->getNumberOfComponents(); + DataArrayPointerType input = this->getInputData(); + T* inPtr = input->getPointer(0); + size_t nTuples = input->getNumberOfTuples(); + int inStride = input->getNumberOfComponents(); #ifdef EbsdLib_USE_PARALLEL_ALGORITHMS - tbb::parallel_for(tbb::blocked_range(0, nTuples), StereographicSanityCheck(inPtr, inStride), tbb::auto_partitioner()); + tbb::parallel_for(tbb::blocked_range(0, nTuples), StereographicSanityCheck(inPtr, inStride), tbb::auto_partitioner()); #else - StereographicSanityCheck serial(inPtr, inStride); - serial.sanityCheck(0, nTuples); + StereographicSanityCheck serial(inPtr, inStride); + serial.sanityCheck(0, nTuples); #endif #endif } @@ -1772,3 +1827,4 @@ class StereographicConverter : public OrientationConverter StereographicConverter& operator=(const StereographicConverter&) = delete; // Copy Assignment Not Implemented StereographicConverter& operator=(StereographicConverter&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/SourceList.cmake b/Source/EbsdLib/SourceList.cmake index c8706707..ce87826f 100644 --- a/Source/EbsdLib/SourceList.cmake +++ b/Source/EbsdLib/SourceList.cmake @@ -59,11 +59,17 @@ include(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/Texture/SourceList.cmake) #------------------------------------------------------------------------------- include(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/Utilities/SourceList.cmake) +#------------------------------------------------------------------------------- +# Orientation +#------------------------------------------------------------------------------- +include(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/Orientation/SourceList.cmake) + + configure_file(${EbsdLibProj_SOURCE_DIR}/Source/EbsdLib/EbsdLibConfiguration.h.in ${EbsdLibProj_BINARY_DIR}/EbsdLib/EbsdLib.h ) -set(VERSION_GEN_NAMESPACE "EbsdLib") +set(VERSION_GEN_NAMESPACE "ebsdlib") set(VERSION_GEN_NAME "EBSDLIB") set(VERSION_GEN_HEADER_FILE_NAME "EbsdLibVersion.h") set(VERSION_GEN_VER_MAJOR ${EbsdLibProj_VERSION_MAJOR}) diff --git a/Source/EbsdLib/Texture/StatsGen.hpp b/Source/EbsdLib/Texture/StatsGen.hpp index 52f7c476..9bde527e 100644 --- a/Source/EbsdLib/Texture/StatsGen.hpp +++ b/Source/EbsdLib/Texture/StatsGen.hpp @@ -49,6 +49,8 @@ #include "EbsdLib/Math/EbsdLibRandom.h" #include "EbsdLib/Texture/Texture.hpp" +namespace ebsdlib +{ /** * @brief This class contains static functions to generate ODF and MDF data as X,Y points. This data can be discretized * onto a regular grid which would result in standard ODF Pole Figures and a regular 2D MDF plot. @@ -714,3 +716,4 @@ class StatsGen StatsGen& operator=(const StatsGen&) = delete; // Copy Assignment Not Implemented StatsGen& operator=(StatsGen&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Texture/Texture.hpp b/Source/EbsdLib/Texture/Texture.hpp index a7b82d3b..68aa219f 100644 --- a/Source/EbsdLib/Texture/Texture.hpp +++ b/Source/EbsdLib/Texture/Texture.hpp @@ -43,9 +43,6 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/CubicOps.h" #include "EbsdLib/LaueOps/HexagonalOps.h" @@ -53,14 +50,17 @@ #include "EbsdLib/LaueOps/OrthoRhombicOps.h" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Math/EbsdLibRandom.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +namespace ebsdlib +{ /** * @brief This class holds default data for Orientation Distribution Function (ODF) * and Misorientation Distribution Functions (MDF) * calculations that the DREAM3D package will perform. * */ - class Texture { public: @@ -88,7 +88,7 @@ class Texture LaueOps ops; std::array odfNumBins = ops.getOdfNumBins(); odf.resize(ops.getODFSize()); - EbsdLib::Int32ArrayType::Pointer textureBins = EbsdLib::Int32ArrayType::CreateArray(numEntries, "TextureBins", true); + ebsdlib::Int32ArrayType::Pointer textureBins = ebsdlib::Int32ArrayType::CreateArray(numEntries, "TextureBins", true); int32_t* TextureBins = textureBins->getPointer(0); float addweight = 0; @@ -274,11 +274,11 @@ class Texture // This is used to create a random Homochoric vector std::array randx3 = {distribution(generator), distribution(generator), distribution(generator)}; EulerDType eu = orientationOps.determineEulerAngles(randx3.data(), choose1); - QuatD q1 = eu.toQuat(); + QuatD q1 = eu.toQuaternion(); randx3 = {distribution(generator), distribution(generator), distribution(generator)}; eu = orientationOps.determineEulerAngles(randx3.data(), choose2); - QuatD q2 = eu.toQuat(); + QuatD q2 = eu.toQuaternion(); RodriguesDType ro = orientationOps.calculateMisorientation(q1, q2).toRodrigues(); ro = orientationOps.getMDFFZRod(ro); // <==== THIS IS NOT IMPELMENTED FOR ALL LAUE CLASSES @@ -311,3 +311,4 @@ class Texture Texture& operator=(const Texture&) = delete; // Copy Assignment Not Implemented Texture& operator=(Texture&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Texture/TexturePreset.cpp b/Source/EbsdLib/Texture/TexturePreset.cpp index d96ff228..c9f5ce5f 100644 --- a/Source/EbsdLib/Texture/TexturePreset.cpp +++ b/Source/EbsdLib/Texture/TexturePreset.cpp @@ -36,6 +36,8 @@ #include "EbsdLib/Core/EbsdLibConstants.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -54,20 +56,20 @@ TexturePreset::~TexturePreset() = default; std::vector CubicTexturePresets::getTextures() { std::vector textures; - ADD_NEW_TEXTURE("Brass", EbsdLib::CrystalStructure::Cubic_High, 35.0, 45.0, 0.0) - ADD_NEW_TEXTURE("S", EbsdLib::CrystalStructure::Cubic_High, 59.0, 37.0, 63.0) - ADD_NEW_TEXTURE("Copper", EbsdLib::CrystalStructure::Cubic_High, 90.0, 35.0, 45.0) - ADD_NEW_TEXTURE("S1", EbsdLib::CrystalStructure::Cubic_High, 55.0, 30.0, 65.0) - ADD_NEW_TEXTURE("S2", EbsdLib::CrystalStructure::Cubic_High, 45.0, 35.0, 65.0) - ADD_NEW_TEXTURE("Goss", EbsdLib::CrystalStructure::Cubic_High, 0.0, 45.0, 0.0) - ADD_NEW_TEXTURE("Cube", EbsdLib::CrystalStructure::Cubic_High, 0.0, 0.0, 0.0) - ADD_NEW_TEXTURE("RC(rd1)", EbsdLib::CrystalStructure::Cubic_High, 0.0, 20.0, 0.0) - ADD_NEW_TEXTURE("RC(rd2)", EbsdLib::CrystalStructure::Cubic_High, 0.0, 35.0, 0.0) - ADD_NEW_TEXTURE("RC(nd1)", EbsdLib::CrystalStructure::Cubic_High, 20.0, 0.0, 0.0) - ADD_NEW_TEXTURE("RC(nd2)", EbsdLib::CrystalStructure::Cubic_High, 35.0, 0.0, 0.0) - ADD_NEW_TEXTURE("P", EbsdLib::CrystalStructure::Cubic_High, 70.0, 45.0, 0.0) - ADD_NEW_TEXTURE("Q", EbsdLib::CrystalStructure::Cubic_High, 55.0, 20.0, 0.0) - ADD_NEW_TEXTURE("R", EbsdLib::CrystalStructure::Cubic_High, 55.0, 75.0, 25.0) + ADD_NEW_TEXTURE("Brass", ebsdlib::CrystalStructure::Cubic_High, 35.0, 45.0, 0.0) + ADD_NEW_TEXTURE("S", ebsdlib::CrystalStructure::Cubic_High, 59.0, 37.0, 63.0) + ADD_NEW_TEXTURE("Copper", ebsdlib::CrystalStructure::Cubic_High, 90.0, 35.0, 45.0) + ADD_NEW_TEXTURE("S1", ebsdlib::CrystalStructure::Cubic_High, 55.0, 30.0, 65.0) + ADD_NEW_TEXTURE("S2", ebsdlib::CrystalStructure::Cubic_High, 45.0, 35.0, 65.0) + ADD_NEW_TEXTURE("Goss", ebsdlib::CrystalStructure::Cubic_High, 0.0, 45.0, 0.0) + ADD_NEW_TEXTURE("Cube", ebsdlib::CrystalStructure::Cubic_High, 0.0, 0.0, 0.0) + ADD_NEW_TEXTURE("RC(rd1)", ebsdlib::CrystalStructure::Cubic_High, 0.0, 20.0, 0.0) + ADD_NEW_TEXTURE("RC(rd2)", ebsdlib::CrystalStructure::Cubic_High, 0.0, 35.0, 0.0) + ADD_NEW_TEXTURE("RC(nd1)", ebsdlib::CrystalStructure::Cubic_High, 20.0, 0.0, 0.0) + ADD_NEW_TEXTURE("RC(nd2)", ebsdlib::CrystalStructure::Cubic_High, 35.0, 0.0, 0.0) + ADD_NEW_TEXTURE("P", ebsdlib::CrystalStructure::Cubic_High, 70.0, 45.0, 0.0) + ADD_NEW_TEXTURE("Q", ebsdlib::CrystalStructure::Cubic_High, 55.0, 20.0, 0.0) + ADD_NEW_TEXTURE("R", ebsdlib::CrystalStructure::Cubic_High, 55.0, 75.0, 25.0) return textures; } @@ -77,7 +79,7 @@ std::vector CubicTexturePresets::getTextures() std::vector HexTexturePresets::getTextures() { std::vector textures; - // ADD_NEW_TEXTURE( "Brass", EbsdLib::CrystalStructure::Hexagonal, 35.0, 45.0, 0.0) + // ADD_NEW_TEXTURE( "Brass", ebsdlib::CrystalStructure::Hexagonal, 35.0, 45.0, 0.0) return textures; } diff --git a/Source/EbsdLib/Texture/TexturePreset.h b/Source/EbsdLib/Texture/TexturePreset.h index 863ecea2..b9a181e0 100644 --- a/Source/EbsdLib/Texture/TexturePreset.h +++ b/Source/EbsdLib/Texture/TexturePreset.h @@ -43,6 +43,8 @@ #include "EbsdLib/Core/EbsdLibConstants.h" #include "EbsdLib/EbsdLib.h" +namespace ebsdlib +{ /** * @brief The TexturePreset class */ @@ -186,3 +188,4 @@ class EbsdLib_EXPORT HexTexturePresets HexTexturePresets& operator=(const HexTexturePresets&) = delete; // Copy Assignment Not Implemented HexTexturePresets& operator=(HexTexturePresets&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/CanvasUtilities.cpp b/Source/EbsdLib/Utilities/CanvasUtilities.cpp index 5a1456a2..5ef7f6dd 100644 --- a/Source/EbsdLib/Utilities/CanvasUtilities.cpp +++ b/Source/EbsdLib/Utilities/CanvasUtilities.cpp @@ -12,7 +12,7 @@ #define CANVAS_ITY_IMPLEMENTATION #include -namespace EbsdLib +namespace ebsdlib { // ----------------------------------------------------------------------------- @@ -99,8 +99,8 @@ std::vector GeneratePointsOnUnitCircle(const Point3DType& direction // Find another vector (v2) that is perpendicular to both the normal and v1 using the cross product Point3DType v2 = dirNormalized.cross(v1).normalize(); - double angleStart = 0.0 * EbsdLib::Constants::k_PiOver180D; - double arc = 360.0 * EbsdLib::Constants::k_PiOver180D; + double angleStart = 0.0 * ebsdlib::constants::k_PiOver180D; + double arc = 360.0 * ebsdlib::constants::k_PiOver180D; // Generate points on the unit circle that has been rotated according to the direction for(int i = 0; i < num_points + 1; ++i) @@ -120,10 +120,10 @@ std::vector GeneratePointsOnUnitCircle(const Point3DType& direction } // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(EbsdLib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight) +ebsdlib::UInt8ArrayType::Pointer DrawStandardCubicProjection(ebsdlib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight) { - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); // Initialize our fonts fonts::Base64Decode(fonts::k_LatoRegularBase64, latoRegular); fonts::Base64Decode(fonts::k_LatoBoldBase64, latoBold); @@ -161,7 +161,7 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(EbsdLib::UInt8Array context.close_path(); int num_points = 50; - std::vector directions = { + std::vector directions = { {1.0, 0.0, 1.0}, // Horizontal Meridian Line // {2.0, 0.0, 1.0}, // {1.0, 0.0, 2.0}, @@ -179,12 +179,12 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(EbsdLib::UInt8Array std::array figureOrigin = {0.0F, 0.0F}; for(const auto& direction : directions) { - std::vector stereoPoints = Stereographic::Utils::TransformUnitSphereToStereographicCoords(EbsdLib::GeneratePointsOnUnitCircle(direction, num_points)); + std::vector stereoPoints = stereographic::utils::TransformUnitSphereToStereographicCoords(ebsdlib::GeneratePointsOnUnitCircle(direction, num_points)); for(size_t i = 1; i < stereoPoints.size(); i++) { - EbsdLib::Point3DType p0 = stereoPoints[i - 1]; - EbsdLib::Point3DType p1 = stereoPoints[i]; + ebsdlib::Point3DType p0 = stereoPoints[i - 1]; + ebsdlib::Point3DType p1 = stereoPoints[i]; p0 = (p0 * static_cast(halfWidth)) + halfWidth; p1 = (p1 * static_cast(halfWidth)) + halfWidth; @@ -194,33 +194,33 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(EbsdLib::UInt8Array p1[0] = p1[0] + figureOrigin[0]; p1[1] = p1[1] + figureOrigin[1]; - EbsdLib::DrawLine(context, p0[0], p0[1], p1[0], p1[1]); + ebsdlib::DrawLine(context, p0[0], p0[1], p1[0], p1[1]); } } // This is PRE ROTATION of the entire image, so +X is to the RIGHT, +Y is UP std::string fontWidthString = "[100]"; float fontWidth = context.measure_text(fontWidthString.c_str()); - EbsdLib::WriteText(context, fontWidthString, {pageWidth - fontWidth, static_cast(halfHeight)}, fontPtSize); - EbsdLib::WriteText(context, "[010]", {pageWidth * 0.5F, static_cast(fontPtSize * 1.2F)}, fontPtSize); - EbsdLib::WriteText(context, "[110]", {pageWidth * 0.85F, pageHeight * 0.15F}, fontPtSize); - EbsdLib::WriteText(context, "[-110]", {pageWidth * 0.15F, pageHeight * 0.15F}, fontPtSize); - EbsdLib::WriteText(context, "[-100]", {pageWidth * 0.0F, pageHeight * 0.5F}, fontPtSize); - EbsdLib::WriteText(context, "[-1-10]", {pageWidth * 0.15F, pageHeight * 0.85F}, fontPtSize); - EbsdLib::WriteText(context, "[0-10]", {pageWidth * 0.5F, pageHeight - fontPtSize * 1.1F}, fontPtSize); - EbsdLib::WriteText(context, "[1-10]", {pageWidth * 0.85F, pageHeight * 0.85F}, fontPtSize); + ebsdlib::WriteText(context, fontWidthString, {pageWidth - fontWidth, static_cast(halfHeight)}, fontPtSize); + ebsdlib::WriteText(context, "[010]", {pageWidth * 0.5F, static_cast(fontPtSize * 1.2F)}, fontPtSize); + ebsdlib::WriteText(context, "[110]", {pageWidth * 0.85F, pageHeight * 0.15F}, fontPtSize); + ebsdlib::WriteText(context, "[-110]", {pageWidth * 0.15F, pageHeight * 0.15F}, fontPtSize); + ebsdlib::WriteText(context, "[-100]", {pageWidth * 0.0F, pageHeight * 0.5F}, fontPtSize); + ebsdlib::WriteText(context, "[-1-10]", {pageWidth * 0.15F, pageHeight * 0.85F}, fontPtSize); + ebsdlib::WriteText(context, "[0-10]", {pageWidth * 0.5F, pageHeight - fontPtSize * 1.1F}, fontPtSize); + ebsdlib::WriteText(context, "[1-10]", {pageWidth * 0.85F, pageHeight * 0.85F}, fontPtSize); // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight) +ebsdlib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(ebsdlib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight) { int legendHeight = pageHeight; int legendWidth = pageWidth; @@ -246,8 +246,8 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8A // Create a Canvas to draw into canvas_ity::canvas context(pageWidth, pageHeight); - std::vector latoBold = EbsdLib::fonts::GetLatoBold(); - std::vector latoRegular = EbsdLib::fonts::GetLatoRegular(); + std::vector latoBold = ebsdlib::fonts::GetLatoBold(); + std::vector latoRegular = ebsdlib::fonts::GetLatoRegular(); context.set_font(latoBold.data(), static_cast(latoBold.size()), fontPtSize); context.set_color(canvas_ity::fill_style, 0.0f, 0.0f, 0.0f, 1.0f); canvas_ity::baseline_style const baselines[] = {canvas_ity::alphabetic, canvas_ity::top, canvas_ity::middle, canvas_ity::bottom, canvas_ity::hanging, canvas_ity::ideographic}; @@ -315,7 +315,7 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8A context.set_color(canvas_ity::stroke_style, 0.25f, 0.25f, 0.25f, 1.0f); context.set_line_width(penWidth); - EbsdLib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); + ebsdlib::DrawLine(context, figureCenter[0], figureCenter[1], x, y); std::string label = labels2[idx]; std::string fontWidthString = EbsdStringUtils::replace(label, "-", ""); @@ -326,7 +326,7 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8A context.set_color(canvas_ity::stroke_style, 0.0f, 0.0f, 0.0f, 1.0f); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } // Draw the [0001] in the center of the image @@ -335,29 +335,29 @@ EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8A float y = figureCenter[1] - fontPtSize * 0.2F; std::string label("[0001]"); - EbsdLib::WriteText(context, label, {x, y}, fontPtSize); + ebsdlib::WriteText(context, label, {x, y}, fontPtSize); } // Fetch the rendered RGBA pixels from the entire canvas. - EbsdLib::UInt8ArrayType::Pointer rgbaCanvasImage = EbsdLib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); + ebsdlib::UInt8ArrayType::Pointer rgbaCanvasImage = ebsdlib::UInt8ArrayType::CreateArray(pageHeight * pageWidth, {4ULL}, "Triangle Legend", true); // std::vector rgbaCanvasImage(static_cast(pageHeight * pageWidth * 4)); context.get_image_data(rgbaCanvasImage->getPointer(0), pageWidth, pageHeight, pageWidth * 4, 0, 0); - rgbaCanvasImage = EbsdLib::RemoveAlphaChannel(rgbaCanvasImage.get()); + rgbaCanvasImage = ebsdlib::RemoveAlphaChannel(rgbaCanvasImage.get()); return rgbaCanvasImage; } // ----------------------------------------------------------------------------- -void DrawStereographicLines(canvas_ity::canvas& context, const std::vector& directions, int numPoints, int halfWidth, std::array figureOrigin) +void DrawStereographicLines(canvas_ity::canvas& context, const std::vector& directions, int numPoints, int halfWidth, std::array figureOrigin) { for(const auto& direction : directions) { - std::vector stereoPoints = Stereographic::Utils::TransformUnitSphereToStereographicCoords(EbsdLib::GeneratePointsOnUnitCircle(direction, numPoints)); + std::vector stereoPoints = stereographic::utils::TransformUnitSphereToStereographicCoords(ebsdlib::GeneratePointsOnUnitCircle(direction, numPoints)); for(size_t i = 1; i < stereoPoints.size(); i++) { - EbsdLib::Point3DType p0 = stereoPoints[i - 1]; - EbsdLib::Point3DType p1 = stereoPoints[i]; + ebsdlib::Point3DType p0 = stereoPoints[i - 1]; + ebsdlib::Point3DType p1 = stereoPoints[i]; p0 = (p0 * static_cast(halfWidth)) + halfWidth; p1 = (p1 * static_cast(halfWidth)) + halfWidth; @@ -367,9 +367,9 @@ void DrawStereographicLines(canvas_ity::canvas& context, const std::vector -namespace EbsdLib +namespace ebsdlib { -using Point3DType = EbsdLib::Matrix3X1; +using Point3DType = ebsdlib::Matrix3X1; /** * @brief @@ -45,7 +45,7 @@ EbsdLib_EXPORT std::vector GeneratePointsOnUnitCircle(const Point3D * @param height * @return */ -EbsdLib_EXPORT EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(EbsdLib::UInt8ArrayType::Pointer image, int width, int height); +EbsdLib_EXPORT ebsdlib::UInt8ArrayType::Pointer DrawStandardCubicProjection(ebsdlib::UInt8ArrayType::Pointer image, int width, int height); /** * @brief @@ -54,7 +54,7 @@ EbsdLib_EXPORT EbsdLib::UInt8ArrayType::Pointer DrawStandardCubicProjection(Ebsd * @param pageHeight * @return */ -EbsdLib_EXPORT EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(EbsdLib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight); +EbsdLib_EXPORT ebsdlib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection(ebsdlib::UInt8ArrayType::Pointer image, int pageWidth, int pageHeight); /** * @brief @@ -64,7 +64,7 @@ EbsdLib_EXPORT EbsdLib::UInt8ArrayType::Pointer DrawStandardHexagonalProjection( * @param halfWidth * @param figureOrigin */ -EbsdLib_EXPORT void DrawStereographicLines(canvas_ity::canvas& context, const std::vector& directions, int numPoints, int halfWidth, std::array figureOrigin); +EbsdLib_EXPORT void DrawStereographicLines(canvas_ity::canvas& context, const std::vector& directions, int numPoints, int halfWidth, std::array figureOrigin); // ----------------------------------------------------------------------------- template @@ -180,4 +180,4 @@ typename EbsdDataArray::Pointer CropRGBImage(typename EbsdDataArray::Point return converted; } -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/ColorTable.cpp b/Source/EbsdLib/Utilities/ColorTable.cpp index 179d25dd..e91c38b5 100644 --- a/Source/EbsdLib/Utilities/ColorTable.cpp +++ b/Source/EbsdLib/Utilities/ColorTable.cpp @@ -40,7 +40,7 @@ // #include -using namespace EbsdLib; +using namespace ebsdlib; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/Utilities/ColorTable.h b/Source/EbsdLib/Utilities/ColorTable.h index e45999b0..4c6b8509 100644 --- a/Source/EbsdLib/Utilities/ColorTable.h +++ b/Source/EbsdLib/Utilities/ColorTable.h @@ -43,7 +43,7 @@ #include "EbsdLib/Core/EbsdLibConstants.h" #include "EbsdLib/EbsdLib.h" -namespace EbsdLib +namespace ebsdlib { class EbsdLib_EXPORT RgbColor @@ -52,47 +52,47 @@ class EbsdLib_EXPORT RgbColor /** * @brief Rgb An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int and The type also holds a value for the alpha-channel. */ - inline static int dRed(EbsdLib::Rgb rgb) + inline static int dRed(ebsdlib::Rgb rgb) { return ((rgb >> 16) & 0xff); } - inline static int dGreen(EbsdLib::Rgb rgb) + inline static int dGreen(ebsdlib::Rgb rgb) { return ((rgb >> 8) & 0xff); } - inline static int dBlue(EbsdLib::Rgb rgb) + inline static int dBlue(ebsdlib::Rgb rgb) { return (rgb & 0xff); } - inline static int dAlpha(EbsdLib::Rgb rgb) + inline static int dAlpha(ebsdlib::Rgb rgb) { return rgb >> 24; } - inline static int dGray(EbsdLib::Rgb rgb) + inline static int dGray(ebsdlib::Rgb rgb) { return (((rgb >> 16) & 0xff) * 11 + ((rgb >> 8) & 0xff) * 16 + (rgb & 0xff) * 5) / 32; } - inline static EbsdLib::Rgb dRgb(int r, int g, int b, int a) + inline static ebsdlib::Rgb dRgb(int r, int g, int b, int a) { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); } - inline static void print(std::ostream& out, const char& sep, const EbsdLib::Rgb& rgb) + inline static void print(std::ostream& out, const char& sep, const ebsdlib::Rgb& rgb) { - out << EbsdLib::RgbColor::dRed(rgb) << sep << EbsdLib::RgbColor::dGreen(rgb) << sep << EbsdLib::RgbColor::dBlue(rgb); + out << ebsdlib::RgbColor::dRed(rgb) << sep << ebsdlib::RgbColor::dGreen(rgb) << sep << ebsdlib::RgbColor::dBlue(rgb); } - inline static bool compare(const EbsdLib::Rgb& left, const EbsdLib::Rgb& right) + inline static bool compare(const ebsdlib::Rgb& left, const ebsdlib::Rgb& right) { return left == right; } - inline static std::tuple fRgb(EbsdLib::Rgb rgb) + inline static std::tuple fRgb(ebsdlib::Rgb rgb) { return std::make_tuple(static_cast(((rgb >> 16) & 0xff) / 255.0f), static_cast(((rgb >> 8) & 0xff) / 255.0f), static_cast((rgb & 0xff) / 255.0f)); } @@ -106,7 +106,7 @@ class EbsdLib_EXPORT RgbColor RgbColor& operator=(const RgbColor&) = delete; // Copy Assignment Not Implemented RgbColor& operator=(RgbColor&&) = delete; // Move Assignment Not Implemented }; -} // namespace EbsdLib +} // namespace ebsdlib class QJsonArray; /** diff --git a/Source/EbsdLib/Utilities/ColorUtilities.cpp b/Source/EbsdLib/Utilities/ColorUtilities.cpp index c3b7699b..8183ac81 100644 --- a/Source/EbsdLib/Utilities/ColorUtilities.cpp +++ b/Source/EbsdLib/Utilities/ColorUtilities.cpp @@ -37,7 +37,7 @@ #include "EbsdLib/Math/EbsdLibMath.h" -using namespace EbsdLib; +using namespace ebsdlib; // ----------------------------------------------------------------------------- // @@ -52,7 +52,7 @@ ColorUtilities::~ColorUtilities() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb ColorUtilities::ConvertHSVtoRgb(float h, float s, float v) +ebsdlib::Rgb ColorUtilities::ConvertHSVtoRgb(float h, float s, float v) { // hsv to rgb (from wikipedia hsv/hsl page) float c = v * s; @@ -126,13 +126,13 @@ EbsdLib::Rgb ColorUtilities::ConvertHSVtoRgb(float h, float s, float v) b = 0.0f; } - return EbsdLib::RgbColor::dRgb(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255), 0); + return ebsdlib::RgbColor::dRgb(static_cast(r * 255), static_cast(g * 255), static_cast(b * 255), 0); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::Rgb ColorUtilities::Hsv2Rgb(float h, float s, float v) +ebsdlib::Rgb ColorUtilities::Hsv2Rgb(float h, float s, float v) { double hh, p, q, t, ff; long i; @@ -158,7 +158,7 @@ EbsdLib::Rgb ColorUtilities::Hsv2Rgb(float h, float s, float v) out.r = in.v; out.g = in.v; out.b = in.v; - return EbsdLib::RgbColor::dRgb(static_cast(out.r * 255), static_cast(out.g * 255), static_cast(out.b * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(out.r * 255), static_cast(out.g * 255), static_cast(out.b * 255), 255); } hh = in.h; if(hh >= 360.0) @@ -207,21 +207,21 @@ EbsdLib::Rgb ColorUtilities::Hsv2Rgb(float h, float s, float v) out.b = q; break; } - return EbsdLib::RgbColor::dRgb(static_cast(out.r * 255), static_cast(out.g * 255), static_cast(out.b * 255), 255); + return ebsdlib::RgbColor::dRgb(static_cast(out.r * 255), static_cast(out.g * 255), static_cast(out.b * 255), 255); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::vector ColorUtilities::GenerateColors(int count, int saturation, int value) +std::vector ColorUtilities::GenerateColors(int count, int saturation, int value) { - std::vector colors(count); + std::vector colors(count); float s = static_cast(saturation) / 255.0f; float v = static_cast(value) / 255.0f; float increment = 360.0f / count; for(float i = 0; i < static_cast(count); i = i + 1.0f) { - EbsdLib::Rgb c = ColorUtilities::Hsv2Rgb(i * increment, s, v); + ebsdlib::Rgb c = ColorUtilities::Hsv2Rgb(i * increment, s, v); colors[static_cast(i)] = c; } return colors; diff --git a/Source/EbsdLib/Utilities/ColorUtilities.h b/Source/EbsdLib/Utilities/ColorUtilities.h index 21c74416..0cec22b6 100644 --- a/Source/EbsdLib/Utilities/ColorUtilities.h +++ b/Source/EbsdLib/Utilities/ColorUtilities.h @@ -41,7 +41,7 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Utilities/ColorTable.h" -namespace EbsdLib +namespace ebsdlib { class EbsdLib_EXPORT ColorUtilities @@ -56,7 +56,7 @@ class EbsdLib_EXPORT ColorUtilities * @param v 0-1 Range * @return Rgb Conversion */ - static EbsdLib::Rgb ConvertHSVtoRgb(float h, float s, float v); + static ebsdlib::Rgb ConvertHSVtoRgb(float h, float s, float v); /** * @brief @@ -65,7 +65,7 @@ class EbsdLib_EXPORT ColorUtilities * @param v a fraction between 0 and 1 * @return Rgb Conversion */ - static EbsdLib::Rgb Hsv2Rgb(float h, float s, float v); + static ebsdlib::Rgb Hsv2Rgb(float h, float s, float v); /** * @brief Generates a vector of colors based on the HSV color wheel. The colors @@ -75,10 +75,10 @@ class EbsdLib_EXPORT ColorUtilities * @param value Range between 0-255 * @return */ - static std::vector GenerateColors(int count, int saturation = 255, int value = 255); + static std::vector GenerateColors(int count, int saturation = 255, int value = 255); protected: ColorUtilities(); }; -} // namespace EbsdLib +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/ComputeStereographicProjection.cpp b/Source/EbsdLib/Utilities/ComputeStereographicProjection.cpp index 2b196485..8eb64966 100644 --- a/Source/EbsdLib/Utilities/ComputeStereographicProjection.cpp +++ b/Source/EbsdLib/Utilities/ComputeStereographicProjection.cpp @@ -38,10 +38,12 @@ #endif #include "EbsdLib/Utilities/ModifiedLambertProjection.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ComputeStereographicProjection::ComputeStereographicProjection(EbsdLib::FloatArrayType* xyzCoords, PoleFigureConfiguration_t* config, EbsdLib::DoubleArrayType* intensity) +ComputeStereographicProjection::ComputeStereographicProjection(ebsdlib::FloatArrayType* xyzCoords, PoleFigureConfiguration_t* config, ebsdlib::DoubleArrayType* intensity) : m_XYZCoords(xyzCoords) , m_Config(config) , m_Intensity(intensity) diff --git a/Source/EbsdLib/Utilities/ComputeStereographicProjection.h b/Source/EbsdLib/Utilities/ComputeStereographicProjection.h index 8a049886..617e7857 100644 --- a/Source/EbsdLib/Utilities/ComputeStereographicProjection.h +++ b/Source/EbsdLib/Utilities/ComputeStereographicProjection.h @@ -36,31 +36,31 @@ #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Utilities/PoleFigureUtilities.h" -namespace Stereographic::Utils +namespace stereographic::utils { template -EbsdLib::Matrix3X1 StereoToSpherical(const EbsdLib::Matrix3X1& stereo) +ebsdlib::Matrix3X1 StereoToSpherical(const ebsdlib::Matrix3X1& stereo) { T sumOfSquares = stereo.dot(); return {(2.0 * stereo[0]) / (1 + sumOfSquares), (2.0 * stereo[1]) / (1 + sumOfSquares), (1 - sumOfSquares) / (1 + sumOfSquares)}; } template -EbsdLib::Matrix3X1 StereoToSpherical(T x, T y) +ebsdlib::Matrix3X1 StereoToSpherical(T x, T y) { T sumOfSquares = x * x + y * y; return {(2.0 * x) / (1 + sumOfSquares), (2.0 * y) / (1 + sumOfSquares), (1 - sumOfSquares) / (1 + sumOfSquares)}; } template -EbsdLib::Matrix3X1 SphericalToStereo(const EbsdLib::Matrix3X1& spherical) +ebsdlib::Matrix3X1 SphericalToStereo(const ebsdlib::Matrix3X1& spherical) { return {spherical[0] / (1 + spherical[2]), spherical[1] / (1 + spherical[2]), 0.0}; } template -EbsdLib::Matrix3X1 SphericalToStereo(T x, T y, T z) +ebsdlib::Matrix3X1 SphericalToStereo(T x, T y, T z) { return {x / (1 + z), y / (1 + z), 0.0}; } @@ -71,10 +71,10 @@ EbsdLib::Matrix3X1 SphericalToStereo(T x, T y, T z) * @return */ template -std::vector> TransformUnitSphereToStereographicCoords(const std::vector>& points) +std::vector> TransformUnitSphereToStereographicCoords(const std::vector>& points) { - using Point3DType = EbsdLib::Matrix3X1; - std::vector> stereoPts; + using Point3DType = ebsdlib::Matrix3X1; + std::vector> stereoPts; for(const auto& point : points) { @@ -91,8 +91,10 @@ std::vector> TransformUnitSphereToStereographicCoords(cons return stereoPts; } -} // namespace Stereographic::Utils +} // namespace stereographic::utils +namespace ebsdlib +{ class EbsdLib_EXPORT ComputeStereographicProjection { public: @@ -102,7 +104,7 @@ class EbsdLib_EXPORT ComputeStereographicProjection * @param config * @param intensity */ - ComputeStereographicProjection(EbsdLib::FloatArrayType* xyzCoords, PoleFigureConfiguration_t* config, EbsdLib::DoubleArrayType* intensity); + ComputeStereographicProjection(ebsdlib::FloatArrayType* xyzCoords, PoleFigureConfiguration_t* config, ebsdlib::DoubleArrayType* intensity); virtual ~ComputeStereographicProjection(); @@ -118,9 +120,9 @@ class EbsdLib_EXPORT ComputeStereographicProjection ComputeStereographicProjection(); private: - EbsdLib::FloatArrayType* m_XYZCoords = nullptr; + ebsdlib::FloatArrayType* m_XYZCoords = nullptr; PoleFigureConfiguration_t* m_Config = nullptr; - EbsdLib::DoubleArrayType* m_Intensity = nullptr; + ebsdlib::DoubleArrayType* m_Intensity = nullptr; public: ComputeStereographicProjection(const ComputeStereographicProjection&) = delete; // Copy Constructor Not Implemented @@ -128,3 +130,4 @@ class EbsdLib_EXPORT ComputeStereographicProjection ComputeStereographicProjection& operator=(const ComputeStereographicProjection&) = delete; // Copy Assignment Not Implemented ComputeStereographicProjection& operator=(ComputeStereographicProjection&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/FiraSansRegular.hpp b/Source/EbsdLib/Utilities/FiraSansRegular.hpp index e788b1c4..5528123f 100644 --- a/Source/EbsdLib/Utilities/FiraSansRegular.hpp +++ b/Source/EbsdLib/Utilities/FiraSansRegular.hpp @@ -1,6 +1,6 @@ #pragma once #include -namespace EbsdLib::fonts +namespace ebsdlib::fonts { // clang-format off char const k_FiraSansRegularBase64 [] = @@ -7384,4 +7384,4 @@ namespace EbsdLib::fonts "sECIWLEDZESxJgGIUVi6CIAAAQRAiGNUWLEDAERZWVlZQAxZCEUIMwclBRkEBQwquAH/hbAE" "jbECAESxBWREAAAAAAAAAQAAAAA="; // clang-format on -} // namespace EbsdLib::fonts +} // namespace ebsdlib::fonts diff --git a/Source/EbsdLib/Utilities/Fonts.cpp b/Source/EbsdLib/Utilities/Fonts.cpp index 8b89041a..cfceee6c 100644 --- a/Source/EbsdLib/Utilities/Fonts.cpp +++ b/Source/EbsdLib/Utilities/Fonts.cpp @@ -4,7 +4,7 @@ #include "LatoBold.hpp" #include "LatoRegular.hpp" -namespace EbsdLib::fonts +namespace ebsdlib::fonts { std::vector GetFiraSansRegular() @@ -28,4 +28,4 @@ std::vector GetLatoBold() return fontData; } -} // namespace EbsdLib::fonts +} // namespace ebsdlib::fonts diff --git a/Source/EbsdLib/Utilities/Fonts.hpp b/Source/EbsdLib/Utilities/Fonts.hpp index b1e2b977..a1546485 100644 --- a/Source/EbsdLib/Utilities/Fonts.hpp +++ b/Source/EbsdLib/Utilities/Fonts.hpp @@ -4,7 +4,7 @@ #include -namespace EbsdLib::fonts +namespace ebsdlib::fonts { EbsdLib_EXPORT std::vector GetFiraSansRegular(); @@ -45,4 +45,4 @@ inline void Base64Decode(char const* input, std::vector& output) } } } -} // namespace EbsdLib::fonts +} // namespace ebsdlib::fonts diff --git a/Source/EbsdLib/Utilities/LambertUtilities.cpp b/Source/EbsdLib/Utilities/LambertUtilities.cpp index 62754609..cf3f75b9 100644 --- a/Source/EbsdLib/Utilities/LambertUtilities.cpp +++ b/Source/EbsdLib/Utilities/LambertUtilities.cpp @@ -37,6 +37,8 @@ #include "EbsdLib/Math/EbsdLibMath.h" +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -53,7 +55,7 @@ LambertUtilities::~LambertUtilities() = default; int32_t LambertUtilities::LambertSquareVertToSphereVert(float* vert, Hemisphere hemi) { static const float epsilon = 0.00001f; - static const float L = EbsdLib::Constants::k_SqrtHalfPiF; + static const float L = ebsdlib::constants::k_SqrtHalfPiF; static const float r = 1.0f; // radius of unit sphere float x = 0.0f; @@ -82,19 +84,19 @@ int32_t LambertUtilities::LambertSquareVertToSphereVert(float* vert, Hemisphere } else if(std::abs(b) <= std::abs(a)) { - float var0 = (2.0f * a / EbsdLib::Constants::k_PiF) * std::sqrt(EbsdLib::Constants::k_PiF - (a * a / r * r)); - float var1 = b * EbsdLib::Constants::k_PiF / (4.0f * a); + float var0 = (2.0f * a / ebsdlib::constants::k_PiF) * std::sqrt(ebsdlib::constants::k_PiF - (a * a / r * r)); + float var1 = b * ebsdlib::constants::k_PiF / (4.0f * a); x = var0 * std::cos(var1); y = var0 * std::sin(var1); - z = hemiFactor * ((2 * a * a / EbsdLib::Constants::k_PiF * r) - r); + z = hemiFactor * ((2 * a * a / ebsdlib::constants::k_PiF * r) - r); } else if(std::abs(a) <= std::abs(b)) { - float var0 = (2.0f * b / EbsdLib::Constants::k_PiF) * std::sqrt(EbsdLib::Constants::k_PiF - (b * b / r * r)); - float var1 = a * EbsdLib::Constants::k_PiF / (4.0f * b); + float var0 = (2.0f * b / ebsdlib::constants::k_PiF) * std::sqrt(ebsdlib::constants::k_PiF - (b * b / r * r)); + float var1 = a * ebsdlib::constants::k_PiF / (4.0f * b); x = var0 * std::sin(var1); y = var0 * std::cos(var1); - z = hemiFactor * ((2 * b * b / EbsdLib::Constants::k_PiF * r) - r); + z = hemiFactor * ((2 * b * b / ebsdlib::constants::k_PiF * r) - r); } if(std::abs(x * x + y * y + z * z - 1.0f) > epsilon) diff --git a/Source/EbsdLib/Utilities/LambertUtilities.h b/Source/EbsdLib/Utilities/LambertUtilities.h index ec7125ec..2359e2ba 100644 --- a/Source/EbsdLib/Utilities/LambertUtilities.h +++ b/Source/EbsdLib/Utilities/LambertUtilities.h @@ -35,7 +35,8 @@ #include #include "EbsdLib/EbsdLib.h" - +namespace ebsdlib +{ class EbsdLib_EXPORT LambertUtilities { public: @@ -89,3 +90,4 @@ class EbsdLib_EXPORT LambertUtilities private: }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/LatoBold.hpp b/Source/EbsdLib/Utilities/LatoBold.hpp index 013943c9..f289d1fb 100644 --- a/Source/EbsdLib/Utilities/LatoBold.hpp +++ b/Source/EbsdLib/Utilities/LatoBold.hpp @@ -1,6 +1,6 @@ #pragma once #include -namespace EbsdLib::fonts +namespace ebsdlib::fonts { // clang-format off char const k_LatoBoldBase64 [] = @@ -2262,4 +2262,4 @@ namespace EbsdLib::fonts "AAEAFAAWAAAAAAAAAAEAAAAA"; // clang-format on -} // namespace EbsdLib::fonts +} // namespace ebsdlib::fonts diff --git a/Source/EbsdLib/Utilities/LatoRegular.hpp b/Source/EbsdLib/Utilities/LatoRegular.hpp index ad9db575..972cd5ce 100644 --- a/Source/EbsdLib/Utilities/LatoRegular.hpp +++ b/Source/EbsdLib/Utilities/LatoRegular.hpp @@ -1,6 +1,6 @@ #pragma once #include -namespace EbsdLib::fonts +namespace ebsdlib::fonts { // clang-format off char const k_LatoRegularBase64 [] = @@ -2232,4 +2232,4 @@ namespace EbsdLib::fonts "AGoAcQB2ANsA3ADeAN8A4ADiAOMAAQABAEkAAgABABQAFgAAAAAAAAABAAAAAA=="; // clang-format on -} // namespace EbsdLib::fonts +} // namespace ebsdlib::fonts diff --git a/Source/EbsdLib/Utilities/ModifiedLambertProjection.cpp b/Source/EbsdLib/Utilities/ModifiedLambertProjection.cpp index aa6017c0..cfa4045e 100644 --- a/Source/EbsdLib/Utilities/ModifiedLambertProjection.cpp +++ b/Source/EbsdLib/Utilities/ModifiedLambertProjection.cpp @@ -42,6 +42,8 @@ #define WRITE_LAMBERT_SQUARE_COORD_VTK 0 +using namespace ebsdlib; + namespace { double calcInterpolatedValue(const ModifiedLambertProjection& self, const std::array& xyz) @@ -80,7 +82,7 @@ ModifiedLambertProjection::~ModifiedLambertProjection() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -ModifiedLambertProjection::Pointer ModifiedLambertProjection::LambertBallToSquare(EbsdLib::FloatArrayType* coords, int dimension, float sphereRadius) +ModifiedLambertProjection::Pointer ModifiedLambertProjection::LambertBallToSquare(ebsdlib::FloatArrayType* coords, int dimension, float sphereRadius) { size_t npoints = coords->getNumberOfTuples(); @@ -152,7 +154,7 @@ void ModifiedLambertProjection::initializeSquares(int dims, float sphereRadius) m_Dimension = dims; m_SphereRadius = sphereRadius; // We want half the sphere area for each square because each square represents a hemisphere. - float halfSphereArea = 4.0f * EbsdLib::Constants::k_PiF * sphereRadius * sphereRadius / 2.0f; + float halfSphereArea = 4.0f * ebsdlib::constants::k_PiF * sphereRadius * sphereRadius / 2.0f; // The length of a side of the square is the square root of the area float squareEdge = sqrt(halfSphereArea); @@ -165,9 +167,9 @@ void ModifiedLambertProjection::initializeSquares(int dims, float sphereRadius) std::vector tDims(2, m_Dimension); std::vector cDims(1, 1); - m_NorthSquare = EbsdLib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_NorthSquare", true); + m_NorthSquare = ebsdlib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_NorthSquare", true); m_NorthSquare->initializeWithZeros(); - m_SouthSquare = EbsdLib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_SouthSquare", true); + m_SouthSquare = ebsdlib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambert_SouthSquare", true); m_SouthSquare->initializeWithZeros(); } #ifdef DATA_ARRAY_ENABLE_HDF5_IO @@ -438,15 +440,15 @@ bool ModifiedLambertProjection::getSquareCoord(const float* xyz, float* sqCoord) } if(std::fabs(xyz[0]) >= std::fabs(xyz[1])) { - sqCoord[0] = static_cast((xyz[0] / std::fabs(xyz[0])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * EbsdLib::Constants::k_HalfOfSqrtPiD); + sqCoord[0] = static_cast((xyz[0] / std::fabs(xyz[0])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * ebsdlib::constants::k_HalfOfSqrtPiD); sqCoord[1] = - static_cast((xyz[0] / std::fabs(xyz[0])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * ((EbsdLib::Constants::k_2OverSqrtPiD)*std::atan(xyz[1] / xyz[0]))); + static_cast((xyz[0] / std::fabs(xyz[0])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * ((ebsdlib::constants::k_2OverSqrtPiD)*std::atan(xyz[1] / xyz[0]))); } else { sqCoord[0] = - static_cast((xyz[1] / std::fabs(xyz[1])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * ((EbsdLib::Constants::k_2OverSqrtPiD)*std::atan(xyz[0] / xyz[1]))); - sqCoord[1] = static_cast((xyz[1] / std::fabs(xyz[1])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * (EbsdLib::Constants::k_HalfOfSqrtPiD)); + static_cast((xyz[1] / std::fabs(xyz[1])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * ((ebsdlib::constants::k_2OverSqrtPiD)*std::atan(xyz[0] / xyz[1]))); + sqCoord[1] = static_cast((xyz[1] / std::fabs(xyz[1])) * std::sqrt(2.0 * m_SphereRadius * (m_SphereRadius + (xyz[2] * adjust))) * (ebsdlib::constants::k_HalfOfSqrtPiD)); } if(sqCoord[0] >= m_MaxCoord) @@ -541,7 +543,7 @@ void ModifiedLambertProjection::normalizeSquaresToMRD() // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void ModifiedLambertProjection::createStereographicProjection(int dim, EbsdLib::DoubleArrayType& stereoIntensity) +void ModifiedLambertProjection::createStereographicProjection(int dim, ebsdlib::DoubleArrayType& stereoIntensity) { int xpoints = dim; int ypoints = dim; @@ -588,11 +590,11 @@ void ModifiedLambertProjection::createStereographicProjection(int dim, EbsdLib:: // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::DoubleArrayType::Pointer ModifiedLambertProjection::createStereographicProjection(int dim) +ebsdlib::DoubleArrayType::Pointer ModifiedLambertProjection::createStereographicProjection(int dim) { std::vector tDims(2, dim); std::vector cDims(1, 1); - EbsdLib::DoubleArrayType::Pointer stereoIntensity = EbsdLib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambertProjection_StereographicProjection", true); + ebsdlib::DoubleArrayType::Pointer stereoIntensity = ebsdlib::DoubleArrayType::CreateArray(tDims, cDims, "ModifiedLambertProjection_StereographicProjection", true); createStereographicProjection(dim, *stereoIntensity); return stereoIntensity; } @@ -689,13 +691,13 @@ float ModifiedLambertProjection::getSphereRadius() const } // ----------------------------------------------------------------------------- -EbsdLib::DoubleArrayType::Pointer ModifiedLambertProjection::getNorthSquare() const +ebsdlib::DoubleArrayType::Pointer ModifiedLambertProjection::getNorthSquare() const { return m_NorthSquare; } // ----------------------------------------------------------------------------- -EbsdLib::DoubleArrayType::Pointer ModifiedLambertProjection::getSouthSquare() const +ebsdlib::DoubleArrayType::Pointer ModifiedLambertProjection::getSouthSquare() const { return m_SouthSquare; } diff --git a/Source/EbsdLib/Utilities/ModifiedLambertProjection.h b/Source/EbsdLib/Utilities/ModifiedLambertProjection.h index 8048579f..c92191bc 100644 --- a/Source/EbsdLib/Utilities/ModifiedLambertProjection.h +++ b/Source/EbsdLib/Utilities/ModifiedLambertProjection.h @@ -45,6 +45,8 @@ #include "H5Support/H5SupportTypeDefs.h" #endif +namespace ebsdlib +{ /** * @class ModifiedLambertProjection ModifiedLambertProjection.h DREAM3DLib/Common/ModifiedLambertProjection.h * @brief This class holds a pair of Modified Lambert Projection images. Based off the paper @@ -91,7 +93,7 @@ class EbsdLib_EXPORT ModifiedLambertProjection * @param sphereRadius The radius of the sphere from where the coordinates are coming from. * @return */ - static Pointer LambertBallToSquare(EbsdLib::FloatArrayType* coords, int dimension, float sphereRadius); + static Pointer LambertBallToSquare(ebsdlib::FloatArrayType* coords, int dimension, float sphereRadius); /** * @brief Getter property for Dimension @@ -115,13 +117,13 @@ class EbsdLib_EXPORT ModifiedLambertProjection * @brief Getter property for NorthSquare * @return Value of NorthSquare */ - EbsdLib::DoubleArrayType::Pointer getNorthSquare() const; + ebsdlib::DoubleArrayType::Pointer getNorthSquare() const; /** * @brief Getter property for SouthSquare * @return Value of SouthSquare */ - EbsdLib::DoubleArrayType::Pointer getSouthSquare() const; + ebsdlib::DoubleArrayType::Pointer getSouthSquare() const; /** * @brief initializeSquares @@ -206,9 +208,9 @@ class EbsdLib_EXPORT ModifiedLambertProjection * @brief createStereographicProjection * @param stereoGraphicProjectionDims */ - EbsdLib::DoubleArrayType::Pointer createStereographicProjection(int dim); + ebsdlib::DoubleArrayType::Pointer createStereographicProjection(int dim); - void createStereographicProjection(int dim, EbsdLib::DoubleArrayType& stereoIntensity); + void createStereographicProjection(int dim, ebsdlib::DoubleArrayType& stereoIntensity); /** * @brief Creates a circular Projection @@ -231,8 +233,8 @@ class EbsdLib_EXPORT ModifiedLambertProjection float m_MaxCoord; float m_MinCoord; - EbsdLib::DoubleArrayType::Pointer m_NorthSquare; - EbsdLib::DoubleArrayType::Pointer m_SouthSquare; + ebsdlib::DoubleArrayType::Pointer m_NorthSquare; + ebsdlib::DoubleArrayType::Pointer m_SouthSquare; public: ModifiedLambertProjection(const ModifiedLambertProjection&) = delete; // Copy Constructor Not Implemented @@ -240,3 +242,4 @@ class EbsdLib_EXPORT ModifiedLambertProjection ModifiedLambertProjection& operator=(const ModifiedLambertProjection&) = delete; // Copy Assignment Not Implemented ModifiedLambertProjection& operator=(ModifiedLambertProjection&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/ModifiedLambertProjection3D.hpp b/Source/EbsdLib/Utilities/ModifiedLambertProjection3D.hpp index 05383b61..974a8e28 100644 --- a/Source/EbsdLib/Utilities/ModifiedLambertProjection3D.hpp +++ b/Source/EbsdLib/Utilities/ModifiedLambertProjection3D.hpp @@ -38,8 +38,10 @@ #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/ArrayHelpers.hpp" -namespace LPs = EbsdLib::LambertParametersType; +namespace LPs = ebsdlib::LambertParametersType; +namespace ebsdlib +{ /** * @brief The ModifiedLambertProjection3D class provides methods to convert between * a 3D Lambert Cube and a Sphere (XYZ) coordinates. @@ -399,3 +401,4 @@ class ModifiedLambertProjection3D ModifiedLambertProjection3D(const ModifiedLambertProjection3D&); // Copy Constructor Not Implemented void operator=(const ModifiedLambertProjection3D&); // Move assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.cpp b/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.cpp index 06afcdfc..840ef653 100644 --- a/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.cpp +++ b/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.cpp @@ -47,6 +47,8 @@ using namespace H5Support; #endif +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -623,7 +625,7 @@ int ModifiedLambertProjectionArray::writeH5Data(hid_t parentId, const std::vecto { return -2; } - hid_t gid = H5Utilities::createGroup(parentId, EbsdLib::StringConstants::GBCD); + hid_t gid = H5Utilities::createGroup(parentId, ebsdlib::StringConstants::GBCD); if(gid < 0) { return -1; @@ -638,8 +640,8 @@ int ModifiedLambertProjectionArray::writeH5Data(hid_t parentId, const std::vecto Create2DExpandableDataset(gid, dsetName, static_cast(lambertElements), lambertElements * 2, tmp->getNorthSquare()->getPointer(0), tmp->getSouthSquare()->getPointer(0)); - EbsdLib::DoubleArrayType* north = nullptr; - EbsdLib::DoubleArrayType* south = nullptr; + ebsdlib::DoubleArrayType* north = nullptr; + ebsdlib::DoubleArrayType* south = nullptr; // We start numbering our phases at 1. Anything in slot 0 is considered "Dummy" or invalid for(size_t i = 1; i < m_ModifiedLambertProjectionArray.size(); ++i) @@ -665,7 +667,7 @@ int ModifiedLambertProjectionArray::readH5Data(hid_t parentId) // bool ok = false; int err = 0; std::string statsType; - hid_t gid = H5Utilities::openHDF5Object(parentId, EbsdLib::StringConstants::Statistics); + hid_t gid = H5Utilities::openHDF5Object(parentId, ebsdlib::StringConstants::Statistics); if(gid < 0) { return err; @@ -684,7 +686,7 @@ int ModifiedLambertProjectionArray::readH5Data(hid_t parentId) // int index = 0; statsType = ""; // index = std::string( *iter ).toInt(&ok, 10); - H5Lite::readStringAttribute(gid, name, EbsdLib::StringConstants::StatsType, statsType); + H5Lite::readStringAttribute(gid, name, ebsdlib::StringConstants::StatsType, statsType); hid_t statId = H5Utilities::openHDF5Object(gid, name); if(statId < 0) { @@ -713,9 +715,9 @@ int ModifiedLambertProjectionArray::writeXdmfAttribute(std::stringstream& out, i // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -std::string ModifiedLambertProjectionArray::getInfoString(EbsdLib::InfoStringFormat format) const +std::string ModifiedLambertProjectionArray::getInfoString(ebsdlib::InfoStringFormat format) const { - if(format == EbsdLib::HtmlFormat) + if(format == ebsdlib::HtmlFormat) { return getToolTipGenerator().generateHTML(); } @@ -725,9 +727,9 @@ std::string ModifiedLambertProjectionArray::getInfoString(EbsdLib::InfoStringFor // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::ToolTipGenerator ModifiedLambertProjectionArray::getToolTipGenerator() const +ebsdlib::ToolTipGenerator ModifiedLambertProjectionArray::getToolTipGenerator() const { - EbsdLib::ToolTipGenerator toolTipGen; + ebsdlib::ToolTipGenerator toolTipGen; toolTipGen.addTitle("Attribute Array Info"); toolTipGen.addValue("Name", getName()); diff --git a/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.h b/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.h index 6869905b..384df16e 100644 --- a/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.h +++ b/Source/EbsdLib/Utilities/ModifiedLambertProjectionArray.h @@ -48,6 +48,8 @@ #include "H5Support/H5SupportTypeDefs.h" #endif +namespace ebsdlib +{ /** * @brief The ModifiedLambertProjectionArray class */ @@ -372,14 +374,14 @@ class EbsdLib_EXPORT ModifiedLambertProjectionArray * @return Returns a formatted string that contains general infomation about * the instance of the object. */ - std::string getInfoString(EbsdLib::InfoStringFormat format) const; + std::string getInfoString(ebsdlib::InfoStringFormat format) const; /** * @brief Returns a ToolTipGenerator for creating HTML tooltip tables * with values populated to match the current DataArray. * @return */ - EbsdLib::ToolTipGenerator getToolTipGenerator() const; + ebsdlib::ToolTipGenerator getToolTipGenerator() const; protected: ModifiedLambertProjectionArray(); @@ -397,3 +399,4 @@ class EbsdLib_EXPORT ModifiedLambertProjectionArray ModifiedLambertProjectionArray& operator=(const ModifiedLambertProjectionArray&) = delete; // Copy Assignment Not Implemented ModifiedLambertProjectionArray& operator=(ModifiedLambertProjectionArray&&) = delete; // Move Assignment Not Implemented }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/PoleFigureData.cpp b/Source/EbsdLib/Utilities/PoleFigureData.cpp index 117e4003..25f31655 100644 --- a/Source/EbsdLib/Utilities/PoleFigureData.cpp +++ b/Source/EbsdLib/Utilities/PoleFigureData.cpp @@ -36,6 +36,8 @@ #include "PoleFigureData.h" #include +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- diff --git a/Source/EbsdLib/Utilities/PoleFigureData.h b/Source/EbsdLib/Utilities/PoleFigureData.h index 60a55bea..e180eae2 100644 --- a/Source/EbsdLib/Utilities/PoleFigureData.h +++ b/Source/EbsdLib/Utilities/PoleFigureData.h @@ -40,7 +40,8 @@ #include #include "EbsdLib/EbsdLib.h" - +namespace ebsdlib +{ /** * @class PoleFigureData PoleFigureData.h StatsGenerator/PoleFigureData.h * @brief @@ -78,3 +79,4 @@ class EbsdLib_EXPORT PoleFigureData private: }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/PoleFigureUtilities.cpp b/Source/EbsdLib/Utilities/PoleFigureUtilities.cpp index 09eda91a..26b4b327 100644 --- a/Source/EbsdLib/Utilities/PoleFigureUtilities.cpp +++ b/Source/EbsdLib/Utilities/PoleFigureUtilities.cpp @@ -47,6 +47,8 @@ #define WRITE_XYZ_SPHERE_COORD_VTK 0 #define WRITE_LAMBERT_SQUARES 0 +using namespace ebsdlib; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -60,7 +62,7 @@ PoleFigureUtilities::~PoleFigureUtilities() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -int writeVtkFile(EbsdLib::FloatArrayType* xyz, const std::string& filename) +int writeVtkFile(ebsdlib::FloatArrayType* xyz, const std::string& filename) { std::ofstream out(filename, std::ios_base::out); @@ -86,10 +88,10 @@ int writeVtkFile(EbsdLib::FloatArrayType* xyz, const std::string& filename) // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -EbsdLib::UInt8ArrayType::Pointer PoleFigureUtilities::CreateColorImage(EbsdLib::DoubleArrayType* data, int width, int height, int nColors, const std::string& name, double min, double max) +ebsdlib::UInt8ArrayType::Pointer PoleFigureUtilities::CreateColorImage(ebsdlib::DoubleArrayType* data, int width, int height, int nColors, const std::string& name, double min, double max) { std::vector dims(1, 4); - EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(static_cast(width * height), dims, name, true); + ebsdlib::UInt8ArrayType::Pointer image = ebsdlib::UInt8ArrayType::CreateArray(static_cast(width * height), dims, name, true); PoleFigureConfiguration_t config; config.imageDim = width; config.numColors = nColors; @@ -106,7 +108,7 @@ EbsdLib::UInt8ArrayType::Pointer PoleFigureUtilities::CreateColorImage(EbsdLib:: // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PoleFigureUtilities::CreateColorImage(EbsdLib::DoubleArrayType* data, PoleFigureConfiguration_t& config, EbsdLib::UInt8ArrayType* image) +void PoleFigureUtilities::CreateColorImage(ebsdlib::DoubleArrayType* data, PoleFigureConfiguration_t& config, ebsdlib::UInt8ArrayType* image) { int width = config.imageDim; int height = config.imageDim; @@ -175,7 +177,7 @@ void PoleFigureUtilities::CreateColorImage(EbsdLib::DoubleArrayType* data, PoleF b = colors[3 * bin + 2]; } - rgbaPtr[idx] = EbsdLib::RgbColor::dRgb(static_cast(r * 255.0f), static_cast(g * 255.0f), static_cast(b * 255.0f), 255); + rgbaPtr[idx] = ebsdlib::RgbColor::dRgb(static_cast(r * 255.0f), static_cast(g * 255.0f), static_cast(b * 255.0f), 255); } else // Outside the Circle - Set pixel to White { @@ -188,19 +190,19 @@ void PoleFigureUtilities::CreateColorImage(EbsdLib::DoubleArrayType* data, PoleF // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PoleFigureUtilities::GenerateHexPoleFigures(EbsdLib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, EbsdLib::DoubleArrayType::Pointer& intensity0001, - EbsdLib::DoubleArrayType::Pointer& intensity1010, EbsdLib::DoubleArrayType::Pointer& intensity1120) +void PoleFigureUtilities::GenerateHexPoleFigures(ebsdlib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, ebsdlib::DoubleArrayType::Pointer& intensity0001, + ebsdlib::DoubleArrayType::Pointer& intensity1010, ebsdlib::DoubleArrayType::Pointer& intensity1120) { size_t numOrientations = eulers->getNumberOfTuples(); // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for HEX ONLY, <0001> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz0001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<0001>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz0001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<0001>_xyzCoords", true); // this is size for HEX ONLY, <10-10> Family - EbsdLib::FloatArrayType::Pointer xyz1010 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 6, dims, "TEMP_<1010>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz1010 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 6, dims, "TEMP_<1010>_xyzCoords", true); // this is size for HEX ONLY, <11-20> Family - EbsdLib::FloatArrayType::Pointer xyz1120 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 6, dims, "TEMP_<1120>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz1120 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 6, dims, "TEMP_<1120>_xyzCoords", true); float sphereRadius = 1.0f; @@ -216,15 +218,15 @@ void PoleFigureUtilities::GenerateHexPoleFigures(EbsdLib::FloatArrayType* eulers // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere ModifiedLambertProjection::Pointer lambert = ModifiedLambertProjection::LambertBallToSquare(xyz0001.get(), lambertDimension, sphereRadius); // Now create the intensity image that will become the actual Pole figure image - EbsdLib::DoubleArrayType::Pointer poleFigurePtr = lambert->createStereographicProjection(poleFigureDim); + ebsdlib::DoubleArrayType::Pointer poleFigurePtr = lambert->createStereographicProjection(poleFigureDim); poleFigurePtr->setName("PoleFigure_<0001>"); intensity0001.swap(poleFigurePtr); #if WRITE_LAMBERT_SQUARES size_t dims[3] = {lambert->getDimension(), lambert->getDimension(), 1}; FloatVec3Type res = {lambert->getStepSize(), lambert->getStepSize(), lambert->getStepSize()}; - EbsdLib::DoubleArrayType::Pointer north = lambert->getNorthSquare(); - EbsdLib::DoubleArrayType::Pointer south = lambert->getSouthSquare(); + ebsdlib::DoubleArrayType::Pointer north = lambert->getNorthSquare(); + ebsdlib::DoubleArrayType::Pointer south = lambert->getSouthSquare(); VtkRectilinearGridWriter::WriteDataArrayToFile("/tmp/ModifiedLambert_North.vtk", north.get(), dims, res, "double", true); VtkRectilinearGridWriter::WriteDataArrayToFile("/tmp/ModifiedLambert_South.vtk", south.get(), dims, res, "double", true); #endif @@ -245,19 +247,19 @@ void PoleFigureUtilities::GenerateHexPoleFigures(EbsdLib::FloatArrayType* eulers // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void PoleFigureUtilities::GenerateOrthoPoleFigures(EbsdLib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, EbsdLib::DoubleArrayType::Pointer& intensity100, - EbsdLib::DoubleArrayType::Pointer& intensity010, EbsdLib::DoubleArrayType::Pointer& intensity001) +void PoleFigureUtilities::GenerateOrthoPoleFigures(ebsdlib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, ebsdlib::DoubleArrayType::Pointer& intensity100, + ebsdlib::DoubleArrayType::Pointer& intensity010, ebsdlib::DoubleArrayType::Pointer& intensity001) { size_t numOrientations = eulers->getNumberOfTuples(); // Create an Array to hold the XYZ Coordinates which are the coords on the sphere. // this is size for ORTHO ONLY, <100> Family std::vector dims(1, 3); - EbsdLib::FloatArrayType::Pointer xyz100 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<100>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz100 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<100>_xyzCoords", true); // this is size for ORTHO ONLY, <010> Family - EbsdLib::FloatArrayType::Pointer xyz010 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<010>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz010 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<010>_xyzCoords", true); // this is size for ORTHO ONLY, <001> Family - EbsdLib::FloatArrayType::Pointer xyz001 = EbsdLib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<001>_xyzCoords", true); + ebsdlib::FloatArrayType::Pointer xyz001 = ebsdlib::FloatArrayType::CreateArray(numOrientations * 2, dims, "TEMP_<001>_xyzCoords", true); float sphereRadius = 1.0f; @@ -273,15 +275,15 @@ void PoleFigureUtilities::GenerateOrthoPoleFigures(EbsdLib::FloatArrayType* eule // Generate the modified Lambert projection images (Squares, 2 of them, 1 for northern hemisphere, 1 for southern hemisphere ModifiedLambertProjection::Pointer lambert = ModifiedLambertProjection::LambertBallToSquare(xyz100.get(), lambertDimension, sphereRadius); // Now create the intensity image that will become the actual Pole figure image - EbsdLib::DoubleArrayType::Pointer poleFigurePtr = lambert->createStereographicProjection(poleFigureDim); + ebsdlib::DoubleArrayType::Pointer poleFigurePtr = lambert->createStereographicProjection(poleFigureDim); poleFigurePtr->setName("PoleFigure_<100>"); intensity100.swap(poleFigurePtr); #if WRITE_LAMBERT_SQUARES size_t dims[3] = {lambert->getDimension(), lambert->getDimension(), 1}; FloatVec3Type res = {lambert->getStepSize(), lambert->getStepSize(), lambert->getStepSize()}; - EbsdLib::DoubleArrayType::Pointer north = lambert->getNorthSquare(); - EbsdLib::DoubleArrayType::Pointer south = lambert->getSouthSquare(); + ebsdlib::DoubleArrayType::Pointer north = lambert->getNorthSquare(); + ebsdlib::DoubleArrayType::Pointer south = lambert->getSouthSquare(); VtkRectilinearGridWriter::WriteDataArrayToFile("/tmp/ModifiedLambert_North.vtk", north.get(), dims, res, "double", true); VtkRectilinearGridWriter::WriteDataArrayToFile("/tmp/ModifiedLambert_South.vtk", south.get(), dims, res, "double", true); #endif @@ -304,7 +306,7 @@ void PoleFigureUtilities::GenerateOrthoPoleFigures(EbsdLib::FloatArrayType* eule // ----------------------------------------------------------------------------- GeneratePoleFigureRgbaImageImpl::GeneratePoleFigureRgbaImageImpl() = default; -GeneratePoleFigureRgbaImageImpl::GeneratePoleFigureRgbaImageImpl(EbsdLib::DoubleArrayType* intensity, PoleFigureConfiguration_t* config, EbsdLib::UInt8ArrayType* rgba) +GeneratePoleFigureRgbaImageImpl::GeneratePoleFigureRgbaImageImpl(ebsdlib::DoubleArrayType* intensity, PoleFigureConfiguration_t* config, ebsdlib::UInt8ArrayType* rgba) : m_Intensity(intensity) , m_Config(config) , m_Rgba(rgba) diff --git a/Source/EbsdLib/Utilities/PoleFigureUtilities.h b/Source/EbsdLib/Utilities/PoleFigureUtilities.h index 4ddeed08..37e1c358 100644 --- a/Source/EbsdLib/Utilities/PoleFigureUtilities.h +++ b/Source/EbsdLib/Utilities/PoleFigureUtilities.h @@ -43,6 +43,8 @@ #include #include +namespace ebsdlib +{ /** * @struct PoleFigureConfiguration_t * @brief This structure controls how Pole Figures are generated. The Order member @@ -60,7 +62,7 @@ */ struct PoleFigureConfiguration_t { - EbsdLib::FloatArrayType* eulers; ///<* The Euler Angles (in Radians) to use for the pole figure + ebsdlib::FloatArrayType* eulers; ///<* The Euler Angles (in Radians) to use for the pole figure int imageDim; ///<* The height/width of the generated pole figure int lambertDim; ///<* The dimensions in voxels of the Lambert Square used for interpolation int numColors; ///<* The number of colors to use in the Pole figure @@ -100,7 +102,7 @@ class EbsdLib_EXPORT PoleFigureUtilities * @param max * @return */ - static EbsdLib::UInt8ArrayType::Pointer CreateColorImage(EbsdLib::DoubleArrayType* data, int width, int height, int nColors, const std::string& name, double min, double max); + static ebsdlib::UInt8ArrayType::Pointer CreateColorImage(ebsdlib::DoubleArrayType* data, int width, int height, int nColors, const std::string& name, double min, double max); /** * @brief CreateColorImage @@ -108,7 +110,7 @@ class EbsdLib_EXPORT PoleFigureUtilities * @param config * @param image */ - static void CreateColorImage(EbsdLib::DoubleArrayType* data, PoleFigureConfiguration_t& config, EbsdLib::UInt8ArrayType* image); + static void CreateColorImage(ebsdlib::DoubleArrayType* data, PoleFigureConfiguration_t& config, ebsdlib::UInt8ArrayType* image); private: /** @@ -120,8 +122,8 @@ class EbsdLib_EXPORT PoleFigureUtilities * @param intensity1010 [output] * @param intensity1120 [output] */ - void GenerateHexPoleFigures(EbsdLib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, EbsdLib::DoubleArrayType::Pointer& intensity0001, - EbsdLib::DoubleArrayType::Pointer& intensity1010, EbsdLib::DoubleArrayType::Pointer& intensity1120); + void GenerateHexPoleFigures(ebsdlib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, ebsdlib::DoubleArrayType::Pointer& intensity0001, + ebsdlib::DoubleArrayType::Pointer& intensity1010, ebsdlib::DoubleArrayType::Pointer& intensity1120); /** * @brief GenerateHexPoleFigures @@ -132,8 +134,8 @@ class EbsdLib_EXPORT PoleFigureUtilities * @param intensity010 [output] * @param intensity001 [output] */ - void GenerateOrthoPoleFigures(EbsdLib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, EbsdLib::DoubleArrayType::Pointer& intensity100, - EbsdLib::DoubleArrayType::Pointer& intensity010, EbsdLib::DoubleArrayType::Pointer& intensity001); + void GenerateOrthoPoleFigures(ebsdlib::FloatArrayType* eulers, int lambertDimension, int poleFigureDim, ebsdlib::DoubleArrayType::Pointer& intensity100, + ebsdlib::DoubleArrayType::Pointer& intensity010, ebsdlib::DoubleArrayType::Pointer& intensity001); public: PoleFigureUtilities(const PoleFigureUtilities&) = delete; // Copy Constructor Not Implemented @@ -149,7 +151,7 @@ class EbsdLib_EXPORT PoleFigureUtilities class GeneratePoleFigureRgbaImageImpl { public: - GeneratePoleFigureRgbaImageImpl(EbsdLib::DoubleArrayType* intensity, PoleFigureConfiguration_t* config, EbsdLib::UInt8ArrayType* rgba); + GeneratePoleFigureRgbaImageImpl(ebsdlib::DoubleArrayType* intensity, PoleFigureConfiguration_t* config, ebsdlib::UInt8ArrayType* rgba); virtual ~GeneratePoleFigureRgbaImageImpl(); void operator()() const; @@ -158,7 +160,8 @@ class GeneratePoleFigureRgbaImageImpl GeneratePoleFigureRgbaImageImpl(); private: - EbsdLib::DoubleArrayType* m_Intensity = nullptr; + ebsdlib::DoubleArrayType* m_Intensity = nullptr; PoleFigureConfiguration_t* m_Config = nullptr; - EbsdLib::UInt8ArrayType* m_Rgba = nullptr; + ebsdlib::UInt8ArrayType* m_Rgba = nullptr; }; +} // namespace ebsdlib diff --git a/Source/EbsdLib/Utilities/ToolTipGenerator.cpp b/Source/EbsdLib/Utilities/ToolTipGenerator.cpp index be83f16b..5781c45b 100644 --- a/Source/EbsdLib/Utilities/ToolTipGenerator.cpp +++ b/Source/EbsdLib/Utilities/ToolTipGenerator.cpp @@ -34,7 +34,7 @@ #include -using namespace EbsdLib; +using namespace ebsdlib; // ----------------------------------------------------------------------------- // diff --git a/Source/EbsdLib/Utilities/ToolTipGenerator.h b/Source/EbsdLib/Utilities/ToolTipGenerator.h index a1697041..adda7436 100644 --- a/Source/EbsdLib/Utilities/ToolTipGenerator.h +++ b/Source/EbsdLib/Utilities/ToolTipGenerator.h @@ -38,7 +38,7 @@ #include "EbsdLib/EbsdLib.h" -namespace EbsdLib +namespace ebsdlib { /** * @class ToolTipGenerator ToolTipGenerator.h SIMPLib/Utilities/ToolTipGenerator.h @@ -132,4 +132,4 @@ class EbsdLib_EXPORT ToolTipGenerator std::string m_RowColorStr = "#FFFCEA"; std::vector m_Rows; }; -} // end namespace EbsdLib \ No newline at end of file +} // end namespace ebsdlib \ No newline at end of file diff --git a/Source/Test/AngImportTest.cpp b/Source/Test/AngImportTest.cpp index 7cda5880..9779a03f 100644 --- a/Source/Test/AngImportTest.cpp +++ b/Source/Test/AngImportTest.cpp @@ -32,6 +32,7 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include #include #include @@ -42,7 +43,6 @@ #ifdef EbsdLib_ENABLE_HDF5 #include "EbsdLib/IO/TSL/H5AngImporter.h" -#include "H5Support/H5Lite.h" #include "H5Support/H5Utilities.h" #endif @@ -50,136 +50,84 @@ #include "EbsdLib/Test/EbsdLibTestFileLocations.h" -class AngImportTest +using namespace ebsdlib; + +TEST_CASE("ebsdlib::AngImportTest-TestNormalFile", "[EbsdLib][AngImportTest]") +{ + // This is just a normal Ang file, well formed and should read without error + AngReader reader; + reader.setFileName(UnitTest::AngImportTest::TestFile1); + int err = reader.readFile(); + std::cout << reader.getErrorMessage(); + REQUIRE(err == 0); + + size_t numElements = reader.getNumberOfElements(); + REQUIRE(numElements == 160); + float* ptr = reader.getPhi1Pointer(); + REQUIRE(ptr[159] == 12.56637f); +} + +TEST_CASE("ebsdlib::AngImportTest-TestMissingHeaders", "[EbsdLib][AngImportTest]") { -public: - AngImportTest() = default; - virtual ~AngImportTest() = default; - EBSD_GET_NAME_OF_CLASS_DECL(AngImportTest) + AngReader reader; + reader.setFileName(UnitTest::AngImportTest::MissingHeader1); + int err = reader.readHeaderOnly(); + // It should read through this header just fine + REQUIRE(err > 0); - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES - fs::remove(UnitTest::AngImportTest::H5EbsdOutputFile); -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestMissingHeaders() - { - - AngReader reader; - reader.setFileName(UnitTest::AngImportTest::MissingHeader1); - int err = reader.readHeaderOnly(); - // It should read through this header just fine - DREAM3D_REQUIRE(err > 0) - - int value = reader.getNumEvenCols(); - DREAM3D_REQUIRE_EQUAL(value, -1) - - value = reader.getNumOddCols(); - DREAM3D_REQUIRE_EQUAL(value, -1) - - value = reader.getNumRows(); - DREAM3D_REQUIRE_EQUAL(value, -1) - - float step = reader.getXStep(); - DREAM3D_REQUIRE_EQUAL(step, 0.0f) - - step = reader.getYStep(); - DREAM3D_REQUIRE_EQUAL(step, 0.0f) - - err = reader.readFile(); - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, ==, -110) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestMissingGrid() - { - - AngReader reader; - reader.setFileName(UnitTest::AngImportTest::GridMissing); - int err = reader.readHeaderOnly(); - // It should read through this header just fine - DREAM3D_REQUIRE(err > 0) - - err = reader.readFile(); - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, ==, -300) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestHexGrid() - { - - AngReader reader; - reader.setFileName(UnitTest::AngImportTest::HexHeader); - int err = reader.readHeaderOnly(); - // It should read through this header just fine - DREAM3D_REQUIRE(err > 0) - - err = reader.readFile(); - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, ==, -400) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestShortFile() - { - AngReader reader; - reader.setFileName(UnitTest::AngImportTest::ShortFile); - int err = reader.readFile(); - // It should read through this header just fine but die when reading the file because there is not enough data being read - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, <, 0) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestNormalFile() - { - // This is just a normal Ang file, well formed and should read without error - AngReader reader; - reader.setFileName(UnitTest::AngImportTest::TestFile1); - int err = reader.readFile(); - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, ==, 0) - - size_t numElements = reader.getNumberOfElements(); - DREAM3D_REQUIRED(numElements, ==, 160) - float* ptr = reader.getPhi1Pointer(); - DREAM3D_REQUIRED(ptr[159], ==, 12.56637f) - } - - void operator()() - { - int err = EXIT_SUCCESS; - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - DREAM3D_REGISTER_TEST(TestNormalFile()) - DREAM3D_REGISTER_TEST(TestMissingHeaders()) - DREAM3D_REGISTER_TEST(TestHexGrid()) - DREAM3D_REGISTER_TEST(TestMissingGrid()) - DREAM3D_REGISTER_TEST(TestShortFile()) - - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - } - -public: - AngImportTest(const AngImportTest&) = delete; // Copy Constructor Not Implemented - AngImportTest(AngImportTest&&) = delete; // Move Constructor Not Implemented - AngImportTest& operator=(const AngImportTest&) = delete; // Copy Assignment Not Implemented - AngImportTest& operator=(AngImportTest&&) = delete; // Move Assignment Not Implemented -}; + int value = reader.getNumEvenCols(); + REQUIRE(value == -1); + + value = reader.getNumOddCols(); + REQUIRE(value == -1); + + value = reader.getNumRows(); + REQUIRE(value == -1); + + float step = reader.getXStep(); + REQUIRE(step == 0.0f); + + step = reader.getYStep(); + REQUIRE(step == 0.0f); + + err = reader.readFile(); + std::cout << reader.getErrorMessage(); + REQUIRE(err == -110); +} + +TEST_CASE("ebsdlib::AngImportTest-TestHexGrid", "[EbsdLib][AngImportTest]") +{ + AngReader reader; + reader.setFileName(UnitTest::AngImportTest::HexHeader); + int err = reader.readHeaderOnly(); + // It should read through this header just fine + REQUIRE(err > 0); + + err = reader.readFile(); + std::cout << reader.getErrorMessage(); + REQUIRE(err == -400); +} + +TEST_CASE("ebsdlib::AngImportTest-TestMissingGrid", "[EbsdLib][AngImportTest]") +{ + AngReader reader; + reader.setFileName(UnitTest::AngImportTest::GridMissing); + int err = reader.readHeaderOnly(); + // It should read through this header just fine + REQUIRE(err > 0); + + err = reader.readFile(); + std::cout << reader.getErrorMessage(); + REQUIRE(err == -300); +} + +TEST_CASE("ebsdlib::AngImportTest-TestShortFile", "[EbsdLib][AngImportTest]") +{ + AngReader reader; + reader.setFileName(UnitTest::AngImportTest::ShortFile); + int err = reader.readFile(); + // It should read through this header just fine but die when reading the file because there is not enough data being read + std::cout << reader.getErrorMessage(); + REQUIRE(err < 0); +} diff --git a/Source/Test/AngleFileLoaderTest.cpp b/Source/Test/AngleFileLoaderTest.cpp index d94292cf..2b8465aa 100644 --- a/Source/Test/AngleFileLoaderTest.cpp +++ b/Source/Test/AngleFileLoaderTest.cpp @@ -32,33 +32,24 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include +#include #include +#include #include #include -#include #include #include "EbsdLib/EbsdLib.h" -#include "EbsdLib/Utilities/IO/AngleFileLoader.h" +#include "EbsdLib/IO/AngleFileLoader.h" #include "UnitTestSupport.hpp" -#include "TestFileLocations.h" +#include "EbsdLib/Test/EbsdLibTestFileLocations.h" -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void RemoveTestFiles() -{ -#if REMOVE_TEST_FILES - std::fstream::remove(UnitTest::AngleFileLoaderTest::OutputFile); -#endif -} +using namespace ebsdlib; // ----------------------------------------------------------------------------- // @@ -70,22 +61,19 @@ void makeTestFile(const std::string delim, const std::string& outputFile) FILE* f = fopen(outputFile.c_str(), "wb"); - fprintf(f, "%d\n", count); + fprintf(f, "Angle Count:%d\n", count); for(int i = 0; i < count; ++i) { e0 = static_cast(i) * 0.1; e1 = static_cast(i) * 0.25; e2 = static_cast(i) * 0.58; - fprintf(f, "%0.6f%s%0.6f%s%0.6f\n", e0, delim.c_str(), e1, delim.c_str(), e2); + fprintf(f, "%0.6f%s%0.6f%s%0.6f%s1000%s5000\n", e0, delim.c_str(), e1, delim.c_str(), e2, delim.c_str(), delim.c_str()); } fclose(f); } -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void TestLoadingSpaceDelimited() +TEST_CASE("ebsdlib::AngleFileLoader-TestLoadingSpaceDelimited", "[EbsdLib][AngleFileLoader]") { // Create a Teset File makeTestFile(" ", UnitTest::AngleFileLoaderTest::OutputFile); @@ -96,13 +84,9 @@ void TestLoadingSpaceDelimited() reader->setAngleRepresentation(AngleFileLoader::EulerAngles); reader->loadData(); int err = reader->getErrorCode(); - DREAM3D_REQUIRE_EQUAL(err, 0) + REQUIRE(err == 0); } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void TestLoadingCommaDelimited() +TEST_CASE("ebsdlib::AngleFileLoader-TestLoadingCommaDelimited", "[EbsdLib][AngleFileLoader]") { // Create a Teset File makeTestFile(", ", UnitTest::AngleFileLoaderTest::OutputFile); @@ -113,13 +97,9 @@ void TestLoadingCommaDelimited() reader->setAngleRepresentation(AngleFileLoader::EulerAngles); reader->loadData(); int err = reader->getErrorCode(); - DREAM3D_REQUIRE_EQUAL(err, 0) + REQUIRE(err == 0); } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void TestLoadingSemiColonDelimited() +TEST_CASE("ebsdlib::AngleFileLoader-TestLoadingSemiColonDelimited", "[EbsdLib][AngleFileLoader]") { // Create a Teset File makeTestFile(";", UnitTest::AngleFileLoaderTest::OutputFile); @@ -130,13 +110,9 @@ void TestLoadingSemiColonDelimited() reader->setAngleRepresentation(AngleFileLoader::EulerAngles); reader->loadData(); int err = reader->getErrorCode(); - DREAM3D_REQUIRE_EQUAL(err, 0) + REQUIRE(err == 0); } - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -void TestLoadingTabDelimited() +TEST_CASE("ebsdlib::AngleFileLoader-TestLoadingTabDelimited", "[EbsdLib][AngleFileLoader]") { // Create a Teset File makeTestFile("\t", UnitTest::AngleFileLoaderTest::OutputFile); @@ -147,33 +123,5 @@ void TestLoadingTabDelimited() reader->setAngleRepresentation(AngleFileLoader::EulerAngles); reader->loadData(); int err = reader->getErrorCode(); - DREAM3D_REQUIRE_EQUAL(err, 0) -} - -// ----------------------------------------------------------------------------- -// -// ----------------------------------------------------------------------------- -int main(int argc, char* argv[]) -{ - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - QDir dir(UnitTest::AngleFileLoaderTest::TestDir); - dir.mkpath("."); - -#if !REMOVE_TEST_FILES - DREAM3D_REGISTER_TEST(RemoveTestFiles()) -#endif - - DREAM3D_REGISTER_TEST(TestLoadingSpaceDelimited()) - DREAM3D_REGISTER_TEST(TestLoadingCommaDelimited()) - DREAM3D_REGISTER_TEST(TestLoadingSemiColonDelimited()) - DREAM3D_REGISTER_TEST(TestLoadingTabDelimited()) - -#if REMOVE_TEST_FILES - DREAM3D_REGISTER_TEST(RemoveTestFiles()) -#endif - - PRINT_TEST_SUMMARY(); - return err; + REQUIRE(err == 0); } diff --git a/Source/Test/CMakeLists.txt b/Source/Test/CMakeLists.txt index f2aafccc..9da60f9b 100644 --- a/Source/Test/CMakeLists.txt +++ b/Source/Test/CMakeLists.txt @@ -1,157 +1,51 @@ -#------------------------------------------------------------------------------- -# -function(CMP_AddDefinitions) - set(options) - set(oneValueArgs TARGET) - set(multiValueArgs) - cmake_parse_arguments(Z "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +set(UNIT_TEST_TARGET EbsdLibUnitTest) - # -------------------------------------------------------------------- - # Add in some compiler definitions - # -------------------------------------------------------------------- - if( CMAKE_BUILD_TYPE MATCHES Debug ) - target_compile_definitions(${Z_TARGET} PRIVATE -DDEBUG) - endif( CMAKE_BUILD_TYPE MATCHES Debug ) - - # On linux we need to set this because some of the libraries are Static - # and some are shared. - if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT MSVC ) - target_compile_options(${Z_TARGET} PRIVATE -fPIC) - endif() - - # -------------------------------------------------------------------- - # If was are using GCC, make the compiler messages on a single line - if(CMAKE_COMPILER_IS_GNUCC) - target_compile_options(${Z_TARGET} PRIVATE -fmessage-length=0) - endif(CMAKE_COMPILER_IS_GNUCC) - if(CMAKE_COMPILER_IS_GNUCXX) - target_compile_options(${Z_TARGET} PRIVATE -fmessage-length=0) - endif(CMAKE_COMPILER_IS_GNUCXX) - - if(MSVC AND EBSD_DISABLE_MSVC_WARNINGS) - target_compile_definitions(${Z_TARGET} PRIVATE -D_CRT_SECURE_NO_WARNINGS) - target_compile_definitions(${Z_TARGET} PRIVATE -D_SCL_SECURE_NO_WARNINGS) - endif() - -endfunction() - - -# -------------------------------------------------------------------------- -# Adds a Unit Test -function(AddSIMPLUnitTest) - set(options) - set(oneValueArgs TESTNAME FOLDER) - set(multiValueArgs SOURCES LINK_LIBRARIES INCLUDE_DIRS) - cmake_parse_arguments(Z "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - add_executable( ${Z_TESTNAME} ${Z_SOURCES}) - if("${Z_FOLDER}" STREQUAL "") - set(Z_FOLDER "Test") - endif() - set_target_properties( ${Z_TESTNAME} PROPERTIES FOLDER ${Z_FOLDER}) - CMP_AddDefinitions(TARGET ${Z_TESTNAME} ) -# cmp_IDE_SOURCE_PROPERTIES( "" "" "${Z_SOURCES}" "0") - target_include_directories(${Z_TESTNAME} PUBLIC ${Z_INCLUDE_DIRS}) - target_link_libraries( ${Z_TESTNAME} ${Z_LINK_LIBRARIES}) - add_test(${Z_TESTNAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${Z_TESTNAME}) - -endfunction() - - -enable_testing() -set(TEST_TEMP_DIR ${EbsdLibProj_BINARY_DIR}/Test/Temp) -# Make sure the directory is created during CMake time -file(MAKE_DIRECTORY ${TEST_TEMP_DIR}) - -configure_file(${EbsdLibProj_SOURCE_DIR}/Source/Test/TestFileLocations.h.in - ${EbsdLibProj_BINARY_DIR}/EbsdLib/Test/EbsdLibTestFileLocations.h @ONLY IMMEDIATE) -set(TEST_NAMES "") - -if(EbsdLib_ENABLE_HDF5) - set(TEST_NAMES - ${TEST_NAMES} - H5EspritReaderTest - EdaxOIMReaderTest - # H5OINAReaderTest - ) -endif() +set(EBSDLIB_TEST_DIRS_HEADER ${EbsdLibProj_BINARY_DIR}/EbsdLib/Test/EbsdLibTestFileLocations.h) +configure_file(${EbsdLibProj_SOURCE_DIR}/Source/Test/TestFileLocations.h.in ${EBSDLIB_TEST_DIRS_HEADER} @ONLY) #------------------------------------------------------------------------------ -# List all the source files here. They will NOT be compiled but instead -# be directly included in the main test source file. We list them here so that -# they will show up in IDEs -set(TEST_NAMES - ${TEST_NAMES} - - OrientationConverterTest - - OrientationTransformsTest - - QuaternionTest - - AngImportTest - - CtfReaderTest - - ODFTest - - SO3SamplerTest - - TextureTest - - ConvertToFundamentalZoneTest - - OrientationRepresentationTransformTest +# Find the Catch2 unit testing package +find_package(Catch2 CONFIG REQUIRED) +include(Catch) + + +# ------------------------------------------------------------------------------ +# Define the list of unit test source files +set(EbsdLib_UnitTest_SRCS + ${EbsdLibProj_SOURCE_DIR}/Source/Test/AngImportTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/AngleFileLoaderTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/OrientationTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/ConvertToFundamentalZoneTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/CtfReaderTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/EdaxOIMReaderTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/H5EspritReaderTest.cpp + # ${EbsdLibProj_SOURCE_DIR}/Source/Test/H5OINAReaderTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/IPFLegendTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/QuaternionTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/ODFTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/TextureTest.cpp + ${EbsdLibProj_SOURCE_DIR}/Source/Test/OrientationConverterTest.cpp ) -set(EbsdLibProj_TEST_SRCS ) -set(FilterTestIncludes "") -set(TestMainFunctors "") - -foreach(name ${TEST_NAMES}) - set( EbsdLibProj_TEST_SRCS - ${EbsdLibProj_TEST_SRCS} - "${EbsdLibProj_SOURCE_DIR}/Source/Test/${name}.cpp" - ) - string(CONCAT - FilterTestIncludes - ${FilterTestIncludes} - "#include \"${name}.cpp\"\n" - ) - - string(CONCAT - TestMainFunctors - ${TestMainFunctors} - " ${name}()()|\n") -endforeach() - -STRING(REPLACE "|" ";" TestMainFunctors ${TestMainFunctors} ) - -configure_file(${EbsdLibProj_SOURCE_DIR}/Source/Test/TestMain.cpp.in - ${EbsdLibProj_BINARY_DIR}/Test/EbsdLibUnitTest.cpp @ONLY) +set(DISABLED_TESTS +) -# Set the source files properties on each source file. -foreach(f ${EbsdLibProj_TEST_SRCS}) - set_source_files_properties( ${f} PROPERTIES HEADER_FILE_ONLY TRUE) -endforeach() +#------------------------------------------------------------------------------ +# Create the unit test executable +add_executable(${UNIT_TEST_TARGET} + ${EBSDLIB_TEST_DIRS_HEADER} + ${EbsdLibProj_SOURCE_DIR}/Source/Test/EbsdLib_test_main.cpp + ${EbsdLib_UnitTest_SRCS} +) -AddSIMPLUnitTest(TESTNAME EbsdLibUnitTest - SOURCES ${EbsdLibProj_BINARY_DIR}/Test/EbsdLibUnitTest.cpp ${EbsdLibProj_TEST_SRCS} - FOLDER "EbsdLibProj/Test" - LINK_LIBRARIES EbsdLib - INCLUDE_DIRS - ${EbsdLibProj_SOURCE_DIR}/Source - ${EbsdLibProj_SOURCE_DIR}/Source/Test - ${EbsdLibProj_BINARY_DIR} - ${EbsdLibProj_BINARY_DIR}/Test - ${EIGEN3_INCLUDE_DIR} - ${HDF5_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIR} - ${H5Support_SOURCE_DIR}/Source - ) +target_link_libraries(${UNIT_TEST_TARGET} + PRIVATE + EbsdLib + Catch2::Catch2 +) if(MSVC) diff --git a/Source/Test/ConvertToFundamentalZoneTest.cpp b/Source/Test/ConvertToFundamentalZoneTest.cpp index d6e9a4fd..1fefa18e 100644 --- a/Source/Test/ConvertToFundamentalZoneTest.cpp +++ b/Source/Test/ConvertToFundamentalZoneTest.cpp @@ -32,20 +32,22 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" #include "EbsdLib/Test/EbsdLibTestFileLocations.h" -#include "TestPrintFunctions.h" #include "UnitTestSupport.hpp" #include #include +using namespace ebsdlib; + //clang-format off namespace detail { @@ -71,76 +73,45 @@ std::vector> k_FZValues = { } // namespace detail -class ConvertToFundamentalZoneTest +static RodriguesDType convertRodrigues(const std::array& rod) { -public: - ConvertToFundamentalZoneTest() = default; - virtual ~ConvertToFundamentalZoneTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(ConvertToFundamentalZoneTest) - - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES -// fs::remove(); -#endif - } + const float length = sqrt(rod[0] * rod[0] + rod[1] * rod[1] + rod[2] * rod[2]); + return {rod[0] / length, rod[1] / length, rod[2] / length, length}; +} - static RodriguesDType convertRodrigues(const std::array& rod) +TEST_CASE("ebsdlib::ConvertToFundamentalZoneTest", "[EbsdLib][ConvertToFundamentalZoneTest]") +{ + auto ops = LaueOps::GetAllOrientationOps(); + std::cout << "############################################################\n"; + for(size_t opsIdx = 0; opsIdx < ops.size() - 1; ++opsIdx) // We ONLY want Cubic 432 rotation group { - const float length = sqrt(rod[0] * rod[0] + rod[1] * rod[1] + rod[2] * rod[2]); - return {rod[0] / length, rod[1] / length, rod[2] / length, length}; - } + std::cout << "OpsIndex: " << opsIdx << " " << ops[opsIdx]->getRotationPointGroup() << ", " << ops[opsIdx]->getSymmetryName() << ", " << ops[opsIdx]->getPointGroup() << ", " + << ops[opsIdx]->FZTypeToString(ops[opsIdx]->getFZType()) << ", " << ops[opsIdx]->AxisOrderingTypeToString(ops[opsIdx]->getAxisOrderingType()) << std::endl; + const std::array& testValues = detail::k_FZValues[opsIdx]; - void TestRodrigues() - { - auto ops = LaueOps::GetAllOrientationOps(); - std::cout << "############################################################\n"; - for(size_t opsIdx = 0; opsIdx < ops.size() - 1; ++opsIdx) // We ONLY want Cubic 432 rotation group + for(size_t testIdx = 0; testIdx < testValues.size(); testIdx++) { - std::cout << "OpsIndex: " << opsIdx << " " << ops[opsIdx]->getRotationPointGroup() << ", " << ops[opsIdx]->getSymmetryName() << ", " << ops[opsIdx]->getPointGroup() << ", " - << ops[opsIdx]->FZTypeToString(ops[opsIdx]->getFZType()) << ", " << ops[opsIdx]->AxisOrderingTypeToString(ops[opsIdx]->getAxisOrderingType()) << std::endl; - const std::array& testValues = detail::k_FZValues[opsIdx]; - - for(size_t testIdx = 0; testIdx < testValues.size(); testIdx++) + // OrientationD testRod = OrientationTransformation::qu2ro(Detail::k_InputQuat); + std::array rod = detail::k_TestRodrigues[testIdx]; + RodriguesDType testRod = convertRodrigues(rod); + bool isInside = LaueOps::IsInsideFZ(testRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); + + REQUIRE(isInside == testValues[testIdx]); + // if(testValues[testIdx] != isInside) + // { + // std::stringstream ss; + // ss << testIdx << ": " << "(" << rod[0] << ", " << rod[1] << ", " << rod[2] << "), " << testValues[testIdx] << ", " << isInside; + // std::cout << ss.str() << std::endl; + // } + + if(!isInside) { - // OrientationD testRod = OrientationTransformation::qu2ro(Detail::k_InputQuat); - std::array rod = detail::k_TestRodrigues[testIdx]; - RodriguesDType testRod = convertRodrigues(rod); - bool isInside = LaueOps::IsInsideFZ(testRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); - - DREAM3D_REQUIRE_EQUAL(isInside, testValues[testIdx]) - // if(testValues[testIdx] != isInside) - // { - // std::stringstream ss; - // ss << testIdx << ": " << "(" << rod[0] << ", " << rod[1] << ", " << rod[2] << "), " << testValues[testIdx] << ", " << isInside; - // std::cout << ss.str() << std::endl; - // } - - if(!isInside) - { - QuatD quat = testRod.toQuat(); - QuatD fzQuat = ops[opsIdx]->getFZQuat(quat); - RodriguesDType fzRod = QuaternionDType(fzQuat).toRodrigues(); - isInside = LaueOps::IsInsideFZ(fzRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); - DREAM3D_REQUIRE_EQUAL(isInside, true); - } + QuatD quat = testRod.toQuaternion(); + QuatD fzQuat = ops[opsIdx]->getFZQuat(quat); + RodriguesDType fzRod = QuaternionDType(fzQuat).toRodrigues(); + isInside = LaueOps::IsInsideFZ(fzRod, ops[opsIdx]->getFZType(), ops[opsIdx]->getAxisOrderingType()); + REQUIRE(isInside == true); } } } - - // ----------------------------------------------------------------------------- - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestRodrigues()) - } - -public: - ConvertToFundamentalZoneTest(const ConvertToFundamentalZoneTest&) = delete; // Copy Constructor Not Implemented - ConvertToFundamentalZoneTest(ConvertToFundamentalZoneTest&&) = delete; // Move Constructor Not Implemented - ConvertToFundamentalZoneTest& operator=(const ConvertToFundamentalZoneTest&) = delete; // Copy Assignment Not Implemented - ConvertToFundamentalZoneTest& operator=(ConvertToFundamentalZoneTest&&) = delete; // Move Assignment Not Implemented -}; +} diff --git a/Source/Test/CtfReaderTest.cpp b/Source/Test/CtfReaderTest.cpp index 32573533..92221cad 100644 --- a/Source/Test/CtfReaderTest.cpp +++ b/Source/Test/CtfReaderTest.cpp @@ -35,9 +35,7 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include +#include #include "EbsdLib/IO/HKL/CtfReader.h" @@ -45,213 +43,182 @@ #include "EbsdLib/Test/EbsdLibTestFileLocations.h" -class CtfReaderTest -{ -public: - CtfReaderTest() = default; - virtual ~CtfReaderTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(CtfReaderTest) - - // ----------------------------------------------------------------------------- - void TestCtfReader() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::EuropeanInputFile1); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, >=, 0) - - float xstep = reader.getXStep(); - DREAM3D_REQUIRE(xstep == 0.5f) - float ystep = reader.getYStep(); - DREAM3D_REQUIRE(ystep == 0.5f) - DREAM3D_REQUIRE(reader.getNumPhases() == 1) - CtfPhase::Pointer phase = reader.getPhaseVector().at(0); - std::vector latticeConstants = phase->getLatticeConstants(); - DREAM3D_REQUIRE(latticeConstants[0] >= 3.230f && latticeConstants[0] <= 3.232f) - DREAM3D_REQUIRE(latticeConstants[1] >= 3.230f && latticeConstants[1] <= 3.232f) - DREAM3D_REQUIRE(latticeConstants[2] >= 5.147f && latticeConstants[2] <= 5.149f) - DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[5] >= 120.00f && latticeConstants[5] <= 120.00f) - DREAM3D_REQUIRE(latticeConstants.size() == 6) - - float* euler1 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler1)); - DREAM3D_REQUIRE(euler1 != nullptr) - DREAM3D_REQUIRE(euler1[1] == 103.85f) - - float* euler2 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler2)); - DREAM3D_REQUIRE(euler2 != nullptr) - DREAM3D_REQUIRE(euler2[1] == 40.207f) - - float* euler3 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler3)); - DREAM3D_REQUIRE(euler3 != nullptr) - DREAM3D_REQUIRE(euler3[1] == 29.394f) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestMultiplePhases_European() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::EuropeanInputFile2); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, >=, 0) - - float xstep = reader.getXStep(); - DREAM3D_REQUIRE(xstep == 0.5f) - float ystep = reader.getYStep(); - DREAM3D_REQUIRE(ystep == 0.5f) - DREAM3D_REQUIRE(reader.getNumPhases() == 5) - CtfPhase::Pointer phase = reader.getPhaseVector().at(0); - std::vector latticeConstants = phase->getLatticeConstants(); - DREAM3D_REQUIRE(latticeConstants[0] >= 3.61f && latticeConstants[0] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[1] >= 3.61f && latticeConstants[1] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[2] >= 3.61f && latticeConstants[2] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[4] >= 90.00f && latticeConstants[4] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[5] >= 90.00f && latticeConstants[5] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants.size() == 6) - - float* euler1 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler1)); - DREAM3D_REQUIRE(euler1 != nullptr) - DREAM3D_REQUIRE(euler1[1] == 5.673f) - - float* euler2 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler2)); - DREAM3D_REQUIRE(euler2 != nullptr) - DREAM3D_REQUIRE(euler2[1] == 0.2549f) - - float* euler3 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler3)); - DREAM3D_REQUIRE(euler3 != nullptr) - DREAM3D_REQUIRE(euler3[1] == 0.2423f) - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestMultiplePhases_US() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::USInputFile2); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, >=, 0) - - float xstep = reader.getXStep(); - DREAM3D_REQUIRE(xstep == 0.5f) - float ystep = reader.getYStep(); - DREAM3D_REQUIRE(ystep == 0.5f) - DREAM3D_REQUIRE(reader.getNumPhases() == 5) - CtfPhase::Pointer phase = reader.getPhaseVector().at(0); - std::vector latticeConstants = phase->getLatticeConstants(); - DREAM3D_REQUIRE(latticeConstants[0] >= 3.61f && latticeConstants[0] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[1] >= 3.61f && latticeConstants[1] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[2] >= 3.61f && latticeConstants[2] <= 3.61f) - DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[4] >= 90.00f && latticeConstants[4] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants[5] >= 90.00f && latticeConstants[5] <= 90.00f) - DREAM3D_REQUIRE(latticeConstants.size() == 6) - - float* euler1 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler1)); - DREAM3D_REQUIRE(euler1 != nullptr) - DREAM3D_REQUIRE(euler1[1] == 103.85f) - - float* euler2 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler2)); - DREAM3D_REQUIRE(euler2 != nullptr) - DREAM3D_REQUIRE(euler2[1] == 40.207f) - - float* euler3 = reinterpret_cast(reader.getPointerByName(EbsdLib::Ctf::Euler3)); - DREAM3D_REQUIRE(euler3 != nullptr) - DREAM3D_REQUIRE(euler3[1] == 29.394f) - } +#include +#include - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestCellCountToLarge() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::Corrupted_XCells); - int err = reader.readFile(); - std::cout << reader.getErrorMessage(); - DREAM3D_REQUIRED(err, ==, -110) - } +using namespace ebsdlib; - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestShortFile() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::ShortFile); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, ==, -105) - } +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestCtfReader", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::EuropeanInputFile1); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, >=, 0) + + float xstep = reader.getXStep(); + DREAM3D_REQUIRE(xstep == 0.5f) + float ystep = reader.getYStep(); + DREAM3D_REQUIRE(ystep == 0.5f) + DREAM3D_REQUIRE(reader.getNumPhases() == 1) + CtfPhase::Pointer phase = reader.getPhaseVector().at(0); + std::vector latticeConstants = phase->getLatticeConstants(); + DREAM3D_REQUIRE(latticeConstants[0] >= 3.230f && latticeConstants[0] <= 3.232f) + DREAM3D_REQUIRE(latticeConstants[1] >= 3.230f && latticeConstants[1] <= 3.232f) + DREAM3D_REQUIRE(latticeConstants[2] >= 5.147f && latticeConstants[2] <= 5.149f) + DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[5] >= 120.00f && latticeConstants[5] <= 120.00f) + DREAM3D_REQUIRE(latticeConstants.size() == 6) + + float* euler1 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler1)); + DREAM3D_REQUIRE(euler1 != nullptr) + DREAM3D_REQUIRE(euler1[1] == 103.85f) + + float* euler2 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler2)); + DREAM3D_REQUIRE(euler2 != nullptr) + DREAM3D_REQUIRE(euler2[1] == 40.207f) + + float* euler3 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler3)); + DREAM3D_REQUIRE(euler3 != nullptr) + DREAM3D_REQUIRE(euler3[1] == 29.394f) +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestMultiplePhases_European", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::EuropeanInputFile2); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, >=, 0) + + float xstep = reader.getXStep(); + DREAM3D_REQUIRE(xstep == 0.5f) + float ystep = reader.getYStep(); + DREAM3D_REQUIRE(ystep == 0.5f) + DREAM3D_REQUIRE(reader.getNumPhases() == 5) + CtfPhase::Pointer phase = reader.getPhaseVector().at(0); + std::vector latticeConstants = phase->getLatticeConstants(); + DREAM3D_REQUIRE(latticeConstants[0] >= 3.61f && latticeConstants[0] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[1] >= 3.61f && latticeConstants[1] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[2] >= 3.61f && latticeConstants[2] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[4] >= 90.00f && latticeConstants[4] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[5] >= 90.00f && latticeConstants[5] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants.size() == 6) + + float* euler1 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler1)); + DREAM3D_REQUIRE(euler1 != nullptr) + DREAM3D_REQUIRE(euler1[1] == 5.673f) + + float* euler2 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler2)); + DREAM3D_REQUIRE(euler2 != nullptr) + DREAM3D_REQUIRE(euler2[1] == 0.2549f) + + float* euler3 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler3)); + DREAM3D_REQUIRE(euler3 != nullptr) + DREAM3D_REQUIRE(euler3[1] == 0.2423f) +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestMultiplePhases_US", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::USInputFile2); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, >=, 0) + + float xstep = reader.getXStep(); + DREAM3D_REQUIRE(xstep == 0.5f) + float ystep = reader.getYStep(); + DREAM3D_REQUIRE(ystep == 0.5f) + DREAM3D_REQUIRE(reader.getNumPhases() == 5) + CtfPhase::Pointer phase = reader.getPhaseVector().at(0); + std::vector latticeConstants = phase->getLatticeConstants(); + DREAM3D_REQUIRE(latticeConstants[0] >= 3.61f && latticeConstants[0] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[1] >= 3.61f && latticeConstants[1] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[2] >= 3.61f && latticeConstants[2] <= 3.61f) + DREAM3D_REQUIRE(latticeConstants[3] >= 90.00f && latticeConstants[3] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[4] >= 90.00f && latticeConstants[4] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants[5] >= 90.00f && latticeConstants[5] <= 90.00f) + DREAM3D_REQUIRE(latticeConstants.size() == 6) + + float* euler1 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler1)); + DREAM3D_REQUIRE(euler1 != nullptr) + DREAM3D_REQUIRE(euler1[1] == 103.85f) + + float* euler2 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler2)); + DREAM3D_REQUIRE(euler2 != nullptr) + DREAM3D_REQUIRE(euler2[1] == 40.207f) + + float* euler3 = reinterpret_cast(reader.getPointerByName(ebsdlib::Ctf::Euler3)); + DREAM3D_REQUIRE(euler3 != nullptr) + DREAM3D_REQUIRE(euler3[1] == 29.394f) +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestCellCountToLarge", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::Corrupted_XCells); + int err = reader.readFile(); + std::cout << reader.getErrorMessage(); + DREAM3D_REQUIRED(err, ==, -110) +} + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestShortFile", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::ShortFile); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, ==, -105) +} + +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestZeroXYCells", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::ZeroXYCells); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, ==, -103) +} + +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::CtfReaderTest::TestWriteCtfFile", "[EbsdLib][CtfReaderTest]") +{ + CtfReader reader; + reader.setFileName(UnitTest::CtfReaderTest::USInputFile1); + int err = reader.readFile(); + DREAM3D_REQUIRED(err, ==, 0) - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestZeroXYCells() - { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::ZeroXYCells); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, ==, -103) - } + // std::string header = reader.getOriginalHeader(); - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestWriteCtfFile() + float* phi2Ptr = reinterpret_cast(reader.getPointerByName("Euler3")); + if(nullptr != phi2Ptr) { - CtfReader reader; - reader.setFileName(UnitTest::CtfReaderTest::USInputFile1); - int err = reader.readFile(); - DREAM3D_REQUIRED(err, ==, 0) - - // std::string header = reader.getOriginalHeader(); - - float* phi2Ptr = reinterpret_cast(reader.getPointerByName("Euler3")); - if(nullptr != phi2Ptr) - { - int total = reader.getXCells() * reader.getYCells() * reader.getZCells(); - for(int i = 0; i < total; i++) - { - phi2Ptr[i] = phi2Ptr[i] + 30.0F; - } - } - - std::stringstream filePath; - filePath << UnitTest::TestTempDir << "/CTF_WriteFile_test.ctf"; - err = reader.writeFile(filePath.str()); - DREAM3D_REQUIRE(err == 0); - if(REMOVE_TEST_FILES == 1) + int total = reader.getXCells() * reader.getYCells() * reader.getZCells(); + for(int i = 0; i < total; i++) { - bool removed = fs::remove(filePath.str()); - DREAM3D_REQUIRE(removed == true); + phi2Ptr[i] = phi2Ptr[i] + 30.0F; } } - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void operator()() + std::stringstream filePath; + filePath << UnitTest::TestTempDir << "/CTF_WriteFile_test.ctf"; + err = reader.writeFile(filePath.str()); + DREAM3D_REQUIRE(err == 0); + if(REMOVE_TEST_FILES == 1) { - int err = EXIT_SUCCESS; - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - DREAM3D_REGISTER_TEST(TestCtfReader()) - DREAM3D_REGISTER_TEST(TestMultiplePhases_European()) - DREAM3D_REGISTER_TEST(TestMultiplePhases_US()) - DREAM3D_REGISTER_TEST(TestCellCountToLarge()) - DREAM3D_REGISTER_TEST(TestShortFile()) - DREAM3D_REGISTER_TEST(TestZeroXYCells()) - DREAM3D_REGISTER_TEST(TestWriteCtfFile()); + bool removed = fs::remove(filePath.str()); + DREAM3D_REQUIRE(removed == true); } - -public: - CtfReaderTest(const CtfReaderTest&) = delete; // Copy Constructor Not Implemented - CtfReaderTest(CtfReaderTest&&) = delete; // Move Constructor Not Implemented - CtfReaderTest& operator=(const CtfReaderTest&) = delete; // Copy Assignment Not Implemented - CtfReaderTest& operator=(CtfReaderTest&&) = delete; // Move Assignment Not Implemented -}; +} diff --git a/Source/Test/EbsdLib_test_main.cpp b/Source/Test/EbsdLib_test_main.cpp new file mode 100644 index 00000000..48425c53 --- /dev/null +++ b/Source/Test/EbsdLib_test_main.cpp @@ -0,0 +1,4 @@ +// Catch2 recommends placing these lines by themselves in a translation unit +// which will help reduce unnecessary recompilations of the expensive Catch main +#define CATCH_CONFIG_MAIN +#include diff --git a/Source/Test/EdaxOIMReaderTest.cpp b/Source/Test/EdaxOIMReaderTest.cpp index 4b7095ac..42731de4 100644 --- a/Source/Test/EdaxOIMReaderTest.cpp +++ b/Source/Test/EdaxOIMReaderTest.cpp @@ -32,11 +32,7 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include - -#include -#include +#include #include "EbsdLib/EbsdLib.h" #include "EbsdLib/IO/TSL/AngReader.h" @@ -45,92 +41,63 @@ #include "UnitTestSupport.hpp" -class EdaxOIMReaderTest -{ -public: - EdaxOIMReaderTest() = default; - virtual ~EdaxOIMReaderTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(EdaxOIMReaderTest) - - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES -// fs::remove(UnitTest::AngImportTest::H5EbsdOutputFile); -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestH5OIMReader() - { - int err = 0; - int err1 = 0; - H5OIMReader::Pointer reader = H5OIMReader::New(); - reader->setFileName(UnitTest::AngImportTest::EdaxOIMH5File); - std::list names; - err = reader->readScanNames(names); - DREAM3D_REQUIRED(err, >=, 0) - int count = static_cast(names.size()); - DREAM3D_REQUIRED(count, ==, 1) - - reader->setHDF5Path("Scan_1"); - err1 = reader->readHeaderOnly(); - - err = reader->getErrorCode(); - DREAM3D_REQUIRED(err, >=, 0) - DREAM3D_REQUIRED(err1, >=, 0) - - int x = reader->getXDimension(); - DREAM3D_REQUIRED(x, ==, 186) - int y = reader->getYDimension(); - DREAM3D_REQUIRED(y, ==, 151) - - reader->setReadPatternData(false); - err = reader->readFile(); - float* f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::Phi1)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::Phi)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::Phi2)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::ImageQuality)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::ConfidenceIndex)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::SEMSignal)); - DREAM3D_REQUIRE_VALID_POINTER(f1) - f1 = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::Fit)); - - int* phasePtr = reinterpret_cast(reader->getPointerByName(EbsdLib::Ang::PhaseData)); - DREAM3D_REQUIRE_VALID_POINTER(phasePtr) +#include +#include +#include - if(reader->getReadPatternData()) - { - uint8_t* patterns = reader->getPatternData(); - DREAM3D_REQUIRE_VALID_POINTER(patterns) - std::array patternDims = {{0, 0}}; - reader->getPatternDims(patternDims); - DREAM3D_REQUIRED(patternDims[0], ==, 60) - DREAM3D_REQUIRED(patternDims[1], ==, 60) - } - } +using namespace ebsdlib; - void operator()() +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::EdaxOIMReaderTest::TestH5OIMReader", "[EbsdLib][EdaxOIMReaderTest]") +{ + int err = 0; + int err1 = 0; + H5OIMReader::Pointer reader = H5OIMReader::New(); + reader->setFileName(UnitTest::AngImportTest::EdaxOIMH5File); + std::list names; + err = reader->readScanNames(names); + DREAM3D_REQUIRED(err, >=, 0) + int count = static_cast(names.size()); + DREAM3D_REQUIRED(count, ==, 1) + + reader->setHDF5Path("Scan_1"); + err1 = reader->readHeaderOnly(); + + err = reader->getErrorCode(); + DREAM3D_REQUIRED(err, >=, 0) + DREAM3D_REQUIRED(err1, >=, 0) + + int x = reader->getXDimension(); + DREAM3D_REQUIRED(x, ==, 186) + int y = reader->getYDimension(); + DREAM3D_REQUIRED(y, ==, 151) + + reader->setReadPatternData(false); + err = reader->readFile(); + float* f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::Phi1)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::Phi)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::Phi2)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::ImageQuality)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::ConfidenceIndex)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::SEMSignal)); + DREAM3D_REQUIRE_VALID_POINTER(f1) + f1 = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::Fit)); + + int* phasePtr = reinterpret_cast(reader->getPointerByName(ebsdlib::Ang::PhaseData)); + DREAM3D_REQUIRE_VALID_POINTER(phasePtr) + + if(reader->getReadPatternData()) { - int err = EXIT_SUCCESS; - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - DREAM3D_REGISTER_TEST(TestH5OIMReader()) - - DREAM3D_REGISTER_TEST(RemoveTestFiles()) + uint8_t* patterns = reader->getPatternData(); + DREAM3D_REQUIRE_VALID_POINTER(patterns) + std::array patternDims = {{0, 0}}; + reader->getPatternDims(patternDims); + DREAM3D_REQUIRED(patternDims[0], ==, 60) + DREAM3D_REQUIRED(patternDims[1], ==, 60) } - -public: - EdaxOIMReaderTest(const EdaxOIMReaderTest&) = delete; // Copy Constructor Not Implemented - EdaxOIMReaderTest(EdaxOIMReaderTest&&) = delete; // Move Constructor Not Implemented - EdaxOIMReaderTest& operator=(const EdaxOIMReaderTest&) = delete; // Copy Assignment Not Implemented - EdaxOIMReaderTest& operator=(EdaxOIMReaderTest&&) = delete; // Move Assignment Not Implemented -}; +} diff --git a/Source/Test/GenerateFunctionList.h b/Source/Test/GenerateFunctionList.h index b90c8e0d..8a5dfda4 100644 --- a/Source/Test/GenerateFunctionList.h +++ b/Source/Test/GenerateFunctionList.h @@ -1,14 +1,18 @@ #pragma once +#include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/OrientationMath/OrientationConverter.hpp" #include "EbsdLib/Utilities/EbsdStringUtils.hpp" -#include "TestPrintFunctions.h" +#include "UnitTestSupport.hpp" #include +#include #include #include +using namespace ebsdlib; + class GenerateFunctionList { @@ -130,7 +134,7 @@ std::shared_ptr> generateRepresentation(int32_t inputType, int3 // using ArrayType = typename EbsdDataArray::Pointer; using OCType = OrientationConverter, T>; - std::vector converters(s_NumReps); + std::vector converters(ebsdlib::s_NumReps); converters[0] = EulerConverter, T>::New(); converters[1] = OrientationMatrixConverter, T>::New(); @@ -141,7 +145,7 @@ std::shared_ptr> generateRepresentation(int32_t inputType, int3 converters[6] = CubochoricConverter, T>::New(); converters[7] = StereographicConverter, T>::New(); - std::vector ocTypes = OCType::GetOrientationTypes(); + std::vector ocTypes = OCType::GetOrientationTypes(); converters[inputType]->setInputData(inputOrientations); converters[inputType]->convertRepresentationTo(ocTypes[outputType]); @@ -173,15 +177,15 @@ void GenerateEulers(size_t nSteps, std::map cDims = {3}; T phi1_min = static_cast(0.0); - T phi1_max = DConst::k_2PiD; + T phi1_max = ebsdlib::constants::k_2PiD; T phi1_delta = (phi1_max - phi1_min) / static_cast(nSteps); T phi_min = static_cast(0.0); - T phi_max = DConst::k_PiD; + T phi_max = ebsdlib::constants::k_PiD; T phi_delta = (phi_max - phi_min) / static_cast(nSteps); T phi2_min = static_cast(0.0); - T phi2_max = DConst::k_2PiD; + T phi2_max = ebsdlib::constants::k_2PiD; T phi2_delta = (phi2_max - phi2_min) / static_cast(nSteps); size_t nStepsCubed = (nSteps + 1) * (nSteps + 1) * (nSteps + 1); @@ -204,14 +208,14 @@ void GenerateEulers(size_t nSteps, std::mapsetComponent(counter, 2, phi2_min + k * phi2_delta); T one80Check = phi1_min + i * phi1_delta + phi2_min + k * phi2_delta; - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) + if(ebsdlib::math::closeEnough(static_cast(ebsdlib::constants::k_PiD), one80Check, static_cast(1.0E-6))) { eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); } - one80Check = fmod(one80Check, EbsdLib::Constants::k_2PiD); - if(EbsdLibMath::closeEnough(static_cast(EbsdLib::Constants::k_PiD), one80Check, static_cast(1.0E-6))) + one80Check = fmod(one80Check, ebsdlib::constants::k_2PiD); + if(ebsdlib::math::closeEnough(static_cast(ebsdlib::constants::k_PiD), one80Check, static_cast(1.0E-6))) { eulers->setComponent(counter, 0, phi1_min + i * phi1_delta + .1); eulers->setComponent(counter, 2, phi2_min + k * phi2_delta + .1); diff --git a/Source/Test/H5EspritReaderTest.cpp b/Source/Test/H5EspritReaderTest.cpp index bc60d09e..87779dc8 100644 --- a/Source/Test/H5EspritReaderTest.cpp +++ b/Source/Test/H5EspritReaderTest.cpp @@ -1,6 +1,4 @@ - -#include -#include +#include #include "H5Support/H5Lite.h" #include "H5Support/H5ScopedSentinel.h" @@ -13,192 +11,181 @@ #include "UnitTestSupport.hpp" -std::stringstream& operator<<(std::stringstream& out, EbsdLib::NumericTypes::Type value) +#include +#include + +using namespace ebsdlib; + +std::stringstream& operator<<(std::stringstream& out, ebsdlib::NumericTypes::Type value) { out << static_cast(value); return out; } -class H5EspritReaderTest +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::H5EspritReaderTest::TestH5EspritReader", "[EbsdLib][H5EspritReaderTest]") { const std::string k_HDF5Path = std::string("Section_435"); -public: - H5EspritReaderTest() = default; - ~H5EspritReaderTest() = default; + H5EspritReader::Pointer reader = H5EspritReader::New(); + + reader->readHeaderOnly(); + int32_t err = reader->getErrorCode(); + DREAM3D_REQUIRED(err, ==, -1) - EBSD_GET_NAME_OF_CLASS_DECL(H5EspritReaderTest) + reader->setHDF5Path(k_HDF5Path); + reader->readHeaderOnly(); + err = reader->getErrorCode(); + DREAM3D_REQUIRED(err, ==, -387) - // ----------------------------------------------------------------------------- - void RemoveTestFiles() + reader->setFileName("Some Random Path"); + reader->readHeaderOnly(); + err = reader->getErrorCode(); + DREAM3D_REQUIRED(err, ==, -2) + + reader->setFileName(UnitTest::H5EspritReaderTest::InputFile); + reader->readHeaderOnly(); + err = reader->getErrorCode(); + if(err < 0) { -#if REMOVE_TEST_FILES - fs::remove(UnitTest::H5EspritReaderTest::OutputFile); -#endif + std::cout << reader->getErrorMessage(); } - // ----------------------------------------------------------------------------- - void TestH5EspritReader() - { - H5EspritReader::Pointer reader = H5EspritReader::New(); - - reader->readHeaderOnly(); - int32_t err = reader->getErrorCode(); - DREAM3D_REQUIRED(err, ==, -1) - - reader->setHDF5Path(k_HDF5Path); - reader->readHeaderOnly(); - err = reader->getErrorCode(); - DREAM3D_REQUIRED(err, ==, -387) - - reader->setFileName("Some Random Path"); - reader->readHeaderOnly(); - err = reader->getErrorCode(); - DREAM3D_REQUIRED(err, ==, -2) - - reader->setFileName(UnitTest::H5EspritReaderTest::InputFile); - reader->readHeaderOnly(); - err = reader->getErrorCode(); - if(err < 0) - { - std::cout << reader->getErrorMessage(); - } - - int32_t ncols = reader->getNumColumns(); - DREAM3D_REQUIRED(ncols, ==, 600) - - int32_t nrows = reader->getNumRows(); - DREAM3D_REQUIRED(nrows, ==, 600) - - float xstep = static_cast(reader->getXStep()); - DREAM3D_REQUIRED(xstep, ==, 0.0) - float ystep = static_cast(reader->getYStep()); - DREAM3D_REQUIRED(ystep, ==, 0.0) - - std::string grid = reader->getGrid(); - DREAM3D_REQUIRED(grid, ==, EbsdLib::H5Esprit::Isometric); - DREAM3D_REQUIRED(err, >=, 0) - int32_t patWidth = reader->getPatternWidth(); - DREAM3D_REQUIRED(patWidth, ==, 80) - int32_t patHeight = reader->getPatternHeight(); - DREAM3D_REQUIRED(patHeight, ==, 60) - - int32_t xDim = reader->getXDimension(); - DREAM3D_REQUIRED(xDim, ==, 600) - - int32_t yDim = reader->getYDimension(); - DREAM3D_REQUIRED(yDim, ==, 600) - - std::list scanNames; - err = reader->readScanNames(scanNames); - DREAM3D_REQUIRED(scanNames.size(), ==, 1) - DREAM3D_REQUIRED(scanNames.front(), ==, k_HDF5Path) - - err = reader->readFile(); - - // void* ptr = reader->getPointerByName(EbsdLib::H5Esprit::DD); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - void* ptr = reader->getPointerByName(EbsdLib::H5Esprit::MAD); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::MADPhase); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::NIndexedBands); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::PCX); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::PCY); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::PHI); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::Phase); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::RadonBandCount); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::RadonQuality); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::XBEAM); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::YBEAM); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::XSAMPLE); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::YSAMPLE); - // DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::phi1); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::phi2); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::RawPatterns); - DREAM3D_REQUIRE_NULL_POINTER(ptr); - - // numType = reader->getPointerType(EbsdLib::H5Esprit::DD); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Float) - EbsdLib::NumericTypes::Type numType = reader->getPointerType(EbsdLib::H5Esprit::MAD); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Float) - // numType = reader->getPointerType(EbsdLib::H5Esprit::MADPhase); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Int32) - numType = reader->getPointerType(EbsdLib::H5Esprit::NIndexedBands); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Int32) - // numType = reader->getPointerType(EbsdLib::H5Esprit::PCX); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Float) - // numType = reader->getPointerType(EbsdLib::H5Esprit::PCY); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::PHI); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::Phase); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Int32) - numType = reader->getPointerType(EbsdLib::H5Esprit::RadonBandCount); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Int32) - numType = reader->getPointerType(EbsdLib::H5Esprit::RadonQuality); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::XBEAM); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Int32) - numType = reader->getPointerType(EbsdLib::H5Esprit::YBEAM); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Int32) - // numType = reader->getPointerType(EbsdLib::H5Esprit::XSAMPLE); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Float) - // numType = reader->getPointerType(EbsdLib::H5Esprit::YSAMPLE); - // DREAM3D_REQUIRED(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::phi1); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::phi2); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::Float) - numType = reader->getPointerType(EbsdLib::H5Esprit::RawPatterns); - DREAM3D_REQUIRE(numType == EbsdLib::NumericTypes::Type::UInt8); - - // float* xsamplePtr = reader->getXSAMPLEPointer(); - // DREAM3D_REQUIRE_VALID_POINTER(xsamplePtr); - // reader->releaseXSAMPLEOwnership(); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::XSAMPLE); - // DREAM3D_REQUIRE_NULL_POINTER(ptr); - // reader->deallocateArrayData(xsamplePtr); - - // float* ysamplePtr = reader->getYSAMPLEPointer(); - // DREAM3D_REQUIRE_VALID_POINTER(ysamplePtr); - // reader->releaseYSAMPLEOwnership(); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::YSAMPLE); - // DREAM3D_REQUIRE_NULL_POINTER(ptr); - // reader->deallocateArrayData(ysamplePtr); - - // std::cout << "=============================================================" << std::endl; - std::set arraysToRead; - arraysToRead.insert(EbsdLib::H5Esprit::phi1); - arraysToRead.insert(EbsdLib::H5Esprit::PHI); - arraysToRead.insert(EbsdLib::H5Esprit::phi2); - reader->setArraysToRead(arraysToRead); - err = reader->readFile(); - - ptr = reader->getPointerByName(EbsdLib::H5Esprit::phi1); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::phi2); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - ptr = reader->getPointerByName(EbsdLib::H5Esprit::PHI); - DREAM3D_REQUIRE_VALID_POINTER(ptr); - - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::XSAMPLE); - // DREAM3D_REQUIRE_NULL_POINTER(ptr); - // ptr = reader->getPointerByName(EbsdLib::H5Esprit::YSAMPLE); - // DREAM3D_REQUIRE_NULL_POINTER(ptr); + int32_t ncols = reader->getNumColumns(); + DREAM3D_REQUIRED(ncols, ==, 600) + + int32_t nrows = reader->getNumRows(); + DREAM3D_REQUIRED(nrows, ==, 600) + + float xstep = static_cast(reader->getXStep()); + DREAM3D_REQUIRED(xstep, ==, 0.0) + float ystep = static_cast(reader->getYStep()); + DREAM3D_REQUIRED(ystep, ==, 0.0) + + std::string grid = reader->getGrid(); + DREAM3D_REQUIRED(grid, ==, ebsdlib::H5Esprit::Isometric); + DREAM3D_REQUIRED(err, >=, 0) + int32_t patWidth = reader->getPatternWidth(); + DREAM3D_REQUIRED(patWidth, ==, 80) + int32_t patHeight = reader->getPatternHeight(); + DREAM3D_REQUIRED(patHeight, ==, 60) + + int32_t xDim = reader->getXDimension(); + DREAM3D_REQUIRED(xDim, ==, 600) + + int32_t yDim = reader->getYDimension(); + DREAM3D_REQUIRED(yDim, ==, 600) + + std::list scanNames; + err = reader->readScanNames(scanNames); + DREAM3D_REQUIRED(scanNames.size(), ==, 1) + DREAM3D_REQUIRED(scanNames.front(), ==, k_HDF5Path) + + err = reader->readFile(); + + // void* ptr = reader->getPointerByName(ebsdlib::H5Esprit::DD); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + void* ptr = reader->getPointerByName(ebsdlib::H5Esprit::MAD); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::MADPhase); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::NIndexedBands); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::PCX); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::PCY); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::PHI); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::Phase); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::RadonBandCount); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::RadonQuality); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::XBEAM); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::YBEAM); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::XSAMPLE); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::YSAMPLE); + // DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::phi1); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::phi2); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::RawPatterns); + DREAM3D_REQUIRE_NULL_POINTER(ptr); + + // numType = reader->getPointerType(ebsdlib::H5Esprit::DD); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Float) + ebsdlib::NumericTypes::Type numType = reader->getPointerType(ebsdlib::H5Esprit::MAD); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Float) + // numType = reader->getPointerType(ebsdlib::H5Esprit::MADPhase); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Int32) + numType = reader->getPointerType(ebsdlib::H5Esprit::NIndexedBands); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Int32) + // numType = reader->getPointerType(ebsdlib::H5Esprit::PCX); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Float) + // numType = reader->getPointerType(ebsdlib::H5Esprit::PCY); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::PHI); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::Phase); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Int32) + numType = reader->getPointerType(ebsdlib::H5Esprit::RadonBandCount); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Int32) + numType = reader->getPointerType(ebsdlib::H5Esprit::RadonQuality); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::XBEAM); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Int32) + numType = reader->getPointerType(ebsdlib::H5Esprit::YBEAM); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Int32) + // numType = reader->getPointerType(ebsdlib::H5Esprit::XSAMPLE); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Float) + // numType = reader->getPointerType(ebsdlib::H5Esprit::YSAMPLE); + // DREAM3D_REQUIRED(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::phi1); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::phi2); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::Float) + numType = reader->getPointerType(ebsdlib::H5Esprit::RawPatterns); + DREAM3D_REQUIRE(numType == ebsdlib::NumericTypes::Type::UInt8); + + // float* xsamplePtr = reader->getXSAMPLEPointer(); + // DREAM3D_REQUIRE_VALID_POINTER(xsamplePtr); + // reader->releaseXSAMPLEOwnership(); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::XSAMPLE); + // DREAM3D_REQUIRE_NULL_POINTER(ptr); + // reader->deallocateArrayData(xsamplePtr); + + // float* ysamplePtr = reader->getYSAMPLEPointer(); + // DREAM3D_REQUIRE_VALID_POINTER(ysamplePtr); + // reader->releaseYSAMPLEOwnership(); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::YSAMPLE); + // DREAM3D_REQUIRE_NULL_POINTER(ptr); + // reader->deallocateArrayData(ysamplePtr); + + // std::cout << "=============================================================" << std::endl; + std::set arraysToRead; + arraysToRead.insert(ebsdlib::H5Esprit::phi1); + arraysToRead.insert(ebsdlib::H5Esprit::PHI); + arraysToRead.insert(ebsdlib::H5Esprit::phi2); + reader->setArraysToRead(arraysToRead); + err = reader->readFile(); + + ptr = reader->getPointerByName(ebsdlib::H5Esprit::phi1); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::phi2); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + ptr = reader->getPointerByName(ebsdlib::H5Esprit::PHI); + DREAM3D_REQUIRE_VALID_POINTER(ptr); + + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::XSAMPLE); + // DREAM3D_REQUIRE_NULL_POINTER(ptr); + // ptr = reader->getPointerByName(ebsdlib::H5Esprit::YSAMPLE); + // DREAM3D_REQUIRE_NULL_POINTER(ptr); #if 0 reader->setReadPatternData(true); @@ -210,23 +197,4 @@ class H5EspritReaderTest } DREAM3D_REQUIRED(err, >=, 0) #endif - } - - // ----------------------------------------------------------------------------- - void operator()() - { - int err = EXIT_SUCCESS; - - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - DREAM3D_REGISTER_TEST(TestH5EspritReader()) - - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - } - -public: - H5EspritReaderTest(const H5EspritReaderTest&) = delete; // Copy Constructor Not Implemented - H5EspritReaderTest(H5EspritReaderTest&&) = delete; // Move Constructor Not Implemented - H5EspritReaderTest& operator=(const H5EspritReaderTest&) = delete; // Copy Assignment Not Implemented - H5EspritReaderTest& operator=(H5EspritReaderTest&&) = delete; // Move Assignment Not Implemented -}; +} diff --git a/Source/Test/H5OINAReaderTest.cpp b/Source/Test/H5OINAReaderTest.cpp deleted file mode 100644 index d80fc6f0..00000000 --- a/Source/Test/H5OINAReaderTest.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -#include -#include - -#include "H5Support/H5Lite.h" -#include "H5Support/H5ScopedSentinel.h" -#include "H5Support/H5Utilities.h" - -#include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/IO/HKL/H5OINAReader.h" -#include "EbsdLib/Test/EbsdLibTestFileLocations.h" - -#include "UnitTestSupport.hpp" - -class H5OINAReaderTest -{ - const std::string k_HDF5Path = std::string("1"); - -public: - H5OINAReaderTest() = default; - ~H5OINAReaderTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(H5OINAReaderTest) - - // ----------------------------------------------------------------------------- - void RemoveTestFiles() - { -#if REMOVE_TEST_FILES - // fs::remove(UnitTest::H5OINAReaderTest::OutputFile); -#endif - } - -#define H5OINA_CHECK_POINTERS(name, def, type) \ - { \ - type* ptr0 = reader->get##name##Pointer(); \ - void* ptr1 = reader->getPointerByName(def); \ - DREAM3D_REQUIRED(ptr0, ==, ptr1) \ - } - - // ----------------------------------------------------------------------------- - void TestH5OINAReader() - { - H5OINAReader::Pointer reader = H5OINAReader::New(); - reader->setFileName("/Users/mjackson/Desktop/Alumin.h5oina"); - reader->setHDF5Path(k_HDF5Path); - reader->readHeaderOnly(); - - int32_t err = reader->getErrorCode(); - DREAM3D_REQUIRED(err, ==, 0) - - err = reader->readFile(); - DREAM3D_REQUIRED(err, ==, 0) - - H5OINA_CHECK_POINTERS(BandContrast, EbsdLib::H5OINA::BandContrast, uint8_t) - H5OINA_CHECK_POINTERS(BandSlope, EbsdLib::H5OINA::BandSlope, uint8_t) - H5OINA_CHECK_POINTERS(Bands, EbsdLib::H5OINA::Bands, uint8_t) - H5OINA_CHECK_POINTERS(Error, EbsdLib::H5OINA::Error, uint8_t) - H5OINA_CHECK_POINTERS(Euler, EbsdLib::H5OINA::Euler, float) - H5OINA_CHECK_POINTERS(MeanAngularDeviation, EbsdLib::H5OINA::MeanAngularDeviation, float) - H5OINA_CHECK_POINTERS(Phase, EbsdLib::H5OINA::Phase, uint8_t) - H5OINA_CHECK_POINTERS(X, EbsdLib::H5OINA::X, float) - H5OINA_CHECK_POINTERS(Y, EbsdLib::H5OINA::Y, float) - } - - // ----------------------------------------------------------------------------- - void operator()() - { - int err = EXIT_SUCCESS; - - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - DREAM3D_REGISTER_TEST(TestH5OINAReader()) - - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - } - -public: - H5OINAReaderTest(const H5OINAReaderTest&) = delete; // Copy Constructor Not Implemented - H5OINAReaderTest(H5OINAReaderTest&&) = delete; // Move Constructor Not Implemented - H5OINAReaderTest& operator=(const H5OINAReaderTest&) = delete; // Copy Assignment Not Implemented - H5OINAReaderTest& operator=(H5OINAReaderTest&&) = delete; // Move Assignment Not Implemented -}; diff --git a/Source/Test/IPFLegendTest.cpp b/Source/Test/IPFLegendTest.cpp index 442df32c..38f2f09f 100644 --- a/Source/Test/IPFLegendTest.cpp +++ b/Source/Test/IPFLegendTest.cpp @@ -32,117 +32,37 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include -#include -#include -#include +#include #include "EbsdLib/EbsdLib.h" -#include "UnitTestSupport.hpp" - -#include "EbsdLib/EbsdLib.h" -#include "EbsdLib/LaueOps/CubicLowOps.h" #include "EbsdLib/LaueOps/CubicOps.h" -#include "EbsdLib/LaueOps/HexagonalLowOps.h" -#include "EbsdLib/LaueOps/HexagonalOps.h" -#include "EbsdLib/LaueOps/MonoclinicOps.h" -#include "EbsdLib/LaueOps/OrthoRhombicOps.h" -#include "EbsdLib/LaueOps/TetragonalLowOps.h" -#include "EbsdLib/LaueOps/TetragonalOps.h" -#include "EbsdLib/LaueOps/TriclinicOps.h" -#include "EbsdLib/LaueOps/TrigonalLowOps.h" -#include "EbsdLib/LaueOps/TrigonalOps.h" +#include "EbsdLib/Utilities/TiffWriter.h" + +#include "EbsdLib/Apps/EbsdLibFileLocations.h" +#include "UnitTestSupport.hpp" -#include "OrientationLibTestFileLocations.h" +#include #define IMAGE_WIDTH 512 #define IMAGE_HEIGHT 512 -class IPFLegendTest -{ -public: - IPFLegendTest() = default; - ~IPFLegendTest() = default; +using namespace ebsdlib; - IPFLegendTest(const IPFLegendTest&) = delete; // Copy Constructor Not Implemented - IPFLegendTest(IPFLegendTest&&) = delete; // Move Constructor Not Implemented - IPFLegendTest& operator=(const IPFLegendTest&) = delete; // Copy Assignment Not Implemented - IPFLegendTest& operator=(IPFLegendTest&&) = delete; // Move Assignment Not Implemented +// TODO: This unit test needs to compare the output to something that has been verified as correct - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - int getImageSize() - { - return IMAGE_HEIGHT; - } +TEST_CASE("ebsdlib::IPFLegendTest", "[EbsdLib][IPFLegendTest]") +{ + std::vector ops = LaueOps::GetAllOrientationOps(); - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void SaveImage(EbsdLib::UInt8ArrayType::Pointer rgbaImage, const std::string outputFile) + for(size_t index = 0; index < 11; index++) { - QRgb* rgba = reinterpret_cast(rgbaImage->getPointer(0)); - - QImage image(getImageSize(), getImageSize(), QImage::Format_ARGB32_Premultiplied); - - int32_t xDim = getImageSize(); - int32_t yDim = getImageSize(); - size_t idx = 0; - - for(int32_t y = 0; y < yDim; ++y) - { - for(int32_t x = 0; x < xDim; ++x) - { - idx = (y * xDim) + x; - image.setPixel(x, y, rgba[idx]); - } - } - - QFileInfo fi(outputFile); - QDir parent(fi.absolutePath()); - if(parent.exists() == false) + SECTION(ops[index]->getSymmetryName()) { - parent.mkpath(fi.absolutePath()); + ebsdlib::UInt8ArrayType::Pointer image = ops[index]->generateIPFTriangleLegend(IMAGE_WIDTH, false); + std::stringstream outputFilePathStream; + outputFilePathStream << UnitTest::TestTempDir << "/" << ops[index]->getNameOfClass() << ".tiff"; + auto result = TiffWriter::WriteColorImage(outputFilePathStream.str(), IMAGE_WIDTH, IMAGE_WIDTH, 3, image->data()); + REQUIRE(result.first == 0); } - - bool saved = image.save(outputFile); - DREAM3D_REQUIRE(saved == true) -#if REMOVE_TEST_FILES - bool removed = std::fstream::remove(outputFile); - DREAM3D_REQUIRE(removed == true) -#endif - } - - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - template - void TestIPFLegend(const std::string& outputFile) - { - LaueOpsType ops; - EbsdLib::UInt8ArrayType::Pointer image = ops.generateIPFTriangleLegend(IMAGE_WIDTH); - - SaveImage(image, outputFile); - } - - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - - // DREAM3D_REGISTER_TEST( TestIPFLegend(UnitTest::IPFLegendTest::CubicLowFile ) ) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::CubicHighFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::HexagonalLowFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::HexagonalHighFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::MonoclinicFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::OrthorhombicFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::TetragonalLowFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::TetragonalHighFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::TriclinicFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::TrignonalLowFile)) - DREAM3D_REGISTER_TEST(TestIPFLegend(UnitTest::IPFLegendTest::TrignonalHighFile)) } -}; +} diff --git a/Source/Test/Not_Used/H5OINAReaderTest.cpp b/Source/Test/Not_Used/H5OINAReaderTest.cpp new file mode 100644 index 00000000..9fb9a3f6 --- /dev/null +++ b/Source/Test/Not_Used/H5OINAReaderTest.cpp @@ -0,0 +1,48 @@ +#include + +#include "H5Support/H5Lite.h" +#include "H5Support/H5ScopedSentinel.h" +#include "H5Support/H5Utilities.h" + +#include "EbsdLib/Core/EbsdLibConstants.h" +#include "EbsdLib/IO/HKL/H5OINAReader.h" +#include "EbsdLib/Test/EbsdLibTestFileLocations.h" + +#include "UnitTestSupport.hpp" + +#include +#include + +using namespace ebsdlib; +#define H5OINA_CHECK_POINTERS(name, def, type) \ + { \ + type* ptr0 = reader->get##name##Pointer(); \ + void* ptr1 = reader->getPointerByName(def); \ + REQUIRE(ptr0 == ptr1); \ + } + +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::H5OINAReaderTest::TestH5OINAReader", "[EbsdLib][AngleFileLoader]") +{ + const std::string k_HDF5Path = std::string("1"); + H5OINAReader::Pointer reader = H5OINAReader::New(); + reader->setFileName("/Users/mjackson/Desktop/Alumin.h5oina"); + reader->setHDF5Path(k_HDF5Path); + reader->readHeaderOnly(); + + int32_t err = reader->getErrorCode(); + DREAM3D_REQUIRED(err, ==, 0) + + err = reader->readFile(); + DREAM3D_REQUIRED(err, ==, 0) + + H5OINA_CHECK_POINTERS(BandContrast, ebsdlib::H5OINA::BandContrast, uint8_t) + H5OINA_CHECK_POINTERS(BandSlope, ebsdlib::H5OINA::BandSlope, uint8_t) + H5OINA_CHECK_POINTERS(Bands, ebsdlib::H5OINA::Bands, uint8_t) + H5OINA_CHECK_POINTERS(Error, ebsdlib::H5OINA::Error, uint8_t) + H5OINA_CHECK_POINTERS(Euler, ebsdlib::H5OINA::Euler, float) + H5OINA_CHECK_POINTERS(MeanAngularDeviation, ebsdlib::H5OINA::MeanAngularDeviation, float) + H5OINA_CHECK_POINTERS(Phase, ebsdlib::H5OINA::Phase, uint8_t) + H5OINA_CHECK_POINTERS(X, ebsdlib::H5OINA::X, float) + H5OINA_CHECK_POINTERS(Y, ebsdlib::H5OINA::Y, float) +} diff --git a/Source/Test/OrientationTransformsTest.cpp b/Source/Test/Not_Used/OrientationTransformsTest.cpp similarity index 93% rename from Source/Test/OrientationTransformsTest.cpp rename to Source/Test/Not_Used/OrientationTransformsTest.cpp index 0d22f8f6..afd33a4a 100644 --- a/Source/Test/OrientationTransformsTest.cpp +++ b/Source/Test/Not_Used/OrientationTransformsTest.cpp @@ -33,28 +33,20 @@ * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#include -#include -#include -#include -#include - -#include -#include - #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/OrientationMath/OrientationConverter.hpp" -#include "EbsdLib/Utilities/EbsdStringUtils.hpp" #include "GenerateFunctionList.h" #include "TestPrintFunctions.h" #include "UnitTestSupport.hpp" +#include +#include +#include +#include +#include + /* * - DREAM.3D Testing | From/To | e | o | a | r | q | h | c | @@ -67,7 +59,6 @@ | h | X | X | X | X | X | # | | | c | | | | | | | # | - */ class OrientationTransformsTest @@ -97,32 +88,32 @@ class OrientationTransformsTest template void CheckRepresentation(K* data, int repType) { - OrientationTransformation::ResultType res; + ebsdlib::ResultType res; switch(repType) { case 0: - res = OrientationTransformation::eu_check>({data}); + res = ebsdlib::Euler(data).isValid(); break; case 1: - res = OrientationTransformation::om_check>({data}); + res = ebsdlib::OrientationMatrix(data).isValid(); break; case 2: - res = OrientationTransformation::qu_check>({data}); + res = ebsdlib::Quaternion(data).isValid(); break; case 3: - res = OrientationTransformation::ax_check>({data}); + res = ebsdlib::AxisAngle(data).isValid(); break; case 4: - res = OrientationTransformation::ro_check>({data}); + res = ebsdlib::Rodrigues(data).isValid(); break; case 5: - res = OrientationTransformation::ho_check>({data}); + res = ebsdlib::Homochoric(data).isValid(); break; case 6: - res = OrientationTransformation::cu_check>({data}); + res = ebsdlib::Cubochoric(data).isValid(); break; case 7: - res = OrientationTransformation::st_check>({data}); + res = ebsdlib::Stereographic(data).isValid(); break; default: break; diff --git a/Source/Test/SO3SamplerTest.cpp b/Source/Test/Not_Used/SO3SamplerTest.cpp similarity index 95% rename from Source/Test/SO3SamplerTest.cpp rename to Source/Test/Not_Used/SO3SamplerTest.cpp index d4cd9e66..fc724fc5 100644 --- a/Source/Test/SO3SamplerTest.cpp +++ b/Source/Test/Not_Used/SO3SamplerTest.cpp @@ -31,12 +31,11 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include "EbsdLib/LaueOps/SO3Sampler.h" -#include "EbsdLib/Core/OrientationRepresentation.hpp" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/LaueOps.h" #include "EbsdLib/Math/EbsdLibMath.h" +#include "EbsdLib/Orientation/OrientationFwd.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/Utilities/ModifiedLambertProjection3D.hpp" #include "UnitTestSupport.hpp" @@ -90,12 +89,12 @@ class SO3SamplerTest CubochoricDType cu(-0.3217544095666538, 0.2145029397111025, -0.4290058794222050); rod = cu.toRodrigues(); - bool inside = sampler->insideCubicFZ(rod.data(), 4); + bool inside = sampler->insideCubicFZ(rod, 4); DREAM3D_REQUIRE_EQUAL(inside, false); cu = CubochoricDType(-0.42900587942220514, -0.21450293971110265, 0.42900587942220514); rod = cu.toRodrigues(); - inside = sampler->insideCubicFZ(rod.data(), 4); + inside = sampler->insideCubicFZ(rod, 4); DREAM3D_REQUIRE_EQUAL(inside, true); } diff --git a/Source/Test/TestMain.cpp.in b/Source/Test/Not_Used/TestMain.cpp.in similarity index 100% rename from Source/Test/TestMain.cpp.in rename to Source/Test/Not_Used/TestMain.cpp.in diff --git a/Source/Test/TestPrintFunctions.h b/Source/Test/Not_Used/TestPrintFunctions.h similarity index 93% rename from Source/Test/TestPrintFunctions.h rename to Source/Test/Not_Used/TestPrintFunctions.h index 5d957ea9..0ab23a83 100644 --- a/Source/Test/TestPrintFunctions.h +++ b/Source/Test/Not_Used/TestPrintFunctions.h @@ -6,19 +6,19 @@ #include #include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/Quaternion.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" static const std::string DCName("Orientation Transforms Test"); static const std::string AMName("Angles"); #define s_NumReps 8 -std::string k_InputNames[s_NumReps] = {"eu", "om", "qu", "ax", "ro", "ho", "cu", "st"}; -int k_CompDims[s_NumReps] = {3, 9, 4, 4, 4, 3, 3, 3}; - -namespace OrientationPrinters +namespace ebsdlib { +const std::string k_InputNames[s_NumReps] = {"eu", "om", "qu", "ax", "ro", "ho", "cu", "st"}; +const int k_CompDims[s_NumReps] = {3, 9, 4, 4, 4, 3, 3, 3}; + // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- @@ -97,8 +97,8 @@ void Print_QU(const T& om, typename T::Order layout) } // ----------------------------------------------------------------------------- -template -void Print_QU(const QuaternionType& q) +template +void Print_QU(const Quaternion& q) { printf("QU:<% 3.16f % 3.6f % 3.16f> % 3.16f\n", q.x(), q.y(), q.z(), q.w()); } @@ -143,4 +143,4 @@ void PrintTuple(typename DataArrayClass::Pointer data, size_t t) } printf("\n"); } -} // namespace OrientationPrinters +} // namespace ebsdlib diff --git a/Source/Test/ODFTest.cpp b/Source/Test/ODFTest.cpp index 2ff80a8e..c05fde3c 100644 --- a/Source/Test/ODFTest.cpp +++ b/Source/Test/ODFTest.cpp @@ -32,23 +32,19 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -/** - * @brief main.cpp This is mainly a test to make sure that the Texture.h - * file will compile using strict STL containers - * @param argc - * @param argv - * @return - */ -#include -#include +#include #include "EbsdLib/LaueOps/CubicOps.h" #include "EbsdLib/Math/EbsdLibMath.h" #include "EbsdLib/Texture/StatsGen.hpp" #include "EbsdLib/Texture/Texture.hpp" -#include "TestPrintFunctions.h" +#include +#include + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +// TODO: THIS TEST SHOULD BE UPDATED TO ACTUALLY COMPARE RESULTS AGAINST A KNOWN GOOD DATA SET +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #define POPULATE_DATA(i, e1, e2, e3, w, s) \ e1s[i] = e1; \ @@ -57,90 +53,65 @@ weights[i] = w; \ sigmas[i] = s; -class ODFTest +using namespace ebsdlib; +// ----------------------------------------------------------------------------- +template +void Print_Coord(const T* om) +{ + printf("Coord:% 3.16f % 3.16f % 3.16f\n", om[0], om[1], om[2]); +} + +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::ODFTest::CubicODFTest", "[EbsdLib][ODFTest]") { -public: - ODFTest() = default; - ~ODFTest() = default; - - // ----------------------------------------------------------------------------- - template - void Print_Coord(const T* om) - { - printf("Coord:% 3.16f % 3.16f % 3.16f\n", om[0], om[1], om[2]); - } - - void CubicODFTest() - { // Resize the ODF vector properly for Cubic - CubicOps ops; - std::vector odf(ops.getODFSize()); - std::vector e1s(2); - std::vector e2s(2); - std::vector e3s(2); - std::vector weights(2); - std::vector sigmas(2); - - POPULATE_DATA(0, 35, 45, 0, 1000.0, 2.0) - POPULATE_DATA(1, 59, 37, 63, 1000.0, 1.0) - - // Calculate the ODF Data - - size_t numEntries = e1s.size(); - Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); - - size_t npoints = 1000; - std::vector x001(npoints * 3); - std::vector y001(npoints * 3); - std::vector x011(npoints * 6); - std::vector y011(npoints * 6); - std::vector x111(npoints * 4); - std::vector y111(npoints * 4); - } - - void TestRotation() - { - float phi1 = 0.0f * EbsdLib::Constants::k_PiOver180D; - float PHI = 180.0f; - float phi2 = 0.0f; - - // float ga[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}; - - Matrix3X3 ga = EulerFType(phi1, PHI, phi2).toOrientationMatrix().toGMatrixObj<>(); - - // OrientationTransformation::eu2om(OrientationF(phi1, PHI, phi2)).toGMatrix(ga); - - Matrix3X1 coordsRotated = {0.0f, 0.0f, 0.0f}; - Matrix3X1 coords = {0.0f, 0.0f, 0.0f}; - float xc = -0.0; - float yc = -5.0; - float zc = 0.0; - coords[0] = coords[0] - xc; - coords[1] = coords[1] - yc; - coords[2] = coords[2] - zc; - - coordsRotated = ga * coords; - - Print_Coord(coords.data()); - Print_Coord(coordsRotated.data()); - } - - void operator()() - { - std::cout << "<===== Start ODF Test" << std::endl; - - TestRotation(); - CubicODFTest(); - - int err = 0; - - if(err == 1) - { - // TODO: Present Error Message - return; - } - } - -private: - ODFTest(const ODFTest&); // Copy Constructor Not Implemented - void operator=(const ODFTest&); // Move assignment Not Implemented -}; + CubicOps ops; + std::vector odf(ops.getODFSize()); + std::vector e1s(2); + std::vector e2s(2); + std::vector e3s(2); + std::vector weights(2); + std::vector sigmas(2); + + POPULATE_DATA(0, 35, 45, 0, 1000.0, 2.0) + POPULATE_DATA(1, 59, 37, 63, 1000.0, 1.0) + + // Calculate the ODF Data + + size_t numEntries = e1s.size(); + Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); + + size_t npoints = 1000; + std::vector x001(npoints * 3); + std::vector y001(npoints * 3); + std::vector x011(npoints * 6); + std::vector y011(npoints * 6); + std::vector x111(npoints * 4); + std::vector y111(npoints * 4); +} + +TEST_CASE("ebsdlib::ODFTest::TestRotation", "[EbsdLib][ODFTest]") +{ + float phi1 = 0.0f * ebsdlib::constants::k_PiOver180D; + float PHI = 180.0f; + float phi2 = 0.0f; + + // float ga[3][3] = {{0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}}; + + Matrix3X3 ga = EulerFType(phi1, PHI, phi2).toOrientationMatrix().toGMatrix(); + + // OrientationTransformation::eu2om(OrientationF(phi1, PHI, phi2)).toGMatrix(ga); + + Matrix3X1 coordsRotated = {0.0f, 0.0f, 0.0f}; + Matrix3X1 coords = {0.0f, 0.0f, 0.0f}; + float xc = -0.0; + float yc = -5.0; + float zc = 0.0; + coords[0] = coords[0] - xc; + coords[1] = coords[1] - yc; + coords[2] = coords[2] - zc; + + coordsRotated = ga * coords; + + Print_Coord(coords.data()); + Print_Coord(coordsRotated.data()); +} diff --git a/Source/Test/OrientationConverterTest.cpp b/Source/Test/OrientationConverterTest.cpp index efa22d2a..d36aafa5 100644 --- a/Source/Test/OrientationConverterTest.cpp +++ b/Source/Test/OrientationConverterTest.cpp @@ -32,6 +32,7 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include #include #include @@ -39,162 +40,133 @@ #include "EbsdLib/Core/EbsdDataArray.hpp" #include "EbsdLib/Core/EbsdLibConstants.h" -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/LaueOps/CubicOps.h" +#include "EbsdLib/Orientation/Quaternion.hpp" #include "EbsdLib/OrientationMath/OrientationConverter.hpp" -#include "TestPrintFunctions.h" #include "UnitTestSupport.hpp" -class OrientationConverterTest -{ -public: - OrientationConverterTest() = default; - ~OrientationConverterTest() = default; - - OrientationConverterTest(const OrientationConverterTest&) = delete; // Copy Constructor Not Implemented - OrientationConverterTest(OrientationConverterTest&&) = delete; // Move Constructor Not Implemented - OrientationConverterTest& operator=(const OrientationConverterTest&) = delete; // Copy Assignment Not Implemented - OrientationConverterTest& operator=(OrientationConverterTest&&) = delete; // Move Assignment Not Implemented - - EBSD_GET_NAME_OF_CLASS_DECL(OrientationConverterTest) +using namespace ebsdlib; - // ----------------------------------------------------------------------------- - void TestEuler2Quaternion() +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::OrientationConverterTest::TestEuler2Quaternion", "[EbsdLib][OrientationConverterTest]") +{ + size_t nTuples = 2; + // int qStride = 4; + std::vector cDims(1, 3); + ebsdlib::FloatArrayType::Pointer eulers = ebsdlib::FloatArrayType::CreateArray(nTuples, cDims, "Eulers", true); + // Initialize the Eulers with some values + eulers->setComponent(0, 0, 302.84f * ebsdlib::constants::k_PiOver180F); + eulers->setComponent(0, 1, 51.282f * ebsdlib::constants::k_PiOver180F); + eulers->setComponent(0, 2, 37.969f * ebsdlib::constants::k_PiOver180F); + eulers->setComponent(1, 0, 45.0f * ebsdlib::constants::k_PiOver180F); + eulers->setComponent(1, 1, 0.0f * ebsdlib::constants::k_PiOver180F); + eulers->setComponent(1, 2, 0.0f * ebsdlib::constants::k_PiOver180F); + + // float rad = 302.84f * static_cast(ebsdlib::constants::k_PiOver180); + // std::cout << "Rad: " << rad << std::endl; + // std::cout << "2Pi: " << ebsdlib::constants::k_2Pi << std::endl; + + // std::cout << "Remainer (302.84/360): " << remainder(rad, ebsdlib::constants::k_2Pi) << std::endl; + // std::cout << "fmod (5.28556 / 2Pi): " << fmod(rad, ebsdlib::constants::k_2Pi) << std::endl; + + OrientationConverter::Pointer ocEulers = EulerConverter::New(); + ocEulers->setInputData(eulers); + ocEulers->convertRepresentationTo(ebsdlib::orientations::Type::Quaternion); + + ebsdlib::FloatArrayType::Pointer output = ocEulers->getOutputData(); + + std::vector exemplar = {-0.2919894754886627F, 0.319372F, 0.1502762138843536F, 0.8889099955558777F, 0.0000000000000000F, -0.000000F, -0.3826834559440613F, 0.9238795042037964F}; + + for(size_t i = 0; i < 8; i++) { - size_t nTuples = 2; - // int qStride = 4; - std::vector cDims(1, 3); - EbsdLib::FloatArrayType::Pointer eulers = EbsdLib::FloatArrayType::CreateArray(nTuples, cDims, "Eulers", true); - // Initialize the Eulers with some values - eulers->setComponent(0, 0, 302.84f * EbsdLib::Constants::k_PiOver180F); - eulers->setComponent(0, 1, 51.282f * EbsdLib::Constants::k_PiOver180F); - eulers->setComponent(0, 2, 37.969f * EbsdLib::Constants::k_PiOver180F); - eulers->setComponent(1, 0, 45.0f * EbsdLib::Constants::k_PiOver180F); - eulers->setComponent(1, 1, 0.0f * EbsdLib::Constants::k_PiOver180F); - eulers->setComponent(1, 2, 0.0f * EbsdLib::Constants::k_PiOver180F); - - // float rad = 302.84f * static_cast(EbsdLib::Constants::k_PiOver180); - // std::cout << "Rad: " << rad << std::endl; - // std::cout << "2Pi: " << EbsdLib::Constants::k_2Pi << std::endl; - - // std::cout << "Remainer (302.84/360): " << remainder(rad, EbsdLib::Constants::k_2Pi) << std::endl; - // std::cout << "fmod (5.28556 / 2Pi): " << fmod(rad, EbsdLib::Constants::k_2Pi) << std::endl; - - OrientationConverter::Pointer ocEulers = EulerConverter::New(); - ocEulers->setInputData(eulers); - ocEulers->convertRepresentationTo(OrientationRepresentation::Type::Quaternion); - - EbsdLib::FloatArrayType::Pointer output = ocEulers->getOutputData(); - - std::vector exemplar = {-0.2919894754886627F, 0.319372F, 0.1502762138843536F, 0.8889099955558777F, 0.0000000000000000F, -0.000000F, -0.3826834559440613F, 0.9238795042037964F}; - - for(size_t i = 0; i < 8; i++) - { - float delta = std::abs(exemplar[i] - (*output)[i]); - DREAM3D_REQUIRE(delta < 1.0E6); - } - - EulerFType euler = {302.84f * EbsdLib::Constants::k_PiOver180F, 51.282f * EbsdLib::Constants::k_PiOver180F, 37.969f * EbsdLib::Constants::k_PiOver180F}; - QuatF qOut = OrientationTransformation::eu2qu(euler); - OrientationPrinters::Print_QU(qOut); + float delta = std::abs(exemplar[i] - (*output)[i]); + REQUIRE(delta < 1.0E6); } +} - // ----------------------------------------------------------------------------- - void TestEulerAngle(float phi1, float phi, float phi2) +// ----------------------------------------------------------------------------- +void TestEulerAngle(float phi1, float phi, float phi2) +{ + // std::cout << "TESTING EULER ANGLE (Rad): " << phi1 << ", " << phi << ", " << phi2 << std::endl; + + size_t nTuples = 1; + int qStride = 4; + std::vector cDims(1, 3); + ebsdlib::FloatArrayType::Pointer eulers = ebsdlib::FloatArrayType::CreateArray(nTuples, cDims, "Eulers", true); + // Initialize the Eulers with some values + eulers->setComponent(0, 0, phi1); + eulers->setComponent(0, 1, phi); + eulers->setComponent(0, 2, phi2); + + using StringContainerType = std::vector; + using OCType = OrientationConverter; + std::vector ocTypes = OCType::GetOrientationTypes(); + auto tStrings = OCType::GetOrientationTypeStrings(); + std::vector converters(6); + converters[0] = EulerConverter::New(); + converters[1] = OrientationMatrixConverter::New(); + converters[2] = QuaternionConverter::New(); + converters[3] = AxisAngleConverter::New(); + converters[4] = RodriguesConverter::New(); + converters[5] = HomochoricConverter::New(); + // converters[6] = CubochoricConverter::New(); + + auto strides = OCType::GetComponentCounts>(); + + for(size_t t0 = 0; t0 < 1; t0++) { - // std::cout << "TESTING EULER ANGLE (Rad): " << phi1 << ", " << phi << ", " << phi2 << std::endl; - - size_t nTuples = 1; - int qStride = 4; - std::vector cDims(1, 3); - EbsdLib::FloatArrayType::Pointer eulers = EbsdLib::FloatArrayType::CreateArray(nTuples, cDims, "Eulers", true); - // Initialize the Eulers with some values - eulers->setComponent(0, 0, phi1); - eulers->setComponent(0, 1, phi); - eulers->setComponent(0, 2, phi2); - - using StringContainerType = std::vector; - using OCType = OrientationConverter; - std::vector ocTypes = OCType::GetOrientationTypes(); - auto tStrings = OCType::GetOrientationTypeStrings(); - std::vector converters(6); - converters[0] = EulerConverter::New(); - converters[1] = OrientationMatrixConverter::New(); - converters[2] = QuaternionConverter::New(); - converters[3] = AxisAngleConverter::New(); - converters[4] = RodriguesConverter::New(); - converters[5] = HomochoricConverter::New(); - // converters[6] = CubochoricConverter::New(); - - OrientationTransformation::ResultType result; - auto strides = OCType::GetComponentCounts>(); - - for(size_t t0 = 0; t0 < 1; t0++) + for(size_t t1 = 1; t1 < converters.size(); t1++) { - for(size_t t1 = 1; t1 < converters.size(); t1++) + if(t0 == t1) { - if(t0 == t1) - { - continue; - } + continue; + } - converters[t0]->setInputData(eulers); - converters[t0]->convertRepresentationTo(ocTypes[t1]); - EbsdLib::FloatArrayType::Pointer t1_output = converters[t0]->getOutputData(); + converters[t0]->setInputData(eulers); + converters[t0]->convertRepresentationTo(ocTypes[t1]); + ebsdlib::FloatArrayType::Pointer t1_output = converters[t0]->getOutputData(); - converters[t1]->setInputData(t1_output); - converters[t1]->convertRepresentationTo(ocTypes[t0]); - EbsdLib::FloatArrayType::Pointer t0_output = converters[t1]->getOutputData(); + converters[t1]->setInputData(t1_output); + converters[t1]->convertRepresentationTo(ocTypes[t0]); + ebsdlib::FloatArrayType::Pointer t0_output = converters[t1]->getOutputData(); - qStride = strides[t0]; - std::vector delta(qStride, 0); - for(size_t i = 0; i < nTuples; i++) + qStride = strides[t0]; + std::vector delta(qStride, 0); + for(size_t i = 0; i < nTuples; i++) + { + float* orig = eulers->getPointer(i * qStride); + float* converted = t0_output->getPointer(i * qStride); + // printf("%s -> %s -> %s\n", tStrings[t0].toLatin1().constData(), tStrings[t1].toLatin1().constData(), tStrings[t0].toLatin1().constData()); + for(size_t j = 0; j < qStride; j++) { - float* orig = eulers->getPointer(i * qStride); - float* converted = t0_output->getPointer(i * qStride); - // printf("%s -> %s -> %s\n", tStrings[t0].toLatin1().constData(), tStrings[t1].toLatin1().constData(), tStrings[t0].toLatin1().constData()); - for(size_t j = 0; j < qStride; j++) - { - delta[j] = std::abs(orig[j] - converted[j]); - DREAM3D_REQUIRE(delta[j] < 1.0E6); - } + delta[j] = std::abs(orig[j] - converted[j]); + REQUIRE(delta[j] < 1.0E6); } } } } +} - // ----------------------------------------------------------------------------- - void TestEulerConversion() - { +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::OrientationConverterTest::TestEulerConversion", "[EbsdLib][OrientationConverterTest]") +{ - float numSteps = 4.0F; - float phi1Inc = 360.0F / numSteps; - float phiInc = 180.0F / numSteps; - float phi2Inc = 360.0F / numSteps; + float numSteps = 4.0F; + float phi1Inc = 360.0F / numSteps; + float phiInc = 180.0F / numSteps; + float phi2Inc = 360.0F / numSteps; - for(float p2 = 0.0; p2 < 361.0; p2 = p2 + phi2Inc) + for(float p2 = 0.0; p2 < 361.0; p2 = p2 + phi2Inc) + { + for(float p = 0.0; p < 181.0; p = p + phiInc) { - for(float p = 0.0; p < 181.0; p = p + phiInc) + for(float p1 = 0.0; p1 < 361.0; p1 = p1 + phi1Inc) { - for(float p1 = 0.0; p1 < 361.0; p1 = p1 + phi1Inc) - { - // std::cout << "TESTING EULER ANGLE (Degrees): " << p1 << ", " << p << ", " << p2 << std::endl; - TestEulerAngle(p1 * EbsdLib::Constants::k_PiOver180F, p * EbsdLib::Constants::k_PiOver180F, p2 * EbsdLib::Constants::k_PiOver180F); - } + // std::cout << "TESTING EULER ANGLE (Degrees): " << p1 << ", " << p << ", " << p2 << std::endl; + TestEulerAngle(p1 * ebsdlib::constants::k_PiOver180F, p * ebsdlib::constants::k_PiOver180F, p2 * ebsdlib::constants::k_PiOver180F); } } } - - // ----------------------------------------------------------------------------- - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = 0; - DREAM3D_REGISTER_TEST(TestEuler2Quaternion()); - DREAM3D_REGISTER_TEST(TestEulerConversion()); - } -}; +} diff --git a/Source/Test/OrientationMathTest.cpp b/Source/Test/OrientationMathTest.cpp deleted file mode 100644 index c3f2a253..00000000 --- a/Source/Test/OrientationMathTest.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* ============================================================================ - * Copyright (c) 2009-2025 BlueQuartz Software, LLC - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its - * contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The code contained herein was partially funded by the following contracts: - * United States Air Force Prime Contract FA8650-07-D-5800 - * United States Air Force Prime Contract FA8650-10-D-5210 - * United States Prime Contract Navy N00173-07-C-2068 - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -#include "UnitTestSupport.hpp" - -#include "OrientationLibTestFileLocations.h" - -// ----------------------------------------------------------------------------- -// Use test framework -// ----------------------------------------------------------------------------- -int main(int argc, char** argv) -{ - int err = EXIT_SUCCESS; - - PRINT_TEST_SUMMARY(); - return err; -} diff --git a/Source/Test/OrientationRepresentationTransformTest.cpp b/Source/Test/OrientationRepresentationTransformTest.cpp deleted file mode 100644 index 3119d1c2..00000000 --- a/Source/Test/OrientationRepresentationTransformTest.cpp +++ /dev/null @@ -1,563 +0,0 @@ - -#include "EbsdLib/Core/EbsdDataArray.hpp" -#include "EbsdLib/Core/OrientationRepresentation.hpp" - -#include "EbsdLib/Test/EbsdLibTestFileLocations.h" -#include "GenerateFunctionList.h" -#include "TestPrintFunctions.h" -#include "UnitTestSupport.hpp" - -#include -#include -#include -#include -#include -#include - -using namespace EbsdLib; - -class OrientationRepresentationTransformTest -{ -public: - OrientationRepresentationTransformTest() = default; - virtual ~OrientationRepresentationTransformTest() = default; - - OrientationRepresentationTransformTest(const OrientationRepresentationTransformTest&) = delete; // Copy Constructor Not Implemented - OrientationRepresentationTransformTest(OrientationRepresentationTransformTest&&) = delete; // Move Constructor Not Implemented - OrientationRepresentationTransformTest& operator=(const OrientationRepresentationTransformTest&) = delete; // Copy Assignment Not Implemented - OrientationRepresentationTransformTest& operator=(OrientationRepresentationTransformTest&&) = delete; // Move Assignment Not Implemented - - EBSD_GET_NAME_OF_CLASS_DECL(OrientationRepresentationTransformTest) - - void Test1() - { - - { - EulerDType euler(0.0, 0.0, 0.0); - QuatD quat = euler.toQuat(); - EulerDType e1 = euler.toOrientationMatrix().toEuler(); - } - - { - QuatD quat = EulerDType(0.0f, 0.0f, 0.0f).toOrientationMatrix().toQuat(); - OrientationPrinters::Print_QU(quat); - } - - { - AxisAngleDType ax = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle(); - OrientationMatrixDType om = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix(); - RodriguesDType ro = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues(); - HomochoricDType ho = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues().toHomochoric(); - CubochoricDType cu = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toOrientationMatrix().toRodrigues().toHomochoric().toCubochoric(); - - QuatD quat = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle().toQuat(); - } - - AxisAngleDType ax = EulerDType(0.0f, 1.570f, 0.0f).toAxisAngle(); - OrientationPrinters::Print_AX(ax); - } - - std::string k_MethodNames[s_NumReps] = {"Euler", "OrientationMatrix", "Quaternion", "AxisAngle", "Rodrigues", "Homochoric", "Cubochoric", "Stereographic"}; - int k_CompDims[s_NumReps] = {3, 9, 4, 4, 4, 3, 3, 3}; - - template - void printVector(const std::vector& vec) - { - std::cout << " GENERATE_TEST_METHOD("; - for(size_t i = 0; i < vec.size(); i++) - { - // std::cout << vec[i]; - std::cout << k_MethodNames[vec[i]] << ""; - if(i < vec.size() - 1) - { - std::cout << ", "; - } - } - std::cout << ");"; - } - - void StartTest() - { - // std::vector functionNames = OrientationConverter::GetOrientationTypeStrings(); - - GenerateFunctionList generator; - std::vector entries = generator.GeneratePermutationsOfCombinations(s_NumReps, 3); - // This outer loop will group the tests based on the first orientation representation - for(int t = 0; t < s_NumReps; t++) - { - std::cout << "void " << k_MethodNames[t] << "Test() {\n"; - std::cout << " TEST_PREAMBLE();\n\n"; - for(auto& entry : entries) - { - if(entry[0] != t) - { - continue; - } - entry.push_back(entry[0]); - { - // RunTestCase(entry, 16); - printVector(entry); - std::cout << "\n"; - } - } - std::cout << "}\n\n"; - } - } - -#define TEST_PREAMBLE() \ - using EbsdDataArrayType = EbsdDataArray; \ - using EbsdDataArrayPointerType = EbsdDataArrayType::Pointer; \ - size_t nSteps = 16; \ - std::map attrMat; \ - generate_test_data::GenerateEulers(nSteps, attrMat); \ - EbsdDataArrayType& inputArray = *(attrMat["eu"]); \ - size_t numTuples = inputArray.getNumberOfTuples(); \ - double tolerance = 1.0E-3; \ - std::string k_EulerStr("Euler"); - -#define GENERATE_TEST_METHOD_EU(TYPE1, TYPE2, TYPE3, TYPE4) \ - { \ - std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ - for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ - { \ - const EulerDType euler = EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ - const TYPE1##DType type1 = euler.to##TYPE1(); \ - const TYPE2##DType type2 = type1.to##TYPE2(); \ - const TYPE3##DType type3 = type2.to##TYPE3(); \ - TYPE4##DType type4 = type3.to##TYPE4().toOrientationMatrix().toEuler(); \ - bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ - if(!withinTolerance) \ - { \ - std::cout << "Index: " << tupleIdx << "\n"; \ - std::cout << type1 << "\n"; \ - std::cout << type4 << "\n"; \ - } \ - DREAM3D_REQUIRED(withinTolerance, ==, true) \ - } \ - } - -#define GENERATE_TEST_METHOD(TYPE1, TYPE2, TYPE3, TYPE4) \ - { \ - std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ - for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ - { \ - const EulerDType euler = EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ - const TYPE1##DType type1 = euler.to##TYPE1(); \ - const TYPE2##DType type2 = type1.to##TYPE2(); \ - const TYPE3##DType type3 = type2.to##TYPE3(); \ - TYPE4##DType type4 = type3.to##TYPE4(); \ - bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ - if(!withinTolerance) \ - { \ - std::cout << "Index: " << tupleIdx << "\n"; \ - std::cout << type1 << "\n"; \ - std::cout << type4 << "\n"; \ - } \ - DREAM3D_REQUIRED(withinTolerance, ==, true) \ - } \ - } - - void EulerTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Cubochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, OrientationMatrix, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, Cubochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, Quaternion, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, Quaternion, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Cubochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, AxisAngle, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Cubochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, Rodrigues, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, Cubochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Homochoric, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, Homochoric, Euler); - GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Stereographic, Euler); - GENERATE_TEST_METHOD_EU(Euler, Stereographic, Cubochoric, Euler); - } - - void OrientationMatrixTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(OrientationMatrix, Euler, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Euler, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Euler, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Euler, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Euler, Cubochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Euler, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Euler, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Cubochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Quaternion, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Cubochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, AxisAngle, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Cubochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Rodrigues, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Cubochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Homochoric, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Stereographic, OrientationMatrix); - GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Cubochoric, OrientationMatrix); - } - - void QuaternionTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(Quaternion, Euler, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Euler, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Euler, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Euler, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Euler, Cubochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Euler, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, Euler, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Cubochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, OrientationMatrix, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, Cubochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, AxisAngle, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, AxisAngle, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, Cubochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Rodrigues, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, Rodrigues, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, Cubochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Homochoric, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, Homochoric, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Cubochoric, Stereographic, Quaternion); - GENERATE_TEST_METHOD(Quaternion, Stereographic, Cubochoric, Quaternion); - } - - void AxisAngleTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(AxisAngle, Euler, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Euler, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Euler, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Euler, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Euler, Cubochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Euler, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, Euler, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Cubochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, OrientationMatrix, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, Cubochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Quaternion, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, Quaternion, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Cubochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, Rodrigues, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, Cubochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Homochoric, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, Homochoric, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Stereographic, AxisAngle); - GENERATE_TEST_METHOD(AxisAngle, Stereographic, Cubochoric, AxisAngle); - } - - void RodriguesTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(Rodrigues, Euler, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Euler, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Euler, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Euler, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Euler, Cubochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Euler, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, Euler, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Cubochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, OrientationMatrix, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, Cubochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Quaternion, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, Quaternion, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Cubochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, AxisAngle, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, Cubochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Homochoric, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, Homochoric, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Stereographic, Rodrigues); - GENERATE_TEST_METHOD(Rodrigues, Stereographic, Cubochoric, Rodrigues); - } - - void HomochoricTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(Homochoric, Euler, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Euler, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Euler, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Euler, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Euler, Cubochoric, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Euler, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, Euler, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Cubochoric, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, OrientationMatrix, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, Cubochoric, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Quaternion, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, Quaternion, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, Cubochoric, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, AxisAngle, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, AxisAngle, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, Cubochoric, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Rodrigues, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, Rodrigues, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Cubochoric, Stereographic, Homochoric); - GENERATE_TEST_METHOD(Homochoric, Stereographic, Cubochoric, Homochoric); - } - - void CubochoricTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(Cubochoric, Euler, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Euler, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Euler, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Euler, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Euler, Homochoric, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Euler, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, Euler, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Homochoric, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, OrientationMatrix, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, Homochoric, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Quaternion, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, Quaternion, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Homochoric, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, AxisAngle, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Homochoric, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, Rodrigues, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Homochoric, Stereographic, Cubochoric); - GENERATE_TEST_METHOD(Cubochoric, Stereographic, Homochoric, Cubochoric); - } - - void StereographicTest() - { - TEST_PREAMBLE(); - - GENERATE_TEST_METHOD(Stereographic, Euler, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Euler, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Euler, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Euler, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Euler, Homochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Euler, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, Euler, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Homochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, OrientationMatrix, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, Homochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Quaternion, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, Quaternion, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, Homochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, AxisAngle, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, AxisAngle, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, Homochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Rodrigues, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, Rodrigues, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Homochoric, Cubochoric, Stereographic); - GENERATE_TEST_METHOD(Stereographic, Cubochoric, Homochoric, Stereographic); - } - - // ----------------------------------------------------------------------------- - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - - int err = EXIT_SUCCESS; - // DREAM3D_REGISTER_TEST(StartTest()); - - DREAM3D_REGISTER_TEST(Test1()); - - DREAM3D_REGISTER_TEST(EulerTest()); - DREAM3D_REGISTER_TEST(OrientationMatrixTest()); - DREAM3D_REGISTER_TEST(QuaternionTest()); - DREAM3D_REGISTER_TEST(AxisAngleTest()); - DREAM3D_REGISTER_TEST(RodriguesTest()); - DREAM3D_REGISTER_TEST(HomochoricTest()); - DREAM3D_REGISTER_TEST(CubochoricTest()); - DREAM3D_REGISTER_TEST(StereographicTest()); - } -}; diff --git a/Source/Test/OrientationTest.cpp b/Source/Test/OrientationTest.cpp new file mode 100644 index 00000000..24290fc1 --- /dev/null +++ b/Source/Test/OrientationTest.cpp @@ -0,0 +1,578 @@ +#include + +#include "EbsdLib/Core/EbsdDataArray.hpp" +#include "EbsdLib/Math/Matrix3X1.hpp" +#include "EbsdLib/Math/Matrix3X3.hpp" +#include "EbsdLib/Orientation/AxisAngle.hpp" +#include "EbsdLib/Orientation/Cubochoric.hpp" +#include "EbsdLib/Orientation/Euler.hpp" +#include "EbsdLib/Orientation/Homochoric.hpp" +#include "EbsdLib/Orientation/OrientationMatrix.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Orientation/Rodrigues.hpp" +#include "EbsdLib/Orientation/Stereographic.hpp" + +#include "GenerateFunctionList.h" +#include "UnitTestSupport.hpp" + +#include +#include +#include +#include +#include +#include +#include + +using namespace ebsdlib; + +#define TEST_PREAMBLE() \ + using EbsdDataArrayType = EbsdDataArray; \ + using EbsdDataArrayPointerType = EbsdDataArrayType::Pointer; \ + size_t nSteps = 16; \ + std::map attrMat; \ + generate_test_data::GenerateEulers(nSteps, attrMat); \ + EbsdDataArrayType& inputArray = *(attrMat["eu"]); \ + size_t numTuples = inputArray.getNumberOfTuples(); \ + double tolerance = 1.0E-3; \ + std::string k_EulerStr("Euler"); + +#define GENERATE_TEST_METHOD_EU(TYPE1, TYPE2, TYPE3, TYPE4) \ + { \ + std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ + for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ + { \ + const ebsdlib::EulerDType euler = ebsdlib::EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ + const ebsdlib::TYPE1##DType type1 = euler.to##TYPE1(); \ + const ebsdlib::TYPE2##DType type2 = type1.to##TYPE2(); \ + const ebsdlib::TYPE3##DType type3 = type2.to##TYPE3(); \ + ebsdlib::TYPE4##DType type4 = type3.to##TYPE4().toOrientationMatrix().toEuler(); \ + bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ + if(!withinTolerance) \ + { \ + std::cout << "Index: " << tupleIdx << "\n"; \ + std::cout << type1 << "\n"; \ + std::cout << type4 << "\n"; \ + } \ + DREAM3D_REQUIRED(withinTolerance, ==, true) \ + auto result = type4.isValid(); \ + if(result.result != 1) \ + { \ + std::cout << result.msg << std::endl; \ + } \ + REQUIRE(result.result == 1); \ + } \ + } + +#define GENERATE_TEST_METHOD(TYPE1, TYPE2, TYPE3, TYPE4) \ + { \ + std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE3 << " -> " << #TYPE4 << "\n"; \ + for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ + { \ + const ebsdlib::EulerDType euler = ebsdlib::EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ + const ebsdlib::TYPE1##DType type1 = euler.to##TYPE1(); \ + const ebsdlib::TYPE2##DType type2 = type1.to##TYPE2(); \ + const ebsdlib::TYPE3##DType type3 = type2.to##TYPE3(); \ + ebsdlib::TYPE4##DType type4 = type3.to##TYPE4(); \ + bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ + if(!withinTolerance) \ + { \ + std::cout << "Index: " << tupleIdx << "\n"; \ + std::cout << type1 << "\n"; \ + std::cout << type4 << "\n"; \ + } \ + DREAM3D_REQUIRED(withinTolerance, ==, true) \ + auto result = type4.isValid(); \ + if(result.result != 1) \ + { \ + std::cout << euler << std::endl; \ + std::cout << type1 << std::endl; \ + std::cout << type2 << std::endl; \ + std::cout << type3 << std::endl; \ + std::cout << type4 << std::endl; \ + std::cout << result.msg << std::endl; \ + } \ + REQUIRE(result.result == 1); \ + } \ + } + +#define GENERATE_TEST_METHOD_2(TYPE1, TYPE2, TYPE3, TYPE4) \ + { \ + std::cout << "Starting " << #TYPE1 << " -> " << #TYPE2 << " -> " << #TYPE4 << "\n"; \ + for(size_t tupleIdx = 0; tupleIdx < numTuples; tupleIdx++) \ + { \ + const ebsdlib::EulerDType euler = ebsdlib::EulerDType(inputArray[tupleIdx * 3], inputArray[tupleIdx * 3 + 1], inputArray[tupleIdx * 3 + 2]).toOrientationMatrix().toEuler(); \ + const ebsdlib::TYPE1##DType type1 = euler.to##TYPE1(); \ + const ebsdlib::TYPE2##DType type2 = type1.to##TYPE2(); \ + ebsdlib::TYPE4##DType type4 = type2.to##TYPE4(); \ + bool withinTolerance = type4.isWithinTolerance(type1, tolerance); \ + if(!withinTolerance) \ + { \ + std::cout << "Index: " << tupleIdx << "\n"; \ + std::cout << type1 << "\n"; \ + std::cout << type4 << "\n"; \ + } \ + DREAM3D_REQUIRED(withinTolerance, ==, true) \ + auto result = type2.isValid(); \ + if(result.result != 1) \ + { \ + std::cout << result.msg << std::endl; \ + } \ + REQUIRE(result.result == 1); \ + } \ + } + +TEST_CASE("ebsdlib::Orientations::EulerConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::EulerDType euler(0.0, 0.0, 0.0); + OrientationMatrix om = euler.toOrientationMatrix(); + AxisAngle ax = euler.toAxisAngle(); + Rodrigues rod = euler.toRodrigues(); + Quaternion quat = euler.toQuaternion(); + Homochoric ho = euler.toHomochoric(); + Cubochoric cu = euler.toCubochoric(); + Stereographic stereo = euler.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, OrientationMatrix, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, OrientationMatrix, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, Quaternion, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Quaternion, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, AxisAngle, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, AxisAngle, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Rodrigues, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Rodrigues, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Cubochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Homochoric, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Homochoric, Euler); + GENERATE_TEST_METHOD_EU(Euler, Cubochoric, Stereographic, Euler); + GENERATE_TEST_METHOD_EU(Euler, Stereographic, Cubochoric, Euler); +} + +TEST_CASE("ebsdlib::Orientations::OrientationMatrixConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::OrientationMatrixDType om(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); + Euler euler = om.toEuler(); + AxisAngle ax = om.toAxisAngle(); + Rodrigues rod = om.toRodrigues(); + Quaternion quat = om.toQuaternion(); + Homochoric ho = om.toHomochoric(); + Cubochoric cu = om.toCubochoric(); + Stereographic stereo = om.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Euler, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Euler, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Quaternion, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Quaternion, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, AxisAngle, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, AxisAngle, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Rodrigues, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Rodrigues, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Cubochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Homochoric, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Homochoric, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Cubochoric, Stereographic, OrientationMatrix); + GENERATE_TEST_METHOD(OrientationMatrix, Stereographic, Cubochoric, OrientationMatrix); +} + +TEST_CASE("ebsdlib::Orientations::AxisAngleConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::AxisAngle ax(0.0, 0.0, 0.0, 0.707); + Euler euler = ax.toEuler(); + OrientationMatrix om = ax.toOrientationMatrix(); + Rodrigues rod = ax.toRodrigues(); + Quaternion quat = ax.toQuaternion(); + Homochoric ho = ax.toHomochoric(); + Cubochoric cu = ax.toCubochoric(); + Stereographic stereo = ax.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(AxisAngle, Euler, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Euler, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Euler, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, OrientationMatrix, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, OrientationMatrix, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Quaternion, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Quaternion, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Rodrigues, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Rodrigues, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Cubochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Homochoric, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Homochoric, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Cubochoric, Stereographic, AxisAngle); + GENERATE_TEST_METHOD(AxisAngle, Stereographic, Cubochoric, AxisAngle); +} + +TEST_CASE("ebsdlib::Orientations::RodriguesConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::RodriguesDType rod(0.0, 0.0, 0.0, 1.0); + Euler euler = rod.toEuler(); + OrientationMatrix om = rod.toOrientationMatrix(); + AxisAngle ax = rod.toAxisAngle(); + Quaternion quat = rod.toQuaternion(); + Homochoric ho = rod.toHomochoric(); + Cubochoric cu = rod.toCubochoric(); + Stereographic stereo = rod.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Rodrigues, Euler, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Euler, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Euler, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, OrientationMatrix, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, OrientationMatrix, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Quaternion, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Quaternion, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, AxisAngle, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, AxisAngle, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Cubochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Homochoric, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Homochoric, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Cubochoric, Stereographic, Rodrigues); + GENERATE_TEST_METHOD(Rodrigues, Stereographic, Cubochoric, Rodrigues); +} + +TEST_CASE("ebsdlib::Orientations::QuaternionConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::Quaternion qu(0.0, 0.0, 0.0, 1.0); + Euler euler = qu.toEuler(); + OrientationMatrix om = qu.toOrientationMatrix(); + AxisAngle ax = qu.toAxisAngle(); + Rodrigues ro = qu.toRodrigues(); + Homochoric ho = qu.toHomochoric(); + Cubochoric cu = qu.toCubochoric(); + Stereographic stereo = qu.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Quaternion, Euler, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Euler, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Euler, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, OrientationMatrix, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, OrientationMatrix, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, AxisAngle, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, AxisAngle, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Rodrigues, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Rodrigues, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Cubochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Homochoric, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Homochoric, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Cubochoric, Stereographic, Quaternion); + GENERATE_TEST_METHOD(Quaternion, Stereographic, Cubochoric, Quaternion); +} + +TEST_CASE("ebsdlib::Orientations::HomochoricConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::Homochoric ho(1.0, 1.0, 0.0); + + Euler euler = ho.toEuler(); + OrientationMatrix om = ho.toOrientationMatrix(); + AxisAngle ax = ho.toAxisAngle(); + Rodrigues ro = ho.toRodrigues(); + Quaternion qu = ho.toQuaternion(); + Cubochoric cu = ho.toCubochoric(); + Stereographic stereo = ho.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Homochoric, Euler, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Euler, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Euler, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, OrientationMatrix, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, OrientationMatrix, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Quaternion, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Quaternion, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, AxisAngle, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, AxisAngle, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Cubochoric, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Rodrigues, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Rodrigues, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Cubochoric, Stereographic, Homochoric); + GENERATE_TEST_METHOD(Homochoric, Stereographic, Cubochoric, Homochoric); +} + +TEST_CASE("ebsdlib::Orientations::CubochoricConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::Cubochoric cu(1.0, 1.0, 0.0); + Euler euler = cu.toEuler(); + OrientationMatrix om = cu.toOrientationMatrix(); + AxisAngle ax = cu.toAxisAngle(); + Rodrigues ro = cu.toRodrigues(); + Quaternion qu = cu.toQuaternion(); + Homochoric ho = cu.toHomochoric(); + Stereographic stereo = cu.toStereographic(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Cubochoric, Euler, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Euler, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Euler, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, OrientationMatrix, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, OrientationMatrix, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Quaternion, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Quaternion, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, AxisAngle, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, AxisAngle, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Homochoric, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Rodrigues, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Rodrigues, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Homochoric, Stereographic, Cubochoric); + GENERATE_TEST_METHOD(Cubochoric, Stereographic, Homochoric, Cubochoric); +} + +TEST_CASE("ebsdlib::Orientations::StereographicConsistencyCheck", "[EbsdLib][Orientations]") +{ + ebsdlib::StereographicDType stereo(1.0, 1.0, 1.0); + + Euler euler = stereo.toEuler(); + OrientationMatrix om = stereo.toOrientationMatrix(); + AxisAngle ax = stereo.toAxisAngle(); + Rodrigues ro = stereo.toRodrigues(); + Quaternion qu = stereo.toQuaternion(); + Homochoric ho = stereo.toHomochoric(); + Cubochoric cu = stereo.toCubochoric(); + + TEST_PREAMBLE(); + + GENERATE_TEST_METHOD(Stereographic, Euler, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Euler, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Euler, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, OrientationMatrix, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, OrientationMatrix, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Quaternion, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Quaternion, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, AxisAngle, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, AxisAngle, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Homochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Rodrigues, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Rodrigues, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Homochoric, Cubochoric, Stereographic); + GENERATE_TEST_METHOD(Stereographic, Cubochoric, Homochoric, Stereographic); +} diff --git a/Source/Test/QuaternionTest.cpp b/Source/Test/QuaternionTest.cpp index b4584148..5bef9c67 100644 --- a/Source/Test/QuaternionTest.cpp +++ b/Source/Test/QuaternionTest.cpp @@ -32,363 +32,321 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include -#include - -#include -#include -#include - -#include "EbsdLib/Core/OrientationTransformation.hpp" -#include "EbsdLib/Core/Quaternion.hpp" #include "EbsdLib/EbsdLib.h" #include "EbsdLib/Math/EbsdMatrixMath.h" #include "EbsdLib/Math/Matrix3X1.hpp" #include "EbsdLib/Math/Matrix3X3.hpp" +#include "EbsdLib/Orientation/Quaternion.hpp" +#include "EbsdLib/Test/EbsdLibTestFileLocations.h" #include "UnitTestSupport.hpp" -#include "EbsdLib/Test/EbsdLibTestFileLocations.h" +#include + +#include +#include +#include constexpr float DREAM3D_PASSIVE = 1.0F; constexpr float DREAM3D_ACTIVE = -1.0F; +using namespace ebsdlib; -class QuaternionTest +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::QuaternionTest::TestEbsdMatrixMath", "[EbsdLib][QuaternionTest]") { -public: - QuaternionTest() = default; - virtual ~QuaternionTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(QuaternionTest) + using VectorMapType = Eigen::Map; - // ----------------------------------------------------------------------------- - void RemoveTestFiles() { -#if REMOVE_TEST_FILES -// fs::remove(); -#endif - } + std::array dir = {1.0f, 2.0f, 3.0f}; - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestEbsdMatrixMath() - { - using VectorMapType = Eigen::Map; - - { - std::array dir = {1.0f, 2.0f, 3.0f}; - - VectorMapType array(dir.data()); - array.normalize(); - array = array * -1.0f; - } - - { - std::array dir = {1.0f, 2.0f, 3.0f}; - EbsdMatrixMath::Normalize3x1(dir.data()); - EbsdMatrixMath::Multiply3x1withConstant(dir.data(), -1.0f); - } + VectorMapType array(dir.data()); + array.normalize(); + array = array * -1.0f; } - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void TestQuaternion() { - QuatF p(1.0f, 0.0f, 0.0f, 1.0f); - QuatF q(0.0f, 1.0f, 0.0f, 2.0f); - QuatF out(0.0f, 0.0f, 0.0f, 0.0f); - QuatF out2(10.0f, 20.0f, 30.0f, 40.0f); - - out2.negate(); - DREAM3D_REQUIRE_EQUAL(out2.x(), -10.0) - DREAM3D_REQUIRE_EQUAL(out2.y(), -20.0) - DREAM3D_REQUIRE_EQUAL(out2.z(), -30.0) - DREAM3D_REQUIRE_EQUAL(out2.w(), -40.0) - - out = p; - DREAM3D_REQUIRE_EQUAL(p.x(), out.x()) - DREAM3D_REQUIRE_EQUAL(p.y(), out.y()) - DREAM3D_REQUIRE_EQUAL(p.z(), out.z()) - DREAM3D_REQUIRE_EQUAL(p.w(), out.w()) - - out = QuatF::identity(); - DREAM3D_REQUIRE_EQUAL(out.x(), 0.0) - DREAM3D_REQUIRE_EQUAL(out.y(), 0.0) - DREAM3D_REQUIRE_EQUAL(out.z(), 0.0) - DREAM3D_REQUIRE_EQUAL(out.w(), 1.0) - - out = QuatF(-10.5f, -1.5f, -30.66f, -40.987f); - out.elementWiseAbs(); - DREAM3D_REQUIRE_EQUAL(out.x(), 10.5f) - DREAM3D_REQUIRE_EQUAL(out.y(), 1.5f) - DREAM3D_REQUIRE_EQUAL(out.z(), 30.66f) - DREAM3D_REQUIRE_EQUAL(out.w(), 40.987f) - - out = QuatF(10.0f, 20.0f, 30.0f, 40.0f); - out.scalarMultiply(-1.0f); - DREAM3D_REQUIRE_EQUAL(out.x(), -10.0) - DREAM3D_REQUIRE_EQUAL(out.y(), -20.0) - DREAM3D_REQUIRE_EQUAL(out.z(), -30.0) - DREAM3D_REQUIRE_EQUAL(out.w(), -40.0) - - out.scalarDivide(-1.0f).scalarAdd(50.0f); - DREAM3D_REQUIRE_EQUAL(out.x(), 60.0) - DREAM3D_REQUIRE_EQUAL(out.y(), 70.0) - DREAM3D_REQUIRE_EQUAL(out.z(), 80.0) - DREAM3D_REQUIRE_EQUAL(out.w(), 90.0) - - out.elementWiseAssign(5.0f); - DREAM3D_REQUIRE_EQUAL(out.x(), 5.0) - DREAM3D_REQUIRE_EQUAL(out.y(), 5.0) - DREAM3D_REQUIRE_EQUAL(out.z(), 5.0) - DREAM3D_REQUIRE_EQUAL(out.w(), 5.0) - - out.negate(); - out = p + q; - out = p - q; - - // Conjugate Tests where conjugate of a Quaternion is q* - // (q*)* = q - - p.x() = 1.0f; - p.y() = 2.0f; - p.z() = 3.0f; - p.w() = 1.0f; - - p = p.conjugate(); - DREAM3D_REQUIRE_EQUAL(p.x(), -1.0) - DREAM3D_REQUIRE_EQUAL(p.y(), -2.0) - DREAM3D_REQUIRE_EQUAL(p.z(), -3.0) - DREAM3D_REQUIRE_EQUAL(p.w(), 1.0) - p = p.conjugate(); - DREAM3D_REQUIRE_EQUAL(p.x(), 1.0) - DREAM3D_REQUIRE_EQUAL(p.y(), 2.0) - DREAM3D_REQUIRE_EQUAL(p.z(), 3.0) - DREAM3D_REQUIRE_EQUAL(p.w(), 1.0) - - // (pq)* = q*p* - q.x() = 1.0f; - q.y() = 0.0f; - q.z() = 1.0f; - q.w() = 1.0f; - out = p * q; - out = out.conjugate(); - p = p.conjugate(); - q = q.conjugate(); - out2 = q * p; - DREAM3D_REQUIRE_EQUAL(out.x(), out2.x()) - DREAM3D_REQUIRE_EQUAL(out.y(), out2.y()) - DREAM3D_REQUIRE_EQUAL(out.z(), out2.z()) - DREAM3D_REQUIRE_EQUAL(out.w(), out2.w()) - - //(p+q)* = p*+q* - p.x() = 1.0f; - p.y() = 2.0f; - p.z() = 3.0f; - p.w() = 1.0f; - q.x() = 1.0f; - q.y() = 0.0f; - q.z() = 1.0f; - q.w() = 1.0f; - out = p + q; - out = out.conjugate(); - p = p.conjugate(); - q = q.conjugate(); - out2 = p + q; - - DREAM3D_REQUIRE_EQUAL(out.x(), out2.x()) - DREAM3D_REQUIRE_EQUAL(out.y(), out2.y()) - DREAM3D_REQUIRE_EQUAL(out.z(), out2.z()) - DREAM3D_REQUIRE_EQUAL(out.w(), out2.w()) - - // Multiplication Test - // pq != qp - p.x() = 1.0f; - p.y() = 0.0f; - p.z() = 0.0f; - p.w() = 1.0f; - - q.x() = 0.0f; - q.y() = 1.0f; - q.z() = 0.0f; - q.w() = 2.0f; - - out = p * q; - DREAM3D_REQUIRE_EQUAL(out.x(), 2.0) - DREAM3D_REQUIRE_EQUAL(out.y(), 1.0) - DREAM3D_REQUIRE_EQUAL(out.z(), 1.0) - DREAM3D_REQUIRE_EQUAL(out.w(), 2.0) - - out = q * p; - DREAM3D_REQUIRE_EQUAL(out.x(), 2.0) - DREAM3D_REQUIRE_EQUAL(out.y(), 1.0) - DREAM3D_REQUIRE_EQUAL(out.z(), -1.0) - DREAM3D_REQUIRE_EQUAL(out.w(), 2.0) - - // Norm Test - // N(q*) = N(q) - p.x() = 1.0f; - p.y() = 0.0f; - p.z() = 0.0f; - p.w() = 1.0f; - q.x() = 0.0f; - q.y() = 1.0f; - q.z() = 0.0f; - q.w() = 2.0f; - float norm = p.norm(); - p = p.conjugate(); - float cnorm = p.norm(); - DREAM3D_REQUIRE_EQUAL(norm, cnorm) - - // Length and Unit Quaternion Tests - p.x() = 2.0f; - p.y() = 2.0f; - p.z() = 2.0f; - p.w() = 2.0f; - float length = p.length(); - DREAM3D_REQUIRE_EQUAL(length, 4.0); - p = p.normalize(); - DREAM3D_REQUIRE_EQUAL(p.x(), 0.5) - DREAM3D_REQUIRE_EQUAL(p.y(), 0.5) - DREAM3D_REQUIRE_EQUAL(p.z(), 0.5) - DREAM3D_REQUIRE_EQUAL(p.w(), 0.5) - - p.x() = 1.0; - p.y() = 2.0; - p.z() = 3.0; - p.w() = 0.0; - std::array vec = {0.0f, 0.0f, 0.0f}; - std::array ovec = {0.0f, 0.0f, 0.0f}; - - vec = p.getMisorientationVector(); - bool pass = EbsdLibMath::closeEnough(vec[0], 3.14159274f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); - - pass = EbsdLibMath::closeEnough(vec[1], 6.28318548f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - pass = EbsdLibMath::closeEnough(vec[2], 9.42477798f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - // Test point r=[100] rotated 120Deg @ [111] axis - vec = {1.0F, 0.0F, 0.0F}; - // The quaternion Representation for 120@[111] - q = QuatF(0.5f, 0.5f, 0.5f, 0.5f); - - // Passive Rotation - ovec = q.multiplyByVector(vec.data()); - - pass = EbsdLibMath::closeEnough(ovec[0], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); - - pass = EbsdLibMath::closeEnough(ovec[1], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - pass = EbsdLibMath::closeEnough(ovec[2], 1.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - // Active Rotation - q = q.conjugate(); - ovec = q.multiplyByVector(vec.data()); - - pass = EbsdLibMath::closeEnough(ovec[0], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); - - pass = EbsdLibMath::closeEnough(ovec[1], 1.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - pass = EbsdLibMath::closeEnough(ovec[2], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - // 90@[100] - q.x() = 0.7071067811865475f; - q.y() = 0.0f; - q.z() = 0.0f; - q.w() = 0.7071067811865476f; - - vec[0] = 0.0; - vec[1] = 1.0; - vec[2] = 0.0; - // Passive Rotation - ovec = q.multiplyByVector(vec.data()); - - pass = EbsdLibMath::closeEnough(ovec[0], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); - - pass = EbsdLibMath::closeEnough(ovec[1], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - pass = EbsdLibMath::closeEnough(ovec[2], -1.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - // active Rotation - q = q.conjugate(); - ovec = q.multiplyByVector(vec.data()); - - pass = EbsdLibMath::closeEnough(ovec[0], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); - - pass = EbsdLibMath::closeEnough(ovec[1], 0.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - pass = EbsdLibMath::closeEnough(ovec[2], 1.0f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) - - // Rotate a vector by a quaternion - Quaternion quat(0.32732683f, -0.54554468f, 0.76376259f, 0.10910894f); - - vec = {0.26726124f, -0.53452247f, 0.80178368f}; - ovec = quat.rotateVector(vec.data(), static_cast(DREAM3D_PASSIVE)); + std::array dir = {1.0f, 2.0f, 3.0f}; + ebsdlib::EbsdMatrixMath::Normalize3x1(dir.data()); + ebsdlib::EbsdMatrixMath::Multiply3x1withConstant(dir.data(), -1.0f); + } +} - pass = EbsdLibMath::closeEnough(ovec[0], 0.381802f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true); +// ----------------------------------------------------------------------------- +TEST_CASE("ebsdlib::QuaternionTest::TestQuaternion", "[EbsdLib][QuaternionTest]") +{ + QuatF p(1.0f, 0.0f, 0.0f, 1.0f); + QuatF q(0.0f, 1.0f, 0.0f, 2.0f); + QuatF out(0.0f, 0.0f, 0.0f, 0.0f); + QuatF out2(10.0f, 20.0f, 30.0f, 40.0f); + + out2.negate(); + DREAM3D_REQUIRE_EQUAL(out2.x(), -10.0) + DREAM3D_REQUIRE_EQUAL(out2.y(), -20.0) + DREAM3D_REQUIRE_EQUAL(out2.z(), -30.0) + DREAM3D_REQUIRE_EQUAL(out2.w(), -40.0) + + out = p; + DREAM3D_REQUIRE_EQUAL(p.x(), out.x()) + DREAM3D_REQUIRE_EQUAL(p.y(), out.y()) + DREAM3D_REQUIRE_EQUAL(p.z(), out.z()) + DREAM3D_REQUIRE_EQUAL(p.w(), out.w()) + + out = QuatF::identity(); + DREAM3D_REQUIRE_EQUAL(out.x(), 0.0) + DREAM3D_REQUIRE_EQUAL(out.y(), 0.0) + DREAM3D_REQUIRE_EQUAL(out.z(), 0.0) + DREAM3D_REQUIRE_EQUAL(out.w(), 1.0) + + out = QuatF(-10.5f, -1.5f, -30.66f, -40.987f); + out.elementWiseAbs(); + DREAM3D_REQUIRE_EQUAL(out.x(), 10.5f) + DREAM3D_REQUIRE_EQUAL(out.y(), 1.5f) + DREAM3D_REQUIRE_EQUAL(out.z(), 30.66f) + DREAM3D_REQUIRE_EQUAL(out.w(), 40.987f) + + out = QuatF(10.0f, 20.0f, 30.0f, 40.0f); + out.scalarMultiply(-1.0f); + DREAM3D_REQUIRE_EQUAL(out.x(), -10.0) + DREAM3D_REQUIRE_EQUAL(out.y(), -20.0) + DREAM3D_REQUIRE_EQUAL(out.z(), -30.0) + DREAM3D_REQUIRE_EQUAL(out.w(), -40.0) + + out.scalarDivide(-1.0f).scalarAdd(50.0f); + DREAM3D_REQUIRE_EQUAL(out.x(), 60.0) + DREAM3D_REQUIRE_EQUAL(out.y(), 70.0) + DREAM3D_REQUIRE_EQUAL(out.z(), 80.0) + DREAM3D_REQUIRE_EQUAL(out.w(), 90.0) + + out.elementWiseAssign(5.0f); + DREAM3D_REQUIRE_EQUAL(out.x(), 5.0) + DREAM3D_REQUIRE_EQUAL(out.y(), 5.0) + DREAM3D_REQUIRE_EQUAL(out.z(), 5.0) + DREAM3D_REQUIRE_EQUAL(out.w(), 5.0) + + out.negate(); + out = p + q; + out = p - q; + + // Conjugate Tests where conjugate of a Quaternion is q* + // (q*)* = q + + p.x() = 1.0f; + p.y() = 2.0f; + p.z() = 3.0f; + p.w() = 1.0f; + + p = p.conjugate(); + DREAM3D_REQUIRE_EQUAL(p.x(), -1.0) + DREAM3D_REQUIRE_EQUAL(p.y(), -2.0) + DREAM3D_REQUIRE_EQUAL(p.z(), -3.0) + DREAM3D_REQUIRE_EQUAL(p.w(), 1.0) + p = p.conjugate(); + DREAM3D_REQUIRE_EQUAL(p.x(), 1.0) + DREAM3D_REQUIRE_EQUAL(p.y(), 2.0) + DREAM3D_REQUIRE_EQUAL(p.z(), 3.0) + DREAM3D_REQUIRE_EQUAL(p.w(), 1.0) + + // (pq)* = q*p* + q.x() = 1.0f; + q.y() = 0.0f; + q.z() = 1.0f; + q.w() = 1.0f; + out = p * q; + out = out.conjugate(); + p = p.conjugate(); + q = q.conjugate(); + out2 = q * p; + DREAM3D_REQUIRE_EQUAL(out.x(), out2.x()) + DREAM3D_REQUIRE_EQUAL(out.y(), out2.y()) + DREAM3D_REQUIRE_EQUAL(out.z(), out2.z()) + DREAM3D_REQUIRE_EQUAL(out.w(), out2.w()) + + //(p+q)* = p*+q* + p.x() = 1.0f; + p.y() = 2.0f; + p.z() = 3.0f; + p.w() = 1.0f; + q.x() = 1.0f; + q.y() = 0.0f; + q.z() = 1.0f; + q.w() = 1.0f; + out = p + q; + out = out.conjugate(); + p = p.conjugate(); + q = q.conjugate(); + out2 = p + q; + + DREAM3D_REQUIRE_EQUAL(out.x(), out2.x()) + DREAM3D_REQUIRE_EQUAL(out.y(), out2.y()) + DREAM3D_REQUIRE_EQUAL(out.z(), out2.z()) + DREAM3D_REQUIRE_EQUAL(out.w(), out2.w()) + + // Multiplication Test + // pq != qp + p.x() = 1.0f; + p.y() = 0.0f; + p.z() = 0.0f; + p.w() = 1.0f; + + q.x() = 0.0f; + q.y() = 1.0f; + q.z() = 0.0f; + q.w() = 2.0f; + + out = p * q; + DREAM3D_REQUIRE_EQUAL(out.x(), 2.0) + DREAM3D_REQUIRE_EQUAL(out.y(), 1.0) + DREAM3D_REQUIRE_EQUAL(out.z(), 1.0) + DREAM3D_REQUIRE_EQUAL(out.w(), 2.0) + + out = q * p; + DREAM3D_REQUIRE_EQUAL(out.x(), 2.0) + DREAM3D_REQUIRE_EQUAL(out.y(), 1.0) + DREAM3D_REQUIRE_EQUAL(out.z(), -1.0) + DREAM3D_REQUIRE_EQUAL(out.w(), 2.0) + + // Norm Test + // N(q*) = N(q) + p.x() = 1.0f; + p.y() = 0.0f; + p.z() = 0.0f; + p.w() = 1.0f; + q.x() = 0.0f; + q.y() = 1.0f; + q.z() = 0.0f; + q.w() = 2.0f; + float norm = p.norm(); + p = p.conjugate(); + float cnorm = p.norm(); + DREAM3D_REQUIRE_EQUAL(norm, cnorm) + + // Length and Unit Quaternion Tests + p.x() = 2.0f; + p.y() = 2.0f; + p.z() = 2.0f; + p.w() = 2.0f; + float length = p.length(); + DREAM3D_REQUIRE_EQUAL(length, 4.0); + p = p.normalize(); + DREAM3D_REQUIRE_EQUAL(p.x(), 0.5) + DREAM3D_REQUIRE_EQUAL(p.y(), 0.5) + DREAM3D_REQUIRE_EQUAL(p.z(), 0.5) + DREAM3D_REQUIRE_EQUAL(p.w(), 0.5) + + p.x() = 1.0; + p.y() = 2.0; + p.z() = 3.0; + p.w() = 0.0; + Matrix3X1 vec = {0.0f, 0.0f, 0.0f}; + Matrix3X1 ovec = {0.0f, 0.0f, 0.0f}; + + vec = p.getMisorientationVector(); + bool pass = ebsdlib::math::closeEnough(vec[0], 3.14159274f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); + + pass = ebsdlib::math::closeEnough(vec[1], 6.28318548f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + pass = ebsdlib::math::closeEnough(vec[2], 9.42477798f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + // Test point r=[100] rotated 120Deg @ [111] axis + vec = {1.0F, 0.0F, 0.0F}; + // The quaternion Representation for 120@[111] + q = QuatF(0.5f, 0.5f, 0.5f, 0.5f); + + // Passive Rotation + ovec = q.multiplyByVector(vec.data()); + + pass = ebsdlib::math::closeEnough(ovec[0], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); + + pass = ebsdlib::math::closeEnough(ovec[1], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + pass = ebsdlib::math::closeEnough(ovec[2], 1.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + // Active Rotation + q = q.conjugate(); + ovec = q.multiplyByVector(vec.data()); + + pass = ebsdlib::math::closeEnough(ovec[0], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); + + pass = ebsdlib::math::closeEnough(ovec[1], 1.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + pass = ebsdlib::math::closeEnough(ovec[2], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + // 90@[100] + q.x() = 0.7071067811865475f; + q.y() = 0.0f; + q.z() = 0.0f; + q.w() = 0.7071067811865476f; + + vec[0] = 0.0; + vec[1] = 1.0; + vec[2] = 0.0; + // Passive Rotation + ovec = q.multiplyByVector(vec.data()); + + pass = ebsdlib::math::closeEnough(ovec[0], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); + + pass = ebsdlib::math::closeEnough(ovec[1], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + pass = ebsdlib::math::closeEnough(ovec[2], -1.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + // active Rotation + q = q.conjugate(); + ovec = q.multiplyByVector(vec.data()); + + pass = ebsdlib::math::closeEnough(ovec[0], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); + + pass = ebsdlib::math::closeEnough(ovec[1], 0.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) + + pass = ebsdlib::math::closeEnough(ovec[2], 1.0f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) - pass = EbsdLibMath::closeEnough(ovec[1], -0.572703f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) + // Rotate a vector by a quaternion + QuaternionFType quat(0.32732683f, -0.54554468f, 0.76376259f, 0.10910894f); - pass = EbsdLibMath::closeEnough(ovec[2], 0.725423f, 1.0E-4f); - DREAM3D_REQUIRE_EQUAL(pass, true) + vec = {0.26726124f, -0.53452247f, 0.80178368f}; + ovec = quat.rotateVector(vec, static_cast(DREAM3D_PASSIVE)); - std::cout << ovec[0] << ", " << ovec[1] << ", " << ovec[2] << std::endl; - } + pass = ebsdlib::math::closeEnough(ovec[0], 0.381802f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true); - void Matrix3x3Test() - { - EbsdLib::Matrix3X1D vec0 = {1.0, 0.0, 0.0}; - EbsdLib::Matrix3X1D vec1 = {0.0, 1.0, 0.0}; - EbsdLib::Matrix3X1D vec2 = {-1.0, 0.0, 0.0}; - EbsdLib::Matrix3X1D vec3 = {1.0, 1.0, 0.0}; - - double cosTheta = vec0.cosTheta(vec1); - DREAM3D_REQUIRE_EQUAL(cosTheta, 0.0) - cosTheta = vec0.cosTheta(vec2); - DREAM3D_REQUIRE_EQUAL(cosTheta, -1.0) - cosTheta = vec0.cosTheta(vec0); - DREAM3D_REQUIRE_EQUAL(cosTheta, 1.0) - - cosTheta = vec0.cosTheta(vec3); - bool pass = EbsdLibMath::closeEnough(cosTheta, 0.70710678118654746, 1.0E-4); - DREAM3D_REQUIRE_EQUAL(pass, true); - } + pass = ebsdlib::math::closeEnough(ovec[1], -0.572703f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) - // ----------------------------------------------------------------------------- - // - // ----------------------------------------------------------------------------- - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; - int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestEbsdMatrixMath()) - DREAM3D_REGISTER_TEST(TestQuaternion()) - DREAM3D_REGISTER_TEST(RemoveTestFiles()) - DREAM3D_REGISTER_TEST(Matrix3x3Test()) - } + pass = ebsdlib::math::closeEnough(ovec[2], 0.725423f, 1.0E-4f); + DREAM3D_REQUIRE_EQUAL(pass, true) +} -public: - QuaternionTest(const QuaternionTest&) = delete; // Copy Constructor Not Implemented - QuaternionTest(QuaternionTest&&) = delete; // Move Constructor Not Implemented - QuaternionTest& operator=(const QuaternionTest&) = delete; // Copy Assignment Not Implemented - QuaternionTest& operator=(QuaternionTest&&) = delete; // Move Assignment Not Implemented -}; +TEST_CASE("ebsdlib::QuaternionTest::Matrix3x3Test", "[EbsdLib][QuaternionTest]") +{ + ebsdlib::Matrix3X1D vec0 = {1.0, 0.0, 0.0}; + ebsdlib::Matrix3X1D vec1 = {0.0, 1.0, 0.0}; + ebsdlib::Matrix3X1D vec2 = {-1.0, 0.0, 0.0}; + ebsdlib::Matrix3X1D vec3 = {1.0, 1.0, 0.0}; + + double cosTheta = vec0.cosTheta(vec1); + DREAM3D_REQUIRE_EQUAL(cosTheta, 0.0) + cosTheta = vec0.cosTheta(vec2); + DREAM3D_REQUIRE_EQUAL(cosTheta, -1.0) + cosTheta = vec0.cosTheta(vec0); + DREAM3D_REQUIRE_EQUAL(cosTheta, 1.0) + + cosTheta = vec0.cosTheta(vec3); + bool pass = ebsdlib::math::closeEnough(cosTheta, 0.70710678118654746, 1.0E-4); + DREAM3D_REQUIRE_EQUAL(pass, true); +} diff --git a/Source/Test/TestFileLocations.h.in b/Source/Test/TestFileLocations.h.in index 8bbab746..2a3550f4 100644 --- a/Source/Test/TestFileLocations.h.in +++ b/Source/Test/TestFileLocations.h.in @@ -37,7 +37,7 @@ #define _EbsdTestFileLocation_h_ /*********** - * This file is auto generated from the file at DREAM3D/Source/EbsdLib/Test/EbsdTestFileLocations.h.in + * This file is auto generated from the file at DREAM3D/Source/EbsdLib/Test/TestFileLocations.h.in * If there is an issue with this file edit the original file. This file is autogenerated at * CMake time. */ @@ -50,7 +50,7 @@ namespace UnitTest { const std::string DataDir("@EbsdLibProj_SOURCE_DIR@/Data/"); -const std::string TestTempDir("@TEST_TEMP_DIR@"); +const std::string TestTempDir("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/"); const std::string DREAM3DProjDir("@EbsdLibProj_SOURCE_DIR@"); namespace AngImportTest @@ -59,7 +59,7 @@ const std::string FileDir("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/"); const std::string TestFile1("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/Test_1.ang"); const std::string TestFile2("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/Test_2.ang"); const std::string TestFile3("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/Test_3.ang"); -const std::string H5EbsdOutputFile("@TEST_TEMP_DIR@/FromAng.h5ebsd"); +const std::string H5EbsdOutputFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/FromAng.h5ebsd"); const std::string MissingHeader1("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/MissingHeader_1.ang"); const std::string GridMissing("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/GridMissing.ang"); const std::string MissingHeader3("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/MissingHeader_3.ang"); @@ -68,6 +68,11 @@ const std::string ShortFile("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/ShortFi const std::string EdaxOIMH5File("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/EdaxAngOnly.h5"); } // namespace AngImportTest +namespace AngleFileLoaderTest +{ + const std::string OutputFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/output_file.csv"); +} + namespace CtfReaderTest { const std::string FileDir("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/"); @@ -79,7 +84,7 @@ const std::string Corrupted_XCells("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/ const std::string ShortFile("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/ShortFile.ctf"); const std::string ZeroXYCells("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/ZeroXYCells.ctf"); -const std::string H5EbsdOutputFile("@TEST_TEMP_DIR@/FromCtf.h5ebsd"); +const std::string H5EbsdOutputFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/FromCtf.h5ebsd"); } // namespace CtfReaderTest namespace HedmReaderTest @@ -93,22 +98,22 @@ const std::string MicFile("@EbsdLibProj_SOURCE_DIR@/Data/HEDMTestFiles/HedmTest. namespace H5EspritReaderTest { const std::string InputFile("@EbsdLibProj_SOURCE_DIR@/Data/EbsdTestFiles/H5EspritReaderTest.h5"); -const std::string OutputFile("@TEST_TEMP_DIR@/H5Esprit_Output_File.h5"); +const std::string OutputFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/H5Esprit_Output_File.h5"); } // namespace H5EspritReaderTest namespace IPFLegendTest { -const std::string CubicLowFile("@TEST_TEMP_DIR@/Cubic_Low_m3(Tetrahedral).png"); -const std::string CubicHighFile("@TEST_TEMP_DIR@/Cubic_High_m3m.png"); -const std::string HexagonalLowFile("@TEST_TEMP_DIR@/Hexagonal-Low_6_m.png"); -const std::string HexagonalHighFile("@TEST_TEMP_DIR@/Hexagonal-High_6_mmm.png"); -const std::string MonoclinicFile("@TEST_TEMP_DIR@/Monoclinic-2_m.png"); -const std::string OrthorhombicFile("@TEST_TEMP_DIR@/Orthorhombic_mmm.png"); -const std::string TetragonalLowFile("@TEST_TEMP_DIR@/Tetragonal_Low_4m.png"); -const std::string TetragonalHighFile("@TEST_TEMP_DIR@/Tetragonal_High_4mmm.png"); -const std::string TriclinicFile("@TEST_TEMP_DIR@/Triclinic-1.png"); -const std::string TrignonalLowFile("@TEST_TEMP_DIR@/Trigonal-3.png"); -const std::string TrignonalHighFile("@TEST_TEMP_DIR@/Trigonal_high-3m.png"); +const std::string CubicLowFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Cubic_Low_m3(Tetrahedral).png"); +const std::string CubicHighFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Cubic_High_m3m.png"); +const std::string HexagonalLowFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Hexagonal-Low_6_m.png"); +const std::string HexagonalHighFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Hexagonal-High_6_mmm.png"); +const std::string MonoclinicFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Monoclinic-2_m.png"); +const std::string OrthorhombicFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Orthorhombic_mmm.png"); +const std::string TetragonalLowFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Tetragonal_Low_4m.png"); +const std::string TetragonalHighFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Tetragonal_High_4mmm.png"); +const std::string TriclinicFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Triclinic-1.png"); +const std::string TrignonalLowFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Trigonal-3.png"); +const std::string TrignonalHighFile("@EbsdLibProj_BINARY_DIR@/Testing/Temporary/Trigonal_high-3m.png"); } // namespace IPFLegendTest } // namespace UnitTest diff --git a/Source/Test/TextureTest.cpp b/Source/Test/TextureTest.cpp index ab93bec6..0e62d6c9 100644 --- a/Source/Test/TextureTest.cpp +++ b/Source/Test/TextureTest.cpp @@ -32,6 +32,7 @@ * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +#include #include #include @@ -57,170 +58,160 @@ #include "EbsdLib/Test/EbsdLibTestFileLocations.h" -/** - * @brief These tests are just here to make sure the code compiles. The tests will - * not actually work or would probably produced undefined results. - * @param argc - * @param argv - * @return - */ -class TextureTest -{ -public: - TextureTest() = default; - ~TextureTest() = default; - - EBSD_GET_NAME_OF_CLASS_DECL(TextureTest) - - template - void TestTextureMdf() - { - LaueOps ops; - std::cout << "======================================================" << std::endl; - std::cout << ops.getNameOfClass() << " MDF Plot Values" << std::endl; - - std::vector odf; - - int size = 10000; - std::vector e1s; - std::vector e2s; - std::vector e3s; - std::vector sigmas; - std::vector angles; - std::vector axes; - std::vector weights; - size_t numEntries = static_cast(e1s.size()); - std::cout << " Generating ODF....." << std::endl; - Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); - - // Allocate a new vector to hold the mdf data - std::vector mdf; - int32_t err = 0; - std::cout << " Generating MDF....." << std::endl; - try - { - // Calculate the MDF Data using the ODF data and the rows from the MDF Table model - Texture::CalculateMDFData>(angles, axes, weights, odf, mdf, static_cast(angles.size())); - // Now generate the actual XY point data that gets plotted. - // These are the output vectors - - int npoints = 36; - std::vector x(npoints); - std::vector y(npoints); - std::cout << " Generating MDF Plot Data....." << std::endl; - - err = StatsGen::GenMDFPlotData>(mdf, x, y, size); - if(err < 0) - { - std::cout << "Error Generating MDF Plot Values" << std::endl; - return; - } - std::cout << " npoints: " << x.size() << std::endl; - for(size_t i = 0; i < x.size(); i++) - { - std::cout << i << ": " << x[i] << ", " << y[i] << std::endl; - } - } catch([[maybe_unused]] const EbsdLib::method_not_implemented& exception) - { - std::cout << " MDF Plot Values NOT implemented" << std::endl; - } - } +using namespace ebsdlib; - void TestMdfGeneration() +template +void TestTextureMdf() +{ + LaueOps ops; + std::cout << "======================================================" << std::endl; + std::cout << ops.getNameOfClass() << " MDF Plot Values" << std::endl; + + std::vector odf; + + int size = 10000; + std::vector e1s; + std::vector e2s; + std::vector e3s; + std::vector sigmas; + std::vector angles; + std::vector axes; + std::vector weights; + size_t numEntries = static_cast(e1s.size()); + std::cout << " Generating ODF....." << std::endl; + Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); + + // Allocate a new vector to hold the mdf data + std::vector mdf; + int32_t err = 0; + std::cout << " Generating MDF....." << std::endl; + try { - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - TestTextureMdf(); - - try - { - TestTextureMdf(); - } catch(std::runtime_error e) + // Calculate the MDF Data using the ODF data and the rows from the MDF Table model + Texture::CalculateMDFData>(angles, axes, weights, odf, mdf, static_cast(angles.size())); + // Now generate the actual XY point data that gets plotted. + // These are the output vectors + + int npoints = 36; + std::vector x(npoints); + std::vector y(npoints); + std::cout << " Generating MDF Plot Data....." << std::endl; + + err = StatsGen::GenMDFPlotData>(mdf, x, y, size); + if(err < 0) { + std::cout << "Error Generating MDF Plot Values" << std::endl; + return; } - try - { - TestTextureMdf(); - } catch(std::runtime_error e) - { - } - try - { - TestTextureMdf(); - } catch(std::runtime_error e) + std::cout << " npoints: " << x.size() << std::endl; + for(size_t i = 0; i < x.size(); i++) { + std::cout << i << ": " << x[i] << ", " << y[i] << std::endl; } + } catch([[maybe_unused]] const ebsdlib::method_not_implemented& exception) + { + std::cout << " MDF Plot Values NOT implemented" << std::endl; } +} - template - void TestTextureOdf() +TEST_CASE("ebsdlib::TextureTest::TestMdfGeneration", "[EbsdLib][TextureTest]") +{ + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + TestTextureMdf(); + + try + { + TestTextureMdf(); + } catch(std::runtime_error e) { - std::vector e1s; - std::vector e2s; - std::vector e3s; - std::vector weights; - std::vector sigmas; - std::vector odf; - - LaueOps ops; - size_t numEntries = e1s.size(); - Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); } - - void TestOdfGeneration() + try + { + TestTextureMdf(); + } catch(std::runtime_error e) { - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); - TestTextureOdf(); } - - void TestMatrix3X3() + try + { + TestTextureMdf(); + } catch(std::runtime_error e) { - EbsdLib::Matrix3X3F matrix(1.0f, 2.0f, 3.0, 4.0f, 5.0f, 6.0f, 7.0, 8.0f, 9.0f); - matrix[0] = 10.0f; - matrix.data()[0] = 12.0f; - matrix = matrix * matrix; - matrix = matrix.multiplyInPlace(matrix); - matrix = matrix + matrix; - matrix = matrix - matrix; - matrix = matrix * 22.0f; - - matrix = matrix.transpose(); - matrix = matrix.invert(); - matrix = matrix.adjoint(); - matrix = matrix.cofactor(); - matrix = matrix.minors(); - float det = matrix.determinant(); - matrix = matrix.normalize(); - matrix = matrix.identity(); } +} - void operator()() - { - std::cout << "<===== Start " << getNameOfClass() << std::endl; +template +void TestTextureOdf() +{ + std::vector e1s; + std::vector e2s; + std::vector e3s; + std::vector weights; + std::vector sigmas; + std::vector odf; + + LaueOps ops; + size_t numEntries = e1s.size(); + Texture::CalculateODFData>(e1s, e2s, e3s, weights, sigmas, true, odf, numEntries); +} + +TEST_CASE("ebsdlib::TextureTest::TestOdfGeneration", "[EbsdLib][TextureTest]") +{ + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); + TestTextureOdf(); +} + +TEST_CASE("ebsdlib::TextureTest::TestMatrix3X3", "[EbsdLib][TextureTest]") +{ + ebsdlib::Matrix3X3F matrix(1.0f, 2.0f, 3.0, 4.0f, 5.0f, 6.0f, 7.0, 8.0f, 9.0f); + matrix[0] = 10.0f; + matrix.data()[0] = 12.0f; + matrix = matrix * matrix; + matrix = matrix.multiplyInPlace(matrix); + matrix = matrix + matrix; + matrix = matrix - matrix; + matrix = matrix * 22.0f; + + matrix = matrix.transpose(); + matrix = matrix.invert(); + matrix = matrix.adjoint(); + matrix = matrix.cofactor(); + matrix = matrix.minors(); + float det = matrix.determinant(); + matrix = matrix.normalize(); + matrix = ebsdlib::Matrix3X3F::Identity(); +} + +TEST_CASE("ebsdlib::TextureTest::DirectStructureMatrix", "[EbsdLib][DirectStructureMatrix]") +{ + std::array latticeParameters = {0.5, 0.5, 1.0, 90.0, 90.0, 90.0}; - int err = EXIT_SUCCESS; - DREAM3D_REGISTER_TEST(TestOdfGeneration()) - DREAM3D_REGISTER_TEST(TestMdfGeneration()) - DREAM3D_REGISTER_TEST(TestMatrix3X3()) - } + Matrix3X3 dsm = Matrix3X3::DirectStructureMatrix(latticeParameters); + + Matrix3X1 latticePoint(0.0, 0.0, 1.0); + auto cartesian = dsm * latticePoint; + std::cout << cartesian << std::endl; + + latticePoint = Matrix3X1(1.0, 0.0, 0.0); + std::cout << dsm * latticePoint << std::endl; + + latticePoint = Matrix3X1(0.0, 1.0, 0.0); + std::cout << dsm * latticePoint << std::endl; -public: - TextureTest(const TextureTest&) = delete; // Copy Constructor Not Implemented - TextureTest(TextureTest&&) = delete; // Move Constructor Not Implemented - TextureTest& operator=(const TextureTest&) = delete; // Copy Assignment Not Implemented - TextureTest& operator=(TextureTest&&) = delete; // Move Assignment Not Implemented -}; + latticePoint = Matrix3X1(0.0, 0.0, 1.0); + std::cout << dsm * latticePoint << std::endl; +} diff --git a/Source/Test/UnitTestSupport.hpp b/Source/Test/UnitTestSupport.hpp index 13e35b86..209749df 100644 --- a/Source/Test/UnitTestSupport.hpp +++ b/Source/Test/UnitTestSupport.hpp @@ -55,8 +55,13 @@ return {#CLASS}; \ } -namespace Ebsd +namespace ebsdlib { +constexpr int s_NumReps = 8; + +const std::string k_InputNames[s_NumReps] = {"eu", "om", "qu", "ax", "ro", "ho", "cu", "st"}; +const int k_CompDims[s_NumReps] = {3, 9, 4, 4, 4, 3, 3, 3}; + namespace unittest { static std::string CurrentMethod(""); @@ -70,7 +75,7 @@ static const char Failed[6] = {'F', 'A', 'I', 'L', 'E', 'D'}; static int SizeOfPassed = 6; static int SizeOfFailed = 6; } // namespace unittest -} // namespace Ebsd +} // namespace ebsdlib #if 0 // ----------------------------------------------------------------------------- @@ -198,47 +203,47 @@ class TestException : public std::exception // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TestPassed(const std::string& test) +inline void TestPassed(const std::string& test) { - ::memset(Ebsd::unittest::TestMessage, ' ', NUM_COLS); // Splat Spaces across the entire message - Ebsd::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated + ::memset(ebsdlib::unittest::TestMessage, ' ', NUM_COLS); // Splat Spaces across the entire message + ebsdlib::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated - std::string::size_type size = NUM_COLS - Ebsd::unittest::SizeOfPassed; - ::strncpy(&(Ebsd::unittest::TestMessage[size]), Ebsd::unittest::Passed, Ebsd::unittest::SizeOfPassed); + std::string::size_type size = NUM_COLS - ebsdlib::unittest::SizeOfPassed; + ::strncpy(&(ebsdlib::unittest::TestMessage[size]), ebsdlib::unittest::Passed, ebsdlib::unittest::SizeOfPassed); if(test.length() < size) { - ::strncpy(Ebsd::unittest::TestMessage, test.c_str(), test.length()); + ::strncpy(ebsdlib::unittest::TestMessage, test.c_str(), test.length()); } else { - ::strncpy(Ebsd::unittest::TestMessage, test.substr(0, size).c_str(), size); + ::strncpy(ebsdlib::unittest::TestMessage, test.substr(0, size).c_str(), size); } - Ebsd::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated - std::cout << Ebsd::unittest::TestMessage << std::endl; - Ebsd::unittest::numTestsPass++; + ebsdlib::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated + std::cout << ebsdlib::unittest::TestMessage << std::endl; + ebsdlib::unittest::numTestsPass++; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- -void TestFailed(const std::string& test) +inline void TestFailed(const std::string& test) { - ::memset(Ebsd::unittest::TestMessage, ' ', NUM_COLS); // Splat Spaces across the entire message - Ebsd::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated + ::memset(ebsdlib::unittest::TestMessage, ' ', NUM_COLS); // Splat Spaces across the entire message + ebsdlib::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated - std::string::size_type size = NUM_COLS - Ebsd::unittest::SizeOfFailed; - ::strncpy(&(Ebsd::unittest::TestMessage[size]), Ebsd::unittest::Failed, Ebsd::unittest::SizeOfFailed); + std::string::size_type size = NUM_COLS - ebsdlib::unittest::SizeOfFailed; + ::strncpy(&(ebsdlib::unittest::TestMessage[size]), ebsdlib::unittest::Failed, ebsdlib::unittest::SizeOfFailed); if(test.length() < size) { - ::strncpy(Ebsd::unittest::TestMessage, test.c_str(), test.length()); + ::strncpy(ebsdlib::unittest::TestMessage, test.c_str(), test.length()); } else { - ::strncpy(Ebsd::unittest::TestMessage, test.substr(0, size).c_str(), size); + ::strncpy(ebsdlib::unittest::TestMessage, test.substr(0, size).c_str(), size); } - Ebsd::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated - std::cout << Ebsd::unittest::TestMessage << std::endl; - Ebsd::unittest::numTestFailed++; + ebsdlib::unittest::TestMessage[NUM_COLS] = 0; // Make sure it is null terminated + std::cout << ebsdlib::unittest::TestMessage << std::endl; + ebsdlib::unittest::numTestFailed++; } // ----------------------------------------------------------------------------- @@ -287,7 +292,7 @@ inline int Sign(float* A) } #endif -bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) +inline bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) { // There are several optional checks that you can do, depending // on what behavior you want from your floating point comparisons. @@ -376,20 +381,8 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) } \ } -#define DREAM3D_REQUIRED(L, Q, R) \ - { \ - std::string buf; \ - std::stringstream ss(buf); \ - bool b = (L Q R); \ - if((b) == (false)) \ - { \ - ss << "Your test required the following\n '"; \ - ss << #L << " " << #Q << " " << #R << "' but this condition was not met.\n"; \ - ss << " " << #L << " = " << L << "\n"; \ - ss << " " << #R << " = " << R << "\n"; \ - DREAM3D_TEST_THROW_EXCEPTION(buf) \ - } \ - } +#define DREAM3D_REQUIRED(L, Q, R) REQUIRE(L Q R); +#define DREAM3D_REQUIRE_VALID_POINTER(P) REQUIRE(P != nullptr); #define DREAM3D_REQUIRED_PTR(L, Q, P) \ { \ @@ -417,16 +410,7 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) DREAM3D_TEST_THROW_EXCEPTION(buf) \ } -#define DREAM3D_REQUIRE_EQUAL(L, R) \ - if((L) != (R)) \ - { \ - const std::string buf; \ - std::stringstream outStream(buf); \ - outStream << "Your test required the following\n '"; \ - outStream << #L << " == " << #R << "'\n but this condition was not met.\n"; \ - outStream << " " << L << "==" << R; \ - DREAM3D_TEST_THROW_EXCEPTION(buf) \ - } +#define DREAM3D_REQUIRE_EQUAL(L, R) REQUIRE(L == R); #define DREAM3D_COMPARE_FLOATS(L, R, Ulps) \ if(false == AlmostEqualUlpsFinal((L), (R), Ulps)) \ @@ -472,31 +456,7 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) } \ } -#define DREAM3D_REQUIRE_VALID_POINTER(L) \ - { \ - std::string buf; \ - std::stringstream ss(buf); \ - if(L == nullptr) \ - { \ - ss << "Your test requires\n '"; \ - ss << #L << "' != nullptr' but this condition was not met.\n"; \ - ss << "\n"; \ - DREAM3D_TEST_THROW_EXCEPTION(buf) \ - } \ - } - -#define DREAM3D_REQUIRE_NULL_POINTER(L) \ - { \ - std::string buf; \ - std::stringstream ss(buf); \ - if(L != nullptr) \ - { \ - ss << "Your test requires\n '"; \ - ss << #L << " == nullptr' but this condition was not met.\n"; \ - ss << "\n"; \ - DREAM3D_TEST_THROW_EXCEPTION(buf) \ - } \ - } +#define DREAM3D_REQUIRE_NULL_POINTER(L) REQUIRE(L == nullptr) // ----------------------------------------------------------------------------- // Private Macros. The Normal developer should NOT be using these. @@ -506,12 +466,12 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) #define DREAM3D_ASSERT(P) assert((P)); #define DREAM3D_ENTER_TEST(test) \ - Ebsd::unittest::CurrentMethod = #test; \ - Ebsd::unittest::numTests++; + ebsdlib::unittest::CurrentMethod = #test; \ + ebsdlib::unittest::numTests++; #define DREAM3D_LEAVE_TEST(test) \ TestPassed(#test); \ - Ebsd::unittest::CurrentMethod = ""; + ebsdlib::unittest::CurrentMethod = ""; #define DREAM3D_REGISTER_TEST(test) \ try \ @@ -521,17 +481,17 @@ bool AlmostEqualUlpsFinal(float* A, float* B, int maxUlps) DREAM3D_LEAVE_TEST(test) \ } catch(TestException & e) \ { \ - TestFailed(Ebsd::unittest::CurrentMethod); \ + TestFailed(ebsdlib::unittest::CurrentMethod); \ std::cout << e.what() << std::endl; \ err = EXIT_FAILURE; \ } #define PRINT_TEST_SUMMARY() \ std::cout << "Test Summary:" << std::endl; \ - std::cout << " Tests Passed: " << Ebsd::unittest::numTestsPass << std::endl; \ - std::cout << " Tests Failed: " << Ebsd::unittest::numTestFailed << std::endl; \ - std::cout << " Total Tests: " << Ebsd::unittest::numTests << std::endl; \ - if(Ebsd::unittest::numTestFailed > 0) \ + std::cout << " Tests Passed: " << ebsdlib::unittest::numTestsPass << std::endl; \ + std::cout << " Tests Failed: " << ebsdlib::unittest::numTestFailed << std::endl; \ + std::cout << " Total Tests: " << ebsdlib::unittest::numTests << std::endl; \ + if(ebsdlib::unittest::numTestFailed > 0) \ { \ err = EXIT_FAILURE; \ } diff --git a/cmake/Utility.cmake b/cmake/Utility.cmake new file mode 100644 index 00000000..fbe032d0 --- /dev/null +++ b/cmake/Utility.cmake @@ -0,0 +1,543 @@ + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +function(enable_vcpkg_manifest_feature) + set(optionsArgs) + set(oneValueArgs TEST_VAR FEATURE) + set(multiValueArgs) + cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(${ARGS_TEST_VAR}) + if(NOT ${ARGS_FEATURE} IN_LIST VCPKG_MANIFEST_FEATURES) + set(VCPKG_MANIFEST_FEATURES ${VCPKG_MANIFEST_FEATURES} ${ARGS_FEATURE} CACHE STRING "" FORCE) + message(WARNING "VCPKG_MANIFEST_FEATURES was changed. ${ARGS_FEATURE} was added. Rerun CMake again to have VCPKG pick up the changes.") + endif() + endif() +endfunction() + + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +function(install_with_directory) + set(optionsArgs) + set(oneValueArgs DESTINATION COMPONENT BASE_DIR) + set(multiValueArgs FILES) + cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + foreach(file ${ARGS_FILES}) + file(RELATIVE_PATH relative_file ${ARGS_BASE_DIR} ${file}) + get_filename_component(destination_dir ${relative_file} DIRECTORY) + install(FILES ${file} + DESTINATION ${ARGS_DESTINATION}/${destination_dir} + COMPONENT ${ARGS_COMPONENT} + ) + endforeach() +endfunction() + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +function(simplnx_enable_warnings) + set(optionsArgs) + set(oneValueArgs TARGET) + set(multiValueArgs) + cmake_parse_arguments(ARG "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT TARGET ${ARG_TARGET}) + message(FATAL_ERROR "simplnx_enable_warnings must be called with the argument TARGET set to a valid target") + endif() + + if(MSVC) + target_compile_options(${ARG_TARGET} + PUBLIC + /Zc:__cplusplus # Enables the __cplusplus preprocessor macro to report an updated value for recent C++ language standards support. By default, Visual Studio always returns the value 199711L for the __cplusplus preprocessor macro. + PRIVATE + # Suppressed warnings + /wd4275 # C4275: An exported class was derived from a class that wasn't exported. + /wd4251 # C4251: 'type' : class 'type1' needs to have dll-interface to be used by clients of class 'type2' + + # Warning to error + /we4706 # C4706: assignment within conditional expression + /we4715 # C4715: The specified function can potentially not return a value. + /we4456 # C4456: declaration of 'identifier' hides previous local declaration + /we4457 # C4457: declaration of 'identifier' hides function parameter + /we4458 # C4458: declaration of 'identifier' hides class member + /we4459 # C4459: declaration of 'identifier' hides global declaration + /we4263 # C4263: 'function' : member function does not override any base class virtual member function + /we4266 # C4266: 'function' : no override available for virtual member function from base 'type'; function is hidden + + /permissive- # Standards compliance + ) + else() + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(SHADOW_WARNING "shadow") + else() + set(SHADOW_WARNING "shadow-all") + endif() + + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CLANG_WARNINGS + -Werror=implicit-exception-spec-mismatch # Wimplicit-exception-spec-mismatch: function previously declared with an explicit/implicit exception specification redeclared with an implicit/explicit exception specification + -Werror=inconsistent-missing-override # Winconsistent-missing-override: A overrides a member function but is not marked "override" + -Werror=inconsistent-missing-destructor-override # Winconsistent-missing-destructor-override: A overrides a destructor but is not marked "override" + ) + endif() + + target_compile_options(${ARG_TARGET} + PRIVATE + # Warning to error + -Werror=parentheses # Wparentheses: Warn if parentheses are omitted in certain contexts, such as when there is an assignment in a context where a truth value is expected, or when operators are nested whose precedence people often get confused about + -Werror=return-type # Wreturn-type: Warn about any "return" statement with no return value in a function whose return type is not "void" + -Werror=${SHADOW_WARNING} # Wshadow: Warn whenever a local variable or type declaration shadows another variable, parameter, type, class member (in C++), or instance variable (in Objective-C) or whenever a built-in function is shadowed. + ${CLANG_WARNINGS} + ) + + endif() +endfunction() + + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +include(FetchContent) +include(ExternalProject) + +function(download_test_data) + set(optionsArgs INSTALL COPY_DATA) + set(oneValueArgs DREAM3D_DATA_DIR ARCHIVE_NAME SHA512) + set(multiValueArgs FILES) + cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT SIMPLNX_DOWNLOAD_TEST_FILES) + return() + endif() + + get_property(FETCH_FILE_PATH GLOBAL PROPERTY FETCH_FILE_PATH) + + get_filename_component(archive_base_name ${ARGS_ARCHIVE_NAME} NAME_WE) + file(TO_CMAKE_PATH "${simplnx_BINARY_DIR}/TestFiles" test_files_dir) + file(TO_CMAKE_PATH "${ARGS_DREAM3D_DATA_DIR}" ARGS_DREAM3D_DATA_DIR) + #---------------------------------------------------------------------------- + # Create the custom CMake File for this archive file + #---------------------------------------------------------------------------- + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + set(CX_CONFIG_DIR "\${CONFIG}") + else() + set(CX_CONFIG_DIR ".") + endif() + set(DATA_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data") + + set(fetch_data_file "${test_files_dir}/${ARGS_ARCHIVE_NAME}.cmake") + # Strip off the .tar.gz extension + string(REPLACE ".tar.gz" "" ARCHIVE_BASE_NAME "${ARGS_ARCHIVE_NAME}") + + #---------------------------------------------------------------------------- + # This section will sequentially number the downloads + #---------------------------------------------------------------------------- + get_property(FETCH_FILE_INDEX GLOBAL PROPERTY FETCH_FILE_INDEX) + math(EXPR FETCH_FILE_INDEX "${FETCH_FILE_INDEX} + 1") + set_property(GLOBAL PROPERTY FETCH_FILE_INDEX ${FETCH_FILE_INDEX}) + + #---------------------------------------------------------------------------- + # This section configures the bit of CMake code for the specific data file + # that is being downloaded + #---------------------------------------------------------------------------- + configure_file(${simplnx_SOURCE_DIR}/cmake/FetchDataFile.cmake.in + ${fetch_data_file} + @ONLY + ) + # Read the file back into a string + file(READ "${fetch_data_file}" FETCH_FILE_CONTENTS) + # Append the string to the master file + file(APPEND "${FETCH_FILE_PATH}" "${FETCH_FILE_CONTENTS}") + file(REMOVE "${fetch_data_file}") # Remove the temporary file + + #----- + # If we are installing the data files then we need to create a custom install + # rule to ensure the archive contents are actually decompressed and available. Since + # we are possibly making a copy into the binary directory, use that as the source + # location of the data. Running the unit tests might remove the decompressed data + # as a by product. + if(ARGS_INSTALL) + if(is_multi_config) + set(CX_CONFIG_DIR "$") + else() + set(CX_CONFIG_DIR ".") + endif() + set(DATA_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data") + install(DIRECTORY + "${DATA_DEST_DIR}/${ARCHIVE_BASE_NAME}" + DESTINATION Data/ + COMPONENT Applications + ) + + endif() + +endfunction() + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +function(create_data_copy_rules) + set(optionsArgs) + set(oneValueArgs DREAM3D_DATA_DIR) + set(multiValueArgs FILES) + cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + message(STATUS "DREAM3D_DATA_DIR: ${ARGS_DREAM3D_DATA_DIR}") + # If the data directory does not exist then bail out now. + if(NOT EXISTS "${ARGS_DREAM3D_DATA_DIR}") + message(STATUS "DREAM3D_Data directory does not exist. Not creating copy and install rules.") + return() + endif() + + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + set(CX_CONFIG_DIR "$") + else() + set(CX_CONFIG_DIR ".") + endif() + + set(DATA_DEST_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data/") + if(EXISTS "${ARGS_DREAM3D_DATA_DIR}/Data") + add_custom_target(DataFolderCopy ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${ARGS_DREAM3D_DATA_DIR}/Data ${DATA_DEST_DIR} + COMMENT "Copying Data Folder into Binary Directory" + COMMAND_EXPAND_LISTS + VERBATIM + ) + set_target_properties(DataFolderCopy PROPERTIES FOLDER ZZ_COPY_FILES) + + set(DREAM3D_DATA_DIRECTORIES + ${ARGS_DREAM3D_DATA_DIR}/Data/Image + ${ARGS_DREAM3D_DATA_DIR}/Data/Models + ) + + set(SIMPLNX_DATA_INSTALL_DIR "Data") + + # NOTE: If we are creating an Anaconda install the install directory WILL be different + foreach(data_dir ${DREAM3D_DATA_DIRECTORIES}) + if(EXISTS ${data_dir}) + install(DIRECTORY + ${data_dir} + DESTINATION ${SIMPLNX_DATA_INSTALL_DIR} + COMPONENT Applications + ) + endif() + endforeach() + endif() +endfunction() + +#------------------------------------------------------------------------------ +# +#------------------------------------------------------------------------------ +function(pad_string output str padchar length) + string(LENGTH "${str}" _strlen) + math(EXPR _strlen "${length} - ${_strlen}") + + if(_strlen GREATER 0) + string(REPEAT ${padchar} ${_strlen} _pad) + string(APPEND ${_pad} str ) + endif() + + set(${output} "${_pad}" PARENT_SCOPE) +endfunction() + +#------------------------------------------------------------------------------ +# This function creates a CTest for each Pipeline path passed into it. +#------------------------------------------------------------------------------ +function(create_pipeline_tests) + set(optionsArgs) + set(oneValueArgs PLUGIN_NAME) + set(multiValueArgs PIPELINE_LIST) + cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(TEST_PIPELINE_LIST_FILE ${${ARGS_PLUGIN_NAME}_BINARY_DIR}/test/Prebuilt_Pipeline_Tests.txt) + FILE(WRITE ${TEST_PIPELINE_LIST_FILE} "# ${ARGS_PLUGIN_NAME} Example Pipelines Test List") + + set(TEST_WORKING_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(TEST_WORKING_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<$:Debug>$<$:Release>") + endif() + + + get_target_property(PIPELINE_RUNNER_NAME nxrunner NAME) + get_target_property(PIPELINE_RUNNER_DEBUG nxrunner DEBUG_POSTFIX) + + set(test_index "0") + foreach(pipeline_file_path ${ARGS_PIPELINE_LIST} ) + math(EXPR test_index "${test_index} + 1") + # get the padding string to prefix in front of the test_index + pad_string(padding "${test_index}" "0" "3") + + FILE(APPEND ${TEST_PIPELINE_LIST_FILE} "[${padding}${test_index}] ${pipeline_file_path}\n") + + get_filename_component(test_file_name ${pipeline_file_path} NAME_WE) + string(REPLACE "/" "-" test_file_name "${test_file_name}") + + add_test(NAME "PIPELINE::${ARGS_PLUGIN_NAME}::${padding}${test_index}_${test_file_name}" + COMMAND "${PIPELINE_RUNNER_NAME}$<$:${PIPELINE_RUNNER_DEBUG}>" --execute ${pipeline_file_path} + #CONFIGURATIONS Debug + WORKING_DIRECTORY ${TEST_WORKING_DIR}) + endforeach() + +endfunction() + +#------------------------------------------------------------------------------- +# This function generates a file ONLY if the MD5 between the "to be" generated file +# and the current file are different. This will help reduce recompiles based on +# the generation of files that are really the same. +#------------------------------------------------------------------------------- +function(cmpConfigureFileWithMD5Check) + set(options) + set(oneValueArgs CONFIGURED_TEMPLATE_PATH GENERATED_FILE_PATH ) + cmake_parse_arguments(GVS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + # message(STATUS " GVS_CONFIGURED_TEMPLATE_PATH: ${GVS_CONFIGURED_TEMPLATE_PATH}") + # message(STATUS " GVS_GENERATED_FILE_PATH: ${GVS_GENERATED_FILE_PATH}") + + # Only Generate a file if it is different than what is already there. + if(EXISTS ${GVS_GENERATED_FILE_PATH} ) + file(MD5 ${GVS_GENERATED_FILE_PATH} VERSION_HDR_MD5) + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH}_tmp ) + + file(MD5 ${GVS_GENERATED_FILE_PATH}_tmp VERSION_GEN_HDR_MD5) + #message(STATUS " File Exists, doing MD5 Comparison") + + # Compare the MD5 checksums. If they are different then configure the file into the proper location + if(NOT "${VERSION_HDR_MD5}" STREQUAL "${VERSION_GEN_HDR_MD5}") + #message(STATUS " ${VERSION_GEN_HDR_MD5}") + #message(STATUS " ${VERSION_HDR_MD5}") + #message(STATUS " Files differ: Replacing with newly generated file") + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH} ) + else() + #message(STATUS " NO Difference in Files") + endif() + file(REMOVE ${GVS_GENERATED_FILE_PATH}_tmp) + else() + # message(STATUS " File does NOT Exist, Generating one...") + configure_file(${GVS_CONFIGURED_TEMPLATE_PATH} ${GVS_GENERATED_FILE_PATH} ) + endif() + +endfunction() + + + +#------------------------------------------------------------------------------- +# We are going to use Git functionality to create a version number for our package +# The MAJOR.MINOR.PATCH is based off of YYYY.MM.DD +# The TWEAK is the git hash of project. +#------------------------------------------------------------------------------- +function(cmpBuildDateRevisionString) + set(options) + set(oneValueArgs GENERATED_HEADER_FILE_PATH GENERATED_SOURCE_FILE_PATH + NAMESPACE PROJECT_NAME EXPORT_MACRO VERSION_MACRO_PATH STRING_CLASS STRING_INCLUDE) + cmake_parse_arguments(GVS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + if(NOT DEFINED GVS_STRING_CLASS) + set(GVS_STRING_CLASS "std::string") + endif() + + if(NOT DEFINED GVS_STRING_INCLUDE) + set(GVS_STRING_INCLUDE "") + endif() + + if(0) + message(STATUS "--------------------------------------------") + message(STATUS "GVS_NAMESPACE: ${GVS_NAMESPACE}") + message(STATUS "GVS_PROJECT_NAME: ${GVS_PROJECT_NAME}") + message(STATUS "GVS_GENERATED_HEADER_FILE_PATH: ${GVS_GENERATED_HEADER_FILE_PATH}") + message(STATUS "GVS_GENERATED_SOURCE_FILE_PATH: ${GVS_GENERATED_SOURCE_FILE_PATH}") + message(STATUS "GVS_PROJECT_VERSION_MAJOR: ${GVS_PROJECT_VERSION_MAJOR}") + message(STATUS "GVS_EXPORT_MACRO: ${GVS_EXPORT_MACRO}") + message(STATUS "${GVS_PROJECT_NAME}_BUILD_DATE: ${${GVS_PROJECT_NAME}_BUILD_DATE}") + message(STATUS "${GVS_PROJECT_NAME}_SOURCE_DIR: ${${GVS_PROJECT_NAME}_SOURCE_DIR}") + message(STATUS "--------------------------------------------") + endif() + + string(STRIP "${${GVS_PROJECT_NAME}_BUILD_DATE}" DVERS) + string(REPLACE "/" "-" DVERS "${DVERS}") + # Run 'git describe' to get our tag offset + # execute_process(COMMAND ${GIT_EXECUTABLE} describe --long + # OUTPUT_VARIABLE DVERS + # RESULT_VARIABLE did_run + # ERROR_VARIABLE git_error + # WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} ) + + #message(STATUS "DVERS: ${DVERS}") + set(PROJECT_PREFIX "${GVS_PROJECT_NAME}") + set(VERSION_GEN_NAME "${GVS_PROJECT_NAME}") + set(VERSION_GEN_NAMESPACE "${GVS_NAMESPACE}") + string(TOLOWER "${VERSION_GEN_NAMESPACE}" VERSION_INCLUDE_GUARD) + set(VERSION_GEN_NAMESPACE_EXPORT "${GVS_EXPORT_MACRO}") + set(VERSION_GEN_VER_MAJOR ${${GVS_PROJECT_NAME}_VERSION_MAJOR}) + set(VERSION_GEN_VER_MINOR ${${GVS_PROJECT_NAME}_VERSION_MINOR}) + set(VERSION_GEN_VER_PATCH ${${GVS_PROJECT_NAME}_VERSION_PATCH}) + set(VERSION_GEN_VER_SUFFIX ${${GVS_PROJECT_NAME}_VERSION_SUFFIX}) + set(VERSION_GEN_GIT_HASH_SHORT "0") + + string(TIMESTAMP VERSION_BUILD_DATE "%Y/%m/%d") + + set(VERSION_GEN_HEADER_FILE_NAME ${GVS_GENERATED_HEADER_FILE_PATH}) + + #-- Make sure that actually worked and if not just generate some dummy values + if(NOT "${DVERS}" STREQUAL "") + string(STRIP ${DVERS} DVERS) + string(REPLACE "-" ";" VERSION_LIST ${DVERS}) + list(LENGTH VERSION_LIST VERSION_LIST_LENGTH) + + set(VERSION_GEN_VER_PATCH "0") + set(VERSION_GEN_GIT_HASH_SHORT "0") + + list(LENGTH VERSION_LIST LIST_LENGTH) + if(LIST_LENGTH GREATER 1) + list(GET VERSION_LIST 0 VERSION_GEN_VER_MAJOR) + list(GET VERSION_LIST 1 VERSION_GEN_VER_MINOR) + list(GET VERSION_LIST 2 VERSION_GEN_VER_PATCH) + endif() + + endif() + + find_package(Git) + # Run 'git rev-parse --short HEAD' to get our revision + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + OUTPUT_VARIABLE DVERS + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} ) + string(STRIP "${DVERS}" DVERS) + if(DVERS STREQUAL "") + message(STATUS "[${GVS_PROJECT_NAME}] 'git rev-parse --short HEAD' did not return anything valid") + set(VERSION_GEN_GIT_HASH_SHORT "000000000000") + else() + set(VERSION_GEN_GIT_HASH_SHORT "${DVERS}") + endif() + + set(${GVS_PROJECT_NAME}_VERSION_MAJOR "${VERSION_GEN_VER_MAJOR}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_MINOR "${VERSION_GEN_VER_MINOR}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_PATCH "${VERSION_GEN_VER_PATCH}" PARENT_SCOPE) + set(${GVS_PROJECT_NAME}_VERSION_TWEAK "${VERSION_GEN_GIT_HASH_SHORT}" PARENT_SCOPE) + + set(CMP_TOP_HEADER_INCLUDE_STATMENT "") + if(NOT "${CMP_TOP_HEADER_FILE}" STREQUAL "") + set(CMP_TOP_HEADER_INCLUDE_STATMENT "#include \"${CMP_TOP_HEADER_FILE}\"") + endif() + + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD + OUTPUT_VARIABLE GVS_GIT_HASH + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} + ) + string(REPLACE "\n" "" GVS_GIT_HASH "${GVS_GIT_HASH}") + set_property(GLOBAL PROPERTY ${GVS_PROJECT_NAME}_GIT_HASH ${GVS_GIT_HASH}) + + execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --pretty='%cd' --date=format:%Y-%m-%d-%H:%M:%S + OUTPUT_VARIABLE GVS_GIT_COMMIT_DATE + RESULT_VARIABLE did_run + ERROR_VARIABLE git_error + WORKING_DIRECTORY ${${GVS_PROJECT_NAME}_SOURCE_DIR} + ) + string(REPLACE "\n" "" GVS_GIT_COMMIT_DATE "${GVS_GIT_COMMIT_DATE}") + set_property(GLOBAL PROPERTY ${GVS_PROJECT_NAME}_GIT_COMMIT_DATE ${GVS_GIT_COMMIT_DATE}) + + if(NOT "${GVS_GENERATED_HEADER_FILE_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_HEADER_FILE_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_HEADER_FILE_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_VERSION_HDR_TEMPLATE_FILE} ) + endif() + + if(NOT "${GVS_GENERATED_SOURCE_FILE_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_SOURCE_FILE_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_GENERATED_SOURCE_FILE_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_VERSION_SRC_TEMPLATE_FILE} ) + endif() + + if(NOT "${GVS_VERSION_MACRO_PATH}" STREQUAL "") + # message(STATUS "Generating: ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_VERSION_MACRO_PATH}") + cmpConfigureFileWithMD5Check( GENERATED_FILE_PATH ${${GVS_PROJECT_NAME}_BINARY_DIR}/${GVS_VERSION_MACRO_PATH} + CONFIGURED_TEMPLATE_PATH ${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpVersionMacro.h.in ) + endif() + +endfunction() + + +#------------------------------------------------------------------------------- +# @Brief function AddPythonTest +# @ NAME +# @ FILE +# @ PYTHONPATH +#------------------------------------------------------------------------------- +function(AddPythonTest) + set(options ) + set(oneValueArgs NAME FILE) + set(multiValueArgs PYTHONPATH) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # message(STATUS "ARGS_FILE:${ARGS_FILE}") + if(SIMPLNX_BUILD_PYTHON) + if(WIN32) + set(test_driver_file ${simplnx_SOURCE_DIR}/wrapping/python/testing/anaconda_test.bat) + else() + set(test_driver_file ${simplnx_SOURCE_DIR}/wrapping/python/testing/anaconda_test.sh) + endif() + + add_test(NAME ${ARGS_NAME} + COMMAND ${test_driver_file} + ) + + set_property(TEST ${ARGS_NAME} + PROPERTY + ENVIRONMENT + "PYTHON_TEST_FILE=${ARGS_FILE}" + "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}" + ) + else() + add_test(NAME ${ARGS_NAME} + COMMAND ${Python3_EXECUTABLE} ${ARGS_FILE} + ) + endif() + + if(WIN32) + string(REPLACE ";" "\\;" ARGS_PYTHONPATH "${ARGS_PYTHONPATH}") + else() + string(REPLACE ";" ":" ARGS_PYTHONPATH "${ARGS_PYTHONPATH}") + endif() + + set_property(TEST ${ARGS_NAME} + APPEND + PROPERTY + ENVIRONMENT + "PYTHONPATH=${ARGS_PYTHONPATH}" + ) +endfunction() + +#------------------------------------------------------------------------------- +# @Brief function CreatePythonTests +# @ PREFIX +# @ INPUT_DIR +# @ TEST_NAMES +#------------------------------------------------------------------------------- +function(CreatePythonTests) + set(options) + set(oneValueArgs PREFIX INPUT_DIR) + set(multiValueArgs TEST_NAMES) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(TESTS_PYTHONPATH + "$" + ) + + foreach(test ${ARGS_TEST_NAMES}) + string(REPLACE "/" "_" test_name ${test}) + set(PY_TEST_NAME ${ARGS_PREFIX}_${test_name}) + + AddPythonTest(NAME ${PY_TEST_NAME} + FILE ${ARGS_INPUT_DIR}/${test}.py + PYTHONPATH ${TESTS_PYTHONPATH} + ) + endforeach() +endfunction() diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index a4a8e9c7..3bbe168e 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -10,22 +10,18 @@ "repository": "https://github.com/bluequartzsoftware/simplnx-registry", "packages": [ "eigen3", - "expected-lite", "fmt", "h5support", "hdf5", - "lz4", - "nlohmann-json", - "nod", - "span-lite", "tbb", "ninja", "vcpkg-cmake", "vcpkg-cmake-config", "zlib", - "zstd" + "zstd", + "catch2" ], - "baseline": "c9415182598df306f0d3f2f2b354d9d79cf1bf8b" + "baseline": "9ff0ea7373196b1c26c9cac15919b23045405994" } ] } diff --git a/vcpkg.json b/vcpkg.json index 263b10db..c6d09f33 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,6 +3,9 @@ "name": "simplnx", "version": "0.1.0", "dependencies": [ + { + "name": "fmt" + }, { "name": "eigen3" }, @@ -25,6 +28,14 @@ "name": "tbb" } ] + }, + "tests": { + "description": "Tests", + "dependencies": [ + { + "name": "catch2" + } + ] } } }