HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IMG_DeepPixelWriter Class Reference

Thread-safe convenience class to make writing DSM pixels easy. More...

#include <IMG_DeepShadow.h>

Public Member Functions

 IMG_DeepPixelWriter (const IMG_DeepShadow &dsm)
 
 ~IMG_DeepPixelWriter ()
 
void writeRawSamples (bool enable)
 
bool open (int x, int y)
 Open a pixel for writing. More...
 
bool close ()
 
bool write (float z, const float *chdata, int chsize, int flags, int sampleid, float dz=0)
 
bool writeOrdered (float z, const float *chdata, int chsize, int flags, int sampleid, float dz=0)
 
bool writePixel (int pixel_x, int pixel_y, const PXL_DeepSampleListPtr &pixel)
 
const PXL_DeepCompressorPtrcompressor () const
 Access to the pixel compressor. More...
 

Detailed Description

Thread-safe convenience class to make writing DSM pixels easy.

This is a thread-safe convenience class to wrap around writing pixels which ensures that the pixel is closed properly.

Warning
Beware when declaring an IMG_DeepPixelReader in the same scope as an IMG_DeepShadow. Since the pixel reader keeps a reference to the file, the destruction order is important – though calling close() should avoid any problems.

The class should be used as follows for sequential samples:

for (x, y) in raster {
if (pixel.open(x, y)) {
for (int i = 0; i < depth; i++)
data = pixel.writeOrdered(z, data, vsize);
pixel.close();
}
}
Examples:
standalone/i3ddsmgen.C.

Definition at line 129 of file IMG_DeepShadow.h.

Constructor & Destructor Documentation

IMG_DeepPixelWriter::IMG_DeepPixelWriter ( const IMG_DeepShadow dsm)
IMG_DeepPixelWriter::~IMG_DeepPixelWriter ( )

Member Function Documentation

bool IMG_DeepPixelWriter::close ( )

Close the pixel. This is called automatically on destruction. However, if an IMG_DeepPixelWriter and IMG_DeepShadow are created in the same scope, the IMG_DeepPixelReader may hold onto references (and cause crashing errors). Calling close() manually is a safe thing to do.

Examples:
standalone/i3ddsmgen.C.
const PXL_DeepCompressorPtr& IMG_DeepPixelWriter::compressor ( ) const
inline

Access to the pixel compressor.

Definition at line 209 of file IMG_DeepShadow.h.

bool IMG_DeepPixelWriter::open ( int  x,
int  y 
)

Open a pixel for writing.

Examples:
standalone/i3ddsmgen.C.
bool IMG_DeepPixelWriter::write ( float  z,
const float *  chdata,
int  chsize,
int  flags,
int  sampleid,
float  dz = 0 
)

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.

The flags parameter is used to pass information to the PXL_DeepSampleList interface. Possible values are:

  • 0x00: No special meaning
  • 0x01: Sample represents a volume
  • 0x02: Sample is a matte surface These values are found in the PXL_DeepSampleList::SampleFlag enum.

The sampleid parameter specifies which pixel sample is associated with these values (see sxres and syres on the create() method).

The z value represents the "z-front" value for the depth sample. For hard surfaces dz should be 0. For volumes dz should be set to the extent of the volume sample so that the "z-back" data can be set appropriately.

bool IMG_DeepPixelWriter::writeOrdered ( float  z,
const float *  chdata,
int  chsize,
int  flags,
int  sampleid,
float  dz = 0 
)
inline

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

Examples:
standalone/i3ddsmgen.C.

Definition at line 190 of file IMG_DeepShadow.h.

bool IMG_DeepPixelWriter::writePixel ( int  pixel_x,
int  pixel_y,
const PXL_DeepSampleListPtr pixel 
)

Alternatively, you can do something like:

pixel.startPixel(x, y);
for (rec : records) pixel.store(rec);
write(pixel.closePixel(writer.compressor()));
void IMG_DeepPixelWriter::writeRawSamples ( bool  enable)

Ignore the desired sample compositing state in IMG_DeepShadow. The default is to assume the incoming samples are pre-composited. Writing raw samples will ignore compression levels, since the compressors assume pre-composited samples.


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