Skip to content

Commit 4062f56

Browse files
author
Alec Jacobson
committed
add back files and tests
1 parent 9cd7b78 commit 4062f56

190 files changed

Lines changed: 13087 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# This is very dubious... It *may* work because these are just cpp libraries that should not depend on the python version. Still, super-dubious.
5353
CIBW_BEFORE_BUILD_WINDOWS: "python -m pip install delvewheel"
5454
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "python -m delvewheel repair --no-mangle-all --add-path build\\temp.win-amd64-3.6\\Release;build\\temp.win-amd64-3.6\\Release\\Release;build\\temp.win-amd64-3.6\\Release\\_deps\\gmp-src\\lib;build\\temp.win-amd64-3.6\\Release\\_deps\\mpfr-src\\lib -w {dest_dir} {wheel} "
55-
#CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py {project}/data/"
55+
CIBW_TEST_COMMAND: "python {project}/tests/test_basic.py {project}/data/"
5656
CIBW_BUILD: "${{ matrix.cpversion }}-${{ matrix.os.cibw-arch }}"
5757
CIBW_TEST_SKIP: "*-macosx_arm64"
5858
CIBW_ENVIRONMENT: "MAX_JOBS=2"

src/active_set.cpp

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#include <common.h>
2+
#include <npe.h>
3+
#include <typedefs.h>
4+
#include <igl/active_set.h>
5+
6+
const char *ds_active_set = R"igl_Qu8mg5v7(
7+
ACTIVE_SET Minimize quadratic energy
8+
9+
0.5*Z'*A*Z + Z'*B + C with constraints
10+
that Z(known) = Y, optionally also subject to the constraints Aeq*Z = Beq,
11+
and further optionally subject to the linear inequality constraints that
12+
Aieq*Z <= Bieq and constant inequality constraints lx <= x <= ux
13+
14+
Parameters
15+
----------
16+
A n by n matrix of quadratic coefficients
17+
B n by 1 column of linear coefficients
18+
known list of indices to known rows in Z
19+
Y list of fixed values corresponding to known rows in Z
20+
Aeq meq by n list of linear equality constraint coefficients
21+
Beq meq by 1 list of linear equality constraint constant values
22+
Aieq mieq by n list of linear inequality constraint coefficients
23+
Bieq mieq by 1 list of linear inequality constraint constant values
24+
lx n by 1 list of lower bounds [] implies -Inf
25+
ux n by 1 list of upper bounds [] implies Inf
26+
params struct of additional parameters (see below)
27+
Z if not empty, is taken to be an n by 1 list of initial guess values (see output)
28+
Returns
29+
-------
30+
Z n by 1 list of solution values
31+
Returns SOLVER_STATUS_CONVERGED = 0, SOLVER_STATUS_MAX_ITER = 1, SOLVER_STATUS_ERROR = 2,
32+
33+
See also
34+
--------
35+
36+
Notes
37+
-----
38+
For a harmonic solve on a mesh with 325K facets, matlab 2.2 secs, igl / min_quad_with_fixed.h 7.1 secs
39+
40+
Known Bugs : rows of[Aeq; Aieq] **must **be linearly independent.Should be using QR decomposition otherwise : http : //www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
41+
42+
43+
Examples
44+
--------
45+
46+
)igl_Qu8mg5v7";
47+
48+
//NONe and dense_like
49+
npe_function(active_set)
50+
npe_doc(ds_active_set)
51+
npe_arg(A, sparse_float, sparse_double)
52+
npe_arg(B, dense_float, dense_double)
53+
npe_arg(known, dense_int, dense_long, dense_longlong)
54+
npe_arg(Y, npe_matches(B))
55+
npe_arg(Aeq, npe_matches(A))
56+
npe_arg(Beq, npe_matches(B))
57+
npe_arg(Aieq, npe_matches(A))
58+
npe_arg(Bieq, npe_matches(B))
59+
npe_arg(lx, npe_matches(B))
60+
npe_arg(ux, npe_matches(B))
61+
62+
npe_default_arg(Auu_pd, bool, false)
63+
npe_default_arg(max_iter, int, 100)
64+
npe_default_arg(inactive_threshold, double, igl::DOUBLE_EPS)
65+
npe_default_arg(constraint_threshold, double, igl::DOUBLE_EPS)
66+
npe_default_arg(solution_diff_threshold, double, igl::DOUBLE_EPS)
67+
68+
npe_begin_code()
69+
assert_cols_equals(A, A.rows(), "A");
70+
assert_rows_match(A, B, "A", "B");
71+
assert_cols_equals(B, 1, "B");
72+
73+
assert_cols_match(A, Aeq, "A", "Aeq");
74+
assert_rows_match(Aeq, Beq, "Aeq", "Beq");
75+
assert_cols_equals(Beq, 1, "Beq");
76+
77+
assert_rows_match(Aieq, Bieq, "Aieq", "Bieq");
78+
79+
if(Aieq.size() > 0)
80+
{
81+
assert_cols_match(A, Aieq, "A", "Aieq");
82+
assert_cols_equals(Bieq, 1, "Bieq");
83+
}
84+
85+
if(lx.size() > 0)
86+
{
87+
assert_rows_match(A, lx, "A", "lx");
88+
assert_cols_equals(lx, 1, "lx");
89+
}
90+
91+
if (ux.size() > 0)
92+
{
93+
assert_rows_match(A, ux, "A", "ux");
94+
assert_cols_equals(ux, 1, "ux");
95+
}
96+
97+
Eigen::SparseMatrix<double> A_copy = A.template cast<double>();
98+
Eigen::VectorXd B_copy = B.template cast<double>();
99+
Eigen::VectorXi known_copy = known.template cast<int>();
100+
Eigen::VectorXd Y_copy = Y.template cast<double>();
101+
Eigen::SparseMatrix<double> Aeq_copy = Aeq.template cast<double>();
102+
Eigen::VectorXd Beq_copy = Beq.template cast<double>();
103+
Eigen::SparseMatrix<double> Aieq_copy;
104+
Eigen::VectorXd Bieq_copy;
105+
106+
if(Aieq.size() > 0)
107+
{
108+
Aieq_copy = Aieq.template cast<double>();
109+
Bieq_copy = Bieq.template cast<double>();
110+
}
111+
112+
Eigen::VectorXd lx_copy;
113+
if(lx.size() > 0)
114+
lx_copy = lx.template cast<double>();
115+
Eigen::VectorXd ux_copy;
116+
if (ux.size() > 0)
117+
ux_copy = ux.template cast<double>();
118+
119+
igl::active_set_params params;
120+
params.Auu_pd = Auu_pd;
121+
params.max_iter = max_iter;
122+
params.inactive_threshold = inactive_threshold;
123+
params.constraint_threshold = constraint_threshold;
124+
params.solution_diff_threshold = solution_diff_threshold;
125+
126+
Eigen::VectorXd Z;
127+
128+
auto res = igl::active_set(A_copy, B_copy, known_copy, Y_copy, Aeq_copy, Beq_copy, Aieq_copy, Bieq_copy, lx_copy, ux_copy, params, Z);
129+
EigenDenseLike<npe_Matrix_B> Z_row_major = Z.template cast<typename npe_Matrix_B::Scalar>();
130+
131+
return std::make_tuple(int(res), npe::move(Z_row_major));
132+
133+
npe_end_code()

src/adjacency_list.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <common.h>
2+
#include <npe.h>
3+
#include <igl/adjacency_list.h>
4+
#include <pybind11/stl.h>
5+
6+
const char* ds_adjacency_list = R"igl_Qu8mg5v7(
7+
Constructs the graph adjacency list of a given mesh (v, f)
8+
9+
Parameters
10+
----------
11+
f : #f by dim array of fixed dimensional (e.g. triangle (#f by 3),
12+
tet (#f by 4), quad (#f by 4), etc...) mesh faces
13+
14+
Returns
15+
-------
16+
list of lists containing at index i the adjacent vertices of vertex i
17+
18+
See also
19+
--------
20+
adjacency_matrix
21+
22+
Notes
23+
-----
24+
25+
Examples
26+
--------
27+
# Mesh in (v, f)
28+
>>> a = mesh_adjacency_list(f)
29+
)igl_Qu8mg5v7";
30+
31+
npe_function(adjacency_list)
32+
npe_doc(ds_adjacency_list)
33+
npe_arg(f, dense_int, dense_long, dense_longlong)
34+
npe_begin_code()
35+
assert_valid_tet_or_tri_mesh_faces(f, "f");
36+
std::vector<std::vector<npe_Scalar_f>> a;
37+
igl::adjacency_list(f, a);
38+
return pybind11::detail::type_caster<decltype(a)>::cast(a, pybind11::return_value_policy::move, pybind11::none());
39+
40+
npe_end_code()

src/adjacency_matrix.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <common.h>
2+
#include <npe.h>
3+
#include <typedefs.h>
4+
#include <igl/adjacency_matrix.h>
5+
6+
const char* ds_adjacency_matrix = R"igl_Qu8mg5v7(
7+
Constructs the graph adjacency matrix of a given mesh (v, f).
8+
9+
Parameters
10+
----------
11+
f : #f by dim list of mesh simplices
12+
13+
Returns
14+
-------
15+
a : max(f) by max(f) cotangent matrix, each row i corresponding to v(i, :)
16+
17+
See also
18+
--------
19+
adjacency_list, edges, cotmatrix, diag
20+
21+
Notes
22+
-----
23+
None
24+
25+
Examples
26+
--------
27+
# Mesh in (v, f)
28+
>>> a = adjacency_matrix(f)
29+
30+
# Sum each row
31+
>>> a_sum = np.sum(a, axis=1)
32+
33+
# Convert row sums into diagonal of sparse matrix
34+
>>> a_diag = diag(a_sum)
35+
36+
# Build uniform laplacian
37+
>>> u = a - a_diag
38+
)igl_Qu8mg5v7";
39+
40+
npe_function(adjacency_matrix)
41+
npe_doc(ds_adjacency_matrix)
42+
npe_arg(f, dense_int, dense_long, dense_longlong)
43+
npe_begin_code()
44+
45+
assert_valid_simplex_idxs(f, "f");
46+
EigenSparseLike<npe_Matrix_f> a;
47+
igl::adjacency_matrix(f, a);
48+
return npe::move(a);
49+
50+
npe_end_code()
51+
52+

src/all_pairs_distances.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <common.h>
2+
#include <npe.h>
3+
#include <typedefs.h>
4+
#include <igl/all_pairs_distances.h>
5+
6+
const char *ds_all_pairs_distances = R"igl_Qu8mg5v7(
7+
compute distances between each point i in V and point j in U
8+
9+
Parameters
10+
----------
11+
V #V by dim list of points
12+
U #U by dim list of points
13+
squared whether to return squared distances
14+
15+
Returns
16+
-------
17+
D #V by #U matrix of distances, where D(i,j) gives the distance or squareed distance between V(i,:) and U(j,:)
18+
19+
See also
20+
--------
21+
22+
23+
Notes
24+
-----
25+
26+
27+
Examples
28+
--------
29+
D = all_pairs_distances(u,v)
30+
31+
32+
)igl_Qu8mg5v7";
33+
34+
npe_function(all_pairs_distances)
35+
npe_doc(ds_all_pairs_distances)
36+
37+
npe_arg(u, dense_float, dense_double)
38+
npe_arg(v, npe_matches(u))
39+
npe_arg(squared, bool)
40+
41+
42+
npe_begin_code()
43+
assert_cols_match(u, v, "u", "v");
44+
assert_nonzero_rows(u, "u");
45+
assert_nonzero_rows(v, "v");
46+
//same input/output template
47+
EigenDenseLike<npe_Matrix_u> u_copy = u;
48+
EigenDenseLike<npe_Matrix_u> v_copy = v;
49+
50+
EigenDenseLike<npe_Matrix_u> D;
51+
igl::all_pairs_distances(u_copy, v_copy, squared, D);
52+
return npe::move(D);
53+
54+
npe_end_code()
55+
56+

src/ambient_occlusion.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// TODO: __missing miss the rest two functions with AABB and shoot_ray. __example
2+
3+
#include <common.h>
4+
#include <npe.h>
5+
#include <typedefs.h>
6+
#include <igl/ambient_occlusion.h>
7+
8+
const char* ds_ambient_occlusion = R"igl_Qu8mg5v7(
9+
10+
Parameters
11+
----------
12+
V #V by 3 list of mesh vertex positions
13+
F #F by 3 list of mesh face indices into V
14+
P #P by 3 list of origin points
15+
N #P by 3 list of origin normals
16+
17+
Returns
18+
-------
19+
S #P list of ambient occusion values between 1 (fully occluded) and 0 (not occluded)
20+
21+
See also
22+
--------
23+
24+
25+
Notes
26+
-----
27+
None
28+
29+
Examples
30+
--------
31+
32+
)igl_Qu8mg5v7";
33+
34+
npe_function(ambient_occlusion)
35+
npe_doc(ds_ambient_occlusion)
36+
37+
npe_arg(v, dense_float, dense_double)
38+
npe_arg(f, dense_int, dense_long, dense_longlong)
39+
npe_arg(p, dense_float, dense_double)
40+
npe_arg(n, npe_matches(p))
41+
npe_arg(num_samples, int)
42+
npe_begin_code()
43+
44+
assert_valid_3d_tri_mesh(v, f);
45+
assert_cols_equals(p, 3, "p");
46+
assert_cols_equals(n, 3, "n");
47+
assert_nonzero_rows(p, "p");
48+
assert_nonzero_rows(n, "n");
49+
assert_shapes_match(p, n, "p", "n");
50+
51+
EigenDenseLike<npe_Matrix_p> s;
52+
igl::ambient_occlusion(v, f, p, n, num_samples, s);
53+
return npe::move(s);
54+
55+
npe_end_code()

0 commit comments

Comments
 (0)