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 terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_CPU_PATCH_TABLE_H
9#define OPENSUBDIV3_OSD_CPU_PATCH_TABLE_H
10
11#include "../version.h"
12
13#include <vector>
14#include "../far/patchDescriptor.h"
15#include "../osd/nonCopyable.h"
16#include "../osd/types.h"
17
18#include <vector>
19
20namespace OpenSubdiv {
21namespace OPENSUBDIV_VERSION {
22
23namespace Far{
24 class PatchTable;
25};
26
27namespace Osd {
28
42 class CpuPatchTable {
43public:
44 static CpuPatchTable *Create(const Far::PatchTable *patchTable,
45 void *deviceContext = NULL) {
46 (void)deviceContext; // unused
47 return new CpuPatchTable(patchTable);
48 }
49
50 explicit CpuPatchTable(const Far::PatchTable *patchTable);
51 ~CpuPatchTable() {}
52
53 const PatchArray *GetPatchArrayBuffer() const {
54 return &_patchArrays[0];
55 }
56 const int *GetPatchIndexBuffer() const {
57 return &_indexBuffer[0];
58 }
59 const PatchParam *GetPatchParamBuffer() const {
60 return &_patchParamBuffer[0];
61 }
62
63 size_t GetNumPatchArrays() const {
64 return _patchArrays.size();
65 }
66 size_t GetPatchIndexSize() const {
67 return _indexBuffer.size();
68 }
69 size_t GetPatchParamSize() const {
70 return _patchParamBuffer.size();
71 }
72
73 const PatchArray *GetVaryingPatchArrayBuffer() const {
74 if (_varyingPatchArrays.empty()) {
75 return NULL;
76 }
77 return &_varyingPatchArrays[0];
78 }
79 const int *GetVaryingPatchIndexBuffer() const {
80 if (_varyingIndexBuffer.empty()) {
81 return NULL;
82 }
83 return &_varyingIndexBuffer[0];
84 }
85 size_t GetVaryingPatchIndexSize() const {
86 return _varyingIndexBuffer.size();
87 }
88
89 int GetNumFVarChannels() const {
90 return (int)_fvarPatchArrays.size();
91 }
92 const PatchArray *GetFVarPatchArrayBuffer(int fvarChannel = 0) const {
93 return &_fvarPatchArrays[fvarChannel][0];
94 }
95 const int *GetFVarPatchIndexBuffer(int fvarChannel = 0) const {
96 return &_fvarIndexBuffers[fvarChannel][0];
97 }
98 size_t GetFVarPatchIndexSize(int fvarChannel = 0) const {
99 return _fvarIndexBuffers[fvarChannel].size();
100 }
101 const PatchParam *GetFVarPatchParamBuffer(int fvarChannel= 0) const {
102 return &_fvarParamBuffers[fvarChannel][0];
103 }
104 size_t GetFVarPatchParamSize(int fvarChannel = 0) const {
105 return _fvarParamBuffers[fvarChannel].size();
106 }
107
108protected:
109 PatchArrayVector _patchArrays;
110 std::vector<int> _indexBuffer;
111 PatchParamVector _patchParamBuffer;
112
113 PatchArrayVector _varyingPatchArrays;
114 std::vector<int> _varyingIndexBuffer;
115
116 std::vector< PatchArrayVector > _fvarPatchArrays;
117 std::vector< std::vector<int> > _fvarIndexBuffers;
118 std::vector< PatchParamVector > _fvarParamBuffers;
119};
120
121} // end namespace Osd
122
123} // end namespace OPENSUBDIV_VERSION
124using namespace OPENSUBDIV_VERSION;
125
126} // end namespace OpenSubdiv
127
128#endif // OPENSUBDIV3_OSD_CPU_PATCH_TABLE_H
patchDescriptor.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParamVector
std::vector< PatchParam > PatchParamVector
Definition types.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchArrayBuffer
const PatchArray * GetFVarPatchArrayBuffer(int fvarChannel=0) const
Definition cpuPatchTable.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchIndexBuffer
const int * GetVaryingPatchIndexBuffer() const
Definition cpuPatchTable.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_varyingIndexBuffer
std::vector< int > _varyingIndexBuffer
Definition cpuPatchTable.h:114
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchParamSize
size_t GetFVarPatchParamSize(int fvarChannel=0) const
Definition cpuPatchTable.h:104
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::~CpuPatchTable
~CpuPatchTable()
Definition cpuPatchTable.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_patchParamBuffer
PatchParamVector _patchParamBuffer
Definition cpuPatchTable.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchIndexBuffer
const int * GetPatchIndexBuffer() const
Definition cpuPatchTable.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::Create
static CpuPatchTable * Create(const Far::PatchTable *patchTable, void *deviceContext=NULL)
Definition cpuPatchTable.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_fvarParamBuffers
std::vector< PatchParamVector > _fvarParamBuffers
Definition cpuPatchTable.h:118
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:117
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchIndexSize
size_t GetPatchIndexSize() const
Definition cpuPatchTable.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_patchArrays
PatchArrayVector _patchArrays
Definition cpuPatchTable.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchParamBuffer
const PatchParam * GetPatchParamBuffer() const
Definition cpuPatchTable.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_indexBuffer
std::vector< int > _indexBuffer
Definition cpuPatchTable.h:110
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchIndexSize
size_t GetFVarPatchIndexSize(int fvarChannel=0) const
Definition cpuPatchTable.h:98
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchIndexBuffer
const int * GetFVarPatchIndexBuffer(int fvarChannel=0) const
Definition cpuPatchTable.h:95
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetFVarPatchParamBuffer
const PatchParam * GetFVarPatchParamBuffer(int fvarChannel=0) const
Definition cpuPatchTable.h:101
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchParamSize
size_t GetPatchParamSize() const
Definition cpuPatchTable.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchIndexSize
size_t GetVaryingPatchIndexSize() const
Definition cpuPatchTable.h:85
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetVaryingPatchArrayBuffer
const PatchArray * GetVaryingPatchArrayBuffer() const
Definition cpuPatchTable.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetNumFVarChannels
int GetNumFVarChannels() const
Definition cpuPatchTable.h:89
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetNumPatchArrays
size_t GetNumPatchArrays() const
Definition cpuPatchTable.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::GetPatchArrayBuffer
const PatchArray * GetPatchArrayBuffer() const
Definition cpuPatchTable.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_varyingPatchArrays
PatchArrayVector _varyingPatchArrays
Definition cpuPatchTable.h:113
OpenSubdiv::OPENSUBDIV_VERSION::Osd::CpuPatchTable::_fvarPatchArrays
std::vector< PatchArrayVector > _fvarPatchArrays
Definition cpuPatchTable.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray
Definition types.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition types.h:110
types.h