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>
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
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);
52
54 return &_patchArrays[0];
55 }
56 const int *GetPatchIndexBuffer() const {
57 return &_indexBuffer[0];
58 }
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
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:
110 std::vector<int> _indexBuffer;
112
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
std::vector< PatchParam > PatchParamVector
Definition types.h:116
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
Container for arrays of parametric patches.
Definition patchTable.h:38
const PatchArray * GetFVarPatchArrayBuffer(int fvarChannel=0) const
size_t GetFVarPatchParamSize(int fvarChannel=0) const
static CpuPatchTable * Create(const Far::PatchTable *patchTable, void *deviceContext=NULL)
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
std::vector< PatchArrayVector > _fvarPatchArrays