Skip to content

Commit

Permalink
WriteSTLFile: Ensure output path is created when executing filter.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
(cherry picked from commit 5e43278)
  • Loading branch information
imikejackson committed Sep 26, 2023
1 parent 35fe3e9 commit 22c28ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "WriteStlFile.hpp"

#include "complex/DataStructure/Geometry/TriangleGeom.hpp"
#include "complex/Utilities/FilterUtilities.hpp"
#include "complex/Utilities/StringUtilities.hpp"

using namespace complex;
Expand Down Expand Up @@ -65,7 +66,15 @@ Result<> WriteStlFile::operator()()
const IGeometry::MeshIndexArrayType& triangles = triangleGeom.getFacesRef();
const IGeometry::MeshIndexType nTriangles = triangleGeom.getNumberOfFaces();
const auto& featureIds = m_DataStructure.getDataRefAs<Int32Array>(m_InputValues->FeatureIdsPath);
// const auto& normals = m_DataStructure.getDataRefAs<Float32Array>(m_InputValues->FaceNormalsPath);

const std::filesystem::path outputPath = m_InputValues->OutputStlDirectory;
// Make sure any directory path is also available as the user may have just typed
// in a path without actually creating the full path
Result<> createDirectoriesResult = complex::CreateOutputDirectories(outputPath);
if(createDirectoriesResult.invalid())
{
return createDirectoriesResult;
}

// Store all the unique Spins
std::map<int32, int32> uniqueGrainIdToPhase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,6 @@ IFilter::PreflightResult WriteStlFileFilter::preflightImpl(const DataStructure&
return MakePreflightErrorResult(-27873, fmt::format("Feature Ids Array doesn't exist at: {}", pFeatureIdsPathValue.toString()));
}

// if(auto* normals = dataStructure.getDataAs<Float32Array>(pFaceNormalsPathValue); normals == nullptr)
// {
// return MakePreflightErrorResult(-27874, fmt::format("Face Normals Array doesn't exist at: {}", pFaceNormalsPathValue.toString()));
// }

if(!exists(pOutputStlDirectoryValue))
{
return MakePreflightErrorResult(-27875, fmt::format("Directory {} doesn't exist.", pOutputStlDirectoryValue.string()));
}

// Return both the resultOutputActions and the preflightUpdatedValues via std::move()
return {std::move(resultOutputActions), std::move(preflightUpdatedValues)};
}
Expand Down

0 comments on commit 22c28ca

Please sign in to comment.