OpenSubdiv
Toggle main menu visibility
Loading...
Searching...
No Matches
patchDescriptor.h
Go to the documentation of this file.
1
//
2
// Copyright 2013 Pixar
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
25
#ifndef OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
26
#define OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
27
28
#include "../version.h"
29
30
#include "
../far/types.h
"
31
#include "
../sdc/types.h
"
32
33
#include <vector>
34
35
namespace
OpenSubdiv
{
36
namespace
OPENSUBDIV_VERSION
{
37
38
namespace
Far
{
39
44
class
PatchDescriptor
{
45
46
public
:
47
48
enum
Type
{
49
NON_PATCH
= 0,
50
51
POINTS
,
52
LINES
,
53
54
QUADS
,
55
TRIANGLES
,
56
57
LOOP
,
58
59
REGULAR
,
60
GREGORY
,
61
GREGORY_BOUNDARY
,
62
GREGORY_BASIS
,
63
GREGORY_TRIANGLE
64
};
65
66
public
:
67
69
PatchDescriptor
() :
70
_type(
NON_PATCH
) { }
71
73
PatchDescriptor
(
int
type) :
74
_type(type) { }
75
77
PatchDescriptor
(
PatchDescriptor
const
& d ) :
78
_type(d.
GetType
()) { }
79
81
Type
GetType
()
const
{
82
return
(
Type
)_type;
83
}
84
86
static
inline
bool
IsAdaptive
(
Type
type) {
87
return
type >
TRIANGLES
;
88
}
89
91
bool
IsAdaptive
()
const
{
92
return
IsAdaptive
( this->
GetType
() );
93
}
94
97
static
inline
short
GetNumControlVertices
(
Type
t );
98
100
static
inline
short
GetNumFVarControlVertices
(
Type
t );
101
104
short
GetNumControlVertices
()
const
{
105
return
GetNumControlVertices
( this->
GetType
() );
106
}
107
109
short
GetNumFVarControlVertices
()
const
{
110
return
GetNumFVarControlVertices
( this->
GetType
() );
111
}
112
114
static
short
GetRegularPatchSize
() {
return
16; }
115
117
static
short
GetGregoryPatchSize
() {
return
4; }
118
120
static
short
GetGregoryBasisPatchSize
() {
return
20; }
121
122
125
static
Vtr::ConstArray<PatchDescriptor>
GetAdaptivePatchDescriptors
(
Sdc::SchemeType
type);
126
128
inline
bool
operator <
(
PatchDescriptor
const
other )
const
;
129
131
inline
bool
operator ==
(
PatchDescriptor
const
other )
const
;
132
133
// debug helper
134
void
print
()
const
;
135
136
private
:
137
unsigned
int
_type;
138
};
139
140
typedef
Vtr::ConstArray<PatchDescriptor>
ConstPatchDescriptorArray
;
141
142
// Returns the number of control vertices expected for a patch of this type
143
inline
short
144
PatchDescriptor::GetNumControlVertices
(
Type
type ) {
145
switch
(type) {
146
case
REGULAR
:
return
GetRegularPatchSize
();
147
case
LOOP
:
return
12;
148
case
QUADS
:
return
4;
149
case
GREGORY
:
150
case
GREGORY_BOUNDARY
:
return
GetGregoryPatchSize
();
151
case
GREGORY_BASIS
:
return
GetGregoryBasisPatchSize
();
152
case
GREGORY_TRIANGLE
:
return
18;
153
case
TRIANGLES
:
return
3;
154
case
LINES
:
return
2;
155
case
POINTS
:
return
1;
156
default :
return
-1;
157
}
158
}
159
160
// Returns the number of face-varying control vertices expected for a patch of this type
161
inline
short
162
PatchDescriptor::GetNumFVarControlVertices
(
Type
type ) {
163
return
PatchDescriptor::GetNumControlVertices
(type);
164
}
165
166
// Allows ordering of patches by type
167
inline
bool
168
PatchDescriptor::operator <
(
PatchDescriptor
const
other )
const
{
169
return
(_type < other._type);
170
}
171
172
// True if the descriptors are identical
173
inline
bool
174
PatchDescriptor::operator ==
(
PatchDescriptor
const
other )
const
{
175
return
_type == other._type;
176
}
177
178
179
180
}
// end namespace Far
181
182
}
// end namespace OPENSUBDIV_VERSION
183
using namespace
OPENSUBDIV_VERSION
;
184
185
}
// end namespace OpenSubdiv
186
187
#endif
/* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
OpenSubdiv
Definition
error.h:30
OpenSubdiv::OPENSUBDIV_VERSION
Definition
error.h:31
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition
error.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstPatchDescriptorArray
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
Definition
patchDescriptor.h:140
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition
types.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::Type
Type
Definition
patchDescriptor.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LINES
@ LINES
lines (useful for cage drawing)
Definition
patchDescriptor.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::QUADS
@ QUADS
4-sided quadrilateral (bilinear)
Definition
patchDescriptor.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::NON_PATCH
@ NON_PATCH
undefined
Definition
patchDescriptor.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LOOP
@ LOOP
regular triangular patch for the Loop scheme
Definition
patchDescriptor.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_TRIANGLE
@ GREGORY_TRIANGLE
Definition
patchDescriptor.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::TRIANGLES
@ TRIANGLES
3-sided triangle
Definition
patchDescriptor.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BOUNDARY
@ GREGORY_BOUNDARY
Definition
patchDescriptor.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BASIS
@ GREGORY_BASIS
Definition
patchDescriptor.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::POINTS
@ POINTS
points (useful for cage drawing)
Definition
patchDescriptor.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY
@ GREGORY
Definition
patchDescriptor.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::REGULAR
@ REGULAR
regular B-Spline patch for the Catmark scheme
Definition
patchDescriptor.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
bool IsAdaptive() const
Returns true if the type is an adaptive patch.
Definition
patchDescriptor.h:91
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetType
Type GetType() const
Returns the type of the patch.
Definition
patchDescriptor.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryBasisPatchSize
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20).
Definition
patchDescriptor.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumControlVertices
short GetNumControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
Definition
patchDescriptor.h:104
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
Definition
patchDescriptor.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator==
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
Definition
patchDescriptor.h:174
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetRegularPatchSize
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
Definition
patchDescriptor.h:114
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
short GetNumFVarControlVertices() const
Deprecated.
Definition
patchDescriptor.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(int type)
Constructor.
Definition
patchDescriptor.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
static bool IsAdaptive(Type type)
Returns true if the type is an adaptive (non-linear) patch.
Definition
patchDescriptor.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator<
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
Definition
patchDescriptor.h:168
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryPatchSize
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
Definition
patchDescriptor.h:117
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::print
void print() const
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
static short GetNumFVarControlVertices(Type t)
Deprecated.
Definition
patchDescriptor.h:162
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetAdaptivePatchDescriptors
static Vtr::ConstArray< PatchDescriptor > GetAdaptivePatchDescriptors(Sdc::SchemeType type)
Returns a vector of all the legal patch descriptors for the given adaptive subdivision scheme.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumControlVertices
static short GetNumControlVertices(Type t)
Returns the number of control vertices expected for a patch of the type described.
Definition
patchDescriptor.h:144
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor()
Default constructor.
Definition
patchDescriptor.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::ConstArray
Definition
array.h:53
types.h
types.h
opensubdiv
far
patchDescriptor.h
Generated on
for OpenSubdiv by
1.18.0