OpenSubdiv
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
18namespace OpenSubdiv {
19namespace OPENSUBDIV_VERSION {
20
21namespace Far {
22
28
29public:
30
48
49public:
50
53 _type(NON_PATCH) { }
54
56 PatchDescriptor(int type) :
57 _type(type) { }
58
61 _type(d.GetType()) { }
62
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
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
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
125private:
126 unsigned int _type;
127};
128
130
131// Returns the number of control vertices expected for a patch of this type
132inline short
134 switch (type) {
135 case REGULAR : return GetRegularPatchSize();
136 case LOOP : return 12;
137 case QUADS : return 4;
138 case GREGORY :
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
150inline short
154
155// Allows ordering of patches by type
156inline bool
158 return (_type < other._type);
159}
160
161// True if the descriptors are identical
162inline bool
164 return _type == other._type;
165}
166
167
168
169} // end namespace Far
170
171} // end namespace OPENSUBDIV_VERSION
172using namespace OPENSUBDIV_VERSION;
173
174} // end namespace OpenSubdiv
175
176#endif /* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition types.h:20
@ LOOP
regular triangular patch for the Loop scheme
@ REGULAR
regular B-Spline patch for the Catmark scheme
bool IsAdaptive() const
Returns true if the type is an adaptive patch.
Type GetType() const
Returns the type of the patch.
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20)
short GetNumControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
PatchDescriptor & operator=(PatchDescriptor const &d)
Assignment operator.
static bool IsAdaptive(Type type)
Returns true if the type is an adaptive (non-linear) patch.
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
static Vtr::ConstArray< PatchDescriptor > GetAdaptivePatchDescriptors(Sdc::SchemeType type)
Returns a vector of all the legal patch descriptors for the given adaptive subdivision scheme.