Skip to content

Commit

Permalink
Merge pull request #1410 from fspindle/feat_visp_namespace
Browse files Browse the repository at this point in the history
Introduce visp namespace to protect ViSP classes
  • Loading branch information
fspindle authored Jun 10, 2024
2 parents 1efa2f4 + fd63541 commit 92b1ddc
Show file tree
Hide file tree
Showing 1,318 changed files with 10,377 additions and 5,726 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-dep-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
pwd
echo "GIT_CLONE_PROTECTION_ACTIVE=false" >> $GITHUB_ENV
export GIT_CLONE_PROTECTION_ACTIVE=false
git clone --recursive --depth 1 https://github.com/Kitware/VTK.git ${HOME}/VTK
git clone --recursive --depth 1 --branch v9.3.0 https://github.com/Kitware/VTK.git ${HOME}/VTK
cd ${HOME}/VTK
mkdir build && cd build && mkdir install
cmake .. -DVTK_ANDROID_BUILD=OFF -DVTK_BUILD_DOCUMENTATION=OFF -DVTK_BUILD_EXAMPLES=OFF -DVTK_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release \
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,5 @@
"editor.rulers": [
{"column": 120, "color": "#ffcc00"}
],
"C_Cpp.default.compilerPath": "/usr/bin/g++",
}
25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ VP_OPTION(ENABLE_MOMENTS_COMBINE_MATRICES "" "" "Use linear combination of matr
VP_OPTION(ENABLE_TEST_WITHOUT_DISPLAY "" "" "Don't use display feature when testing" "" ON)
VP_OPTION(ENABLE_FULL_DOC "" "" "Build doc with internal classes that are by default not part of the doc" "" OFF)

# Allow introduction of "visp" namespace. By default disabled to keep compat with previous versions
VP_OPTION(ENABLE_VISP_NAMESPACE "" "" "Enable visp namespace" "" OFF)

if(ENABLE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
Expand Down Expand Up @@ -777,17 +780,18 @@ endif()
# ----------------------------------------------------------------------------
# Build-in 3rd parties. Should be after c++ standard potential modification
# ----------------------------------------------------------------------------
VP_OPTION(WITH_PTHREAD "" "" "Build pthread as built-in library" "" ON IF (WIN32 OR MINGW) AND (NOT WINRT))
VP_OPTION(WITH_PTHREAD "" "" "Use pthread as built-in library" "" ON IF (WIN32 OR MINGW) AND (NOT WINRT))
# Since C99 is not supported by MSVC 2010 or prior, we disable apriltag if MSVC < 2012
VP_OPTION(WITH_APRILTAG "" "" "Build AprilTag as built-in library" "" ON IF (USE_THREADS OR USE_PTHREAD OR WITH_PTHREAD) AND (NOT WINRT) AND (NOT MSVC_VERSION LESS 1700))
VP_OPTION(WITH_APRILTAG_BIG_FAMILY "" "" "Build AprilTag big family (41h12, 48h12, 49h12, 52h13)" "" OFF IF WITH_APRILTAG)
VP_OPTION(WITH_ATIDAQ "" "" "Build atidaq-c as built-in library" "" ON IF USE_COMEDI AND NOT WINRT)
VP_OPTION(WITH_CLIPPER "" "" "Build clipper as built-in library" "" ON IF USE_OPENCV)
VP_OPTION(WITH_LAPACK "" "" "Build lapack as built-in library" "" ON IF NOT USE_LAPACK)
VP_OPTION(WITH_QBDEVICE "" "" "Build qbdevice-api as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS))
VP_OPTION(WITH_TAKKTILE2 "" "" "Build Right Hand takktile2 driver as built-in library" "" ON IF (NOT WIN32) AND (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_APRILTAG "" "" "Use AprilTag as built-in library" "" ON IF (USE_THREADS OR USE_PTHREAD OR WITH_PTHREAD) AND (NOT WINRT) AND (NOT MSVC_VERSION LESS 1700))
VP_OPTION(WITH_APRILTAG_BIG_FAMILY "" "" "Use AprilTag big family (41h12, 48h12, 49h12, 52h13)" "" OFF IF WITH_APRILTAG)
VP_OPTION(WITH_MINIZ "" "" "Use npz related I/O as built-in functions" "" ON)
VP_OPTION(WITH_ATIDAQ "" "" "Use atidaq-c as built-in library" "" ON IF USE_COMEDI AND NOT WINRT)
VP_OPTION(WITH_CLIPPER "" "" "Use clipper as built-in library" "" ON IF USE_OPENCV)
VP_OPTION(WITH_LAPACK "" "" "Use lapack as built-in library" "" ON IF NOT USE_LAPACK)
VP_OPTION(WITH_QBDEVICE "" "" "Use qbdevice-api as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS))
VP_OPTION(WITH_TAKKTILE2 "" "" "Use Right Hand takktile2 driver as built-in library" "" ON IF (NOT WIN32) AND (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_CATCH2 "" "" "Use catch2 built-in library" "" ON)
VP_OPTION(WITH_POLOLU "" "" "Build rapa pololu as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_POLOLU "" "" "Use rapa pololu as built-in library" "" ON IF (NOT WINRT) AND (NOT IOS) AND (NOT ANDROID))
VP_OPTION(WITH_PUGIXML "" "" "Use pugixml built-in third-party" "" ON)
VP_OPTION(WITH_SIMDLIB "" "" "Use simdlib built-in third-party" "" ON)
VP_OPTION(WITH_STBIMAGE "" "" "Use std_image built-in third-party" "" ON)
Expand Down Expand Up @@ -1146,6 +1150,7 @@ VP_SET(VISP_HAVE_SIMDLIB TRUE IF (BUILD_MODULE_visp_core AND WITH_SIMDLIB))
VP_SET(VISP_HAVE_STBIMAGE TRUE IF (BUILD_MODULE_visp_core AND WITH_STBIMAGE))
VP_SET(VISP_HAVE_TINYEXR TRUE IF (BUILD_MODULE_visp_core AND WITH_TINYEXR))
VP_SET(VISP_HAVE_PUGIXML TRUE IF (BUILD_MODULE_visp_core AND WITH_PUGIXML))
VP_SET(VISP_HAVE_MINIZ TRUE IF (BUILD_MODULE_visp_core AND WITH_MINIZ))

VP_SET(VISP_HAVE_QUALISYS TRUE IF (BUILD_MODULE_visp_sensor AND USE_QUALISYS))
VP_SET(VISP_HAVE_VICON TRUE IF (BUILD_MODULE_visp_sensor AND USE_VICON))
Expand Down Expand Up @@ -1603,6 +1608,7 @@ status(" To be built:" VISP_MODULES_BUILD THEN ${VISP_MOD
status(" Disabled:" VISP_MODULES_DISABLED_USER THEN ${VISP_MODULES_DISABLED_USER_ST} ELSE "-")
status(" Disabled by dependency:" VISP_MODULES_DISABLED_AUTO THEN ${VISP_MODULES_DISABLED_AUTO_ST} ELSE "-")
status(" Unavailable:" VISP_MODULES_DISABLED_FORCE THEN ${VISP_MODULES_DISABLED_FORCE_ST} ELSE "-")
status(" Enable visp namespace:" ENABLE_VISP_NAMESPACE THEN "yes" ELSE "no")

# ========================== Android details ==========================
if(ANDROID)
Expand Down Expand Up @@ -1739,6 +1745,7 @@ status(" Use OpenCV:" USE_OPENCV THEN "yes (ver ${OpenCV_VE
status(" Use stb_image (built-in):" WITH_STBIMAGE THEN "yes (ver ${STBIMAGE_VERSION})" ELSE "no")
status(" Use TinyEXR (built-in):" WITH_TINYEXR THEN "yes (ver ${TINYEXR_VERSION})" ELSE "no")
status(" Use simdlib (built-in):" WITH_SIMDLIB THEN "yes" ELSE "no")
status(" Use npz I/O (built-in):" WITH_MINIZ THEN "yes" ELSE "no")
status("")
status(" Real robots: ")
status(" Use Afma4:" USE_AFMA4 THEN "yes" ELSE "no")
Expand Down
1 change: 1 addition & 0 deletions apps/calibration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if(VISP_HAVE_REALSENSE2)
list(APPEND CXX_FLAGS_MUTE_WARNINGS "-Wno-unused-function")
list(APPEND CXX_FLAGS_MUTE_WARNINGS "-Wno-unused-parameter")
list(APPEND CXX_FLAGS_MUTE_WARNINGS "-Wno-unqualified-std-cast-call")
list(APPEND CXX_FLAGS_MUTE_WARNINGS "-Wno-missing-field-initializers")

visp_set_source_file_compile_flag(visp-acquire-franka-calib-data.cpp ${CXX_FLAGS_MUTE_WARNINGS})
visp_set_source_file_compile_flag(visp-acquire-universal-robots-calib-data.cpp ${CXX_FLAGS_MUTE_WARNINGS})
Expand Down
4 changes: 4 additions & 0 deletions apps/calibration/visp-acquire-franka-calib-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <iostream>

#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpXmlParserCamera.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
Expand Down Expand Up @@ -66,6 +67,9 @@ void usage(const char **argv, int error, const std::string &robot_ip)

int main(int argc, const char **argv)
{
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif
try {
std::string opt_robot_ip = "192.168.1.1";

Expand Down
4 changes: 4 additions & 0 deletions apps/calibration/visp-acquire-universal-robots-calib-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <iostream>

#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpXmlParserCamera.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
Expand Down Expand Up @@ -66,6 +67,9 @@ void usage(const char **argv, int error, const std::string &robot_ip)

int main(int argc, const char **argv)
{
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif
try {
std::string opt_robot_ip = "192.168.0.100";

Expand Down
8 changes: 6 additions & 2 deletions apps/calibration/visp-compute-chessboard-poses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
#include <visp3/io/vpVideoReader.h>
#include <visp3/vision/vpPose.h>

#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

namespace
{
void calcChessboardCorners(int width, int height, double squareSize, std::vector<vpPoint> &corners)
Expand Down Expand Up @@ -224,7 +228,7 @@ int main(int argc, const char **argv)
#elif defined(VISP_HAVE_GTK)
display = new vpDisplayGTK(I);
#endif
}
}
#endif

std::vector<vpPoint> corners_pts;
Expand Down Expand Up @@ -335,7 +339,7 @@ int main(int argc, const char **argv)
}
}
#endif
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e.getMessage() << std::endl;
}
Expand Down
5 changes: 5 additions & 0 deletions apps/calibration/visp-compute-hand-eye-calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
//! \example visp-compute-hand-eye-calibration.cpp
#include <map>

#include <visp3/core/vpConfig.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/vision/vpHandEyeCalibration.h>

Expand Down Expand Up @@ -74,6 +75,10 @@ void usage(const char *argv[], int error)

int main(int argc, const char *argv[])
{
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

std::string opt_data_path = "./";
std::string opt_fPe_files = "pose_fPe_%d.yaml";
std::string opt_cPo_files = "pose_cPo_%d.yaml";
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindVirtuose.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ elseif(MSVC)
set(VIRTUOSE_MSVC_RUNTIME VC2017)
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
set(VIRTUOSE_MSVC_RUNTIME VC2019)
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
elseif(MSVC_VERSION MATCHES "^19[34][0-9]$")
set(VIRTUOSE_MSVC_RUNTIME VC2022)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/VISPDetectPlatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ elseif(MSVC)
set(VISP_RUNTIME vc15)
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
set(VISP_RUNTIME vc16)
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
elseif(MSVC_VERSION MATCHES "^19[34][0-9]$")
set(VISP_RUNTIME vc17)
else()
message(WARNING "ViSP does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set VISP_RUNTIME")
Expand Down
2 changes: 2 additions & 0 deletions cmake/templates/VISPConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ set(VISP_BIN_INSTALL_PATH "@VISP_BIN_INSTALL_PATH@")
#----------------------------------------------------------------------
# Remember VISP third party libs configuration
#----------------------------------------------------------------------
set(ENABLE_VISP_NAMESPACE "@ENABLE_VISP_NAMESPACE@")
set(VISP_HAVE_AFMA4 "@VISP_HAVE_AFMA4@")
set(VISP_HAVE_AFMA6 "@VISP_HAVE_AFMA6@")
set(VISP_HAVE_APRILTAG "@VISP_HAVE_APRILTAG@")
Expand Down Expand Up @@ -228,6 +229,7 @@ set(VISP_HAVE_LIBFREENECT_AND_DEPENDENCIES "@VISP_HAVE_LIBFREENECT_AND_DEPENDENC
set(VISP_HAVE_LIBFREENECT_OLD "@VISP_HAVE_LIBFREENECT_OLD@")
set(VISP_HAVE_LIBUSB_1 "@VISP_HAVE_LIBUSB_1@")
set(VISP_HAVE_MAVSDK "@VISP_HAVE_MAVSDK@")
set(VISP_HAVE_MINIZ "@VISP_HAVE_MINIZ@")
set(VISP_HAVE_MKL "@VISP_HAVE_MKL@")
set(VISP_HAVE_NETLIB "@VISP_HAVE_NETLIB@")
set(VISP_HAVE_NULLPTR "@VISP_HAVE_NULLPTR@")
Expand Down
2 changes: 1 addition & 1 deletion cmake/templates/VISPConfig.root-WIN32.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ elseif(MSVC)
set(VISP_RUNTIME vc14) # selecting previous compatible runtime version
endif()
endif()
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
elseif(MSVC_VERSION MATCHES "^19[34][0-9]$")
set(VISP_RUNTIME vc17)
check_one_config(has_VS2022)
if(NOT has_VS2022)
Expand Down
21 changes: 21 additions & 0 deletions cmake/templates/vpConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@
VISP_VERSION_MINOR, \
VISP_VERSION_PATCH)

// Defined if the user wants to protect the classes in a dedicated visp namespace
#cmakedefine ENABLE_VISP_NAMESPACE
#define VISP_NAMESPACE_NAME visp
#ifdef ENABLE_VISP_NAMESPACE
#define VISP_NAMESPACE_ADDRESSING visp::
#define BEGIN_VISP_NAMESPACE namespace visp {
#define END_VISP_NAMESPACE }
// Create an empty namespace to ensure that "using VISP_NAMESPACE_NAME;" does not raise an error
namespace VISP_NAMESPACE_NAME {}

// Create an alias for compatibility with older versions of ViSP
namespace vp = VISP_NAMESPACE_NAME;
#else
#define VISP_NAMESPACE_ADDRESSING
#define BEGIN_VISP_NAMESPACE
#define END_VISP_NAMESPACE
#endif

// Enable debug and trace printings
#cmakedefine VP_TRACE
#cmakedefine VP_DEBUG
Expand Down Expand Up @@ -143,6 +161,9 @@
// Always define pugixml for compatibility.
#cmakedefine VISP_HAVE_PUGIXML

// Defined if basisu_miniz is used internally
#cmakedefine VISP_HAVE_MINIZ

// Defined if XML2 library available.
#cmakedefine VISP_HAVE_XML2

Expand Down
4 changes: 4 additions & 0 deletions demo/wireframe-simulator/servoSimu4Points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@

#if defined(VISP_HAVE_DISPLAY) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))

#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
4 changes: 4 additions & 0 deletions demo/wireframe-simulator/servoSimuCylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@

#if defined(VISP_HAVE_DISPLAY) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))

#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
5 changes: 5 additions & 0 deletions demo/wireframe-simulator/servoSimuSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <stdlib.h>

#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpImage.h>
#include <visp3/core/vpIoTools.h>
Expand All @@ -69,6 +70,10 @@

#if defined(VISP_HAVE_DISPLAY) && (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))

#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

/*!
Print the program options.
Expand Down
1 change: 1 addition & 0 deletions doc/config-doxygen.in
Original file line number Diff line number Diff line change
Expand Up @@ -2390,6 +2390,7 @@ PREDEFINED = @DOXYGEN_SHOULD_SKIP_THIS@ \
VISP_HAVE_LIBFREENECT_AND_DEPENDENCIES \
VISP_HAVE_LIBUSB_1 \
VISP_HAVE_MAVSDK \
VISP_HAVE_MINIZ \
VISP_HAVE_NLOHMANN_JSON \
VISP_HAVE_NULLPTR \
VISP_HAVE_OCCIPITAL_STRUCTURE \
Expand Down
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ visp_add_subdirectory(servo-universal-robots REQUIRED_DEPS visp_core visp_robo
visp_add_subdirectory(servo-viper650 REQUIRED_DEPS visp_core visp_blob visp_vs visp_robot visp_sensor visp_vision visp_gui)
visp_add_subdirectory(servo-viper850 REQUIRED_DEPS visp_core visp_blob visp_vs visp_robot visp_sensor visp_vision visp_gui)
visp_add_subdirectory(tools REQUIRED_DEPS visp_core visp_robot visp_io visp_gui)
visp_add_subdirectory(tracking REQUIRED_DEPS visp_core visp_io visp_gui)
visp_add_subdirectory(tracking REQUIRED_DEPS visp_core visp_core visp_blob visp_io visp_gui visp_mbt visp_me visp_tt visp_tt_mi)
visp_add_subdirectory(video REQUIRED_DEPS visp_core visp_io visp_gui)
visp_add_subdirectory(wireframe-simulator REQUIRED_DEPS visp_core visp_robot visp_io visp_gui)
6 changes: 5 additions & 1 deletion example/calibration/calibrate-camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ void usage(const char *argv[], int error)

int main(int argc, const char *argv[])
{
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

try {
if (argc == 1) {
usage(argv, 0);
Expand Down Expand Up @@ -679,5 +683,5 @@ int main()
std::cout << "pugixml built-in 3rdparty is requested to run the calibration." << std::endl;
#endif
return EXIT_SUCCESS;
}
}
#endif
6 changes: 5 additions & 1 deletion example/calibration/calibrate-hand-eye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <stdio.h>
#include <vector>

#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpExponentialMap.h>
#include <visp3/core/vpIoTools.h>
Expand All @@ -54,6 +55,9 @@
int main()
{
#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
#if defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif
try {
// We want to calibrate the hand-eye extrinsic camera parameters from 6
// couple of poses: cMo and wMe
Expand Down Expand Up @@ -167,4 +171,4 @@ int main()
std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
return EXIT_SUCCESS;
#endif
}
}
Loading

0 comments on commit 92b1ddc

Please sign in to comment.