arap_rhs.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "arap_rhs.h"
  9. #include "arap_linear_block.h"
  10. #include "verbose.h"
  11. #include "repdiag.h"
  12. #include "cat.h"
  13. IGL_INLINE void igl::arap_rhs(
  14. const Eigen::MatrixXd & V,
  15. const Eigen::MatrixXi & F,
  16. const igl::ARAPEnergyType energy,
  17. Eigen::SparseMatrix<double>& K)
  18. {
  19. using namespace igl;
  20. using namespace Eigen;
  21. // Number of dimensions
  22. int dim = V.cols();
  23. //// Number of mesh vertices
  24. //int n = V.rows();
  25. //// Number of mesh elements
  26. //int m = F.rows();
  27. //// number of rotations
  28. //int nr;
  29. switch(energy)
  30. {
  31. case ARAP_ENERGY_TYPE_SPOKES:
  32. //nr = n;
  33. break;
  34. case ARAP_ENERGY_TYPE_SPOKES_AND_RIMS:
  35. //nr = n;
  36. break;
  37. case ARAP_ENERGY_TYPE_ELEMENTS:
  38. //nr = m;
  39. break;
  40. default:
  41. fprintf(
  42. stderr,
  43. "covariance_scatter_matrix.h: Error: Unsupported arap energy %d\n",
  44. energy);
  45. return;
  46. }
  47. SparseMatrix<double> KX,KY,KZ;
  48. arap_linear_block(V,F,0,energy,KX);
  49. arap_linear_block(V,F,1,energy,KY);
  50. if(dim == 2)
  51. {
  52. K = cat(2,repdiag(KX,dim),repdiag(KY,dim));
  53. }else if(dim == 3)
  54. {
  55. arap_linear_block(V,F,2,energy,KZ);
  56. K = cat(2,cat(2,repdiag(KX,dim),repdiag(KY,dim)),repdiag(KZ,dim));
  57. }else
  58. {
  59. fprintf(
  60. stderr,
  61. "covariance_scatter_matrix.h: Error: Unsupported dimension %d\n",
  62. dim);
  63. return;
  64. }
  65. }