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

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

#include <IMG_DeepShadow.h>

Public Member Functions

 IMG_DeepPixelReader (const IMG_DeepShadow &dsm)
 
 ~IMG_DeepPixelReader ()
 
bool open (int x, int y)
 Open a pixel for reading. More...
 
void close ()
 
int getDepth () const
 Returns the number of z-records. More...
 
const float * getData (const IMG_DeepShadowChannel &chp, int depth_index)
 Return the data for the channel at the given depth index. More...
 
bool readPixel (int x, int y, PXL_DeepSampleList &pixel) const
 
void composite (const IMG_DeepShadowChannel &pz, const IMG_DeepShadowChannel &of, bool force=false)
 
void uncomposite (const IMG_DeepShadowChannel &pz, const IMG_DeepShadowChannel &of, bool force=false)
 

Detailed Description

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

This is a thread-safe convenience class to wrap around reading 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 (x, y) in raster {
if (pixel.open(x, y)) {
for (int i = 0; i < pixel.getDepth(); i++)
data = pixel.getData(chp, i);
}
}
Examples:
standalone/dsmprint.C.

Definition at line 60 of file IMG_DeepShadow.h.

Constructor & Destructor Documentation

IMG_DeepPixelReader::IMG_DeepPixelReader ( const IMG_DeepShadow dsm)
IMG_DeepPixelReader::~IMG_DeepPixelReader ( )

Member Function Documentation

void IMG_DeepPixelReader::close ( )

Close the pixel. This is called automatically on destruction. However, if an IMG_DeepPixelReader 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.

void IMG_DeepPixelReader::composite ( const IMG_DeepShadowChannel pz,
const IMG_DeepShadowChannel of,
bool  force = false 
)

After opening, you can call either of these methods to ensure that the data is in the correct form for your application. "composited" pixels will have the data accumulated over from front to back. "uncomposited" pixels will have the raw data for each z-record.

If the force flag is false, then the state of the file will be used to determine whether the deep records need to be processed or not.

These methods should be called after the pixel has been opened.

const float* IMG_DeepPixelReader::getData ( const IMG_DeepShadowChannel chp,
int  depth_index 
)

Return the data for the channel at the given depth index.

Examples:
standalone/dsmprint.C.
int IMG_DeepPixelReader::getDepth ( ) const

Returns the number of z-records.

Examples:
standalone/dsmprint.C.
bool IMG_DeepPixelReader::open ( int  x,
int  y 
)

Open a pixel for reading.

Examples:
standalone/dsmprint.C.
bool IMG_DeepPixelReader::readPixel ( int  x,
int  y,
PXL_DeepSampleList pixel 
) const

Alternately, just fill a PXL_DeepSampleList with the appropriate data. This manages zback, coverage, flags and other special deep channels.

void IMG_DeepPixelReader::uncomposite ( const IMG_DeepShadowChannel pz,
const IMG_DeepShadowChannel of,
bool  force = false 
)

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