OpenSubdiv
Toggle main menu visibility
Loading...
Searching...
No Matches
crease.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_CREASE_H
25
#define OPENSUBDIV3_SDC_CREASE_H
26
27
#include "../version.h"
28
29
#include "
../sdc/options.h
"
30
31
namespace
OpenSubdiv
{
32
namespace
OPENSUBDIV_VERSION
{
33
34
namespace
Sdc
{
35
61
62
class
Crease
{
63
public
:
65
67
static
float
const
SHARPNESS_SMOOTH
;
// = 0.0f, do we really need this?
68
static
float
const
SHARPNESS_INFINITE
;
// = 10.0f;
69
70
static
bool
IsSmooth
(
float
sharpness) {
return
sharpness <=
SHARPNESS_SMOOTH
; }
71
static
bool
IsSharp
(
float
sharpness) {
return
sharpness >
SHARPNESS_SMOOTH
; }
72
static
bool
IsInfinite
(
float
sharpness) {
return
sharpness >=
SHARPNESS_INFINITE
; }
73
static
bool
IsSemiSharp
(
float
sharpness) {
return
(
SHARPNESS_SMOOTH
< sharpness) && (sharpness <
SHARPNESS_INFINITE
); }
75
82
enum
Rule
{
83
RULE_UNKNOWN
= 0,
84
RULE_SMOOTH
= (1 << 0),
85
RULE_DART
= (1 << 1),
86
RULE_CREASE
= (1 << 2),
87
RULE_CORNER
= (1 << 3)
88
};
89
90
public
:
91
Crease
() : _options() { }
92
Crease
(
Options
const
& options) : _options(options) { }
93
~Crease
() { }
94
95
bool
IsUniform
()
const
{
return
_options.GetCreasingMethod() ==
Options::CREASE_UNIFORM
; }
96
98
104
float
SharpenBoundaryEdge
(
float
edgeSharpness)
const
;
105
float
SharpenBoundaryVertex
(
float
edgeSharpness)
const
;
106
107
// For future consideration
108
//float SharpenNonManifoldEdge(float edgeSharpness) const;
109
//float SharpenNonManifoldVertex(float edgeSharpness) const;
111
113
124
float
SubdivideUniformSharpness
(
float
vertexOrEdgeSharpness)
const
;
125
126
float
SubdivideVertexSharpness
(
float
vertexSharpness)
const
;
127
128
float
SubdivideEdgeSharpnessAtVertex
(
float
edgeSharpness,
129
int
incidentEdgeCountAtEndVertex,
130
float
const
* edgeSharpnessAroundEndVertex)
const
;
131
132
void
SubdivideEdgeSharpnessesAroundVertex
(
int
incidentEdgeCountAtVertex,
133
float
const
* incidentEdgeSharpnessAroundVertex,
134
float
* childEdgesSharpnessAroundVertex)
const
;
136
138
144
Rule
DetermineVertexVertexRule
(
float
vertexSharpness,
145
int
incidentEdgeCount,
146
float
const
* incidentEdgeSharpness)
const
;
147
Rule
DetermineVertexVertexRule
(
float
vertexSharpness,
148
int
sharpEdgeCount)
const
;
150
162
float
ComputeFractionalWeightAtVertex
(
float
vertexSharpness,
163
float
childVertexSharpness,
164
int
incidentEdgeCount,
165
float
const
* incidentEdgeSharpness,
166
float
const
* childEdgesSharpness)
const
;
167
168
void
GetSharpEdgePairOfCrease
(
float
const
* incidentEdgeSharpness,
169
int
incidentEdgeCount,
170
int
sharpEdgePair[2])
const
;
171
172
// Would these really help? Maybe only need Rules for the vertex-vertex case...
173
//
174
// Rule DetermineEdgeVertexRule(float parentEdgeSharpness) const;
175
// Rule DetermineEdgeVertexRule(float childEdge1Sharpness, float childEdge2Sharpness) const;
176
177
protected
:
178
float
decrementSharpness
(
float
sharpness)
const
;
179
180
private
:
181
Options
_options;
182
};
183
184
185
//
186
// Inline declarations:
187
//
188
inline
float
189
Crease::SharpenBoundaryEdge
(
float
/* edgeSharpness */
)
const
{
190
191
//
192
// Despite the presence of the BOUNDARY_NONE option, boundary edges are always sharpened.
193
// Much of the code relies on sharpness to indicate boundaries to avoid the more complex
194
// topological inspection
195
//
196
return
SHARPNESS_INFINITE
;
197
}
198
199
inline
float
200
Crease::SharpenBoundaryVertex
(
float
vertexSharpness)
const
{
201
202
return
(_options.GetVtxBoundaryInterpolation() ==
Options::VTX_BOUNDARY_EDGE_AND_CORNER
) ?
203
SHARPNESS_INFINITE
: vertexSharpness;
204
}
205
206
inline
float
207
Crease::decrementSharpness
(
float
sharpness)
const
{
208
209
if
(
IsSmooth
(sharpness))
return
Crease::SHARPNESS_SMOOTH
;
// redundant but most common
210
if
(
IsInfinite
(sharpness))
return
Crease::SHARPNESS_INFINITE
;
211
if
(sharpness > 1.0f)
return
(sharpness - 1.0f);
212
return
Crease::SHARPNESS_SMOOTH
;
213
}
214
215
inline
float
216
Crease::SubdivideUniformSharpness
(
float
vertexOrEdgeSharpness)
const
{
217
218
return
decrementSharpness
(vertexOrEdgeSharpness);
219
}
220
221
inline
float
222
Crease::SubdivideVertexSharpness
(
float
vertexSharpness)
const
{
223
224
return
decrementSharpness
(vertexSharpness);
225
}
226
227
inline
void
228
Crease::GetSharpEdgePairOfCrease
(
float
const
* incidentEdgeSharpness,
int
incidentEdgeCount,
229
int
sharpEdgePair[2])
const
{
230
231
// Only to be called when a crease is present at a vertex -- exactly two sharp
232
// edges are expected here:
233
//
234
sharpEdgePair[0] = 0;
235
while
(
IsSmooth
(incidentEdgeSharpness[sharpEdgePair[0]])) ++ sharpEdgePair[0];
236
237
sharpEdgePair[1] = incidentEdgeCount - 1;
238
while
(
IsSmooth
(incidentEdgeSharpness[sharpEdgePair[1]])) -- sharpEdgePair[1];
239
}
240
241
}
// end namespace sdc
242
243
}
// end namespace OPENSUBDIV_VERSION
244
using namespace
OPENSUBDIV_VERSION
;
245
}
// end namespace OpenSubdiv
246
247
#endif
/* OPENSUBDIV3_SDC_CREASE_H */
options.h
OpenSubdiv
Definition
error.h:30
OpenSubdiv::OPENSUBDIV_VERSION
Definition
error.h:31
OpenSubdiv::OPENSUBDIV_VERSION::Sdc
Definition
bilinearScheme.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SubdivideVertexSharpness
float SubdivideVertexSharpness(float vertexSharpness) const
Definition
crease.h:222
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::IsInfinite
static bool IsInfinite(float sharpness)
Definition
crease.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::Rule
Rule
Definition
crease.h:82
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::RULE_CORNER
@ RULE_CORNER
Definition
crease.h:87
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::RULE_DART
@ RULE_DART
Definition
crease.h:85
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::RULE_SMOOTH
@ RULE_SMOOTH
Definition
crease.h:84
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::RULE_CREASE
@ RULE_CREASE
Definition
crease.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::RULE_UNKNOWN
@ RULE_UNKNOWN
Definition
crease.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SharpenBoundaryVertex
float SharpenBoundaryVertex(float edgeSharpness) const
Definition
crease.h:200
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SHARPNESS_SMOOTH
static float const SHARPNESS_SMOOTH
Definition
crease.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::GetSharpEdgePairOfCrease
void GetSharpEdgePairOfCrease(float const *incidentEdgeSharpness, int incidentEdgeCount, int sharpEdgePair[2]) const
Definition
crease.h:228
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SHARPNESS_INFINITE
static float const SHARPNESS_INFINITE
Definition
crease.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::DetermineVertexVertexRule
Rule DetermineVertexVertexRule(float vertexSharpness, int incidentEdgeCount, float const *incidentEdgeSharpness) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::decrementSharpness
float decrementSharpness(float sharpness) const
Definition
crease.h:207
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::IsSmooth
static bool IsSmooth(float sharpness)
Definition
crease.h:70
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::DetermineVertexVertexRule
Rule DetermineVertexVertexRule(float vertexSharpness, int sharpEdgeCount) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::IsUniform
bool IsUniform() const
Definition
crease.h:95
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::IsSemiSharp
static bool IsSemiSharp(float sharpness)
Definition
crease.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::Crease
Crease(Options const &options)
Definition
crease.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SubdivideEdgeSharpnessesAroundVertex
void SubdivideEdgeSharpnessesAroundVertex(int incidentEdgeCountAtVertex, float const *incidentEdgeSharpnessAroundVertex, float *childEdgesSharpnessAroundVertex) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SubdivideUniformSharpness
float SubdivideUniformSharpness(float vertexOrEdgeSharpness) const
Definition
crease.h:216
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::Crease
Crease()
Definition
crease.h:91
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SharpenBoundaryEdge
float SharpenBoundaryEdge(float edgeSharpness) const
Definition
crease.h:189
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::ComputeFractionalWeightAtVertex
float ComputeFractionalWeightAtVertex(float vertexSharpness, float childVertexSharpness, int incidentEdgeCount, float const *incidentEdgeSharpness, float const *childEdgesSharpness) const
Transitional weighting: When the rules applicable to a parent vertex and its child differ,...
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::SubdivideEdgeSharpnessAtVertex
float SubdivideEdgeSharpnessAtVertex(float edgeSharpness, int incidentEdgeCountAtEndVertex, float const *edgeSharpnessAroundEndVertex) const
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::IsSharp
static bool IsSharp(float sharpness)
Definition
crease.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Crease::~Crease
~Crease()
Definition
crease.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options
All supported options applying to subdivision scheme.
Definition
options.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options::CREASE_UNIFORM
@ CREASE_UNIFORM
Catmark rule.
Definition
options.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::Options::VTX_BOUNDARY_EDGE_AND_CORNER
@ VTX_BOUNDARY_EDGE_AND_CORNER
Definition
options.h:57
opensubdiv
sdc
crease.h
Generated on
for OpenSubdiv by
1.18.0