BKE_sketch.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * Contributor(s): none yet.
  19. *
  20. * ***** END GPL LICENSE BLOCK *****
  21. */
  22. #ifndef __BKE_SKETCH_H__
  23. #define __BKE_SKETCH_H__
  24. /** \file BKE_sketch.h
  25. * \ingroup bke
  26. */
  27. typedef enum SK_PType {
  28. PT_CONTINUOUS,
  29. PT_EXACT,
  30. } SK_PType;
  31. typedef enum SK_PMode {
  32. PT_SNAP,
  33. PT_PROJECT,
  34. } SK_PMode;
  35. typedef struct SK_Point {
  36. float p[3];
  37. short p2d[2];
  38. float no[3];
  39. float size;
  40. SK_PType type;
  41. SK_PMode mode;
  42. } SK_Point;
  43. typedef struct SK_Stroke {
  44. struct SK_Stroke *next, *prev;
  45. SK_Point *points;
  46. int nb_points;
  47. int buf_size;
  48. int selected;
  49. } SK_Stroke;
  50. #define SK_OVERDRAW_LIMIT 5
  51. typedef struct SK_Overdraw {
  52. SK_Stroke *target;
  53. int start, end;
  54. int count;
  55. } SK_Overdraw;
  56. #define SK_Stroke_BUFFER_INIT_SIZE 20
  57. typedef struct SK_DrawData {
  58. int mval[2];
  59. int previous_mval[2];
  60. SK_PType type;
  61. } SK_DrawData;
  62. typedef struct SK_Intersection {
  63. struct SK_Intersection *next, *prev;
  64. SK_Stroke *stroke;
  65. int before;
  66. int after;
  67. int gesture_index;
  68. float p[3];
  69. float lambda; /* used for sorting intersection points */
  70. } SK_Intersection;
  71. typedef struct SK_Sketch {
  72. ListBase strokes;
  73. SK_Stroke *active_stroke;
  74. SK_Stroke *gesture;
  75. SK_Point next_point;
  76. SK_Overdraw over;
  77. } SK_Sketch;
  78. typedef struct SK_Gesture {
  79. SK_Stroke *stk;
  80. SK_Stroke *segments;
  81. ListBase intersections;
  82. ListBase self_intersections;
  83. int nb_self_intersections;
  84. int nb_intersections;
  85. int nb_segments;
  86. } SK_Gesture;
  87. /************************************************/
  88. void freeSketch(SK_Sketch *sketch);
  89. SK_Sketch *createSketch(void);
  90. void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk);
  91. void sk_freeStroke(SK_Stroke *stk);
  92. SK_Stroke *sk_createStroke(void);
  93. SK_Point *sk_lastStrokePoint(SK_Stroke *stk);
  94. void sk_allocStrokeBuffer(SK_Stroke *stk);
  95. void sk_shrinkStrokeBuffer(SK_Stroke *stk);
  96. void sk_growStrokeBuffer(SK_Stroke *stk);
  97. void sk_growStrokeBufferN(SK_Stroke *stk, int n);
  98. void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
  99. void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
  100. void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt);
  101. void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end);
  102. void sk_trimStroke(SK_Stroke *stk, int start, int end);
  103. void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3]);
  104. void sk_polygonizeStroke(SK_Stroke *stk, int start, int end);
  105. void sk_flattenStroke(SK_Stroke *stk, int start, int end);
  106. void sk_reverseStroke(SK_Stroke *stk);
  107. void sk_filterLastContinuousStroke(SK_Stroke *stk);
  108. void sk_filterStroke(SK_Stroke *stk, int start, int end);
  109. void sk_initPoint(SK_Point *pt, SK_DrawData *dd, const float no[3]);
  110. void sk_copyPoint(SK_Point *dst, SK_Point *src);
  111. int sk_stroke_filtermval(SK_DrawData *dd);
  112. void sk_endContinuousStroke(SK_Stroke *stk);
  113. void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk);
  114. void sk_initDrawData(SK_DrawData *dd, const int mval[2]);
  115. void sk_deleteSelectedStrokes(SK_Sketch *sketch);
  116. void sk_selectAllSketch(SK_Sketch *sketch, int mode);
  117. #endif