All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
fvarRefinement.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 OPENSUBDIV3_VTR_FVAR_REFINEMENT_H
25 #define OPENSUBDIV3_VTR_FVAR_REFINEMENT_H
26 
27 #include "../version.h"
28 
29 #include "../sdc/types.h"
30 #include "../sdc/crease.h"
31 #include "../vtr/types.h"
32 #include "../vtr/refinement.h"
33 #include "../vtr/fvarLevel.h"
34 
35 #include <vector>
36 #include <cassert>
37 #include <cstring>
38 
39 
40 namespace OpenSubdiv {
41 namespace OPENSUBDIV_VERSION {
42 
43 namespace Vtr {
44 namespace internal {
45 
46 //
47 // FVarRefinement:
48 // A face-varying refinement contains data to support the refinement of a
49 // particular face-varying "channel". Just as Refinement maintains a mapping
50 // between the components of a parent Level and its child, the face-varying
51 // analog maintains a mapping between the face-varying values of a parent
52 // FVarLevel and its child.
53 //
54 // It turns out there is little data necessary here, so the class consists
55 // mainly of methods that populate the child FVarLevel. The mapping data in
56 // the refinement between Levels serves most purposes and all that is required
57 // in addition is a mapping from values in the child FVarLevel to the parent.
58 //
60 public:
61  FVarRefinement(Refinement const& refinement, FVarLevel& parent, FVarLevel& child);
63 
64  int getChildValueParentSource(Index vIndex, int sibling) const {
65  return _childValueParentSource[_childFVar.getVertexValueOffset(vIndex, (LocalIndex)sibling)];
66  }
67 
68  float getFractionalWeight(Index pVert, LocalIndex pSibling,
69  Index cVert, LocalIndex cSibling) const;
70 
71 
72  // Modifiers supporting application of the refinement:
73  void applyRefinement();
74 
76  void populateChildValues();
83 
84  void propagateEdgeTags();
85  void propagateValueTags();
86  void propagateValueCreases();
88 
89 private:
90  //
91  // Identify the Refinement, its Levels and assigned FVarLevels for more
92  // immediate access -- child FVarLevel is non-const as it is to be assigned:
93  //
94  Refinement const & _refinement;
95 
96  Level const & _parentLevel;
97  FVarLevel const & _parentFVar;
98 
99  Level const & _childLevel;
100  FVarLevel & _childFVar;
101 
102  // When refinement is sparse, we need a mapping between siblings of a vertex
103  // value in the parent and child -- and for some child values, there will not
104  // be a parent value, in which case the source of the parent component will
105  // be stored. So we refer to the parent "source" rather than "sibling":
106  //
107  std::vector<LocalIndex> _childValueParentSource;
108 };
109 
110 } // end namespace internal
111 } // end namespace Vtr
112 
113 } // end namespace OPENSUBDIV_VERSION
114 using namespace OPENSUBDIV_VERSION;
115 } // end namespace OpenSubdiv
116 
117 #endif /* OPENSUBDIV3_VTR_FVAR_REFINEMENT_H */
FVarRefinement(Refinement const &refinement, FVarLevel &parent, FVarLevel &child)
Index getVertexValueOffset(Index v, Sibling i=0) const
Definition: fvarLevel.h:188
int getChildValueParentSource(Index vIndex, int sibling) const
float getFractionalWeight(Index pVert, LocalIndex pSibling, Index cVert, LocalIndex cSibling) const