OpenSubdiv: Properly respect Subdivide UVs option
[blender.git] / intern / opensubdiv / opensubdiv_converter_capi.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2015 Blender Foundation.
19  * All rights reserved.
20  *
21  * Contributor(s): Sergey Sharybin.
22  *
23  * ***** END GPL LICENSE BLOCK *****
24  */
25
26 #ifndef __OPENSUBDIV_CONVERTER_CAPI_H__
27 #define __OPENSUBDIV_CONVERTER_CAPI_H__
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 struct OpenSubdiv_TopologyRefinerDescr;
34 typedef struct OpenSubdiv_TopologyRefinerDescr OpenSubdiv_TopologyRefinerDescr;
35
36 typedef struct OpenSubdiv_Converter OpenSubdiv_Converter;
37
38 typedef enum OpenSubdiv_SchemeType {
39         OSD_SCHEME_BILINEAR,
40         OSD_SCHEME_CATMARK,
41         OSD_SCHEME_LOOP,
42 } OpenSubdiv_SchemeType;
43
44 typedef struct OpenSubdiv_Converter {
45         /* TODO(sergey): Needs to be implemented. */
46         /* OpenSubdiv::Sdc::Options get_options() const; */
47
48         OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter);
49
50         bool (*get_subdiv_uvs)(const OpenSubdiv_Converter *converter);
51
52         int (*get_num_faces)(const OpenSubdiv_Converter *converter);
53         int (*get_num_edges)(const OpenSubdiv_Converter *converter);
54         int (*get_num_verts)(const OpenSubdiv_Converter *converter);
55
56         /* Face relationships. */
57         int (*get_num_face_verts)(const OpenSubdiv_Converter *converter,
58                                   int face);
59         void (*get_face_verts)(const OpenSubdiv_Converter *converter,
60                                int face,
61                                int *face_verts);
62         void (*get_face_edges)(const OpenSubdiv_Converter *converter,
63                                int face,
64                                int *face_edges);
65
66         /* Edge relationships. */
67         void (*get_edge_verts)(const OpenSubdiv_Converter *converter,
68                                int edge,
69                                int *edge_verts);
70         int (*get_num_edge_faces)(const OpenSubdiv_Converter *converter,
71                                   int edge);
72         void (*get_edge_faces)(const OpenSubdiv_Converter *converter,
73                                int edge,
74                                int *edge_faces);
75         float (*get_edge_sharpness)(const OpenSubdiv_Converter *converter,
76                                     int edge);
77
78         /* Vertex relationships. */
79         int (*get_num_vert_edges)(const OpenSubdiv_Converter *converter, int vert);
80         void (*get_vert_edges)(const OpenSubdiv_Converter *converter,
81                                int vert,
82                                int *vert_edges);
83         int (*get_num_vert_faces)(const OpenSubdiv_Converter *converter, int vert);
84         void (*get_vert_faces)(const OpenSubdiv_Converter *converter,
85                                int vert,
86                                int *vert_faces);
87
88         /* Face-varying data. */
89
90         int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter);
91
92         void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer);
93         void (*finish_uv_layer)(const OpenSubdiv_Converter *converter);
94
95         int (*get_num_uvs)(const OpenSubdiv_Converter *converter);
96         void (*get_uvs)(const OpenSubdiv_Converter *converter, float *uvs);
97
98         int (*get_face_corner_uv_index)(const OpenSubdiv_Converter *converter,
99                                         int face,
100                                         int corner);
101
102         void (*free_user_data)(const OpenSubdiv_Converter *converter);
103         void *user_data;
104 } OpenSubdiv_Converter;
105
106 OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
107         OpenSubdiv_Converter *converter);
108
109 void openSubdiv_deleteTopologyRefinerDescr(
110         OpenSubdiv_TopologyRefinerDescr *topology_refiner);
111
112 /* TODO(sergey): Those calls are not strictly related to conversion.
113  * needs some dedicated file perhaps.
114  */
115
116 int openSubdiv_topologyRefinerGetSubdivLevel(
117         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
118
119 int openSubdiv_topologyRefinerGetNumVerts(
120         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
121
122 int openSubdiv_topologyRefinerGetNumEdges(
123         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
124
125 int openSubdiv_topologyRefinerGetNumFaces(
126         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
127
128 int openSubdiv_topologyRefinerGetNumFaceVerts(
129         const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
130         int face);
131
132 int openSubdiv_topologyRefnerCompareConverter(
133         const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
134         OpenSubdiv_Converter *converter);
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif  /* __OPENSUBDIV_CONVERTER_CAPI_H__ */