From b70af64836d2e39c6e0fe72cc5ca314050992f92 Mon Sep 17 00:00:00 2001 From: Pavel Skrylev Date: Sun, 18 Feb 2024 19:37:22 +0300 Subject: [PATCH] feat(qpbo): use system qpbo library option + used system qpbo library option ! fixed code to compile QPBO from insource with outsource --- CMakeLists.txt | 12 ++++++++++++ src/CMakeLists.txt | 8 ++++++++ src/uti_phgrm/CPP_Tequila.cpp | 4 ++-- src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp | 2 ++ src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.h | 3 +++ src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_extra.cpp | 2 ++ src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_maxflow.cpp | 2 ++ .../GraphCut/QPBO-v1.4/QPBO_postprocessing.cpp | 2 ++ src/uti_phgrm/GraphCut/QPBO-v1.4/instances.inc | 4 +++- src/uti_phgrm/GraphCut/QPBO-v1.4/qpbo.h | 1 + src/uti_phgrm/Sources.cmake | 8 ++++++-- 11 files changed, 43 insertions(+), 5 deletions(-) create mode 120000 src/uti_phgrm/GraphCut/QPBO-v1.4/qpbo.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3110457628..fd2b83fb32 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,9 @@ option(WITH_OPENCL "Utilisation d'OpenCL" OFF) # Multi thread Poisson avec OpenMP option(WITH_OPEN_MP "use OpenMP" OFF) +# External QPBO library require +option(WITH_QPBO "use external QPBO" OFF) + # print system calls option(TRACE_SYSTEM "print system calls" OFF) @@ -174,6 +177,15 @@ if(WITH_OPEN_MP) set(USE_OPEN_MP 1) endif() +if(WITH_QPBO) + FIND_PACKAGE(qpbo REQUIRED) + if(NOT qpbo_FOUND) + message(FATAL_ERROR "QPBO library package wasn't found. Please disable QPBO with -DWITH_QPBO=OFF") + endif() +else(WITH_QPBO) + message(STATUS "System QPBO was disabled, using embedded one") +endif(WITH_QPBO) + ###################################### ## Trouver les EXES et Libs ## ###################################### diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a6a732a50..bfdac6fd31 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -170,6 +170,14 @@ else() add_library(${libElise} ${Elise_Src_Files} ${QT_ALLFILES}) endif() +if(qpbo_FOUND) + string(APPEND CMAKE_C_FLAGS " ${qpbo_C_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " ${qpbo_CXX_FLAGS}") + target_link_libraries(${libElise} "${qpbo_LD_FLAGS}") +else(qpbo_FOUND) + target_include_directories(${libElise} PUBLIC "$") +endif(qpbo_FOUND) + if(QT_ENABLED) target_link_libraries(${libElise} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Xml Qt5::Concurrent Qt5::OpenGL) add_subdirectory(saisieQT) diff --git a/src/uti_phgrm/CPP_Tequila.cpp b/src/uti_phgrm/CPP_Tequila.cpp index dd553fcc9e..f428bfe6d9 100755 --- a/src/uti_phgrm/CPP_Tequila.cpp +++ b/src/uti_phgrm/CPP_Tequila.cpp @@ -38,7 +38,7 @@ English : Header-MicMac-eLiSe-25/06/2007*/ #include "StdAfx.h" #include "TexturePacker/TexturePacker.h" -#include "GraphCut/QPBO-v1.4/QPBO.h" +#include "qpbo.h" void LoadTrScaleRotate ( @@ -558,7 +558,7 @@ int Tequila_main(int argc,char ** argv) for(int aCam=0; aCam< nCam;++aCam) { - QPBO* q = new QPBO(nTriangles, nEdges); // max number of nodes & edges + qpbo::QPBO* q = new qpbo::QPBO(nTriangles, nEdges); // max number of nodes & edges set vTri; cZBuf *aZBuffer = aZBufManager.getZBuf(aCam); diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp index b5600dde89..1c61691367 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.cpp @@ -24,6 +24,8 @@ #include "QPBO.h" +using namespace qpbo; + template QPBO::QPBO(int node_num_max, int edge_num_max, void (*err_function)(const char *)) : node_num(0), diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.h b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.h index f0759fd383..d68715d7be 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.h +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO.h @@ -121,6 +121,7 @@ // #define code_assert(ignore)((void) 0) +namespace qpbo { // REAL: can be int, float, double. // Current instantiations are in instances.inc @@ -804,6 +805,8 @@ template } } +} // end namespace qpbo + /* special constants for node->parent */ diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_extra.cpp b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_extra.cpp index cfc732b897..a8961f9260 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_extra.cpp +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_extra.cpp @@ -28,6 +28,8 @@ #undef REAL #endif +using namespace qpbo; + ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_maxflow.cpp b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_maxflow.cpp index f62f391765..e74eb7e894 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_maxflow.cpp +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_maxflow.cpp @@ -22,6 +22,8 @@ #include #include "QPBO.h" +using namespace qpbo; + #ifdef REAL #undef REAL #endif diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_postprocessing.cpp b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_postprocessing.cpp index cdcf751d61..2c8c51ae9a 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_postprocessing.cpp +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/QPBO_postprocessing.cpp @@ -28,6 +28,8 @@ #undef REAL #endif +using namespace qpbo; + template void QPBO::ComputeWeakPersistencies() { diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/instances.inc b/src/uti_phgrm/GraphCut/QPBO-v1.4/instances.inc index 048bdf85de..3f3e0223ed 100755 --- a/src/uti_phgrm/GraphCut/QPBO-v1.4/instances.inc +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/instances.inc @@ -6,6 +6,8 @@ // Instantiations +namespace qpbo { + template <> inline void QPBO::get_type_information(const char*& type_name, const char*& type_format) { @@ -31,4 +33,4 @@ template class QPBO; template class QPBO; template class QPBO; - +} // end namespace qpbo diff --git a/src/uti_phgrm/GraphCut/QPBO-v1.4/qpbo.h b/src/uti_phgrm/GraphCut/QPBO-v1.4/qpbo.h new file mode 120000 index 0000000000..f3464b2828 --- /dev/null +++ b/src/uti_phgrm/GraphCut/QPBO-v1.4/qpbo.h @@ -0,0 +1 @@ +QPBO.h \ No newline at end of file diff --git a/src/uti_phgrm/Sources.cmake b/src/uti_phgrm/Sources.cmake index 0f33baee26..713758d8fc 100755 --- a/src/uti_phgrm/Sources.cmake +++ b/src/uti_phgrm/Sources.cmake @@ -22,7 +22,9 @@ set(UTI_PHGRM_SAT_PHYS_MOD ${UTI_PHGRM_DIR}/SatPhysMod) set(UTI_PHGRM_TEXT_DIR ${UTI_PHGRM_DIR}/TexturePacker) set(UTI_PHGRM_MAXFLOW_DIR ${UTI_PHGRM_GRAPHCUT_DIR}/MaxFlow) -set(UTI_PHGRM_QPBO_DIR ${UTI_PHGRM_GRAPHCUT_DIR}/QPBO-v1.4) +if(NOT QPBO_FOUND) + set(UTI_PHGRM_QPBO_DIR ${UTI_PHGRM_GRAPHCUT_DIR}/QPBO-v1.4) +endif(NOT QPBO_FOUND) set(UTI_PHGRM_SAT4GEO_DIR ${UTI_PHGRM_DIR}/SAT4GEO) set(SrcGrp_Uti_PHGRM uti_phgrm) @@ -31,7 +33,9 @@ set(SrcGrp_Graph_Cut uti_phgrm/GraphCut) include(${UTI_PHGRM_APERO_DIR}/Sources.cmake) include(${UTI_PHGRM_MICMAC_DIR}/Sources.cmake) include(${UTI_PHGRM_MAXFLOW_DIR}/Sources.cmake) -include(${UTI_PHGRM_QPBO_DIR}/Sources.cmake) +if(NOT QPBO_FOUND) + include(${UTI_PHGRM_QPBO_DIR}/Sources.cmake) +endif(NOT QPBO_FOUND) include(${UTI_PHGRM_REDUCHOM_DIR}/Sources.cmake) include(${UTI_PHGRM_RHH_DIR}/Sources.cmake) include(${UTI_PHGRM_PORTO_DIR}/Sources.cmake)