1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
use crate::vtr::types::*;
pub type TopologyLevelPtr = *mut crate::OpenSubdiv_v3_7_0_Far_TopologyLevel;
#[link(name = "osd-capi", kind = "static")]
unsafe extern "C" {
/// Return the number of vertices in this level
pub fn TopologyLevel_GetNumVertices(tl: TopologyLevelPtr) -> u32;
/// Return the number of faces in this level
pub fn TopologyLevel_GetNumFaces(tl: TopologyLevelPtr) -> u32;
/// Return the number of edges in this level
pub fn TopologyLevel_GetNumEdges(tl: TopologyLevelPtr) -> u32;
/// Return the total number of face-vertices, i.e. the sum of all
/// vertices for all faces
pub fn TopologyLevel_GetNumFaceVertices(tl: TopologyLevelPtr) -> u32;
/// Methods to inspect topological relationships for individual
/// components:
///
/// With three main component types (vertices, faces and edges), for each of
/// the three components the TopologyLevel stores the incident/adjacent
/// components of the other two types. So there are six relationships
/// available for immediate inspection. All are accessed by methods
/// that return an array of fixed size containing the indices of the
/// incident components.
///
/// For some of the relations, i.e. those for which the incident components
/// are of higher order or 'contain' the component itself (e.g. a vertex
/// has incident faces that contain it), an additional 'local index' is
/// available that identifies the component within each of its
/// neighbors. For example, if vertex V is the k'th vertex in some face
/// F, then when F occurs in the set of incident vertices of V,
/// the local index corresponding to F will be k. The ordering of local
/// indices matches the ordering of the incident component to which it
/// corresponds.
/// Access the vertices incident a given face
pub fn TopologyLevel_GetFaceVertices(tl: TopologyLevelPtr, f: Index) -> ConstIndexArray;
/// Access the edges incident a given face
pub fn TopologyLevel_GetFaceEdges(tl: TopologyLevelPtr, f: Index) -> ConstIndexArray;
/// Access the vertices incident a given edge
pub fn TopologyLevel_GetEdgeVertices(tl: TopologyLevelPtr, e: Index) -> ConstIndexArray;
/// Access the faces incident a given edge
pub fn TopologyLevel_GetEdgeFaces(tl: TopologyLevelPtr, e: Index) -> ConstIndexArray;
/// Access the faces incident a given vertex
pub fn TopologyLevel_GetVertexFaces(tl: TopologyLevelPtr, v: Index) -> ConstIndexArray;
/// Access the edges incident a given vertex
pub fn TopologyLevel_GetVertexEdges(tl: TopologyLevelPtr, v: Index) -> ConstIndexArray;
/// Access the local indices of a vertex with respect to its incident
/// faces
pub fn TopologyLevel_GetVertexFaceLocalIndices(
tl: TopologyLevelPtr,
v: Index,
) -> ConstLocalIndexArray;
/// Access the local indices of a vertex with respect to its incident
/// edges
pub fn TopologyLevel_GetVertexEdgeLocalIndices(
tl: TopologyLevelPtr,
v: Index,
) -> ConstLocalIndexArray;
/// Access the local indices of an edge with respect to its incident
/// faces
pub fn TopologyLevel_GetEdgeFaceLocalIndices(
tl: TopologyLevelPtr,
e: Index,
) -> ConstLocalIndexArray;
/// Identify the edge matching the given vertex pair
pub fn TopologyLevel_FindEdge(tl: TopologyLevelPtr, v0: Index, v1: Index) -> Index;
/// Methods to inspect other topological properties of individual
/// components:
/// Return if the edge is non-manifold
pub fn TopologyLevel_IsEdgeNonManifold(tl: TopologyLevelPtr, e: Index) -> bool;
/// Return if the vertex is non-manifold
pub fn TopologyLevel_IsVertexNonManifold(tl: TopologyLevelPtr, v: Index) -> bool;
/// Return if the edge is a boundary
pub fn TopologyLevel_IsEdgeBoundary(tl: TopologyLevelPtr, e: Index) -> bool;
/// Return if the vertex is a boundary
pub fn TopologyLevel_IsVertexBoundary(tl: TopologyLevelPtr, v: Index) -> bool;
/// Methods to inspect feature tags for individual components:
///
/// While only a subset of components may have been tagged with features
/// such as sharpness, all such features have a default value and so all
/// components can be inspected.
/// Return the sharpness assigned a given edge
pub fn TopologyLevel_GetEdgeSharpness(tl: TopologyLevelPtr, e: Index) -> f32;
/// Return the sharpness assigned a given vertex
pub fn TopologyLevel_GetVertexSharpness(tl: TopologyLevelPtr, v: Index) -> f32;
/// Return if a given face has been tagged as a hole
pub fn TopologyLevel_IsFaceHole(tl: TopologyLevelPtr, f: Index) -> bool;
/// Return the subdivision rule assigned a given vertex specific to
/// this level
pub fn TopologyLevel_GetVertexRule(v: Index) -> u32;
//. Methods to inspect face-varying data:
///
/// Face-varying data is organized into topologically independent channels,
/// each with an integer identifier. Access to face-varying data generally
/// requires the specification of a channel, though with a single channel
/// being a common situation the first/only channel will be assumed if
/// unspecified.
///
/// A face-varying channel is composed of a set of values that may be shared
/// by faces meeting at a common vertex. Just as there are sets of vertices
/// that are associated with faces by index (ranging from 0 to
/// num-vertices - 1), face-varying values are also referenced by index
/// (ranging from 0 to num-values -1).
///
/// The face-varying values associated with a face are accessed similarly to
/// the way in which vertices associated with the face are accessed -- an
/// array of fixed size containing the indices for each corner is provided
/// for inspection, iteration, etc.
///
/// When the face-varying topology around a vertex "matches", it has the
/// same limit properties and so results in the same limit surface when
/// collections of adjacent vertices match. Like other references to
/// "topology", this includes consideration of sharpness. So it may be
/// that face-varying values are assigned around a vertex on a boundary in
/// a way that appears to match, but the face-varying interpolation option
/// requires sharpening of that vertex in face-varying space -- the
/// difference in the topology of the resulting limit surfaces leading to
/// the query returning false for the match. The edge case is simpler in
/// that it only considers continuity across the edge, not the entire
/// neighborhood around each end vertex.
/// Return the number of face-varying channels (should be same for
/// all levels)
pub fn TopologyLevel_GetNumFVarChannels(tl: TopologyLevelPtr) -> i32;
/// Return the total number of face-varying values in a particular
/// channel (the upper bound of a face-varying value index)
pub fn TopologyLevel_GetNumFVarValues(tl: TopologyLevelPtr, channel: i32) -> u32;
/// Access the face-varying values associated with a particular face
pub fn TopologyLevel_GetFaceFVarValues(
tl: TopologyLevelPtr,
f: Index,
channel: i32,
) -> ConstIndexArray;
/// Return if face-varying topology around a vertex matches
pub fn TopologyLevel_DoesVertexFVarTopologyMatch(
tl: TopologyLevelPtr,
v: Index,
channel: i32,
) -> bool;
/// Return if face-varying topology across the edge only matches
pub fn TopologyLevel_DoesEdgeFVarTopologyMatch(
tl: TopologyLevelPtr,
e: Index,
channel: i32,
) -> bool;
/// Return if face-varying topology around a face matches
pub fn TopologyLevel_DoesFaceFVarTopologyMatch(
tl: TopologyLevelPtr,
f: Index,
channel: i32,
) -> bool;
/// Methods to identify parent or child components in adjoining levels
/// of refinement:
/// Access the child faces (in the next level) of a given face
pub fn TopologyLevel_GetFaceChildFaces(tl: TopologyLevelPtr, f: Index) -> ConstIndexArray;
/// Access the child edges (in the next level) of a given face
pub fn TopologyLevel_GetFaceChildEdges(tl: TopologyLevelPtr, f: Index) -> ConstIndexArray;
/// Access the child edges (in the next level) of a given edge
pub fn TopologyLevel_GetEdgeChildEdges(tl: TopologyLevelPtr, e: Index) -> ConstIndexArray;
/// Return the child vertex (in the next level) of a given face
pub fn TopologyLevel_GetFaceChildVertex(tl: TopologyLevelPtr, f: Index) -> Index;
/// Return the child vertex (in the next level) of a given edge
pub fn TopologyLevel_GetEdgeChildVertex(tl: TopologyLevelPtr, e: Index) -> Index;
/// Return the child vertex (in the next level) of a given vertex
pub fn TopologyLevel_GetVertexChildVertex(tl: TopologyLevelPtr, v: Index) -> Index;
/// Return the parent face (in the previous level) of a given face
pub fn TopologyLevel_GetFaceParentFace(tl: TopologyLevelPtr, f: Index) -> Index;
/// Debugging aides:
pub fn TopologyLevel_ValidateTopology(tl: TopologyLevelPtr) -> bool;
pub fn TopologyLevel_PrintTopology(tl: TopologyLevelPtr, children: bool);
}