Skip to content

Commit

Permalink
ENH: Improvements and Bug Fixes to Orientation Analysis filters. (#1081)
Browse files Browse the repository at this point in the history
* MergeTwins: Only get the LaueOps list once when the MergeTwins class is instantiated.
* ENH: Various updates to Compute Feature Face Curvature filters
    * Create parameter defaults for Feature Face Curvature filter
    *  Docs and new pipeline included.
* Update CMake Policies
* CMAKE: Check for proper version of CMake before setting policy
* BUG: Fix human name of ComputeFZQuaternions
* STYLE: Remove bad comment from WritePoleFigure
* Update TiffWriter to properly order the tiff tags in ascending order.
* Fix pole figure generation. Add improved IPF Legends
* COMP: Update to EbsdLib 1.0.33
* PY: Update conda build specs for newer EbsdLib 1.0.33
* DOC: Fix sphinx warnings

Signed-off-by: Michael Jackson <[email protected]>

---------

Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson authored Sep 27, 2024
1 parent e6148a2 commit 8037025
Show file tree
Hide file tree
Showing 46 changed files with 676 additions and 83 deletions.
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
cmake_minimum_required(VERSION 3.26)

cmake_policy(SET CMP0074 NEW) # ``find_package()`` uses ``<PackageName>_ROOT`` variables.
cmake_policy(SET CMP0077 NEW) # ``option()`` honors normal variables.
cmake_policy(SET CMP0080 NEW) # ``BundleUtilities`` cannot be included at configure time.

# The ``FindPythonInterp`` and ``FindPythonLibs`` modules are removed.
# if(CMAKE_VERSION VERSION_GREATER "3.27.0")
# cmake_policy(SET CMP0148 NEW)
# endif()

# resolves symlinks before collapsing ../ components.
if(CMAKE_VERSION VERSION_GREATER "3.28.0")
cmake_policy(SET CMP0152 NEW)
endif()


include(${CMAKE_CURRENT_LIST_DIR}/cmake/Utility.cmake)

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -123,9 +138,7 @@ file(WRITE ${FETCH_FILE_PATH} "# -----------------------------------------------
# The WORKING_DIRECTORY is set to the following CMake code:
# ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>
# -----------------------------------------------------------------------\n
cmake_policy(SET CMP0012 NEW)
cmake_policy(SET CMP0054 NEW)\n
")
cmake_policy(SET CMP0012 NEW)\ncmake_policy(SET CMP0054 NEW)\ncmake_policy(SET CMP0152 NEW)\ncmake_policy(SET CMP0148 NEW)")

set(TEST_WORKING_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
if(CMAKE_GENERATOR MATCHES "Visual Studio")
Expand Down
1 change: 1 addition & 0 deletions cmake/Summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ message(STATUS "* span-lite (${span-lite_VERSION}) ${span-lite_DIR}")
message(STATUS "* boost_mp11 (${boost_mp11_VERSION}) ${boost_mp11_DIR}")
message(STATUS "* nod (${nod_VERSION}) ${nod_DIR}")
message(STATUS "* reproc++ (${reproc_VERSION}) ${reproc++_DIR}")
message(STATUS "* EbsdLib (${EbsdLib_VERSION}) ${EbsdLib_DIR}")

message(STATUS "* -------------- Simplnx Configuration Options -------------------------------------")
message(STATUS "* SIMPLNX_BUILD_TESTS: ${SIMPLNX_BUILD_TESTS}")
Expand Down
26 changes: 26 additions & 0 deletions cmake/UseEbsdLib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ------------------------------------------------------------------------------
# Required EbsdLib and H5Support
# ------------------------------------------------------------------------------

if(SIMPLNX_BUILD_EBSDLIB)
find_package(H5Support REQUIRED)
find_package(EbsdLib REQUIRED)
else()

if(NOT TARGET EbsdLib::EbsdLib)

if(EXISTS "${simplnx_SOURCE_DIR}/../EbsdLib")
set(EbsdLibProj_SOURCE_DIR "${simplnx_SOURCE_DIR}/../EbsdLib")
else()
message(FATAL_ERROR "EbsdLibProj_SOURCE_DIR was not set. Where is the EbsdLib project directory. Please set the EbsdLibProj_SOURCE_DIR variable to the EbsdLib directory.")
endif()
message(STATUS "EbsdLibProj_SOURCE_DIR: ${EbsdLibProj_SOURCE_DIR}")

set(EbsdLib_ENABLE_HDF5 ON)
set(EbsdLib_USE_PARALLEL_ALGORITHMS ${SIMPLNX_ENABLE_MULTICORE})
set(EbsdLib_BUILD_H5SUPPORT ON)
set(H5Support_INCLUDE_QT_API OFF)
add_subdirectory( ${EbsdLibProj_SOURCE_DIR} ${PROJECT_BINARY_DIR}/EbsdLib)
endif()
endif()

9 changes: 3 additions & 6 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "simplnx" %}
{% set version = "24.08.10" %}
{% set version = "24.09.30" %}

package:
name: {{ name|lower }}
Expand All @@ -9,7 +9,7 @@ source:
- path: ../
folder: simplnx
- git_url: https://github.com/BlueQuartzSoftware/EbsdLib
git_rev: v1.0.30
git_rev: v1.0.33
folder: EbsdLib
- git_url: https://github.com/BlueQuartzSoftware/H5Support
git_rev: v1.0.13
Expand All @@ -25,9 +25,6 @@ source:
folder: span-lite
- url: https://raw.githubusercontent.com/BlueQuartzSoftware/simplnx-registry/9a5db7b5fa02b2495eb51654cbaab3c63820c779/ports/nod/CMakeLists.txt
folder: nod
- git_url: https://github.com/insightsoftwareconsortium/ITK
git_rev: v5.4.0
folder: itk

build:
number: 0
Expand Down Expand Up @@ -78,4 +75,4 @@ test:
about:
home: https://www.dream3d.io/
license: BSD
summary: DREAM3D-NX consists of data analysis tools (Filters) that allow for the construction of customized workflows (Pipelines) to analyze data.
summary: simplnx consists of data analysis tools (Filters) that allow for the construction of customized workflows (Pipelines) to analyze data.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "EbsdLib/Core/EbsdLibConstants.h"
#include "EbsdLib/Core/Orientation.hpp"
#include "EbsdLib/Core/Quaternion.hpp"
#include "EbsdLib/LaueOps/LaueOps.h"

#include <random>

Expand All @@ -21,6 +20,7 @@ MergeTwins::MergeTwins(DataStructure& dataStructure, const IFilter::MessageHandl
, m_ShouldCancel(shouldCancel)
, m_MessageHandler(mesgHandler)
{
m_OrientationOps = LaueOps::GetAllOrientationOps();
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -76,7 +76,6 @@ bool MergeTwins::determineGrouping(int32 referenceFeature, int32 neighborFeature
auto axisToleranceRad = m_InputValues->AxisTolerance * numbers::pi_v<float32> / 180.0f;

bool twin = false;
std::vector<LaueOps::Pointer> m_OrientationOps = LaueOps::GetAllOrientationOps();

if(featureParentIds[neighborFeature] == -1 && phases[referenceFeature] > 0 && phases[neighborFeature] > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "OrientationAnalysis/OrientationAnalysis_export.hpp"

#include "EbsdLib/LaueOps/LaueOps.h"
#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/Filter/IFilter.hpp"
Expand Down Expand Up @@ -50,6 +51,8 @@ class ORIENTATIONANALYSIS_EXPORT MergeTwins
const MergeTwinsInputValues* m_InputValues = nullptr;
const std::atomic_bool& m_ShouldCancel;
const IFilter::MessageHandler& m_MessageHandler;

std::vector<LaueOps::Pointer> m_OrientationOps;
};

} // namespace nx::core
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ComputeIntensityStereographicProjection
float* xyzPtr = m_XYZCoords->getPointer(0);
for(size_t i = 0; i < numCoords; i++)
{
if(xyzPtr[i * 3 + 2] < 0.0f)
if(xyzPtr[i * 3 + 2] < 0.0f) // If the unit sphere data is in the southern hemisphere
{
xyzPtr[i * 3 + 0] *= -1.0f;
xyzPtr[i * 3 + 1] *= -1.0f;
Expand Down Expand Up @@ -474,8 +474,6 @@ typename EbsdDataArray<T>::Pointer flipAndMirrorPoleFigure(EbsdDataArray<T>* src
{
typename EbsdDataArray<T>::Pointer converted = EbsdDataArray<T>::CreateArray(config.imageDim * config.imageDim, src->getComponentDimensions(), src->getName(), true);
// We need to flip the image "vertically", which means the bottom row becomes
// the top row and convert from BGRA to RGBA ordering (This is a Little Endian code)
// If this is ever compiled on a BIG ENDIAN machine the colors will be off.
for(int y = 0; y < config.imageDim; y++)
{
const int destY = config.imageDim - 1 - y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Uuid ComputeFZQuaternionsFilter::uuid() const
//------------------------------------------------------------------------------
std::string ComputeFZQuaternionsFilter::humanName() const
{
return "Compute Reduction Orientations to Fundamental Zone";
return "Compute Fundamental Zone Orientations";
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -279,7 +279,7 @@ Result<> ComputeFZQuaternionsFilter::executeImpl(DataStructure& dataStructure, c
algArrays.push_back(maskArray);
}

// Parallel algorithm to find duplicate nodes
// Parallel algorithm
ParallelDataAlgorithm dataAlg;
dataAlg.setRange(0ULL, static_cast<size_t>(quatArray.getNumberOfTuples()));
dataAlg.requireArraysInMemory(algArrays);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ Parameters WritePoleFigureFilter::parameters() const
params.insert(std::make_unique<Int32Parameter>(k_LambertSize_Key, "Lambert Image Size (Pixels)", "The height/width of the internal Lambert Square that is used for interpolation", 64));
params.insert(std::make_unique<Int32Parameter>(k_NumColors_Key, "Number of Colors", "The number of colors to use for the Color Intensity pole figures", 32));

params.insertSeparator(Parameters::Separator{"Input Cell Data"});
params.insert(std::make_unique<ArraySelectionParameter>(k_CellEulerAnglesArrayPath_Key, "Cell Euler Angles", "Three angles defining the orientation of the Element in Bunge convention (Z-X-Z)",
params.insertSeparator(Parameters::Separator{"Input Orientation Data"});
params.insert(std::make_unique<ArraySelectionParameter>(k_CellEulerAnglesArrayPath_Key, "Euler Angles", "Three angles defining the orientation of the Element in Bunge convention (Z-X-Z)",
DataPath{}, ArraySelectionParameter::AllowedTypes{DataType::float32}, ArraySelectionParameter::AllowedComponentShapes{{3}}));
params.insert(std::make_unique<ArraySelectionParameter>(k_CellPhasesArrayPath_Key, "Cell Phases", "Specifies to which Ensemble each cell belongs", DataPath{},
params.insert(std::make_unique<ArraySelectionParameter>(k_CellPhasesArrayPath_Key, "Phases", "Specifies to which Ensemble each Euler angle belongs", DataPath{},
ArraySelectionParameter::AllowedTypes{DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{1}}));
params.insertSeparator(Parameters::Separator{"Optional Data Mask"});
params.insertLinkableParameter(std::make_unique<BoolParameter>(k_UseMask_Key, "Use Mask Array", "Should the algorithm use a mask array to remove non-indexed points", false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,29 @@ std::pair<int32_t, std::string> TiffWriter::WriteImage(const std::string& filepa
// Generate the offset into the Image File Directory (ifd) which we are going to write first
constexpr uint32_t ifdOffset = 8;
outputFile.write(reinterpret_cast<const char*>(&ifdOffset), sizeof(ifdOffset));

const int k_NumTags = 12;
std::vector<TIFTAG> tags;
tags.push_back(TIFTAG{0x00FE, 0x0004, 1, 0x00000000}); // NewSubfileType
tags.push_back(TIFTAG{0x0100, 0x0004, 1, width}); // ImageWidth
tags.push_back(TIFTAG{0x0101, 0x0004, 1, height}); // ImageLength
tags.push_back(TIFTAG{0x0102, 0x0003, 1, 8 * sizeof(char)}); // BitsPerSample
tags.push_back(TIFTAG{0x0103, 0x0003, 1, 0x0001}); // Compression
tags.push_back(TIFTAG{0x0106, 0x0003, 1, photometricInterpretation}); // PhotometricInterpretation // For SamplesPerPixel = 3 or 4 (RGB or RGBA)
tags.push_back(TIFTAG{0x00FE, 0x0004, 1, 0x00000000}); // NewSubfileType
tags.push_back(TIFTAG{0x0100, 0x0004, 1, width}); // ImageWidth
tags.push_back(TIFTAG{0x0101, 0x0004, 1, height}); // ImageLength
tags.push_back(TIFTAG{0x0102, 0x0003, 1, 8 * sizeof(char)}); // BitsPerSample
tags.push_back(TIFTAG{0x0103, 0x0003, 1, 0x0001}); // Compression
tags.push_back(TIFTAG{0x0106, 0x0003, 1, photometricInterpretation}); // PhotometricInterpretation // For SamplesPerPixel = 3 or 4 (RGB or RGBA)
// Now compute the offset to the image data so that we can put that into the tag.
// The math on this ONLY Works if we have 11 total Tags.
// IF YOU ADD MORE TAGS, YOU NEED TO ADJUST THE NEXT LINE OF CODE
int32_t imageDataOffset = static_cast<int32_t>(8 + (k_NumTags * 12) + 6); // Header + tags + IDF Tag entry count and Next IFD Offset
tags.push_back(TIFTAG{0x0111, 0x0004, 1, imageDataOffset}); // StripOffsets

tags.push_back(TIFTAG{0x0112, 0x0003, 1, 1}); // Orientation
tags.push_back(TIFTAG{0x0115, 0x0003, 1, samplesPerPixel}); // SamplesPerPixel
tags.push_back(TIFTAG{0x0116, 0x0004, 1, height}); // RowsPerStrip
tags.push_back(TIFTAG{0x0117, 0x0004, 1, width * height * samplesPerPixel}); // StripByteCounts

// TIFTAG XResolution;
// TIFTAG YResolution;
// TIFTAG ResolutionUnit;
tags.push_back(TIFTAG{0x011c, 0x0003, 1, 0x0001}); // PlanarConfiguration

// Now compute the offset to the image data so that we can put that into the tag.
// THESE NEXT 2 LINES MUST BE THE LAST TAG TO BE PUSHED BACK INTO THE VECTOR OR THE MATH WILL BE WRONG
const int32_t imageDataOffset = static_cast<int32_t>(8 + ((tags.size() + 1) * 12) + 6); // Header + tags + IDF Tag entry count and Next IFD Offset
tags.push_back(TIFTAG{0x0111, 0x0004, 1, imageDataOffset}); // StripOffsets
tags.push_back(TIFTAG{0x011c, 0x0003, 1, 0x0001}); // PlanarConfiguration // 284

// Write the number of tags to the IFD section
uint16_t numEntries = static_cast<uint16_t>(tags.size());
Expand Down
12 changes: 6 additions & 6 deletions src/Plugins/SimplnxCore/docs/AppendImageGeometryFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ This filter also has an option to mirror the resulting geometry in the chosen di

### X Direction Examples

#### Example 1
#### Example 1 (X)
If the user has an already existing **Image Geometry** that is 100 voxels in the *Y* direction by 300 pixels in the
*Z* direction and composed of 10 *X* slices, then if the user appends another three data sets in the X direction that are the same dimensions in Y & Z but contain 20 *X* slices each, the resulting **Image Geometry** will have a total of 70 *X* slices.

#### Example 2 (Visual Example)
#### Example 2 (Visual Example) (X)
Here's the SmallIN100 dataset example sliced into three pieces in the X direction:

![](Images/AppendImageGeometry/x_direction_pieces.png)
Expand All @@ -28,11 +28,11 @@ And here is what the geometry looks like after appending the three pieces togeth

### Y Direction Examples

#### Example 1
#### Example 1 (Y)
If the user has an already existing **Image Geometry** that is 400 voxels in the *X* direction by 200 pixels in the
*Z* direction and composed of 50 *Y* slices, then if the user appends another two data sets in the Y direction that are the same dimensions in X & Z but contain 40 *Y* slices each, the resulting **Image Geometry** will have a total of 130 *Y* slices.

#### Example 2 (Visual Example)
#### Example 2 (Visual Example) (Y)
Here's the SmallIN100 dataset example sliced into three pieces in the Y direction:

![](Images/AppendImageGeometry/y_direction_pieces.png)
Expand All @@ -43,11 +43,11 @@ And here is what the geometry looks like after appending the three pieces togeth

### Z Direction Examples

#### Example 1
#### Example 1 (Z)
If the user has an already existing **Image Geometry** that is 100 voxels in the *X* direction by 200 pixels in the
*Y* direction and composed of 5 *Z* slices, then if the user appends one other data set in the Z direction that is the same dimensions in X & Y but contains 10 *Z* slices, the resulting **Image Geometry** will have a total of 15 *Z* slices.

#### Example 2 (Visual Example)
#### Example 2 (Visual Example) (Z)
Here's the SmallIN100 dataset example sliced into three pieces in the Z direction:

![](Images/AppendImageGeometry/z_direction_pieces.png)
Expand Down
6 changes: 3 additions & 3 deletions src/Plugins/SimplnxCore/docs/ComputeSurfaceFeaturesFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ This **Filter** determines whether a **Feature** touches an outer *Surface* of t

The output of this filter is a **Feature** level array of booleans where 0=Interior/Not touching and 1=Surface/Touching.

### WARNING
### WARNING - Feature ID=0 Voxels

If there are voxels within the volume that have **Feature ID=0** then any feature touching those voxels will be considered a *Surface* feature.

### WARNING
### WARNING - Fixed bugs

The version of this filter in legacy DREAM.3D had two bugs: one that indexed into neighboring features incorrectly (DREAM3D repo issue #988), and another that incorrectly labeled feature 0 as a surface feature when feature 0 exists in the feature ids array (DREAM3D repo issue #989). Both of these bugs have been fixed in this new version.
The version of this filter in legacy DREAM.3D (version 6.x) had two bugs: one that indexed into neighboring features incorrectly [DREAM.3D repo issue #988](https://github.com/BlueQuartzSoftware/DREAM3D/issues/988), and another that incorrectly labeled feature 0 as a surface feature when feature 0 exists in the feature ids array [DREAM.3D repo issue #989](https://github.com/BlueQuartzSoftware/DREAM3D/issues/989). Both of these bugs have been fixed in this new version.

### 2D Image Geometry

Expand Down
16 changes: 15 additions & 1 deletion src/Plugins/SimplnxCore/docs/FeatureFaceCurvatureFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@ The values of the principal directions can have their signs flipped. They are ca

*Note*: Computing the Weingarten matrix values is an experimental feature, and there is no guarantee at this time that the values are correct.

![Curvature Coloring of a Feature](Images/FeatureFaceCurvatureFilter.png)
![Curvature Coloring](Images/FeatureFaceCurvatureFilter_3.png)
@image latex FeatureFaceCurvatureFilter.png "Curvature Coloring of a Feature" width = 6in

## Ring Neighbor Schematic

![Ring Neighbor Schematic](Images/FeatureFaceCurvatureFilter_1.png)

## Parameter Notes:

- The "Feature Face Ids" input data can be computed from the "Compute Triangle Face Ids" filter
- The "Face Normals" input data can be computed from the "Compute Triangle Normals" filter
- The "Face Centroids" input data can be computed from the "Compute Triangle Centroids" filter


% Auto generated parameter table will be inserted here

## References
Expand All @@ -26,6 +37,9 @@ The values of the principal directions can have their signs flipped. They are ca

## Example Pipelines

- Pipelines -> SimplnxCore -> Compute_Feature_Face_Curvature
- Pipelines -> SimplnxCore -> Compute_Feature_Face_Curvature_2

## License & Copyright

Please see the description file distributed with this**Plugin**
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8037025

Please sign in to comment.