### Install Gpytoolbox Latest Release Source: https://github.com/sgsellan/gpytoolbox/blob/main/docs/index.md Installs the latest stable release of the Gpytoolbox library using pip. This is the recommended installation method for most users. ```bash python -m pip install gpytoolbox ``` -------------------------------- ### Build gpytoolbox C++ Bindings on Ubuntu Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Instructions for building gpytoolbox C++ bindings on Ubuntu. Includes updating system packages, installing development libraries (libmpfr-dev, libgmp-dev), and then using CMake and make. ```bash sudo apt-get update sudo apt-get upgrade sudo apt-get install libmpfr-dev libgmp-dev mkdir build cd build cmake .. make -j2 ``` -------------------------------- ### Install Gpytoolbox from Git Source: https://github.com/sgsellan/gpytoolbox/blob/main/docs/index.md Installs Gpytoolbox directly from its GitHub repository, allowing for development or use of the latest unreleased features. It requires numpy to be installed first. ```bash python -m pip install numpy python -m pip install . ``` -------------------------------- ### Get Help with Gpytoolbox Functions Source: https://github.com/sgsellan/gpytoolbox/blob/main/docs/index.md Demonstrates how to access documentation for specific Gpytoolbox functions in an interactive Python session. This includes function purpose, parameters, return values, and related functions. ```python >>> from gpytoolbox import grad >>> help(grad) Finite element gradient matrix Given a triangle mesh or a polyline, computes the finite element gradient matrix assuming piecewise linear hat function basis. Parameters ---------- V : numpy double array Matrix of vertex coordinates F : numpy int array, optional (default None) Matrix of triangle indices Returns ------- G : scipy sparse.csr_matrix Sparse FEM gradient matrix See Also -------- cotangent_laplacian. Notes ----- ``` ``` -------------------------------- ### Use C++ Bindings and Python Functions Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Example showcasing the use of both pure Python functions (regular_square_mesh) and C++ bindings (in_element_aabb) from gpytoolbox after setting up the path. ```python import sys import os import numpy as np sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../ext/gpytoolbox'))) from gpytoolbox import regular_square_mesh, in_element_aabb v, f = regular_square_mesh(10) # This is a pure python function query = np.aarray([[0.1,0.1]]) I = in_element_aabb(queries,V,F) # This is a C++ binding ``` -------------------------------- ### Install gpytoolbox Dependencies Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Installs necessary Python packages for gpytoolbox using conda and pip. Includes libraries like numpy, igl, matplotlib, scipy, and polyscope. ```bash conda install numpy conda install -c conda-forge igl conda install -c conda-forge matplotlib conda install -c conda-forge scipy conda install -c conda-forge scikit-sparse python -m pip install --upgrade pip python -m pip install polyscope python -m pip install tetgen python -m pip install scikit-image ``` -------------------------------- ### Get Help for Gpytoolbox 'grad' Function Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Demonstrates how to access documentation for a specific Gpytoolbox function, 'grad', using Python's built-in help() function. The 'grad' function computes the finite element gradient matrix for triangle meshes or polylines assuming piecewise linear hat function basis. ```python from gpytoolbox import grad help(grad) ``` -------------------------------- ### CMake Build Configuration Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt Sets up the CMake build environment, including minimum version, project name, C++ standard, and compiler flags. It also configures specific settings for MSVC and AppleClang compilers. ```cmake cmake_minimum_required(VERSION 3.16) # https://discourse.cmake.org/t/msvc-runtime-library-completely-ignored/10004 cmake_policy(SET CMP0091 NEW) project(Bindings DESCRIPTION "Python bindings" ) # MSVC needs explicit configuration for multithreading # Select a multi-threaded statically-linked runtime library # with or without debug information depending on the configuration set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_BUILD_TYPE "Release") #set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(EXT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION") if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.0.0") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ld_classic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ld_classic") endif() endif() ``` -------------------------------- ### Build gpytoolbox C++ Bindings on Windows Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Build instructions for gpytoolbox C++ bindings on Windows using CMake. Specifies release build type and uses `cmake --build` for compilation. ```bash mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build "." --config Release ``` -------------------------------- ### Copy DLLs on Windows for gpytoolbox copyleft bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command sets up a post-build action for the 'gpytoolbox_bindings_copyleft' target on Windows. It ensures that the necessary runtime DLLs are copied alongside the target file, facilitating proper execution. ```cmake if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") add_custom_command(TARGET gpytoolbox_bindings_copyleft POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $ $ COMMAND_EXPAND_LISTS) endif() ``` -------------------------------- ### Copy wgpu binaries for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command invokes a custom function `target_copy_webgpu_binaries` to handle the copying of wgpu binaries for the 'gpytoolbox_bindings' target. This is a project-specific utility to manage external binary dependencies. ```cmake # Manually copy wgpu to the right place target_copy_webgpu_binaries(gpytoolbox_bindings) ``` -------------------------------- ### Import and Use gpytoolbox in Python Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Demonstrates how to add the gpytoolbox directory to the Python path and import functions like regular_square_mesh. ```python import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'path/to/gpytoolbox'))) from gpytoolbox import regular_square_mesh v, f = regular_square_mesh(10) ``` -------------------------------- ### Include External Libraries Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt Includes and configures external libraries such as libigl, PoissonRecon, nanoflann, and webgpu. It sets options for libigl and defines include directories for PoissonRecon. ```cmake # Include libigl option(LIBIGL_COPYLEFT_CGAL "Use CGAL" ON) option(LIBIGL_EMBREE "Build target igl::embree" ON) set(BOOST_ROOT "/Users/silviasellan/Dropbox/temp/libigl/build/_deps/boost-src") include(libigl) igl_include(glfw) igl_include(embree) # Include PoissonRecon include(PoissonRecon) add_library(PoissonRecon INTERFACE) target_include_directories(PoissonRecon INTERFACE "${CMAKE_BINARY_DIR}/_deps/poissonrecon-src/Src/") # Include nanoflann include(nanoflann) # Include webgpu include(webgpu) include(glfw3webgpu) if(TARGET webgpu AND TARGET glfw3webgpu) add_compile_definitions(GL_AVAILABLE) set(GL_LIBS webgpuglfw3webgpu) else() set(GL_LIBS "") endif() ``` -------------------------------- ### Import Gpytoolbox MIT Licensed Modules Source: https://github.com/sgsellan/gpytoolbox/blob/main/docs/index.md Shows how to import the main Gpytoolbox module or individual functions, ensuring adherence to the permissive MIT license. This is the standard way to use the library. ```python import gpytoolbox ``` ```python from gpytoolbox import regular_square_mesh, regular_cube_mesh ``` -------------------------------- ### Clone gpytoolbox Repository Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md This command clones the gpytoolbox repository from GitHub. The --recursive flag ensures that any submodules are also cloned. ```bash git clone --recursive https://github.com/sgsellan/gpytoolbox.git ``` -------------------------------- ### Define cpytoolbox_copyleft Library Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt Defines the static library 'cpytoolbox_copyleft' which includes source and header files for swept volume functionalities. It also links against copyleft libraries. ```cmake add_library(cpytoolbox_copyleft STATIC # SHARED # Headers src/cpp/swept_volume/fd_interpolate.cpp src/cpp/swept_volume/gradient_descent_test.cpp src/cpp/swept_volume/random_points_on_mesh.cpp src/cpp/swept_volume/sparse_continuation.cpp src/cpp/swept_volume/swept_volume.cpp # Source src/cpp/swept_volume/fd_interpolate.h src/cpp/swept_volume/gradient_descent_test.h src/cpp/swept_volume/random_points_on_mesh.h src/cpp/swept_volume/sparse_continuation.h src/cpp/swept_volume/swept_volume.h ) target_link_libraries(cpytoolbox_copyleft ${COPYLEFT_LIBRARIES_TO_LINK}) ``` -------------------------------- ### Import Gpytoolbox GPL Licensed Modules Source: https://github.com/sgsellan/gpytoolbox/blob/main/docs/index.md Illustrates how to import functions from the `gpytoolbox.copyleft` module, which are subject to the more restrictive GPL license. Explicit import is required for these functions. ```python from gpytoolbox.copyleft import mesh_boolean ``` -------------------------------- ### Build gpytoolbox C++ Bindings on MacOS Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Steps to build the C++ bindings for gpytoolbox on MacOS using CMake. This involves creating a build directory, configuring with CMake, and making the project. ```bash mkdir build cd build cmake .. make -j2 ``` -------------------------------- ### Copy DLLs on Windows for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command defines a post-build custom command for the 'gpytoolbox_bindings' target. On Windows systems, it copies the target's runtime DLLs to the same directory as the target executable, ensuring that dependencies are correctly resolved. ```cmake if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") add_custom_command(TARGET gpytoolbox_bindings POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $ $ COMMAND_EXPAND_LISTS) endif() ``` -------------------------------- ### Set include directories for gpytoolbox copyleft bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command sets the include directories for the 'gpytoolbox_bindings_copyleft' target. The C++ source directory is added as a PUBLIC include directory, making it accessible to dependent targets. ```cmake target_include_directories(gpytoolbox_bindings_copyleft PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp") ``` -------------------------------- ### Set include directories for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command configures the include directories for the 'gpytoolbox_bindings' target. It makes the C++ source directory publicly available for inclusion by any target that depends on 'gpytoolbox_bindings'. ```cmake target_include_directories(gpytoolbox_bindings PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/") ``` -------------------------------- ### Import Gpytoolbox Main Module Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Imports the main Gpytoolbox module, adhering to the MIT license terms. ```python import gpytoolbox ``` -------------------------------- ### Fix dylib paths on macOS for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake code block defines a post-build custom command for macOS that uses `install_name_tool`. It modifies the shared library paths within the 'gpytoolbox_bindings' target to ensure correct loading of dependent libraries like `libwgpu_native.dylib`. ```cmake if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # Extra difficult on mac. add_custom_command( TARGET gpytoolbox_bindings POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} "-change" "@executable_path/libwgpu_native.dylib" "$/libwgpu_native.dylib" "$" VERBATIM ) endif() ``` -------------------------------- ### Define cpytoolbox Library Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt Defines the static library 'cpytoolbox' which includes various C++ source and header files for different functionalities. It links against the configured external libraries. ```cmake # List of all libraries to link set(LIBRARIES_TO_LINK igl::core igl::embree nanoflann PoissonRecon ${GL_LIBS}) set(COPYLEFT_LIBRARIES_TO_LINK igl::core igl_copyleft::cgal) add_library(cpytoolbox STATIC # SHARED # Headers src/cpp/upper_envelope.h src/cpp/ray_mesh_intersect_aabb.h src/cpp/in_element_aabb.h src/cpp/read_obj.h src/cpp/write_obj.h src/cpp/point_cloud_to_mesh.h src/cpp/reach_for_the_arcs/outside_points_from_rasterization.h src/cpp/reach_for_the_arcs/locally_make_feasible.h src/cpp/reach_for_the_arcs/fine_tune_point_cloud_iter.h src/cpp/reach_for_the_arcs/sAABB.h src/cpp/reach_for_the_arcs/resolve_collisions_on_sphere.h src/cpp/remesher/collapse_edges.h src/cpp/remesher/equalize_valences.h src/cpp/remesher/remesh_botsch.h src/cpp/remesher/split_edges_until_bound.h src/cpp/remesher/split_edges.h src/cpp/remesher/tangential_relaxation.h src/cpp/microstl/microstl_wrappers.h src/cpp/tinyply/tinyply_wrappers.h # Source src/cpp/upper_envelope.cpp src/cpp/ray_mesh_intersect_aabb.cpp src/cpp/in_element_aabb.cpp src/cpp/read_obj.cpp src/cpp/write_obj.cpp src/cpp/point_cloud_to_mesh.cpp src/cpp/reach_for_the_arcs/outside_points_from_rasterization.cpp src/cpp/reach_for_the_arcs/locally_make_feasible.cpp src/cpp/reach_for_the_arcs/fine_tune_point_cloud_iter.cpp src/cpp/reach_for_the_arcs/sAABB.cpp src/cpp/reach_for_the_arcs/resolve_collisions_on_sphere.cpp src/cpp/remesher/collapse_edges.cpp src/cpp/remesher/equalize_valences.cpp src/cpp/remesher/remesh_botsch.cpp src/cpp/remesher/split_edges_until_bound.cpp src/cpp/remesher/split_edges.cpp src/cpp/remesher/tangential_relaxation.cpp src/cpp/microstl/microstl_wrappers.cpp src/cpp/tinyply/tinyply_wrappers.cpp # microstl src/cpp/microstl/microstl.h # tinyply src/cpp/tinyply/tinyply.h ) target_link_libraries(cpytoolbox ${LIBRARIES_TO_LINK}) ``` -------------------------------- ### Add pybind11 module for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This snippet uses CMake's pybind11 integration to create a Python module named 'gpytoolbox_bindings'. It lists all the necessary C++ source files for the bindings, including core functionalities and specific features like reading/writing OBJ and STL files, decimation, and Hausdorff distance calculations. ```cmake add_subdirectory(./ext/pybind11/) pybind11_add_module(gpytoolbox_bindings "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/gpytoolbox_bindings_core.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_read_obj.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_write_obj.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_decimate.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_fast_winding_number.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_hausdorff_distance.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_in_element_aabb.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_marching_cubes.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_offset_surface.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_point_mesh_squared_distance.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_ray_mesh_intersect.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_read_stl.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_write_stl.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_remesher_botsch.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_upper_envelope.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_read_ply.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_write_ply.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_curved_hessian_intrinsic.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_point_cloud_to_mesh.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/reach_for_the_arcs/binding_outside_points_from_rasterization.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/reach_for_the_arcs//binding_locally_make_feasible.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/reach_for_the_arcs//binding_fine_tune_point_cloud_iter.cpp" ) ``` -------------------------------- ### Link libraries for gpytoolbox copyleft bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command links libraries to the 'gpytoolbox_bindings_copyleft' target. It indicates that the libraries defined in `${COPYLEFT_LIBRARIES_TO_LINK}` are required as PUBLIC dependencies for this module. ```cmake target_link_libraries(gpytoolbox_bindings_copyleft PUBLIC ${COPYLEFT_LIBRARIES_TO_LINK}) ``` -------------------------------- ### Link libraries for gpytoolbox bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command links external libraries to the 'gpytoolbox_bindings' target. It specifies that the libraries listed in the `${LIBRARIES_TO_LINK}` variable should be linked as PUBLIC dependencies, making them available to targets that depend on 'gpytoolbox_bindings'. ```cmake target_link_libraries(gpytoolbox_bindings PUBLIC ${LIBRARIES_TO_LINK}) ``` -------------------------------- ### Clang Compiler Specific Options Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt Applies a specific compile option '-Wno-missing-template-arg-list-after-template-kw' to the 'cpytoolbox' target when using Clang version 17.0 or greater, to resolve potential compiler warnings. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17.0") #To make PSR work on newer Clangs target_compile_options(cpytoolbox PRIVATE -Wno-missing-template-arg-list-after-template-kw) endif() endif() set(LIBRARIES_TO_LINK cpytoolbox ${LIBRARIES_TO_LINK}) set(COPYLEFT_LIBRARIES_TO_LINK cpytoolbox_copyleft ${COPYLEFT_LIBRARIES_TO_LINK}) ``` -------------------------------- ### Import Specific Gpytoolbox Functions Source: https://github.com/sgsellan/gpytoolbox/blob/main/README.md Imports specific functions (regular_square_mesh, regular_cube_mesh) from the main Gpytoolbox module, adhering to the MIT license terms. ```python from gpytoolbox import regular_square_mesh, regular_cube_mesh ``` -------------------------------- ### Add pybind11 module for gpytoolbox copyleft bindings Source: https://github.com/sgsellan/gpytoolbox/blob/main/CMakeLists.txt This CMake command defines a separate Python module named 'gpytoolbox_bindings_copyleft' using pybind11. It includes specific C++ source files related to copyleft functionalities, such as swept volumes and boolean operations. ```cmake pybind11_add_module(gpytoolbox_bindings_copyleft "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/gpytoolbox_bindings_copyleft_core.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_swept_volume.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/binding_booleans.cpp" ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.