From 22c28ca1e5c03efaf20ff91d99f154b2308cd2c7 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 25 Sep 2023 18:22:55 -0400 Subject: [PATCH] WriteSTLFile: Ensure output path is created when executing filter. Signed-off-by: Michael Jackson (cherry picked from commit 5e432784e270c828f90e8f90b2a3abea8bcf4d38) --- .../ComplexCore/Filters/Algorithms/WriteStlFile.cpp | 11 ++++++++++- .../src/ComplexCore/Filters/WriteStlFileFilter.cpp | 10 ---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/WriteStlFile.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/WriteStlFile.cpp index fee1e33685..79e01d647d 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/WriteStlFile.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/WriteStlFile.cpp @@ -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; @@ -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(m_InputValues->FeatureIdsPath); - // const auto& normals = m_DataStructure.getDataRefAs(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 uniqueGrainIdToPhase; diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/WriteStlFileFilter.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/WriteStlFileFilter.cpp index 68eed1d215..66ec38fbc8 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/WriteStlFileFilter.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/WriteStlFileFilter.cpp @@ -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(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)}; }