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