All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 
51 
52 public:
53 
54  enum Type {
55  NON_PATCH = 0,
56 
59 
62 
63  LOOP,
64 
69  };
70 
71 public:
72 
75  _type(NON_PATCH) { }
76 
78  PatchDescriptor(int type) :
79  _type(type) { }
80 
83  _type(d.GetType()) { }
84 
86  Type GetType() const {
87  return (Type)_type;
88  }
89 
91  static inline bool IsAdaptive(Type type) {
92  return (type>=LOOP && type<=GREGORY_BASIS);
93  }
94 
96  bool IsAdaptive() const {
97  return IsAdaptive( this->GetType() );
98  }
99 
102  static inline short GetNumControlVertices( Type t );
103 
105  static inline short GetNumFVarControlVertices( Type t );
106 
109  short GetNumControlVertices() const {
110  return GetNumControlVertices( this->GetType() );
111  }
112 
115  return GetNumFVarControlVertices( this->GetType() );
116  }
117 
119  static short GetRegularPatchSize() { return 16; }
120 
122  static short GetGregoryPatchSize() { return 4; }
123 
125  static short GetGregoryBasisPatchSize() { return 20; }
126 
127 
131 
133  inline bool operator < ( PatchDescriptor const other ) const;
134 
136  inline bool operator == ( PatchDescriptor const other ) const;
137 
138  // debug helper
139  void print() const;
140 
141 private:
142  unsigned int _type;
143 };
144 
146 
147 // Returns the number of control vertices expected for a patch of this type
148 inline short
150  switch (type) {
151  case REGULAR : return GetRegularPatchSize();
152  case QUADS : return 4;
153  case GREGORY :
154  case GREGORY_BOUNDARY : return GetGregoryPatchSize();
155  case GREGORY_BASIS : return GetGregoryBasisPatchSize();
156  case TRIANGLES : return 3;
157  case LINES : return 2;
158  case POINTS : return 1;
159  default : return -1;
160  }
161 }
162 
163 // Returns the number of face-varying control vertices expected for a patch of this type
164 inline short
167 }
168 
169 // Allows ordering of patches by type
170 inline bool
172  return (_type < other._type);
173 }
174 
175 // True if the descriptors are identical
176 inline bool
178  return _type == other._type;
179 }
180 
181 
182 
183 } // end namespace Far
184 
185 } // end namespace OPENSUBDIV_VERSION
186 using namespace OPENSUBDIV_VERSION;
187 
188 } // end namespace OpenSubdiv
189 
190 #endif /* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
static bool IsAdaptive(Type type)
Returns true if the type is an adaptive patch.
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20)
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
static Vtr::ConstArray< PatchDescriptor > GetAdaptivePatchDescriptors(Sdc::SchemeType type)
Returns a vector of all the legal patch descriptors for the given adaptive subdivision scheme...
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition: types.h:37
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
Type GetType() const
Returns the type of the patch.
short GetNumControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
bool IsAdaptive() const
Returns true if the type is an adaptive patch.