diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 8b3fa97567c..00000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,7 +0,0 @@ -# .appveyor.yml is intentionally left blank. -# Checkout .github/workflows/windows.yml instead. - -version: 1.0.{build} -image: -- Visual Studio 2019 -build: off diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000000..2eaa313e0bc --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,57 @@ +name: macOS CI + +on: + push: + branches: + - master + pull_request: + types: [opened, reopened, synchronize] # Rebuild on new pushes to PR + +jobs: + macos: + runs-on: macos-10.15 + strategy: + fail-fast: false + matrix: + BUILD_ML_OPS: [ON, OFF] + env: + SHARED: OFF + NPROC: 2 + BUILD_DEPENDENCY_FROM_SOURCE: OFF + BUILD_CUDA_MODULE: OFF + BUILD_TENSORFLOW_OPS: ${{ matrix.BUILD_ML_OPS }} + BUILD_PYTORCH_OPS: ${{ matrix.BUILD_ML_OPS }} + LOW_MEM_USAGE: ON + steps: + - name: Checkout source code + uses: actions/checkout@v2 + with: + submodules: true + - name: Setup cache + uses: actions/cache@v2 + with: + # Ref: https://github.com/apache/incubator-mxnet/pull/18459/files + path: ~/.ccache + # We include the commit sha in the cache key, as new cache entries are + # only created if there is no existing entry for the key yet. + key: ${{ runner.os }}-ccache-${{ github.sha }} + # Restore any ccache cache entry, if none for + # ${{ runner.os }}-ccache-${{ github.sha }} exists. + # Common prefix will be used so that ccache can be used across commits. + restore-keys: | + ${{ runner.os }}-ccache + - name: Set up Python version + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Install dependencies + run: | + ./util/scripts/install-deps-osx.sh skip-upgrade + brew install ccache + ccache -M 2G # GitHub's total cache limit is 5GB for all OSes. + - name: Config and build + run: | + PATH=/usr/local/var/homebrew/linked/ccache/libexec:$PATH + ccache -s + ./util/scripts/run-ci.sh + ccache -s diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b6f27e9c68a..51e670de66a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -29,6 +29,19 @@ jobs: uses: actions/checkout@v2 with: submodules: true + - name: Setup cache + uses: actions/cache@v2 + with: + # Ref: https://github.com/apache/incubator-mxnet/pull/18459/files + path: ~/.ccache + # We include the commit sha in the cache key, as new cache entries are + # only created if there is no existing entry for the key yet. + key: ${{ runner.os }}-ccache-${{ github.sha }} + # Restore any ccache cache entry, if none for + # ${{ runner.os }}-ccache-${{ github.sha }} exists. + # Common prefix will be used so that ccache can be used across commits. + restore-keys: | + ${{ runner.os }}-ccache - name: Set up Python version uses: actions/setup-python@v2 with: @@ -36,7 +49,12 @@ jobs: # Pre-installed 18.04 packages: https://git.io/JfHmW - name: Install dependencies run: | - ./util/scripts/setup-linux.sh + ./util/scripts/install-deps-ubuntu.sh assume-yes + sudo apt-get --yes install ccache + ccache -M 2G # GitHub's total cache limit is 5GB for all OSes. - name: Config and build run: | + PATH=/usr/lib/ccache:$PATH + ccache -s ./util/scripts/run-ci.sh + ccache -s diff --git a/.travis.yml b/.travis.yml index 60e24bdd868..ccc1ff54d14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,13 @@ matrix: - cmake - clang-7 - clang-format-5.0 - install: ./util/scripts/setup-linux.sh + install: + - ./util/scripts/install-deps-ubuntu.sh assume-yes script: - mkdir build - cd build - cmake .. - - pip install -U yapf==0.28.0 + - pip install -U yapf==0.28.0 nbformat - make check-style # Build headless and docs @@ -57,7 +58,7 @@ matrix: - libosmesa6-dev install: # Install ubuntu dependencies - - ./util/scripts/setup-linux.sh + - ./util/scripts/install-deps-ubuntu.sh assume-yes # Install Kinect k4a package - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - sudo apt-add-repository --yes https://packages.microsoft.com/ubuntu/18.04/prod @@ -97,35 +98,6 @@ matrix: - ./util/scripts/make-documentation.sh - ./.travis/deploy_docs.sh - - os: osx - osx_image: xcode11 - env: BUILD_TENSORFLOW_OPS=ON BUILD_PYTORCH_OPS=ON LOW_MEM_USAGE=ON - install: - - echo "Travis processors:" - - nproc - - brew update - - brew upgrade python || true - #python@3 on Travis is 3.7 - - /usr/local/opt/python@3/bin/pip3 install virtualenv - - /usr/local/opt/python@3/bin/python3 -m venv ~/py3env - - source ~/py3env/bin/activate - - ./util/scripts/install-deps-osx.sh - script: ./util/scripts/run-ci.sh - - - os: osx - osx_image: xcode11.5 - env: BUILD_TENSORFLOW_OPS=OFF BUILD_PYTORCH_OPS=OFF LOW_MEM_USAGE=ON - install: - - echo "Travis processors:" - - nproc - - brew update - - brew upgrade python || true - - /usr/local/opt/python@3.8/bin/pip3 install virtualenv - - /usr/local/opt/python@3.8/bin/python3 -m venv ~/py3env - - source ~/py3env/bin/activate - - ./util/scripts/install-deps-osx.sh - script: ./util/scripts/run-ci.sh - # - env: DOCKER=YES UBUNTU=16.04 BUNDLE=deps ENV=py3 LINK=STATIC # script: ./util/docker/open3d-test/tools/test.sh $UBUNTU $BUNDLE $ENV $LINK # install: sudo apt-get update && sudo apt-get install -y realpath diff --git a/3rdparty/CMake/FindPytorch.cmake b/3rdparty/CMake/FindPytorch.cmake index 014f88a7a0d..bc8a96b11d6 100644 --- a/3rdparty/CMake/FindPytorch.cmake +++ b/3rdparty/CMake/FindPytorch.cmake @@ -46,9 +46,22 @@ if(NOT Pytorch_FOUND) get_target_property( iface_link_libs torch INTERFACE_LINK_LIBRARIES ) string( REPLACE "/usr/local/cuda" "${CUDA_TOOLKIT_ROOT_DIR}" iface_link_libs "${iface_link_libs}" ) set_target_properties( torch PROPERTIES INTERFACE_LINK_LIBRARIES "${iface_link_libs}" ) + if( BUILD_CUDA_MODULE ) + get_target_property( iface_link_libs torch_cuda INTERFACE_LINK_LIBRARIES ) + string( REPLACE "/usr/local/cuda" "${CUDA_TOOLKIT_ROOT_DIR}" iface_link_libs "${iface_link_libs}" ) + set_target_properties( torch_cuda PROPERTIES INTERFACE_LINK_LIBRARIES "${iface_link_libs}" ) + endif() # if successful everything works :) # if unsuccessful CMake will complain that there are no rules to make the targets with the hardcoded paths + if( BUILD_CUDA_MODULE ) + # remove flags that nvcc does not understand + get_target_property( iface_compile_options torch INTERFACE_COMPILE_OPTIONS ) + set_target_properties( torch PROPERTIES INTERFACE_COMPILE_OPTIONS "" ) + set_target_properties( torch_cuda PROPERTIES INTERFACE_COMPILE_OPTIONS "" ) + set_target_properties( torch_cpu PROPERTIES INTERFACE_COMPILE_OPTIONS "" ) + endif() + # Get Pytorch_CXX11_ABI: True/False execute_process( COMMAND diff --git a/3rdparty/CMake/FindTensorflow.cmake b/3rdparty/CMake/FindTensorflow.cmake index b1cf748eab9..7030c4e9cfe 100644 --- a/3rdparty/CMake/FindTensorflow.cmake +++ b/3rdparty/CMake/FindTensorflow.cmake @@ -13,6 +13,13 @@ if(NOT Tensorflow_FOUND) message(STATUS "Getting Tensorflow properties ...") + # Get Tensorflow_VERSION + execute_process( + COMMAND + ${PYTHON_EXECUTABLE} "-c" + "import tensorflow as tf; print(tf.__version__, end='')" + OUTPUT_VARIABLE Tensorflow_VERSION) + # Get Tensorflow_INCLUDE_DIR execute_process( COMMAND @@ -52,7 +59,8 @@ if(NOT Tensorflow_FOUND) ) endif() -message(STATUS "Tensorflow include dir: ${Tensorflow_INCLUDE_DIR}") +message(STATUS "Tensorflow version: ${Tensorflow_VERSION}") +message(STATUS " include dir: ${Tensorflow_INCLUDE_DIR}") message(STATUS " library dir: ${Tensorflow_LIB_DIR}") message(STATUS " framework lib: ${Tensorflow_FRAMEWORK_LIB}") message(STATUS " definitions: ${Tensorflow_DEFINITIONS}") diff --git a/3rdparty/Eigen b/3rdparty/Eigen index d41dc4dd74a..71429883ee4 160000 --- a/3rdparty/Eigen +++ b/3rdparty/Eigen @@ -1 +1 @@ -Subproject commit d41dc4dd74acce21fb210e7625d5d135751fa9e5 +Subproject commit 71429883ee41689fd657cdca824459f38ae53423 diff --git a/3rdparty/filament/filament_download.cmake b/3rdparty/filament/filament_download.cmake index 0fb4420d1b8..27a605d5082 100644 --- a/3rdparty/filament/filament_download.cmake +++ b/3rdparty/filament/filament_download.cmake @@ -1,3 +1,5 @@ +include(FetchContent) + if (FILAMENT_PRECOMPILED_ROOT) if (EXISTS "${FILAMENT_PRECOMPILED_ROOT}") set(FILAMENT_ROOT "${FILAMENT_PRECOMPILED_ROOT}") @@ -5,42 +7,36 @@ if (FILAMENT_PRECOMPILED_ROOT) message(FATAL_ERROR "Filament binaries not found in ${FILAMENT_PRECOMPILED_ROOT}") endif() else() - set(FILAMENT_ROOT ${CMAKE_BINARY_DIR}/downloads/filament) + # Setup download links + if(WIN32) + set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200127-windows.tgz") + set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-windows.tgz") + elseif(APPLE) + set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200127-mac-10.14-resizefix2.tgz") + set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-mac.tgz") + else() + set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200220-linux.tgz") + set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-linux.tgz") + endif() if (USE_VULKAN AND (ANDROID OR WIN32 OR WEBGL OR IOS)) MESSAGE(FATAL_ERROR "Downloadable version of Filament supports vulkan only on Linux and Apple") endif() - if (NOT EXISTS ${FILAMENT_ROOT}/README.md) - set(DOWNLOAD_PATH ${CMAKE_BINARY_DIR}/downloads) - set(TAR_PWD ${DOWNLOAD_PATH}) - - if (NOT EXISTS ${ARCHIVE_FILE}) - set(ARCHIVE_FILE ${CMAKE_BINARY_DIR}/downloads/filament.tgz) - - # Setup download links ============================================================================ - set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200220-linux.tgz") - set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-linux.tgz") - - if (WIN32) - set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200127-windows.tgz") - set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-windows.tgz") - - file(MAKE_DIRECTORY ${FILAMENT_ROOT}) - set(TAR_PWD ${FILAMENT_ROOT}) - elseif (APPLE) - set(DOWNLOAD_URL_PRIMARY "https://storage.googleapis.com/isl-datasets/open3d-dev/filament-20200127-mac-10.14-resizefix2.tgz") - set(DOWNLOAD_URL_FALLBACK "https://github.com/google/filament/releases/download/v1.4.5/filament-20200127-mac.tgz") - endif() - # ================================================================================================= - - file(DOWNLOAD ${DOWNLOAD_URL_PRIMARY} ${ARCHIVE_FILE} SHOW_PROGRESS STATUS DOWNLOAD_RESULT) - if (NOT DOWNLOAD_RESULT EQUAL 0) - file(DOWNLOAD ${DOWNLOAD_URL_FALLBACK} ${ARCHIVE_FILE} SHOW_PROGRESS STATUS DOWNLOAD_RESULT) - endif() - endif() - - execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${ARCHIVE_FILE} WORKING_DIRECTORY ${TAR_PWD}) + FetchContent_Declare( + fetch_filament + URL ${DOWNLOAD_URL_PRIMARY} ${DOWNLOAD_URL_FALLBACK} + ) + + # FetchContent happends at config time. + FetchContent_GetProperties(fetch_filament) + if(NOT fetch_filament_POPULATED) + message(STATUS "Downloading Filament...") + FetchContent_Populate(fetch_filament) + # We use the default download and unpack directories for FetchContent. + message(STATUS "Filament has been downloaded to ${fetch_filament_DOWNLOADED_FILE}.") + message(STATUS "Filament has been extracted to ${fetch_filament_SOURCE_DIR}.") + set(FILAMENT_ROOT "${fetch_filament_SOURCE_DIR}") endif() endif() diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index f86a2eac85f..b6bfa1d61cc 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -48,6 +48,10 @@ find_package(PkgConfig QUIET) # include headers are in the subdirectories . Trailing slashes # have the same meaning as with install(DIRECTORY). must be # relative to the library source directory. +# If your include is "#include " and the path of the file is +# "path/to/libx/x.hpp" then you need to pass "path/to/libx/" +# with the trailing "/". If you have "#include " then you +# need to pass "path/to/libx". # SOURCES [ ...] # the library sources. Can be omitted for header-only libraries. # All sources must be relative to the library source directory. @@ -83,12 +87,12 @@ function(build_3rdparty_library name) else() get_filename_component(incl_path "${incl}" DIRECTORY) endif() - target_include_directories(${name} SYSTEM PUBLIC + target_include_directories(${name} SYSTEM PUBLIC $ ) endforeach() - target_include_directories(${name} PUBLIC - $ + target_include_directories(${name} PUBLIC + $ ) open3d_set_global_properties(${name}) set_target_properties(${name} PROPERTIES @@ -105,12 +109,12 @@ function(build_3rdparty_library name) else() get_filename_component(incl_path "${incl}" DIRECTORY) endif() - target_include_directories(${name} SYSTEM INTERFACE + target_include_directories(${name} SYSTEM INTERFACE $ ) endforeach() target_include_directories(${name} INTERFACE - $ + $ ) endif() if(NOT BUILD_SHARED_LIBS OR arg_PUBLIC) @@ -124,11 +128,11 @@ function(build_3rdparty_library name) foreach(incl IN LISTS include_dirs) if(arg_INCLUDE_ALL) install(DIRECTORY ${incl} - DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/3rdparty + DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty ) else() install(DIRECTORY ${incl} - DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/3rdparty + DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" @@ -182,9 +186,13 @@ endfunction() # HEADER # the library headers belong to the public interface and will be # installed, but the library is linked privately. -# INCLUDE_DIR +# INCLUDE_DIRS # the temporary location where the library headers have been installed. # Trailing slashes have the same meaning as with install(DIRECTORY). +# If your include is "#include " and the path of the file is +# "/path/to/libx/x.hpp" then you need to pass "/path/to/libx/" +# with the trailing "/". If you have "#include " then you +# need to pass "/path/to/libx". # LIBRARIES # the built library name(s). It is assumed that the library is static. # If the library is PUBLIC, it will be renamed to Open3D_${name} at @@ -194,7 +202,7 @@ endfunction() # CMAKE_ARCHIVE_OUTPUT_DIRECTORY. # function(import_3rdparty_library name) - cmake_parse_arguments(arg "PUBLIC;HEADER" "INCLUDE_DIR;LIB_DIR" "LIBRARIES" ${ARGN}) + cmake_parse_arguments(arg "PUBLIC;HEADER" "LIB_DIR" "INCLUDE_DIRS;LIBRARIES" ${ARGN}) if(arg_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Invalid syntax: import_3rdparty_library(${name} ${ARGN})") endif() @@ -202,19 +210,21 @@ function(import_3rdparty_library name) set(arg_LIB_DIR "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") endif() add_library(${name} INTERFACE) - if(arg_INCLUDE_DIR) - if (arg_INCLUDE_DIR MATCHES "(.*)/$") - set(incl_path ${CMAKE_MATCH_1}) - else() - get_filename_component(incl_path "${incl}" DIRECTORY) - endif() - target_include_directories(${name} SYSTEM INTERFACE $) - if(arg_PUBLIC OR arg_HEADER) - install(DIRECTORY ${arg_INCLUDE_DIR} DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/3rdparty - FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" - ) - target_include_directories(${name} INTERFACE $) - endif() + if(arg_INCLUDE_DIRS) + foreach(incl IN LISTS arg_INCLUDE_DIRS) + if (incl MATCHES "(.*)/$") + set(incl_path ${CMAKE_MATCH_1}) + else() + get_filename_component(incl_path "${incl}" DIRECTORY) + endif() + target_include_directories(${name} SYSTEM INTERFACE $) + if(arg_PUBLIC OR arg_HEADER) + install(DIRECTORY ${incl} DESTINATION ${Open3D_INSTALL_INCLUDE_DIR}/open3d/3rdparty + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" + ) + target_include_directories(${name} INTERFACE $) + endif() + endforeach() endif() if(arg_LIBRARIES) list(LENGTH arg_LIBRARIES libcount) @@ -357,7 +367,7 @@ endif() if(BUILD_GLFW) message(STATUS "Building library 3rdparty_glfw3 from source") add_subdirectory(${Open3D_3RDPARTY_DIR}/GLFW) - import_3rdparty_library(3rdparty_glfw3 HEADER INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/GLFW/include/ LIBRARIES glfw3) + import_3rdparty_library(3rdparty_glfw3 HEADER INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/GLFW/include/ LIBRARIES glfw3) add_dependencies(3rdparty_glfw3 glfw) target_link_libraries(3rdparty_glfw3 INTERFACE Threads::Threads) if(UNIX AND NOT APPLE) @@ -425,7 +435,7 @@ if (BUILD_JPEG) message(STATUS "Building third-party library JPEG from source") include(${Open3D_3RDPARTY_DIR}/libjpeg-turbo/libjpeg-turbo.cmake) import_3rdparty_library(3rdparty_jpeg - INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/include/ + INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/include/ LIBRARIES ${JPEG_TURBO_LIBRARIES} LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo-install/lib ) @@ -434,38 +444,17 @@ if (BUILD_JPEG) endif() list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${JPEG_TARGET}") -# jsoncpp -if(NOT BUILD_JSONCPP) - find_package(jsoncpp) - if(TARGET jsoncpp_lib) - message(STATUS "Using installed third-party library jsoncpp") - if(NOT BUILD_SHARED_LIBS) - list(APPEND Open3D_3RDPARTY_EXTERNAL_MODULES "jsoncpp") - endif() - set(JSONCPP_TARGET "jsoncpp_lib") - elseif(TARGET jsoncpp) - message(STATUS "Using installed third-party library jsoncpp") - if(NOT BUILD_SHARED_LIBS) - list(APPEND Open3D_3RDPARTY_EXTERNAL_MODULES "jsoncpp") - endif() - set(JSONCPP_TARGET "jsoncpp") - else() - message(STATUS "Unable to find installed third-party library jsoncpp") - set(BUILD_JSONCPP ON) - endif() -endif() -if(BUILD_JSONCPP) - build_3rdparty_library(3rdparty_jsoncpp DIRECTORY jsoncpp - SOURCES - json_reader.cpp - json_value.cpp - json_writer.cpp - INCLUDE_DIRS - include/ - ) - target_compile_features(3rdparty_jsoncpp PUBLIC cxx_override cxx_noexcept cxx_rvalue_references) - set(JSONCPP_TARGET "3rdparty_jsoncpp") -endif() +# jsoncpp: always compile from source to avoid ABI issues. +build_3rdparty_library(3rdparty_jsoncpp DIRECTORY jsoncpp + SOURCES + json_reader.cpp + json_value.cpp + json_writer.cpp + INCLUDE_DIRS + include/ +) +target_compile_features(3rdparty_jsoncpp PUBLIC cxx_override cxx_noexcept cxx_rvalue_references) +set(JSONCPP_TARGET "3rdparty_jsoncpp") list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${JSONCPP_TARGET}") # liblzf @@ -501,7 +490,7 @@ list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${TRITRIINTERSECT_TARGET}") if (BUILD_LIBREALSENSE) message(STATUS "Building third-party library librealsense from source") add_subdirectory(${Open3D_3RDPARTY_DIR}/librealsense) - import_3rdparty_library(3rdparty_realsense INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/librealsense/include/ LIBRARIES ${REALSENSE_LIBRARY}) + import_3rdparty_library(3rdparty_realsense INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/librealsense/include/ LIBRARIES ${REALSENSE_LIBRARY}) add_dependencies(3rdparty_realsense ${REALSENSE_LIBRARY}) set(LIBREALSENSE_TARGET "3rdparty_realsense") list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS "${LIBREALSENSE_TARGET}") @@ -524,11 +513,11 @@ endif() if(BUILD_PNG) message(STATUS "Building third-party library zlib from source") add_subdirectory(${Open3D_3RDPARTY_DIR}/zlib) - import_3rdparty_library(3rdparty_zlib INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/zlib LIBRARIES ${ZLIB_LIBRARY}) + import_3rdparty_library(3rdparty_zlib INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/zlib LIBRARIES ${ZLIB_LIBRARY}) add_dependencies(3rdparty_zlib ${ZLIB_LIBRARY}) message(STATUS "Building third-party library libpng from source") add_subdirectory(${Open3D_3RDPARTY_DIR}/libpng) - import_3rdparty_library(3rdparty_png INCLUDE_DIR ${Open3D_3RDPARTY_DIR}/libpng/ LIBRARIES ${PNG_LIBRARIES}) + import_3rdparty_library(3rdparty_png INCLUDE_DIRS ${Open3D_3RDPARTY_DIR}/libpng/ LIBRARIES ${PNG_LIBRARIES}) add_dependencies(3rdparty_png ${PNG_LIBRARIES}) target_link_libraries(3rdparty_png INTERFACE 3rdparty_zlib) set(PNG_TARGET "3rdparty_png") @@ -840,7 +829,7 @@ if(ENABLE_GUI) include(${Open3D_3RDPARTY_DIR}/filament/filament_download.cmake) endif() import_3rdparty_library(3rdparty_filament HEADER - INCLUDE_DIR ${FILAMENT_ROOT}/include/ + INCLUDE_DIRS ${FILAMENT_ROOT}/include/ LIB_DIR ${FILAMENT_ROOT}/lib/x86_64 LIBRARIES ${filament_LIBRARIES} ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926fe28101b..6d2f2fb5ae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ * Fixed a bug in open3d::geometry::TriangleMesh::ClusterConnectedTriangles. * Added option BUILD_BENCHMARKS for building microbenchmarks * Extend Python API of UniformTSDFVolume to allow setting the origin - +* Corrected documentation of PointCloud.h ## 0.9.0 * Version bump to 0.9.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index eb2ba045ee0..664cccaf3ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ option(BUILD_FMT "Build fmtlib from source" ON) option(BUILD_GLEW "Build glew from source" OFF) option(BUILD_GLFW "Build glfw from source" OFF) option(BUILD_IMGUI "Build Dear ImGui from source" ON) -option(BUILD_JSONCPP "Build jsoncpp from source" ON) option(BUILD_LIBLZF "Build liblzf from source" ON) option(BUILD_PNG "Build png from source" OFF) option(BUILD_ZLIB "Build zlib from source" OFF) @@ -185,18 +184,28 @@ if (BUILD_CUDA_MODULE) find_package(CUDA REQUIRED) # required for cuda_select_nvcc_arch_flags message(STATUS "Building CUDA enabled") enable_language(CUDA) - # get gencode flags + # Get gencode flags if("${CUDA_ARCH}" STREQUAL "User") cuda_select_nvcc_arch_flags(CUDA_GENCODES "${CUDA_ARCH_USER}") elseif("${CUDA_ARCH}" STREQUAL "BasicPTX") - # include oldest and most recent PTX and rely on JIT compilation + # Include oldest and most recent PTX and rely on JIT compilation set(CUDA_GENCODES "-gencode arch=compute_30,code=compute_30;-gencode arch=compute_75,code=compute_75") else() cuda_select_nvcc_arch_flags(CUDA_GENCODES "${CUDA_ARCH}") endif() - # make CUDA_GENCODES a string to avoid deduplication in target_compile_options + # Make CUDA_GENCODES a string to avoid deduplication in target_compile_options string( REPLACE ";" " " CUDA_GENCODES "${CUDA_GENCODES}") message(STATUS "CUDA_GENCODES: ${CUDA_GENCODES}") + # Allows CUDA headers to be included as "system" headers for CMake prior + # to 3.17, + # https://gitlab.kitware.com/cmake/cmake/-/issues/20270 + # https://github.com/intel-isl/Open3D/issues/2040 + if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) + list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES + ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) + endif() + message(STATUS "CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES: ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") + message(STATUS "CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}") else() set(BUILD_CUDA_MODULE OFF) message(STATUS "No CUDA support") @@ -356,18 +365,36 @@ add_subdirectory(examples) install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: DESTINATION ${Open3D_INSTALL_CMAKE_DIR}) export(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}::) -# `make check-style` errors if styling is not compliant +# `make check-style` checks style for c++/cuda/python/ipynb files add_custom_target(check-style + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/check_style.py + COMMENT "Python executable used for style check: ${PYTHON_EXECUTABLE}." +) + +# `make apply-style` applies style for c++/cuda/python/ipynb files +add_custom_target(apply-style + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/check_style.py --do_apply_style + COMMENT "Python executable used for style check: ${PYTHON_EXECUTABLE}." +) + +# `make check-cpp-style` checks style for c++/cuda files. +# This works outside of python virtualenv. +add_custom_target(check-cpp-style COMMAND ${CMAKE_COMMAND} -DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}" - -P ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/check-style.cmake + -DDO_APPLY_STYLE=OFF + -P ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/check_cpp_style.cmake ) -# `make apply-style` runs clang-format to format all source code -add_custom_target(apply-style +# `make apply-cpp-style` applies style for c++/cuda files. +# This works outside of python virtualenv. +add_custom_target(apply-cpp-style COMMAND ${CMAKE_COMMAND} -DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}" - -P ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/apply-style.cmake + -DDO_APPLY_STYLE=ON + -P ${CMAKE_CURRENT_SOURCE_DIR}/util/scripts/check_cpp_style.cmake ) function(open3d_aligned_print first second) diff --git a/README.md b/README.md index 22c0b6b2c42..ac2a7308ab3 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ data structures and algorithms in both C++ and Python. The backend is highly optimized and is set up for parallelization. We welcome contributions from the open-source community. -[![C/C++ CI](https://github.com/intel-isl/Open3D/workflows/C/C++%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions) +[![Ubuntu CI](https://github.com/intel-isl/Open3D/workflows/Ubuntu%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22Ubuntu+CI%22) +[![macOS CI](https://github.com/intel-isl/Open3D/workflows/macOS%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22macOS+CI%22) +[![Windows CI](https://github.com/intel-isl/Open3D/workflows/Windows%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22Windows+CI%22) [![Build Status](https://travis-ci.org/intel-isl/Open3D.svg?branch=master)](https://travis-ci.org/intel-isl/) -[![Build status](https://ci.appveyor.com/api/projects/status/3hasjo041lv6srsi/branch/master?svg=true)](https://ci.appveyor.com/project/yxlao/open3d/branch/master) **Core features of Open3D include:** diff --git a/cpp/apps/Open3DViewer/Info.plist.in b/cpp/apps/Open3DViewer/Info.plist.in index e1ca5210293..c6d459370d7 100644 --- a/cpp/apps/Open3DViewer/Info.plist.in +++ b/cpp/apps/Open3DViewer/Info.plist.in @@ -44,7 +44,9 @@ CFBundleTypeName GL Transmission Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.gl-transmission-format @@ -62,7 +64,9 @@ CFBundleTypeName GL Binary Transmission Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.gl-binary-transmission-format @@ -79,7 +83,9 @@ CFBundleTypeName Geometry Definition File Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.geometry-definition-format @@ -96,7 +102,9 @@ CFBundleTypeName Object File Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.object-file-format @@ -108,13 +116,34 @@ LSHandlerRank Owner + + CFBundleTypeIconFile + documentIcon + CFBundleTypeName + Point Cloud Library File + CFBundleTypeRole + Editor + LSIsAppleDefaultForType + + LSItemContentTypes + + public.point-cloud-library-file + public.3d-content + public.content + public.data + + LSHandlerRank + Owner + CFBundleTypeIconFile documentIcon CFBundleTypeName Polygon File Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.polygon-file-format @@ -131,7 +160,9 @@ CFBundleTypeName 3D Points File CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.3d-points-format @@ -149,7 +180,9 @@ CFBundleTypeName Standard Tesselated Geometry Format CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.standard-tesselated-geometry-format @@ -166,7 +199,9 @@ CFBundleTypeName XYZ File CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.xyz-points-format @@ -184,7 +219,9 @@ CFBundleTypeName XYZN File CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.xyzn-points-format @@ -202,7 +239,9 @@ CFBundleTypeName XYZ RGB File CFBundleTypeRole - Viewer + Editor + LSIsAppleDefaultForType + LSItemContentTypes public.xyzrgb-points-format @@ -311,6 +350,29 @@ + + UTTypeIdentifier + public.point-cloud-library-file + UTTypeConformsTo + + public.3d-content + public.content + public.data + + UTTypeDescription + Point Cloud Library File + UTTypeTagSpecification + + public.filename-extension + + pcd + + public.mime-type + + model/pcd + + + UTTypeIdentifier public.polygon-file-format diff --git a/cpp/apps/Open3DViewer/Open3DViewer.cpp b/cpp/apps/Open3DViewer/Open3DViewer.cpp index d4efd106382..87c5afa3d81 100644 --- a/cpp/apps/Open3DViewer/Open3DViewer.cpp +++ b/cpp/apps/Open3DViewer/Open3DViewer.cpp @@ -40,26 +40,6 @@ namespace { static const std::string gUsage = "Usage: Open3DViewer [meshfile|pointcloud]"; } // namespace -void LoadAndCreateWindow(const char *path) { - static int x = 50, y = 50; - - bool is_path_valid = (path && path[0] != '\0'); - std::vector> empty; - std::string title = "Open3D"; - if (is_path_valid) { - title += " - "; - title += path; - } - auto vis = - std::make_shared(empty, title, WIDTH, HEIGHT, x, y); - x += 20; // so next window (if any) doesn't hide this one - y += 20; - if (is_path_valid) { - vis->LoadGeometry(path); - } - gui::Application::GetInstance().AddWindow(vis); -} - int Run(int argc, const char *argv[]) { const char *path = nullptr; if (argc > 1) { @@ -72,7 +52,12 @@ int Run(int argc, const char *argv[]) { auto &app = gui::Application::GetInstance(); app.Initialize(argc, argv); - LoadAndCreateWindow(path); + auto vis = std::make_shared("Open3D", WIDTH, HEIGHT); + bool is_path_valid = (path && path[0] != '\0'); + if (is_path_valid) { + vis->LoadGeometry(path); + } + gui::Application::GetInstance().AddWindow(vis); app.Run(); diff --git a/cpp/apps/Open3DViewer/Open3DViewer.h b/cpp/apps/Open3DViewer/Open3DViewer.h index fc4fad9528a..c2385ba2129 100644 --- a/cpp/apps/Open3DViewer/Open3DViewer.h +++ b/cpp/apps/Open3DViewer/Open3DViewer.h @@ -39,4 +39,3 @@ class GuiVisualizer; #define HEIGHT 960 int Run(int argc, const char *argv[]); -void LoadAndCreateWindow(const char *path); diff --git a/cpp/apps/Open3DViewer/Open3DViewer_mac.mm b/cpp/apps/Open3DViewer/Open3DViewer_mac.mm index 4063afa802c..dd1505665d4 100644 --- a/cpp/apps/Open3DViewer/Open3DViewer_mac.mm +++ b/cpp/apps/Open3DViewer/Open3DViewer_mac.mm @@ -27,12 +27,122 @@ #ifdef __APPLE__ #import +#import #include "Open3DViewer.h" +#include "open3d/utility/FileSystem.h" #include "open3d/visualization/gui/Application.h" +#include "open3d/visualization/gui/Button.h" +#include "open3d/visualization/gui/Dialog.h" +#include "open3d/visualization/gui/Label.h" +#include "open3d/visualization/gui/Layout.h" #include "open3d/visualization/gui/Native.h" -#include "open3d/utility/FileSystem.h" +#include "open3d/visualization/gui/Theme.h" +#include "open3d/visualization/visualizer/GuiVisualizer.h" + +// ---------------------------------------------------------------------------- +using namespace open3d::visualization::gui; + +class Open3DVisualizer : public open3d::visualization::GuiVisualizer { + using Super = GuiVisualizer; +public: + Open3DVisualizer() + : open3d::visualization::GuiVisualizer("Open3D", WIDTH, HEIGHT) { + AddItemsToAppMenu({{"Make Default 3D Viewer", MAC_MAKE_DEFAULT_APP}}); + } + +protected: + static constexpr Menu::ItemId MAC_MAKE_DEFAULT_APP = 100; + + void OnMenuItemSelected(Menu::ItemId item_id) override { + if (item_id == MAC_MAKE_DEFAULT_APP) { + auto em = GetTheme().font_size; + auto dlg = std::make_shared("Make Open3D default"); + + auto cancel = std::make_shared