Skip to content

Commit

Permalink
Merge pull request #331 from favreau/master
Browse files Browse the repository at this point in the history
Boost filesystem cleanup
  • Loading branch information
favreau authored Nov 24, 2023
2 parents faa26d2 + e22e7fd commit 67d3074
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 51 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ set(PACKAGE_REV_STRING "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACK

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
set(${NAME}_MODULES_DIR ${PROJECT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

find_package(Boost REQUIRED COMPONENTS program_options filesystem)
find_package(glm REQUIRED)
find_package(FreeImage REQUIRED)
find_package(ospray)
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ include_directories(

set(${NAME}_LINK_LIBRARIES
PUBLIC ${${NAME}_PUBLIC_MODULE_LIBRARIES}
PRIVATE CoreParameters CoreCommon CoreEngine CoreIO mpfr
${${NAME}_PRIVATE_MODULE_LIBRARIES} ${FreeImage_LIBRARIES} ${PQXX_LIBRARIES} ${OpenMP_CXX_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}
PRIVATE CoreParameters CoreCommon CoreEngine CoreIO mpfr stdc++fs
${${NAME}_PRIVATE_MODULE_LIBRARIES} ${FreeImage_LIBRARIES} ${PQXX_LIBRARIES} ${OpenMP_CXX_LIBRARIES}
)

if(${CGAL_FOUND})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <brion/uri.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <platform/core/common/Timer.h>
#include <platform/core/common/scene/ClipPlane.h>
#include <platform/core/common/utils/Utils.h>
#include <platform/core/engineapi/Material.h>
#include <platform/core/engineapi/Model.h>
#include <platform/core/engineapi/Scene.h>
Expand Down Expand Up @@ -145,8 +146,8 @@ brain::GIDSet AbstractCircuitLoader::_getGids(const PropertyMap &properties, con
// Pair synapse usecase
if (!preSynapticNeuron.empty() && !postSynapticNeuron.empty())
{
gids.insert(boost::lexical_cast<Gid>(preSynapticNeuron));
gids.insert(boost::lexical_cast<Gid>(postSynapticNeuron));
gids.insert(lexical_cast<Gid>(preSynapticNeuron));
gids.insert(lexical_cast<Gid>(postSynapticNeuron));
return gids;
}

Expand Down Expand Up @@ -825,8 +826,8 @@ float AbstractCircuitLoader::_importMorphologies(const PropertyMap &properties,
const auto gid = localGids[morphologyId];
if (prePostSynapticUsecase)
{
synapsesInfo.preGid = boost::lexical_cast<Gid>(preSynapticNeuron);
synapsesInfo.postGid = boost::lexical_cast<Gid>(postSynapticNeuron);
synapsesInfo.preGid = lexical_cast<Gid>(preSynapticNeuron);
synapsesInfo.postGid = lexical_cast<Gid>(postSynapticNeuron);
}
if (loadAfferentSynapses)
synapsesInfo.afferentSynapses =
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/science/atlas/AtlasLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <platform/core/common/Properties.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down Expand Up @@ -76,7 +76,7 @@ ModelDescriptorPtr AtlasLoader::importFromStorage(const std::string& storage, co
props.merge(properties);

details::AtlasDetails details;
const auto baseName = boost::filesystem::basename(storage);
const auto baseName = std::filesystem::path(storage).filename();
details.assemblyName = baseName;
details.cellSqlFilter = props.getProperty<std::string>(LOADER_PROPERTY_ATLAS_CELL_SQL_FILTER.name);
details.regionSqlFilter = props.getProperty<std::string>(LOADER_PROPERTY_ATLAS_REGION_SQL_FILTER.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <platform/core/common/Properties.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down Expand Up @@ -76,7 +76,7 @@ ModelDescriptorPtr WhiteMatterLoader::importFromStorage(const std::string& stora
props.merge(properties);

details::WhiteMatterDetails details;
const auto baseName = boost::filesystem::basename(storage);
const auto baseName = std::filesystem::path(storage).filename();
details.assemblyName = baseName;
details.populationName = baseName;
details.sqlFilter = props.getProperty<std::string>(LOADER_PROPERTY_DATABASE_SQL_FILTER.name);
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/science/morphologies/AstrocytesLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <platform/core/common/Properties.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down Expand Up @@ -76,7 +76,7 @@ ModelDescriptorPtr AstrocytesLoader::importFromStorage(const std::string& storag
props.merge(properties);

details::AstrocytesDetails details;
const auto baseName = boost::filesystem::basename(storage);
const auto baseName = std::filesystem::path(storage).filename();
details.assemblyName = baseName;
details.populationName = baseName;
details.vasculaturePopulationName =
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/science/morphologies/NeuronsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <platform/core/common/Properties.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down Expand Up @@ -76,7 +76,7 @@ ModelDescriptorPtr NeuronsLoader::importFromStorage(const std::string& storage,
props.merge(properties);

details::NeuronsDetails details;
const auto baseName = boost::filesystem::basename(storage);
const auto baseName = std::filesystem::path(storage).filename();
details.assemblyName = baseName;
details.populationName = baseName;
details.sqlNodeFilter = props.getProperty<std::string>(LOADER_PROPERTY_DATABASE_SQL_FILTER.name);
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/science/vasculature/VasculatureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <platform/core/common/Properties.h>

#include <boost/filesystem.hpp>
#include <filesystem>

using namespace core;

Expand Down Expand Up @@ -76,7 +76,7 @@ ModelDescriptorPtr VasculatureLoader::importFromStorage(const std::string& stora
props.merge(properties);

details::VasculatureDetails details;
const auto baseName = boost::filesystem::basename(storage);
const auto baseName = std::filesystem::path(storage).filename();
details.assemblyName = baseName;
details.populationName = baseName;
details.sqlFilter = props.getProperty<std::string>(LOADER_PROPERTY_DATABASE_SQL_FILTER.name);
Expand Down
2 changes: 1 addition & 1 deletion bioexplorer/backend/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ foreach(FILE ${TESTS_SRC})

target_link_libraries(${NAME}
PRIVATE
Core CoreParameters CoreCommon CoreEngine CoreIO OSPRayEngine CorePluginRockets
Core CoreParameters CoreCommon CoreEngine CoreIO OSPRayEngine CorePluginRockets stdc++fs
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${LIBRARY_NAME}
)
Expand Down
77 changes: 58 additions & 19 deletions bioexplorer/pythonsdk/notebooks/widgets/BioExplorer_widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,56 @@
"source": [
"from bioexplorer import BioExplorer, Widgets\n",
"\n",
"url = 'localhost:5000'\n",
"url = 'r5i2n23:5000'\n",
"be = BioExplorer(url)\n",
"w = Widgets(be)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'accumulation': True,\n",
" 'background_color': [1.0, 1.0, 1.0],\n",
" 'current': 'advanced',\n",
" 'head_light': True,\n",
" 'max_accum_frames': 357,\n",
" 'samples_per_pixel': 1,\n",
" 'subsampling': 4,\n",
" 'types': ['advanced',\n",
" 'albedo',\n",
" 'ambient_occlusion',\n",
" 'basic',\n",
" 'bio_explorer_density',\n",
" 'bio_explorer_golgi_style',\n",
" 'bio_explorer_path_tracing',\n",
" 'bio_explorer_voxel',\n",
" 'cell_growth',\n",
" 'depth',\n",
" 'metabolism',\n",
" 'point_fields',\n",
" 'proximity_detection',\n",
" 'radiance',\n",
" 'raycast_Ng',\n",
" 'raycast_Ns',\n",
" 'scivis',\n",
" 'shadow',\n",
" 'vector_fields']}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"be.core_api().get_renderer()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -31,6 +76,15 @@
"w.display_clipping_planes([-50, 50])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"be.core_api().inspect([0.5,0.5])"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -48,31 +102,16 @@
},
"outputs": [],
"source": [
"w.display_focal_distance(with_preview=False)"
"w.display_focal_distance(with_preview=True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "69fcc02ea4a74618a602999313058ed2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Select(description='Models:', options=('Demo scene', 'vasculature', 'astrocytes'…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"w.display_palette_for_models()"
]
Expand Down
1 change: 0 additions & 1 deletion extensions/medicalimaging/dicom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ add_library(

target_link_libraries(
${LIBRARY_NAME}
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}
${${NAME}_LINK_LIBRARIES})

# ================================================================================
Expand Down
10 changes: 5 additions & 5 deletions extensions/medicalimaging/dicom/plugin/io/DICOMLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <dcmtk/dcmdata/dctk.h>
#include <dcmtk/dcmimgle/dcmimage.h>

#include <boost/filesystem.hpp>
#include <filesystem>

namespace medicalimagingexplorer
{
Expand Down Expand Up @@ -210,8 +210,8 @@ DICOMImageDescriptors DICOMLoader::_parseDICOMImagesData(const std::string& file
str.replace(str.find("\\"), 1, "/");

// Full image filename
boost::filesystem::path path = fileName;
boost::filesystem::path folder = path.parent_path();
const std::filesystem::path path = fileName;
const std::filesystem::path folder = path.parent_path();
const std::string imageFileName = std::string(folder.string()) + "/" + str;

// Load image from file
Expand Down Expand Up @@ -413,7 +413,7 @@ ModelDescriptorPtr DICOMLoader::importFromStorage(const std::string& storage, co
const PropertyMap& /*properties*/) const
{
PLUGIN_INFO("Importing DICOM dataset from " << storage);
const auto extension = boost::filesystem::extension(storage);
const auto extension = std::filesystem::path(storage).extension().string();
if (extension == "." + SUPPORTED_EXTENSION_DCM)
return _readFile(storage);
return _readDirectory(storage, callback);
Expand All @@ -436,7 +436,7 @@ std::vector<std::string> DICOMLoader::getSupportedStorage() const

bool DICOMLoader::isSupported(const std::string& storage, const std::string& extension) const
{
const auto basename = boost::filesystem::basename(storage);
const auto basename = std::filesystem::path(storage).filename();
const std::set<std::string> basenames = {SUPPORTED_BASENAME_DICOMDIR};
const std::set<std::string> extensions = {SUPPORTED_EXTENSION_DCM};
return (basenames.find(basename) != basenames.end() || extensions.find(extension) != extensions.end());
Expand Down
1 change: 0 additions & 1 deletion platform/apps/viewer/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set(${NAME}_SOURCES BaseWindow.cpp)
set(${NAME}_PUBLIC_HEADERS BaseWindow.h)
set(${NAME}_LINK_LIBRARIES
PUBLIC Core CoreParameters
${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}
PRIVATE glut ${OPENGL_gl_LIBRARY} ${glew_LIBRARIES}
)

Expand Down
9 changes: 9 additions & 0 deletions platform/core/common/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <platform/core/common/utils/FileSystem.h>

#include <algorithm>
#include <charconv>
#include <cmath>
#include <set>
#include <sstream>
Expand Down Expand Up @@ -134,4 +135,12 @@ Vector3fs getRainbowColormap(const uint32_t colormapSize)
return colormap;
}

template <typename To, typename From>
To lexical_cast(const From& from)
{
To to;
std::from_chars(from.data(), from.data() + from.size(), to);
return to;
}

} // namespace core
11 changes: 11 additions & 0 deletions platform/core/common/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ Vector4f getBezierPoint(const Vector4fs& controlPoints, const float t);
*/
Vector3fs getRainbowColormap(const uint32_t colormapSize);

/**
* @brief Function template taking two template parameters (To and From) representing the source and target types
*
* @tparam To Source type
* @tparam From Destination type
* @param from Input data
* @return To Output data
*/
template <typename To, typename From>
To lexical_cast(const From& from);

} // namespace core
2 changes: 1 addition & 1 deletion platform/core/engineapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ target_link_libraries(
${LIBRARY_NAME}
${${NAME}_LINK_LIBRARIES}
PUBLIC Async++
PRIVATE CoreParameters ${GLM_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${FREEIMAGE_LIBRARIES}
PRIVATE CoreParameters ${GLM_LIBRARIES} ${FREEIMAGE_LIBRARIES}
)

# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion platform/core/manipulators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set(${NAME}_PUBLIC_HEADERS
include_directories(${BIOEXPLORER_SOURCE_DIRS})

set(${NAME}_LINK_LIBRARIES
PRIVATE ${GLM_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}
PRIVATE ${GLM_LIBRARIES}
)

add_library(
Expand Down
2 changes: 1 addition & 1 deletion platform/core/tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(${NAME}_PUBLIC_HEADERS
include_directories(${BIOEXPLORER_SOURCE_DIRS})

set(${NAME}_LINK_LIBRARIES
PRIVATE ${GLM_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}
PRIVATE ${GLM_LIBRARIES}
)

add_library(
Expand Down
2 changes: 1 addition & 1 deletion platform/engines/ospray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ target_link_libraries(
${LIBRARY_NAME}
${${NAME}_LINK_LIBRARIES}
PUBLIC Async++
PRIVATE CoreParameters ${GLM_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${FREEIMAGE_LIBRARIES}
PRIVATE CoreParameters ${GLM_LIBRARIES} ${FREEIMAGE_LIBRARIES}
)

# ==============================================================================
Expand Down
Loading

0 comments on commit 67d3074

Please sign in to comment.