IMG_DeepShadow Class Reference

Class to read or write deep shadow/camera images. More...

#include <IMG_DeepShadow.h>

List of all members.

Public Member Functions

 IMG_DeepShadow ()
virtual ~IMG_DeepShadow ()
void setOption (const char *option, const char *value)
void setOptions (const UT_Options &options)
void printArgs (UT_WorkBuffer &wbuf)
 Print the current values of the file options into the work buffer.
const char * getDescription ()
bool addExtraChannel (const IMG_DeepShadowChannel &def, const UT_Options *options=0)
bool open (const char *name, int xres, int yres)
bool pixelStart (int x, int y)
bool pixelWrite (float z, const float *data, int vsize)
bool pixelWriteOrdered (float z, const float *data, int vsize)
bool pixelClose ()
 Close a pixel and flush the pixel's data to file.
bool close ()
 Close the deep shadow map and write it to disk.
UT_OptionsgetTBFOptions ()
bool open (const char *name)
 Open a deep shadow map for reading.
void resolution (int &xres, int &yres)
 Get the resolution of the deep shadow map.
int getChannelCount () const
 Get the number of channels in the DSM.
const IMG_DeepShadowChannelgetChannel (int i) const
 Get a channel definition.
float SYS_DEPRECATED * pixelRead (int x, int y, float &z, int &vsize)
IMG_DepthInterp depthInterp ()

Friends

class IMG_DeepPixelReader
class img_DeepShadow


Detailed Description

Class to read or write deep shadow/camera images.

This class provides a creation interface for deep shadow maps. The class can be used as follows:

     setOption(...);
     setOption(...);
     ...
     open(fname, xres, yres);
     foreach pixel loop
             pixelStart(pixel);
             foreach record
                     pixelWrite(record);
             end loop
             pixelClose()
     end loop
     close();

To read from an existing deep shadow map, the class can be used as follows:

     IMG_DeepShadow          dsm;
     IMG_DeepPixelReader     pixel;
     dsm.open(fname);
     foreach (x,y) in raster:
             pixel.open(x, y)
             for (i = 0; i < pixel.getDepth(); i++)
                     pixel.getData(chp, i);
     close();

See also:
Examples:

standalone/dsmprint.C, and standalone/i3ddsmgen.C.

Definition at line 209 of file IMG_DeepShadow.h.


Constructor & Destructor Documentation

IMG_DeepShadow::IMG_DeepShadow (  ) 

virtual IMG_DeepShadow::~IMG_DeepShadow (  )  [virtual]


Member Function Documentation

bool IMG_DeepShadow::addExtraChannel ( const IMG_DeepShadowChannel def,
const UT_Options options = 0 
)

Add an extra channel to be stored along with Of and Pz. Any number of channels may be added (though the file size will increase accordingly).

  • The name must be unique among (and not Of or Pz)
  • The float_offset is the offset into the "data" in the pixelWrite() method. Note that the opacity must occupy the first 3 floats of the data array. So, the float_offset must be at least 3.
  • The tuple_size is the number of elements in the channel Currently, this must be 1, 3 or 4.
  • The storage specifies the storage type (and uses the same tokens as the "ofstorage" option (i.e. int8, int16, int32, int64, uint8, uint16, uint32, uint64, real16, real32 or real64. The extra channels must be added before open() is called.

bool IMG_DeepShadow::close (  ) 

Close the deep shadow map and write it to disk.

Examples:
standalone/i3ddsmgen.C.

IMG_DepthInterp IMG_DeepShadow::depthInterp (  ) 

const IMG_DeepShadowChannel* IMG_DeepShadow::getChannel ( int  i  )  const

Get a channel definition.

Examples:
standalone/dsmprint.C.

int IMG_DeepShadow::getChannelCount (  )  const

Get the number of channels in the DSM.

Examples:
standalone/dsmprint.C.

const char* IMG_DeepShadow::getDescription (  ) 

Get a description of the available options that can be provided in setOption()

UT_Options* IMG_DeepShadow::getTBFOptions (  ) 

Get UT_Option structure from TBF. These options are stored with the file and may be queried in VEX using teximport().

Examples:
standalone/dsmprint.C.

bool IMG_DeepShadow::open ( const char *  name  ) 

Open a deep shadow map for reading.

bool IMG_DeepShadow::open ( const char *  name,
int  xres,
int  yres 
)

Open a deep shadow map for writing. This method will return false if there were errors opening the texture.

Examples:
standalone/dsmprint.C, and standalone/i3ddsmgen.C.

bool IMG_DeepShadow::pixelClose (  ) 

Close a pixel and flush the pixel's data to file.

Examples:
standalone/i3ddsmgen.C.

float SYS_DEPRECATED* IMG_DeepShadow::pixelRead ( int  x,
int  y,
float &  z,
int &  vsize 
)

Get the raw data values for a pixel, in the order that they appear in the file. This method should be called repeatedly for each pixel until a 0 is returned, indicating that all records have been read for that pixel. Reading pixels in a regular order will be more efficient than reading them in a random order.

Warning:
You should copy the data out of the returned pointer before proceeding. Do NOT refer to this pointer after reading more data from the shadow map. Because of this, this method is not thread-safe.
Deprecated:
In favour of IMG_DeepPixelReader

bool IMG_DeepShadow::pixelStart ( int  x,
int  y 
)

Start writing data to a pixel. This method must be called exactly once for each pixel. Starting pixels in a regular order will be more efficient than writing them in a random order, but is not required.

Examples:
standalone/i3ddsmgen.C.

bool IMG_DeepShadow::pixelWrite ( float  z,
const float *  data,
int  vsize 
)

Write data to the currently open pixel. This method inserts an unordered data record with the given z-value and data into the current pixel. vsize is the number of floats that are contained in the data array.

The first 3 floats of the data array must be the opacity (RGB). Any extra channel data follows this according to the float_offset associated with the channel. This data may be quantized to a single float depending on the options.

If vsize doesn't contain a full record, then this method will fail. vsize must be greater or equal to 3 (depending on extra channels)

Currently, mantra will always interpret the data as a rgb opacity triple.

Examples:
standalone/i3ddsmgen.C.

bool IMG_DeepShadow::pixelWriteOrdered ( float  z,
const float *  data,
int  vsize 
)

Perform the same operation as pixelWrite() except assume that data is pre-sorted by increasing z-value. This method will perform slightly better than pixelWrite() as data does not need to be sorted.

void IMG_DeepShadow::printArgs ( UT_WorkBuffer wbuf  ) 

Print the current values of the file options into the work buffer.

void IMG_DeepShadow::resolution ( int &  xres,
int &  yres 
)

Get the resolution of the deep shadow map.

Examples:
standalone/dsmprint.C.

void IMG_DeepShadow::setOption ( const char *  option,
const char *  value 
)

Set a file creation option. Options must be set before the file is opened with open() below.

Currently (and this list may be out of date), the options are:

  • "ofstorage" = one of { "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "real16", "real32", "real64" }
  • "pzstorage" = one of { "int8" ... "real64" }
  • "ofsize" = one of { "1", "3" }
  • "compression = a value between "0" and "9" (lossyness)
  • "zbias" = minimum delta between z-values (float value)
  • "depth_mode" = one of { "nearest", "midpoint", "farthest" }
  • "depth_interp" = one of { "discrete", "continuous" }
  • "compositing" = "0" will turn off pre-compositing of the z-records This is recommended when dealing with deep camera maps (i.e. if there are extra channels)
Examples:
standalone/i3ddsmgen.C.

void IMG_DeepShadow::setOptions ( const UT_Options options  ) 

Set options based on the "texture:*" options defined in the UT_Options. The UT_Options will be checked for options:

  • texture:ofstorage
  • texture:pzstorage
  • texture:ofsize
  • etc.


Friends And Related Function Documentation

friend class IMG_DeepPixelReader [friend]

Definition at line 334 of file IMG_DeepShadow.h.

friend class img_DeepShadow [friend]

Definition at line 351 of file IMG_DeepShadow.h.


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

Generated on Mon Jan 28 00:29:41 2013 for HDK by  doxygen 1.5.9