- Initial integration of CCGSubSurf library into blender. The lib is
[blender.git] / source / blender / blenkernel / intern / CCGSubSurf.h
1 /* $Id$ */
2
3 typedef void* CCGMeshHDL;
4 typedef void* CCGVertHDL;
5 typedef void* CCGEdgeHDL;
6 typedef void* CCGFaceHDL;
7
8 typedef struct _CCGMeshIFC CCGMeshIFC;
9 struct _CCGMeshIFC {
10         int                     vertUserSize, edgeUserSize, faceUserSize;
11
12         int                     vertDataSize;
13         void            (*vertDataZero)         (CCGMeshHDL m, void *t);
14         int                     (*vertDataEqual)        (CCGMeshHDL m, void *a, void *b);
15         void            (*vertDataCopy)         (CCGMeshHDL m, void *t, void *a);
16         void            (*vertDataAdd)          (CCGMeshHDL m, void *ta, void *b);
17         void            (*vertDataSub)          (CCGMeshHDL m, void *ta, void *b);
18         void            (*vertDataMulN)         (CCGMeshHDL m, void *ta, double n);
19         void            (*vertDataAvg4)         (CCGMeshHDL m, void *t, void *a, void *b, void *c, void *d);
20
21         int                     (*getNumVerts)          (CCGMeshHDL m);
22         int                     (*getNumEdges)          (CCGMeshHDL m);
23         int                     (*getNumFaces)          (CCGMeshHDL m);
24         CCGVertHDL      (*getVert)                      (CCGMeshHDL m, int idx);
25         CCGEdgeHDL      (*getEdge)                      (CCGMeshHDL m, int idx);
26         CCGFaceHDL      (*getFace)                      (CCGMeshHDL m, int idx);
27
28         void            (*getVertData)          (CCGMeshHDL m, CCGVertHDL v, void *data_r);
29
30         CCGVertHDL      (*getEdgeVert0)         (CCGMeshHDL m, CCGEdgeHDL e);
31         CCGVertHDL      (*getEdgeVert1)         (CCGMeshHDL m, CCGEdgeHDL e);
32
33         int                     (*getFaceNumVerts)      (CCGMeshHDL m, CCGFaceHDL f);
34         CCGVertHDL      (*getFaceVert)          (CCGMeshHDL m, CCGFaceHDL f, int idx);
35 };
36
37 /***/
38
39 typedef void* CCGAllocatorHDL;
40
41 typedef struct _CCGAllocatorIFC CCGAllocatorIFC;
42 struct _CCGAllocatorIFC {
43         void*           (*alloc)                        (CCGAllocatorHDL a, int numBytes);
44         void*           (*realloc)                      (CCGAllocatorHDL a, void *ptr, int newSize, int oldSize);
45         void            (*free)                         (CCGAllocatorHDL a, void *ptr);
46         void            (*release)                      (CCGAllocatorHDL a);
47 };
48
49 /***/
50
51 typedef enum {
52         eCCGError_None = 0,
53
54         eCCGError_InvalidSyncState,
55         eCCGError_InvalidValue,
56 } CCGError;
57
58 /***/
59
60 typedef struct _CCGSubSurf CCGSubSurf;
61
62 CCGSubSurf*     ccgSubSurf_new  (CCGMeshIFC *ifc, CCGMeshHDL meshData, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator);
63 void            ccgSubSurf_free (CCGSubSurf *ss);
64
65 CCGError        ccgSubSurf_sync (CCGSubSurf *ss);
66
67 CCGError        ccgSubSurf_initFullSync         (CCGSubSurf *ss);
68 CCGError        ccgSubSurf_initPartialSync      (CCGSubSurf *ss);
69
70 CCGError        ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData);
71 CCGError        ccgSubSurf_syncEdge             (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1);
72 CCGError        ccgSubSurf_syncFace             (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs);
73
74 CCGError        ccgSubSurf_syncVertDel  (CCGSubSurf *ss, CCGVertHDL vHDL);
75 CCGError        ccgSubSurf_syncEdgeDel  (CCGSubSurf *ss, CCGEdgeHDL eHDL);
76 CCGError        ccgSubSurf_syncFaceDel  (CCGSubSurf *ss, CCGFaceHDL fHDL);
77
78 CCGError        ccgSubSurf_processSync  (CCGSubSurf *ss);
79
80 CCGError        ccgSubSurf_setSubdivisionLevels         (CCGSubSurf *ss, int subdivisionLevels);
81 CCGError        ccgSubSurf_setAllowEdgeCreation         (CCGSubSurf *ss, int allowEdgeCreation);
82 CCGError        ccgSubSurf_setUseAgeCounts                      (CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset);
83
84 /***/
85
86 typedef struct _CCGVert CCGVert;
87 typedef struct _CCGEdge CCGEdge;
88 typedef struct _CCGFace CCGFace;
89
90 int                     ccgSubSurf_getNumVerts                          (CCGSubSurf *ss);
91 int                     ccgSubSurf_getNumEdges                          (CCGSubSurf *ss);
92 int                     ccgSubSurf_getNumFaces                          (CCGSubSurf *ss);
93
94 int                     ccgSubSurf_getSubdivisionLevels         (CCGSubSurf *ss);
95 int                     ccgSubSurf_getEdgeSize                          (CCGSubSurf *ss);
96 int                     ccgSubSurf_getEdgeLevelSize                     (CCGSubSurf *ss, int level);
97 int                     ccgSubSurf_getGridSize                          (CCGSubSurf *ss);
98 int                     ccgSubSurf_getGridLevelSize                     (CCGSubSurf *ss, int level);
99
100 CCGVertHDL      ccgSubSurf_getVertVertHandle            (CCGSubSurf *ss, CCGVert *v);
101 int                     ccgSubSurf_getVertNumFaces                      (CCGSubSurf *ss, CCGVert *v);
102 CCGFace*        ccgSubSurf_getVertFace                          (CCGSubSurf *ss, CCGVert *v, int index);
103 int                     ccgSubSurf_getVertNumEdges                      (CCGSubSurf *ss, CCGVert *v);
104 CCGEdge*        ccgSubSurf_getVertEdge                          (CCGSubSurf *ss, CCGVert *v, int index);
105
106 int                     ccgSubSurf_getVertAge                           (CCGSubSurf *ss, CCGVert *v);
107 void*           ccgSubSurf_getVertUserData                      (CCGSubSurf *ss, CCGVert *v);
108 void*           ccgSubSurf_getVertData                          (CCGSubSurf *ss, CCGVert *v);
109 void*           ccgSubSurf_getVertLevelData                     (CCGSubSurf *ss, CCGVert *v, int level);
110
111 CCGEdgeHDL      ccgSubSurf_getEdgeEdgeHandle            (CCGSubSurf *ss, CCGEdge *e);
112 int                     ccgSubSurf_getEdgeNumFaces                      (CCGSubSurf *ss, CCGEdge *e);
113 CCGFace*        ccgSubSurf_getEdgeFace                          (CCGSubSurf *ss, CCGEdge *e, int index);
114 CCGVert*        ccgSubSurf_getEdgeVert0                         (CCGSubSurf *ss, CCGEdge *e);
115 CCGVert*        ccgSubSurf_getEdgeVert1                         (CCGSubSurf *ss, CCGEdge *e);
116
117 int                     ccgSubSurf_getEdgeAge                           (CCGSubSurf *ss, CCGEdge *e);
118 void*           ccgSubSurf_getEdgeUserData                      (CCGSubSurf *ss, CCGEdge *e);
119 void*           ccgSubSurf_getEdgeDataArray                     (CCGSubSurf *ss, CCGEdge *e);
120 void*           ccgSubSurf_getEdgeData                          (CCGSubSurf *ss, CCGEdge *e, int x);
121 void*           ccgSubSurf_getEdgeLevelData                     (CCGSubSurf *ss, CCGEdge *e, int x, int level);
122
123 CCGFaceHDL      ccgSubSurf_getFaceFaceHandle            (CCGSubSurf *ss, CCGFace *f);
124 int                     ccgSubSurf_getFaceNumVerts                      (CCGSubSurf *ss, CCGFace *f);
125 CCGVert*        ccgSubSurf_getFaceVert                          (CCGSubSurf *ss, CCGFace *f, int index);
126 CCGEdge*        ccgSubSurf_getFaceEdge                          (CCGSubSurf *ss, CCGFace *f, int index);
127
128 int                     ccgSubSurf_getFaceAge                           (CCGSubSurf *ss, CCGFace *f);
129 void*           ccgSubSurf_getFaceUserData                      (CCGSubSurf *ss, CCGFace *f);
130 void*           ccgSubSurf_getFaceCenterData            (CCGSubSurf *ss, CCGFace *f);
131 void*           ccgSubSurf_getFaceGridEdgeDataArray     (CCGSubSurf *ss, CCGFace *f, int gridIndex);
132 void*           ccgSubSurf_getFaceGridEdgeData          (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x);
133 void*           ccgSubSurf_getFaceGridDataArray         (CCGSubSurf *ss, CCGFace *f, int gridIndex);
134 void*           ccgSubSurf_getFaceGridData                      (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
135
136 int                     ccgSubSurf_getNumFinalVerts             (CCGSubSurf *ss);
137 int                     ccgSubSurf_getNumFinalEdges             (CCGSubSurf *ss);
138 int                     ccgSubSurf_getNumFinalFaces             (CCGSubSurf *ss);
139
140 /***/
141
142 typedef struct _CCGVertIterator CCGVertIterator;
143 typedef struct _CCGEdgeIterator CCGEdgeIterator;
144 typedef struct _CCGFaceIterator CCGFaceIterator;
145
146 CCGVertIterator*        ccgSubSurf_getVertIterator      (CCGSubSurf *ss);
147 CCGEdgeIterator*        ccgSubSurf_getEdgeIterator      (CCGSubSurf *ss);
148 CCGFaceIterator*        ccgSubSurf_getFaceIterator      (CCGSubSurf *ss);
149
150 CCGVert*                        ccgVertIterator_getCurrent      (CCGVertIterator *vi);
151 int                                     ccgVertIterator_isStopped       (CCGVertIterator *vi);
152 void                            ccgVertIterator_next            (CCGVertIterator *vi);
153 void                            ccgVertIterator_free            (CCGVertIterator *vi);
154
155 CCGEdge*                        ccgEdgeIterator_getCurrent      (CCGEdgeIterator *ei);
156 int                                     ccgEdgeIterator_isStopped       (CCGEdgeIterator *ei);
157 void                            ccgEdgeIterator_next            (CCGEdgeIterator *ei);
158 void                            ccgEdgeIterator_free            (CCGEdgeIterator *ei);
159
160 CCGFace*                        ccgFaceIterator_getCurrent      (CCGFaceIterator *fi);
161 int                                     ccgFaceIterator_isStopped       (CCGFaceIterator *fi);
162 void                            ccgFaceIterator_next            (CCGFaceIterator *fi);
163 void                            ccgFaceIterator_free            (CCGFaceIterator *fi);