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

#include <PtexWriter.h>

Inheritance diagram for PtexWriterBase:
PtexWriter PtexIncrWriter PtexMainWriter

Classes

struct  MetaEntry
 

Public Member Functions

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

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. More...
 

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 PtexWriteropen (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. More...
 
static PtexWriteredit (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. More...
 
static bool applyEdits (const char *path, Ptex::String &error)
 Apply edits to a file. More...
 

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

◆ ~PtexWriterBase()

PtexWriterBase::~PtexWriterBase ( )
protectedvirtual

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 
)
protectedvirtual

◆ calcTileRes()

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

Definition at line 570 of file PtexWriter.cpp.

References _pixelSize, PtexUtils::floor_log2(), PtexUtils::min(), 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 PtexIncrWriter, and PtexMainWriter.

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

◆ datatype()

DataType PtexWriterBase::datatype ( ) const
inlineprotected

◆ finish()

virtual void PtexWriterBase::finish ( )
protectedpure virtual

Implemented in PtexIncrWriter, and PtexMainWriter.

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 
)
inlinevirtual

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)
inlinevirtual

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)
inlineprotected

◆ storeFaceInfo()

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

◆ writeBlank()

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

◆ writeBlock()

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

◆ 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

◆ writeFaceData()

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

◆ 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(), and Ptex::mdt_string.

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(), and Ptex::mdt_double.

◆ 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(), and Ptex::mdt_float.

◆ 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(), and Ptex::mdt_int16.

◆ 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(), and Ptex::mdt_int32.

◆ 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(), and Ptex::mdt_int8.

◆ writeMeta() [7/7]

void PtexWriterBase::writeMeta ( PtexMetaData data)
virtual

◆ writeMetaDataBlock()

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

◆ writeReduction()

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

◆ writeZipBlock()

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

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

◆ _header

Header PtexWriterBase::_header
protected

◆ _metadata

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

◆ _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

◆ _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

◆ _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: