PtexWriter Class Referenceabstract

Interface for writing data to a ptex file. More...

`#include <Ptexture.h>`

Inheritance diagram for PtexWriter:

## Public Member Functions

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

## Static Public Member Functions

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.

## Protected Member Functions

virtual | ~PtexWriter ()
| Destructor not for public use. Use release() instead.

## Detailed Description

Interface for writing data to a ptex file.

Note: if an alpha channel is specified, then the textures being written to the file are expected to have unmultiplied-alpha data. Generated mipmaps will be premultiplied by the Ptex library. On read, PtexTexture will (if requested) premultiply all textures by alpha when getData is called; by default only reductions are premultiplied. If the source textures are already premultiplied, then alphachan can be set to -1 and the library will just leave all the data as-is. The only reason to store unmultiplied-alpha textures in the file is to preserve the original texture data for later editing.

Definition at line 810 of file Ptexture.h.

## Constructor & Destructor Documentation

## ~PtexWriter()

virtual PtexWriter::~PtexWriter | ( |  | ) |

inline protected virtual

Destructor not for public use. Use release() instead.

Definition at line 813 of file Ptexture.h.

## Member Function Documentation

## applyEdits()

bool PtexWriter::applyEdits | ( | const char * | path,
|  | Ptex::String & | error
| ) |  |

static

Apply edits to a file.

If a file has pending edits, the edits will be applied and the file will be regenerated with no edits. This is equivalent to calling edit() with incremental set to false. The advantage is that the file attributes such as mesh type, data type, etc., don't need to be known in advance.

Definition at line 242 of file PtexWriter.cpp.

References PtexTexture::alphaChannel(), PtexTexture::dataType(), PtexTexture::hasEdits(), PtexTexture::hasMipMaps(), PtexTexture::meshType(), PtexTexture::numChannels(), PtexTexture::numFaces(), and PtexTexture::open().

## close()

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

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

Implemented in PtexWriterBase, PtexMainWriter, and PtexIncrWriter.

## edit()

PtexWriter * 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`
| ) |  |

static

Open an existing texture file for writing.

If the incremental param is specified as true, then data values written to the file are appended to the file as "edit blocks". This is the fastest way to write data to the file, but edit blocks are slower to read back, and they have no mipmaps so filtering can be inefficient.

If incremental is false, then the edits are applied to the file and the entire file is regenerated on close as if it were written all at once with open().

If the file doesn't exist it will be created and written as if open() were used. If the file exists, the mesh type, data type, number of channels, alpha channel, and number of faces must agree with those stored in the file.

Definition at line 186 of file PtexWriter.cpp.

References PtexTexture::alphaChannel(), Ptex::String::c_str(), PtexTexture::dataType(), PtexTexture::meshType(), PtexTexture::numChannels(), PtexTexture::numFaces(), PtexWriterBase::ok(), PtexTexture::open(), and PtexWriterBase::release().

## open()

PtexWriter * PtexWriter::open | ( | const char * | path,
|  | Ptex::MeshType | mt,
|  | Ptex::DataType | dt,
|  | int | nchannels,
|  | int | alphachan,
|  | int | nfaces,
|  | Ptex::String & | error,
|  | bool | genmipmaps = `true`
| ) |  |

static

Open a new texture file for writing.

Parameters

  path | Path to file.
  mt | Type of mesh for which the textures are defined.
  dt | Type of data stored within file.
  nchannels | Number of data channels.
  alphachan | Index of alpha channel, [0..nchannels-1] or -1 if no alpha channel is present.
  nfaces | Number of faces in mesh.
  error | String containing error message if open failed.
  genmipmaps | Specify true if mipmaps should be generated.

Definition at line 167 of file PtexWriter.cpp.

References PtexWriterBase::ok(), and PtexWriterBase::release().

## release()

virtual void PtexWriter::release | ( |  | ) |

pure virtual

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

Implemented in PtexWriterBase.

## setBorderModes()

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

pure virtual

Set border modes.

Implemented in PtexWriterBase.

## setEdgeFilterMode()

virtual void PtexWriter::setEdgeFilterMode | ( | Ptex::EdgeFilterMode | edgeFilterMode | ) |

pure virtual

Set edge filter mode.

Implemented in PtexWriterBase.

## writeConstantFace()

virtual bool PtexWriter::writeConstantFace | ( | int | faceid,
|  | const Ptex::FaceInfo & | info,
|  | const void * | data
| ) |  |

pure virtual

Write constant texture data for a face.

The data is written as a single constant texel value. Note: the resolution specified in the info param may indicate a resolution greater than 1x1 and the value will be preserved when reading. This is useful to indicate a texture's logical resolution even when the data is constant.

## writeFace()

virtual bool PtexWriter::writeFace | ( | int | faceid,
|  | const Ptex::FaceInfo & | info,
|  | const void * | data,
|  | int | stride = `0`
| ) |  |

pure virtual

Write texture data for a face.

The data is assumed to be channel-interleaved per texel and stored in v-major order.

Parameters

  faceid | Face index [0..nfaces-1].
  info | Face resolution and adjacency information.
  data | Texel data.
  stride | Distance between rows, in bytes (if zero, data is assumed packed).

If an error is encountered while writing, false is returned and an error message can be retrieved when close is called.

## writeMeta() [1/7]

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

pure virtual

Write a string as meta data.

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

Implemented in PtexWriterBase.

## writeMeta() [2/7]

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

pure virtual

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

The key must be a null-terminated string.

Implemented in PtexWriterBase.

## writeMeta() [3/7]

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

pure virtual

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

The key must be a null-terminated string.

Implemented in PtexWriterBase.

## writeMeta() [4/7]

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

pure virtual

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

The key must be a null-terminated string.

Implemented in PtexWriterBase.

## writeMeta() [5/7]

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

pure virtual

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

The key must be a null-terminated string.

Implemented in PtexWriterBase.

## writeMeta() [6/7]

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

pure virtual

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

The key must be a null-terminated string.

Implemented in PtexWriterBase.

## writeMeta() [7/7]

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

pure virtual

Copy meta data from an existing meta data block.

Implemented in PtexWriterBase.

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

- Ptexture.h
- PtexWriter.cpp