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: Fix multiple compiler warnings and other small issues #1108

Merged
Merged
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
7 changes: 0 additions & 7 deletions cmake/CopyDataFile.cmake.in

This file was deleted.

10 changes: 8 additions & 2 deletions cmake/FetchDataFile.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand All @@ -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)
Expand All @@ -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()
23 changes: 1 addition & 22 deletions cmake/Utility.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -145,35 +145,14 @@ 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
# we are possibly making a copy into the binary directory, use that as the source
# 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 "$<CONFIG>")
else()
set(CX_CONFIG_DIR ".")
Expand Down
44 changes: 22 additions & 22 deletions src/Plugins/SimplnxCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -466,35 +466,35 @@ 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
SHA512 6a17caa1c5b60740a18d30732b10139b5864e12abd5009ce482972f4070f86e1762a3bf2bbceb8f178187b4d70bedbde1516f32397c3d4424404557b320dde9d
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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Result<> CreateAMScanPaths::operator()()
char good = determineIntersectCoord(p1, p2, vert1, vert2, coord);
if(good == 'i')
{
intersectionCoords.insert(std::pair<float, usize>(coord, 0));
intersectionCoords.insert(std::pair<float, usize>(coord, 0ULL));
}
else if(good == 'c' || good == 'd')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ IFilter::PreflightResult CreateDataArrayAdvancedFilter::preflightImpl(const Data
usize numComponents = std::accumulate(compDims.begin(), compDims.end(), static_cast<usize>(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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Parameters DBSCANFilter::parameters() const

params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
params.insert(std::make_unique<BoolParameter>(k_UsePrecaching_Key, "Use Precaching", "If true the algorithm will be significantly faster, but it requires more memory", true));
params.insert(std::make_unique<Float32Parameter>(k_Epsilon_Key, "Epsilon", "The epsilon-neighborhood around each point is queried", 0.0001));
params.insert(std::make_unique<Float32Parameter>(k_Epsilon_Key, "Epsilon", "The epsilon-neighborhood around each point is queried", 0.0001f));
params.insert(std::make_unique<Int32Parameter>(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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Parameters SliceTriangleGeometryFilter::parameters() const
params.insertLinkableParameter(std::make_unique<ChoicesParameter>(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<Float32Parameter>(k_Zstart_Key, "Slicing Start", "The z axis start value", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0));
params.insert(std::make_unique<Float32Parameter>(k_Zend_Key, "Slicing End", "The z axis stop value", 0.0f));
params.insert(std::make_unique<Float32Parameter>(k_SliceResolution_Key, "Slice Spacing", "The spacing between slices", 1.0f));

params.insertSeparator(Parameters::Separator{"Input Geometry"});
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SimplnxCore/test/DBSCANTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChoicesParameter::ValueType>(to_underlying(AlgType::Iterative)));
args.insertOrAssign(DBSCANFilter::k_UsePrecaching_Key, std::make_any<bool>(true));
args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any<float32>(0.01));
args.insertOrAssign(DBSCANFilter::k_Epsilon_Key, std::make_any<float32>(0.01f));
args.insertOrAssign(DBSCANFilter::k_MinPoints_Key, std::make_any<int32>(50));
args.insertOrAssign(DBSCANFilter::k_UseMask_Key, std::make_any<bool>(false));
args.insertOrAssign(DBSCANFilter::k_SelectedArrayPath_Key, std::make_any<DataPath>(k_TargetArrayPath));
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/DataStructure/IO/HDF5/DataStructureWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Utilities/ClusteringUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace nx::core::ClusterUtilities
{
enum SIMPLNX_EXPORT DistanceMetric
enum DistanceMetric
{
Euclidean,
SquaredEuclidean,
Expand Down
60 changes: 55 additions & 5 deletions src/simplnx/Utilities/Parsing/DREAM3D/Dream3dIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ Result<> readLegacyDataArrayDims(const nx::core::HDF5::DatasetReader& dataArrayR
return nx::core::MakeWarningVoidResult(Legacy::k_FailedReadingTupleDims_Code, ss);
}
tDims = tupleAttrib.readAsVector<usize>();
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 {};
Expand Down Expand Up @@ -868,10 +868,19 @@ Result<> readLegacyStringArray(DataStructure& dataStructure, const nx::core::HDF
return {};
}

Result<IDataArray*> 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<IDataArray*> readLegacyDataArray(DataStructure& dataStructure, const nx::core::HDF5::DatasetReader& dataArrayReader, DataObject::IdType parentId, std::vector<uint64>& amTDims,
bool preflight = false)
{
auto size = H5Dget_storage_size(dataArrayReader.getId());
auto typeId = dataArrayReader.getTypeId();

std::vector<usize> tDims;
std::vector<usize> cDims;
Expand All @@ -883,6 +892,46 @@ Result<IDataArray*> readLegacyDataArray(DataStructure& dataStructure, const nx::
}

Result<IDataArray*> 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.
imikejackson marked this conversation as resolved.
Show resolved Hide resolved
{
//
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<float32>(dataStructure, parentId, dataArrayReader, tDims, cDims, preflight);
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -1154,7 +1203,8 @@ void readGenericGeomDims(IGeometry* geom, const nx::core::HDF5::GroupReader& geo
Result<IDataArray*> 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<uint64> tDims;
return readLegacyDataArray(dataStructure, dataArraySet, geometry->getId(), tDims, preflight);
}

template <typename T>
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
set_target_properties(Copy_simplnx_Test_Data PROPERTIES FOLDER ZZ_COPY_FILES)
4 changes: 4 additions & 0 deletions wrapping/python/docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand All @@ -62,6 +64,7 @@ add_custom_target(sphinx_generate_plugin_rst ALL
COMMAND "$<TARGET_FILE:generate_sphinx_docs>"
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
Expand Down Expand Up @@ -103,3 +106,4 @@ else()
WORKING_DIRECTORY "${SIMPLNX_SPHINX_DOCS_DIR}"
)
endif()
set_target_properties(sphinx_docs_generation PROPERTIES FOLDER simplnx_Python__Documentation)
Loading