Skip to content

Commit

Permalink
Merge pull request #1437 from PFasano99/devel
Browse files Browse the repository at this point in the history
filter_embree
  • Loading branch information
alemuntoni authored Oct 25, 2023
2 parents f43e829 + 23070c9 commit cc86319
Show file tree
Hide file tree
Showing 13 changed files with 589 additions and 7 deletions.
14 changes: 13 additions & 1 deletion scripts/Linux/0_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

DONT_INSTALL_QT=false
DONT_INSTALL_CGAL_BOOST=false
DONT_INSTALL_EMBREE=false

#checking for parameters
for i in "$@"
Expand All @@ -19,6 +20,10 @@ case $i in
DONT_INSTALL_CGAL_BOOST=true
shift # past argument=value
;;
--dont_install_embree)
DONT_INSTALL_EMBREE=true
shift # past argument=value
;;
*)
# unknown option
;;
Expand All @@ -30,7 +35,7 @@ echo "=== installing mesa packages..."
sudo apt-get install -y mesa-common-dev libglu1-mesa-dev

echo "=== installing cmake, patchelf, gmp, mpfr and xcerces-c..."
sudo apt-get install -y cmake ninja-build patchelf libgmp-dev libmpfr-dev libxerces-c-dev
sudo apt-get install -y cmake ninja-build patchelf libgmp-dev libmpfr-dev libxerces-c-dev libtbb-dev

if [ "$DONT_INSTALL_QT" = false ] ; then
echo "=== installing qt packages..."
Expand All @@ -50,3 +55,10 @@ if [ "$DONT_INSTALL_CGAL_BOOST" = false ] ; then
else
echo "=== jumping installation of cgal and boost packages..."
fi

if [ "$DONT_INSTALL_EMBREE" = false ] ; then
echo "=== installing embree..."
sudo apt-get install -y libembree-dev
else
echo "=== jumping installation of embree package..."
fi
2 changes: 1 addition & 1 deletion scripts/macOS/0_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case $i in
esac
done

brew install coreutils node cmake ninja libomp cgal xerces-c
brew install coreutils node cmake ninja llvm libomp cgal xerces-c tbb embree
npm install -g appdmg

if [ "$DONT_INSTALL_QT" = false ] ; then
Expand Down
15 changes: 15 additions & 0 deletions scripts/macOS/1_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BUILD_PATH=$SOURCE_PATH/build
INSTALL_PATH=$SOURCE_PATH/install
DOUBLE_PRECISION_OPTION=""
NIGHTLY_OPTION=""
USE_BREW_LLVM=false
QT_DIR=""
CCACHE=""

Expand Down Expand Up @@ -38,6 +39,10 @@ case $i in
QT_DIR=${i#*=}
shift # past argument=value
;;
--use_brew_llvm)
USE_BREW_LLVM=true
shift # past argument=value
;;
--ccache)
CCACHE="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
shift # past argument=value
Expand Down Expand Up @@ -65,6 +70,16 @@ then
export Qt5_DIR=$QT_DIR
fi

if [ "$USE_BREW_LLVM" = true ] ; then
export PATH="$(brew --prefix llvm)/bin:$PATH";
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export COMPILER=${CXX}
export CFLAGS="-I /usr/local/include -I/usr/local/opt/llvm/include"
export CXXFLAGS="-I /usr/local/include -I/usr/local/opt/llvm/include"
export LDFLAGS="-L /usr/local/lib -L/usr/local/opt/llvm/lib"
fi

BUILD_PATH=$(realpath $BUILD_PATH)
INSTALL_PATH=$(realpath $INSTALL_PATH)

Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ if(NOT DEFINED MESHLAB_PLUGINS) # it may be already defined in parent directory
meshlabplugins/filter_cubization
meshlabplugins/filter_developability
meshlabplugins/filter_dirt
meshlabplugins/filter_embree
meshlabplugins/filter_fractal
meshlabplugins/filter_func
meshlabplugins/filter_func
meshlabplugins/filter_img_patch_param
meshlabplugins/filter_icp
meshlabplugins/filter_io_nxs
Expand Down
3 changes: 3 additions & 0 deletions src/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ if ((NOT MESHLAB_BUILD_MINI) AND MESHLAB_ALLOW_OPTIONAL_EXTERNAL_LIBRARIES)
# cgal - optional for filter_mesh_booleans
include(${CMAKE_CURRENT_SOURCE_DIR}/cgal.cmake)

# embree - optional for filter_embree
include(${CMAKE_CURRENT_SOURCE_DIR}/embree.cmake)

# levmar - optional, for several plugins
include(${CMAKE_CURRENT_SOURCE_DIR}/levmar.cmake)

Expand Down
131 changes: 131 additions & 0 deletions src/external/embree.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Copyright 2019, 2021, Collabora, Ltd.
# Copyright 2019, 2021, Visual Computing Lab, ISTI - Italian National Research Council
# SPDX-License-Identifier: BSL-1.0
option(MESHLAB_ALLOW_DOWNLOAD_SOURCE_EMBREE "Allow download and use of embree source (linux only)" ON)
option(MESHLAB_ALLOW_DOWNLOAD_DLL_EMBREE "Allow download and use of embree dll (windows only)" ON)
option(MESHLAB_ALLOW_SYSTEM_EMBREE "Allow use of system-provided embree" ON)

# looking for embree for the filter_embree
find_package(embree 3.0)
find_package(TBB)

if(MESHLAB_ALLOW_SYSTEM_EMBREE AND TARGET embree AND TBB_FOUND)
message(STATUS "- embree - using system-provided library")
add_library(external-embree INTERFACE)
target_link_libraries(external-embree INTERFACE embree tbb)
elseif(MESHLAB_ALLOW_DOWNLOAD_DLL_EMBREE AND WIN32)
set(EMBREE_WIN_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/embree-3.13.5.x64.vc14.windows")
set(EMBREE_WIN_CHECK "${EMBREE_WIN_DIR}/lib/embree3.lib")
set(TBB_WIN_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/oneapi-tbb-2021.6.0")
set(TBB_WIN_CHECK "${TBB_WIN_DIR}/lib/cmake/tbb/TBBConfig.cmake")

if (NOT EXISTS ${TBB_WIN_CHECK})
set(TBB_WIN_LINK https://github.com/oneapi-src/oneTBB/releases/download/v2021.6.0/oneapi-tbb-2021.6.0-win.zip)
#set(TBB_WIN_MD5 )
download_and_unzip(
NAME "TBB"
LINK ${TBB_WIN_LINK}
#MD5 ${TBB_WIN_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR})
if (NOT download_and_unzip_SUCCESS)
message(STATUS "- TBB - download failed.")
endif()
endif()

if(NOT EXISTS ${EMBREE_WIN_CHECK})
set(EMBREE_WIN_LINK https://github.com/embree/embree/releases/download/v3.13.5/embree-3.13.5.x64.vc14.windows.zip)
#set(EMBREE_WIN_MD5 )
download_and_unzip(
NAME "embree dll"
LINK ${EMBREE_WIN_LINK}
#MD5 ${EMBREE_WIN_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR})
if (NOT download_and_unzip_SUCCESS)
message(STATUS "- embree dll - download failed.")
endif()
endif()

if (EXISTS ${TBB_WIN_CHECK} AND EXISTS ${EMBREE_WIN_CHECK})
message(STATUS "- embree - using downloaded dll")

set(TBB_DIR "${TBB_WIN_DIR}/lib/cmake/tbb")
set(embree_DIR "${EMBREE_WIN_DIR}/lib/cmake/embree-3.13.5")
find_package(embree)

add_library(external-embree INTERFACE)
target_link_libraries(external-embree INTERFACE embree)

if (DEFINED MESHLAB_LIB_OUTPUT_DIR)
file(
COPY
${EMBREE_WIN_DIR}/bin/embree3.dll
${EMBREE_WIN_DIR}/bin/tbb12.dll
DESTINATION
${MESHLAB_LIB_OUTPUT_DIR})
endif()
if (DEFINED MESHLAB_LIB_INSTALL_DIR)
install(
FILES
${EMBREE_WIN_DIR}/bin/embree3.dll
${EMBREE_WIN_DIR}/bin/tbb12.dll
DESTINATION
${MESHLAB_LIB_INSTALL_DIR})
endif()
endif()
elseif(MESHLAB_ALLOW_DOWNLOAD_SOURCE_EMBREE AND (UNIX AND NOT APPLE))
set(EMBREE_SRC_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/embree-3.13.5")
set(EMBREE_CHECK "${EMBREE_SRC_DIR}/CMakeLists.txt")
set(ISPC_DIR "${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/ispc-v1.18.1-linux")
set(ISPC_CHECK "${ISPC_DIR}/bin/ispc")

if (NOT EXISTS ${ISPC_CHECK})
set(ISPC_LINK
https://github.com/ispc/ispc/releases/download/v1.18.1/ispc-v1.18.1-linux.tar.gz)
#set(ISPC_MD5 )
download_and_unzip(
NAME "embree ispc"
LINK ${ISPC_LINK}
#MD5 ${ISPC_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR})
if (NOT download_and_unzip_SUCCESS)
message(STATUS "- embree ispc - download failed.")
endif()
endif()

if (NOT EXISTS ${EMBREE_CHECK})
set(EMBREE_LINK
https://github.com/embree/embree/archive/refs/tags/v3.13.5.zip)
#set(EMBREE_MD5 )
download_and_unzip(
NAME "embree"
LINK ${EMBREE_LINK}
#MD5 ${EMBREE_MD5}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR})
if (NOT download_and_unzip_SUCCESS)
message(STATUS "- embree - download failed.")
endif()
endif()

if (EXISTS ${EMBREE_CHECK})
message(STATUS "- embree - using downloaded source")

if (EXISTS ${ISPC_CHECK})
set(EMBREE_ISPC_EXECUTABLE ${ISPC_CHECK})
else()
set(EMBREE_ISPC_SUPPORT OFF)
endif()

set(EMBREE_TUTORIALS OFF)

set(MESSAGE_QUIET ON)
add_subdirectory(${EMBREE_SRC_DIR} EXCLUDE_FROM_ALL)
unset(MESSAGE_QUIET)

add_library(external-embree INTERFACE)
target_link_libraries(external-embree INTERFACE embree)

install(TARGETS embree DESTINATION ${MESHLAB_LIB_INSTALL_DIR})
endif()
else()
message(STATUS "- embree - skipping embree library")
endif()
6 changes: 6 additions & 0 deletions src/external/qhull.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ elseif(MESHLAB_ALLOW_DOWNLOAD_SOURCE_QHULL)
if (EXISTS ${QHULL_CHECK})
message(STATUS "- qhull - using downloaded source")

# remove target uninstall to avoid duplicates
# todo - make PR to Qhull to solve this
file(READ "${QHULL_DIR}/CMakeLists.txt" FILE_CONTENTS)
string(REPLACE "uninstall" "qhull-uninstall" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE "${QHULL_DIR}/CMakeLists.txt" "${FILE_CONTENTS}")

set(MESSAGE_QUIET ON)
add_subdirectory(${QHULL_DIR} EXCLUDE_FROM_ALL)
unset(MESSAGE_QUIET)
Expand Down
2 changes: 1 addition & 1 deletion src/meshlabplugins/filter_ao/filter_ao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ QString AmbientOcclusionPlugin::filterName(ActionIDType filterId) const
QString AmbientOcclusionPlugin::pythonFilterName(ActionIDType f) const
{
switch (f) {
case FP_AMBIENT_OCCLUSION: return QString("compute_scalar_ambient_occlusion");
case FP_AMBIENT_OCCLUSION: return QString("compute_scalar_ambient_occlusion_gpu");
default: assert(0); return QString();
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/meshlabplugins/filter_embree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0

if (TARGET external-embree)
set(SOURCES filter_embree.cpp)

set(HEADERS filter_embree.h)

add_meshlab_plugin(filter_embree ${SOURCES} ${HEADERS})

target_link_libraries(filter_embree PRIVATE external-embree OpenMP::OpenMP_CXX)
else()
message(
STATUS "Skipping filter_embree - don't know about embree or omp on this system.")
endif()
Loading

0 comments on commit cc86319

Please sign in to comment.