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 terms set forth in the LICENSE.txt file available at
5
// https://opensubdiv.org/license.
6
//
7
8
#ifndef OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
9
#define OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
10
11
#include "../version.h"
12
13
#include "
../far/types.h
"
14
#include "
../sdc/types.h
"
15
16
#include <vector>
17
18
namespace
OpenSubdiv
{
19
namespace
OPENSUBDIV_VERSION
{
20
21
namespace
Far
{
22
27
class
PatchDescriptor
{
28
29
public
:
30
31
enum
Type
{
32
NON_PATCH
= 0,
33
34
POINTS
,
35
LINES
,
36
37
QUADS
,
38
TRIANGLES
,
39
40
LOOP
,
41
42
REGULAR
,
43
GREGORY
,
44
GREGORY_BOUNDARY
,
45
GREGORY_BASIS
,
46
GREGORY_TRIANGLE
47
};
48
49
public
:
50
52
PatchDescriptor
() :
53
_type(
NON_PATCH
) { }
54
56
PatchDescriptor
(
int
type) :
57
_type(type) { }
58
60
PatchDescriptor
(
PatchDescriptor
const
& d ) :
61
_type(d.
GetType
()) { }
62
64
PatchDescriptor
&
operator=
(
PatchDescriptor
const
& d ) {
65
_type = d.
GetType
();
66
return
*
this
;
67
}
68
70
Type
GetType
()
const
{
71
return
(
Type
)_type;
72
}
73
75
static
inline
bool
IsAdaptive
(
Type
type) {
76
return
type >
TRIANGLES
;
77
}
78
80
bool
IsAdaptive
()
const
{
81
return
IsAdaptive
( this->
GetType
() );
82
}
83
86
static
inline
short
GetNumControlVertices
(
Type
t );
87
89
static
inline
short
GetNumFVarControlVertices
(
Type
t );
90
93
short
GetNumControlVertices
()
const
{
94
return
GetNumControlVertices
( this->
GetType
() );
95
}
96
98
short
GetNumFVarControlVertices
()
const
{
99
return
GetNumFVarControlVertices
( this->
GetType
() );
100
}
101
103
static
short
GetRegularPatchSize
() {
return
16; }
104
106
static
short
GetGregoryPatchSize
() {
return
4; }
107
109
static
short
GetGregoryBasisPatchSize
() {
return
20; }
110
111
114
static
Vtr::ConstArray<PatchDescriptor>
GetAdaptivePatchDescriptors
(
Sdc::SchemeType
type);
115
117
inline
bool
operator <
(
PatchDescriptor
const
other )
const
;
118
120
inline
bool
operator ==
(
PatchDescriptor
const
other )
const
;
121
122
// debug helper
123
void
print
()
const
;
124
125
private
:
126
unsigned
int
_type;
127
};
128
129
typedef
Vtr::ConstArray<PatchDescriptor>
ConstPatchDescriptorArray
;
130
131
// Returns the number of control vertices expected for a patch of this type
132
inline
short
133
PatchDescriptor::GetNumControlVertices
(
Type
type ) {
134
switch
(type) {
135
case
REGULAR
:
return
GetRegularPatchSize
();
136
case
LOOP
:
return
12;
137
case
QUADS
:
return
4;
138
case
GREGORY
:
139
case
GREGORY_BOUNDARY
:
return
GetGregoryPatchSize
();
140
case
GREGORY_BASIS
:
return
GetGregoryBasisPatchSize
();
141
case
GREGORY_TRIANGLE
:
return
18;
142
case
TRIANGLES
:
return
3;
143
case
LINES
:
return
2;
144
case
POINTS
:
return
1;
145
default :
return
-1;
146
}
147
}
148
149
// Returns the number of face-varying control vertices expected for a patch of this type
150
inline
short
151
PatchDescriptor::GetNumFVarControlVertices
(
Type
type ) {
152
return
PatchDescriptor::GetNumControlVertices
(type);
153
}
154
155
// Allows ordering of patches by type
156
inline
bool
157
PatchDescriptor::operator <
(
PatchDescriptor
const
other )
const
{
158
return
(_type < other._type);
159
}
160
161
// True if the descriptors are identical
162
inline
bool
163
PatchDescriptor::operator ==
(
PatchDescriptor
const
other )
const
{
164
return
_type == other._type;
165
}
166
167
168
169
}
// end namespace Far
170
171
}
// end namespace OPENSUBDIV_VERSION
172
using namespace
OPENSUBDIV_VERSION
;
173
174
}
// end namespace OpenSubdiv
175
176
#endif
/* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
OpenSubdiv
Definition
limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition
limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition
refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstPatchDescriptorArray
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
Definition
patchDescriptor.h:129
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition
types.h:20
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::Type
Type
Definition
patchDescriptor.h:31
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LINES
@ LINES
lines (useful for cage drawing)
Definition
patchDescriptor.h:35
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::QUADS
@ QUADS
4-sided quadrilateral (bilinear)
Definition
patchDescriptor.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::NON_PATCH
@ NON_PATCH
undefined
Definition
patchDescriptor.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LOOP
@ LOOP
regular triangular patch for the Loop scheme
Definition
patchDescriptor.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_TRIANGLE
@ GREGORY_TRIANGLE
Definition
patchDescriptor.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::TRIANGLES
@ TRIANGLES
3-sided triangle
Definition
patchDescriptor.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BOUNDARY
@ GREGORY_BOUNDARY
Definition
patchDescriptor.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BASIS
@ GREGORY_BASIS
Definition
patchDescriptor.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::POINTS
@ POINTS
points (useful for cage drawing)
Definition
patchDescriptor.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY
@ GREGORY
Definition
patchDescriptor.h:43
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::REGULAR
@ REGULAR
regular B-Spline patch for the Catmark scheme
Definition
patchDescriptor.h:42
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
bool IsAdaptive() const
Returns true if the type is an adaptive patch.
Definition
patchDescriptor.h:80
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetType
Type GetType() const
Returns the type of the patch.
Definition
patchDescriptor.h:70
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryBasisPatchSize
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20).
Definition
patchDescriptor.h:109
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:93
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
Definition
patchDescriptor.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator==
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
Definition
patchDescriptor.h:163
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetRegularPatchSize
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
Definition
patchDescriptor.h:103
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
short GetNumFVarControlVertices() const
Deprecated.
Definition
patchDescriptor.h:98
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(int type)
Constructor.
Definition
patchDescriptor.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator=
PatchDescriptor & operator=(PatchDescriptor const &d)
Assignment operator.
Definition
patchDescriptor.h:64
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:75
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator<
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
Definition
patchDescriptor.h:157
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryPatchSize
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
Definition
patchDescriptor.h:106
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::print
void print() const
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
static short GetNumFVarControlVertices(Type t)
Deprecated.
Definition
patchDescriptor.h:151
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:133
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor()
Default constructor.
Definition
patchDescriptor.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::ConstArray
Definition
array.h:36
types.h
types.h
opensubdiv
far
patchDescriptor.h
Generated on
for OpenSubdiv by
1.18.0