Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions .github/workflows/continuous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,29 @@ jobs:
echo "disk usage:"
df -h

- name: Select build dir (Linux)
if: runner.os == 'Linux'
# Find mount point with the largest available space for our build dir...
run: |
space_cwd=$(df --output=avail . | tail -1 | tr -d ' ')
space_mnt=$(df --output=avail /mnt 2>/dev/null | tail -1 | tr -d ' ')
echo "Space available on ./: $space_cwd KB"
echo "Space available on /mnt: $space_mnt KB"
if [ -n "$space_mnt" ] && [ "$space_mnt" -gt "$space_cwd" ]; then
echo "build_dir=/mnt/build" >> "$GITHUB_ENV"
echo "Selected /mnt/build (/mnt has $((space_mnt/1024/1024)) GB free vs ./ has $((space_cwd/1024/1024)) GB free)"
sudo mkdir -p /mnt/build
sudo chown $USER /mnt/build
else
echo "build_dir=build" >> "$GITHUB_ENV"
echo "Selected ./build (./ has $((space_cwd/1024/1024)) GB free)"
fi

- name: Select build dir (macOS)
if: runner.os == 'macOS'
run:
echo "build_dir=build" >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v4
# Note: Update to actions/checkout@6 once 6.0.2 is out, and remove the fetch-depth: 0
Expand Down Expand Up @@ -128,10 +151,8 @@ jobs:

- name: Configure
run: |
mkdir -p build
cd build
cmake --version
cmake .. -G Ninja \
cmake -B ${{ env.build_dir }} -S . -G Ninja \
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-DLAGRANGE_JENKINS=ON \
-DLAGRANGE_ALL=ON \
Expand All @@ -144,7 +165,7 @@ jobs:

- name: Build
run: |
cmake --build build -j ${{ steps.cpu-cores.outputs.count }}
cmake --build ${{ env.build_dir }} -j ${{ steps.cpu-cores.outputs.count }}
ccache --show-stats

- name: Show disk space
Expand All @@ -154,7 +175,7 @@ jobs:
df -h

- name: Tests
run: cd build; ctest --verbose -j ${{ steps.cpu-cores.outputs.count }}
run: cd ${{ env.build_dir }}; ctest --verbose -j ${{ steps.cpu-cores.outputs.count }}

####################
# Windows
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ else()
set(LAGRANGE_IDE_PREFIX_DEFAULT "third_party/")
endif()
set(LAGRANGE_IDE_PREFIX ${LAGRANGE_IDE_PREFIX_DEFAULT} CACHE STRING "Folder prefix for Lagrange targets in MSVC/Xcode")
foreach(target IN ITEMS Lagrange_DynamicVersion Lagrange_GitHash Lagrange_Version)
if(TARGET ${target})
set_target_properties(${target} PROPERTIES FOLDER "${LAGRANGE_IDE_PREFIX}Lagrange/Utils")
endif()
endforeach()

# When building python module, compile MKL/TBB as a shared library
if(LAGRANGE_MODULE_PYTHON OR LAGRANGE_ALL OR BUILD_SHARED_LIBS)
Expand Down
14 changes: 2 additions & 12 deletions cmake/recipes/external/Boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ option(BOOST_IOSTREAMS_ENABLE_BZIP2 "Boost.Iostreams: Enable BZip2 support" OFF)
option(BOOST_IOSTREAMS_ENABLE_LZMA "Boost.Iostreams: Enable LZMA support" OFF)
option(BOOST_IOSTREAMS_ENABLE_ZSTD "Boost.Iostreams: Enable Zstd support" OFF)

if(SKBUILD)
set(OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ON)
endif()

set(BOOST_PATCHES "")
if(EMSCRIPTEN)
# Wasm doesn't have rounding mode control yet, so we trick Boost::interval into thinking it has.
Expand All @@ -97,17 +92,12 @@ endif()
include(CPM)
CPMAddPackage(
NAME Boost
VERSION 1.84.0
GITHUB_REPOSITORY "boostorg/boost"
GIT_TAG "boost-1.84.0"
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e
EXCLUDE_FROM_ALL ON
${BOOST_PATCHES}
)

if(SKBUILD)
set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED_LIBS})
endif()

# Due to MKL, we may require the release runtime (/MD) even when compiling in Debug mode.
#
# Boost::random will call <auto_link.hpp> in the following line:
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/DynamicVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2025 Adobe. All rights reserved.
# Copyright 2026 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand Down
7 changes: 5 additions & 2 deletions cmake/recipes/external/MKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ function(mkl_add_imported_library name)
set(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(LINUX)
set(CMAKE_FIND_LIBRARY_SUFFIXES "")
set(mkl_search_name mkl_${name}${MKL_LIB_SUFFIX}.so${MKL_DLL_SUFFIX})
if(MKL_LINKING STREQUAL static)
set(mkl_search_name mkl_${name}${MKL_LIB_SUFFIX}.a)
else()
set(mkl_search_name mkl_${name}${MKL_LIB_SUFFIX}.so${MKL_DLL_SUFFIX})
endif()
else()
set(mkl_search_name mkl_${name}${MKL_LIB_SUFFIX})
endif()
Expand Down Expand Up @@ -385,7 +389,6 @@ add_library(MKL::MKL INTERFACE IMPORTED GLOBAL)

# Find header directory
file(GLOB MKL_INCLUDE_HINTS LIST_DIRECTORIES true "${mkl-include_SOURCE_DIR}/*.data")
message("MKL_INCLUDE_HINTS: ${MKL_INCLUDE_HINTS}")
find_path(MKL_INCLUDE_DIR
NAMES mkl.h
HINTS
Expand Down
15 changes: 14 additions & 1 deletion cmake/recipes/external/OpenVDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ endif()
option(OPENVDB_BUILD_CORE "" ON)
option(OPENVDB_BUILD_BINARIES "" OFF)
option(OPENVDB_ENABLE_RPATH "" OFF)
option(USE_NANOVDB "" ON)
option(NANOVDB_BUILD_TOOLS "" OFF)
option(NANOVDB_USE_BLOSC "" ON)
option(NANOVDB_USE_OPENVDB "" ON)
option(NANOVDB_USE_TBB "" ON)
option(NANOVDB_USE_ZLIB "" ON)

# option(USE_EXPLICIT_INSTANTIATION "" ON)

Expand Down Expand Up @@ -161,7 +167,7 @@ function(openvdb_import_target)
CPMAddPackage(
NAME openvdb
GITHUB_REPOSITORY AcademySoftwareFoundation/openvdb
GIT_TAG v12.0.1
GIT_TAG v13.0.0
)

unignore_package(TBB)
Expand Down Expand Up @@ -191,6 +197,9 @@ function(openvdb_import_target)
else()
add_library(OpenVDB::openvdb ALIAS openvdb)
endif()
if(TARGET nanovdb)
add_library(OpenVDB::nanovdb ALIAS nanovdb)
endif()

# Copy miniz.h as zlib.h to have blosc use miniz symbols (which are aliased through #define in miniz.h)
if(USE_ZLIB AND TARGET miniz::miniz)
Expand All @@ -202,6 +211,10 @@ function(openvdb_import_target)
include(GNUInstallDirs)
target_include_directories(${_aliased} SYSTEM BEFORE PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
if(TARGET nanovdb)
target_include_directories(nanovdb SYSTEM BEFORE INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)
endif()
endif()
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/entt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ include(CPM)
CPMAddPackage(
NAME entt
GITHUB_REPOSITORY skypjack/entt
GIT_TAG v3.16.0
GIT_TAG v3.15.0
)
27 changes: 27 additions & 0 deletions cmake/recipes/external/instant-meshes-core.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright 2026 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if (TARGET instant-meshes-core::instant-meshes-core)
return()
endif()

message(STATUS "Third-party (external): creating target 'instant-meshes-core::instant-meshes-core'")

include(CPM)
CPMAddPackage(
NAME instant-meshes-core
GITHUB_REPOSITORY qnzhou/instant-meshes-core
GIT_TAG 7e2b804d533e10578a730bb9d06dee2a5418730d
)

add_library(instant-meshes-core::instant-meshes-core ALIAS instant-meshes-core)
set_target_properties(instant-meshes-core PROPERTIES FOLDER third_party)
set_target_properties(instant-meshes-core PROPERTIES POSITION_INDEPENDENT_CODE ON)
17 changes: 9 additions & 8 deletions cmake/recipes/external/pcg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET pcg::pcg)
if(TARGET pcg_cpp::pcg_cpp)
return()
endif()

message(STATUS "Third-party (external): creating target 'pcg::pcg'")
message(STATUS "Third-party (external): creating target 'pcg_cpp::pcg_cpp'")

include(CPM)
CPMAddPackage(
NAME pcg
GITHUB_REPOSITORY imneme/pcg-cpp
GIT_TAG 428802d1a5634f96bcd0705fab379ff0113bcf13
GITHUB_REPOSITORY Total-Random/pcg-cpp
GIT_TAG d91bcf5ae5559361ac0d3319d4ab95a231b32984
DOWNLOAD_ONLY ON
)

add_library(pcg::pcg INTERFACE IMPORTED GLOBAL)
target_include_directories(pcg::pcg INTERFACE "${pcg_SOURCE_DIR}/include")
add_library(pcg_cpp::pcg_cpp INTERFACE IMPORTED GLOBAL)
target_include_directories(pcg_cpp::pcg_cpp INTERFACE "${pcg_SOURCE_DIR}/include")

# PCG's auto-detection of endianness does not work properly for Windows on ARM.
# Set the endianness explicitly if CMake knows it.
if(CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN")
target_compile_definitions(pcg::pcg INTERFACE PCG_LITTLE_ENDIAN=0)
target_compile_definitions(pcg_cpp::pcg_cpp INTERFACE PCG_LITTLE_ENDIAN=0)
elseif(CMAKE_CXX_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
target_compile_definitions(pcg::pcg INTERFACE PCG_LITTLE_ENDIAN=1)
target_compile_definitions(pcg_cpp::pcg_cpp INTERFACE PCG_LITTLE_ENDIAN=1)
endif()
62 changes: 62 additions & 0 deletions cmake/recipes/external/tinynpy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright 2026 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET TinyNPY::TinyNPY)
return()
endif()

message(STATUS "Third-party (external): creating target 'TinyNPY::TinyNPY'")

include(CPM)
CPMAddPackage(
NAME tinynpy
GITHUB_REPOSITORY cdcseacave/TinyNPY
GIT_TAG v1.1
DOWNLOAD_ONLY ON
)

add_library(TinyNPY "${tinynpy_SOURCE_DIR}/TinyNPY.cpp" "${tinynpy_SOURCE_DIR}/TinyNPY.h")
add_library(TinyNPY::TinyNPY ALIAS TinyNPY)

include(miniz)
target_link_libraries(TinyNPY PUBLIC miniz::miniz)

# Copy miniz.h as zlib.h to have TinyNPY use miniz symbols (which are aliased through #define in miniz.h)
FetchContent_GetProperties(miniz)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
configure_file(${miniz_SOURCE_DIR}/miniz.h ${CMAKE_CURRENT_BINARY_DIR}/include/zlib.h COPYONLY)

include(GNUInstallDirs)
target_include_directories(TinyNPY SYSTEM BEFORE PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>)

set_target_properties(TinyNPY PROPERTIES
DEFINE_SYMBOL "TINYNPY_EXPORT"
VERSION "1.1.0"
SOVERSION "1"
)

target_include_directories(TinyNPY PUBLIC
"$<BUILD_INTERFACE:${tinynpy_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

target_compile_definitions(TinyNPY
INTERFACE $<$<BOOL:${BUILD_SHARED_LIBS}>:TINYNPY_IMPORT>
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
)

set(unix_compilers "AppleClang;Clang;GNU")
if(CMAKE_CXX_COMPILER_ID IN_LIST unix_compilers) # IN_LIST wants the second arg to be a var
target_compile_options(TinyNPY PRIVATE "-frtti")
endif()

set_target_properties(TinyNPY PROPERTIES FOLDER third_party)
2 changes: 1 addition & 1 deletion cmake/recipes/external/ufbx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include(CPM)
CPMAddPackage(
NAME ufbx
GITHUB_REPOSITORY ufbx/ufbx
GIT_TAG e6bd7ea0833f1bd8732812100b69c596e1f69b64
GIT_TAG v0.21.2
)

include(GNUInstallDirs)
Expand Down
6 changes: 3 additions & 3 deletions modules/bvh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ lagrange_find_package(nanoflann REQUIRED)
include(libigl)
target_link_libraries(lagrange_bvh
PUBLIC
lagrange::core
nanoflann::nanoflann
igl::core
lagrange::core
nanoflann::nanoflann
igl::core
)

# 3. unit tests and examples
Expand Down
3 changes: 3 additions & 0 deletions modules/bvh/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ lagrange_include_modules(io)

lagrange_add_example(weld_vertices weld_vertices.cpp)
target_link_libraries(weld_vertices lagrange::bvh lagrange::io CLI11::CLI11)

lagrange_add_example(remove_interior_shells remove_interior_shells.cpp)
target_link_libraries(remove_interior_shells lagrange::bvh lagrange::io CLI11::CLI11)
60 changes: 60 additions & 0 deletions modules/bvh/examples/remove_interior_shells.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2026 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
#include <lagrange/bvh/remove_interior_shells.h>
#include <lagrange/io/load_mesh.h>
#include <lagrange/io/save_mesh.h>
#include <lagrange/triangulate_polygonal_facets.h>
#include <lagrange/utils/timing.h>

#include <CLI/CLI.hpp>

int main(int argc, char** argv)
{
struct
{
std::string input;
std::string output = "output.ply";
int log_level = 1; // debug
} args;

CLI::App app{argv[0]};
app.option_defaults()->always_capture_default();
app.add_option("input", args.input, "Input mesh.")->required()->check(CLI::ExistingFile);
app.add_option("output", args.output, "Output mesh.");
app.add_option("-l,--level", args.log_level, "Log level (0 = most verbose, 6 = off).");
CLI11_PARSE(app, argc, argv)

args.log_level = std::max(0, std::min(6, args.log_level));
spdlog::set_level(static_cast<spdlog::level::level_enum>(args.log_level));

lagrange::logger().info("Loading input mesh: {}", args.input);
auto mesh = lagrange::io::load_mesh<lagrange::SurfaceMesh32d>(args.input);

lagrange::logger().info("Triangulating mesh...");
lagrange::triangulate_polygonal_facets(mesh);

lagrange::logger().info(
"Mesh has {} vertices and {} facets.",
mesh.get_num_vertices(),
mesh.get_num_facets());

lagrange::logger().info("Removing interior shells...");
lagrange::VerboseTimer timer("remove_interior_shells");
timer.tick();
mesh = lagrange::bvh::remove_interior_shells(mesh);
timer.tock();

lagrange::logger().info("Saving result: {}", args.output);
lagrange::io::save_mesh(args.output, mesh);

return 0;
}
Loading
Loading