-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathboundary_conditions.cpp
More file actions
67 lines (64 loc) · 2.31 KB
/
boundary_conditions.cpp
File metadata and controls
67 lines (64 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "default_types.h"
#include <igl/boundary_conditions.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>
#include <nanobind/stl/tuple.h>
namespace nb = nanobind;
using namespace nb::literals;
namespace pyigl
{
auto boundary_conditions(
const nb::DRef<const Eigen::MatrixXN> &V,
const nb::DRef<const Eigen::MatrixXI> &Ele,
const nb::DRef<const Eigen::MatrixXN> &C,
const nb::DRef<const Eigen::VectorXI> &P,
const nb::DRef<const Eigen::MatrixXI> &BE,
const nb::DRef<const Eigen::MatrixXI> &CE,
const nb::DRef<const Eigen::MatrixXI> &CF)
{
Eigen::VectorXI b;
Eigen::MatrixXN bc;
if(!igl::boundary_conditions(V, Ele, C, P, BE, CE, CF, b, bc))
{
throw std::runtime_error("boundary_conditions: failed to compute");
}
return std::make_tuple(b, bc);
}
}
void bind_boundary_conditions(nb::module_ &m)
{
m.def(
"boundary_conditions",
&pyigl::boundary_conditions,
"V"_a,
"Ele"_a,
"C"_a,
"P"_a=Eigen::VectorXI(),
"BE"_a=Eigen::MatrixXI(),
"CE"_a=Eigen::MatrixXI(),
"CF"_a=Eigen::MatrixXI(),
R"(Compute boundary conditions for automatic weights computation. This
function expects that the given mesh (V,Ele) has sufficient samples
(vertices) exactly at point handle locations and exactly along bone and
cage edges/faces.
@param[in] V #V by dim list of domain vertices
@param[in] Ele #Ele by simplex-size list of simplex indices
@param[in] C #C by dim list of handle positions
@param[in] P #P by 1 list of point handle indices into C
@param[in] BE #BE by 2 list of bone edge indices into C
@param[in] CE #CE by 2 list of cage edge indices into *P*
@param[in] CF #CF by 3 list of (triangular) cage face indices into *P*
@param[out] b #b list of boundary indices (indices into V of vertices which have
known, fixed values)
@param[out] bc #b by #weights list of known/fixed values for boundary vertices
(notice the #b != #weights in general because #b will include all the
intermediary samples along each bone, etc.. The ordering of the
weights corresponds to [P;BE]
throws error if boundary conditions are suspicious:
P and BE are empty
bc is empty
some column of bc doesn't have a 0 (assuming bc has >1 columns)
some column of bc doesn't have a 1 (assuming bc has >1 columns))"
);
}