Skip to content
Permalink
Browse files

Options to combine Eulers and convert to radians.

Cleans up the Data Structure where both the Eulers and the phi1, PHI, phi2 arrays
were all in the AttributeMatrix.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information...
imikejackson committed Feb 24, 2019
1 parent efd42b8 commit 8e5b9e3042812d4eaa65ae8e8396a4848469fac4
@@ -46,6 +46,8 @@
#include "EbsdLib/BrukerNano/H5EspritReader.h"

#include "SIMPLib/Geometry/ImageGeom.h"
#include "SIMPLib/FilterParameters/BooleanFilterParameter.h"
#include "SIMPLib/Math/SIMPLibMath.h"

#include "OrientationAnalysis/OrientationAnalysisVersion.h"

@@ -77,7 +79,9 @@ ImportH5EspritDataPrivate::ImportH5EspritDataPrivate(ImportH5EspritData* ptr)

// -----------------------------------------------------------------------------
ImportH5EspritData::ImportH5EspritData()
: d_ptr(new ImportH5EspritDataPrivate(this))
: m_CombineEulerAngles(true)
, m_DegreesToRadians(true)
, d_ptr(new ImportH5EspritDataPrivate(this))
{
}

@@ -100,6 +104,17 @@ Esprit_Private_Data ImportH5EspritData::getFileCacheData() const
}
#endif

// -----------------------------------------------------------------------------
void ImportH5EspritData::setupFilterParameters()
{
ImportH5OimData::setupFilterParameters();
FilterParameterVector parameters = getFilterParameters();

parameters.insert(4, SIMPL_NEW_BOOL_FP("Combine phi1, PHI, phi2 into Single Euler Angles Attribute Array", CombineEulerAngles, FilterParameter::Parameter, ImportH5EspritData));
parameters.insert(5, SIMPL_NEW_BOOL_FP("Convert Euler Angles to Radians", DegreesToRadians, FilterParameter::Parameter, ImportH5EspritData));
setFilterParameters(parameters);
}

// -----------------------------------------------------------------------------
void ImportH5EspritData::preflight()
{
@@ -161,6 +176,8 @@ void ImportH5EspritData::execute()
}
}

IDataArrayMap ebsdArrayMap;
setEbsdArrayMap(ebsdArrayMap);

}

@@ -348,15 +365,25 @@ void ImportH5EspritData::dataCheckOEM()
return;
}


cDims.resize(1);
cDims[0] = 3;
tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), Ebsd::Esprit::EulerAngles);
m_CellEulerAnglesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 0, cDims);
if(nullptr != m_CellEulerAnglesPtr.lock())

if(getCombineEulerAngles())
{
m_CellEulerAngles = m_CellEulerAnglesPtr.lock()->getPointer(0);
cellAttrMat->removeAttributeArray(Ebsd::H5Esprit::phi1);
cellAttrMat->removeAttributeArray(Ebsd::H5Esprit::PHI);
cellAttrMat->removeAttributeArray(Ebsd::H5Esprit::phi2);

tempPath.update(getDataContainerName(), getCellAttributeMatrixName(), Ebsd::Esprit::EulerAngles);
m_CellEulerAnglesPtr = getDataContainerArray()->createNonPrereqArrayFromPath<DataArray<float>, AbstractFilter, float>(this, tempPath, 0, cDims);
if(nullptr != m_CellEulerAnglesPtr.lock())
{
m_CellEulerAngles = m_CellEulerAnglesPtr.lock()->getPointer(0);
}
ebsdArrayMap.insert(Ebsd::Esprit::EulerAngles, getDataContainerArray()->getPrereqIDataArrayFromPath<FloatArrayType, AbstractFilter>(this, tempPath));
}
ebsdArrayMap.insert(Ebsd::Esprit::EulerAngles, getDataContainerArray()->getPrereqIDataArrayFromPath<FloatArrayType, AbstractFilter>(this, tempPath));


cDims[0] = 1;
tempPath.update(getDataContainerName(), getCellEnsembleAttributeMatrixName(), Ebsd::Esprit::CrystalStructures);
@@ -590,7 +617,7 @@ template <typename T, class Reader>
void copyPointerData(Reader* reader, const QString& name, const IDataArray::Pointer& dataArray, size_t offset, size_t totalPoints, AttributeMatrix::Pointer& ebsdAttrMat)
{
using DataArrayType = DataArray<T>;
// Copy DD from Reader into DataArray<>
// Copy Array from Reader into DataArray<>
T* ptr = reinterpret_cast<T*>(reader->getPointerByName(name));
typename DataArrayType::Pointer fArray = std::dynamic_pointer_cast<DataArrayType>(dataArray);
typename DataArrayType::Pointer freshArray = DataArrayType::WrapPointer(ptr, totalPoints, fArray->getComponentDimensions(), fArray->getName(), true);
@@ -632,27 +659,50 @@ void ImportH5EspritData::copyRawEbsdData(EbsdReader* ebsdReader, QVector<size_t>
auto ebsdArrayMap = getEbsdArrayMap();

auto reader = dynamic_cast<H5EspritReader*>(ebsdReader);
// Condense the Euler Angles from 3 separate arrays into a single 1x3 array
auto f1 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi1));
auto f2 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::PHI));
auto f3 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi2));
cDims[0] = 3;
fArray = std::dynamic_pointer_cast<FloatArrayType>(ebsdArrayMap.value(SIMPL::CellData::EulerAngles));
float* cellEulerAngles = fArray->getTuplePointer(offset);

for(size_t i = 0; i < totalPoints; i++)

float degToRad = 1.0f;
if(getDegreesToRadians())
{
degToRad = static_cast<float>(SIMPLib::Constants::k_PiOver180);
}

if(getCombineEulerAngles())
{
// Condense the Euler Angles from 3 separate arrays into a single 1x3 array
auto f1 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi1));
auto f2 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::PHI));
auto f3 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi2));
cDims[0] = 3;
fArray = std::dynamic_pointer_cast<FloatArrayType>(ebsdArrayMap.value(SIMPL::CellData::EulerAngles));
float* cellEulerAngles = fArray->getTuplePointer(offset);


for(size_t i = 0; i < totalPoints; i++)
{
cellEulerAngles[3 * i] = f1[i] * degToRad;
cellEulerAngles[3 * i + 1] = f2[i] * degToRad;
cellEulerAngles[3 * i + 2] = f3[i] * degToRad;
}
ebsdAttrMat->addAttributeArray(SIMPL::CellData::EulerAngles, fArray);
}
else
{
cellEulerAngles[3 * i] = f1[i];
cellEulerAngles[3 * i + 1] = f2[i];
cellEulerAngles[3 * i + 2] = f3[i];
// Convert to Radians (if applicable) and then copy the values to the AttributeArrays
auto f1 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi1));
auto f2 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::PHI));
auto f3 = reinterpret_cast<float*>(reader->getPointerByName(Ebsd::H5Esprit::phi2));
for(size_t i = 0; i < totalPoints; i++)
{
f1[3 * i] = f1[i] * degToRad;
f2[3 * i + 1] = f2[i] * degToRad;
f3[3 * i + 2] = f3[i] * degToRad;
}

copyPointerData<Ebsd::H5Esprit::phi1_t, H5EspritReader>(reader, Ebsd::H5Esprit::phi1, ebsdArrayMap.value(Ebsd::H5Esprit::phi1), offset, totalPoints, ebsdAttrMat);
copyPointerData<Ebsd::H5Esprit::PHI_t, H5EspritReader>(reader, Ebsd::H5Esprit::PHI, ebsdArrayMap.value(Ebsd::H5Esprit::PHI), offset, totalPoints, ebsdAttrMat);
copyPointerData<Ebsd::H5Esprit::phi2_t, H5EspritReader>(reader, Ebsd::H5Esprit::phi2, ebsdArrayMap.value(Ebsd::H5Esprit::phi2), offset, totalPoints, ebsdAttrMat);
}
ebsdAttrMat->addAttributeArray(SIMPL::CellData::EulerAngles, fArray);
reader->deallocateArrayData<float>(f1);
reader->deallocateArrayData<float>(f2);
reader->deallocateArrayData<float>(f3);
reader->releasephi1Ownership();
reader->releasePHIOwnership();
reader->releasephi2Ownership();

cDims[0] = 1;

@@ -674,27 +724,5 @@ void ImportH5EspritData::copyRawEbsdData(EbsdReader* ebsdReader, QVector<size_t>
if(getReadPatternData()) // Get the pattern Data from the
{
copyPointerData<Ebsd::H5Esprit::RawPatterns_t, H5EspritReader>(reader, Ebsd::H5Esprit::RawPatterns, ebsdArrayMap.value(Ebsd::H5Esprit::RawPatterns), offset, totalPoints, ebsdAttrMat);
// uint8_t* ptr = reader->getPatternData();
// int32_t pDims[2] = {0, 0};
// reader->getPatternDims(pDims);

// if(pDims[0] != 0 && pDims[1] != 0)
// {
// QVector<size_t> pDimsV(2);
// pDimsV[0] = pDims[0];
// pDimsV[1] = pDims[1];

// UInt8ArrayType::Pointer patternData = std::dynamic_pointer_cast<UInt8ArrayType>(ebsdArrayMap.value(Ebsd::Ang::PatternData));
// ::memcpy(patternData->getPointer(offset), ptr, sizeof(uint8_t) * totalPoints);
// ebsdAttrMat->addAttributeArray(Ebsd::Ang::PatternData, patternData);

// // Remove the current PatternData array
// ebsdAttrMat->removeAttributeArray(Ebsd::Ang::PatternData);

// // Push in our own PatternData array
// ebsdAttrMat->addAttributeArray(patternData->getName(), patternData);
// // Set the readers pattern data pointer to nullptr so that reader does not "free" the memory
// reader->setPatternData(nullptr);
// }
}
}
@@ -63,6 +63,13 @@ class OrientationAnalysis_EXPORT ImportH5EspritData : public ImportH5OimData
SIMPL_PIMPL_PROPERTY_DECL(Esprit_Private_Data, FileCacheData)
Q_PROPERTY(Esprit_Private_Data FileCacheData READ getFileCacheData WRITE setFileCacheData)

SIMPL_FILTER_PARAMETER(bool, CombineEulerAngles)
Q_PROPERTY(bool CombineEulerAngles READ getCombineEulerAngles WRITE setCombineEulerAngles)

SIMPL_FILTER_PARAMETER(bool, DegreesToRadians)
Q_PROPERTY(bool DegreesToRadians READ getDegreesToRadians WRITE setDegreesToRadians)


/**
* @brief getFilterVersion Returns a version string for this filter. Default
* value is an empty string.
@@ -86,6 +93,11 @@ class OrientationAnalysis_EXPORT ImportH5EspritData : public ImportH5OimData
*/
const QString getHumanLabel() const override;

/**
* @brief setupFilterParameters Reimplemented from @see AbstractFilter class
*/
void setupFilterParameters() override;

/**
* @brief execute Reimplemented from @see AbstractFilter class
*/

0 comments on commit 8e5b9e3

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.