49
49
#include " EbsdLib/Core/Orientation.hpp"
50
50
#include " EbsdLib/Math/EbsdLibMath.h"
51
51
#include " EbsdLib/Math/GeometryMath.h"
52
+ #include " EbsdLib/Utilities/ColorTable.h"
52
53
#include " EbsdLib/Utilities/ColorUtilities.h"
53
54
#include " EbsdLib/Utilities/ComputeStereographicProjection.h"
54
55
#include " EbsdLib/Utilities/EbsdStringUtils.hpp"
55
- #include " EbsdLib/Utilities/ColorTable.h"
56
56
57
57
namespace CubicHigh
58
58
{
@@ -235,6 +235,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
235
235
236
236
};
237
237
// clang-format on
238
+ static const double k_EtaMin = 0.0 ;
239
+ static const double k_EtaMax = 45.0 ;
240
+
238
241
} // namespace CubicHigh
239
242
240
243
// -----------------------------------------------------------------------------
@@ -1678,13 +1681,11 @@ bool inUnitTriangleD(double eta, double chi)
1678
1681
}
1679
1682
1680
1683
// -----------------------------------------------------------------------------
1681
- //
1682
- // -----------------------------------------------------------------------------
1683
- bool CubicOps::inUnitTriangle (double eta, double chi) const
1684
+ std::array<double , 3 > CubicOps::getIpfColorAngleLimits (double eta) const
1684
1685
{
1685
1686
double etaDeg = eta * EbsdLib::Constants::k_180OverPiD;
1686
1687
double chiMax;
1687
- if (etaDeg > 45.0 )
1688
+ if (etaDeg > CubicHigh::k_EtaMax )
1688
1689
{
1689
1690
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)));
1690
1691
}
@@ -1693,66 +1694,18 @@ bool CubicOps::inUnitTriangle(double eta, double chi) const
1693
1694
chiMax = std::sqrt (1.0 / (2.0 + std::tan (eta) * std::tan (eta)));
1694
1695
}
1695
1696
EbsdLibMath::bound (chiMax, -1.0 , 1.0 );
1696
- chiMax = acos (chiMax);
1697
- return !(eta < 0.0 || eta > (45.0 * EbsdLib::Constants::k_PiOver180D) || chi < 0.0 || chi > chiMax);
1698
- }
1699
-
1700
- // -----------------------------------------------------------------------------
1701
- //
1702
- // -----------------------------------------------------------------------------
1703
- EbsdLib::Rgb CubicOps::generateIPFColor (double * eulers, double * refDir, bool convertDegrees) const
1704
- {
1705
- return generateIPFColor (eulers[0 ], eulers[1 ], eulers[2 ], refDir[0 ], refDir[1 ], refDir[2 ], convertDegrees);
1697
+ chiMax = std::acos (chiMax);
1698
+ return {CubicHigh::k_EtaMin * EbsdLib::Constants::k_DegToRadD, CubicHigh::k_EtaMax * EbsdLib::Constants::k_DegToRadD, chiMax};
1706
1699
}
1707
1700
1708
1701
// -----------------------------------------------------------------------------
1709
1702
//
1710
1703
// -----------------------------------------------------------------------------
1711
- EbsdLib::Rgb CubicOps::generateIPFColor (double phi1 , double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad ) const
1704
+ bool CubicOps::inUnitTriangle (double eta , double chi ) const
1712
1705
{
1713
- if (degToRad)
1714
- {
1715
- phi1 = phi1 * EbsdLib::Constants::k_DegToRadD;
1716
- phi = phi * EbsdLib::Constants::k_DegToRadD;
1717
- phi2 = phi2 * EbsdLib::Constants::k_DegToRadD;
1718
- }
1719
-
1720
- EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
1721
- double chi = 0 .0f ;
1722
- double eta = 0 .0f ;
1723
- double _rgb[3 ] = {0.0 , 0.0 , 0.0 };
1724
-
1725
- OrientationType eu (phi1, phi, phi2);
1726
- OrientationType om (9 ); // Reusable for the loop
1727
- QuatD q1 = OrientationTransformation::eu2qu<OrientationType, QuatD>(eu);
1728
-
1729
- for (int j = 0 ; j < CubicHigh::k_SymOpsCount; j++)
1730
- {
1731
- QuatD qu = getQuatSymOp (j) * q1;
1732
- EbsdLib::Matrix3X3D g (OrientationTransformation::qu2om<QuatD, OrientationType>(qu).data ());
1733
- EbsdLib::Matrix3X1D p = (g * refDirection).normalize ();
1734
-
1735
- if (!getHasInversion () && p[2 ] < 0 )
1736
- {
1737
- continue ;
1738
- }
1739
- if (getHasInversion () && p[2 ] < 0 )
1740
- {
1741
- p = p * -1.0 ;
1742
- }
1743
- chi = std::acos (p[2 ]);
1744
- eta = std::atan2 (p[1 ], p[0 ]);
1745
- if (!inUnitTriangleD (eta, chi))
1746
- {
1747
- continue ;
1748
- }
1749
- break ;
1750
- }
1751
- double etaMin = 0.0 ;
1752
- double etaMax = 45.0 ;
1753
1706
double etaDeg = eta * EbsdLib::Constants::k_180OverPiD;
1754
1707
double chiMax;
1755
- if (etaDeg > 45.0 )
1708
+ if (etaDeg > CubicHigh::k_EtaMax )
1756
1709
{
1757
1710
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)));
1758
1711
}
@@ -1761,32 +1714,26 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do
1761
1714
chiMax = std::sqrt (1.0 / (2.0 + std::tan (eta) * std::tan (eta)));
1762
1715
}
1763
1716
EbsdLibMath::bound (chiMax, -1.0 , 1.0 );
1764
- chiMax = std::acos (chiMax);
1765
-
1766
- _rgb[0 ] = 1.0 - chi / chiMax;
1767
- _rgb[2 ] = std::fabs (etaDeg - etaMin) / (etaMax - etaMin);
1768
- _rgb[1 ] = 1 - _rgb[2 ];
1769
- _rgb[1 ] *= chi / chiMax;
1770
- _rgb[2 ] *= chi / chiMax;
1771
- _rgb[0 ] = std::sqrt (_rgb[0 ]);
1772
- _rgb[1 ] = std::sqrt (_rgb[1 ]);
1773
- _rgb[2 ] = std::sqrt (_rgb[2 ]);
1774
-
1775
- double max = _rgb[0 ];
1776
- if (_rgb[1 ] > max)
1777
- {
1778
- max = _rgb[1 ];
1779
- }
1780
- if (_rgb[2 ] > max)
1781
- {
1782
- max = _rgb[2 ];
1783
- }
1717
+ chiMax = acos (chiMax);
1718
+ return !(eta < CubicHigh::k_EtaMin || eta > (CubicHigh::k_EtaMax * EbsdLib::Constants::k_PiOver180D) || chi < 0.0 || chi > chiMax);
1719
+ }
1784
1720
1785
- _rgb[0 ] = _rgb[0 ] / max;
1786
- _rgb[1 ] = _rgb[1 ] / max;
1787
- _rgb[2 ] = _rgb[2 ] / max;
1721
+ // -----------------------------------------------------------------------------
1722
+ //
1723
+ // -----------------------------------------------------------------------------
1724
+ EbsdLib::Rgb CubicOps::generateIPFColor (double * eulers, double * refDir, bool degToRad) const
1725
+ {
1726
+ return computeIPFColor (eulers, refDir, degToRad);
1727
+ }
1788
1728
1789
- return EbsdLib::RgbColor::dRgb (static_cast <int32_t >(_rgb[0 ] * 255 ), static_cast <int32_t >(_rgb[1 ] * 255 ), static_cast <int32_t >(_rgb[2 ] * 255 ), 255 );
1729
+ // -----------------------------------------------------------------------------
1730
+ //
1731
+ // -----------------------------------------------------------------------------
1732
+ EbsdLib::Rgb CubicOps::generateIPFColor (double phi1, double phi, double phi2, double refDir0, double refDir1, double refDir2, bool degToRad) const
1733
+ {
1734
+ double eulers[3 ] = {phi1, phi, phi2};
1735
+ double refDir[3 ] = {refDir0, refDir1, refDir2};
1736
+ return computeIPFColor (eulers, refDir, degToRad);
1790
1737
}
1791
1738
1792
1739
// -----------------------------------------------------------------------------
0 commit comments