meas.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * meas.h - Measurements
  3. *
  4. * Written 2009, 2010 by Werner Almesberger
  5. * Copyright 2009, 2010 by Werner Almesberger
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef MEAS_H
  13. #define MEAS_H
  14. #include "coord.h"
  15. #include "expr.h"
  16. #include "bitset.h"
  17. typedef int (*lt_op_type)(struct coord a, struct coord b);
  18. struct vec;
  19. struct obj;
  20. struct frame_qual {
  21. const struct frame *frame;
  22. struct frame_qual *next;
  23. };
  24. struct meas {
  25. enum meas_type {
  26. mt_xy_next,
  27. mt_x_next,
  28. mt_y_next,
  29. mt_xy_max,
  30. mt_x_max,
  31. mt_y_max,
  32. mt_n
  33. } type;
  34. char *label; /* or NULL */
  35. int inverted;
  36. /* low is obj->base */
  37. struct vec *high;
  38. struct expr *offset;
  39. /* frame qualifiers */
  40. struct frame_qual *low_qual;
  41. struct frame_qual *high_qual;
  42. };
  43. struct sample {
  44. struct coord pos;
  45. struct bitset *frame_set;
  46. struct sample *next;
  47. };
  48. extern int n_samples;
  49. int lt_x(struct coord a, struct coord b);
  50. int lt_y(struct coord a, struct coord b);
  51. int lt_xy(struct coord a, struct coord b);
  52. const struct sample *meas_find_min(lt_op_type lt, const struct sample *s,
  53. const struct bitset *qual);
  54. const struct sample *meas_find_next(lt_op_type lt, const struct sample *s,
  55. struct coord ref, const struct bitset *qual);
  56. const struct sample *meas_find_max(lt_op_type lt, const struct sample *s,
  57. const struct bitset *qual);
  58. void reset_samples(struct sample **samples, int n);
  59. void meas_start(void);
  60. void meas_post(const struct vec *vec, struct coord pos,
  61. const struct bitset *frame_set);
  62. int instantiate_meas(int n_frames);
  63. #endif /* !MEAS_H */