34d684221b0371d442ca3ca7d9cd6bd388666e5f
[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 #define CCG_OMP_LIMIT   1000000
43
44 /***/
45
46 typedef struct _CCGSubSurf CCGSubSurf;
47
48 CCGSubSurf*     ccgSubSurf_new  (CCGMeshIFC *ifc, int subdivisionLevels, CCGAllocatorIFC *allocatorIFC, CCGAllocatorHDL allocator);
49 void            ccgSubSurf_free (CCGSubSurf *ss);
50
51 CCGError        ccgSubSurf_sync (CCGSubSurf *ss);
52
53 CCGError        ccgSubSurf_initFullSync         (CCGSubSurf *ss);
54 CCGError        ccgSubSurf_initPartialSync      (CCGSubSurf *ss);
55
56 CCGError        ccgSubSurf_syncVert             (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r);
57 CCGError        ccgSubSurf_syncEdge             (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r);
58 CCGError        ccgSubSurf_syncFace             (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r);
59
60 CCGError        ccgSubSurf_syncVertDel  (CCGSubSurf *ss, CCGVertHDL vHDL);
61 CCGError        ccgSubSurf_syncEdgeDel  (CCGSubSurf *ss, CCGEdgeHDL eHDL);
62 CCGError        ccgSubSurf_syncFaceDel  (CCGSubSurf *ss, CCGFaceHDL fHDL);
63
64 CCGError        ccgSubSurf_processSync  (CCGSubSurf *ss);
65
66 CCGError        ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **faces, int numFaces);
67 CCGError        ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **faces, int numFaces);
68 CCGError        ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **faces, int numFaces);
69 CCGError        ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **faces, int numFaces);
70 CCGError        ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **faces, int numFaces);
71
72 CCGError        ccgSubSurf_setSubdivisionLevels         (CCGSubSurf *ss, int subdivisionLevels);
73
74 CCGError        ccgSubSurf_setAllowEdgeCreation         (CCGSubSurf *ss, int allowEdgeCreation, float defaultCreaseValue, void *defaultUserData);
75 void            ccgSubSurf_getAllowEdgeCreation         (CCGSubSurf *ss, int *allowEdgeCreation_r, float *defaultCreaseValue_r, void *defaultUserData_r);
76
77 void            ccgSubSurf_getUseAgeCounts                      (CCGSubSurf *ss, int *useAgeCounts_r, int *vertUserOffset_r, int *edgeUserOffset_r, int *faceUserOffset_r);
78 CCGError        ccgSubSurf_setUseAgeCounts                      (CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset);
79
80 CCGError        ccgSubSurf_setCalcVertexNormals         (CCGSubSurf *ss, int useVertNormals, int normalDataOffset);
81
82 /***/
83
84 int                     ccgSubSurf_getNumVerts                          (CCGSubSurf *ss);
85 int                     ccgSubSurf_getNumEdges                          (CCGSubSurf *ss);
86 int                     ccgSubSurf_getNumFaces                          (CCGSubSurf *ss);
87
88 int                     ccgSubSurf_getSubdivisionLevels         (CCGSubSurf *ss);
89 int                     ccgSubSurf_getEdgeSize                          (CCGSubSurf *ss);
90 int                     ccgSubSurf_getEdgeLevelSize                     (CCGSubSurf *ss, int level);
91 int                     ccgSubSurf_getGridSize                          (CCGSubSurf *ss);
92 int                     ccgSubSurf_getGridLevelSize                     (CCGSubSurf *ss, int level);
93
94 CCGVert*        ccgSubSurf_getVert                                      (CCGSubSurf *ss, CCGVertHDL v);
95 CCGVertHDL      ccgSubSurf_getVertVertHandle            (CCGVert *v);
96 int                     ccgSubSurf_getVertNumFaces                      (CCGVert *v);
97 CCGFace*        ccgSubSurf_getVertFace                          (CCGVert *v, int index);
98 int                     ccgSubSurf_getVertNumEdges                      (CCGVert *v);
99 CCGEdge*        ccgSubSurf_getVertEdge                          (CCGVert *v, int index);
100
101 int                     ccgSubSurf_getVertAge                           (CCGSubSurf *ss, CCGVert *v);
102 void*           ccgSubSurf_getVertUserData                      (CCGSubSurf *ss, CCGVert *v);
103 void*           ccgSubSurf_getVertData                          (CCGSubSurf *ss, CCGVert *v);
104 void*           ccgSubSurf_getVertLevelData                     (CCGSubSurf *ss, CCGVert *v, int level);
105
106 CCGEdge*        ccgSubSurf_getEdge                                      (CCGSubSurf *ss, CCGEdgeHDL e);
107 CCGEdgeHDL      ccgSubSurf_getEdgeEdgeHandle            (CCGEdge *e);
108 int                     ccgSubSurf_getEdgeNumFaces                      (CCGEdge *e);
109 CCGFace*        ccgSubSurf_getEdgeFace                          (CCGEdge *e, int index);
110 CCGVert*        ccgSubSurf_getEdgeVert0                         (CCGEdge *e);
111 CCGVert*        ccgSubSurf_getEdgeVert1                         (CCGEdge *e);
112 float           ccgSubSurf_getEdgeCrease                        (CCGEdge *e);
113
114 int                     ccgSubSurf_getEdgeAge                           (CCGSubSurf *ss, CCGEdge *e);
115 void*           ccgSubSurf_getEdgeUserData                      (CCGSubSurf *ss, CCGEdge *e);
116 void*           ccgSubSurf_getEdgeDataArray                     (CCGSubSurf *ss, CCGEdge *e);
117 void*           ccgSubSurf_getEdgeData                          (CCGSubSurf *ss, CCGEdge *e, int x);
118 void*           ccgSubSurf_getEdgeLevelData                     (CCGSubSurf *ss, CCGEdge *e, int x, int level);
119
120 CCGFace*        ccgSubSurf_getFace                                      (CCGSubSurf *ss, CCGFaceHDL f);
121 CCGFaceHDL      ccgSubSurf_getFaceFaceHandle            (CCGSubSurf *ss, CCGFace *f);
122 int                     ccgSubSurf_getFaceNumVerts                      (CCGFace *f);
123 CCGVert*        ccgSubSurf_getFaceVert                          (CCGSubSurf *ss, CCGFace *f, int index);
124 CCGEdge*        ccgSubSurf_getFaceEdge                          (CCGSubSurf *ss, CCGFace *f, int index);
125 int                     ccgSubSurf_getFaceEdgeIndex                     (CCGFace *f, CCGEdge *e);
126
127 int                     ccgSubSurf_getFaceAge                           (CCGSubSurf *ss, CCGFace *f);
128 void*           ccgSubSurf_getFaceUserData                      (CCGSubSurf *ss, CCGFace *f);
129 void*           ccgSubSurf_getFaceCenterData            (CCGFace *f);
130 void*           ccgSubSurf_getFaceGridEdgeDataArray     (CCGSubSurf *ss, CCGFace *f, int gridIndex);
131 void*           ccgSubSurf_getFaceGridEdgeData          (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x);
132 void*           ccgSubSurf_getFaceGridDataArray         (CCGSubSurf *ss, CCGFace *f, int gridIndex);
133 void*           ccgSubSurf_getFaceGridData                      (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y);
134
135 int                     ccgSubSurf_getNumFinalVerts             (CCGSubSurf *ss);
136 int                     ccgSubSurf_getNumFinalEdges             (CCGSubSurf *ss);
137 int                     ccgSubSurf_getNumFinalFaces             (CCGSubSurf *ss);
138
139 /***/
140
141 typedef struct _CCGVertIterator CCGVertIterator;
142 typedef struct _CCGEdgeIterator CCGEdgeIterator;
143 typedef struct _CCGFaceIterator CCGFaceIterator;
144
145 CCGVertIterator*        ccgSubSurf_getVertIterator      (CCGSubSurf *ss);
146 CCGEdgeIterator*        ccgSubSurf_getEdgeIterator      (CCGSubSurf *ss);
147 CCGFaceIterator*        ccgSubSurf_getFaceIterator      (CCGSubSurf *ss);
148
149 CCGVert*                        ccgVertIterator_getCurrent      (CCGVertIterator *vi);
150 int                                     ccgVertIterator_isStopped       (CCGVertIterator *vi);
151 void                            ccgVertIterator_next            (CCGVertIterator *vi);
152 void                            ccgVertIterator_free            (CCGVertIterator *vi);
153
154 CCGEdge*                        ccgEdgeIterator_getCurrent      (CCGEdgeIterator *ei);
155 int                                     ccgEdgeIterator_isStopped       (CCGEdgeIterator *ei);
156 void                            ccgEdgeIterator_next            (CCGEdgeIterator *ei);
157 void                            ccgEdgeIterator_free            (CCGEdgeIterator *ei);
158
159 CCGFace*                        ccgFaceIterator_getCurrent      (CCGFaceIterator *fi);
160 int                                     ccgFaceIterator_isStopped       (CCGFaceIterator *fi);
161 void                            ccgFaceIterator_next            (CCGFaceIterator *fi);
162 void                            ccgFaceIterator_free            (CCGFaceIterator *fi);