Plaster

c++src
b = Eigen::VectorXd::Zero(V.rows()*2); Eigen::SparseMatrix<double> Dx, Dy, U, D, B; computeSurfaceGradientMatrix(Dx, Dy); igl::cat(2, Dx, Eigen::SparseMatrix<double>(-Dy), U); igl::cat(2, Dx, Dy, D); igl::cat(1, U, D, B); // Area diagonal Eigen::VectorXd areas; igl::doublearea(V, F, areas); Eigen::SparseMatrix<double> AA(areas.size()*2, areas.size()*2); for(int i=0; i<areas.size()*2; ++i){ AA.insert(i, i) = std::sqrt(areas(i%areas.size())); } // Put it together A = (B.transpose()*AA)*B;

Annotations

• c++src
std::vector<std::vector<int>> VV; igl::adjacency_list(F, VV); // Initialize structures. Not sure what the target set is good for. int a = 0, b = 0; double distance = 0; std::set<int> targets; for(int i=0; i<V.rows(); ++i) targets.insert(i); // Loop through all verts. for(int i=0; i<V.rows(); ++i){ // Compute dijkstra to all other nodes Eigen::VectorXd min, prev; targets.erase(i); igl::dijkstra(i, targets, VV, min, prev); // Find maximal distance for(auto j : targets){ if(min(j) <= distance || isinf(min(j))) continue; distance = min(j); a = i; b = j; } } // Store. std::cout << "Fixpoints: " << a << "," << b << " (" << distance << ")\n"; fixed_UV_indices = Eigen::VectorXi::Zero(2); fixed_UV_positions = Eigen::MatrixXd::Zero(2, 2); fixed_UV_indices(0) = a; fixed_UV_indices(1) = b; fixed_UV_positions(0, 0) = -distance/2; fixed_UV_positions(1, 0) = +distance/2;
• c++src
std::vector<std::vector<int>> VV; igl::adjacency_list(F, VV); int a = 0, b = 0; double distance = 0; // Loop through all verts, perform distance measure for(int i=0; i<V.rows(); ++i){ int v, d; std::vector<std::tuple<int, int>> queue; std::unordered_set<int> visited; queue.push_back(std::make_tuple(i, 0)); // While we have neighbours to investigate... while(!queue.empty()){ std::tie(v, d) = queue.back(); visited.emplace(v); queue.pop_back(); // Go through neighbours of this and, if not found yet, enqueue for(int j : VV[v]){ if(visited.count(j) <= 0) queue.push_back(std::make_tuple(j, d+1)); } // Check furthest. if(distance < d){ distance = d; a = i; b = v; } } } // Store. std::cout << "Fixpoints: " << a << "," << b << " (" << distance << ")\n"; fixed_UV_indices = Eigen::VectorXi::Zero(2); fixed_UV_positions = Eigen::MatrixXd::Zero(2, 2); fixed_UV_indices(0) = a; fixed_UV_indices(1) = b; fixed_UV_positions(0, 0) = -0.5; fixed_UV_positions(1, 0) = +0.5;