OpenSubdiv
Loading...
Searching...
No Matches
cpuPatchTable.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_CPU_PATCH_TABLE_H
26#define OPENSUBDIV3_OSD_CPU_PATCH_TABLE_H
27
28#include "../version.h"
29
30#include <vector>
31#include "../far/patchDescriptor.h"
32#include "../osd/nonCopyable.h"
33#include "../osd/types.h"
34
35#include <vector>
36
37namespace OpenSubdiv {
38namespace OPENSUBDIV_VERSION {
39
40namespace Far{
41 class PatchTable;
42};
43
44namespace Osd {
45
60public:
61 static CpuPatchTable *Create(const Far::PatchTable *patchTable,
62 void *deviceContext = NULL) {
63 (void)deviceContext; // unused
64 return new CpuPatchTable(patchTable);
65 }
66
67 explicit CpuPatchTable(const Far::PatchTable *patchTable);
69
71 return &_patchArrays[0];
72 }
73 const int *GetPatchIndexBuffer() const {
74 return &_indexBuffer[0];
75 }
77 return &_patchParamBuffer[0];
78 }
79
80 size_t GetNumPatchArrays() const {
81 return _patchArrays.size();
82 }
83 size_t GetPatchIndexSize() const {
84 return _indexBuffer.size();
85 }
86 size_t GetPatchParamSize() const {
87 return _patchParamBuffer.size();
88 }
89
91 if (_varyingPatchArrays.empty()) {
92 return NULL;
93 }
94 return &_varyingPatchArrays[0];
95 }
96 const int *GetVaryingPatchIndexBuffer() const {
97 if (_varyingIndexBuffer.empty()) {
98 return NULL;
99 }
100 return &_varyingIndexBuffer[0];
101 }
103 return _varyingIndexBuffer.size();
104 }
105
106 int GetNumFVarChannels() const {
107 return (int)_fvarPatchArrays.size();
108 }
109 const PatchArray *GetFVarPatchArrayBuffer(int fvarChannel = 0) const {
110 return &_fvarPatchArrays[fvarChannel][0];
111 }
112 const int *GetFVarPatchIndexBuffer(int fvarChannel = 0) const {
113 return &_fvarIndexBuffers[fvarChannel][0];
114 }
115 size_t GetFVarPatchIndexSize(int fvarChannel = 0) const {
116 return _fvarIndexBuffers[fvarChannel].size();
117 }
118 const PatchParam *GetFVarPatchParamBuffer(int fvarChannel= 0) const {
119 return &_fvarParamBuffers[fvarChannel][0];
120 }
121 size_t GetFVarPatchParamSize(int fvarChannel = 0) const {
122 return _fvarParamBuffers[fvarChannel].size();
123 }
124
125protected:
127 std::vector<int> _indexBuffer;
129
131 std::vector<int> _varyingIndexBuffer;
132
133 std::vector< PatchArrayVector > _fvarPatchArrays;
134 std::vector< std::vector<int> > _fvarIndexBuffers;
135 std::vector< PatchParamVector > _fvarParamBuffers;
136};
137
138} // end namespace Osd
139
140} // end namespace OPENSUBDIV_VERSION
141using namespace OPENSUBDIV_VERSION;
142
143} // end namespace OpenSubdiv
144
145#endif // OPENSUBDIV3_OSD_CPU_PATCH_TABLE_H
std::vector< PatchParam > PatchParamVector
Definition: types.h:133
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
Container for arrays of parametric patches.
Definition: patchTable.h:55
const PatchArray * GetFVarPatchArrayBuffer(int fvarChannel=0) const
size_t GetFVarPatchParamSize(int fvarChannel=0) const
static CpuPatchTable * Create(const Far::PatchTable *patchTable, void *deviceContext=NULL)
Definition: cpuPatchTable.h:61
std::vector< PatchParamVector > _fvarParamBuffers
CpuPatchTable(const Far::PatchTable *patchTable)
std::vector< std::vector< int > > _fvarIndexBuffers
size_t GetFVarPatchIndexSize(int fvarChannel=0) const
const int * GetFVarPatchIndexBuffer(int fvarChannel=0) const
const PatchParam * GetFVarPatchParamBuffer(int fvarChannel=0) const
const PatchArray * GetVaryingPatchArrayBuffer() const
Definition: cpuPatchTable.h:90
std::vector< PatchArrayVector > _fvarPatchArrays