OpenSubdiv: opensubdiv/osd/cpuPatchTable.h Source File

| 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
59 class CpuPatchTable {
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);
68 ~CpuPatchTable() {}
69
70 const PatchArray *GetPatchArrayBuffer() const {
71 return &_patchArrays[0];
72 }
73 const int *GetPatchIndexBuffer() const {
74 return &_indexBuffer[0];
75 }
76 const PatchParam *GetPatchParamBuffer() const {
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
90 const PatchArray *GetVaryingPatchArrayBuffer() const {
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 }
102 size_t GetVaryingPatchIndexSize() const {
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:
126 PatchArrayVector _patchArrays;
127 std::vector<int> _indexBuffer;
128 PatchParamVector _patchParamBuffer;
129
130 PatchArrayVector _varyingPatchArrays;
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
OpenSubdiv
Definition: limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParamVector
std::vector< PatchParam > PatchParamVector
Definition: types.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable
Cpu patch table.
Definition: cpuPatchTable.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchArrayBuffer
const PatchArray * GetFVarPatchArrayBuffer(int fvarChannel=0) const
Definition: cpuPatchTable.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchIndexBuffer
const int * GetVaryingPatchIndexBuffer() const
Definition: cpuPatchTable.h:96
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_varyingIndexBuffer
std::vector< int > _varyingIndexBuffer
Definition: cpuPatchTable.h:131
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchParamSize
size_t GetFVarPatchParamSize(int fvarChannel=0) const
Definition: cpuPatchTable.h:121
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::~CpuPatchTable
~CpuPatchTable()
Definition: cpuPatchTable.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_patchParamBuffer
PatchParamVector _patchParamBuffer
Definition: cpuPatchTable.h:128
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchIndexBuffer
const int * GetPatchIndexBuffer() const
Definition: cpuPatchTable.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::Create
static CpuPatchTable * Create(const Far::PatchTable *patchTable, void *deviceContext=NULL)
Definition: cpuPatchTable.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_fvarParamBuffers
std::vector< PatchParamVector > _fvarParamBuffers
Definition: cpuPatchTable.h:135
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::CpuPatchTable
CpuPatchTable(const Far::PatchTable *patchTable)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_fvarIndexBuffers
std::vector< std::vector< int > > _fvarIndexBuffers
Definition: cpuPatchTable.h:134
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchIndexSize
size_t GetPatchIndexSize() const
Definition: cpuPatchTable.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_patchArrays
PatchArrayVector _patchArrays
Definition: cpuPatchTable.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchParamBuffer
const PatchParam * GetPatchParamBuffer() const
Definition: cpuPatchTable.h:76
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_indexBuffer
std::vector< int > _indexBuffer
Definition: cpuPatchTable.h:127
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchIndexSize
size_t GetFVarPatchIndexSize(int fvarChannel=0) const
Definition: cpuPatchTable.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchIndexBuffer
const int * GetFVarPatchIndexBuffer(int fvarChannel=0) const
Definition: cpuPatchTable.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchParamBuffer
const PatchParam * GetFVarPatchParamBuffer(int fvarChannel=0) const
Definition: cpuPatchTable.h:118
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchParamSize
size_t GetPatchParamSize() const
Definition: cpuPatchTable.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchIndexSize
size_t GetVaryingPatchIndexSize() const
Definition: cpuPatchTable.h:102
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchArrayBuffer
const PatchArray * GetVaryingPatchArrayBuffer() const
Definition: cpuPatchTable.h:90
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetNumFVarChannels
int GetNumFVarChannels() const
Definition: cpuPatchTable.h:106
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetNumPatchArrays
size_t GetNumPatchArrays() const
Definition: cpuPatchTable.h:80
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchArrayBuffer
const PatchArray * GetPatchArrayBuffer() const
Definition: cpuPatchTable.h:70
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_varyingPatchArrays
PatchArrayVector _varyingPatchArrays
Definition: cpuPatchTable.h:130
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_fvarPatchArrays
std::vector< PatchArrayVector > _fvarPatchArrays
Definition: cpuPatchTable.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray
Definition: types.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition: types.h:127