OpenSubdiv
Loading...
Searching...
No Matches
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
40namespace OpenSubdiv {
41namespace OPENSUBDIV_VERSION {
42
43namespace Vtr {
44namespace 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//
59class FVarRefinement {
60public:
61 FVarRefinement(Refinement const& refinement, FVarLevel& parent, FVarLevel& child);
62 ~FVarRefinement();
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
75 void estimateAndAllocateChildValues();
76 void populateChildValues();
77 void populateChildValuesFromFaceVertices();
78 void populateChildValuesFromEdgeVertices();
79 int populateChildValuesForEdgeVertex(Index cVert, Index pEdge);
80 void populateChildValuesFromVertexVertices();
81 int populateChildValuesForVertexVertex(Index cVert, Index pVert);
82 void trimAndFinalizeChildValues();
83
84 void propagateEdgeTags();
85 void propagateValueTags();
86 void propagateValueCreases();
87 void reclassifySemisharpValues();
88
89private:
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
114using namespace OPENSUBDIV_VERSION;
115} // end namespace OpenSubdiv
116
117#endif /* OPENSUBDIV3_VTR_FVAR_REFINEMENT_H */