Skip to content

Commit fe84d21

Browse files
committed
Fix crashing bug when creating an EBSDArray based on the LaueClassName
Update names of Laue classes with fuller information Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent b9e7137 commit fe84d21

11 files changed

+98
-53
lines changed

Source/EbsdLib/LaueOps/CubicLowOps.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "EbsdLib/Utilities/ColorTable.h"
5252
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
5353
#include "EbsdLib/Utilities/ModifiedLambertProjection.h"
54+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
5455

5556
namespace CubicLow
5657
{
@@ -221,7 +222,7 @@ std::array<size_t, 3> CubicLowOps::getOdfNumBins() const
221222
// -----------------------------------------------------------------------------
222223
std::string CubicLowOps::getSymmetryName() const
223224
{
224-
return "Cubic m-3 (Tetrahedral)"; /* Group 23*/
225+
return "Cubic m-3 (Th)"; /* Group 23*/
225226
}
226227

227228
// -----------------------------------------------------------------------------
@@ -928,15 +929,14 @@ EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2,
928929
}
929930
if(getHasInversion() && p[2] < 0)
930931
{
931-
p[0] = -p[0], p[1] = -p[1], p[2] = -p[2];
932+
p = p * -1.0;
932933
}
933934
chi = std::acos(p[2]);
934935
eta = std::atan2(p[1], p[0]);
935936
if(!inUnitTriangle(eta, chi))
936937
{
937938
continue;
938939
}
939-
940940
break;
941941
}
942942
double etaMin = 0.0;
@@ -955,14 +955,28 @@ EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2,
955955
chiMax = acos(chiMax);
956956

957957
_rgb[0] = 1.0 - chi / chiMax;
958-
_rgb[2] = fabs(etaDeg - etaMin) / (etaMax - etaMin);
958+
_rgb[2] = std::fabs(etaDeg - etaMin) / (etaMax - etaMin);
959959
_rgb[1] = 1 - _rgb[2];
960960
_rgb[1] *= chi / chiMax;
961961
_rgb[2] *= chi / chiMax;
962962
_rgb[0] = sqrt(_rgb[0]);
963963
_rgb[1] = sqrt(_rgb[1]);
964964
_rgb[2] = sqrt(_rgb[2]);
965965

966+
double max = _rgb[0];
967+
if(_rgb[1] > max)
968+
{
969+
max = _rgb[1];
970+
}
971+
if(_rgb[2] > max)
972+
{
973+
max = _rgb[2];
974+
}
975+
976+
_rgb[0] = _rgb[0] / max;
977+
_rgb[1] = _rgb[1] / max;
978+
_rgb[2] = _rgb[2] / max;
979+
966980
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);
967981
}
968982

@@ -1161,7 +1175,8 @@ EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int imag
11611175
{
11621176

11631177
std::vector<size_t> dims(1, 4);
1164-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
1178+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
1179+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
11651180
image->initializeWithValue(255);
11661181
return image;
11671182
}

Source/EbsdLib/LaueOps/CubicOps.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
#include "EbsdLib/Math/GeometryMath.h"
5252
#include "EbsdLib/Utilities/ColorUtilities.h"
5353
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
54+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
55+
#include "EbsdLib/Utilities/ColorTable.h"
5456

5557
namespace CubicHigh
5658
{
@@ -300,7 +302,7 @@ std::array<size_t, 3> CubicOps::getOdfNumBins() const
300302
// -----------------------------------------------------------------------------
301303
std::string CubicOps::getSymmetryName() const
302304
{
303-
return "Cubic m-3m"; /* Group 432 */
305+
return "Cubic m-3m (Oh)"; /* Group 432 */
304306
}
305307

306308
// -----------------------------------------------------------------------------
@@ -1716,7 +1718,8 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do
17161718
}
17171719

17181720
EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
1719-
double chi = 0.0f, eta = 0.0f;
1721+
double chi = 0.0f;
1722+
double eta = 0.0f;
17201723
double _rgb[3] = {0.0, 0.0, 0.0};
17211724

17221725
OrientationType eu(phi1, phi, phi2);
@@ -1735,7 +1738,7 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do
17351738
}
17361739
if(getHasInversion() && p[2] < 0)
17371740
{
1738-
p[0] = -p[0], p[1] = -p[1], p[2] = -p[2];
1741+
p = p * -1.0;
17391742
}
17401743
chi = std::acos(p[2]);
17411744
eta = std::atan2(p[1], p[0]);
@@ -1988,7 +1991,8 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int imageDi
19881991
{
19891992

19901993
std::vector<size_t> dims(1, 4);
1991-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
1994+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
1995+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
19921996
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
19931997

19941998
double indexConst1 = 0.414f / static_cast<double>(imageDim);
@@ -2014,7 +2018,7 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int imageDi
20142018

20152019
EbsdLib::Rgb color;
20162020
size_t idx = 0;
2017-
size_t yScanLineIndex = imageDim; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
2021+
size_t yScanLineIndex = imageDim; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically
20182022
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
20192023
// there.
20202024
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)

Source/EbsdLib/LaueOps/HexagonalLowOps.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "EbsdLib/Utilities/ColorTable.h"
5252
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
5353
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
54+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
5455

5556
namespace HexagonalLow
5657
{
@@ -188,7 +189,7 @@ std::array<size_t, 3> HexagonalLowOps::getOdfNumBins() const
188189
// -----------------------------------------------------------------------------
189190
std::string HexagonalLowOps::getSymmetryName() const
190191
{
191-
return "Hexagonal 6/m";
192+
return "Hexagonal 6/m (C6h)";
192193
}
193194

194195
// -----------------------------------------------------------------------------
@@ -1471,7 +1472,8 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int
14711472
{
14721473

14731474
std::vector<size_t> dims(1, 4);
1474-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
1475+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
1476+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
14751477
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
14761478

14771479
double xInc = 1.0 / static_cast<double>(imageDim);
@@ -1495,7 +1497,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int
14951497

14961498
EbsdLib::Rgb color;
14971499
size_t idx = 0;
1498-
size_t yScanLineIndex = imageDim - 1; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
1500+
size_t yScanLineIndex = imageDim - 1; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically
14991501
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
15001502
// there.
15011503
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
@@ -1513,7 +1515,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int
15131515
{
15141516
color = 0xFFFFFFF;
15151517
}
1516-
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
1518+
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
15171519
{
15181520
color = 0xFF000000;
15191521
}

Source/EbsdLib/LaueOps/HexagonalOps.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "EbsdLib/Utilities/ColorUtilities.h"
4646
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
4747
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
48+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
4849

4950
#ifdef EbsdLib_USE_PARALLEL_ALGORITHMS
5051
#include <tbb/blocked_range.h>
@@ -226,7 +227,7 @@ std::array<size_t, 3> HexagonalOps::getOdfNumBins() const
226227
// -----------------------------------------------------------------------------
227228
std::string HexagonalOps::getSymmetryName() const
228229
{
229-
return "Hexagonal 6/mmm";
230+
return "Hexagonal 6/mmm (D6h)";
230231
}
231232

232233
// -----------------------------------------------------------------------------
@@ -1284,7 +1285,8 @@ EbsdLib::Rgb HexagonalOps::generateIPFColor(double phi1, double phi, double phi2
12841285
}
12851286

12861287
EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
1287-
double chi = 0.0f, eta = 0.0f;
1288+
double chi = 0.0f;
1289+
double eta = 0.0f;
12881290
double _rgb[3] = {0.0, 0.0, 0.0};
12891291

12901292
OrientationType eu(phi1, phi, phi2);
@@ -1542,7 +1544,8 @@ std::vector<EbsdLib::UInt8ArrayType::Pointer> HexagonalOps::generatePoleFigure(P
15421544
EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int imageDim) const
15431545
{
15441546
std::vector<size_t> dims(1, 4);
1545-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
1547+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
1548+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
15461549
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
15471550

15481551
double xInc = 1.0f / static_cast<double>(imageDim);
@@ -1567,7 +1570,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int ima
15671570
EbsdLib::Rgb color;
15681571
size_t idx = 0;
15691572
size_t yScanLineIndex = imageDim - 1; // We use this to control where the data
1570-
// is drawn. Otherwise the image will come out flipped vertically
1573+
// is drawn. Otherwise, the image will come out flipped vertically
15711574
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
15721575
// there.
15731576
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
@@ -1585,7 +1588,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int ima
15851588
{
15861589
color = 0xFFFFFFFF;
15871590
}
1588-
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
1591+
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
15891592
{
15901593
color = 0xFF000000;
15911594
}

Source/EbsdLib/LaueOps/MonoclinicOps.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "EbsdLib/Math/EbsdLibMath.h"
5151
#include "EbsdLib/Utilities/ColorTable.h"
5252
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
53+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
5354

5455
namespace Monoclinic
5556
{
@@ -160,7 +161,7 @@ std::array<size_t, 3> MonoclinicOps::getOdfNumBins() const
160161
// -----------------------------------------------------------------------------
161162
std::string MonoclinicOps::getSymmetryName() const
162163
{
163-
return "Monoclinic 2/m";
164+
return "Monoclinic 2/m (C2h)";
164165
}
165166

166167
// -----------------------------------------------------------------------------
@@ -604,7 +605,8 @@ EbsdLib::Rgb MonoclinicOps::generateIPFColor(double phi1, double phi, double phi
604605
}
605606

606607
EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
607-
double chi = 0.0f, eta = 0.0f;
608+
double chi = 0.0f;
609+
double eta = 0.0f;
608610
double _rgb[3] = {0.0, 0.0, 0.0};
609611

610612
OrientationType eu(phi1, phi, phi2);
@@ -863,7 +865,8 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int im
863865
{
864866

865867
std::vector<size_t> dims(1, 4);
866-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
868+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
869+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
867870
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
868871

869872
double xInc = 1.0f / static_cast<double>(imageDim);
@@ -884,7 +887,7 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int im
884887

885888
EbsdLib::Rgb color;
886889
size_t idx = 0;
887-
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
890+
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically
888891
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
889892
// there.
890893
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
@@ -902,12 +905,12 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int im
902905
{
903906
color = 0xFFFFFFFF;
904907
}
905-
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
908+
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
906909
{
907910
color = 0xFF000000;
908911
}
909912

910-
else if(xIndex == 0) // Black Border line
913+
else if(xIndex == 0) // Black Borderline
911914
{
912915
color = 0xFF000000;
913916
}

Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "EbsdLib/Utilities/ColorTable.h"
5151
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
5252
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
53+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
5354

5455
namespace OrthoRhombic
5556
{
@@ -171,7 +172,7 @@ std::array<size_t, 3> OrthoRhombicOps::getOdfNumBins() const
171172
// -----------------------------------------------------------------------------
172173
std::string OrthoRhombicOps::getSymmetryName() const
173174
{
174-
return "OrthoRhombic mmm";
175+
return "Orthorhombic mmm (D2h)";
175176
}
176177

177178
// -----------------------------------------------------------------------------
@@ -615,7 +616,8 @@ EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double phi1, double phi, double p
615616
}
616617

617618
EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
618-
double chi = 0.0f, eta = 0.0f;
619+
double chi = 0.0f;
620+
double eta = 0.0f;
619621
double _rgb[3] = {0.0, 0.0, 0.0};
620622

621623
OrientationType eu(phi1, phi, phi2);
@@ -871,7 +873,8 @@ EbsdLib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int
871873
{
872874

873875
std::vector<size_t> dims(1, 4);
874-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
876+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
877+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
875878
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
876879

877880
double xInc = 1.0f / static_cast<double>(imageDim);
@@ -892,7 +895,7 @@ EbsdLib::UInt8ArrayType::Pointer OrthoRhombicOps::generateIPFTriangleLegend(int
892895

893896
EbsdLib::Rgb color;
894897
size_t idx = 0;
895-
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
898+
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically
896899
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
897900
// there.
898901
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)

Source/EbsdLib/LaueOps/TetragonalLowOps.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "EbsdLib/Utilities/ColorTable.h"
5151
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
5252
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
53+
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
5354

5455
namespace TetragonalLow
5556
{
@@ -171,7 +172,7 @@ std::array<size_t, 3> TetragonalLowOps::getOdfNumBins() const
171172
// -----------------------------------------------------------------------------
172173
std::string TetragonalLowOps::getSymmetryName() const
173174
{
174-
return "Tetragonal 4/m";
175+
return "Tetragonal 4/m (C4h)";
175176
}
176177

177178
// -----------------------------------------------------------------------------
@@ -606,7 +607,8 @@ EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double phi1, double phi, double
606607
}
607608

608609
EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
609-
double chi = 0.0f, eta = 0.0f;
610+
double chi = 0.0f;
611+
double eta = 0.0f;
610612
double _rgb[3] = {0.0, 0.0, 0.0};
611613

612614
OrientationType eu(phi1, phi, phi2);
@@ -865,7 +867,8 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int
865867
{
866868

867869
std::vector<size_t> dims(1, 4);
868-
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
870+
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
871+
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
869872
uint32_t* pixelPtr = reinterpret_cast<uint32_t*>(image->getPointer(0));
870873

871874
double xInc = 1.0f / static_cast<double>(imageDim);
@@ -886,7 +889,7 @@ EbsdLib::UInt8ArrayType::Pointer TetragonalLowOps::generateIPFTriangleLegend(int
886889

887890
EbsdLib::Rgb color;
888891
size_t idx = 0;
889-
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
892+
size_t yScanLineIndex = 0; // We use this to control where the data is drawn. Otherwise, the image will come out flipped vertically
890893
// Loop over every pixel in the image and project up to the sphere to get the angle and then figure out the RGB from
891894
// there.
892895
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)

0 commit comments

Comments
 (0)