Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alec Jacobson committed Sep 1, 2023
2 parents d7537f7 + 1e160ab commit a678bbe
Show file tree
Hide file tree
Showing 225 changed files with 3,413 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
CIBW_ENVIRONMENT: "MAX_JOBS=${{ matrix.os.runs-on == 'macos-latest' && 3 || 2 }}"
# Why universal2 here? It's not included above in CIBW_BUILD
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
CIBW_ENVIRONMENT_MACOS: "CMAKE_OSX_ARCHITECTURES=\"${{ matrix.os.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.os.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.os.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}\""
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.13 CMAKE_OSX_ARCHITECTURES=\"${{ matrix.os.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.os.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.os.cibw-arch == 'macosx_universal2' && 'arm64;x86_64' || '' }}\""


steps:
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include(CXXFeatures)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL "")

option(LIBIGL_COPYLEFT_CGAL "Build target igl_copyleft::cgal" ON)
option(LIBIGL_RESTRICTED_TRIANGLE "Build target igl_restricted::triangle" ON)
# libigl options must come before include(PyiglDependencies)
include(PyiglDependencies)
if(NOT TARGET igl::core)
Expand Down Expand Up @@ -79,17 +80,23 @@ function(pyigl_include prefix name)
target_link_libraries( pyigl INTERFACE ${target_name})
endif()
# https://stackoverflow.com/a/69736197/148668
# https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-E-arg-copy
# until then just needlessly also copy TARGET_FILE in case TARGET_RUNTIME_DLLS is empty
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_custom_command(TARGET ${target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:${target_name}> $<TARGET_FILE_DIR:${target_name}>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target_name}> $<TARGET_RUNTIME_DLLS:${target_name}> $<TARGET_FILE_DIR:${target_name}>
COMMAND_EXPAND_LISTS)
endif()
endfunction()

pyigl_include("copyleft" "cgal")
pyigl_include("restricted" "triangle")


add_library(pyigl_classes MODULE classes/classes.cpp)
file(GLOB PYIGL_CLASSES_SOURCES classes/*.cpp)
add_library(pyigl_classes MODULE ${PYIGL_CLASSES_SOURCES})
# std::variant
target_compile_features(pyigl_classes PRIVATE cxx_std_17)
target_link_libraries(pyigl_classes PRIVATE npe igl::core)
target_link_libraries(pyigl_classes PRIVATE pybind11::module)
set_target_properties(pyigl_classes PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" SUFFIX "${PYTHON_MODULE_EXTENSION}")
Expand Down
674 changes: 674 additions & 0 deletions LICENSE.GPL

Large diffs are not rendered by default.

373 changes: 373 additions & 0 deletions LICENSE.MPL2

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ and if developing and trying to run from this directory. You could use:
PYTHONPATH=. python tests/test_basic.py
```

## License

Like libigl, the wrapper source code is licensed under MPL2. Code included via
the copyleft and restricted sub-directories may have more restrictive licenses.
62 changes: 62 additions & 0 deletions classes/AABB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <igl/AABB.h>
#include <npe.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <variant>
#include <variant>


namespace py = pybind11;
template <int DIM>
void init_AABB(py::module_ &m)
{
using AABB_f64_DIM = igl::AABB<Eigen::MatrixXd,DIM>;
py::class_<AABB_f64_DIM >(m, (std::string("AABB_f64_")+std::to_string(DIM)).c_str() )
.def(py::init([]()
{
std::unique_ptr<AABB_f64_DIM> self = std::make_unique<AABB_f64_DIM>();
return self;
}))
.def("init",[](AABB_f64_DIM & self, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F)
{
self.init(V,F);
},
py::arg("V"), py::arg("F"))
.def("squared_distance",[](
AABB_f64_DIM & self,
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
const Eigen::MatrixXd & P,
const bool return_index = false,
const bool return_closest_point = false) ->
std::variant<py::object,std::list<py::object> >
{
Eigen::VectorXd sqrD;
Eigen::VectorXi I;
Eigen::MatrixXd C;
self.squared_distance(V,F,P,sqrD,I,C);
if(return_index && return_closest_point)
{
return std::list<py::object>({npe::move(sqrD),npe::move(I),npe::move(C)});
}else if(return_index)
{
return std::list<py::object>({npe::move(sqrD),npe::move(I)});
}else if(return_closest_point)
{
return std::list<py::object>({npe::move(sqrD),npe::move(C)});
}else
{
return npe::move(sqrD);
}
},
py::arg("V"),
py::arg("F"),
py::arg("P"),
py::arg("return_index")=false,
py::arg("return_closest_point")=false
)
;
}

template void init_AABB<2>(py::module_ &);
template void init_AABB<3>(py::module_ &);
7 changes: 7 additions & 0 deletions classes/classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@

namespace py = pybind11;

// Forward declaration
template <int DIM>
void init_AABB(py::module_ &);

PYBIND11_MODULE(pyigl_classes, m)
{
init_AABB<2>(m);
init_AABB<3>(m);

py::class_<igl::ARAPData>(m, "ARAP")
.def(py::init([](Eigen::MatrixXd &v, Eigen::MatrixXi &f, int dim, Eigen::MatrixXi &b,
const int energy_type, const bool with_dynamics, const double h, const double ym, const int max_iter) {
Expand Down
2 changes: 1 addition & 1 deletion cmake/PyiglDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
GIT_TAG 78015d4da1c6799dfe15659ed35adfb3a5f23ffa
GIT_TAG 5779714a5bdd62e105a96edfa73d0d3755e33bc8
)
FetchContent_GetProperties(libigl)
FetchContent_MakeAvailable(libigl)
Expand Down
7 changes: 7 additions & 0 deletions igl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# This file is part of libigl, a simple c++ geometry processing library.
#
# Copyright (C) 2023 Alec Jacobson
#
# This Source Code Form is subject to the terms of the Mozilla Public License
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
from .pyigl import *
from .helpers import *
from .pyigl_classes import *
Expand Down
9 changes: 8 additions & 1 deletion igl/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
__version__ = "2.5.2dev"
# This file is part of libigl, a simple c++ geometry processing library.
#
# Copyright (C) 2023 Alec Jacobson
#
# This Source Code Form is subject to the terms of the Mozilla Public License
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.
__version__ = "2.5.4dev"
5 changes: 2 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ remote_branch: 'gh-pages'
theme:
name: material
favicon: 'favicon.ico'
logo:
icon: ' '
icon: ''
palette:
primary: 'light blue'
accent: 'blue'
extra:
social:
- type: 'github'
- icon: fontawesome/brands/github-alt
link: 'https://github.com/libigl/libigl-python-bindings'
markdown_extensions:
- codehilite
Expand Down
Loading

0 comments on commit a678bbe

Please sign in to comment.