| 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
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//
59 class FVarRefinement {
60 public:
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
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 */
refinement.h
fvarLevel.h
crease.h
OpenSubdiv
Definition error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::Index
int Index
Definition types.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::LocalIndex
unsigned short LocalIndex
Definition types.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarLevel
Definition fvarLevel.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarLevel::getVertexValueOffset
Index getVertexValueOffset(Index v, Sibling i=0) const
Definition fvarLevel.h:198
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement
Definition fvarRefinement.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::propagateValueTags
void propagateValueTags()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValuesFromEdgeVertices
void populateChildValuesFromEdgeVertices()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::~FVarRefinement
~FVarRefinement()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::propagateEdgeTags
void propagateEdgeTags()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::estimateAndAllocateChildValues
void estimateAndAllocateChildValues()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::getFractionalWeight
float getFractionalWeight(Index pVert, LocalIndex pSibling, Index cVert, LocalIndex cSibling) const
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::FVarRefinement
FVarRefinement(Refinement const &refinement, FVarLevel &parent, FVarLevel &child)
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::reclassifySemisharpValues
void reclassifySemisharpValues()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValuesFromFaceVertices
void populateChildValuesFromFaceVertices()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValuesForVertexVertex
int populateChildValuesForVertexVertex(Index cVert, Index pVert)
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::trimAndFinalizeChildValues
void trimAndFinalizeChildValues()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValuesForEdgeVertex
int populateChildValuesForEdgeVertex(Index cVert, Index pEdge)
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValues
void populateChildValues()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::propagateValueCreases
void propagateValueCreases()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::applyRefinement
void applyRefinement()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::getChildValueParentSource
int getChildValueParentSource(Index vIndex, int sibling) const
Definition fvarRefinement.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::FVarRefinement::populateChildValuesFromVertexVertices
void populateChildValuesFromVertexVertices()
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Level
Definition level.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::internal::Refinement
Definition refinement.h:69
types.h
types.h