Ptex

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PtexWriterBase Class Referenceabstract

`#include <PtexWriter.h>`

Inheritance diagram for PtexWriterBase:

## Classes
struct | MetaEntry

## Public Member Functions
virtual void | setBorderModes (Ptex::BorderMode uBorderMode, Ptex::BorderMode vBorderMode)
| Set border modes.
virtual void | setEdgeFilterMode (Ptex::EdgeFilterMode edgeFilterMode)
| Set edge filter mode.
virtual void | writeMeta (const char *key, const char *value)
| Write a string as meta data.
virtual void | writeMeta (const char *key, const int8_t *value, int count)
| Write an array of signed 8-bit integers as meta data.
virtual void | writeMeta (const char *key, const int16_t *value, int count)
| Write an array of signed 16-bit integers as meta data.
virtual void | writeMeta (const char *key, const int32_t *value, int count)
| Write an array of signed 32-bit integers as meta data.
virtual void | writeMeta (const char *key, const float *value, int count)
| Write an array of signed 32-bit floats as meta data.
virtual void | writeMeta (const char *key, const double *value, int count)
| Write an array of signed 32-bit doubles as meta data.
virtual void | writeMeta (PtexMetaData *data)
| Copy meta data from an existing meta data block.
virtual bool | close (Ptex::String &error)
| Close the file.
virtual void | release ()
| Release resources held by this pointer (pointer becomes invalid).
bool | ok (Ptex::String &error)
void | getError (Ptex::String &error)
Public Member Functions inherited from PtexWriter
virtual bool | writeFace (int faceid, const Ptex::FaceInfo &info, const void *data, int stride=0)=0
| Write texture data for a face.
virtual bool | writeConstantFace (int faceid, const Ptex::FaceInfo &info, const void *data)=0
| Write constant texture data for a face.

## Protected Member Functions
DataType | datatype () const
virtual void | finish ()=0
| PtexWriterBase (const char *path, Ptex::MeshType mt, Ptex::DataType dt, int nchannels, int alphachan, int nfaces, bool compress)
virtual | ~PtexWriterBase ()
int | writeBlank (FILE *fp, int size)
int | writeBlock (FILE *fp, const void *data, int size)
int | writeZipBlock (FILE *fp, const void *data, int size, bool finish=true)
int | readBlock (FILE *fp, void *data, int size)
int | copyBlock (FILE *dst, FILE *src, FilePos pos, int size)
Res | calcTileRes (Res faceres)
virtual void | addMetaData (const char *key, MetaDataType t, const void *value, int size)
void | writeConstFaceBlock (FILE *fp, const void *data, FaceDataHeader &fdh)
void | writeFaceBlock (FILE *fp, const void *data, int stride, Res res, FaceDataHeader &fdh)
void | writeFaceData (FILE *fp, const void *data, int stride, Res res, FaceDataHeader &fdh)
void | writeReduction (FILE *fp, const void *data, int stride, Res res)
int | writeMetaDataBlock (FILE *fp, MetaEntry &val)
void | setError (const std::string &error)
bool | storeFaceInfo (int faceid, FaceInfo &dest, const FaceInfo &src, int flags=0)
Protected Member Functions inherited from PtexWriter
virtual | ~PtexWriter ()
| Destructor not for public use. Use release() instead.

## Protected Attributes
bool | _ok
std::string | _error
std::string | _path
std::string | _tilepath
FILE * | _tilefp
Header | _header
ExtHeader | _extheader
int | _pixelSize
std::vector< MetaEntry > | _metadata
std::map< std::string, int > | _metamap
z_stream_s | _zstream
PtexUtils::ReduceFn * | _reduceFn

## Additional Inherited Members
Static Public Member Functions inherited from PtexWriter
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.
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.
static bool | applyEdits (const char *path, Ptex::String &error)
| Apply edits to a file.

## Detailed Description

Definition at line 50 of file PtexWriter.h.

## Constructor & Destructor Documentation

## ◆ PtexWriterBase()

PtexWriterBase::PtexWriterBase | ( | const char * | path,
|  | Ptex::MeshType | mt,
|  | Ptex::DataType | dt,
|  | int | nchannels,
|  | int | alphachan,
|  | int | nfaces,
|  | bool | compress
| ) |  |
| protected

Definition at line 261 of file PtexWriter.cpp.

References _extheader, _header, _pixelSize, _reduceFn, _tilefp, _tilepath, _zstream, Header::alphachan, Header::datatype, Header::extheadersize, Header::magic, Magic, Header::meshtype, Header::minorversion, Header::nchannels, Header::nfaces, Header::nlevels, Header::pixelSize(), PtexFileMajorVersion, PtexFileMinorVersion, PtexUtils::reduce(), PtexUtils::reduceTri(), setError(), and Header::version.

## ◆ ~PtexWriterBase()

PtexWriterBase::~PtexWriterBase | ( |  | ) |
| protected virtual

Definition at line 310 of file PtexWriter.cpp.

References _zstream.

## Member Function Documentation

## ◆ addMetaData()

void PtexWriterBase::addMetaData | ( | const char * | key,
|  | MetaDataType | t,
|  | const void * | value,
|  | int | size
| ) |  |
| protected virtual

Reimplemented in PtexMainWriter.

Definition at line 453 of file PtexWriter.cpp.

References _metadata, _metamap, PtexWriterBase::MetaEntry::data, PtexWriterBase::MetaEntry::datatype, PtexWriterBase::MetaEntry::key, and setError().

Referenced by PtexMainWriter::addMetaData(), writeMeta(), writeMeta(), writeMeta(), writeMeta(), writeMeta(), and writeMeta().

## ◆ calcTileRes()

Ptex::Res PtexWriterBase::calcTileRes | ( | Res | faceres | ) |
| protected

Definition at line 570 of file PtexWriter.cpp.

References _pixelSize, PtexUtils::floor_log2(), PtexUtils::min(), Ptex::Res::size(), and TileSize.

Referenced by writeFaceData().

## ◆ close()

bool PtexWriterBase::close | ( | Ptex::String & | error | ) |
| virtual

Close the file.

This operation can take some time if mipmaps are being generated or if there are many edit blocks. If an error occurs while writing, false is returned and an error string is written into the error parameter.

Implements PtexWriter.

Reimplemented in PtexMainWriter, and PtexIncrWriter.

Definition at line 316 of file PtexWriter.cpp.

References _ok, _tilefp, _tilepath, finish(), and getError().

Referenced by PtexMainWriter::close(), PtexIncrWriter::close(), and release().

## ◆ copyBlock()

int PtexWriterBase::copyBlock | ( | FILE * | dst,
|  | FILE * | src,
|  | FilePos | pos,
|  | int | size
| ) |  |
| protected

Definition at line 551 of file PtexWriter.cpp.

References BlockSize, setError(), and writeBlock().

Referenced by PtexMainWriter::finish(), writeFaceData(), and PtexMainWriter::writeMetaData().

## ◆ datatype()

DataType PtexWriterBase::datatype | ( |  | ) | const
| inline protected

Definition at line 80 of file PtexWriter.h.

References _header, and Header::datatype.

Referenced by PtexIncrWriter::PtexIncrWriter(), PtexMainWriter::storeConstValue(), PtexMainWriter::writeFace(), PtexIncrWriter::writeFace(), writeFaceBlock(), PtexMainWriter::writeMetaData(), writeMetaDataBlock(), and writeReduction().

## ◆ finish()

virtual void PtexWriterBase::finish | ( |  | ) |
| protected pure virtual

Implemented in PtexMainWriter, and PtexIncrWriter.

Referenced by close().

## ◆ getError()

void PtexWriterBase::getError | ( | Ptex::String & | error | ) |
| inline

Definition at line 75 of file PtexWriter.h.

References _error, and _path.

Referenced by close(), and ok().

## ◆ ok()

bool PtexWriterBase::ok | ( | Ptex::String & | error | ) |
| inline

Definition at line 71 of file PtexWriter.h.

References _ok, and getError().

Referenced by PtexWriter::edit(), and PtexWriter::open().

## ◆ readBlock()

int PtexWriterBase::readBlock | ( | FILE * | fp,
|  | void * | data,
|  | int | size
| ) |  |
| protected

Definition at line 541 of file PtexWriter.cpp.

References setError().

Referenced by PtexMainWriter::generateReductions().

## ◆ release()

void PtexWriterBase::release | ( |  | ) |
| virtual

Release resources held by this pointer (pointer becomes invalid).

Implements PtexWriter.

Definition at line 301 of file PtexWriter.cpp.

References _tilefp, Ptex::String::c_str(), and close().

Referenced by PtexWriter::edit(), and PtexWriter::open().

## ◆ setBorderModes()

virtual void PtexWriterBase::setBorderModes | ( | Ptex::BorderMode | uBorderMode,
|  | Ptex::BorderMode | vBorderMode
| ) |  |
| inline virtual

Set border modes.

Implements PtexWriter.

Definition at line 52 of file PtexWriter.h.

References _extheader, ExtHeader::ubordermode, and ExtHeader::vbordermode.

Referenced by PtexMainWriter::PtexMainWriter().

## ◆ setEdgeFilterMode()

virtual void PtexWriterBase::setEdgeFilterMode | ( | Ptex::EdgeFilterMode | edgeFilterMode | ) |
| inline virtual

Set edge filter mode.

Implements PtexWriter.

Definition at line 57 of file PtexWriter.h.

References _extheader, and ExtHeader::edgefiltermode.

Referenced by PtexMainWriter::PtexMainWriter().

## ◆ setError()

void PtexWriterBase::setError | ( | const std::string & | error | ) |
| inline protected

Definition at line 110 of file PtexWriter.h.

References _error, and _ok.

Referenced by addMetaData(), copyBlock(), PtexMainWriter::finish(), PtexIncrWriter::PtexIncrWriter(), PtexMainWriter::PtexMainWriter(), PtexWriterBase(), readBlock(), storeFaceInfo(), writeBlock(), and writeZipBlock().

## ◆ storeFaceInfo()

bool PtexWriterBase::storeFaceInfo | ( | int | faceid,
|  | FaceInfo & | dest,
|  | const FaceInfo & | src,
|  | int | flags = `0`
| ) |  |
| protected

Definition at line 329 of file PtexWriter.cpp.

References _header, Header::meshtype, Header::nfaces, and setError().

Referenced by PtexMainWriter::writeConstantFace(), PtexIncrWriter::writeConstantFace(), PtexMainWriter::writeFace(), and PtexIncrWriter::writeFace().

## ◆ writeBlank()

int PtexWriterBase::writeBlank | ( | FILE * | fp,
|  | int | size
| ) |  |
| protected

Definition at line 487 of file PtexWriter.cpp.

References _ok, BlockSize, and writeBlock().

Referenced by PtexMainWriter::finish(), PtexIncrWriter::writeFace(), PtexMainWriter::writeMetaData(), and PtexIncrWriter::writeMetaDataEdit().

## ◆ writeBlock()

int PtexWriterBase::writeBlock | ( | FILE * | fp,
|  | const void * | data,
|  | int | size
| ) |  |
| protected

Definition at line 499 of file PtexWriter.cpp.

References _ok, and setError().

Referenced by copyBlock(), PtexMainWriter::finish(), writeBlank(), PtexIncrWriter::writeConstantFace(), writeConstFaceBlock(), PtexIncrWriter::writeFace(), writeFaceData(), PtexIncrWriter::writeMetaDataEdit(), writeReduction(), and writeZipBlock().

## ◆ writeConstFaceBlock()

void PtexWriterBase::writeConstFaceBlock | ( | FILE * | fp,
|  | const void * | data,
|  | FaceDataHeader & | fdh
| ) |  |
| protected

Definition at line 592 of file PtexWriter.cpp.

References _pixelSize, enc_constant, FaceDataHeader::set(), and writeBlock().

Referenced by writeFaceData().

## ◆ writeFaceBlock()

void PtexWriterBase::writeFaceBlock | ( | FILE * | fp,
|  | const void * | data,
|  | int | stride,
|  | Res | res,
|  | FaceDataHeader & | fdh
| ) |  |
| protected

Definition at line 602 of file PtexWriter.cpp.

References _header, _pixelSize, AllocaMax, datatype(), PtexUtils::deinterleave(), enc_diffzipped, enc_zipped, PtexUtils::encodeDifference(), Header::nchannels, FaceDataHeader::set(), and writeZipBlock().

Referenced by writeFaceData().

## ◆ writeFaceData()

void PtexWriterBase::writeFaceData | ( | FILE * | fp,
|  | const void * | data,
|  | int | stride,
|  | Res | res,
|  | FaceDataHeader & | fdh
| ) |  |
| protected

Definition at line 629 of file PtexWriter.cpp.

References _pixelSize, _tilefp, FaceDataHeader::blocksize(), calcTileRes(), copyBlock(), enc_tiled, PtexUtils::isConstant(), FaceDataHeader::set(), writeBlock(), writeConstFaceBlock(), writeFaceBlock(), and writeZipBlock().

Referenced by PtexMainWriter::generateReductions(), PtexMainWriter::writeFace(), and PtexIncrWriter::writeFace().

## ◆ writeMeta() [1/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const char * | string
| ) |  |
| virtual

Write a string as meta data.

Both the key and string params must be null-terminated strings.

Implements PtexWriter.

Definition at line 361 of file PtexWriter.cpp.

References addMetaData().

Referenced by PtexMainWriter::PtexMainWriter(), and writeMeta().

## ◆ writeMeta() [2/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const double * | value,
|  | int | count
| ) |  |
| virtual

Write an array of signed 32-bit doubles as meta data.

The key must be a null-terminated string.

Implements PtexWriter.

Definition at line 391 of file PtexWriter.cpp.

References addMetaData().

## ◆ writeMeta() [3/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const float * | value,
|  | int | count
| ) |  |
| virtual

Write an array of signed 32-bit floats as meta data.

The key must be a null-terminated string.

Implements PtexWriter.

Definition at line 385 of file PtexWriter.cpp.

References addMetaData().

## ◆ writeMeta() [4/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const int16_t * | value,
|  | int | count
| ) |  |
| virtual

Write an array of signed 16-bit integers as meta data.

The key must be a null-terminated string.

Implements PtexWriter.

Definition at line 373 of file PtexWriter.cpp.

References addMetaData().

## ◆ writeMeta() [5/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const int32_t * | value,
|  | int | count
| ) |  |
| virtual

Write an array of signed 32-bit integers as meta data.

The key must be a null-terminated string.

Implements PtexWriter.

Definition at line 379 of file PtexWriter.cpp.

References addMetaData().

## ◆ writeMeta() [6/7]

void PtexWriterBase::writeMeta | ( | const char * | key,
|  | const int8_t * | value,
|  | int | count
| ) |  |
| virtual

Write an array of signed 8-bit integers as meta data.

The key must be a null-terminated string.

Implements PtexWriter.

Definition at line 367 of file PtexWriter.cpp.

References addMetaData().

## ◆ writeMeta() [7/7]

void PtexWriterBase::writeMeta | ( | PtexMetaData * | data | ) |
| virtual

Copy meta data from an existing meta data block.

Implements PtexWriter.

Definition at line 397 of file PtexWriter.cpp.

References PtexMetaData::getKey(), PtexMetaData::getValue(), PtexMetaData::numKeys(), and writeMeta().

## ◆ writeMetaDataBlock()

int PtexWriterBase::writeMetaDataBlock | ( | FILE * | fp,
|  | MetaEntry & | val
| ) |  |
| protected

Definition at line 707 of file PtexWriter.cpp.

References PtexWriterBase::MetaEntry::data, datatype(), PtexWriterBase::MetaEntry::datatype, PtexWriterBase::MetaEntry::key, and writeZipBlock().

Referenced by PtexMainWriter::writeMetaData(), and PtexIncrWriter::writeMetaDataEdit().

## ◆ writeReduction()

void PtexWriterBase::writeReduction | ( | FILE * | fp,
|  | const void * | data,
|  | int | stride,
|  | Res | res
| ) |  |
| protected

Definition at line 690 of file PtexWriter.cpp.

References _header, _pixelSize, _reduceFn, AllocaMax, datatype(), Header::nchannels, Ptex::Res::size(), Ptex::Res::u(), and writeBlock().

Referenced by PtexMainWriter::generateReductions(), and PtexMainWriter::writeFace().

## ◆ writeZipBlock()

int PtexWriterBase::writeZipBlock | ( | FILE * | fp,
|  | const void * | data,
|  | int | size,
|  | bool | finish = `true`
| ) |  |
| protected

Definition at line 510 of file PtexWriter.cpp.

References _ok, _zstream, BlockSize, setError(), and writeBlock().

Referenced by PtexMainWriter::finish(), writeFaceBlock(), writeFaceData(), PtexMainWriter::writeMetaData(), writeMetaDataBlock(), and PtexIncrWriter::writeMetaDataEdit().

## Member Data Documentation

## ◆ _error

std::string PtexWriterBase::_error
| protected

Definition at line 114 of file PtexWriter.h.

Referenced by getError(), and setError().

## ◆ _extheader

ExtHeader PtexWriterBase::_extheader
| protected

Definition at line 119 of file PtexWriter.h.

Referenced by PtexMainWriter::finish(), PtexIncrWriter::finish(), PtexMainWriter::flagConstantNeighorhoods(), PtexIncrWriter::PtexIncrWriter(), PtexWriterBase(), setBorderModes(), setEdgeFilterMode(), and PtexMainWriter::writeMetaData().

## ◆ _header

Header PtexWriterBase::_header
| protected

Definition at line 118 of file PtexWriter.h.

Referenced by datatype(), PtexMainWriter::finish(), PtexIncrWriter::finish(), PtexMainWriter::flagConstantNeighorhoods(), PtexMainWriter::generateReductions(), PtexIncrWriter::PtexIncrWriter(), PtexWriterBase(), PtexMainWriter::storeConstValue(), storeFaceInfo(), PtexMainWriter::writeFace(), PtexIncrWriter::writeFace(), writeFaceBlock(), PtexMainWriter::writeMetaData(), and writeReduction().

## ◆ _metadata

std::vector<MetaEntry> PtexWriterBase::_metadata
| protected

Definition at line 121 of file PtexWriter.h.

Referenced by addMetaData(), PtexMainWriter::finish(), PtexIncrWriter::finish(), PtexMainWriter::writeMetaData(), and PtexIncrWriter::writeMetaDataEdit().

## ◆ _metamap

std::map<std::string,int> PtexWriterBase::_metamap
| protected

Definition at line 122 of file PtexWriter.h.

Referenced by addMetaData().

## ◆ _ok

bool PtexWriterBase::_ok
| protected

Definition at line 113 of file PtexWriter.h.

Referenced by close(), PtexMainWriter::generateReductions(), ok(), setError(), writeBlank(), writeBlock(), PtexMainWriter::writeConstantFace(), PtexMainWriter::writeFace(), and writeZipBlock().

## ◆ _path

std::string PtexWriterBase::_path
| protected

Definition at line 115 of file PtexWriter.h.

Referenced by PtexMainWriter::close(), and getError().

## ◆ _pixelSize

int PtexWriterBase::_pixelSize
| protected

Definition at line 120 of file PtexWriter.h.

Referenced by calcTileRes(), PtexMainWriter::finish(), PtexMainWriter::flagConstantNeighorhoods(), PtexMainWriter::generateReductions(), PtexMainWriter::PtexMainWriter(), PtexWriterBase(), PtexMainWriter::storeConstValue(), PtexMainWriter::writeConstantFace(), PtexIncrWriter::writeConstantFace(), writeConstFaceBlock(), PtexMainWriter::writeFace(), PtexIncrWriter::writeFace(), writeFaceBlock(), writeFaceData(), and writeReduction().

## ◆ _reduceFn

PtexUtils::ReduceFn* PtexWriterBase::_reduceFn
| protected

Definition at line 125 of file PtexWriter.h.

Referenced by PtexWriterBase(), and writeReduction().

## ◆ _tilefp

FILE* PtexWriterBase::_tilefp
| protected

Definition at line 117 of file PtexWriter.h.

Referenced by close(), PtexWriterBase(), release(), and writeFaceData().

## ◆ _tilepath

std::string PtexWriterBase::_tilepath
| protected

Definition at line 116 of file PtexWriter.h.

Referenced by close(), and PtexWriterBase().

## ◆ _zstream

z_stream_s PtexWriterBase::_zstream
| protected

Definition at line 123 of file PtexWriter.h.

Referenced by PtexWriterBase(), writeZipBlock(), and ~PtexWriterBase().

The documentation for this class was generated from the following files:

- PtexWriter.h
- PtexWriter.cpp