- Main Page
- Namespaces
- Classes
- Files

- File List

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
56 class PatchDescriptor {
57
58 public:
59
60 enum Type {
61 NON_PATCH = 0,
62
63 POINTS,
64 LINES,
65
66 QUADS,
67 TRIANGLES,
68
69 LOOP,
70
71 REGULAR,
72 GREGORY,
73 GREGORY_BOUNDARY,
74 GREGORY_BASIS
75 };
76
77 public:
78
80 PatchDescriptor() :
81 _type(NON_PATCH) { }
82
84 PatchDescriptor(int type) :
85 _type(type) { }
86
88 PatchDescriptor( PatchDescriptor const & d ) :
89 _type(d.GetType()) { }
90
92 Type GetType() const {
93 return (Type)_type;
94 }
95
97 static inline bool IsAdaptive(Type type) {
98 return (type>=LOOP and type<=GREGORY_BASIS);
99 }
100
102 bool IsAdaptive() const {
103 return IsAdaptive( this->GetType() );
104 }
105
108 static inline short GetNumControlVertices( Type t );
109
110 static inline short GetNumFVarControlVertices( Type t );
111
114 short GetNumControlVertices() const {
115 return GetNumControlVertices( this->GetType() );
116 }
117
120 short GetNumFVarControlVertices() const {
121 return GetNumFVarControlVertices( this->GetType() );
122 }
123
125 static short GetRegularPatchSize() { return 16; }
126
128 static short GetGregoryPatchSize() { return 4; }
129
131 static short GetGregoryBasisPatchSize() { return 20; }
132
133
136 static Vtr::ConstArray<PatchDescriptor> GetAdaptivePatchDescriptors(Sdc::SchemeType type);
137
139 inline bool operator < ( PatchDescriptor const other ) const;
140
142 inline bool operator == ( PatchDescriptor const other ) const;
143
144 // debug helper
145 void print() const;
146
147 private:
148 unsigned int _type:4;
149 };
150
151 typedef Vtr::ConstArray<PatchDescriptor> ConstPatchDescriptorArray;
152
153 // Returns the number of control vertices expected for a patch of this type
154 inline short
155 PatchDescriptor::GetNumControlVertices( Type type ) {
156 switch (type) {
157 case REGULAR : return GetRegularPatchSize();
158 case QUADS : return 4;
159 case GREGORY :
160 case GREGORY_BOUNDARY : return GetGregoryPatchSize();
161 case GREGORY_BASIS : return GetGregoryBasisPatchSize();
162 case TRIANGLES : return 3;
163 case LINES : return 2;
164 case POINTS : return 1;
165 default : return -1;
166 }
167 }
168
169 // Returns the number of face-varying control vertices expected for a patch of this type
170 inline short
171 PatchDescriptor::GetNumFVarControlVertices( Type type ) {
172 switch (type) {
173 case REGULAR : return GetRegularPatchSize();
174 case QUADS : return 4;
175 case TRIANGLES : return 3;
176 case LINES : return 2;
177 case POINTS : return 1;
178 case GREGORY_BASIS : assert(0); return GetGregoryBasisPatchSize();
179 case GREGORY :
180 case GREGORY_BOUNDARY : assert(0); // unsupported types
181 default : return -1;
182 }
183 }
184
185 // Allows ordering of patches by type
186 inline bool
187 PatchDescriptor::operator < ( PatchDescriptor const other ) const {
188 return (_type < other._type);
189 }
190
191 // True if the descriptors are identical
192 inline bool
193 PatchDescriptor::operator == ( PatchDescriptor const other ) const {
194 return _type == other._type;
195 }
196
197
198
199 } // end namespace Far
200
201 } // end namespace OPENSUBDIV_VERSION
202 using namespace OPENSUBDIV_VERSION;
203
204 } // end namespace OpenSubdiv
205
206 #endif /* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::ConstArray
Definition: array.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor()
Default constructor.
Definition: patchDescriptor.h:80
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivisions schemes supported by OpenSubdiv.
Definition: types.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BASIS
Definition: patchDescriptor.h:74
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LINES
lines (useful for cage drawing)
Definition: patchDescriptor.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
bool IsAdaptive() const
Returns true if the type is an adaptive patch.
Definition: patchDescriptor.h:102
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
short GetNumFVarControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
Definition: patchDescriptor.h:120
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator==
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
Definition: patchDescriptor.h:193
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetRegularPatchSize
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
Definition: patchDescriptor.h:125
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:114
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator<
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
Definition: patchDescriptor.h:187
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor
Describes the type of a patch.
Definition: patchDescriptor.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::REGULAR
feature-adaptive bicubic patches
Definition: patchDescriptor.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::Type
Type
Definition: patchDescriptor.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::NON_PATCH
undefined
Definition: patchDescriptor.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryBasisPatchSize
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20)
Definition: patchDescriptor.h:131
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BOUNDARY
Definition: patchDescriptor.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::TRIANGLES
bilinear triangles-only mesh
Definition: patchDescriptor.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::POINTS
points (useful for cage drawing)
Definition: patchDescriptor.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY
Definition: patchDescriptor.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetType
Type GetType() const
Returns the type of the patch.
Definition: patchDescriptor.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(int type)
Constructor.
Definition: patchDescriptor.h:84
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
Definition: patchDescriptor.h:88
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryPatchSize
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
Definition: patchDescriptor.h:128
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstPatchDescriptorArray
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
Definition: patchDescriptor.h:151
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LOOP
Loop patch.
Definition: patchDescriptor.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
static bool IsAdaptive(Type type)
Returns true if the type is an adaptive patch.
Definition: patchDescriptor.h:97
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::QUADS
bilinear quads-only patches
Definition: patchDescriptor.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::print
void print() const
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...