Skip to content

Commit 08cf743

Browse files
committed
Update some static constants to constexpr
1 parent 1ff0855 commit 08cf743

12 files changed

Lines changed: 129 additions & 129 deletions

Source/EbsdLib/LaueOps/CubicLowOps.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ using namespace ebsdlib;
5858
namespace CubicLow
5959
{
6060

61-
static const std::array<size_t, 3> OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin
61+
constexpr std::array<size_t, 3> OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin
6262
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)),
6363
std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0)),
6464
std::pow((0.75 * (ebsdlib::constants::k_PiOver2D - std::sin(ebsdlib::constants::k_PiOver2D))), (1.0 / 3.0))};
6565
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0]) / 2.0, OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1]) / 2.0,
6666
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2]) / 2.0};
6767

68-
static const int symSize0 = 6;
69-
static const int symSize1 = 12;
70-
static const int symSize2 = 8;
68+
constexpr int symSize0 = 6;
69+
constexpr int symSize1 = 12;
70+
constexpr int symSize2 = 8;
7171

72-
static const int k_OdfSize = 46656;
73-
static const int k_MdfSize = 46656;
74-
static const int k_SymOpsCount = 12;
75-
static const int k_NumMdfBins = 18;
72+
constexpr int k_OdfSize = 46656;
73+
constexpr int k_MdfSize = 46656;
74+
constexpr int k_SymOpsCount = 12;
75+
constexpr int k_NumMdfBins = 18;
7676

7777
// Rotation Point Group: 23
7878
/* clang-format off */
@@ -157,8 +157,8 @@ static const double MatSym[k_SymOpsCount][3][3] = {
157157

158158
};
159159
/* clang-format on */
160-
static const double k_EtaMin = 0.0;
161-
static const double k_EtaMax = 90.0;
160+
constexpr double k_EtaMin = 0.0;
161+
constexpr double k_EtaMax = 90.0;
162162
} // namespace CubicLow
163163

164164
// -----------------------------------------------------------------------------

Source/EbsdLib/LaueOps/CubicOps.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ using namespace ebsdlib;
6262
namespace CubicHigh
6363
{
6464

65-
static const std::array<size_t, 3> OdfNumBins = {18, 18, 18}; // Represents a 5Deg bin
65+
constexpr std::array<size_t, 3> OdfNumBins = {18, 18, 18}; // Represents a 5Deg bin
6666
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0)),
6767
std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0)),
6868
std::pow((0.75 * (ebsdlib::constants::k_PiOver4D - std::sin(ebsdlib::constants::k_PiOver4D))), (1.0 / 3.0))};
6969

7070
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1] / 2),
7171
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2] / 2)};
7272

73-
static const int symSize0 = 6;
74-
static const int symSize1 = 12;
75-
static const int symSize2 = 8;
73+
constexpr int symSize0 = 6;
74+
constexpr int symSize1 = 12;
75+
constexpr int symSize2 = 8;
7676

77-
static const int k_OdfSize = 5832;
78-
static const int k_MdfSize = 5832;
79-
static const int k_SymOpsCount = 24;
80-
static const int k_NumMdfBins = 13;
77+
constexpr int k_OdfSize = 5832;
78+
constexpr int k_MdfSize = 5832;
79+
constexpr int k_SymOpsCount = 24;
80+
constexpr int k_NumMdfBins = 13;
8181

8282
static const double SlipDirections[12][3] = {{0.0, 1.0, -1.0}, {1.0, 0.0, -1.0}, {1.0, -1.0, 0.0}, {1.0, -1.0, 0.0}, {1.0, 0.0, 1.0}, {0.0, 1.0, 1.0},
8383
{1.0, 1.0, 0.0}, {0.0, 1.0, 1.0}, {1.0, 0.0, -1.0}, {1.0, 1.0, 0.0}, {1.0, 0.0, 1.0}, {0.0, 1.0, -1.0}};
@@ -240,8 +240,8 @@ static const double MatSym[k_SymOpsCount][3][3] = {
240240

241241
};
242242
/* clang-format on */
243-
static const double k_EtaMin = 0.0;
244-
static const double k_EtaMax = 45.0;
243+
constexpr double k_EtaMin = 0.0;
244+
constexpr double k_EtaMax = 45.0;
245245

246246
} // namespace CubicHigh
247247

@@ -2057,7 +2057,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
20572057
{
20582058
radius = 1.0F;
20592059
float angle = angles[idx];
2060-
float rads = angle * M_PI / 180.0f;
2060+
float rads = angle * ebsdlib::constants::k_DegToRadF;
20612061
float x = radius * (cos(rads));
20622062
float y = radius * (sin(rads));
20632063

Source/EbsdLib/LaueOps/HexagonalLowOps.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ using namespace ebsdlib;
5757

5858
namespace HexagonalLow
5959
{
60-
static const std::array<size_t, 3> OdfNumBins = {72, 72, 12}; // Represents a 5Deg bin
60+
constexpr std::array<size_t, 3> OdfNumBins = {72, 72, 12}; // Represents a 5Deg bin
6161
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)),
6262
std::pow((0.75 * (ebsdlib::constants::k_PiD - std::sin(ebsdlib::constants::k_PiD))), (1.0 / 3.0)),
6363
std::pow((0.75 * ((ebsdlib::constants::k_PiD / 6.0) - std::sin(ebsdlib::constants::k_PiD / 6.0))), (1.0 / 3.0))};
6464

6565
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1] / 2),
6666
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2] / 2)};
6767

68-
static const int symSize0 = 2;
69-
static const int symSize1 = 2;
70-
static const int symSize2 = 2;
68+
constexpr int symSize0 = 2;
69+
constexpr int symSize1 = 2;
70+
constexpr int symSize2 = 2;
7171

72-
static const int k_OdfSize = 62208;
73-
static const int k_MdfSize = 62208;
74-
static const int k_SymOpsCount = 6;
75-
static const int k_NumMdfBins = 36;
72+
constexpr int k_OdfSize = 62208;
73+
constexpr int k_MdfSize = 62208;
74+
constexpr int k_SymOpsCount = 6;
75+
constexpr int k_NumMdfBins = 36;
7676

7777
static double sq32 = std::sqrt(3.0) / 2.0;
7878

@@ -124,9 +124,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
124124
};
125125
/* clang-format on */
126126

127-
static const double k_EtaMin = 0.0;
128-
static const double k_EtaMax = 60.0;
129-
static const double k_ChiMax = 90.0;
127+
constexpr double k_EtaMin = 0.0;
128+
constexpr double k_EtaMax = 60.0;
129+
constexpr double k_ChiMax = 90.0;
130130
} // namespace HexagonalLow
131131

132132
// -----------------------------------------------------------------------------
@@ -1539,7 +1539,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
15391539
{
15401540
radius = 1.0F;
15411541
float angle = angles[idx];
1542-
float rads = angle * M_PI / 180.0f;
1542+
float rads = angle * ebsdlib::constants::k_DegToRadF;
15431543
float x = radius * (cos(rads));
15441544
float y = radius * (sin(rads));
15451545

Source/EbsdLib/LaueOps/HexagonalOps.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,22 @@ using namespace ebsdlib;
5959

6060
namespace HexagonalHigh
6161
{
62-
static const std::array<size_t, 3> OdfNumBins = {36, 36, 12}; // Represents a 5Deg bin
62+
constexpr std::array<size_t, 3> OdfNumBins = {36, 36, 12}; // Represents a 5Deg bin
6363

6464
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * (((ebsdlib::constants::k_PiOver2D)) - std::sin(((ebsdlib::constants::k_PiOver2D))))), (1.0 / 3.0)),
6565
std::pow((0.75 * (((ebsdlib::constants::k_PiOver2D)) - std::sin(((ebsdlib::constants::k_PiOver2D))))), (1.0 / 3.0)),
6666
std::pow((0.75 * ((ebsdlib::constants::k_PiD / 6.0) - std::sin(ebsdlib::constants::k_PiD / 6.0))), (1.0 / 3.0))};
6767
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1] / 2),
6868
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2] / 2)};
6969

70-
static const int symSize0 = 2;
71-
static const int symSize1 = 6;
72-
static const int symSize2 = 6;
70+
constexpr int symSize0 = 2;
71+
constexpr int symSize1 = 6;
72+
constexpr int symSize2 = 6;
7373

74-
static const int k_OdfSize = 15552;
75-
static const int k_MdfSize = 15552;
76-
static const int k_SymOpsCount = 12;
77-
static const int k_NumMdfBins = 20;
74+
constexpr int k_OdfSize = 15552;
75+
constexpr int k_MdfSize = 15552;
76+
constexpr int k_SymOpsCount = 12;
77+
constexpr int k_NumMdfBins = 20;
7878

7979
static double sq32 = std::sqrt(3.0) / 2.0;
8080
// Rotation Point Group: 622
@@ -163,9 +163,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
163163

164164
};
165165
/* clang-format on */
166-
static const double k_EtaMin = 0.0;
167-
static const double k_EtaMax = 30.0;
168-
static const double k_ChiMax = 90.0;
166+
constexpr double k_EtaMin = 0.0;
167+
constexpr double k_EtaMax = 30.0;
168+
constexpr double k_ChiMax = 90.0;
169169
// Use a namespace for some detail that only this class needs
170170
} // namespace HexagonalHigh
171171

@@ -1594,7 +1594,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
15941594
{
15951595
radius = 1.0F;
15961596
float angle = angles[idx];
1597-
float rads = angle * M_PI / 180.0f;
1597+
float rads = angle * ebsdlib::constants::k_DegToRadF;
15981598
float x = radius * (cos(rads));
15991599
float y = radius * (sin(rads));
16001600

Source/EbsdLib/LaueOps/MonoclinicOps.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ using namespace ebsdlib;
5757
namespace Monoclinic
5858
{
5959

60-
static const std::array<size_t, 3> OdfNumBins = {72, 36, 72}; // Represents a 5Deg bin
60+
constexpr std::array<size_t, 3> OdfNumBins = {72, 36, 72}; // Represents a 5Deg bin
6161

6262
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.7f * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)),
6363
std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)),
6464
std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0))};
6565
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0]) / 2.0, OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1]) / 2.0,
6666
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2]) / 2.0};
6767

68-
static const int symSize0 = 2;
69-
static const int symSize1 = 2;
70-
static const int symSize2 = 2;
68+
constexpr int symSize0 = 2;
69+
constexpr int symSize1 = 2;
70+
constexpr int symSize2 = 2;
7171

72-
static const int k_OdfSize = 186624;
73-
static const int k_MdfSize = 186624;
74-
static const int k_SymOpsCount = 2;
75-
static const int k_NumMdfBins = 36;
72+
constexpr int k_OdfSize = 186624;
73+
constexpr int k_MdfSize = 186624;
74+
constexpr int k_SymOpsCount = 2;
75+
constexpr int k_NumMdfBins = 36;
7676
// Rotation Point Group: 2
7777
/* clang-format off */
7878
static const std::vector<QuatD> QuatSym ={
@@ -97,9 +97,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
9797
};
9898
/* clang-format on */
9999

100-
static const double k_EtaMin = 0.0;
101-
static const double k_EtaMax = 180.0;
102-
static const double k_ChiMax = 90.0;
100+
constexpr double k_EtaMin = 0.0;
101+
constexpr double k_EtaMax = 180.0;
102+
constexpr double k_ChiMax = 90.0;
103103
} // namespace Monoclinic
104104

105105
// -----------------------------------------------------------------------------
@@ -901,7 +901,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
901901
{
902902
radius = 1.0F;
903903
float angle = angles[idx];
904-
float rads = angle * M_PI / 180.0f;
904+
float rads = angle * ebsdlib::constants::k_DegToRadF;
905905
float x = radius * (cos(rads));
906906
float y = radius * (sin(rads));
907907

Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ using namespace ebsdlib;
5858

5959
namespace OrthoRhombic
6060
{
61-
static const std::array<size_t, 3> OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin
61+
constexpr std::array<size_t, 3> OdfNumBins = {36, 36, 36}; // Represents a 5Deg bin
6262

6363
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)),
6464
std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0)),
6565
std::pow((0.75 * ((ebsdlib::constants::k_PiOver2D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0))};
6666
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1] / 2),
6767
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2] / 2)};
6868

69-
static const int symSize0 = 2;
70-
static const int symSize1 = 2;
71-
static const int symSize2 = 2;
69+
constexpr int symSize0 = 2;
70+
constexpr int symSize1 = 2;
71+
constexpr int symSize2 = 2;
7272

73-
static const int k_OdfSize = 46656;
74-
static const int k_MdfSize = 46656;
75-
static const int k_SymOpsCount = 4;
76-
static const int k_NumMdfBins = 36;
73+
constexpr int k_OdfSize = 46656;
74+
constexpr int k_MdfSize = 46656;
75+
constexpr int k_SymOpsCount = 4;
76+
constexpr int k_NumMdfBins = 36;
7777
// Rotation Point Group: 222
7878
/* clang-format off */
7979
static const std::vector<QuatD> QuatSym ={
@@ -109,9 +109,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
109109

110110
};
111111
/* clang-format on */
112-
static const double k_EtaMin = 0.0;
113-
static const double k_EtaMax = 90.0;
114-
static const double k_ChiMax = 90.0;
112+
constexpr double k_EtaMin = 0.0;
113+
constexpr double k_EtaMax = 90.0;
114+
constexpr double k_ChiMax = 90.0;
115115
} // namespace OrthoRhombic
116116

117117
// -----------------------------------------------------------------------------
@@ -913,7 +913,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
913913
{
914914
radius = 1.0F;
915915
float angle = angles[idx];
916-
float rads = angle * M_PI / 180.0f;
916+
float rads = angle * ebsdlib::constants::k_DegToRadF;
917917
float x = radius * (cos(rads));
918918
float y = radius * (sin(rads));
919919

Source/EbsdLib/LaueOps/TetragonalLowOps.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,22 @@ using namespace ebsdlib;
5656

5757
namespace TetragonalLow
5858
{
59-
static const std::array<size_t, 3> OdfNumBins = {72, 72, 18}; // Represents a 5Deg bin
59+
constexpr std::array<size_t, 3> OdfNumBins = {72, 72, 18}; // Represents a 5Deg bin
6060

6161
static const std::array<double, 3> OdfDimInitValue = {std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)),
6262
std::pow((0.75 * ((ebsdlib::constants::k_PiD)-std::sin((ebsdlib::constants::k_PiD)))), (1.0 / 3.0)),
6363
std::pow((0.75 * ((ebsdlib::constants::k_PiOver4D)-std::sin((ebsdlib::constants::k_PiOver2D)))), (1.0 / 3.0))};
6464
static const std::array<double, 3> OdfDimStepValue = {OdfDimInitValue[0] / static_cast<double>(OdfNumBins[0] / 2), OdfDimInitValue[1] / static_cast<double>(OdfNumBins[1] / 2),
6565
OdfDimInitValue[2] / static_cast<double>(OdfNumBins[2] / 2)};
6666

67-
static const int symSize0 = 2;
68-
static const int symSize1 = 2;
69-
static const int symSize2 = 2;
67+
constexpr int symSize0 = 2;
68+
constexpr int symSize1 = 2;
69+
constexpr int symSize2 = 2;
7070

71-
static const int k_OdfSize = 93312;
72-
static const int k_MdfSize = 93312;
73-
static const int k_SymOpsCount = 4;
74-
static const int k_NumMdfBins = 36;
71+
constexpr int k_OdfSize = 93312;
72+
constexpr int k_MdfSize = 93312;
73+
constexpr int k_SymOpsCount = 4;
74+
constexpr int k_NumMdfBins = 36;
7575
// Rotation Point Group: 4
7676
/* clang-format off */
7777
static const std::vector<QuatD> QuatSym ={
@@ -108,9 +108,9 @@ static const double MatSym[k_SymOpsCount][3][3] = {
108108
};
109109
/* clang-format on */
110110

111-
static const double k_EtaMin = 0.0;
112-
static const double k_EtaMax = 90.0;
113-
static const double k_ChiMax = 90.0;
111+
constexpr double k_EtaMin = 0.0;
112+
constexpr double k_EtaMax = 90.0;
113+
constexpr double k_ChiMax = 90.0;
114114
} // namespace TetragonalLow
115115

116116
// -----------------------------------------------------------------------------
@@ -912,7 +912,7 @@ void DrawFullCircleAnnotations(canvas_ity::canvas& context, int canvasDim, float
912912
{
913913
radius = 1.0F;
914914
float angle = angles[idx];
915-
float rads = angle * M_PI / 180.0f;
915+
float rads = angle * ebsdlib::constants::k_DegToRadF;
916916
float x = radius * (cos(rads));
917917
float y = radius * (sin(rads));
918918

0 commit comments

Comments
 (0)