streamlines.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Created by Francisca Gil Ureta on 7/1/16.
  3. //
  4. #ifndef IGL_STREAMLINES_H
  5. #define IGL_STREAMLINES_H
  6. #include "igl_inline.h"
  7. #include <Eigen/Core>
  8. #include <vector>
  9. namespace igl
  10. {
  11. struct StreamlineData
  12. {
  13. Eigen::MatrixXi TT; // #F by #3 adjacent matrix
  14. Eigen::MatrixXi E; // #E by #3
  15. Eigen::MatrixXi F2E; // #Fx3, Stores the Triangle-Edge relation
  16. Eigen::MatrixXi E2F; // #Ex2, Stores the Edge-Triangle relation
  17. Eigen::MatrixXd field; // #F by 3N list of the 3D coordinates of the per-face vectors
  18. // (N degrees stacked horizontally for each triangle)
  19. Eigen::MatrixXi match_ab; // #E by N matrix, describing for each edge the matching a->b, where a
  20. // and b are the faces adjacent to the edge (i.e. vector #i of
  21. // the vector set in a is matched to vector #mab[i] in b)
  22. Eigen::MatrixXi match_ba; // #E by N matrix, describing the inverse relation to match_ab
  23. int nsample; // #S, number of sample points
  24. int degree; // #N, degrees of the vector field
  25. };
  26. struct StreamlineState
  27. {
  28. Eigen::MatrixXd start_point; // #N*S by 3 starting points of segment (stacked vertically for each degree)
  29. Eigen::MatrixXd end_point; // #N*S by 3 endpoints points of segment (stacked vertically for each degree)
  30. Eigen::MatrixXi current_face; // #S by N face indices (stacked horizontally for each degree)
  31. Eigen::MatrixXi current_direction; // #S by N field direction indices (stacked horizontally for each degree)
  32. };
  33. // Given a mesh and a field the function computes the /data/ necessary for tracing the field'
  34. // streamlines, and creates the initial /state/ for the tracing.
  35. // Inputs:
  36. // V #V by 3 list of mesh vertex coordinates
  37. // F #F by 3 list of mesh faces
  38. // temp_field #F by 3n list of the 3D coordinates of the per-face vectors
  39. // (n-degrees stacked horizontally for each triangle)
  40. // treat_as_symmetric
  41. // if true, adds n symmetry directions to the field (N = 2n). Else N = n
  42. // percentage [0-1] percentage of faces sampled
  43. // Outputs:
  44. // data struct containing topology information of the mesh and field
  45. // state struct containing the state of the tracing
  46. IGL_INLINE void streamlines_init(
  47. const Eigen::MatrixXd V,
  48. const Eigen::MatrixXi F,
  49. const Eigen::MatrixXd &temp_field,
  50. const bool treat_as_symmetric,
  51. StreamlineData &data,
  52. StreamlineState &state,
  53. double percentage = 0.3
  54. );
  55. // The function computes the next state for each point in the sample
  56. // V #V by 3 list of mesh vertex coordinates
  57. // F #F by 3 list of mesh faces
  58. // data struct containing topology information
  59. // state struct containing the state of the tracing
  60. IGL_INLINE void streamlines_next(
  61. const Eigen::MatrixXd V,
  62. const Eigen::MatrixXi F,
  63. const StreamlineData & data,
  64. StreamlineState & state
  65. );
  66. }
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "streamlines.cpp"
  69. #endif
  70. #endif