get_soft_constraint_for_circle.cpp 919 B

1234567891011121314151617181920212223242526272829303132
  1. #include "get_soft_constraint_for_circle.h"
  2. #include <igl/boundary_loop.h>
  3. void get_soft_constraint_for_circle(Eigen::MatrixXd& V_o, Eigen::MatrixXi& F, Eigen::VectorXi& b, Eigen::MatrixXd& bc) {
  4. Eigen::VectorXi bnd;
  5. igl::boundary_loop(F,bnd);
  6. const int B_STEPS = 22; // constraint every B_STEPS vertices of the boundary
  7. b.resize(bnd.rows()/B_STEPS);
  8. bc.resize(b.rows(),2);
  9. int c_idx = 0;
  10. for (int i = B_STEPS; i < bnd.rows(); i+=B_STEPS) {
  11. b(c_idx) = bnd(i);
  12. c_idx++;
  13. }
  14. bc.row(0) = V_o.row(b(0)); // keep it there for now
  15. bc.row(1) = V_o.row(b(2));
  16. bc.row(2) = V_o.row(b(3));
  17. bc.row(3) = V_o.row(b(4));
  18. bc.row(4) = V_o.row(b(5));
  19. bc.row(0) << V_o(b(0),0), 0;
  20. bc.row(4) << V_o(b(4),0), 0;
  21. bc.row(2) << V_o(b(2),0), 0.1;
  22. bc.row(3) << V_o(b(3),0), 0.05;
  23. bc.row(1) << V_o(b(1),0), -0.15;
  24. bc.row(5) << V_o(b(5),0), +0.15;
  25. }