rebranch from 2.5
[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 _CCGVert CCGVert;
9 typedef struct _CCGEdge CCGEdge;
10 typedef struct _CCGFace CCGFace;
11
12 typedef struct _CCGMeshIFC CCGMeshIFC;
13 struct _CCGMeshIFC {
14         int                     vertUserSize, edgeUserSize, faceUserSize;
15
16         int                     vertDataSize;
17 };
18
19 /***/
20
21 typedef void* CCGAllocatorHDL;
22
23 typedef struct _CCGAllocatorIFC CCGAllocatorIFC;
24 struct _CCGAllocatorIFC {
25         void*           (*alloc)                        (CCGAllocatorHDL a, int numBytes);
26         void*           (*realloc)                      (CCGAllocatorHDL a, void *ptr, int newSize, int oldSize);
27         void            (*free)                         (CCGAllocatorHDL a, void *ptr);
28         void            (*release)                      (CCGAllocatorHDL a);
29 };
30
31 /***/
32
33 typedef enum {
34         eCCGError_None = 0,
35
36         eCCGError_InvalidSyncState,
37         eCCGError_InvalidValue,
38 } CCGError;
39
40 /***/
41
42 typedef struct _CCGSubSurf CCGSubSurf;
43
44 CCGSubSurf*     ccgSubSurf_new  (CCGMeshIFC *ifc, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator);
45 void            ccgSubSurf_free (CCGSubSurf *ss);
46
47 CCGError        ccgSubSurf_sync (CCGSubSurf *ss);
48
49 CCGError        ccgSubSurf_initFullSync         (CCGSubSurf *ss);
50 CCGError        ccgSubSurf_initPartialSync      (CCGSubSurf *ss);
51
52 CCGError        ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r);
53 CCGError        ccgSubSurf_syncEdge             (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r);
54 CCGError        ccgSubSurf_syncFace             (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r);
55
56 CCGError        ccgSubSurf_syncVertDel  (CCGSubSurf *ss, CCGVertHDL vHDL);
57 CCGError        ccgSubSurf_syncEdgeDel  (CCGSubSurf *ss, CCGEdgeHDL eHDL);
58 CCGError        ccgSubSurf_syncFaceDel  (CCGSubSurf *ss, CCGFaceHDL fHDL);
59
60 CCGError        ccgSubSurf_processSync  (CCGSubSurf *ss);
61
62 CCGError        ccgSubSurf_setSubdivisionLevels         (CCGSubSurf *ss, int subdivisionLevels);
63
64 CCGError        ccgSubSurf_setAllowEdgeCreation         (CCGSubSurf *ss, int allowEdgeCreation, float defaultCreaseValue, void *defaultUserData);
65 void            ccgSubSurf_getAllowEdgeCreation         (CCGSubSurf *ss, int *allowEdgeCreation_r, float *defaultCreaseValue_r, void *defaultUserData_r);
66
67 void            ccgSubSurf_getUseAgeCounts                      (CCGSubSurf *ss, int *useAgeCounts_r, int *vertUserOffset_r, int *edgeUserOffset_r, int *faceUserOffset_r);
68 CCGError        ccgSubSurf_setUseAgeCounts                      (CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset);
69
70 CCGError        ccgSubSurf_setCalcVertexNormals         (CCGSubSurf *ss, int useVertNormals, int normalDataOffset);
71
72 /***/
73
74 int                     ccgSubSurf_getNumVerts                          (CCGSubSurf *ss);
75 int                     ccgSubSurf_getNumEdges                          (CCGSubSurf *ss);
76 int                     ccgSubSurf_getNumFaces                          (CCGSubSurf *ss);
77
78 int                     ccgSubSurf_getSubdivisionLevels         (CCGSubSurf *ss);
79 int                     ccgSubSurf_getEdgeSize                          (CCGSubSurf *ss);
80 int                     ccgSubSurf_getEdgeLevelSize                     (CCGSubSurf *ss, int level);
81 int                     ccgSubSurf_getGridSize                          (CCGSubSurf *ss);
82 int                     ccgSubSurf_getGridLevelSize                     (CCGSubSurf *ss, int level);
83
84 CCGVert*        ccgSubSurf_getVert                                      (CCGSubSurf *ss, CCGVertHDL v);
85 CCGVertHDL      ccgSubSurf_getVertVertHandle            (CCGVert *v);
86 int                     ccgSubSurf_getVertNumFaces                      (CCGVert *v);
87 CCGFace*        ccgSubSurf_getVertFace                          (CCGVert *v, int index);
88 int                     ccgSubSurf_getVertNumEdges                      (CCGVert *v);
89 CCGEdge*        ccgSubSurf_getVertEdge                          (CCGVert *v, int index);
90
91 int                     ccgSubSurf_getVertAge                           (CCGSubSurf *ss, CCGVert *v);
92 void*           ccgSubSurf_getVertUserData                      (CCGSubSurf *ss, CCGVert *v);
93 void*           ccgSubSurf_getVertData                          (CCGSubSurf *ss, CCGVert *v);
94 void*           ccgSubSurf_getVertLevelData                     (CCGSubSurf *ss, CCGVert *v, int level);
95
96 CCGEdge*        ccgSubSurf_getEdge                                      (CCGSubSurf *ss, CCGEdgeHDL e);
97 CCGEdgeHDL      ccgSubSurf_getEdgeEdgeHandle            (CCGEdge *e);
98 int                     ccgSubSurf_getEdgeNumFaces                      (CCGEdge *e);
99 CCGFace*        ccgSubSurf_getEdgeFace                          (CCGEdge *e, int index);
100 CCGVert*        ccgSubSurf_getEdgeVert0                         (CCGEdge *e);
101 CCGVert*        ccgSubSurf_getEdgeVert1                         (CCGEdge *e);
102 float           ccgSubSurf_getEdgeCrease                        (CCGEdge *e);
103
104 int                     ccgSubSurf_getEdgeAge                           (CCGSubSurf *ss, CCGEdge *e);
105 void*           ccgSubSurf_getEdgeUserData                      (CCGSubSurf *ss, CCGEdge *e);
106 void*           ccgSubSurf_getEdgeDataArray                     (CCGSubSurf *ss, CCGEdge *e);
107 void*           ccgSubSurf_getEdgeData                          (CCGSubSurf *ss, CCGEdge *e, int x);
108 void*           ccgSubSurf_getEdgeLevelData                     (CCGSubSurf *ss, CCGEdge *e, int x, int level);
109
110 CCGFace*        ccgSubSurf_getFace                                      (CCGSubSurf *ss, CCGFaceHDL f);
111 CCGFaceHDL      ccgSubSurf_getFaceFaceHandle            (CCGSubSurf *ss, CCGFace *f);
112 int                     ccgSubSurf_getFaceNumVerts                      (CCGFace *f);
113 CCGVert*        ccgSubSurf_getFaceVert                          (CCGSubSurf *ss, CCGFace *f, int index);
114 CCGEdge*        ccgSubSurf_getFaceEdge                          (CCGSubSurf *ss, CCGFace *f, int index);
115 int                     ccgSubSurf_getFaceEdgeIndex                     (CCGFace *f, CCGEdge *e);
116
117 int                     ccgSubSurf_getFaceAge                           (CCGSubSurf *ss, CCGFace *f);
118 void*           ccgSubSurf_getFaceUserData                      (CCGSubSurf *ss, CCGFace *f);
119 void*           ccgSubSurf_getFaceCenterData            (CCGFace *f);
120 void*           ccgSubSurf_getFaceGridEdgeDataArray     (CCGSubSurf *ss, CCGFace *f, int gridIndex);
121 void*           ccgSubSurf_getFaceGridEdgeData          (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x);
122 void*           ccgSubSurf_getFaceGridDataArray         (CCGSubSurf *ss, CCGFace *f, int gridIndex);
123 void*           ccgSubSurf_getFaceGridData                      (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
124
125 int                     ccgSubSurf_getNumFinalVerts             (CCGSubSurf *ss);
126 int                     ccgSubSurf_getNumFinalEdges             (CCGSubSurf *ss);
127 int                     ccgSubSurf_getNumFinalFaces             (CCGSubSurf *ss);
128
129 /***/
130
131 typedef struct _CCGVertIterator CCGVertIterator;
132 typedef struct _CCGEdgeIterator CCGEdgeIterator;
133 typedef struct _CCGFaceIterator CCGFaceIterator;
134
135 CCGVertIterator*        ccgSubSurf_getVertIterator      (CCGSubSurf *ss);
136 CCGEdgeIterator*        ccgSubSurf_getEdgeIterator      (CCGSubSurf *ss);
137 CCGFaceIterator*        ccgSubSurf_getFaceIterator      (CCGSubSurf *ss);
138
139 CCGVert*                        ccgVertIterator_getCurrent      (CCGVertIterator *vi);
140 int                                     ccgVertIterator_isStopped       (CCGVertIterator *vi);
141 void                            ccgVertIterator_next            (CCGVertIterator *vi);
142 void                            ccgVertIterator_free            (CCGVertIterator *vi);
143
144 CCGEdge*                        ccgEdgeIterator_getCurrent      (CCGEdgeIterator *ei);
145 int                                     ccgEdgeIterator_isStopped       (CCGEdgeIterator *ei);
146 void                            ccgEdgeIterator_next            (CCGEdgeIterator *ei);
147 void                            ccgEdgeIterator_free            (CCGEdgeIterator *ei);
148
149 CCGFace*                        ccgFaceIterator_getCurrent      (CCGFaceIterator *fi);
150 int                                     ccgFaceIterator_isStopped       (CCGFaceIterator *fi);
151 void                            ccgFaceIterator_next            (CCGFaceIterator *fi);
152 void                            ccgFaceIterator_free            (CCGFaceIterator *fi);