From 1484f9e15c206dbb567ea263b596cab91142d44d Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 17 Oct 2024 14:40:45 -0400 Subject: [PATCH 1/6] COMP: Fix warning about Microsoft extensions --- src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp | 2 +- src/simplnx/Utilities/ClusteringUtilities.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp b/src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp index dce156f383..7bcc96c53f 100644 --- a/src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp +++ b/src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp @@ -25,7 +25,7 @@ class IDataIO; */ class SIMPLNX_EXPORT DataStructureWriter { - friend class DataObject; + friend class nx::core::DataObject; friend SIMPLNX_EXPORT Result<> WriteObjectAttributes(DataStructureWriter&, ObjectWriter&, const DataObject*, bool); friend class HDF5::IDataIO; diff --git a/src/simplnx/Utilities/ClusteringUtilities.hpp b/src/simplnx/Utilities/ClusteringUtilities.hpp index 42245f5964..956def810f 100644 --- a/src/simplnx/Utilities/ClusteringUtilities.hpp +++ b/src/simplnx/Utilities/ClusteringUtilities.hpp @@ -7,7 +7,7 @@ namespace nx::core::ClusterUtilities { -enum SIMPLNX_EXPORT DistanceMetric +enum DistanceMetric { Euclidean, SquaredEuclidean, From 189f1f92483c53aa9c2d8a71be20d1c26a9fedb0 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 17 Oct 2024 17:26:05 -0400 Subject: [PATCH 2/6] COMP: Fix warning for double->float conversion in parameter --- .../src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp index e5ee1979ff..acd6095520 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/SliceTriangleGeometryFilter.cpp @@ -64,7 +64,7 @@ Parameters SliceTriangleGeometryFilter::parameters() const params.insertLinkableParameter(std::make_unique(k_SliceRange_Key, "Slice Range", "Type of slice range to use, either Full Range or User Defined Range", 0, ChoicesParameter::Choices{"Full Range", "User Defined Range"})); params.insert(std::make_unique(k_Zstart_Key, "Slicing Start", "The z axis start value", 0.0f)); - params.insert(std::make_unique(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0)); + params.insert(std::make_unique(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0f)); params.insert(std::make_unique(k_SliceResolution_Key, "Slice Spacing", "The spacing between slices", 1.0f)); params.insertSeparator(Parameters::Separator{"Input Geometry"}); From 6e3cbea05c08902fd908184c32daa9d30d1b7170 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 17 Oct 2024 17:29:58 -0400 Subject: [PATCH 3/6] COMP: Fix msvc compiler warnings Signed-off-by: Michael Jackson --- .../src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp | 2 +- .../src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp | 2 +- .../SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp | 2 +- src/Plugins/SimplnxCore/test/DBSCANTest.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp index ee4795e840..53178a7c09 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/CreateAMScanPaths.cpp @@ -347,7 +347,7 @@ Result<> CreateAMScanPaths::operator()() char good = determineIntersectCoord(p1, p2, vert1, vert2, coord); if(good == 'i') { - intersectionCoords.insert(std::pair(coord, 0)); + intersectionCoords.insert(std::pair(coord, 0ULL)); } else if(good == 'c' || good == 'd') { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp index 6fac32e9e0..ddd1c860b7 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/CreateDataArrayAdvancedFilter.cpp @@ -192,7 +192,7 @@ IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const Data usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast(1), std::multiplies<>()); if(numComponents <= 0) { - std::string compDimsStr = std::accumulate(compDims.begin() + 1, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); + std::string compDimsStr = std::accumulate(compDims.begin() + 1ULL, compDims.end(), std::to_string(compDims[0]), [](const std::string& a, int b) { return a + " x " + std::to_string(b); }); return MakePreflightErrorResult( -78601, fmt::format("The chosen component dimensions ({}) results in 0 total components. Please choose component dimensions that result in a positive number of total components.", compDimsStr)); diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp index 31bac09811..976a4503a5 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/DBSCANFilter.cpp @@ -76,7 +76,7 @@ Parameters DBSCANFilter::parameters() const params.insertSeparator(Parameters::Separator{"Input Parameter(s)"}); params.insert(std::make_unique(k_UsePrecaching_Key, "Use Precaching", "If true the algorithm will be significantly faster, but it requires more memory", true)); - params.insert(std::make_unique(k_Epsilon_Key, "Epsilon", "The epsilon-neighborhood around each point is queried", 0.0001)); + params.insert(std::make_unique(k_Epsilon_Key, "Epsilon", "The epsilon-neighborhood around each point is queried", 0.0001f)); params.insert(std::make_unique(k_MinPoints_Key, "Minimum Points", "The minimum number of points needed to form a 'dense region' (i.e., the minimum number of points needed to be called a cluster)", 2)); params.insert( diff --git a/src/Plugins/SimplnxCore/test/DBSCANTest.cpp b/src/Plugins/SimplnxCore/test/DBSCANTest.cpp index 154586a75a..fc85d31410 100644 --- a/src/Plugins/SimplnxCore/test/DBSCANTest.cpp +++ b/src/Plugins/SimplnxCore/test/DBSCANTest.cpp @@ -46,7 +46,7 @@ TEST_CASE("SimplnxCore::DBSCAN: Valid Filter Execution (Precached, Iterative)", // Create default Parameters for the filter. args.insertOrAssign(DBSCANFilter::k_InitTypeIndex_Key, std::make_any(to_underlying(AlgType::Iterative))); args.insertOrAssign(DBSCANFilter::k_UsePrecaching_Key, std::make_any(true)); - args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any(0.01)); + args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any(0.01f)); args.insertOrAssign(DBSCANFilter::k_MinPoints_Key, std::make_any(50)); args.insertOrAssign(DBSCANFilter::k_UseMask_Key, std::make_any(false)); args.insertOrAssign(DBSCANFilter::k_SelectedArrayPath_Key, std::make_any(k_TargetArrayPath)); From 928bff5b6536edc3f3d58d18b960acd1a153a0ed Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 17 Oct 2024 23:30:21 -0400 Subject: [PATCH 4/6] CMAKE: Fix issues during installation on multi-config generators --- CMakeLists.txt | 1 + cmake/CopyDataFile.cmake.in | 8 +---- cmake/FetchDataFile.cmake.in | 10 ++++-- src/Plugins/SimplnxCore/CMakeLists.txt | 44 +++++++++++++------------- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 687b3beee4..14413acbc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,7 @@ cmake_policy(SET CMP0054 NEW) if(CMAKE_VERSION VERSION_GREATER \"3.28.0\") cmake_policy(SET CMP0152 NEW) endif() +set(CONFIG \${CMAKE_CONFIG}) ") set(TEST_WORKING_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") diff --git a/cmake/CopyDataFile.cmake.in b/cmake/CopyDataFile.cmake.in index c8f0a03132..8b13789179 100644 --- a/cmake/CopyDataFile.cmake.in +++ b/cmake/CopyDataFile.cmake.in @@ -1,7 +1 @@ -# -------------------------------------------------------------------------------------------------- -# message(STATUS "[DATA COPY] Copy data from @ARGS_DREAM3D_DATA_DIR@/TestFiles/@ARCHIVE_BASE_NAME@") -# -------------------------------------------------------------------------------------------------- -# execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "@ARGS_DREAM3D_DATA_DIR@/TestFiles/@ARCHIVE_BASE_NAME@" "Data/@ARCHIVE_BASE_NAME@" -# COMMAND_EXPAND_LISTS -# VERBATIM -# ) + diff --git a/cmake/FetchDataFile.cmake.in b/cmake/FetchDataFile.cmake.in index 05dbce606d..a0f58e759c 100644 --- a/cmake/FetchDataFile.cmake.in +++ b/cmake/FetchDataFile.cmake.in @@ -3,6 +3,7 @@ # STARTING @ARGS_ARCHIVE_NAME@ # Download, Decompress, and possibly copy data archive # message(STATUS "[DATA DOWNLOAD] @ARGS_ARCHIVE_NAME@") +# message(STATUS "CMAKE_CONFIG: ${CMAKE_CONFIG}") # -------------------------------------------------------------------------------------------------- string(TIMESTAMP time_stamp_start %s) file(DOWNLOAD @DATA_ARCHIVE_WEB_SITE@@ARGS_ARCHIVE_NAME@ @@ -29,7 +30,10 @@ endif() # -------------------------------------------------------------------------------------------------- # Oddly, if the status comes back as "No Error", that actually means that something got downloaded -# If the file was downloaded then we should also decompress it. +# Assuming the last command was successfull, if the developer wanted the data copied to the +# build folder. +# ARGS_COPY_DATA=@ARGS_COPY_DATA@ +# DATA_DEST_DIR=@DATA_DEST_DIR@ # -------------------------------------------------------------------------------------------------- if(@ARGS_COPY_DATA@) get_filename_component(archive_base_name "@ARGS_ARCHIVE_NAME@" NAME) @@ -40,5 +44,7 @@ if(@ARGS_COPY_DATA@) OUTPUT_VARIABLE output ERROR_VARIABLE error ) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "@ARGS_DREAM3D_DATA_DIR@/TestFiles/@ARCHIVE_BASE_NAME@" "@DATA_DEST_DIR@/@ARCHIVE_BASE_NAME@") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different + "@ARGS_DREAM3D_DATA_DIR@/TestFiles/@ARCHIVE_BASE_NAME@" + "@DATA_DEST_DIR@/@ARCHIVE_BASE_NAME@") endif() diff --git a/src/Plugins/SimplnxCore/CMakeLists.txt b/src/Plugins/SimplnxCore/CMakeLists.txt index 894f2cc119..3c3bdb311f 100644 --- a/src/Plugins/SimplnxCore/CMakeLists.txt +++ b/src/Plugins/SimplnxCore/CMakeLists.txt @@ -466,17 +466,17 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES) INSTALL COPY_DATA ) - add_custom_target(Copy_${PLUGIN_NAME}_ASCIIData ALL - COMMAND ${CMAKE_COMMAND} -E tar xzf "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData.tar.gz" - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data/ASCIIData" - COMMAND ${CMAKE_COMMAND} -E rm -rf "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData" - WORKING_DIRECTORY "${DREAM3D_DATA_DIR}/TestFiles" - COMMENT "Copying ${PLUGIN_NAME}/ASCIIData data into Binary Directory" - DEPENDS Fetch_Remote_Data_Files # Make sure all remote files are downloaded before trying this - COMMAND_EXPAND_LISTS - VERBATIM - ) - set_target_properties(Copy_${PLUGIN_NAME}_ASCIIData PROPERTIES FOLDER Plugins/${PLUGIN_NAME}) + # add_custom_target(Copy_${PLUGIN_NAME}_ASCIIData ALL + # COMMAND ${CMAKE_COMMAND} -E tar xzf "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData.tar.gz" + # COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data/ASCIIData" + # COMMAND ${CMAKE_COMMAND} -E rm -rf "${DREAM3D_DATA_DIR}/TestFiles/ASCIIData" + # WORKING_DIRECTORY "${DREAM3D_DATA_DIR}/TestFiles" + # COMMENT "Copying ${PLUGIN_NAME}/ASCIIData data into Binary Directory" + # DEPENDS Fetch_Remote_Data_Files # Make sure all remote files are downloaded before trying this + # COMMAND_EXPAND_LISTS + # VERBATIM + # ) + # set_target_properties(Copy_${PLUGIN_NAME}_ASCIIData PROPERTIES FOLDER Plugins/${PLUGIN_NAME}) download_test_data(DREAM3D_DATA_DIR ${DREAM3D_DATA_DIR} ARCHIVE_NAME STL_Models.tar.gz @@ -484,17 +484,17 @@ if(EXISTS "${DREAM3D_DATA_DIR}" AND SIMPLNX_DOWNLOAD_TEST_FILES) INSTALL COPY_DATA ) - add_custom_target(Copy_${PLUGIN_NAME}_STL_Models ALL - COMMAND ${CMAKE_COMMAND} -E tar xzf "${DREAM3D_DATA_DIR}/TestFiles/STL_Models.tar.gz" - COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${DREAM3D_DATA_DIR}/TestFiles/STL_Models" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data/STL_Models" - COMMAND ${CMAKE_COMMAND} -E rm -rf "${DREAM3D_DATA_DIR}/TestFiles/STL_Models" - WORKING_DIRECTORY "${DREAM3D_DATA_DIR}/TestFiles" - COMMENT "Copying ${PLUGIN_NAME}/STL_Models data into Binary Directory" - DEPENDS Fetch_Remote_Data_Files # Make sure all remote files are downloaded before trying this - COMMAND_EXPAND_LISTS - VERBATIM - ) - set_target_properties(Copy_${PLUGIN_NAME}_STL_Models PROPERTIES FOLDER Plugins/${PLUGIN_NAME}) + # add_custom_target(Copy_${PLUGIN_NAME}_STL_Models ALL + # COMMAND ${CMAKE_COMMAND} -E tar xzf "${DREAM3D_DATA_DIR}/TestFiles/STL_Models.tar.gz" + # COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different "${DREAM3D_DATA_DIR}/TestFiles/STL_Models" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CX_CONFIG_DIR}/Data/STL_Models" + # COMMAND ${CMAKE_COMMAND} -E rm -rf "${DREAM3D_DATA_DIR}/TestFiles/STL_Models" + # WORKING_DIRECTORY "${DREAM3D_DATA_DIR}/TestFiles" + # COMMENT "Copying ${PLUGIN_NAME}/STL_Models data into Binary Directory" + # DEPENDS Fetch_Remote_Data_Files # Make sure all remote files are downloaded before trying this + # COMMAND_EXPAND_LISTS + # VERBATIM + # ) + # set_target_properties(Copy_${PLUGIN_NAME}_STL_Models PROPERTIES FOLDER Plugins/${PLUGIN_NAME}) endif() From a3821da6c151cae605ec0f8d7e68a63a87993f7f Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 10 Oct 2024 13:07:29 -0400 Subject: [PATCH 5/6] CMAKE: Organize the VS solution and add python path to debugger Signed-off-by: Michael Jackson (cherry picked from commit 9d2eb6bed38d585a05ec45db5846b96ad2eb13d0) --- test/CMakeLists.txt | 3 ++- wrapping/python/docs/CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a79e55d501..58bd20e886 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -96,4 +96,5 @@ add_custom_target(Copy_simplnx_Test_Data ALL COMMENT "Copying ${simplnx_SOURCE_DIR}/test/Data data into Binary Directory" COMMAND_EXPAND_LISTS VERBATIM - ) \ No newline at end of file + ) +set_target_properties(Copy_simplnx_Test_Data PROPERTIES FOLDER ZZ_COPY_FILES) diff --git a/wrapping/python/docs/CMakeLists.txt b/wrapping/python/docs/CMakeLists.txt index a7bc651dd5..729f549086 100644 --- a/wrapping/python/docs/CMakeLists.txt +++ b/wrapping/python/docs/CMakeLists.txt @@ -40,6 +40,7 @@ target_sources(generate_sphinx_docs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/plugin_source_dirs.hpp" ) +set_target_properties(generate_sphinx_docs PROPERTIES FOLDER simplnx_Python__Documentation) set(SIMPLNX_SPHINX_DOCS_DIR "${simplnx_BINARY_DIR}/wrapping/python/docs") @@ -53,6 +54,7 @@ add_custom_target(sphinx_copy_sources ALL COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/source" "${SIMPLNX_SPHINX_DOCS_DIR}/source" COMMENT "SIMPLNX Python Docs: Copying static doc files to build directory at ${SIMPLNX_SPHINX_DOCS_DIR}" ) +set_target_properties(sphinx_copy_sources PROPERTIES FOLDER simplnx_Python__Documentation) #------------------------------------------------------------------------------ # Execute the sphinx rst plugin generation tool @@ -62,6 +64,7 @@ add_custom_target(sphinx_generate_plugin_rst ALL COMMAND "$" COMMENT "SIMPLNX Python Docs: Generated Plugin .rst docs file" ) +set_target_properties(sphinx_generate_plugin_rst PROPERTIES FOLDER simplnx_Python__Documentation) #------------------------------------------------------------------------------ # Find the `sphinx-build` executable @@ -103,3 +106,4 @@ else() WORKING_DIRECTORY "${SIMPLNX_SPHINX_DOCS_DIR}" ) endif() +set_target_properties(sphinx_docs_generation PROPERTIES FOLDER simplnx_Python__Documentation) From 288bc586fd0167da5a087cc60f61eb204bd303c8 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 5 Jul 2024 18:55:19 -0400 Subject: [PATCH 6/6] ENH: Fix issues reading some 3rd party written .dream3d files Some data arrays had their component dimensions attribute written incorrectly. Signed-off-by: Michael Jackson --- cmake/CopyDataFile.cmake.in | 1 - cmake/Utility.cmake | 23 +------ .../Utilities/Parsing/DREAM3D/Dream3dIO.cpp | 60 +++++++++++++++++-- 3 files changed, 56 insertions(+), 28 deletions(-) delete mode 100644 cmake/CopyDataFile.cmake.in diff --git a/cmake/CopyDataFile.cmake.in b/cmake/CopyDataFile.cmake.in deleted file mode 100644 index 8b13789179..0000000000 --- a/cmake/CopyDataFile.cmake.in +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cmake/Utility.cmake b/cmake/Utility.cmake index e20c4639e1..82aaa1fa15 100644 --- a/cmake/Utility.cmake +++ b/cmake/Utility.cmake @@ -145,16 +145,6 @@ function(download_test_data) file(APPEND "${FETCH_FILE_PATH}" "${FETCH_FILE_CONTENTS}") file(REMOVE "${fetch_data_file}") # Remove the temporary file - if(ARGS_COPY_DATA) - configure_file(${simplnx_SOURCE_DIR}/cmake/CopyDataFile.cmake.in - ${fetch_data_file} - @ONLY - ) - file(READ "${fetch_data_file}" FETCH_FILE_CONTENTS) - file(APPEND "${FETCH_FILE_PATH}" "${FETCH_FILE_CONTENTS}") - file(REMOVE "${fetch_data_file}") - endif() - #----- # If we are installing the data files then we need to create a custom install # rule to ensure the archive contents are actually decompressed and available. Since @@ -162,18 +152,7 @@ function(download_test_data) # location of the data. Running the unit tests might remove the decompressed data # as a by product. if(ARGS_INSTALL) - # If we did NOT already copy the data, then do that now during the build - if(NOT ARGS_COPY_DATA) - configure_file(${simplnx_SOURCE_DIR}/cmake/CopyDataFile.cmake.in - ${fetch_data_file} - @ONLY - ) - file(READ "${fetch_data_file}" FETCH_FILE_CONTENTS) - file(APPEND "${FETCH_FILE_PATH}" "${FETCH_FILE_CONTENTS}") - file(REMOVE "${fetch_data_file}") - endif() - - if(is_multi_config) + if(is_multi_config) set(CX_CONFIG_DIR "$") else() set(CX_CONFIG_DIR ".") diff --git a/src/simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.cpp b/src/simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.cpp index f6e272adc9..d72f9fef30 100644 --- a/src/simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.cpp +++ b/src/simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.cpp @@ -835,7 +835,7 @@ Result<> readLegacyDataArrayDims(const nx::core::HDF5::DatasetReader& dataArrayR return nx::core::MakeWarningVoidResult(Legacy::k_FailedReadingTupleDims_Code, ss); } tDims = tupleAttrib.readAsVector(); - std::reverse(tDims.begin(), tDims.end()); // SIMPL writes the Tuple Dimensions in reverse order to this attribute + // std::reverse(tDims.begin(), tDims.end()); // SIMPL writes the Tuple Dimensions in reverse order to this attribute } return {}; @@ -868,10 +868,19 @@ Result<> readLegacyStringArray(DataStructure& dataStructure, const nx::core::HDF return {}; } -Result readLegacyDataArray(DataStructure& dataStructure, const nx::core::HDF5::DatasetReader& dataArrayReader, DataObject::IdType parentId, bool preflight = false) +/** + * @brief + * @param dataStructure + * @param dataArrayReader + * @param parentId + * @param amTDims + * @param preflight + * @return + */ +Result readLegacyDataArray(DataStructure& dataStructure, const nx::core::HDF5::DatasetReader& dataArrayReader, DataObject::IdType parentId, std::vector& amTDims, + bool preflight = false) { auto size = H5Dget_storage_size(dataArrayReader.getId()); - auto typeId = dataArrayReader.getTypeId(); std::vector tDims; std::vector cDims; @@ -883,6 +892,46 @@ Result readLegacyDataArray(DataStructure& dataStructure, const nx:: } Result daResult; + // Let's do some sanity checking of the tuple dims and the comp dims + // This is here because some 3rd party apps are trying to write .dream3d + // files but are getting confused about the Tuple Dims and the component + // dims. This bit of code will try to fix the specific issue where the + // .dream3d file essentially had _all_ the dimensions shoved in the + // tuple dimensions. + if(!amTDims.empty()) // If the amTDims are empty we are just reading a Data Array without an Attribute Matrix so skip. + { + // + if(tDims.size() > amTDims.size() && cDims.size() == 1 && cDims[0] == 1) + { + daResult.warnings().push_back( + {-9543, fmt::format(".dream3d file Tuple and Component Dimensions are not correct. DataSet {} does not have correct component dimensions of they are missing.", dataArrayReader.getName())}); + cDims.clear(); + // Find the index of the first non-matching dimension value. + for(size_t idx = 0; idx < tDims.size(); idx++) + { + // If we are past the end of the AM Dimensions, then copy the value to the component dimensions + if(idx >= amTDims.size()) + { + cDims.push_back(tDims[idx]); + } + else if(amTDims[idx] != tDims[idx]) // something went wrong here. Each vector should have the same exact values at the start of the vector + { + // The first parts of the dimensions should MATCH for this algorithm to work. + // This should not happen at all. If so, bail out now. + cDims.clear(); // just put things back the way they were and fail. + cDims.push_back(1ULL); + daResult.errors().push_back({-9545, fmt::format(".dream3d file Tuple and Component Dimensions are not correct. DataSet {} does not have correct component dimensions or they are missing. An " + "attempt was made to correct this situation but ultimately failed.", + dataArrayReader.getName())}); + return daResult; + } + } + tDims.resize(amTDims.size()); + } + } + + auto typeId = dataArrayReader.getTypeId(); + if(H5Tequal(typeId, H5T_NATIVE_FLOAT) > 0) { daResult = createLegacyDataArray(dataStructure, parentId, dataArrayReader, tDims, cDims, preflight); @@ -1092,7 +1141,7 @@ Result<> readLegacyAttributeMatrix(DataStructure& dataStructure, const nx::core: } else { - Result<> result = ConvertResult(std::move(readLegacyDataArray(dataStructure, dataArraySet, attributeMatrix->getId(), preflight))); + Result<> result = ConvertResult(std::move(readLegacyDataArray(dataStructure, dataArraySet, attributeMatrix->getId(), tDims, preflight))); daResults.push_back(result); } } @@ -1154,7 +1203,8 @@ void readGenericGeomDims(IGeometry* geom, const nx::core::HDF5::GroupReader& geo Result readLegacyGeomArray(DataStructure& dataStructure, IGeometry* geometry, const nx::core::HDF5::GroupReader& geomGroup, const std::string& arrayName, bool preflight) { auto dataArraySet = geomGroup.openDataset(arrayName); - return readLegacyDataArray(dataStructure, dataArraySet, geometry->getId(), preflight); + std::vector tDims; + return readLegacyDataArray(dataStructure, dataArraySet, geometry->getId(), tDims, preflight); } template