OpenSubdiv: opensubdiv/sdc/bilinearScheme.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
bilinearScheme.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_SDC_BILINEAR_SCHEME_H
25#define OPENSUBDIV3_SDC_BILINEAR_SCHEME_H
26
27#include "../version.h"
28
29#include "../sdc/scheme.h"
30
31namespace OpenSubdiv {
32namespace OPENSUBDIV_VERSION {
33
34 namespace Sdc {
35
36//
37// Specializations for Scheme<SCHEME_BILINEAR>:
38//
39
40//
41// Bilinear traits:
42//
43template <>
44 inline Split Scheme<SCHEME_BILINEAR>::GetTopologicalSplitType() { return SPLIT_TO_QUADS; }
45
46template <>
47 inline int Scheme<SCHEME_BILINEAR>::GetRegularFaceSize() { return 4; }
48
49template <>
50 inline int Scheme<SCHEME_BILINEAR>::GetRegularVertexValence() { return 4; }
51
52template <>
53 inline int Scheme<SCHEME_BILINEAR>::GetLocalNeighborhoodSize() { return 0; }
54
55
56//
57// Refinement masks:
58//
59template <>
60template <typename EDGE, typename MASK>
61void
62 Scheme<SCHEME_BILINEAR>::ComputeEdgeVertexMask(EDGE const& edge, MASK& mask,
63 Crease::Rule, Crease::Rule) const {
64 // This should be inline, otherwise trivially replicate it:
65 assignCreaseMaskForEdge(edge, mask);
66}
67
68template <>
69template <typename VERTEX, typename MASK>
70void
71 Scheme<SCHEME_BILINEAR>::ComputeVertexVertexMask(VERTEX const& vertex, MASK& mask,
72 Crease::Rule, Crease::Rule) const {
73 // This should be inline, otherwise trivially replicate it:
74 assignCornerMaskForVertex(vertex, mask);
75}
76
77
78//
79// Limit masks for position -- the limit position of all vertices is the refined vertex.
80//
81template <>
82template <typename VERTEX, typename MASK>
83inline void
84 Scheme<SCHEME_BILINEAR>::assignCornerLimitMask(VERTEX const& /* vertex */, MASK& posMask) const {
85
86 posMask.SetNumVertexWeights(1);
87 posMask.SetNumEdgeWeights(0);
88 posMask.SetNumFaceWeights(0);
89 posMask.SetFaceWeightsForFaceCenters(false);
90
91 posMask.VertexWeight(0) = 1.0f;
92}
93
94template <>
95template <typename VERTEX, typename MASK>
96inline void
97 Scheme<SCHEME_BILINEAR>::assignCreaseLimitMask(VERTEX const& vertex, MASK& posMask,
98 int const /* creaseEnds */[2]) const {
99
100 assignCornerLimitMask(vertex, posMask);
101}
102
103template <>
104template <typename VERTEX, typename MASK>
105inline void
106 Scheme<SCHEME_BILINEAR>::assignSmoothLimitMask(VERTEX const& vertex, MASK& posMask) const {
107
108 assignCornerLimitMask(vertex, posMask);
109}
110
111//
112// Limit masks for tangents -- these are ambiguous around all vertices. Provide
113// the tangents based on the incident edges of the first face.
114//
115template <>
116template <typename VERTEX, typename MASK>
117inline void
118 Scheme<SCHEME_BILINEAR>::assignCornerLimitTangentMasks(VERTEX const& /* vertex */,
119 MASK& tan1Mask, MASK& tan2Mask) const {
120
121 tan1Mask.SetNumVertexWeights(1);
122 tan1Mask.SetNumEdgeWeights(2);
123 tan1Mask.SetNumFaceWeights(0);
124 tan1Mask.SetFaceWeightsForFaceCenters(false);
125
126 tan2Mask.SetNumVertexWeights(1);
127 tan2Mask.SetNumEdgeWeights(2);
128 tan2Mask.SetNumFaceWeights(0);
129 tan2Mask.SetFaceWeightsForFaceCenters(false);
130
131 tan1Mask.VertexWeight(0) = -1.0f;
132 tan1Mask.EdgeWeight(0) = 1.0f;
133 tan1Mask.EdgeWeight(1) = 0.0f;
134
135 tan2Mask.VertexWeight(0) = -1.0f;
136 tan2Mask.EdgeWeight(0) = 0.0f;
137 tan2Mask.EdgeWeight(1) = 1.0f;
138}
139
140template <>
141template <typename VERTEX, typename MASK>
142inline void
143 Scheme<SCHEME_BILINEAR>::assignCreaseLimitTangentMasks(VERTEX const& vertex,
144 MASK& tan1Mask, MASK& tan2Mask, int const /* creaseEnds */[2]) const {
145
146 assignCornerLimitTangentMasks(vertex, tan1Mask, tan2Mask);
147}
148
149template <>
150template <typename VERTEX, typename MASK>
151inline void
152 Scheme<SCHEME_BILINEAR>::assignSmoothLimitTangentMasks(VERTEX const& vertex,
153 MASK& tan1Mask, MASK& tan2Mask) const {
154
155 assignCornerLimitTangentMasks(vertex, tan1Mask, tan2Mask);
156}
157
158} // end namespace sdc
159
160} // end namespace OPENSUBDIV_VERSION
161using namespace OPENSUBDIV_VERSION;
162} // end namespace OpenSubdiv
163
164#endif /* OPENSUBDIV3_SDC_BILINEAR_SCHEME_H */
scheme.h
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Split
Split
Enumerated type for all face splitting schemes.
Definition types.h:47
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SPLIT_TO_QUADS
@ SPLIT_TO_QUADS
Used by Catmark and Bilinear.
Definition types.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::Rule
Rule
Definition crease.h:82
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::GetTopologicalSplitType
static Split GetTopologicalSplitType()
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::ComputeVertexVertexMask
void ComputeVertexVertexMask(VERTEX const &vertexNeighborhood, MASK &vertexVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
Vertex-vertex masks If known, a single Rule or pair of Rules can be specified (indicating a crease tr...
Definition scheme.h:512
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignCreaseLimitTangentMasks
void assignCreaseLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2, int const creaseEnds[2]) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::GetRegularFaceSize
static int GetRegularFaceSize()
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::ComputeEdgeVertexMask
void ComputeEdgeVertexMask(EDGE const &edgeNeighborhood, MASK &edgeVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
Edge-vertex masks If known, the Rule for the edge and/or the derived vertex can be specified to accel...
Definition scheme.h:392
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignSmoothLimitMask
void assignSmoothLimitMask(VERTEX const &vertex, MASK &pos) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::GetLocalNeighborhoodSize
static int GetLocalNeighborhoodSize()
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignCreaseLimitMask
void assignCreaseLimitMask(VERTEX const &vertex, MASK &pos, int const creaseEnds[2]) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::GetRegularVertexValence
static int GetRegularVertexValence()
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignSmoothLimitTangentMasks
void assignSmoothLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignCornerLimitMask
void assignCornerLimitMask(VERTEX const &vertex, MASK &pos) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Scheme::assignCornerLimitTangentMasks
void assignCornerLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2) const