My Project
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
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetIndexBase
int GetIndexBase() const
Definition: types.h:106
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam::sharpness
float sharpness
Definition: types.h:129
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition: types.h:127
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::regDesc
Far::PatchDescriptor regDesc
Definition: types.h:118
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle::arrayIndex
Index arrayIndex
Definition: patchTable.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorRegular
const Far::PatchDescriptor & GetDescriptorRegular() const
Definition: types.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchType
int GetPatchType() const
Definition: types.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray
Definition: types.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle::patchIndex
Index patchIndex
Definition: patchTable.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPrimitiveIdBase
int GetPrimitiveIdBase() const
Definition: types.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord()
Definition: types.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::PatchArray
PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition: types.h:75
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord
Coordinates set on a patch table.
Definition: types.h:42
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptor
const Far::PatchDescriptor & GetDescriptor() const
Definition: types.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::t
float t
parametric location on patch
Definition: types.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeIrregular
int GetPatchTypeIrregular() const
Definition: types.h:99
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::stride
int stride
Definition: types.h:123
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::handle
Far::PatchTable::PatchHandle handle
patch handle
Definition: types.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::numPatches
int numPatches
Definition: types.h:121
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg)
Constructor.
Definition: types.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::PatchArray
PatchArray(Far::PatchDescriptor desc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition: types.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::s
float s
Definition: types.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle
Handle that can be used as unique patch identifier within PatchTable.
Definition: patchTable.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor
Describes the type of a patch.
Definition: patchDescriptor.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Patch parameterization.
Definition: patchParam.h:152
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle::vertIndex
Index vertIndex
Definition: patchTable.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::primitiveIdBase
int primitiveIdBase
Definition: types.h:124
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetType
Type GetType() const
Returns the type of the patch.
Definition: patchDescriptor.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetStride
int GetStride() const
Definition: types.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeRegular
int GetPatchTypeRegular() const
Definition: types.h:96
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParamVector
std::vector< PatchParam > PatchParamVector
Definition: types.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorIrregular
const Far::PatchDescriptor & GetDescriptorIrregular() const
Definition: types.h:89
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::desc
Far::PatchDescriptor desc
Definition: types.h:119
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::indexBase
int indexBase
Definition: types.h:122
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetNumPatches
int GetNumPatches() const
Definition: types.h:103