OpenSubdiv: Initial work to support UV maps in textured OSD viewport
[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         int (*get_num_faces)(const OpenSubdiv_Converter *converter);
51         int (*get_num_edges)(const OpenSubdiv_Converter *converter);
52         int (*get_num_verts)(const OpenSubdiv_Converter *converter);
53
54         /* Face relationships. */
55         int (*get_num_face_verts)(const OpenSubdiv_Converter *converter,
56                                   int face);
57         void (*get_face_verts)(const OpenSubdiv_Converter *converter,
58                                int face,
59                                int *face_verts);
60         void (*get_face_edges)(const OpenSubdiv_Converter *converter,
61                                int face,
62                                int *face_edges);
63
64         /* Edge relationships. */
65         void (*get_edge_verts)(const OpenSubdiv_Converter *converter,
66                                int edge,
67                                int *edge_verts);
68         int (*get_num_edge_faces)(const OpenSubdiv_Converter *converter,
69                                   int edge);
70         void (*get_edge_faces)(const OpenSubdiv_Converter *converter,
71                                int edge,
72                                int *edge_faces);
73         float (*get_edge_sharpness)(const OpenSubdiv_Converter *converter,
74                                     int edge);
75
76         /* Vertex relationships. */
77         int (*get_num_vert_edges)(const OpenSubdiv_Converter *converter, int vert);
78         void (*get_vert_edges)(const OpenSubdiv_Converter *converter,
79                                int vert,
80                                int *vert_edges);
81         int (*get_num_vert_faces)(const OpenSubdiv_Converter *converter, int vert);
82         void (*get_vert_faces)(const OpenSubdiv_Converter *converter,
83                                int vert,
84                                int *vert_faces);
85
86         /* Face-varying data. */
87
88         int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter);
89         void (*get_face_corner_uv)(const OpenSubdiv_Converter *converter,
90                                    int face,
91                                    int corner,
92                                    float r_uv[2]);
93
94         void (*free_user_data)(const OpenSubdiv_Converter *converter);
95         void *user_data;
96 } OpenSubdiv_Converter;
97
98 OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr(
99         OpenSubdiv_Converter *converter);
100
101 void openSubdiv_deleteTopologyRefinerDescr(
102         OpenSubdiv_TopologyRefinerDescr *topology_refiner);
103
104 /* TODO(sergey): Those calls are not strictly related to conversion.
105  * needs some dedicated file perhaps.
106  */
107
108 int openSubdiv_topologyRefinerGetSubdivLevel(
109         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
110
111 int openSubdiv_topologyRefinerGetNumVerts(
112         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
113
114 int openSubdiv_topologyRefinerGetNumEdges(
115         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
116
117 int openSubdiv_topologyRefinerGetNumFaces(
118         const OpenSubdiv_TopologyRefinerDescr *topology_refiner);
119
120 int openSubdiv_topologyRefinerGetNumFaceVerts(
121         const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
122         int face);
123
124 int openSubdiv_topologyRefnerCompareConverter(
125         const OpenSubdiv_TopologyRefinerDescr *topology_refiner,
126         OpenSubdiv_Converter *converter);
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif  /* __OPENSUBDIV_CONVERTER_CAPI_H__ */