All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vdbTextureData.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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 #ifndef GLF_VDB_TEXTURE_DATA_H
25 #define GLF_VDB_TEXTURE_DATA_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/base/gf/matrix4d.h"
31 #include "pxr/base/gf/vec3i.h"
32 #include "pxr/imaging/glf/api.h"
33 #include "pxr/imaging/glf/image.h"
34 #include "pxr/imaging/glf/baseTextureData.h"
35 
36 #include "pxr/base/gf/bbox3d.h"
37 
38 #include <memory>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
43 
44 class GlfVdbTextureData_DenseGridHolderBase;
45 
50 class GlfVdbTextureData : public GlfBaseTextureData {
51 public:
52  GLF_API
53  static GlfVdbTextureDataRefPtr
54  New(std::string const &filePath, size_t targetMemory);
55 
57  const GfBBox3d &GetBoundingBox() const { return _boundingBox; }
58 
59  GLF_API
60  int NumDimensions() const override;
61 
62  GLF_API
63  int ResizedWidth(int mipLevel = 0) const override;
64 
65  GLF_API
66  int ResizedHeight(int mipLevel = 0) const override;
67 
68  GLF_API
69  int ResizedDepth(int mipLevel = 0) const override;
70 
71  GLenum GLInternalFormat() const override;
72 
73  GLenum GLFormat() const override;
74 
75  GLenum GLType() const override;
76 
77  size_t TargetMemory() const override;
78 
79  WrapInfo GetWrapInfo() const override;
80 
81  size_t ComputeBytesUsed() const override;
82 
83  size_t ComputeBytesUsedByMip(int mipLevel = 0) const override;
84 
85  bool Read(int degradeLevel,
86  bool generateMipmap,
88  originLocation = GlfImage::OriginUpperLeft) override;
89 
90  bool HasRawBuffer(int mipLevel = 0) const override;
91 
92  unsigned char * GetRawBuffer(int mipLevel = 0) const override;
93 
94  int GetNumMipLevels() const override;
95 
96 private:
97  GlfVdbTextureData(std::string const &filePath, size_t targetMemory);
98  ~GlfVdbTextureData() override;
99 
100  const std::string _filePath;
101 
102  size_t _targetMemory;
103 
104  int _nativeWidth, _nativeHeight, _nativeDepth;
105  int _bytesPerPixel;
106 
107  GLenum _glInternalFormat, _glFormat, _glType;
108 
109  WrapInfo _wrapInfo;
110 
111  size_t _size;
112 
113  GfBBox3d _boundingBox;
114 
115  std::unique_ptr<GlfVdbTextureData_DenseGridHolderBase> _denseGrid;
116 };
117 
118 
119 PXR_NAMESPACE_CLOSE_SCOPE
120 
121 #endif
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
ImageOriginLocation
Specifies whether to treat the image origin as the upper-left corner or the lower left...
Definition: image.h:60
const GfBBox3d & GetBoundingBox() const
See GlfVdbTexture for details.
Implements GlfBaseTextureData to load an OpenVDB file.
Basic type: arbitrarily oriented 3D bounding box.
Definition: bbox3d.h:84