Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Improve performance of the Surface Mesh to Regular Grid. #1146

Merged
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/Utilities/ClusteringUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/MontageUtilities.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/SIMPLConversion.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/IntersectionUtilities.hpp

${SIMPLNX_SOURCE_DIR}/Utilities/Math/GeometryMath.hpp
${SIMPLNX_SOURCE_DIR}/Utilities/Math/MatrixMath.hpp
Expand Down
1 change: 0 additions & 1 deletion src/Plugins/OrientationAnalysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ set(PLUGIN_EXTRA_SOURCES
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/TiffWriter.cpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/delaunator.cpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/delaunator.h"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/IntersectionUtilities.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/GrainMapper3DUtilities.hpp"
"${${PLUGIN_NAME}_SOURCE_DIR}/src/${PLUGIN_NAME}/utilities/GrainMapper3DUtilities.cpp"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "OrientationAnalysis/utilities/FiraSansRegular.hpp"
#include "OrientationAnalysis/utilities/Fonts.hpp"
#include "OrientationAnalysis/utilities/IntersectionUtilities.hpp"
#include "OrientationAnalysis/utilities/LatoBold.hpp"
#include "OrientationAnalysis/utilities/LatoRegular.hpp"
#include "OrientationAnalysis/utilities/TiffWriter.hpp"
Expand All @@ -15,6 +14,7 @@
#include "simplnx/DataStructure/Geometry/TriangleGeom.hpp"
#include "simplnx/Pipeline/Pipeline.hpp"
#include "simplnx/Utilities/DataArrayUtilities.hpp"
#include "simplnx/Utilities/IntersectionUtilities.hpp"
#include "simplnx/Utilities/ParallelTaskAlgorithm.hpp"
#include "simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.hpp"
#include "simplnx/Utilities/RTree.hpp"
Expand Down Expand Up @@ -123,7 +123,7 @@ class ComputeIntensityStereographicProjection
size_t numTris = delaunayGeom->getNumberOfFaces();
for(size_t tIndex = 0; tIndex < numTris; tIndex++)
{
std::array<float, 6> boundBox = nx::IntersectionUtilities::GetBoundingBoxAtTri(*delaunayGeom, tIndex);
std::array<float, 6> boundBox = nx::core::IntersectionUtilities::GetBoundingBoxAtTri(*delaunayGeom, tIndex);
m_RTree.Insert(boundBox.data(), boundBox.data() + 3, tIndex); // Note, all values including zero are fine in this version
}

Expand Down Expand Up @@ -167,7 +167,7 @@ class ComputeIntensityStereographicProjection

// Get the vertex Indices from the triangle
delaunayGeom->getFacePointIds(triIndex, triVertIndices);
bool inTriangle = nx::IntersectionUtilities::RayTriangleIntersect2(rayOrigin, rayDirection, v0, v1, v2, barycentricCoord);
bool inTriangle = nx::core::IntersectionUtilities::RayTriangleIntersect2(rayOrigin, rayDirection, v0, v1, v2, barycentricCoord);
if(inTriangle)
{
// Linear Interpolate dx and dy values using the barycentric coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ Result<> CombineStlFiles::operator()()
triCounter += currentGeomNumVertices;
}

if(m_InputValues->LabelFaces)
if(m_InputValues->CreatePartNumbers)
{
// Type checked in preflight; Unsafe acceptable; pointer for speed
auto* faceLabelsStore = m_DataStructure.getDataAsUnsafe<Int32Array>(m_InputValues->FaceFileIndexArrayPath)->getDataStore();
std::fill(faceLabelsStore->begin() + faceLabelOffset, faceLabelsStore->begin() + faceLabelOffset + currentGeomNumTriangles, fileIndex);
auto* partNumberDataStore = m_DataStructure.getDataAsUnsafe<Int32Array>(m_InputValues->PartNumberIndexArrayPath)->getDataStore();
std::fill(partNumberDataStore->begin() + faceLabelOffset, partNumberDataStore->begin() + faceLabelOffset + currentGeomNumTriangles, fileIndex);
}

faceLabelOffset += currentGeomNumTriangles;
Expand All @@ -224,5 +224,30 @@ Result<> CombineStlFiles::operator()()
}
taskRunner.wait(); // This will spill over if the number of geometries to processes does not divide evenly by the number of threads.

// Create the Face Labels Array if the user asked for it.
if(m_InputValues->CreateFaceLabels)
{
auto* faceLabelDataStorePtr = m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->FaceLabelIndexArrayPath).getDataStore();
usize numTuples = faceLabelDataStorePtr->getNumberOfTuples();
AbstractDataStore<int32>* partNumberDataStorePtr = nullptr;
if(m_InputValues->CreatePartNumbers)
{
partNumberDataStorePtr = m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->PartNumberIndexArrayPath).getDataStore();
}

for(usize idx = 0; idx < numTuples; idx++)
{
faceLabelDataStorePtr->setComponent(idx, 0, 0);
if(partNumberDataStorePtr != nullptr)
{
faceLabelDataStorePtr->setComponent(idx, 1, (*partNumberDataStorePtr)[idx]);
}
else
{
faceLabelDataStorePtr->setComponent(idx, 1, 1);
}
}
}

return {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ struct SIMPLNXCORE_EXPORT CombineStlFilesInputValues
DataPath TriangleDataContainerName;
DataPath FaceAttributeMatrixName;
DataPath FaceNormalsArrayName;
DataPath FaceFileIndexArrayPath;
bool LabelFaces;

DataPath PartNumberIndexArrayPath;
bool CreatePartNumbers;

DataPath FaceLabelIndexArrayPath;
bool CreateFaceLabels;

DataPath VertexFileIndexArrayPath;
bool LabelVertices;

DataObjectNameParameter::ValueType CellFeatureAttributeMatrixName;
DataObjectNameParameter::ValueType ActiveArrayName;
DataObjectNameParameter::ValueType FileListArrayName;
Expand Down
Loading
Loading