Skip to content

Commit

Permalink
Fix crashing bug when creating an EBSDArray based on the LaueClassName
Browse files Browse the repository at this point in the history
Update names of Laue classes with fuller information

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Aug 29, 2024
1 parent b9e7137 commit fe84d21
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 53 deletions.
25 changes: 20 additions & 5 deletions Source/EbsdLib/LaueOps/CubicLowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "EbsdLib/Utilities/ColorTable.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/ModifiedLambertProjection.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

namespace CubicLow
{
Expand Down Expand Up @@ -221,7 +222,7 @@ std::array<size_t, 3> CubicLowOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string CubicLowOps::getSymmetryName() const
{
return "Cubic m-3 (Tetrahedral)"; /* Group 23*/
return "Cubic m-3 (Th)"; /* Group 23*/
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -928,15 +929,14 @@ EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2,
}
if(getHasInversion() && p[2] < 0)
{
p[0] = -p[0], p[1] = -p[1], p[2] = -p[2];
p = p * -1.0;
}
chi = std::acos(p[2]);
eta = std::atan2(p[1], p[0]);
if(!inUnitTriangle(eta, chi))
{
continue;
}

break;
}
double etaMin = 0.0;
Expand All @@ -955,14 +955,28 @@ EbsdLib::Rgb CubicLowOps::generateIPFColor(double phi1, double phi, double phi2,
chiMax = acos(chiMax);

_rgb[0] = 1.0 - chi / chiMax;
_rgb[2] = fabs(etaDeg - etaMin) / (etaMax - etaMin);
_rgb[2] = std::fabs(etaDeg - etaMin) / (etaMax - etaMin);
_rgb[1] = 1 - _rgb[2];
_rgb[1] *= chi / chiMax;
_rgb[2] *= chi / chiMax;
_rgb[0] = sqrt(_rgb[0]);
_rgb[1] = sqrt(_rgb[1]);
_rgb[2] = sqrt(_rgb[2]);

double max = _rgb[0];
if(_rgb[1] > max)
{
max = _rgb[1];
}
if(_rgb[2] > max)
{
max = _rgb[2];
}

_rgb[0] = _rgb[0] / max;
_rgb[1] = _rgb[1] / max;
_rgb[2] = _rgb[2] / max;

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);
}

Expand Down Expand Up @@ -1161,7 +1175,8 @@ EbsdLib::UInt8ArrayType::Pointer CubicLowOps::generateIPFTriangleLegend(int imag
{

std::vector<size_t> dims(1, 4);
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, getSymmetryName() + " Triangle Legend", true);
std::string arrayName = EbsdStringUtils::replace(getSymmetryName(), "/", "_");
EbsdLib::UInt8ArrayType::Pointer image = EbsdLib::UInt8ArrayType::CreateArray(imageDim * imageDim, dims, arrayName + " Triangle Legend", true);
image->initializeWithValue(255);
return image;
}
Expand Down
14 changes: 9 additions & 5 deletions Source/EbsdLib/LaueOps/CubicOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "EbsdLib/Math/GeometryMath.h"
#include "EbsdLib/Utilities/ColorUtilities.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"
#include "EbsdLib/Utilities/ColorTable.h"

namespace CubicHigh
{
Expand Down Expand Up @@ -300,7 +302,7 @@ std::array<size_t, 3> CubicOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string CubicOps::getSymmetryName() const
{
return "Cubic m-3m"; /* Group 432 */
return "Cubic m-3m (Oh)"; /* Group 432 */
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1716,7 +1718,8 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do
}

EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
double chi = 0.0f, eta = 0.0f;
double chi = 0.0f;
double eta = 0.0f;
double _rgb[3] = {0.0, 0.0, 0.0};

OrientationType eu(phi1, phi, phi2);
Expand All @@ -1735,7 +1738,7 @@ EbsdLib::Rgb CubicOps::generateIPFColor(double phi1, double phi, double phi2, do
}
if(getHasInversion() && p[2] < 0)
{
p[0] = -p[0], p[1] = -p[1], p[2] = -p[2];
p = p * -1.0;
}
chi = std::acos(p[2]);
eta = std::atan2(p[1], p[0]);
Expand Down Expand Up @@ -1988,7 +1991,8 @@ EbsdLib::UInt8ArrayType::Pointer CubicOps::generateIPFTriangleLegend(int imageDi
{

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

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

EbsdLib::Rgb color;
size_t idx = 0;
size_t yScanLineIndex = imageDim; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
size_t yScanLineIndex = imageDim; // 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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand Down
10 changes: 6 additions & 4 deletions Source/EbsdLib/LaueOps/HexagonalLowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "EbsdLib/Utilities/ColorTable.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

namespace HexagonalLow
{
Expand Down Expand Up @@ -188,7 +189,7 @@ std::array<size_t, 3> HexagonalLowOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string HexagonalLowOps::getSymmetryName() const
{
return "Hexagonal 6/m";
return "Hexagonal 6/m (C6h)";
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1471,7 +1472,8 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int
{

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

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

EbsdLib::Rgb color;
size_t idx = 0;
size_t yScanLineIndex = imageDim - 1; // We use this to control where the data is drawn. Otherwise the image will come out flipped vertically
size_t yScanLineIndex = imageDim - 1; // 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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand All @@ -1513,7 +1515,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalLowOps::generateIPFTriangleLegend(int
{
color = 0xFFFFFFF;
}
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
{
color = 0xFF000000;
}
Expand Down
13 changes: 8 additions & 5 deletions Source/EbsdLib/LaueOps/HexagonalOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "EbsdLib/Utilities/ColorUtilities.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

#ifdef EbsdLib_USE_PARALLEL_ALGORITHMS
#include <tbb/blocked_range.h>
Expand Down Expand Up @@ -226,7 +227,7 @@ std::array<size_t, 3> HexagonalOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string HexagonalOps::getSymmetryName() const
{
return "Hexagonal 6/mmm";
return "Hexagonal 6/mmm (D6h)";
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1284,7 +1285,8 @@ EbsdLib::Rgb HexagonalOps::generateIPFColor(double phi1, double phi, double phi2
}

EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
double chi = 0.0f, eta = 0.0f;
double chi = 0.0f;
double eta = 0.0f;
double _rgb[3] = {0.0, 0.0, 0.0};

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

double xInc = 1.0f / static_cast<double>(imageDim);
Expand All @@ -1567,7 +1570,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int ima
EbsdLib::Rgb color;
size_t idx = 0;
size_t yScanLineIndex = imageDim - 1; // We use this to control where the data
// is drawn. Otherwise the image will come out flipped vertically
// 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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand All @@ -1585,7 +1588,7 @@ EbsdLib::UInt8ArrayType::Pointer HexagonalOps::generateIPFTriangleLegend(int ima
{
color = 0xFFFFFFFF;
}
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
{
color = 0xFF000000;
}
Expand Down
15 changes: 9 additions & 6 deletions Source/EbsdLib/LaueOps/MonoclinicOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "EbsdLib/Math/EbsdLibMath.h"
#include "EbsdLib/Utilities/ColorTable.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

namespace Monoclinic
{
Expand Down Expand Up @@ -160,7 +161,7 @@ std::array<size_t, 3> MonoclinicOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string MonoclinicOps::getSymmetryName() const
{
return "Monoclinic 2/m";
return "Monoclinic 2/m (C2h)";
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -604,7 +605,8 @@ EbsdLib::Rgb MonoclinicOps::generateIPFColor(double phi1, double phi, double phi
}

EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
double chi = 0.0f, eta = 0.0f;
double chi = 0.0f;
double eta = 0.0f;
double _rgb[3] = {0.0, 0.0, 0.0};

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

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

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

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
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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand All @@ -902,12 +905,12 @@ EbsdLib::UInt8ArrayType::Pointer MonoclinicOps::generateIPFTriangleLegend(int im
{
color = 0xFFFFFFFF;
}
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Border line
else if(sumSquares > (rad - 2 * xInc) && sumSquares < (rad + 2 * xInc)) // Black Borderline
{
color = 0xFF000000;
}

else if(xIndex == 0) // Black Border line
else if(xIndex == 0) // Black Borderline
{
color = 0xFF000000;
}
Expand Down
11 changes: 7 additions & 4 deletions Source/EbsdLib/LaueOps/OrthoRhombicOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "EbsdLib/Utilities/ColorTable.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

namespace OrthoRhombic
{
Expand Down Expand Up @@ -171,7 +172,7 @@ std::array<size_t, 3> OrthoRhombicOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string OrthoRhombicOps::getSymmetryName() const
{
return "OrthoRhombic mmm";
return "Orthorhombic mmm (D2h)";
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -615,7 +616,8 @@ EbsdLib::Rgb OrthoRhombicOps::generateIPFColor(double phi1, double phi, double p
}

EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
double chi = 0.0f, eta = 0.0f;
double chi = 0.0f;
double eta = 0.0f;
double _rgb[3] = {0.0, 0.0, 0.0};

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

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

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

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
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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand Down
11 changes: 7 additions & 4 deletions Source/EbsdLib/LaueOps/TetragonalLowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "EbsdLib/Utilities/ColorTable.h"
#include "EbsdLib/Utilities/ComputeStereographicProjection.h"
#include "EbsdLib/Utilities/PoleFigureUtilities.h"
#include "EbsdLib/Utilities/EbsdStringUtils.hpp"

namespace TetragonalLow
{
Expand Down Expand Up @@ -171,7 +172,7 @@ std::array<size_t, 3> TetragonalLowOps::getOdfNumBins() const
// -----------------------------------------------------------------------------
std::string TetragonalLowOps::getSymmetryName() const
{
return "Tetragonal 4/m";
return "Tetragonal 4/m (C4h)";
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -606,7 +607,8 @@ EbsdLib::Rgb TetragonalLowOps::generateIPFColor(double phi1, double phi, double
}

EbsdLib::Matrix3X1D refDirection = {refDir0, refDir1, refDir2};
double chi = 0.0f, eta = 0.0f;
double chi = 0.0f;
double eta = 0.0f;
double _rgb[3] = {0.0, 0.0, 0.0};

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

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

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

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
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
// there.
for(int32_t yIndex = 0; yIndex < imageDim; ++yIndex)
Expand Down
Loading

0 comments on commit fe84d21

Please sign in to comment.