Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/Filter/IFilter.hpp"
#include "simplnx/Parameters/ArrayCreationParameter.hpp"
#include "simplnx/Parameters/ArraySelectionParameter.hpp"
#include "simplnx/Parameters/ChoicesParameter.hpp"
#include "simplnx/Parameters/DataGroupCreationParameter.hpp"
#include "simplnx/Parameters/VectorParameter.hpp"
#include "simplnx/Utilities/SampleSurfaceMesh.hpp"

#include <set>

namespace nx::core
{
struct SIMPLNXCORE_EXPORT RegularGridSampleSurfaceMeshInputValues
Expand All @@ -23,6 +21,7 @@ struct SIMPLNXCORE_EXPORT RegularGridSampleSurfaceMeshInputValues
DataPath SurfaceMeshFaceLabelsArrayPath;
DataPath ImageGeometryOutputPath;
DataPath FeatureIdsArrayPath;
DataPath SurfaceMeshPartIdsArrayPath;
};

/**
Expand All @@ -42,11 +41,11 @@ class SIMPLNXCORE_EXPORT RegularGridSampleSurfaceMesh : public SampleSurfaceMesh

Result<> operator()();

const std::atomic_bool& getCancel();
void sendThreadSafeUpdate(Int32Array& m_FeatureIds, const std::vector<int32>& rasterBuffer, usize offset);
void sendThreadSafeUpdate(const std::vector<int32>& rasterBuffer, usize offset);

protected:
void generatePoints(std::vector<Point3Df>& points) override;
void processSlice(int32 m_CurrentSliceId, usize m_ImageGeomIdx, const std::set<int32>& uniquePartIds);

private:
DataStructure& m_DataStructure;
Expand All @@ -56,8 +55,10 @@ class SIMPLNXCORE_EXPORT RegularGridSampleSurfaceMesh : public SampleSurfaceMesh

// Thread safe Progress Message
mutable std::mutex m_ProgressMessage_Mutex;
usize m_ProgressCounter = 0;
usize m_LastProgressInt = 0;
usize m_LayerCompleted = 0;
usize m_TotalSlices = 0;
// usize m_LastProgressInt = 0;
std::chrono::steady_clock::time_point m_InitialTime = std::chrono::steady_clock::now();
Int32Array* m_FeatureIdsDataStorePtr = nullptr;
};
} // namespace nx::core
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Result<> SliceTriangleGeometry::operator()()
zEnd = boundingBox.getMaxPoint()[2];
}

m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Slicing triangle geometry")});

// The majority of the algorithm to slice the triangle geometry is in this function
GeometryUtilities::SliceTriangleReturnType sliceTriangleResult =
GeometryUtilities::SliceTriangleGeometry(triangle, m_ShouldCancel, m_InputValues->SliceRange, zStart, zEnd, m_InputValues->SliceResolution, triRegionIdPtr);
Expand Down Expand Up @@ -84,6 +86,8 @@ Result<> SliceTriangleGeometry::operator()()
triRegionIds->fill(0);
}

m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Setting Feature Ids")});

for(usize i = 0; i < numEdges; i++)
{
edges[2 * i] = 2 * i;
Expand All @@ -101,12 +105,16 @@ Result<> SliceTriangleGeometry::operator()()
}
}

m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Removing duplicate nodes...")});

Result<> result = GeometryUtilities::EliminateDuplicateNodes<EdgeGeom>(edgeGeom);
if(result.invalid())
{
return result;
}

m_MessageHandler({IFilter::Message::Type::Info, fmt::format("Removing duplicate edges...")});

// REMOVE DUPLICATE EDGES FROM THE GENERATED EDGE GEOMETRY
// Remember to also fix up the sliceIds and regionIds arrays
using UniqueEdges = std::set<std::pair<uint64, uint64>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Parameters RegularGridSampleSurfaceMeshFilter::parameters() const
params.insert(std::make_unique<GeometrySelectionParameter>(k_ExistingImageGeomPath_Key, "Image Geometry", "The path to the existing image geometry to use", DataPath{},
GeometrySelectionParameter::AllowedTypes{GeometrySelectionParameter::AllowedType::Image}));

params.insert(std::make_unique<ArraySelectionParameter>(k_SurfaceMeshPartNumbersArrayPath_Key, "Part Numbers", "Array specifying the part number that the triangle belongs to.", DataPath{},
ArraySelectionParameter::AllowedTypes{nx::core::DataType::int32}, ArraySelectionParameter::AllowedComponentShapes{{1}}));

params.insertSeparator(Parameters::Separator{"Output Image Geometry"});
params.insert(std::make_unique<DataGroupCreationParameter>(k_ImageGeomPath_Key, "Image Geometry", "The name and path for the image geometry to be created", DataPath{}));
params.insertSeparator(Parameters::Separator{"Output Cell Attribute Matrix"});
Expand Down Expand Up @@ -145,8 +148,8 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const
auto triangleGeometryPath = filterArgs.value<DataPath>(k_TriangleGeometryPath_Key);
auto geometryOptionIndex = filterArgs.value<ChoicesParameter::ValueType>(k_UseExistingGeometry_Key);
auto existingImageGeomPathValue = filterArgs.value<DataPath>(k_ExistingImageGeomPath_Key);

GeometryOption geometryOption = ConvertIndexToGeometryOption(geometryOptionIndex);
auto partNumbersPath = filterArgs.value<DataPath>(k_SurfaceMeshPartNumbersArrayPath_Key);

nx::core::Result<OutputActions> resultOutputActions;
std::vector<PreflightValue> preflightUpdatedValues;
Expand Down Expand Up @@ -203,7 +206,6 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const
DataPath pSliceDataContainerNameValue({fmt::format(".{}_sliced", triangleGeometryPath.getTargetName())});
std::string pEdgeAttributeMatrixNameValue("EdgeAttributeMatrix");
std::string pSliceIdArrayNameValue("SliceIds");
DataPath pRegionIdArrayPathValue({"NOT USED"});
std::string pSliceAttributeMatrixNameValue("SliceAttributeMatrix");
// create the edge geometry
{
Expand All @@ -225,9 +227,13 @@ IFilter::PreflightResult RegularGridSampleSurfaceMeshFilter::preflightImpl(const
auto createAttributeMatrixAction = std::make_unique<CreateAttributeMatrixAction>(featureSliceAttrMatPath, tDims);
resultOutputActions.value().appendAction(std::move(createAttributeMatrixAction));
}

auto deferredDeleteGeometryAction = std::make_unique<DeleteDataAction>(pSliceDataContainerNameValue);
resultOutputActions.value().appendDeferredAction(std::move(deferredDeleteGeometryAction));
{
DataPath path = pSliceDataContainerNameValue.createChildPath(pEdgeAttributeMatrixNameValue).createChildPath(partNumbersPath.getTargetName());
auto createArray = std::make_unique<CreateArrayAction>(DataType::int32, tDims, compDims, path);
resultOutputActions.value().appendAction(std::move(createArray));
}
// auto deferredDeleteGeometryAction = std::make_unique<DeleteDataAction>(pSliceDataContainerNameValue);
// resultOutputActions.value().appendDeferredAction(std::move(deferredDeleteGeometryAction));
}
/////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -269,6 +275,9 @@ Result<> RegularGridSampleSurfaceMeshFilter::executeImpl(DataStructure& dataStru

inputValues.TriangleGeometryPath = filterArgs.value<DataPath>(k_TriangleGeometryPath_Key);
inputValues.SurfaceMeshFaceLabelsArrayPath = filterArgs.value<DataPath>(k_SurfaceMeshFaceLabelsArrayPath_Key);
// inputValues.FeatureIdsArrayPath =
// filterArgs.value<DataPath>(k_ImageGeomPath_Key).createChildPath(filterArgs.value<std::string>(k_CellAMName_Key)).createChildPath(filterArgs.value<std::string>(k_FeatureIdsArrayName_Key));
inputValues.SurfaceMeshPartIdsArrayPath = filterArgs.value<DataPath>(k_SurfaceMeshPartNumbersArrayPath_Key);

return RegularGridSampleSurfaceMesh(dataStructure, messageHandler, shouldCancel, &inputValues)();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SIMPLNXCORE_EXPORT RegularGridSampleSurfaceMeshFilter : public IFilter
UseExisting = 1
};

static inline constexpr StringLiteral k_SurfaceMeshPartNumbersArrayPath_Key = "surface_mesh_part_numbers_array_path";
/**
* @brief Reads SIMPL json and converts it simplnx Arguments.
* @param json
Expand Down
1 change: 0 additions & 1 deletion src/simplnx/Utilities/ParallelTaskAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ void ParallelTaskAlgorithm::wait()
#ifdef SIMPLNX_ENABLE_MULTICORE
// This will spill over if the number of files to process does not divide evenly by the number of threads.
m_TaskGroup.wait();
m_CurThreads = 0;
#endif
}
6 changes: 0 additions & 6 deletions src/simplnx/Utilities/ParallelTaskAlgorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class SIMPLNX_EXPORT ParallelTaskAlgorithm : public IParallelAlgorithm
if(getParallelizationEnabled())
{
m_TaskGroup.run(body);
m_CurThreads++;
if(m_CurThreads >= m_MaxThreads)
{
wait();
}
}
else
#endif
Expand All @@ -75,7 +70,6 @@ class SIMPLNX_EXPORT ParallelTaskAlgorithm : public IParallelAlgorithm
#ifdef SIMPLNX_ENABLE_MULTICORE
uint32_t m_MaxThreads = std::thread::hardware_concurrency();
tbb::task_group m_TaskGroup;
uint32_t m_CurThreads = 0;
#else
uint32_t m_MaxThreads = 1;
#endif
Expand Down
Loading