Merge pull request #5351 from sgiraudot/Classification-Fix_boost_optional_dependencies-GF

[Classification] Fix Boost optional dependencies
This commit is contained in:
Laurent Rineau 2021-02-05 16:10:32 +01:00
commit 657dadf718
4 changed files with 48 additions and 58 deletions

View File

@ -290,14 +290,10 @@ public:
The output file is written in a binary format that is readable by The output file is written in a binary format that is readable by
the `load_configuration()` method. the `load_configuration()` method.
*/ */
#if defined(DOXYGEN_RUNNING) || \
(defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \
defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION))
void save_configuration (std::ostream& output) const void save_configuration (std::ostream& output) const
{ {
m_rfc->write(output); m_rfc->write(output);
} }
#endif
/*! /*!
\brief loads a configuration from the stream `input`. \brief loads a configuration from the stream `input`.
@ -314,9 +310,6 @@ public:
format for ETHZ Random Forest changed in CGAL 5.2. format for ETHZ Random Forest changed in CGAL 5.2.
*/ */
#if defined(DOXYGEN_RUNNING) || \
(defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \
defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION))
void load_configuration (std::istream& input) void load_configuration (std::istream& input)
{ {
CGAL::internal::liblearning::RandomForest::ForestParams params; CGAL::internal::liblearning::RandomForest::ForestParams params;
@ -324,7 +317,6 @@ public:
m_rfc->read(input); m_rfc->read(input);
} }
#endif
/// @} /// @}

View File

@ -2,25 +2,14 @@ include(polyhedron_demo_macros)
if(TARGET CGAL::Eigen3_support) if(TARGET CGAL::Eigen3_support)
set(Classification_dependencies_met TRUE)
find_package(Boost OPTIONAL_COMPONENTS serialization iostreams) find_package(Boost OPTIONAL_COMPONENTS serialization iostreams)
include(CGAL_Boost_serialization_support) include(CGAL_Boost_serialization_support)
include(CGAL_Boost_iostreams_support) include(CGAL_Boost_iostreams_support)
if(NOT TARGET CGAL::Boost_serialization_support) if(NOT TARGET CGAL::Boost_serialization_support OR NOT TARGET CGAL::Boost_iostreams_support)
message( message(
STATUS STATUS
"NOTICE: Boost Serialization not found. Classification plugin won't be available." "NOTICE: Boost IO Streams and/or Serialization not found, reading deprecated Classification config files won't be possible."
) )
set(Classification_dependencies_met FALSE)
endif()
if(NOT TARGET CGAL::Boost_iostreams_support)
message(
STATUS
"NOTICE: Boost IOStreams not found. Classification plugin won't be available."
)
set(Classification_dependencies_met FALSE)
endif() endif()
find_package(OpenCV QUIET COMPONENTS core ml) # Need core + machine learning find_package(OpenCV QUIET COMPONENTS core ml) # Need core + machine learning
@ -35,7 +24,6 @@ if(TARGET CGAL::Eigen3_support)
STATUS STATUS
"NOTICE: OpenCV was not found. OpenCV random forest predicate for classification won't be available." "NOTICE: OpenCV was not found. OpenCV random forest predicate for classification won't be available."
) )
endif() endif()
find_package(TensorFlow QUIET) find_package(TensorFlow QUIET)
@ -53,45 +41,48 @@ if(TARGET CGAL::Eigen3_support)
) )
endif() endif()
if(Classification_dependencies_met) qt5_wrap_ui(classificationUI_FILES Classification_widget.ui
qt5_wrap_ui(classificationUI_FILES Classification_widget.ui Classification_advanced_widget.ui)
Classification_advanced_widget.ui) polyhedron_demo_plugin(
polyhedron_demo_plugin( classification_plugin
classification_plugin Classification_plugin
Classification_plugin Point_set_item_classification.cpp
Point_set_item_classification.cpp Cluster_classification.cpp
Cluster_classification.cpp Surface_mesh_item_classification.cpp
Surface_mesh_item_classification.cpp ${classificationUI_FILES}
${classificationUI_FILES} KEYWORDS
KEYWORDS Classification)
Classification) target_link_libraries(
target_link_libraries( classification_plugin
classification_plugin PUBLIC scene_points_with_normal_item
PUBLIC scene_points_with_normal_item scene_polylines_item
scene_polylines_item scene_polygon_soup_item
scene_polygon_soup_item scene_surface_mesh_item
scene_surface_mesh_item scene_selection_item
scene_selection_item scene_color_ramp
scene_color_ramp CGAL::Eigen3_support)
CGAL::Eigen3_support
CGAL::Boost_serialization_support
CGAL::Boost_iostreams_support)
if(OpenCV_FOUND) if(TARGET CGAL::Boost_serialization_support AND TARGET CGAL::Boost_iostreams_support)
target_link_libraries(classification_plugin PUBLIC CGAL::OpenCV_support) target_link_libraries(classification_plugin PUBLIC
endif() CGAL::Boost_serialization_support
if(TensorFlow_FOUND) CGAL::Boost_iostreams_support)
target_link_libraries(classification_plugin
PUBLIC CGAL::TensorFlow_support)
endif()
if(TBB_FOUND)
target_link_libraries(classification_plugin PUBLIC CGAL::TBB_support)
endif()
add_dependencies(classification_plugin point_set_selection_plugin
selection_plugin)
endif() endif()
if(TARGET CGAL::OpenCV_support)
target_link_libraries(classification_plugin PUBLIC CGAL::OpenCV_support)
endif()
if(TARGET CGAL::TensorFlow_support)
target_link_libraries(classification_plugin PUBLIC CGAL::TensorFlow_support)
endif()
if(TARGET CGAL::TBB_support)
target_link_libraries(classification_plugin PUBLIC CGAL::TBB_support)
endif()
add_dependencies(classification_plugin point_set_selection_plugin
selection_plugin)
else() else()
message( message(
STATUS STATUS

View File

@ -708,7 +708,12 @@ public Q_SLOTS:
filename = QFileDialog::getOpenFileName(mw, filename = QFileDialog::getOpenFileName(mw,
tr("Open ETHZ random forest configuration"), tr("Open ETHZ random forest configuration"),
".", ".",
#if defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION)
"ETHZ random forest configuration (*.bin);Deprecated compressed ETHZ random forest configuration (*.gz);All Files (*)"); "ETHZ random forest configuration (*.bin);Deprecated compressed ETHZ random forest configuration (*.gz);All Files (*)");
#else
"ETHZ random forest configuration (*.bin);All Files (*)");
#endif
#ifdef CGAL_LINKED_WITH_OPENCV #ifdef CGAL_LINKED_WITH_OPENCV
else if (classifier == CGAL_CLASSIFICATION_OPENCV_NUMBER) // Random Forest (OpenCV) else if (classifier == CGAL_CLASSIFICATION_OPENCV_NUMBER) // Random Forest (OpenCV)
filename = QFileDialog::getOpenFileName(mw, filename = QFileDialog::getOpenFileName(mw,

View File

@ -235,10 +235,12 @@ public:
m_ethz = new ETHZ_random_forest (m_labels, m_features); m_ethz = new ETHZ_random_forest (m_labels, m_features);
std::ifstream f (filename, std::ios_base::in | std::ios_base::binary); std::ifstream f (filename, std::ios_base::in | std::ios_base::binary);
#if defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION)
// Handle deprecated files // Handle deprecated files
if (std::string(filename).find(".gz") != std::string::npos) if (std::string(filename).find(".gz") != std::string::npos)
m_ethz->load_deprecated_configuration(f); m_ethz->load_deprecated_configuration(f);
else else
#endif
m_ethz->load_configuration (f); m_ethz->load_configuration (f);
} }
else if (classifier == CGAL_CLASSIFICATION_OPENCV_NUMBER) else if (classifier == CGAL_CLASSIFICATION_OPENCV_NUMBER)