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