MCPcopy Create free account
hub / github.com/Colin97/DeepMetaHandles / main

Function main

data_preprocessing/calc_weight.cpp:18–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16Eigen::MatrixXd W;
17
18int main(int argc, char *argv[])
19{
20 using namespace Eigen;
21 using namespace std;
22 using namespace igl;
23
24 if (!readMESH(argv[1], high.V, high.T, high.F)) //tet mesh
25 {
26 cout << "failed to load mesh" << endl;
27 }
28
29 if (!readOBJ(argv[2], surface.V, surface.F)) // surface mesh
30 {
31 cout << "failed to load mesh" << endl;
32 }
33
34 if (!readOBJ(argv[3], low.V, low.F)) // key points
35 {
36 cout << "failed to load mesh" << endl;
37 }
38
39 Eigen::VectorXi bb;
40 {
41 Eigen::VectorXi J = Eigen::VectorXi::LinSpaced(high.V.rows(), 0, high.V.rows() - 1);
42 Eigen::VectorXd sqrD;
43 Eigen::MatrixXd _2;
44 igl::point_mesh_squared_distance(surface.V, high.V, J, sqrD, bb, _2);
45 assert(sqrD.minCoeff() < 1e-7 && "surface.V should exist in high.V");
46 }
47 for_each(surface.F.data(), surface.F.data() + surface.F.size(), [&bb](int &a) { a = bb(a); });
48 high.F = surface.F;
49
50 {
51 Eigen::VectorXi b;
52 {
53 Eigen::VectorXi J = Eigen::VectorXi::LinSpaced(high.V.rows(), 0, high.V.rows() - 1);
54 Eigen::VectorXd sqrD;
55 Eigen::MatrixXd _2;
56 igl::point_mesh_squared_distance(low.V, high.V, J, sqrD, b, _2);
57 assert(sqrD.minCoeff() < 1e-7 && "low.V should exist in high.V");
58 }
59
60 igl::slice(high.V, b, 1, low.V);
61
62 std::vector<std::vector<int>> S;
63 igl::matrix_to_list(b, S);
64 cout << "Computing weights for " << b.size() << " handles at " << high.V.rows() << " vertices..." << endl;
65 const int k = 2;
66
67 igl::biharmonic_coordinates(high.V, high.T, S, k, W);
68
69 VectorXi I, J;
70 //cout << high.V.rows() << endl;
71 igl::remove_unreferenced(high.V.rows(), high.F, I, J);
72 for_each(high.F.data(), high.F.data() + high.F.size(), [&I](int &a) { a = I(a); });
73 for_each(b.data(), b.data() + b.size(), [&I](int &a) { a = I(a); });
74 igl::slice(MatrixXd(high.V), J, 1, high.V);
75 igl::slice(MatrixXd(W), J, 1, W);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected