Blender  V2.59
BKE_sketch.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BKE_sketch.h 36644 2011-05-12 16:47:36Z campbellbarton $ 
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): none yet.
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 #ifndef BKE_SKETCH_H
00025 #define BKE_SKETCH_H
00026 
00031 typedef enum SK_PType
00032 {
00033         PT_CONTINUOUS,
00034         PT_EXACT,
00035 } SK_PType;
00036 
00037 typedef enum SK_PMode
00038 {
00039         PT_SNAP,
00040         PT_PROJECT,
00041 } SK_PMode;
00042 
00043 typedef struct SK_Point
00044 {
00045         float p[3];
00046         short p2d[2];
00047         float no[3];
00048         float size;
00049         SK_PType type;
00050         SK_PMode mode;
00051 } SK_Point;
00052 
00053 typedef struct SK_Stroke
00054 {
00055         struct SK_Stroke *next, *prev;
00056 
00057         SK_Point *points;
00058         int nb_points;
00059         int buf_size;
00060         int selected;
00061 } SK_Stroke;
00062 
00063 #define SK_OVERDRAW_LIMIT       5
00064 
00065 typedef struct SK_Overdraw
00066 {
00067         SK_Stroke *target;
00068         int     start, end;
00069         int count;
00070 } SK_Overdraw;
00071 
00072 #define SK_Stroke_BUFFER_INIT_SIZE 20
00073 
00074 typedef struct SK_DrawData
00075 {
00076         int mval[2];
00077         int previous_mval[2];
00078         SK_PType type;
00079 } SK_DrawData;
00080 
00081 typedef struct SK_Intersection
00082 {
00083         struct SK_Intersection *next, *prev;
00084         SK_Stroke *stroke;
00085         int                     before;
00086         int                     after;
00087         int                     gesture_index;
00088         float           p[3];
00089         float           lambda; /* used for sorting intersection points */
00090 } SK_Intersection;
00091 
00092 typedef struct SK_Sketch
00093 {
00094         ListBase        strokes;
00095         ListBase        depth_peels;
00096         SK_Stroke       *active_stroke;
00097         SK_Stroke       *gesture;
00098         SK_Point        next_point;
00099         SK_Overdraw over;
00100 } SK_Sketch;
00101 
00102 
00103 typedef struct SK_Gesture {
00104         SK_Stroke       *stk;
00105         SK_Stroke       *segments;
00106 
00107         ListBase        intersections;
00108         ListBase        self_intersections;
00109 
00110         int                     nb_self_intersections;
00111         int                     nb_intersections;
00112         int                     nb_segments;
00113 } SK_Gesture;
00114 
00115 
00116 /************************************************/
00117 
00118 void freeSketch(SK_Sketch *sketch);
00119 SK_Sketch* createSketch(void);
00120 
00121 void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk);
00122 
00123 void sk_freeStroke(SK_Stroke *stk);
00124 SK_Stroke* sk_createStroke(void);
00125 
00126 SK_Point *sk_lastStrokePoint(SK_Stroke *stk);
00127 
00128 void sk_allocStrokeBuffer(SK_Stroke *stk);
00129 void sk_shrinkStrokeBuffer(SK_Stroke *stk);
00130 void sk_growStrokeBuffer(SK_Stroke *stk);
00131 void sk_growStrokeBufferN(SK_Stroke *stk, int n);
00132 
00133 void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
00134 void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n);
00135 void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt);
00136 void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end);
00137 
00138 void sk_trimStroke(SK_Stroke *stk, int start, int end);
00139 void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], float p_end[3]);
00140 void sk_polygonizeStroke(SK_Stroke *stk, int start, int end);
00141 void sk_flattenStroke(SK_Stroke *stk, int start, int end);
00142 void sk_reverseStroke(SK_Stroke *stk);
00143 
00144 void sk_filterLastContinuousStroke(SK_Stroke *stk);
00145 void sk_filterStroke(SK_Stroke *stk, int start, int end);
00146 
00147 void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no);
00148 void sk_copyPoint(SK_Point *dst, SK_Point *src);
00149 
00150 int sk_stroke_filtermval(SK_DrawData *dd);
00151 void sk_endContinuousStroke(SK_Stroke *stk);
00152 
00153 void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk);
00154 
00155 void sk_initDrawData(SK_DrawData *dd, const int mval[2]);
00156 
00157 void sk_deleteSelectedStrokes(SK_Sketch *sketch);
00158 void sk_selectAllSketch(SK_Sketch *sketch, int mode);
00159 
00160 #endif