OpenSubdiv
topologyLevel.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 DreamWorks Animation LLC.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef OPENSUBDIV3_FAR_TOPOLOGY_LEVEL_H
25 #define OPENSUBDIV3_FAR_TOPOLOGY_LEVEL_H
26 
27 #include "../version.h"
28 
29 #include "../vtr/level.h"
30 #include "../vtr/refinement.h"
31 #include "../far/types.h"
32 
33 #include <vector>
34 
35 namespace OpenSubdiv {
36 namespace OPENSUBDIV_VERSION {
37 
38 namespace Far {
39 
50 
51 public:
53 
62  int GetNumVertices() const { return _level->getNumVertices(); }
63 
65  int GetNumFaces() const { return _level->getNumFaces(); }
66 
68  int GetNumEdges() const { return _level->getNumEdges(); }
69 
71  int GetNumFaceVertices() const { return _level->getNumFaceVerticesTotal(); }
73 
75  //
91 
93  ConstIndexArray GetFaceVertices(Index f) const { return _level->getFaceVertices(f); }
94 
96  ConstIndexArray GetFaceEdges(Index f) const { return _level->getFaceEdges(f); }
97 
99  ConstIndexArray GetEdgeVertices(Index e) const { return _level->getEdgeVertices(e); }
100 
102  ConstIndexArray GetEdgeFaces(Index e) const { return _level->getEdgeFaces(e); }
103 
105  ConstIndexArray GetVertexFaces(Index v) const { return _level->getVertexFaces(v); }
106 
108  ConstIndexArray GetVertexEdges(Index v) const { return _level->getVertexEdges(v); }
109 
111  ConstLocalIndexArray GetVertexFaceLocalIndices(Index v) const { return _level->getVertexFaceLocalIndices(v); }
112 
114  ConstLocalIndexArray GetVertexEdgeLocalIndices(Index v) const { return _level->getVertexEdgeLocalIndices(v); }
115 
117  ConstLocalIndexArray GetEdgeFaceLocalIndices(Index e) const { return _level->getEdgeFaceLocalIndices(e); }
118 
120  Index FindEdge(Index v0, Index v1) const { return _level->findEdge(v0, v1); }
122 
124 
128  bool IsEdgeNonManifold(Index e) const { return _level->isEdgeNonManifold(e); }
129 
131  bool IsVertexNonManifold(Index v) const { return _level->isVertexNonManifold(v); }
132 
134  bool IsEdgeBoundary(Index e) const { return _level->getEdgeTag(e)._boundary; }
135 
137  bool IsVertexBoundary(Index v) const { return _level->getVertexTag(v)._boundary; }
138 
140  bool IsVertexCorner(Index v) const { return (_level->getNumVertexFaces(v) == 1); }
141 
162  bool IsVertexValenceRegular(Index v) const { return !_level->getVertexTag(v)._xordinary || IsVertexCorner(v); }
164 
166 
173  float GetEdgeSharpness(Index e) const { return _level->getEdgeSharpness(e); }
174 
176  float GetVertexSharpness(Index v) const { return _level->getVertexSharpness(v); }
177 
179  bool IsEdgeInfSharp(Index e) const { return _level->getEdgeTag(e)._infSharp; }
180 
182  bool IsVertexInfSharp(Index v) const { return _level->getVertexTag(v)._infSharp; }
183 
185  bool IsEdgeSemiSharp(Index e) const { return _level->getEdgeTag(e)._semiSharp; }
186 
188  bool IsVertexSemiSharp(Index v) const { return _level->getVertexTag(v)._semiSharp; }
189 
191  bool IsFaceHole(Index f) const { return _level->isFaceHole(f); }
192 
194  Sdc::Crease::Rule GetVertexRule(Index v) const { return _level->getVertexRule(v); }
196 
198 
230  int GetNumFVarChannels() const { return _level->getNumFVarChannels(); }
231 
234  int GetNumFVarValues(int channel = 0) const { return _level->getNumFVarValues(channel); }
235 
237  ConstIndexArray GetFaceFVarValues(Index f, int channel = 0) const {
238  return _level->getFaceFVarValues(f, channel);
239  }
240 
242  bool DoesVertexFVarTopologyMatch(Index v, int channel = 0) const {
243  return _level->doesVertexFVarTopologyMatch(v, channel);
244  }
245 
247  bool DoesEdgeFVarTopologyMatch(Index e, int channel = 0) const {
248  return _level->doesEdgeFVarTopologyMatch(e, channel);
249  }
250 
252  bool DoesFaceFVarTopologyMatch(Index f, int channel = 0) const {
253  return _level->doesFaceFVarTopologyMatch(f, channel);
254  }
255 
257 
259 
262  ConstIndexArray GetFaceChildFaces(Index f) const { return _refToChild->getFaceChildFaces(f); }
263 
265  ConstIndexArray GetFaceChildEdges(Index f) const { return _refToChild->getFaceChildEdges(f); }
266 
268  ConstIndexArray GetEdgeChildEdges(Index e) const { return _refToChild->getEdgeChildEdges(e); }
269 
271  Index GetFaceChildVertex( Index f) const { return _refToChild->getFaceChildVertex(f); }
272 
274  Index GetEdgeChildVertex( Index e) const { return _refToChild->getEdgeChildVertex(e); }
275 
277  Index GetVertexChildVertex(Index v) const { return _refToChild->getVertexChildVertex(v); }
278 
280  Index GetFaceParentFace(Index f) const { return _refToParent->getChildFaceParentFace(f); }
282 
284 
286  bool ValidateTopology() const { return _level->validateTopology(); }
287  void PrintTopology(bool children = true) const { _level->print((children && _refToChild) ? _refToChild : 0); }
289 
290 
291 private:
292  friend class TopologyRefiner;
293 
294  Vtr::internal::Level const * _level;
295  Vtr::internal::Refinement const * _refToParent;
296  Vtr::internal::Refinement const * _refToChild;
297 
298 public:
299  // Not intended for public use, but required by std::vector, etc...
302 };
303 
304 } // end namespace Far
305 
306 } // end namespace OPENSUBDIV_VERSION
307 using namespace OPENSUBDIV_VERSION;
308 } // end namespace OpenSubdiv
309 
310 #endif /* OPENSUBDIV3_FAR_TOPOLOGY_LEVEL_H */
void PrintTopology(bool children=true) const
ConstLocalIndexArray GetEdgeFaceLocalIndices(Index e) const
Access the local indices of an edge with respect to its incident faces.
Index GetEdgeChildVertex(Index e) const
Return the child vertex (in the next level) of a given edge.
int GetNumFaces() const
Return the number of faces in this level.
Definition: topologyLevel.h:65
bool IsVertexValenceRegular(Index v) const
Return if the valence of the vertex is regular (must be manifold)
bool IsEdgeInfSharp(Index e) const
Return if the edge is infinitely-sharp.
bool IsVertexCorner(Index v) const
Return if the vertex is a corner (only one incident face)
bool IsFaceHole(Index f) const
Return if a given face has been tagged as a hole.
bool IsEdgeSemiSharp(Index e) const
Return if the edge is semi-sharp.
bool DoesEdgeFVarTopologyMatch(Index e, int channel=0) const
Return if face-varying topology across the edge only matches.
ConstIndexArray GetVertexFaces(Index v) const
Access the faces incident a given vertex.
bool IsEdgeNonManifold(Index e) const
Return if the edge is non-manifold.
bool DoesVertexFVarTopologyMatch(Index v, int channel=0) const
Return if face-varying topology around a vertex matches.
ConstLocalIndexArray GetVertexEdgeLocalIndices(Index v) const
Access the local indices of a vertex with respect to its incident edges.
Index GetFaceParentFace(Index f) const
Return the parent face (in the previous level) of a given face.
ConstIndexArray GetFaceEdges(Index f) const
Access the edges incident a given face.
Definition: topologyLevel.h:96
int GetNumEdges() const
Return the number of edges in this level.
Definition: topologyLevel.h:68
Stores topology data for a specified set of refinement options.
float GetEdgeSharpness(Index e) const
Return the sharpness assigned a given edge.
ConstIndexArray GetEdgeChildEdges(Index e) const
Access the child edges (in the next level) of a given edge.
bool IsVertexInfSharp(Index v) const
Return if the vertex is infinitely-sharp.
bool IsVertexSemiSharp(Index v) const
Return if the vertex is semi-sharp.
ConstIndexArray GetFaceVertices(Index f) const
Access the vertices incident a given face.
Definition: topologyLevel.h:93
int GetNumVertices() const
Return the number of vertices in this level.
Definition: topologyLevel.h:62
int GetNumFaceVertices() const
Return the total number of face-vertices, i.e. the sum of all vertices for all faces.
Definition: topologyLevel.h:71
ConstIndexArray GetVertexEdges(Index v) const
Access the edges incident a given vertex.
ConstLocalIndexArray GetVertexFaceLocalIndices(Index v) const
Access the local indices of a vertex with respect to its incident faces.
bool IsVertexNonManifold(Index v) const
Return if the vertex is non-manifold.
Index GetFaceChildVertex(Index f) const
Return the child vertex (in the next level) of a given face.
Index FindEdge(Index v0, Index v1) const
Identify the edge matching the given vertex pair.
ConstIndexArray GetFaceChildEdges(Index f) const
Access the child edges (in the next level) of a given face.
ConstIndexArray GetFaceFVarValues(Index f, int channel=0) const
Access the face-varying values associated with a particular face.
Index GetVertexChildVertex(Index v) const
Return the child vertex (in the next level) of a given vertex.
bool DoesFaceFVarTopologyMatch(Index f, int channel=0) const
Return if face-varying topology around a face matches.
float GetVertexSharpness(Index v) const
Return the sharpness assigned a given vertex.
Sdc::Crease::Rule GetVertexRule(Index v) const
Return the subdivision rule assigned a given vertex specific to this level.
int GetNumFVarValues(int channel=0) const
Return the total number of face-varying values in a particular channel (the upper bound of a face-var...
bool IsVertexBoundary(Index v) const
Return if the vertex is on a boundary (at least one incident boundary edge)
An interface for accessing data in a specific level of a refined topology hierarchy.
Definition: topologyLevel.h:49
ConstIndexArray GetFaceChildFaces(Index f) const
Access the child faces (in the next level) of a given face.
ConstIndexArray GetEdgeVertices(Index e) const
Access the vertices incident a given edge.
Definition: topologyLevel.h:99
bool IsEdgeBoundary(Index e) const
Return if the edge is a boundary (only one incident face)
int GetNumFVarChannels() const
Return the number of face-varying channels (should be same for all levels)
ConstIndexArray GetEdgeFaces(Index e) const
Access the faces incident a given edge.