All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
types.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 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_OSD_TYPES_H
26 #define OPENSUBDIV3_OSD_TYPES_H
27 
28 #include "../version.h"
29 #include "../far/patchTable.h"
30 
31 #include <algorithm>
32 
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
35 
36 namespace Osd {
37 
42 struct PatchCoord {
43  // 5-ints struct.
44 
53  PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg) :
54  handle(handleArg), s(sArg), t(tArg) { }
55 
56  PatchCoord() : s(0), t(0) {
57  handle.arrayIndex = 0;
58  handle.patchIndex = 0;
59  handle.vertIndex = 0;
60  }
61 
63  float s, t;
64 };
65 
66 struct PatchArray {
67  // 4-ints struct.
69  int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
70  regDesc(desc_in), desc(desc_in),
71  numPatches(numPatches_in), indexBase(indexBase_in),
72  stride(desc_in.GetNumControlVertices()),
73  primitiveIdBase(primitiveIdBase_in) {}
74 
76  int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
77  regDesc(regDesc_in), desc(irregDesc_in),
78  numPatches(numPatches_in), indexBase(indexBase_in),
79  stride(std::max(regDesc_in.GetNumControlVertices(),
80  irregDesc_in.GetNumControlVertices())),
81  primitiveIdBase(primitiveIdBase_in) {}
82 
84  return desc;
85  }
87  return regDesc;
88  }
90  return desc;
91  }
92 
93  int GetPatchType() const {
94  return desc.GetType();
95  }
96  int GetPatchTypeRegular() const {
97  return regDesc.GetType();
98  }
99  int GetPatchTypeIrregular() const {
100  return desc.GetType();
101  }
102 
103  int GetNumPatches() const {
104  return numPatches;
105  }
106  int GetIndexBase() const {
107  return indexBase;
108  }
109  int GetStride() const {
110  return stride;
111  }
112  int GetPrimitiveIdBase() const {
113  return primitiveIdBase;
114  }
115 
116  // Separate regular and irregular patch descriptors for cases where the
117  // array is mixed -- both will be equal if only a single type specified
120 
122  int indexBase; // an offset within the index buffer
123  int stride; // stride in buffer between patches
124  int primitiveIdBase; // an offset within the patch param buffer
125 };
126 
127 struct PatchParam : public Far::PatchParam {
128  // int3 struct.
129  float sharpness;
130 };
131 
132 typedef std::vector<PatchArray> PatchArrayVector;
133 typedef std::vector<PatchParam> PatchParamVector;
134 
135 } // end namespace Osd
136 
137 } // end namespace OPENSUBDIV_VERSION
138 using namespace OPENSUBDIV_VERSION;
139 
140 } // end namespace OpenSubdiv
141 
142 
143 #endif // OPENSUBDIV3_OSD_TYPES_H
Far::PatchDescriptor const & GetDescriptorRegular() const
Definition: types.h:86
Far::PatchTable::PatchHandle handle
patch handle
Definition: types.h:62
std::vector< PatchParam > PatchParamVector
Definition: types.h:133
PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition: types.h:75
float t
parametric location on patch
Definition: types.h:63
Far::PatchDescriptor const & GetDescriptorIrregular() const
Definition: types.h:89
PatchArray(Far::PatchDescriptor desc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition: types.h:68
Type GetType() const
Returns the type of the patch.
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg)
Constructor.
Definition: types.h:53
Handle that can be used as unique patch identifier within PatchTable.
Definition: patchTable.h:60
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
Far::PatchDescriptor const & GetDescriptor() const
Definition: types.h:83
Coordinates set on a patch table.
Definition: types.h:42