Blender  V3.3
opensubdiv_topology_refiner_capi.h
Go to the documentation of this file.
1 // Copyright 2018 Blender Foundation. All rights reserved.
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software Foundation,
15 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 //
17 // Author: Sergey Sharybin
18 
19 #ifndef OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
20 #define OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
21 
22 #include <stdint.h> // for bool
23 
24 #include "opensubdiv_capi_type.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
32 
33 // Those settings don't really belong to OpenSubdiv's topology refiner, but
34 // we are keeping track of them on our side of topology refiner. This is to
35 // make it possible to ensure we are not trying to abuse same OpenSubdiv's
36 // topology refiner with different subdivision levels or with different
37 // adaptive settings.
40  int level;
42 
43 // C-style wrapper around actual topology refiner.
44 //
45 // The only purpose is to allow C-only code to access C++ implementation of the
46 // topology refiner.
48  // Query subdivision level the refiner is created for.
49  int (*getSubdivisionLevel)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
50  bool (*getIsAdaptive)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
51 
52  // NOTE: All queries are querying base level.
53  //
54  // TODO(sergey): Consider making it more obvious in function naming,
55  // but since it's unlikely (or at least, will be uncommon use) for API
56  // which queries final geometry, we should be fine with this name for
57  // now.
58 
60  // Query basic topology information from base level.
61 
62  int (*getNumVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
63  int (*getNumEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
64  int (*getNumFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
65 
66  int (*getNumFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
67  const int face_index);
68  void (*getFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
69  const int face_index,
70  int *face_vertices_indices);
71 
72  int (*getNumFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
73  const int face_index);
74  void (*getFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
75  const int face_index,
76  int *face_edges_indices);
77  void (*getEdgeVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
78  const int edge_index,
79  int edge_vertices_indices[2]);
80 
81  int (*getNumVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
82  const int vertex_index);
83  void (*getVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
84  const int vertex_index,
85  int *vertex_edges_indices);
86 
88  // PTex face geometry queries.
89 
90  // Ptex face corresponds to OpenSubdiv's internal "patch" and to Blender's
91  // subdivision grid. The rule commes as:
92  // - Triangle face consist of 3 ptex faces, ordered in the order of
93  // face-vertices.
94  // - Quad face consists of a single ptex face.
95  // - N-gons (similar to triangle) consists of N ptex faces, ordered same
96  // way as for triangle.
97  int (*getNumFacePtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
98  const int face_index);
99  int (*getNumPtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
100 
101  // Initialize a per-base-face offset measured in ptex face indices.
102  //
103  // Basically, face_ptex_offset[base_face_index] is a total number of ptex
104  // faces created for bases faces [0 .. base_face_index - 1].
105  //
106  // The array must contain at least total number of ptex faces elements.
107  void (*fillFacePtexIndexOffset)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
108  int *face_ptex_index_offset);
109 
111  // Face-varying data.
112 
113  // Number of face-varying channels (or how they are called in Blender layers).
114  int (*getNumFVarChannels)(const struct OpenSubdiv_TopologyRefiner *topology_refiner);
115  // Get face-varying interpolation type.
117  const struct OpenSubdiv_TopologyRefiner *topology_refiner);
118  // Get total number of face-varying values in a particular channel.
119  int (*getNumFVarValues)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
120  const int channel);
121  // Get face-varying value indices associated with a particular face.
122  //
123  // This is an array of indices inside of face-varying array, array elements
124  // are aligned with face corners (or loops in Blender terminology).
125  const int *(*getFaceFVarValueIndices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner,
126  const int face_index,
127  const int channel);
128 
130  // Internal use.
131 
132  // Implementation of the topology refiner.
135 
136 // NOTE: Will return NULL in cases of bad topology.
137 // NOTE: Mesh without faces is considered a bad topology.
140 
142 
143 // Compare given topology refiner with converter. Returns truth if topology
144 // refiner matches given converter, false otherwise.
145 //
146 // This allows users to construct converter (which is supposed to be cheap)
147 // and compare with existing refiner before going into more computationally
148 // complicated parts of subdivision process.
151  const struct OpenSubdiv_Converter *converter);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif // OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
OpenSubdiv::Far::TopologyRefiner * topology_refiner
OpenSubdiv_TopologyRefinerSettings settings
SyclQueue void void size_t num_bytes void
OpenSubdiv_FVarLinearInterpolation
void openSubdiv_deleteTopologyRefiner(OpenSubdiv_TopologyRefiner *topology_refiner)
struct OpenSubdiv_TopologyRefiner OpenSubdiv_TopologyRefiner
bool openSubdiv_topologyRefinerCompareWithConverter(const OpenSubdiv_TopologyRefiner *topology_refiner, const struct OpenSubdiv_Converter *converter)
OpenSubdiv_TopologyRefiner * openSubdiv_createTopologyRefinerFromConverter(struct OpenSubdiv_Converter *converter, const OpenSubdiv_TopologyRefinerSettings *settings)
struct OpenSubdiv_TopologyRefinerSettings OpenSubdiv_TopologyRefinerSettings
int(* getNumVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int vertex_index)
int(* getNumFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index)
void(* getFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index, int *face_edges_indices)
void(* fillFacePtexIndexOffset)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, int *face_ptex_index_offset)
void(* getFaceVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index, int *face_vertices_indices)
int(* getNumPtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
void(* getVertexEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int vertex_index, int *vertex_edges_indices)
OpenSubdiv_FVarLinearInterpolation(* getFVarLinearInterpolation)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
struct OpenSubdiv_TopologyRefinerImpl * impl
int(* getNumFVarValues)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int channel)
void(* getEdgeVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int edge_index, int edge_vertices_indices[2])
bool(* getIsAdaptive)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getSubdivisionLevel)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumFaceEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index)
int(* getNumFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumFacePtexFaces)(const struct OpenSubdiv_TopologyRefiner *topology_refiner, const int face_index)
int(* getNumFVarChannels)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumEdges)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)
int(* getNumVertices)(const struct OpenSubdiv_TopologyRefiner *topology_refiner)