Ptex: Ptexture.h Source File

Ptex

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

Ptexture.h
Go to the documentation of this file.
1 #ifndef Ptexture_h
2 #define Ptexture_h
3
4 /*
5 PTEX SOFTWARE
6 Copyright 2009 Disney Enterprises, Inc. All rights reserved
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15 * Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19
20 * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation
21 Studios" or the names of its contributors may NOT be used to
22 endorse or promote products derived from this software without
23 specific prior written permission from Walt Disney Pictures.
24
25 Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND
26 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
27 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
28 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED.
29 IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER OR
30 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND BASED ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37 */
38
44 #if defined(_WIN32) || defined(_WINDOWS) || defined(_MSC_VER)
45 # ifndef PTEXAPI
46 # ifndef PTEX_STATIC
47 # ifdef PTEX_EXPORTS
48 # define PTEXAPI __declspec(dllexport)
49 # else
50 # define PTEXAPI __declspec(dllimport)
51 # endif
52 # else
53 # define PTEXAPI
54 # endif
55 # endif
56 #else
57 # ifndef PTEXAPI
58 # define PTEXAPI
59 # endif
60 # ifndef DOXYGEN
61 # define PTEX_USE_STDSTRING
62 # endif
63 #endif
64
65 #include "PtexInt.h"
66 #include <ostream>
67
68 #define PtexAPIVersion 2
69 #define PtexFileMajorVersion 1
70 #define PtexFileMinorVersion 3
71
73 struct Ptex {
77 enum MeshType {
78 mt_triangle,
79 mt_quad
80 };
81
83 enum DataType {
84 dt_uint8,
85 dt_uint16,
86 dt_half,
87 dt_float
88 };
89
91 enum BorderMode {
92 m_clamp,
93 m_black,
94 m_periodic
95 };
96
99 enum EdgeId {
100 e_bottom,
101 e_right,
102 e_top,
103 e_left
104 };
105
107 enum MetaDataType {
108 mdt_string,
109 mdt_int8,
110 mdt_int16,
111 mdt_int32,
112 mdt_float,
113 mdt_double
114 };
115
117 PTEXAPI static const char* MeshTypeName(MeshType mt);
118
120 PTEXAPI static const char* DataTypeName(DataType dt);
121
123 PTEXAPI static const char* BorderModeName(BorderMode m);
124
126 PTEXAPI static const char* EdgeIdName(EdgeId eid);
127
129 PTEXAPI static const char* MetaDataTypeName(MetaDataType mdt);
130
132 static int DataSize(DataType dt) {
133 static const int sizes[] = { 1,2,2,4 };
134 return sizes[dt];
135 }
136
138 static float OneValue(DataType dt) {
139 static const float one[] = { 255.f, 65535.f, 1.f, 1.f };
140 return one[dt];
141 }
142
144 static float OneValueInv(DataType dt) {
145 static const float one[] = { 1.f/255.f, 1.f/65535.f, 1.f, 1.f };
146 return one[dt];
147 }
148
150 PTEXAPI static void ConvertToFloat(float* dst, const void* src,
151 Ptex::DataType dt, int numChannels);
152
154 PTEXAPI static void ConvertFromFloat(void* dst, const float* src,
155 Ptex::DataType dt, int numChannels);
156
161 struct Res {
162 int8_t ulog2;
163 int8_t vlog2;
164
166 Res() : ulog2(0), vlog2(0) {}
167
169 Res(int8_t ulog2_, int8_t vlog2_) : ulog2(ulog2_), vlog2(vlog2_) {}
170
172 Res(uint16_t value) {
173 ulog2 = *(uint8_t *)&value;
174 vlog2 = *((uint8_t *)&value + 1);
175 }
176
178 int u() const { return 1<<(unsigned)ulog2; }
179
181 int v() const { return 1<<(unsigned)vlog2; }
182
184 uint16_t& val() { return *(uint16_t*)this; }
185
187 const uint16_t& val() const { return *(const uint16_t*)this; }
188
190 int size() const { return u() * v(); }
191
193 bool operator==(const Res& r) const { return val() == r.val(); }
194
196 bool operator!=(const Res& r) const { return val() != r.val(); }
197
199 bool operator>=(const Res& r) const { return ulog2 >= r.ulog2 && vlog2 >= r.vlog2; }
200
202 Res swappeduv() const { return Res(vlog2, ulog2); }
203
205 void swapuv() { *this = swappeduv(); }
206
208 void clamp(const Res& r) {
209 if (ulog2 > r.ulog2) ulog2 = r.ulog2;
210 if (vlog2 > r.vlog2) vlog2 = r.vlog2;
211 }
212
214 int ntilesu(Res tileres) const { return 1<<(ulog2-tileres.ulog2); }
215
217 int ntilesv(Res tileres) const { return 1<<(vlog2-tileres.vlog2); }
218
220 int ntiles(Res tileres) const { return ntilesu(tileres) * ntilesv(tileres); }
221 };
222
237 struct FaceInfo {
238 Res res;
239 uint8_t adjedges;
240 uint8_t flags;
241 int32_t adjfaces[4];
242
244 FaceInfo() : res(), adjedges(0), flags(0)
245 {
246 adjfaces[0] = adjfaces[1] = adjfaces[2] = adjfaces[3] = -1;
247 }
248
250 FaceInfo(Res res_) : res(res_), adjedges(0), flags(0)
251 {
252 adjfaces[0] = adjfaces[1] = adjfaces[2] = adjfaces[3] = -1;
253 }
254
256 FaceInfo(Res res_, int adjfaces_[4], int adjedges_[4], bool isSubface_=false)
257 : res(res_), flags(isSubface_ ? flag_subface : 0)
258 {
259 setadjfaces(adjfaces_[0], adjfaces_[1], adjfaces_[2], adjfaces_[3]);
260 setadjedges(adjedges_[0], adjedges_[1], adjedges_[2], adjedges_[3]);
261 }
262
264 EdgeId adjedge(int eid) const { return EdgeId((adjedges >> (2*eid)) & 3); }
265
267 int adjface(int eid) const { return adjfaces[eid]; }
268
270 bool isConstant() const { return (flags & flag_constant) != 0; }
271
273 bool isNeighborhoodConstant() const { return (flags & flag_nbconstant) != 0; }
274
276 bool hasEdits() const { return (flags & flag_hasedits) != 0; }
277
279 bool isSubface() const { return (flags & flag_subface) != 0; }
280
282 void setadjfaces(int f0, int f1, int f2, int f3)
283 { adjfaces[0] = f0, adjfaces[1] = f1, adjfaces[2] = f2; adjfaces[3] = f3; }
284
286 void setadjedges(int e0, int e1, int e2, int e3)
287 { adjedges = (uint8_t)((e0&3) | ((e1&3)<<2) | ((e2&3)<<4) | ((e3&3)<<6)); }
288
290 enum { flag_constant = 1, flag_hasedits = 2, flag_nbconstant = 4, flag_subface = 8 };
291 };
292
293
300 #ifdef PTEX_USE_STDSTRING
301 typedef std::string String;
302 #else
303 class String
304 {
305 public:
306 String() : _str(0) {}
307 String(const String& str) : _str(0) { *this = str; }
308 PTEXAPI ~String();
309 PTEXAPI String& operator=(const char* str);
310 String& operator=(const String& str) { *this = str._str; return *this; }
311 String& operator=(const std::string& str) { *this = str.c_str(); return *this; }
312 const char* c_str() const { return _str ? _str : ""; }
313 bool empty() const { return _str == 0; }
314
315 private:
316 char* _str;
317 };
318 #endif
319
320 }
321 #ifndef DOXYGEN
322 ;
323 #endif
324
326 #ifndef PTEX_USE_STDSTRING
327 std::ostream& operator << (std::ostream& stream, const Ptex::String& str);
328 #endif
329
330
337 class PtexMetaData {
338 protected:
340 virtual ~PtexMetaData() {}
341
342 public:
344 virtual void release() = 0;
345
347 virtual int numKeys() = 0;
348
350 virtual void getKey(int n, const char*& key, Ptex::MetaDataType& type) = 0;
351
354 virtual void getValue(const char* key, const char*& value) = 0;
355
358 virtual void getValue(const char* key, const int8_t*& value, int& count) = 0;
359
362 virtual void getValue(const char* key, const int16_t*& value, int& count) = 0;
363
366 virtual void getValue(const char* key, const int32_t*& value, int& count) = 0;
367
370 virtual void getValue(const char* key, const float*& value, int& count) = 0;
371
374 virtual void getValue(const char* key, const double*& value, int& count) = 0;
375 };
376
377
388 class PtexFaceData {
389 protected:
391 virtual ~PtexFaceData() {}
392
393 public:
395 virtual void release() = 0;
396
398 virtual bool isConstant() = 0;
399
403 virtual Ptex::Res res() = 0;
404
408 virtual void getPixel(int u, int v, void* result) = 0;
409
416 virtual void* getData() = 0;
417
420 virtual bool isTiled() = 0;
421
423 virtual Ptex::Res tileRes() = 0;
424
426 virtual PtexFaceData* getTile(int tile) = 0;
427 };
428
429
439 class PtexTexture {
440 protected:
442 virtual ~PtexTexture() {}
443
444 public:
456 PTEXAPI static PtexTexture* open(const char* path, Ptex::String& error, bool premultiply=0);
457
458
460 virtual void release() = 0;
461
465 virtual const char* path() = 0;
466
468 virtual Ptex::MeshType meshType() = 0;
469
471 virtual Ptex::DataType dataType() = 0;
472
474 virtual Ptex::BorderMode uBorderMode() = 0;
475
477 virtual Ptex::BorderMode vBorderMode() = 0;
478
482 virtual int alphaChannel() = 0;
483
485 virtual int numChannels() = 0;
486
488 virtual int numFaces() = 0;
489
491 virtual bool hasEdits() = 0;
492
494 virtual bool hasMipMaps() = 0;
495
497 virtual PtexMetaData* getMetaData() = 0;
498
500 virtual const Ptex::FaceInfo& getFaceInfo(int faceid) = 0;
501
517 virtual void getData(int faceid, void* buffer, int stride) = 0;
518
530 virtual void getData(int faceid, void* buffer, int stride, Ptex::Res res) = 0;
531
533 virtual PtexFaceData* getData(int faceid) = 0;
534
544 virtual PtexFaceData* getData(int faceid, Ptex::Res res) = 0;
545
558 virtual void getPixel(int faceid, int u, int v,
559 float* result, int firstchan, int nchannels) = 0;
560
572 virtual void getPixel(int faceid, int u, int v,
573 float* result, int firstchan, int nchannels,
574 Ptex::Res res) = 0;
575 };
576
577
585 class PtexInputHandler {
586 protected:
587 virtual ~PtexInputHandler() {}
588
589 public:
590 typedef void* Handle;
591
596 virtual Handle open(const char* path) = 0;
597
599 virtual void seek(Handle handle, int64_t pos) = 0;
600
606 virtual size_t read(void* buffer, size_t size, Handle handle) = 0;
607
610 virtual bool close(Handle handle) = 0;
611
613 virtual const char* lastError() = 0;
614 };
615
616
634 class PtexCache {
635 protected:
637 virtual ~PtexCache() {}
638
639 public:
655 PTEXAPI static PtexCache* create(int maxFiles=0,
656 int maxMem=0,
657 bool premultiply=false,
658 PtexInputHandler* handler=0);
659
661 virtual void release() = 0;
662
668 virtual void setSearchPath(const char* path) = 0;
669
671 virtual const char* getSearchPath() = 0;
672
699 virtual PtexTexture* get(const char* path, Ptex::String& error) = 0;
700
705 virtual void purge(PtexTexture* texture) = 0;
706
712 virtual void purge(const char* path) = 0;
713
717 virtual void purgeAll() = 0;
718 };
719
720
737 class PtexWriter {
738 protected:
740 virtual ~PtexWriter() {}
741
742 public:
753 PTEXAPI
754 static PtexWriter* open(const char* path,
755 Ptex::MeshType mt, Ptex::DataType dt,
756 int nchannels, int alphachan, int nfaces,
757 Ptex::String& error, bool genmipmaps=true);
758
776 PTEXAPI
777 static PtexWriter* edit(const char* path, bool incremental,
778 Ptex::MeshType mt, Ptex::DataType dt,
779 int nchannels, int alphachan, int nfaces,
780 Ptex::String& error, bool genmipmaps=true);
781
790 PTEXAPI
791 static bool applyEdits(const char* path, Ptex::String& error);
792
794 virtual void release() = 0;
795
797 virtual void setBorderModes(Ptex::BorderMode uBorderMode, Ptex::BorderMode vBorderMode) = 0;
798
800 virtual void writeMeta(const char* key, const char* string) = 0;
801
803 virtual void writeMeta(const char* key, const int8_t* value, int count) = 0;
804
806 virtual void writeMeta(const char* key, const int16_t* value, int count) = 0;
807
809 virtual void writeMeta(const char* key, const int32_t* value, int count) = 0;
810
812 virtual void writeMeta(const char* key, const float* value, int count) = 0;
813
815 virtual void writeMeta(const char* key, const double* value, int count) = 0;
816
818 virtual void writeMeta(PtexMetaData* data) = 0;
819
831 virtual bool writeFace(int faceid, const Ptex::FaceInfo& info, const void* data, int stride=0) = 0;
832
838 virtual bool writeConstantFace(int faceid, const Ptex::FaceInfo& info, const void* data) = 0;
839
843 virtual bool close(Ptex::String& error) = 0;
844
845 #if NEW_API
846 virtual bool writeFaceReduction(int faceid, const Ptex::Res& res, const void* data, int stride=0) = 0;
847 virtual bool writeConstantFaceReduction(int faceid, const Ptex::Res& res, const void* data) = 0;
848 #endif
849 };
850
851
861 class PtexFilter {
862 protected:
864 virtual ~PtexFilter() {}
865
866 public:
868 enum FilterType {
869 f_point,
870 f_bilinear,
871 f_box,
872 f_gaussian,
873 f_bicubic,
874 f_bspline,
875 f_catmullrom,
876 f_mitchell
877 };
878
880 struct Options {
881 int __structSize;
882 FilterType filter;
883 bool lerp;
884 float sharpness;
885
887 Options(FilterType filter_=f_box, bool lerp_=0, float sharpness_=0) :
888 __structSize(sizeof(Options)),
889 filter(filter_), lerp(lerp_), sharpness(sharpness_) {}
890 };
891
892 /* Construct a filter for the given texture.
893 */
894 PTEXAPI static PtexFilter* getFilter(PtexTexture* tx, const Options& opts);
895
897 virtual void release() = 0;
898
920 virtual void eval(float* result, int firstchan, int nchannels,
921 int faceid, float u, float v, float uw1, float vw1, float uw2, float vw2,
922 float width=1, float blur=0) = 0;
923 };
924
925
955 template <class T> class PtexPtr {
956 T* _ptr;
957 public:
959 PtexPtr(T* ptr=0) : _ptr(ptr) {}
960
962 ~PtexPtr() { if (_ptr) _ptr->release(); }
963
965 operator T* () { return _ptr; }
966
968 T* operator-> () { return _ptr; }
969
971 T* get() { return _ptr; }
972
974 void swap(PtexPtr& p)
975 {
976 T* tmp = p._ptr;
977 p._ptr = _ptr;
978 _ptr = tmp;
979 }
980
982 void reset(T* ptr=0) {
983 if (_ptr) _ptr->release();
984 _ptr = ptr;
985 }
986
987 private:
989 PtexPtr(const PtexPtr& p);
990
992 void operator= (PtexPtr& p);
993 };
994
995 #endif
Ptex::mdt_float
Single-precision (32-bit) floating point.
Definition: Ptexture.h:112
PtexPtr::PtexPtr
PtexPtr(T *ptr=0)
Constructor.
Definition: Ptexture.h:959
Ptex::mt_quad
Mesh is quad-based.
Definition: Ptexture.h:79
PtexPtr::operator->
T * operator->()
Access members of pointer.
Definition: Ptexture.h:968
Ptex::e_left
Left edge, from UV (0,1) to (0,0)
Definition: Ptexture.h:103
PtexTexture::vBorderMode
virtual Ptex::BorderMode vBorderMode()=0
Mode for filtering texture access beyond mesh border.
PtexMetaData::getKey
virtual void getKey(int n, const char *&key, Ptex::MetaDataType &type)=0
Query the name and type of a meta data entry.
Ptex::mdt_int8
Signed 8-bit integer.
Definition: Ptexture.h:109
Ptex::OneValueInv
static float OneValueInv(DataType dt)
Lookup up inverse value of given data type that corresponds to the normalized value of 1...
Definition: Ptexture.h:144
Ptex::Res::ntiles
int ntiles(Res tileres) const
Determine the total number of tiles for the given tile res.
Definition: Ptexture.h:220
Ptex::Res::ntilesv
int ntilesv(Res tileres) const
Determine the number of tiles in the v direction for the given tile res.
Definition: Ptexture.h:217
Ptex::FaceInfo::FaceInfo
FaceInfo()
Default constructor, sets all members to zero.
Definition: Ptexture.h:244
Ptex::FaceInfo::adjface
int adjface(int eid) const
Access an adjacent face id. The eid value must be 0..3.
Definition: Ptexture.h:267
PtexTexture::numChannels
virtual int numChannels()=0
Number of channels stored in file.
PtexWriter
Interface for writing data to a ptex file.
Definition: Ptexture.h:737
Ptex::dt_uint8
Unsigned, 8-bit integer.
Definition: Ptexture.h:84
Ptex::String::~String
~String()
Definition: PtexUtils.cpp:660
Ptex::FaceInfo::setadjedges
void setadjedges(int e0, int e1, int e2, int e3)
Set the adjedges data.
Definition: Ptexture.h:286
Ptex
Common data structures and enums used throughout the API.
Definition: Ptexture.h:73
PtexFilter::f_box
Box filter.
Definition: Ptexture.h:871
PtexWriter::setBorderModes
virtual void setBorderModes(Ptex::BorderMode uBorderMode, Ptex::BorderMode vBorderMode)=0
Set border modes.
Ptex::FaceInfo::isConstant
bool isConstant() const
Determine if face is constant (by checking a flag).
Definition: Ptexture.h:270
MeshType
MeshType
Type of base mesh for which the textures are defined.
Definition: Ptexture.h:190
Ptex::Res::operator>=
bool operator>=(const Res &r) const
True if res is >= given res in both u and v directions.
Definition: Ptexture.h:199
Ptex::dt_uint16
Unsigned, 16-bit integer.
Definition: Ptexture.h:85
Ptex::DataSize
static int DataSize(DataType dt)
Look up size of given data type (in bytes).
Definition: Ptexture.h:132
Ptex::String
Memory-managed string.
Definition: Ptexture.h:303
PtexTexture::hasEdits
virtual bool hasEdits()=0
True if the file has edit blocks.
Ptex::e_top
Top edge, from UV (1,1) to (0,1)
Definition: Ptexture.h:102
Ptex::dt_half
Half-precision (16-bit) floating point.
Definition: Ptexture.h:86
Ptex::DataType
DataType
Type of data stored in texture file.
Definition: Ptexture.h:83
PtexPtr::reset
void reset(T *ptr=0)
Deallocate object pointed to, and optionally set to new value.
Definition: Ptexture.h:982
Ptex::FaceInfo::FaceInfo
FaceInfo(Res res_)
Constructor.
Definition: Ptexture.h:250
PtexMetaData
Meta data accessor.
Definition: Ptexture.h:337
PtexPtr::_ptr
T * _ptr
Definition: Ptexture.h:956
Ptex::FaceInfo::flags
uint8_t flags
Flags.
Definition: Ptexture.h:240
PtexFilter::Options::Options
Options(FilterType filter_=f_box, bool lerp_=0, float sharpness_=0)
Constructor - sets defaults.
Definition: Ptexture.h:887
PtexFilter::getFilter
static PtexFilter * getFilter(PtexTexture *tx, const Options &opts)
Definition: PtexFilters.cpp:421
Ptex::mt_triangle
Mesh is triangle-based.
Definition: Ptexture.h:78
PtexTexture::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
Ptex::Res::swappeduv
Res swappeduv() const
Get value of resolution with u and v swapped.
Definition: Ptexture.h:202
PtexCache
File-handle and memory cache for reading ptex files.
Definition: Ptexture.h:634
PtexFilter::eval
virtual void eval(float *result, int firstchan, int nchannels, int faceid, float u, float v, float uw1, float vw1, float uw2, float vw2, float width=1, float blur=0)=0
Apply filter to a ptex data file.
Ptex::FaceInfo::isNeighborhoodConstant
bool isNeighborhoodConstant() const
Determine if neighborhood of face is constant (by checking a flag).
Definition: Ptexture.h:273
Ptex::String::operator=
String & operator=(const char *str)
Definition: PtexUtils.cpp:666
Res
Pixel resolution of a given texture.
Definition: Ptexture.h:274
PtexPtr::operator=
void operator=(PtexPtr &p)
Assignment prohibited.
PtexFilter::f_bilinear
Bi-linear interpolation.
Definition: Ptexture.h:870
Ptex::mdt_string
Null-terminated string.
Definition: Ptexture.h:108
PtexCache::create
static PtexCache * create(int maxFiles=0, int maxMem=0, bool premultiply=false, PtexInputHandler *handler=0)
Create a cache with the specified limits.
Definition: PtexCache.cpp:410
String
Memory-managed string.
Definition: Ptexture.h:416
Ptex::MetaDataType
MetaDataType
Type of meta data entry.
Definition: Ptexture.h:107
PtexCache::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
Ptex::Res::v
int v() const
V resolution in texels.
Definition: Ptexture.h:181
PtexInputHandler::open
virtual Handle open(const char *path)=0
Open a file in read mode.
EdgeId
EdgeId
Edge IDs used in adjacency data in the Ptex::FaceInfo struct.
Definition: Ptexture.h:212
PtexTexture::alphaChannel
virtual int alphaChannel()=0
Index of alpha channel (if any).
PtexTexture::getMetaData
virtual PtexMetaData * getMetaData()=0
Access meta data.
PtexWriter::open
static PtexWriter * open(const char *path, Ptex::MeshType mt, Ptex::DataType dt, int nchannels, int alphachan, int nfaces, Ptex::String &error, bool genmipmaps=true)
Open a new texture file for writing.
Definition: PtexWriter.cpp:166
Ptex::OneValue
static float OneValue(DataType dt)
Look up value of given data type that corresponds to the normalized value of 1.0. ...
Definition: Ptexture.h:138
Res::vlog2
int8_t vlog2
log base 2 of v resolution, in texels
Definition: Ptexture.h:276
Ptex::e_bottom
Bottom edge, from UV (0,0) to (1,0)
Definition: Ptexture.h:100
Ptex::MeshTypeName
static const char * MeshTypeName(MeshType mt)
Look up name of given mesh type.
Definition: PtexUtils.cpp:45
PtexFaceData::~PtexFaceData
virtual ~PtexFaceData()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:391
PtexInputHandler::read
virtual size_t read(void *buffer, size_t size, Handle handle)=0
Read a number of bytes from the file.
Ptex::String::String
String()
Definition: Ptexture.h:306
Ptex::FaceInfo::adjfaces
int32_t adjfaces[4]
Adjacent faces (-1 == no adjacent face).
Definition: Ptexture.h:241
Ptex::BorderMode
BorderMode
How to handle mesh border when filtering.
Definition: Ptexture.h:91
PtexTexture::meshType
virtual Ptex::MeshType meshType()=0
Type of mesh for which texture data is defined.
PtexFaceData::res
virtual Ptex::Res res()=0
Resolution of the texture held by this data block.
PtexWriter::~PtexWriter
virtual ~PtexWriter()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:740
Ptex::String::_str
char * _str
Definition: Ptexture.h:316
PtexFaceData
Per-face texture data accessor.
Definition: Ptexture.h:388
Ptex::Res::operator!=
bool operator!=(const Res &r) const
Comparison operator.
Definition: Ptexture.h:196
PtexWriter::writeConstantFace
virtual bool writeConstantFace(int faceid, const Ptex::FaceInfo &info, const void *data)=0
Write constant texture data for a face.
Ptex::Res::u
int u() const
U resolution in texels.
Definition: Ptexture.h:178
PtexFaceData::getData
virtual void * getData()=0
Access the data from this data block.
Ptex::Res::vlog2
int8_t vlog2
log base 2 of v resolution, in texels
Definition: Ptexture.h:163
Res::val
uint16_t & val()
Resolution as a single 16-bit integer value.
Definition: Ptexture.h:297
PtexWriter::writeMeta
virtual void writeMeta(const char *key, const char *string)=0
Write a string as meta data.
Ptex::Res::ntilesu
int ntilesu(Res tileres) const
Determine the number of tiles in the u direction for the given tile res.
Definition: Ptexture.h:214
PtexFaceData::getTile
virtual PtexFaceData * getTile(int tile)=0
Access a tile from the data block.
PtexInputHandler::~PtexInputHandler
virtual ~PtexInputHandler()
Definition: Ptexture.h:587
Res::ulog2
int8_t ulog2
log base 2 of u resolution, in texels
Definition: Ptexture.h:275
Ptex::dt_float
Single-precision (32-bit) floating point.
Definition: Ptexture.h:87
PtexTexture::getData
virtual void getData(int faceid, void *buffer, int stride)=0
Access texture data for a face at highest-resolution.
DataType
DataType
Type of data stored in texture file.
Definition: Ptexture.h:196
operator<<
std::ostream & operator<<(std::ostream &stream, const Ptex::String &str)
Definition: PtexUtils.cpp:673
BorderMode
BorderMode
How to handle mesh border when filtering.
Definition: Ptexture.h:204
Ptex::FaceInfo::isSubface
bool isSubface() const
Determine if face is a subface (by checking a flag).
Definition: Ptexture.h:279
PtexTexture::hasMipMaps
virtual bool hasMipMaps()=0
True if the file has mipmaps.
Ptex::FaceInfo::hasEdits
bool hasEdits() const
Determine if face has edits in the file (by checking a flag).
Definition: Ptexture.h:276
Ptex::String::operator=
String & operator=(const String &str)
Definition: Ptexture.h:310
PtexCache::purgeAll
virtual void purgeAll()=0
Remove all texture files from the cache.
PtexFaceData::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
PtexFilter::~PtexFilter
virtual ~PtexFilter()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:864
PtexTexture::numFaces
virtual int numFaces()=0
Number of faces stored in file.
Ptex::DataTypeName
static const char * DataTypeName(DataType dt)
Look up name of given data type.
Definition: PtexUtils.cpp:54
PtexPtr::~PtexPtr
~PtexPtr()
Destructor, calls ptr->release().
Definition: Ptexture.h:962
Ptex::String::empty
bool empty() const
Definition: Ptexture.h:313
Ptex::mdt_int32
Signed 32-bit integer.
Definition: Ptexture.h:111
PtexWriter::writeFace
virtual bool writeFace(int faceid, const Ptex::FaceInfo &info, const void *data, int stride=0)=0
Write texture data for a face.
Ptex::Res::val
const uint16_t & val() const
Resolution as a single 16-bit integer value.
Definition: Ptexture.h:187
PtexFilter::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
PtexInputHandler::lastError
virtual const char * lastError()=0
Return the last error message encountered.
PtexInputHandler::Handle
void * Handle
Definition: Ptexture.h:590
Ptex::FaceInfo::flag_hasedits
Definition: Ptexture.h:290
PtexFilter::f_mitchell
Mitchell (equivalent to bi-cubic w/ sharpness=2/3)
Definition: Ptexture.h:876
Ptex::MeshType
MeshType
Type of base mesh for which the textures are defined.
Definition: Ptexture.h:77
PtexFilter::f_point
Point-sampled (no filtering)
Definition: Ptexture.h:869
Ptex::FaceInfo::adjedge
EdgeId adjedge(int eid) const
Access an adjacent edge id. The eid value must be 0..3.
Definition: Ptexture.h:264
MetaDataType
MetaDataType
Type of meta data entry.
Definition: Ptexture.h:220
PtexTexture::~PtexTexture
virtual ~PtexTexture()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:442
Ptex::String::String
String(const String &str)
Definition: Ptexture.h:307
PtexFilter::Options::filter
FilterType filter
Filter type.
Definition: Ptexture.h:882
Ptex::FaceInfo::FaceInfo
FaceInfo(Res res_, int adjfaces_[4], int adjedges_[4], bool isSubface_=false)
Constructor.
Definition: Ptexture.h:256
Ptex::Res::size
int size() const
Total size of specified texture in texels (u * v).
Definition: Ptexture.h:190
Ptex::FaceInfo::setadjfaces
void setadjfaces(int f0, int f1, int f2, int f3)
Set the adjfaces data.
Definition: Ptexture.h:282
Ptex::String::operator=
String & operator=(const std::string &str)
Definition: Ptexture.h:311
Ptex::m_black
texel beyond border are assumed to be black
Definition: Ptexture.h:93
PtexFilter::f_catmullrom
Catmull-Rom (equivalent to bi-cubic w/ sharpness=1)
Definition: Ptexture.h:875
PtexTexture::dataType
virtual Ptex::DataType dataType()=0
Type of data stored in file.
Ptex::Res::Res
Res()
Default constructor, sets res to 0 (1x1 texel).
Definition: Ptexture.h:166
PtexTexture::open
static PtexTexture * open(const char *path, Ptex::String &error, bool premultiply=0)
Open a ptex file for reading.
Definition: PtexReader.cpp:46
PtexTexture::path
virtual const char * path()=0
Path that file was opened with.
Ptex::Res::swapuv
void swapuv()
Swap the u and v resolution values in place.
Definition: Ptexture.h:205
PtexFilter::f_bspline
BSpline (equivalent to bi-cubic w/ sharpness=0)
Definition: Ptexture.h:874
PtexInputHandler::seek
virtual void seek(Handle handle, int64_t pos)=0
Seek to an absolute byte position in the input stream.
Ptex::Res::Res
Res(int8_t ulog2_, int8_t vlog2_)
Constructor.
Definition: Ptexture.h:169
PtexMetaData::~PtexMetaData
virtual ~PtexMetaData()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:340
PtexPtr
Smart-pointer for acquiring and releasing API objects.
Definition: Ptexture.h:955
PtexFaceData::isTiled
virtual bool isTiled()=0
True if this data block is tiled.
Ptex::MetaDataTypeName
static const char * MetaDataTypeName(MetaDataType mdt)
Look up name of given meta data type.
Definition: PtexUtils.cpp:81
Ptex::mdt_int16
Signed 16-bit integer.
Definition: Ptexture.h:110
PtexFaceData::isConstant
virtual bool isConstant()=0
True if this data block is constant.
Ptex::Res::ulog2
int8_t ulog2
log base 2 of u resolution, in texels
Definition: Ptexture.h:162
PTEXAPI
#define PTEXAPI
Definition: Ptexture.h:58
PtexFaceData::getPixel
virtual void getPixel(int u, int v, void *result)=0
Read a single texel from the data block.
Ptex::BorderModeName
static const char * BorderModeName(BorderMode m)
Look up name of given border mode.
Definition: PtexUtils.cpp:63
PtexFilter::Options::sharpness
float sharpness
Filter sharpness, 0..1 (for general bi-cubic filter only).
Definition: Ptexture.h:884
Ptex::Res::val
uint16_t & val()
Resolution as a single 16-bit integer value.
Definition: Ptexture.h:184
Ptex::e_right
Right edge, from UV (1,0) to (1,1)
Definition: Ptexture.h:101
PtexTexture
Interface for reading data from a ptex file.
Definition: Ptexture.h:439
PtexMetaData::numKeys
virtual int numKeys()=0
Query number of meta data entries stored in file.
PtexWriter::applyEdits
static bool applyEdits(const char *path, Ptex::String &error)
Apply edits to a file.
Definition: PtexWriter.cpp:242
Ptex::Res
Pixel resolution of a given texture.
Definition: Ptexture.h:161
PtexFilter::f_gaussian
Gaussian filter.
Definition: Ptexture.h:872
PtexCache::setSearchPath
virtual void setSearchPath(const char *path)=0
Set a search path for finding textures.
Ptex::FaceInfo::flag_subface
Definition: Ptexture.h:290
PtexTexture::uBorderMode
virtual Ptex::BorderMode uBorderMode()=0
Mode for filtering texture access beyond mesh border.
PtexTexture::getPixel
virtual void getPixel(int faceid, int u, int v, float *result, int firstchan, int nchannels)=0
Access a single texel from the highest resolution texture .
Ptex::FaceInfo::res
Res res
Resolution of face.
Definition: Ptexture.h:238
Ptex::FaceInfo::adjedges
uint8_t adjedges
Adjacent edges, 2 bits per edge.
Definition: Ptexture.h:239
PtexCache::getSearchPath
virtual const char * getSearchPath()=0
Query the search path.
Ptex::FaceInfo
Information about a face, as stored in the Ptex file header.
Definition: Ptexture.h:237
PtexWriter::close
virtual bool close(Ptex::String &error)=0
Close the file.
PtexFilter::Options
Choose filter options.
Definition: Ptexture.h:880
Ptex::FaceInfo::flag_nbconstant
Definition: Ptexture.h:290
Ptex::m_periodic
texel access wraps to other side of face
Definition: Ptexture.h:94
PtexWriter::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
Ptex::ConvertToFloat
static void ConvertToFloat(float *dst, const void *src, Ptex::DataType dt, int numChannels)
Convert a number of data values from the given data type to float.
Definition: PtexUtils.cpp:107
PtexTexture::getFaceInfo
virtual const Ptex::FaceInfo & getFaceInfo(int faceid)=0
Access resolution and adjacency information about a face.
Ptex::mdt_double
Double-precision (32-bit) floating point.
Definition: Ptexture.h:113
PtexFilter::FilterType
FilterType
Filter types.
Definition: Ptexture.h:868
Ptex::Res::Res
Res(uint16_t value)
Constructor from 16-bit integer.
Definition: Ptexture.h:172
Ptex::Res::operator==
bool operator==(const Res &r) const
Comparison operator.
Definition: Ptexture.h:193
Ptex::FaceInfo::flag_constant
Definition: Ptexture.h:290
Ptex::ConvertFromFloat
static void ConvertFromFloat(void *dst, const float *src, Ptex::DataType dt, int numChannels)
Convert a number of data values from float to the given data type.
Definition: PtexUtils.cpp:118
Ptex::m_clamp
texel access is clamped to border
Definition: Ptexture.h:92
Ptex::String::c_str
const char * c_str() const
Definition: Ptexture.h:312
PtexInt.h
Portable fixed-width integer types.
PtexInputHandler::close
virtual bool close(Handle handle)=0
Close a file.
PtexMetaData::getValue
virtual void getValue(const char *key, const char *&value)=0
Query the value of a given meta data entry.
PtexPtr::swap
void swap(PtexPtr &p)
Swap pointer values.
Definition: Ptexture.h:974
Ptex::EdgeIdName
static const char * EdgeIdName(EdgeId eid)
Look up name of given edge ID.
Definition: PtexUtils.cpp:72
Ptex::Res::clamp
void clamp(const Res &r)
Clamp the resolution value against the given value.
Definition: Ptexture.h:208
PtexCache::~PtexCache
virtual ~PtexCache()
Destructor not for public use. Use release() instead.
Definition: Ptexture.h:637
PtexFilter::Options::__structSize
int __structSize
(for internal use only)
Definition: Ptexture.h:881
PtexFilter::Options::lerp
bool lerp
Interpolate between mipmap levels.
Definition: Ptexture.h:883
PtexMetaData::release
virtual void release()=0
Release resources held by this pointer (pointer becomes invalid).
Ptex::EdgeId
EdgeId
Edge IDs used in adjacency data in the Ptex::FaceInfo struct.
Definition: Ptexture.h:99
PtexInputHandler
Custom handler interface for intercepting and redirecting Ptex input stream calls.
Definition: Ptexture.h:585
PtexFilter::f_bicubic
General bi-cubic filter (uses sharpness option)
Definition: Ptexture.h:873
PtexFilter
Interface for filtered sampling of ptex data files.
Definition: Ptexture.h:861
PtexFaceData::tileRes
virtual Ptex::Res tileRes()=0
Resolution of each tile in this data block.
PtexWriter::edit
static PtexWriter * edit(const char *path, bool incremental, Ptex::MeshType mt, Ptex::DataType dt, int nchannels, int alphachan, int nfaces, Ptex::String &error, bool genmipmaps=true)
Open an existing texture file for writing.
Definition: PtexWriter.cpp:186
PtexCache::purge
virtual void purge(PtexTexture *texture)=0
Remove a texture file from the cache.