readTGF.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. #ifndef IGL_READTGF_H
  9. #define IGL_READTGF_H
  10. #include "igl_inline.h"
  11. #include <vector>
  12. #include <string>
  13. #ifndef IGL_NO_EIGEN
  14. #include <Eigen/Dense>
  15. #endif
  16. /// @file readTGF.h
  17. ///
  18. /// .tgf - control handle graphs
  19. /// ============================
  20. ///
  21. /// ------------------------------------------------------------------------
  22. ///
  23. /// A .tgf file contains a graph of describing a set of control handles/structures: point controls, bones of a skeleton and cages made of "cage edges".
  24. ///
  25. /// The first part of the file consists of lines regarding each vertex of the graph. Each line reads:
  26. ///
  27. /// [index] [x] [y] [z] [undocument optional data]
  28. ///
  29. /// Indices begin with 1 and should proceed in order. Then there should be a line with a sole:
  30. ///
  31. /// #
  32. ///
  33. /// The next section concerns the edges of the graph. Each line corresponds to an edge:
  34. ///
  35. /// [source index] [dest index] [is bone] [is pseudo-edge] [is cage edge] [undocument other data]
  36. ///
  37. /// Bone edges trump pseudo and cage edges.
  38. namespace igl
  39. {
  40. /// Read a graph from a .tgf file
  41. ///
  42. /// Input:
  43. /// filename .tgf file name
  44. /// Output:
  45. /// V # vertices by 3 list of vertex positions
  46. /// E # edges by 2 list of edge indices
  47. /// P # point-handles list of point handle indices
  48. /// BE # bone-edges by 2 list of bone-edge indices
  49. /// CE # cage-edges by 2 list of cage-edge indices
  50. /// PE # pseudo-edges by 2 list of pseudo-edge indices
  51. ///
  52. /// Assumes that graph vertices are 3 dimensional
  53. IGL_INLINE bool readTGF(
  54. const std::string tgf_filename,
  55. std::vector<std::vector<double> > & C,
  56. std::vector<std::vector<int> > & E,
  57. std::vector<int> & P,
  58. std::vector<std::vector<int> > & BE,
  59. std::vector<std::vector<int> > & CE,
  60. std::vector<std::vector<int> > & PE);
  61. /// \overload
  62. IGL_INLINE bool readTGF(
  63. const std::string tgf_filename,
  64. Eigen::MatrixXd & C,
  65. Eigen::MatrixXi & E,
  66. Eigen::VectorXi & P,
  67. Eigen::MatrixXi & BE,
  68. Eigen::MatrixXi & CE,
  69. Eigen::MatrixXi & PE);
  70. /// \overload
  71. IGL_INLINE bool readTGF(
  72. const std::string tgf_filename,
  73. Eigen::MatrixXd & C,
  74. Eigen::MatrixXi & E);
  75. }
  76. #ifndef IGL_STATIC_LIBRARY
  77. # include "readTGF.cpp"
  78. #endif
  79. #endif