streamlines.h 3.7 KB

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