All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
level.h
Go to the documentation of this file.
1 //
2 // Copyright 2014 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 VTR_LEVEL_H
25 #define VTR_LEVEL_H
26 
27 #include "../version.h"
28 
29 #include "../sdc/type.h"
30 #include "../sdc/crease.h"
31 #include "../sdc/options.h"
32 #include "../vtr/types.h"
33 
34 #include <algorithm>
35 #include <vector>
36 #include <cassert>
37 #include <cstring>
38 
39 
40 namespace OpenSubdiv {
41 namespace OPENSUBDIV_VERSION {
42 
43 // Forward declarations for friends:
44 namespace Far {
45  template <class MESH> class TopologyRefinerFactory;
46  class TopologyRefinerFactoryBase;
47  class TopologyRefiner;
48  class PatchTablesFactory;
49 }
50 
51 namespace Vtr {
52 
53 class Refinement;
54 class QuadRefinement;
55 class TriRefinement;
56 class FVarRefinement;
57 class FVarLevel;
58 
59 //
60 // Level:
61 // A refinement level includes a vectorized representation of the topology
62 // for a particular subdivision level. The topology is "complete" in that any
63 // level can be used as the base level of another subdivision hierarchy and can
64 // be considered a complete mesh independent of its ancestors. It currently
65 // does contain a "depth" member -- as some inferences can then be made about
66 // the topology (i.e. all quads or all tris if not level 0) but that is still
67 // under consideration (e.g. a "regular" flag would serve the same purpose, and
68 // level 0 may even be regular).
69 //
70 // This class is intended for private use within the library. So really its
71 // interface should be fully protected and only those library classes that need
72 // it will be declared as friends, e.g. Refinement.
73 //
74 // The represenation of topology here is to store six topological relationships
75 // in tables of integers. Each is stored in its own array(s) so the result is
76 // a SOA representation of the topology. The six relations are:
77 //
78 // - face-verts: vertices incident/comprising a face
79 // - face-edges: edges incident a face
80 // - edge-verts: vertices incident/comprising an edge
81 // - edge-faces: faces incident an edge
82 // - vert-faces: faces incident a vertex
83 // - vert-edges: edges incident a vertex
84 //
85 // There is some redundancy here but the intent is not that this be a minimal
86 // represenation, the intent is that it be amenable to refinement. Classes in
87 // the Far layer essentially store 5 of these 6 in a permuted form -- we add
88 // the face-edges here to simplify refinement.
89 //
90 // Notes/limitations/stuff to do -- much of this code still reflects the early days
91 // when it was being prototyped and so it does not conform to OSD standards in many
92 // ways:
93 // - superficial stylistic issues:
94 // . replacing "m" prefix with "_" on member variables
95 // - done
96 // . replace "access" and "modify" prefixes on Array methods with "get"
97 // - done
98 // - replace use of "...Count" with "GetNum..."
99 // - use of Vertex vs Vert in non-local (or any?) methods
100 // - review public/protected/friend accessibility
101 //
102 // Most are more relevant to the refinement, which used to be part of this class:
103 // - short cuts that need revisiting:
104 // - support for face-vert counts > 4
105 // - support for edge-face counts > 2
106 // - some neighborhood searches avoidable with more "local indexing"
107 // - identify (informally) where scheme-specific code will be needed, so far:
108 // - topological splitting and associated marking
109 // - really the only variable here is whether to generate tris or
110 // quads from non-quads
111 // - interpolation
112 // - potentially not part of the pre-processing required for FarMesh
113 // and where it appears *not* to be needed:
114 // - subdivision of sharpness values
115 // - classification of vertex type/mask
116 // - apply classification of vertices (computing Rules or masks)
117 // - apply to base/course level on conversion
118 // - apply to child level after subdivision of sharpness
119 // - keep in mind desired similarity with FarMesh tables for ease of transfer
120 // (contradicts previous point to some degree)
121 //
122 
123 class Level {
124 
125 public:
126  //
127  // Simple nested types to hold the tags for each component type -- some of
128  // which are user-specified features (e.g. whether a face is a hole or not)
129  // while others indicate the topological nature of the component, how it
130  // is affected by creasing in its neighborhood, etc.
131  //
132  // Most of these properties are passed down to child components during
133  // refinement, but some -- notably the designation of a component as semi-
134  // sharp -- require re-determination as sharpnes values are reduced at each
135  // level.
136  //
137  struct VTag {
138  typedef unsigned short VTagSize;
139 
140  VTag() { }
141 
142  VTagSize _nonManifold : 1; // fixed
143  VTagSize _xordinary : 1; // fixed
144  VTagSize _boundary : 1; // fixed
145  VTagSize _infSharp : 1; // fixed
146  VTagSize _semiSharp : 1; // variable
147  VTagSize _rule : 4; // variable when _semiSharp
148  VTagSize _incomplete : 1; // variable for sparse refinement
149 
150  // On deck -- coming soon...
151  //VTagSize _constSharp : 1; // variable when _semiSharp
152  //VTagSize _hasEdits : 1; // variable
153  //VTagSize _editsApplied : 1; // variable
154  };
155  struct ETag {
156  typedef unsigned char ETagSize;
157 
158  ETag() { }
159 
160  ETagSize _nonManifold : 1; // fixed
161  ETagSize _boundary : 1; // fixed
162  ETagSize _infSharp : 1; // fixed
163  ETagSize _semiSharp : 1; // variable
164  };
165  struct FTag {
166  typedef unsigned char FTagSize;
167 
168  FTag() { }
169 
170  FTagSize _hole : 1; // fixed
171 
172  // On deck -- coming soon...
173  //FTagSize _hasEdits : 1; // variable
174  };
175 
176  VTag getFaceCompositeVTag(IndexArray const& faceVerts) const;
177 
178 public:
179  Level();
180  ~Level();
181 
182  // Simple accessors:
183  int getDepth() const { return _depth; }
184 
185  int getNumVertices() const { return _vertCount; }
186  int getNumFaces() const { return _faceCount; }
187  int getNumEdges() const { return _edgeCount; }
188 
189  // More global sizes may prove useful...
190  int getNumFaceVerticesTotal() const { return (int) _faceVertIndices.size(); }
191  int getNumFaceEdgesTotal() const { return (int) _faceEdgeIndices.size(); }
192  int getNumEdgeVerticesTotal() const { return (int) _edgeVertIndices.size(); }
193  int getNumEdgeFacesTotal() const { return (int) _edgeFaceIndices.size(); }
194  int getNumVertexFacesTotal() const { return (int) _vertFaceIndices.size(); }
195  int getNumVertexEdgesTotal() const { return (int) _vertEdgeIndices.size(); }
196 
197  int getMaxValence() const { return _maxValence; }
198  int getMaxEdgeFaces() const { return _maxEdgeFaces; }
199 
200  // Methods to access the relation tables/indices -- note that for some relations
201  // we store an additional "local index", e.g. for the case of vert-faces if one
202  // of the faces F[i] is incident a vertex V, then L[i] is the "local index" in
203  // F[i] of vertex V. Once have only quads (or tris), this local index need only
204  // occupy two bits and could conceivably be packed into the same integer as the
205  // face index, but for now, given the need to support faces of potentially high
206  // valence we'll us an 8- or 16-bit integer.
207  //
208  // Methods to access the six topological relations:
209  IndexArray const getFaceVertices(Index faceIndex) const;
210  IndexArray const getFaceEdges(Index faceIndex) const;
211  IndexArray const getEdgeVertices(Index edgeIndex) const;
212  IndexArray const getEdgeFaces(Index edgeIndex) const;
213  IndexArray const getVertexFaces(Index vertIndex) const;
214  IndexArray const getVertexEdges(Index vertIndex) const;
215 
216  LocalIndexArray const getVertexFaceLocalIndices(Index vertIndex) const;
217  LocalIndexArray const getVertexEdgeLocalIndices(Index vertIndex) const;
218 
219  // Replace these with access to sharpness buffers/arrays rather than elements:
220  Sharpness getEdgeSharpness(Index edgeIndex) const;
221  Sharpness getVertexSharpness(Index vertIndex) const;
222  Sdc::Crease::Rule getVertexRule(Index vertIndex) const;
223 
224  Index findEdge(Index v0Index, Index v1Index) const;
225 
226  // Holes
227  void setHole(Index faceIndex, bool b);
228  bool isHole(Index faceIndex) const;
229 
230 public:
231  // Debugging aides -- unclear what will persist...
232  bool validateTopology() const;
233 
234  void print(const Refinement* parentRefinement = 0) const;
235 
236 public:
237  // High-level topology queries -- these are likely to be moved elsewhere, but here
238  // is the best place for them for now...
239 
240  int gatherManifoldVertexRingFromIncidentQuads(Index vIndex, int vOffset, int ringVerts[]) const;
241 
242  int gatherQuadRegularInteriorPatchVertices(Index fIndex, Index patchVerts[], int rotation = 0) const;
243  int gatherQuadRegularBoundaryPatchVertices(Index fIndex, Index patchVerts[], int boundaryEdgeInFace) const;
244  int gatherQuadRegularCornerPatchVertices( Index fIndex, Index patchVerts[], int cornerVertInFace) const;
245 
246  int gatherTriRegularInteriorPatchVertices( Index fIndex, Index patchVerts[], int rotation = 0) const;
247  int gatherTriRegularBoundaryVertexPatchVertices(Index fIndex, Index patchVerts[], int boundaryVertInFace) const;
248  int gatherTriRegularBoundaryEdgePatchVertices( Index fIndex, Index patchVerts[], int boundaryEdgeInFace) const;
249  int gatherTriRegularCornerVertexPatchVertices( Index fIndex, Index patchVerts[], int cornerVertInFace) const;
250  int gatherTriRegularCornerEdgePatchVertices( Index fIndex, Index patchVerts[], int cornerEdgeInFace) const;
251 
252  bool isSingleCreasePatch(Index face, float* sharpnessOut=NULL, int* rotationOut=NULL) const;
253 
254 protected:
255 
256  friend class Refinement;
257  friend class QuadRefinement;
258  friend class TriRefinement;
259  friend class FVarRefinement;
260  friend class FVarLevel;
261 
262  template <class MESH> friend class Far::TopologyRefinerFactory;
264  friend class Far::TopologyRefiner;
266 
267  // Sizing methods used to construct a level to populate:
268  void resizeFaces( int numFaces);
269  void resizeFaceVertices(int numFaceVertsTotal);
270  void resizeFaceEdges( int numFaceEdgesTotal);
271 
272  void resizeEdges( int numEdges);
273  void resizeEdgeVertices(); // always 2*edgeCount
274  void resizeEdgeFaces(int numEdgeFacesTotal);
275 
276  void resizeVertices( int numVertices);
277  void resizeVertexFaces(int numVertexFacesTotal);
278  void resizeVertexEdges(int numVertexEdgesTotal);
279 
280  // Modifiers to populate the relations for each component:
281  IndexArray getFaceVertices(Index faceIndex);
282  IndexArray getFaceEdges(Index faceIndex);
283  IndexArray getEdgeVertices(Index edgeIndex);
284  IndexArray getEdgeFaces(Index edgeIndex);
285  IndexArray getVertexFaces( Index vertIndex);
287  IndexArray getVertexEdges( Index vertIndex);
289 
290  // Replace these with access to sharpness buffers/arrays rather than elements:
291  Sharpness& getEdgeSharpness(Index edgeIndex);
292  Sharpness& getVertexSharpness(Index vertIndex);
293 
294  // Create, destroy and populate face-varying channels:
295  int createFVarChannel(int fvarValueCount, Sdc::Options const& options);
296  void destroyFVarChannel(int channel = 0);
297 
298  int getNumFVarChannels() const { return (int) _fvarChannels.size(); }
299  int getNumFVarValues(int channel = 0) const;
300 
301  IndexArray const getFVarFaceValues(Index faceIndex, int channel = 0) const;
302  IndexArray getFVarFaceValues(Index faceIndex, int channel = 0);
303 
304  void completeFVarChannelTopology(int channel = 0);
305 
306  // Counts and offsets for all relation types:
307  // - these may be unwarranted if we let Refinement access members directly...
308  int getNumFaceVertices( Index faceIndex) const { return _faceVertCountsAndOffsets[2*faceIndex]; }
309  int getOffsetOfFaceVertices(Index faceIndex) const { return _faceVertCountsAndOffsets[2*faceIndex + 1]; }
310 
311  int getNumFaceEdges( Index faceIndex) const { return getNumFaceVertices(faceIndex); }
312  int getOffsetOfFaceEdges(Index faceIndex) const { return getOffsetOfFaceVertices(faceIndex); }
313 
314  int getNumEdgeVertices( Index ) const { return 2; }
315  int getOffsetOfEdgeVertices(Index edgeIndex) const { return 2 * edgeIndex; }
316 
317  int getNumEdgeFaces( Index edgeIndex) const { return _edgeFaceCountsAndOffsets[2*edgeIndex]; }
318  int getOffsetOfEdgeFaces(Index edgeIndex) const { return _edgeFaceCountsAndOffsets[2*edgeIndex + 1]; }
319 
320  int getNumVertexFaces( Index vertIndex) const { return _vertFaceCountsAndOffsets[2*vertIndex]; }
321  int getOffsetOfVertexFaces(Index vertIndex) const { return _vertFaceCountsAndOffsets[2*vertIndex + 1]; }
322 
323  int getNumVertexEdges( Index vertIndex) const { return _vertEdgeCountsAndOffsets[2*vertIndex]; }
324  int getOffsetOfVertexEdges(Index vertIndex) const { return _vertEdgeCountsAndOffsets[2*vertIndex + 1]; }
325 
326 
327  //
328  // Note that for some relations, the size of the relations for a child component
329  // can vary radically from its parent due to the sparsity of the refinement. So
330  // in these cases a few additional utilities are provided to help define the set
331  // of incident components. Assuming adequate memory has been allocated, the
332  // "resize" methods here initialize the set of incident components by setting
333  // both the size and the appropriate offset, while "trim" is use to quickly lower
334  // the size from an upper bound and nothing else.
335  //
336  void resizeFaceVertices(Index FaceIndex, int count);
337 
338  void resizeEdgeFaces(Index edgeIndex, int count);
339  void trimEdgeFaces( Index edgeIndex, int count);
340 
341  void resizeVertexFaces(Index vertIndex, int count);
342  void trimVertexFaces( Index vertIndex, int count);
343 
344  void resizeVertexEdges(Index vertIndex, int count);
345  void trimVertexEdges( Index vertIndex, int count);
346 
347 protected:
348  //
349  // Plans where to have a few specific friend classes properly construct the topology,
350  // e.g. the Refinement class. There is now clearly a need to have some class
351  // construct full topology given only a simple face-vertex list. That can be done
352  // externally (either a Factory outside Vtr or another Vtr construction helper), but
353  // until we decide where, the required implementation is defined here.
354  //
356  Index findEdge(Index v0, Index v1, IndexArray const& v0Edges) const;
357 
358  // Methods supporting the above:
360  bool orderVertexFacesAndEdges(Index vIndex, Index* vFaces, Index* vEdges) const;
361  bool orderVertexFacesAndEdges(Index vIndex);
362  void populateLocalIndices();
363 
365 
366 protected:
367  //
368  // A Level is independent of subdivision scheme or options. While it may have been
369  // affected by them in its construction, they are not associated with it -- a Level
370  // is pure topology and any subdivision parameters are external.
371  //
372 
373  // Simple members for inventory, etc.
377 
378  // TBD - "depth" is clearly useful in both the topological splitting and the
379  // stencil queries so could be valuable in both. As face-vert valence becomes
380  // constant there is no need to store face-vert and face-edge counts so it has
381  // value in Level, though perhaps specified as something other than "depth"
382  int _depth;
385 
386  //
387  // Topology vectors:
388  // Note that of all of these, only data for the face-edge relation is not
389  // stored in the osd::FarTables in any form. The FarTable vectors combine
390  // the edge-vert and edge-face relations. The eventual goal is that this
391  // data be part of the osd::Far classes and be a superset of the FarTable
392  // vectors, i.e. no data duplication or conversion. The fact that FarTable
393  // already stores 5 of the 6 possible relations should make the topology
394  // storage as a whole a non-issue.
395  //
396  // The vert-face-child and vert-edge-child indices are also arguably not
397  // a topology relation but more one for parent/child relations. But it is
398  // a topological relationship, and if named differently would not likely
399  // raise this. It has been named with "child" in the name as it does play
400  // a more significant role during subdivision in mapping between parent
401  // and child components, and so has been named to reflect that more clearly.
402  //
403 
404  // Per-face:
405  std::vector<Index> _faceVertCountsAndOffsets; // 2 per face, redundant after level 0
406  std::vector<Index> _faceVertIndices; // 3 or 4 per face, variable at level 0
407  std::vector<Index> _faceEdgeIndices; // matches face-vert indices
408  std::vector<FTag> _faceTags; // 1 per face: includes "hole" tag
409 
410  // Per-edge:
411  std::vector<Index> _edgeVertIndices; // 2 per edge
412  std::vector<Index> _edgeFaceCountsAndOffsets; // 2 per edge
413  std::vector<Index> _edgeFaceIndices; // varies with faces per edge
414 
415  std::vector<Sharpness> _edgeSharpness; // 1 per edge
416  std::vector<ETag> _edgeTags; // 1 per edge: manifold, boundary, etc.
417 
418  // Per-vertex:
419  std::vector<Index> _vertFaceCountsAndOffsets; // 2 per vertex
420  std::vector<Index> _vertFaceIndices; // varies with valence
421  std::vector<LocalIndex> _vertFaceLocalIndices; // varies with valence, 8-bit for now
422 
423  std::vector<Index> _vertEdgeCountsAndOffsets; // 2 per vertex
424  std::vector<Index> _vertEdgeIndices; // varies with valence
425  std::vector<LocalIndex> _vertEdgeLocalIndices; // varies with valence, 8-bit for now
426 
427  std::vector<Sharpness> _vertSharpness; // 1 per vertex
428  std::vector<VTag> _vertTags; // 1 per vertex: manifold, Sdc::Rule, etc.
429 
430  // Face-varying channels:
431  std::vector<FVarLevel*> _fvarChannels;
432 };
433 
434 //
435 // Access/modify the vertices indicent a given face:
436 //
437 inline IndexArray const
438 Level::getFaceVertices(Index faceIndex) const {
439  return IndexArray(&_faceVertIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
440  _faceVertCountsAndOffsets[faceIndex*2]);
441 }
442 inline IndexArray
444  return IndexArray(&_faceVertIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
445  _faceVertCountsAndOffsets[faceIndex*2]);
446 }
447 
448 inline void
449 Level::resizeFaceVertices(Index faceIndex, int count) {
450  assert(count < 256);
451 
452  int* countOffsetPair = &_faceVertCountsAndOffsets[faceIndex*2];
453 
454  countOffsetPair[0] = count;
455  countOffsetPair[1] = (faceIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
456 
457  _maxValence = std::max(_maxValence, count);
458 }
459 
460 //
461 // Access/modify the edges indicent a given face:
462 //
463 inline IndexArray const
464 Level::getFaceEdges(Index faceIndex) const {
465  return IndexArray(&_faceEdgeIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
466  _faceVertCountsAndOffsets[faceIndex*2]);
467 }
468 inline IndexArray
470  return IndexArray(&_faceEdgeIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
471  _faceVertCountsAndOffsets[faceIndex*2]);
472 }
473 
474 //
475 // Access/modify the faces indicent a given vertex:
476 //
477 inline IndexArray const
478 Level::getVertexFaces(Index vertIndex) const {
479  return IndexArray(&_vertFaceIndices[_vertFaceCountsAndOffsets[vertIndex*2+1]],
480  _vertFaceCountsAndOffsets[vertIndex*2]);
481 }
482 inline IndexArray
484  return IndexArray(&_vertFaceIndices[_vertFaceCountsAndOffsets[vertIndex*2+1]],
485  _vertFaceCountsAndOffsets[vertIndex*2]);
486 }
487 
488 inline LocalIndexArray const
491  _vertFaceCountsAndOffsets[vertIndex*2]);
492 }
493 inline LocalIndexArray
496  _vertFaceCountsAndOffsets[vertIndex*2]);
497 }
498 
499 inline void
500 Level::resizeVertexFaces(Index vertIndex, int count) {
501  int* countOffsetPair = &_vertFaceCountsAndOffsets[vertIndex*2];
502 
503  countOffsetPair[0] = count;
504  countOffsetPair[1] = (vertIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
505 }
506 inline void
507 Level::trimVertexFaces(Index vertIndex, int count) {
508  _vertFaceCountsAndOffsets[vertIndex*2] = count;
509 }
510 
511 //
512 // Access/modify the edges indicent a given vertex:
513 //
514 inline IndexArray const
515 Level::getVertexEdges(Index vertIndex) const {
516  return IndexArray(&_vertEdgeIndices[_vertEdgeCountsAndOffsets[vertIndex*2+1]],
517  _vertEdgeCountsAndOffsets[vertIndex*2]);
518 }
519 inline IndexArray
521  return IndexArray(&_vertEdgeIndices[_vertEdgeCountsAndOffsets[vertIndex*2+1]],
522  _vertEdgeCountsAndOffsets[vertIndex*2]);
523 }
524 
525 inline LocalIndexArray const
528  _vertEdgeCountsAndOffsets[vertIndex*2]);
529 }
530 inline LocalIndexArray
533  _vertEdgeCountsAndOffsets[vertIndex*2]);
534 }
535 
536 inline void
537 Level::resizeVertexEdges(Index vertIndex, int count) {
538  int* countOffsetPair = &_vertEdgeCountsAndOffsets[vertIndex*2];
539 
540  countOffsetPair[0] = count;
541  countOffsetPair[1] = (vertIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
542 
543  _maxValence = std::max(_maxValence, count);
544 }
545 inline void
546 Level::trimVertexEdges(Index vertIndex, int count) {
547  _vertEdgeCountsAndOffsets[vertIndex*2] = count;
548 }
549 
550 //
551 // Access/modify the vertices indicent a given edge:
552 //
553 inline IndexArray const
554 Level::getEdgeVertices(Index edgeIndex) const {
555  return IndexArray(&_edgeVertIndices[edgeIndex*2], 2);
556 }
557 inline IndexArray
559  return IndexArray(&_edgeVertIndices[edgeIndex*2], 2);
560 }
561 
562 //
563 // Access/modify the faces indicent a given edge:
564 //
565 inline IndexArray const
566 Level::getEdgeFaces(Index edgeIndex) const {
567  return IndexArray(&_edgeFaceIndices[_edgeFaceCountsAndOffsets[edgeIndex*2+1]],
568  _edgeFaceCountsAndOffsets[edgeIndex*2]);
569 }
570 inline IndexArray
572  return IndexArray(&_edgeFaceIndices[_edgeFaceCountsAndOffsets[edgeIndex*2+1]],
573  _edgeFaceCountsAndOffsets[edgeIndex*2]);
574 }
575 
576 inline void
577 Level::resizeEdgeFaces(Index edgeIndex, int count) {
578  int* countOffsetPair = &_edgeFaceCountsAndOffsets[edgeIndex*2];
579 
580  countOffsetPair[0] = count;
581  countOffsetPair[1] = (edgeIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
582 
583  _maxEdgeFaces = std::max(_maxEdgeFaces, count);
584 }
585 inline void
586 Level::trimEdgeFaces(Index edgeIndex, int count) {
587  _edgeFaceCountsAndOffsets[edgeIndex*2] = count;
588 }
589 
590 //
591 // Access/modify sharpness values:
592 //
593 inline Sharpness
594 Level::getEdgeSharpness(Index edgeIndex) const {
595  return _edgeSharpness[edgeIndex];
596 }
597 inline Sharpness&
599  return _edgeSharpness[edgeIndex];
600 }
601 
602 inline Sharpness
604  return _vertSharpness[vertIndex];
605 }
606 inline Sharpness&
608  return _vertSharpness[vertIndex];
609 }
610 
611 inline Sdc::Crease::Rule
612 Level::getVertexRule(Index vertIndex) const {
613  return (Sdc::Crease::Rule) _vertTags[vertIndex]._rule;
614 }
615 
616 //
617 // Access/modify hole tag:
618 //
619 inline void
620 Level::setHole(Index faceIndex, bool b) {
621  _faceTags[faceIndex]._hole = b;
622 }
623 inline bool
624 Level::isHole(Index faceIndex) const {
625  return _faceTags[faceIndex]._hole;
626 }
627 
628 //
629 // Sizing methods to allocate space:
630 //
631 inline void
632 Level::resizeFaces(int faceCount) {
633  _faceCount = faceCount;
634  _faceVertCountsAndOffsets.resize(2 * faceCount);
635 
636  _faceTags.resize(faceCount);
637  std::memset(&_faceTags[0], 0, _faceCount * sizeof(FTag));
638 }
639 inline void
640 Level::resizeFaceVertices(int totalFaceVertCount) {
641  _faceVertIndices.resize(totalFaceVertCount);
642 }
643 inline void
644 Level::resizeFaceEdges(int totalFaceEdgeCount) {
645  _faceEdgeIndices.resize(totalFaceEdgeCount);
646 }
647 
648 inline void
649 Level::resizeEdges(int edgeCount) {
650 
651  _edgeCount = edgeCount;
652  _edgeFaceCountsAndOffsets.resize(2 * edgeCount);
653 
654  _edgeSharpness.resize(edgeCount);
655  _edgeTags.resize(edgeCount);
656 
657  if (edgeCount>0) {
658  std::memset(&_edgeTags[0], 0, _edgeCount * sizeof(ETag));
659  }
660 }
661 inline void
663 
664  _edgeVertIndices.resize(2 * _edgeCount);
665 }
666 inline void
667 Level::resizeEdgeFaces(int totalEdgeFaceCount) {
668 
669  _edgeFaceIndices.resize(totalEdgeFaceCount);
670 }
671 
672 inline void
673 Level::resizeVertices(int vertCount) {
674 
675  _vertCount = vertCount;
676  _vertFaceCountsAndOffsets.resize(2 * vertCount);
677  _vertEdgeCountsAndOffsets.resize(2 * vertCount);
678 
679  _vertSharpness.resize(vertCount);
680  _vertTags.resize(vertCount);
681  std::memset(&_vertTags[0], 0, _vertCount * sizeof(VTag));
682 }
683 inline void
684 Level::resizeVertexFaces(int totalVertFaceCount) {
685 
686  _vertFaceIndices.resize(totalVertFaceCount);
687  _vertFaceLocalIndices.resize(totalVertFaceCount);
688 }
689 inline void
690 Level::resizeVertexEdges(int totalVertEdgeCount) {
691 
692  _vertEdgeIndices.resize(totalVertEdgeCount);
693  _vertEdgeLocalIndices.resize(totalVertEdgeCount);
694 }
695 
696 inline IndexArray const
699 }
700 
701 } // end namespace Vtr
702 
703 } // end namespace OPENSUBDIV_VERSION
704 using namespace OPENSUBDIV_VERSION;
705 } // end namespace OpenSubdiv
706 
707 #endif /* VTR_LEVEL_H */
708 
int gatherQuadRegularInteriorPatchVertices(Index fIndex, Index patchVerts[], int rotation=0) const
Index findEdge(Index v0Index, Index v1Index) const
A specialized factory for feature adaptive PatchTables.
int getNumVertexFaces(Index vertIndex) const
Definition: level.h:320
void print(const Refinement *parentRefinement=0) const
int getOffsetOfVertexFaces(Index vertIndex) const
Definition: level.h:321
int getOffsetOfVertexEdges(Index vertIndex) const
Definition: level.h:324
std::vector< FVarLevel * > _fvarChannels
Definition: level.h:431
std::vector< Index > _vertEdgeIndices
Definition: level.h:424
int getNumEdgeFaces(Index edgeIndex) const
Definition: level.h:317
int getNumFaceVertices(Index faceIndex) const
Definition: level.h:308
void trimEdgeFaces(Index edgeIndex, int count)
Definition: level.h:586
int getOffsetOfEdgeVertices(Index edgeIndex) const
Definition: level.h:315
IndexArray const shareFaceVertCountsAndOffsets() const
Definition: level.h:697
void trimVertexEdges(Index vertIndex, int count)
Definition: level.h:546
LocalIndexArray const getVertexFaceLocalIndices(Index vertIndex) const
Definition: level.h:489
int getNumFaceEdges(Index faceIndex) const
Definition: level.h:311
void resizeFaceEdges(int numFaceEdgesTotal)
Definition: level.h:644
int getOffsetOfFaceVertices(Index faceIndex) const
Definition: level.h:309
int gatherTriRegularBoundaryEdgePatchVertices(Index fIndex, Index patchVerts[], int boundaryEdgeInFace) const
int gatherTriRegularBoundaryVertexPatchVertices(Index fIndex, Index patchVerts[], int boundaryVertInFace) const
IndexArray const getEdgeFaces(Index edgeIndex) const
Definition: level.h:566
int createFVarChannel(int fvarValueCount, Sdc::Options const &options)
std::vector< Index > _faceVertCountsAndOffsets
Definition: level.h:405
int gatherQuadRegularBoundaryPatchVertices(Index fIndex, Index patchVerts[], int boundaryEdgeInFace) const
void resizeEdgeFaces(int numEdgeFacesTotal)
Definition: level.h:667
int gatherQuadRegularCornerPatchVertices(Index fIndex, Index patchVerts[], int cornerVertInFace) const
std::vector< Index > _vertEdgeCountsAndOffsets
Definition: level.h:423
void resizeVertexFaces(int numVertexFacesTotal)
Definition: level.h:684
int gatherTriRegularInteriorPatchVertices(Index fIndex, Index patchVerts[], int rotation=0) const
LocalIndexArray const getVertexEdgeLocalIndices(Index vertIndex) const
Definition: level.h:526
int getOffsetOfFaceEdges(Index faceIndex) const
Definition: level.h:312
bool orderVertexFacesAndEdges(Index vIndex, Index *vFaces, Index *vEdges) const
bool isHole(Index faceIndex) const
Definition: level.h:624
int gatherManifoldVertexRingFromIncidentQuads(Index vIndex, int vOffset, int ringVerts[]) const
std::vector< LocalIndex > _vertEdgeLocalIndices
Definition: level.h:425
std::vector< Index > _edgeFaceCountsAndOffsets
Definition: level.h:412
std::vector< Sharpness > _edgeSharpness
Definition: level.h:415
IndexArray const getFaceVertices(Index faceIndex) const
Definition: level.h:438
std::vector< Index > _vertFaceCountsAndOffsets
Definition: level.h:419
std::vector< Index > _vertFaceIndices
Definition: level.h:420
Stores topology data for a specified set of refinement options.
std::vector< Index > _edgeFaceIndices
Definition: level.h:413
IndexArray const getVertexEdges(Index vertIndex) const
Definition: level.h:515
IndexArray const getVertexFaces(Index vertIndex) const
Definition: level.h:478
void resizeVertexEdges(int numVertexEdgesTotal)
Definition: level.h:690
void resizeVertices(int numVertices)
Definition: level.h:673
int gatherTriRegularCornerEdgePatchVertices(Index fIndex, Index patchVerts[], int cornerEdgeInFace) const
void resizeFaceVertices(int numFaceVertsTotal)
Definition: level.h:640
std::vector< LocalIndex > _vertFaceLocalIndices
Definition: level.h:421
void trimVertexFaces(Index vertIndex, int count)
Definition: level.h:507
std::vector< Index > _faceEdgeIndices
Definition: level.h:407
std::vector< Index > _faceVertIndices
Definition: level.h:406
IndexArray const getFaceEdges(Index faceIndex) const
Definition: level.h:464
int gatherTriRegularCornerVertexPatchVertices(Index fIndex, Index patchVerts[], int cornerVertInFace) const
void setHole(Index faceIndex, bool b)
Definition: level.h:620
bool isSingleCreasePatch(Index face, float *sharpnessOut=NULL, int *rotationOut=NULL) const
int getOffsetOfEdgeFaces(Index edgeIndex) const
Definition: level.h:318
Sharpness getVertexSharpness(Index vertIndex) const
Definition: level.h:603
Array< LocalIndex > LocalIndexArray
Definition: types.h:73
Sharpness getEdgeSharpness(Index edgeIndex) const
Definition: level.h:594
IndexArray const getFVarFaceValues(Index faceIndex, int channel=0) const
VTag getFaceCompositeVTag(IndexArray const &faceVerts) const
int getNumVertexEdges(Index vertIndex) const
Definition: level.h:323
Sdc::Crease::Rule getVertexRule(Index vertIndex) const
Definition: level.h:612
std::vector< Index > _edgeVertIndices
Definition: level.h:411
std::vector< Sharpness > _vertSharpness
Definition: level.h:427
int getNumFVarValues(int channel=0) const
IndexArray const getEdgeVertices(Index edgeIndex) const
Definition: level.h:554