Skip to content

Commit

Permalink
Renamed ComputeColorTable to CreateColorMap
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Duffey <jared.duffey@bluequartz.net>
  • Loading branch information
imikejackson committed May 20, 2024
1 parent 77d62f7 commit 683e6dd
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 192 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ set(CoreParameters
DynamicTableParameter
EnsembleInfoParameter
FileSystemPathParameter
ComputeColorTableParameter
CreateColorMapParameter
GeneratedFileListParameter
GeometrySelectionParameter
DataStoreFormatParameter
Expand Down
4 changes: 2 additions & 2 deletions scripts/simpl_filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -12299,11 +12299,11 @@
"uuid": "{8ec1fc8e-6484-5412-a898-8079986c0a26}"
},
{
"name": "ComputeColorTable",
"name": "CreateColorMap",
"parameters": [
{
"name": "SelectedPresetName",
"type": "ComputeColorTableFilterParameter"
"type": "CreateColorMapFilterParameter"
},
{
"name": "SelectedDataArrayPath",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
},
"comments": "",
"filter": {
"name": "nx::core::ComputeColorTableFilter",
"name": "nx::core::CreateColorMapFilter",
"uuid": "d1731177-4d70-41c0-9334-566a0b482796"
},
"isDisabled": false
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/SimplnxCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ set(FilterList
ComputeBoundaryElementFractionsFilter
ComputeTriangleGeomSizesFilter
FlyingEdges3DFilter
ComputeColorTableFilter
CreateColorMapFilter
IdentifySampleFilter
InitializeDataFilter
InitializeImageGeomCellDataFilter
Expand Down Expand Up @@ -178,7 +178,7 @@ set(AlgorithmList
FindNRingNeighbors
ComputeTriangleGeomSizes
FlyingEdges3D
ComputeColorTable
CreateColorMap
LabelTriangleGeometry
LaplacianSmoothing
NearestPointFuseRegularGrids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compute Color Table
# Create Color Map

## Description

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ComputeColorTable.hpp"
#include "CreateColorMap.hpp"

#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataGroup.hpp"
Expand Down Expand Up @@ -33,15 +33,15 @@ usize findRightBinIndex(float32 nValue, const std::vector<float32>& binPoints)
}

/**
* @brief The ComputeColorTableImpl class implements a threaded algorithm that computes the RGB values
* @brief The CreateColorMapImpl class implements a threaded algorithm that computes the RGB values
* for each element in a given array of data
*/
template <typename T>
class ComputeColorTableImpl
class CreateColorMapImpl
{
public:
ComputeColorTableImpl(const DataArray<T>& arrayPtr, const std::vector<float32>& binPoints, const std::vector<float32>& controlPoints, int numControlColors, UInt8Array& colorArray,
const nx::core::IDataArray* goodVoxels, const std::vector<uint8>& invalidColor)
CreateColorMapImpl(const DataArray<T>& arrayPtr, const std::vector<float32>& binPoints, const std::vector<float32>& controlPoints, int numControlColors, UInt8Array& colorArray,
const nx::core::IDataArray* goodVoxels, const std::vector<uint8>& invalidColor)
: m_ArrayPtr(arrayPtr)
, m_BinPoints(binPoints)
, m_NumControlColors(numControlColors)
Expand All @@ -64,12 +64,12 @@ class ComputeColorTableImpl
}
}
}
virtual ~ComputeColorTableImpl() = default;
virtual ~CreateColorMapImpl() = default;

ComputeColorTableImpl(const ComputeColorTableImpl&) = default;
ComputeColorTableImpl(ComputeColorTableImpl&&) noexcept = delete;
ComputeColorTableImpl& operator=(const ComputeColorTableImpl&) = delete;
ComputeColorTableImpl& operator=(ComputeColorTableImpl&&) noexcept = delete;
CreateColorMapImpl(const CreateColorMapImpl&) = default;
CreateColorMapImpl(CreateColorMapImpl&&) noexcept = delete;
CreateColorMapImpl& operator=(const CreateColorMapImpl&) = delete;
CreateColorMapImpl& operator=(CreateColorMapImpl&&) noexcept = delete;

template <typename K>
void convert(size_t start, size_t end) const
Expand Down Expand Up @@ -174,7 +174,7 @@ class ComputeColorTableImpl
struct GenerateColorArrayFunctor
{
template <typename ScalarType>
Result<> operator()(DataStructure& dataStructure, const ComputeColorTableInputValues* inputValues, const std::vector<float32>& controlPoints)
Result<> operator()(DataStructure& dataStructure, const CreateColorMapInputValues* inputValues, const std::vector<float32>& controlPoints)
{
// Control Points is a flattened 2D array with an unknown tuple count and a component size of 4
const usize numControlColors = controlPoints.size() / k_ControlPointCompSize;
Expand Down Expand Up @@ -211,14 +211,14 @@ struct GenerateColorArrayFunctor

ParallelDataAlgorithm dataAlg;
dataAlg.setRange(0, arrayRef.getNumberOfTuples());
dataAlg.execute(ComputeColorTableImpl(arrayRef, binPoints, controlPoints, numControlColors, colorArray, goodVoxelsArray, inputValues->InvalidColor));
dataAlg.execute(CreateColorMapImpl(arrayRef, binPoints, controlPoints, numControlColors, colorArray, goodVoxelsArray, inputValues->InvalidColor));
return {};
}
};
} // namespace

// -----------------------------------------------------------------------------
ComputeColorTable::ComputeColorTable(DataStructure& dataStructure, const IFilter::MessageHandler& msgHandler, const std::atomic_bool& shouldCancel, ComputeColorTableInputValues* inputValues)
CreateColorMap::CreateColorMap(DataStructure& dataStructure, const IFilter::MessageHandler& msgHandler, const std::atomic_bool& shouldCancel, CreateColorMapInputValues* inputValues)
: m_DataStructure(dataStructure)
, m_InputValues(inputValues)
, m_ShouldCancel(shouldCancel)
Expand All @@ -227,16 +227,16 @@ ComputeColorTable::ComputeColorTable(DataStructure& dataStructure, const IFilter
}

// -----------------------------------------------------------------------------
ComputeColorTable::~ComputeColorTable() noexcept = default;
CreateColorMap::~CreateColorMap() noexcept = default;

// -----------------------------------------------------------------------------
const std::atomic_bool& ComputeColorTable::getCancel()
const std::atomic_bool& CreateColorMap::getCancel()
{
return m_ShouldCancel;
}

// -----------------------------------------------------------------------------
Result<> ComputeColorTable::operator()()
Result<> CreateColorMap::operator()()
{
const IDataArray& selectedIDataArray = m_DataStructure.getDataRefAs<IDataArray>(m_InputValues->SelectedDataArrayPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace nx::core
{
struct SIMPLNXCORE_EXPORT ComputeColorTableInputValues
struct SIMPLNXCORE_EXPORT CreateColorMapInputValues
{
std::string PresetName;
DataPath SelectedDataArrayPath;
Expand All @@ -18,24 +18,24 @@ struct SIMPLNXCORE_EXPORT ComputeColorTableInputValues
std::vector<uint8> InvalidColor;
};

class SIMPLNXCORE_EXPORT ComputeColorTable
class SIMPLNXCORE_EXPORT CreateColorMap
{
public:
ComputeColorTable(DataStructure& dataStructure, const IFilter::MessageHandler& msgHandler, const std::atomic_bool& shouldCancel, ComputeColorTableInputValues* inputValues);
~ComputeColorTable() noexcept;
CreateColorMap(DataStructure& dataStructure, const IFilter::MessageHandler& msgHandler, const std::atomic_bool& shouldCancel, CreateColorMapInputValues* inputValues);
~CreateColorMap() noexcept;

ComputeColorTable(const ComputeColorTable&) = delete;
ComputeColorTable(ComputeColorTable&&) noexcept = delete;
ComputeColorTable& operator=(const ComputeColorTable&) = delete;
ComputeColorTable& operator=(ComputeColorTable&&) noexcept = delete;
CreateColorMap(const CreateColorMap&) = delete;
CreateColorMap(CreateColorMap&&) noexcept = delete;
CreateColorMap& operator=(const CreateColorMap&) = delete;
CreateColorMap& operator=(CreateColorMap&&) noexcept = delete;

Result<> operator()();

const std::atomic_bool& getCancel();

private:
DataStructure& m_DataStructure;
const ComputeColorTableInputValues* m_InputValues = nullptr;
const CreateColorMapInputValues* m_InputValues = nullptr;
const std::atomic_bool& m_ShouldCancel;
const IFilter::MessageHandler& m_MessageHandler;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ComputeColorTableFilter.hpp"
#include "CreateColorMapFilter.hpp"

#include "Algorithms/ComputeColorTable.hpp"
#include "Algorithms/CreateColorMap.hpp"

#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataPath.hpp"
Expand All @@ -13,7 +13,7 @@
#include "simplnx/Utilities/ColorTableUtilities.hpp"
#include "simplnx/Utilities/SIMPLConversion.hpp"

#include "simplnx/Parameters/ComputeColorTableParameter.hpp"
#include "simplnx/Parameters/CreateColorMapParameter.hpp"
#include "simplnx/Parameters/VectorParameter.hpp"

using namespace nx::core;
Expand All @@ -31,44 +31,44 @@ inline constexpr int32 k_MissingOrIncorrectGoodVoxelsArray = -72443;
namespace nx::core
{
//------------------------------------------------------------------------------
std::string ComputeColorTableFilter::name() const
std::string CreateColorMapFilter::name() const
{
return FilterTraits<ComputeColorTableFilter>::name.str();
return FilterTraits<CreateColorMapFilter>::name.str();
}

//------------------------------------------------------------------------------
std::string ComputeColorTableFilter::className() const
std::string CreateColorMapFilter::className() const
{
return FilterTraits<ComputeColorTableFilter>::className;
return FilterTraits<CreateColorMapFilter>::className;
}

//------------------------------------------------------------------------------
Uuid ComputeColorTableFilter::uuid() const
Uuid CreateColorMapFilter::uuid() const
{
return FilterTraits<ComputeColorTableFilter>::uuid;
return FilterTraits<CreateColorMapFilter>::uuid;
}

//------------------------------------------------------------------------------
std::string ComputeColorTableFilter::humanName() const
std::string CreateColorMapFilter::humanName() const
{
return "Generate Color Table";
return "Create Color Map";
}

//------------------------------------------------------------------------------
std::vector<std::string> ComputeColorTableFilter::defaultTags() const
std::vector<std::string> CreateColorMapFilter::defaultTags() const
{
return {className(), "Core", "Image"};
return {className(), "Core", "Image", "Color Table", "Generate"};
}

//------------------------------------------------------------------------------
Parameters ComputeColorTableFilter::parameters() const
Parameters CreateColorMapFilter::parameters() const
{
Parameters params;

// Create the parameter descriptors that are needed for this filter
params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
params.insert(std::make_unique<ComputeColorTableParameter>(k_SelectedPreset_Key, "Select Preset...", "Select a preset color scheme to apply to the created array",
ColorTableUtilities::GetDefaultRGBPresetName()));
params.insert(std::make_unique<CreateColorMapParameter>(k_SelectedPreset_Key, "Select Preset...", "Select a preset color scheme to apply to the created array",
ColorTableUtilities::GetDefaultRGBPresetName()));
params.insertSeparator(Parameters::Separator{"Input Data Objects"});
params.insert(std::make_unique<ArraySelectionParameter>(k_SelectedDataArrayPath_Key, "Data Array",
"The complete path to the data array from which to create the rgb array by applying the selected preset color scheme", DataPath{},
Expand All @@ -92,14 +92,14 @@ Parameters ComputeColorTableFilter::parameters() const
}

//------------------------------------------------------------------------------
IFilter::UniquePointer ComputeColorTableFilter::clone() const
IFilter::UniquePointer CreateColorMapFilter::clone() const
{
return std::make_unique<ComputeColorTableFilter>();
return std::make_unique<CreateColorMapFilter>();
}

//------------------------------------------------------------------------------
IFilter::PreflightResult ComputeColorTableFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
IFilter::PreflightResult CreateColorMapFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
auto pSelectedDataArrayPathValue = filterArgs.value<DataPath>(k_SelectedDataArrayPath_Key);
auto pRgbArrayPathValue = pSelectedDataArrayPathValue.replaceName(filterArgs.value<std::string>(k_RgbArrayPath_Key));
Expand Down Expand Up @@ -147,19 +147,19 @@ IFilter::PreflightResult ComputeColorTableFilter::preflightImpl(const DataStruct
}

//------------------------------------------------------------------------------
Result<> ComputeColorTableFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
Result<> CreateColorMapFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
const std::atomic_bool& shouldCancel) const
{
ComputeColorTableInputValues inputValues;
CreateColorMapInputValues inputValues;

inputValues.PresetName = filterArgs.value<ComputeColorTableParameter::ValueType>(k_SelectedPreset_Key);
inputValues.PresetName = filterArgs.value<CreateColorMapParameter::ValueType>(k_SelectedPreset_Key);
inputValues.SelectedDataArrayPath = filterArgs.value<DataPath>(k_SelectedDataArrayPath_Key);
inputValues.RgbArrayPath = inputValues.SelectedDataArrayPath.replaceName(filterArgs.value<std::string>(k_RgbArrayPath_Key));
inputValues.UseMask = filterArgs.value<bool>(k_UseMask_Key);
inputValues.MaskArrayPath = filterArgs.value<DataPath>(k_MaskArrayPath_Key);
inputValues.InvalidColor = filterArgs.value<std::vector<uint8>>(k_InvalidColorValue_Key);

return ComputeColorTable(dataStructure, messageHandler, shouldCancel, &inputValues)();
return CreateColorMap(dataStructure, messageHandler, shouldCancel, &inputValues)();
}

namespace
Expand All @@ -173,14 +173,14 @@ constexpr StringLiteral k_RgbArrayNameKey = "RgbArrayName";
} // namespace SIMPL
} // namespace

Result<Arguments> ComputeColorTableFilter::FromSIMPLJson(const nlohmann::json& json)
Result<Arguments> CreateColorMapFilter::FromSIMPLJson(const nlohmann::json& json)
{
Arguments args = ComputeColorTableFilter().getDefaultArguments();
Arguments args = CreateColorMapFilter().getDefaultArguments();

std::vector<Result<>> results;

results.push_back(SIMPLConversion::Convert2Parameters<SIMPLConversion::ComputeColorTableFilterParameterConverter>(args, json, SIMPL::k_SelectedPresetNameKey, SIMPL::k_SelectedPresetControlPointsKey,
k_SelectedPreset_Key));
results.push_back(SIMPLConversion::Convert2Parameters<SIMPLConversion::CreateColorMapFilterParameterConverter>(args, json, SIMPL::k_SelectedPresetNameKey, SIMPL::k_SelectedPresetControlPointsKey,
k_SelectedPreset_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::DataArraySelectionFilterParameterConverter>(args, json, SIMPL::k_SelectedDataArrayPathKey, k_SelectedDataArrayPath_Key));
results.push_back(SIMPLConversion::ConvertParameter<SIMPLConversion::LinkedPathCreationFilterParameterConverter>(args, json, SIMPL::k_RgbArrayNameKey, k_RgbArrayPath_Key));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
namespace nx::core
{
/**
* @class ComputeColorTableFilter
* @class CreateColorMapFilter
* @brief This filter generates a color table array for a given 1-component input array.
* Each element of the input array is normalized and converted to a color based on where
* the value falls in the spectrum of the selected color preset.
*/
class SIMPLNXCORE_EXPORT ComputeColorTableFilter : public IFilter
class SIMPLNXCORE_EXPORT CreateColorMapFilter : public IFilter
{
public:
ComputeColorTableFilter() = default;
~ComputeColorTableFilter() noexcept override = default;
CreateColorMapFilter() = default;
~CreateColorMapFilter() noexcept override = default;

ComputeColorTableFilter(const ComputeColorTableFilter&) = delete;
ComputeColorTableFilter(ComputeColorTableFilter&&) noexcept = delete;
CreateColorMapFilter(const CreateColorMapFilter&) = delete;
CreateColorMapFilter(CreateColorMapFilter&&) noexcept = delete;

ComputeColorTableFilter& operator=(const ComputeColorTableFilter&) = delete;
ComputeColorTableFilter& operator=(ComputeColorTableFilter&&) noexcept = delete;
CreateColorMapFilter& operator=(const CreateColorMapFilter&) = delete;
CreateColorMapFilter& operator=(CreateColorMapFilter&&) noexcept = delete;

// Parameter Keys
static inline constexpr StringLiteral k_SelectedPreset_Key = "selected_preset";
Expand Down Expand Up @@ -107,4 +107,4 @@ class SIMPLNXCORE_EXPORT ComputeColorTableFilter : public IFilter
};
} // namespace nx::core

SIMPLNX_DEF_FILTER_TRAITS(nx::core, ComputeColorTableFilter, "d1731177-4d70-41c0-9334-566a0b482796");
SIMPLNX_DEF_FILTER_TRAITS(nx::core, CreateColorMapFilter, "d1731177-4d70-41c0-9334-566a0b482796");
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "SimplnxCore/Filters/ComputeSurfaceAreaToVolumeFilter.hpp"
#include "SimplnxCore/Filters/ComputeSurfaceFeaturesFilter.hpp"
#include "SimplnxCore/Filters/ComputeVolumeFractionsFilter.hpp"
#include "SimplnxCore/Filters/ComputeColorTableFilter.hpp"
#include "SimplnxCore/Filters/CreateColorMapFilter.hpp"
#include "SimplnxCore/Filters/IdentifySampleFilter.hpp"
#include "SimplnxCore/Filters/ReadBinaryCTNorthstarFilter.hpp"
#include "SimplnxCore/Filters/ReadCSVFileFilter.hpp"
Expand Down Expand Up @@ -171,7 +171,7 @@ namespace nx::core
{nx::core::Uuid::FromString("5d586366-6b59-566e-8de1-57aa9ae8a91c").value(), {nx::core::FilterTraits<ComputeSurfaceAreaToVolumeFilter>::uuid, &ComputeSurfaceAreaToVolumeFilter::FromSIMPLJson}}, // ComputeSurfaceAreaToVolume
{nx::core::Uuid::FromString("d2b0ae3d-686a-5dc0-a844-66bc0dc8f3cb").value(), {nx::core::FilterTraits<ComputeSurfaceFeaturesFilter>::uuid, &ComputeSurfaceFeaturesFilter::FromSIMPLJson}}, // ComputeSurfaceFeaturesFilter
{nx::core::Uuid::FromString("68246a67-7f32-5c80-815a-bec82008d7bc").value(), {nx::core::FilterTraits<ComputeVolumeFractionsFilter>::uuid, &ComputeVolumeFractionsFilter::FromSIMPLJson}}, // ComputeVolumeFractions
{nx::core::Uuid::FromString("0d0a6535-6565-51c5-a3fc-fbc00008606d").value(), {nx::core::FilterTraits<ComputeColorTableFilter>::uuid, &ComputeColorTableFilter::FromSIMPLJson}}, // ComputeColorTable
{nx::core::Uuid::FromString("0d0a6535-6565-51c5-a3fc-fbc00008606d").value(), {nx::core::FilterTraits<CreateColorMapFilter>::uuid, &CreateColorMapFilter::FromSIMPLJson}}, // CreateColorMap
{nx::core::Uuid::FromString("0e8c0818-a3fb-57d4-a5c8-7cb8ae54a40a").value(), {nx::core::FilterTraits<IdentifySampleFilter>::uuid, &IdentifySampleFilter::FromSIMPLJson}}, // IdentifySampleFilter
{nx::core::Uuid::FromString("f2259481-5011-5f22-9fcb-c92fb6f8be10").value(), {nx::core::FilterTraits<ReadBinaryCTNorthstarFilter>::uuid, &ReadBinaryCTNorthstarFilter::FromSIMPLJson}}, // ImportBinaryCTNorthstarFilter
{nx::core::Uuid::FromString("bdb978bc-96bf-5498-972c-b509c38b8d50").value(), {nx::core::FilterTraits<ReadCSVFileFilter>::uuid, &ReadCSVFileFilter::FromSIMPLJson}}, // ReadASCIIData
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SimplnxCore/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ set(${PLUGIN_NAME}UnitTest_SRCS
ComputeBoundaryElementFractionsTest.cpp
ComputeTriangleGeomSizesTest.cpp
FlyingEdges3DTest.cpp
ComputeColorTableTest.cpp
CreateColorMapTest.cpp
IdentifySampleTest.cpp
ImageGeomTest.cpp
InitializeDataTest.cpp
Expand Down

0 comments on commit 683e6dd

Please sign in to comment.