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

#include <deepdata.h>

Public Member Functions

 DeepData ()
 Construct an empty DeepData. More...
 
 DeepData (const ImageSpec &spec)
 Construct and init from an ImageSpec. More...
 
 DeepData (const DeepData &src)
 Copy constructor. More...
 
 DeepData (const DeepData &src, cspan< TypeDesc > channeltypes)
 Copy constructor with change of channel types. More...
 
 DeepData (DeepData &&src)
 Move constructor. More...
 
 ~DeepData ()
 
const DeepDataoperator= (const DeepData &d)
 Copy assignment. More...
 
void clear ()
 Reset the DeepData to be equivalent to its empty initial state. More...
 
void free ()
 
void init (int64_t npix, int nchan, cspan< TypeDesc > channeltypes, cspan< std::string > channelnames)
 
void init (const ImageSpec &spec)
 
bool initialized () const
 Is the DeepData initialized? More...
 
bool allocated () const
 
int64_t pixels () const
 Retrieve the total number of pixels. More...
 
int channels () const
 Retrieve the number of channels. More...
 
int Z_channel () const
 
int Zback_channel () const
 
int A_channel () const
 
int AR_channel () const
 
int AG_channel () const
 
int AB_channel () const
 
string_view channelname (int c) const
 Return the name of channel c. More...
 
TypeDesc channeltype (int c) const
 Retrieve the data type of channel c. More...
 
size_t channelsize (int c) const
 Return the size (in bytes) of one sample datum of channel c. More...
 
size_t samplesize () const
 Return the size (in bytes) for all channels of one sample. More...
 
bool same_channeltypes (const DeepData &other) const
 Does this DeepData have the same channel types as other? More...
 
int samples (int64_t pixel) const
 Retrieve the number of samples for the given pixel index. More...
 
void set_samples (int64_t pixel, int samps)
 
void set_all_samples (cspan< unsigned int > samples)
 
void set_capacity (int64_t pixel, int samps)
 
int capacity (int64_t pixel) const
 
void insert_samples (int64_t pixel, int samplepos, int n=1)
 
void erase_samples (int64_t pixel, int samplepos, int n=1)
 
float deep_value (int64_t pixel, int channel, int sample) const
 
uint32_t deep_value_uint (int64_t pixel, int channel, int sample) const
 
void set_deep_value (int64_t pixel, int channel, int sample, float value)
 
void set_deep_value (int64_t pixel, int channel, int sample, uint32_t value)
 
voiddata_ptr (int64_t pixel, int channel, int sample)
 
const voiddata_ptr (int64_t pixel, int channel, int sample) const
 
cspan< TypeDescall_channeltypes () const
 
cspan< unsigned intall_samples () const
 
cspan< char > all_data () const
 
void get_pointers (std::vector< void * > &pointers) const
 
bool copy_deep_sample (int64_t pixel, int sample, const DeepData &src, int64_t srcpixel, int srcsample)
 
bool copy_deep_pixel (int64_t pixel, const DeepData &src, int64_t srcpixel)
 
bool split (int64_t pixel, float depth)
 
void sort (int64_t pixel)
 Sort the samples of the pixel by their Z depth. More...
 
void merge_overlaps (int64_t pixel)
 
void merge_deep_pixels (int64_t pixel, const DeepData &src, int srcpixel)
 
float opaque_z (int64_t pixel) const
 Return the z depth at which the pixel reaches full opacity. More...
 
void occlusion_cull (int64_t pixel)
 Remove any samples hidden behind opaque samples. More...
 

Detailed Description

A DeepData holds the contents of an image of ``deep'' pixels (multiple depth samples per pixel).

Definition at line 24 of file deepdata.h.

Constructor & Destructor Documentation

DeepData::DeepData ( )

Construct an empty DeepData.

DeepData::DeepData ( const ImageSpec spec)

Construct and init from an ImageSpec.

DeepData::DeepData ( const DeepData src)

Copy constructor.

DeepData::DeepData ( const DeepData src,
cspan< TypeDesc channeltypes 
)

Copy constructor with change of channel types.

DeepData::DeepData ( DeepData &&  src)

Move constructor.

DeepData::~DeepData ( )

Member Function Documentation

int DeepData::A_channel ( ) const
int DeepData::AB_channel ( ) const
int DeepData::AG_channel ( ) const
cspan<TypeDesc> DeepData::all_channeltypes ( ) const
cspan<char> DeepData::all_data ( ) const
cspan<unsigned int> DeepData::all_samples ( ) const
bool DeepData::allocated ( ) const

Has the DeepData fully allocated? If no, it is still very inexpensive to call set_capacity().

int DeepData::AR_channel ( ) const
int DeepData::capacity ( int64_t  pixel) const

Retrieve the capacity (number of allocated samples) for the given pixel index.

string_view DeepData::channelname ( int  c) const

Return the name of channel c.

int DeepData::channels ( ) const

Retrieve the number of channels.

size_t DeepData::channelsize ( int  c) const

Return the size (in bytes) of one sample datum of channel c.

TypeDesc DeepData::channeltype ( int  c) const

Retrieve the data type of channel c.

void DeepData::clear ( )

Reset the DeepData to be equivalent to its empty initial state.

bool DeepData::copy_deep_pixel ( int64_t  pixel,
const DeepData src,
int64_t  srcpixel 
)

Copy an entire deep pixel from src to this DeepData, completely replacing any pixel data for that pixel. They must have the same channel layout. Return true if ok, false if the operation could not be performed.

bool DeepData::copy_deep_sample ( int64_t  pixel,
int  sample,
const DeepData src,
int64_t  srcpixel,
int  srcsample 
)

Copy a deep sample from src to this DeepData. They must have the same channel layout. Return true if ok, false if the operation could not be performed.

void* DeepData::data_ptr ( int64_t  pixel,
int  channel,
int  sample 
)

Retrieve the pointer to a given pixel/channel/sample, or NULL if there are no samples for that pixel. Use with care, and note that calls to insert_samples and erase_samples can invalidate pointers returned by prior calls to data_ptr.

const void* DeepData::data_ptr ( int64_t  pixel,
int  channel,
int  sample 
) const
float DeepData::deep_value ( int64_t  pixel,
int  channel,
int  sample 
) const

Retrieve the value of the given pixel, channel, and sample index, cast to a float.

uint32_t DeepData::deep_value_uint ( int64_t  pixel,
int  channel,
int  sample 
) const

Retrieve the value of the given pixel, channel, and sample index, cast to a uint32.

void DeepData::erase_samples ( int64_t  pixel,
int  samplepos,
int  n = 1 
)

Erase n samples of the specified pixel, betinning at the sample position index.

void DeepData::free ( )

In addition to performing the tasks of clear(), also ensure that all allocated memory has been truly freed.

void DeepData::get_pointers ( std::vector< void * > &  pointers) const

Fill in the vector with pointers to the start of the first channel for each pixel.

void DeepData::init ( int64_t  npix,
int  nchan,
cspan< TypeDesc channeltypes,
cspan< std::string channelnames 
)

Initialize the DeepData with the specified number of pixels, channels, channel types, and channel names, and allocate memory for all the data.

void DeepData::init ( const ImageSpec spec)

Initialize the DeepData based on the ImageSpec's total number of pixels, number and types of channels. At this stage, all pixels are assumed to have 0 samples, and no sample data is allocated.

bool DeepData::initialized ( ) const

Is the DeepData initialized?

void DeepData::insert_samples ( int64_t  pixel,
int  samplepos,
int  n = 1 
)

Insert n samples of the specified pixel, betinning at the sample position index. After insertion, the new samples will have uninitialized values.

void DeepData::merge_deep_pixels ( int64_t  pixel,
const DeepData src,
int  srcpixel 
)

Merge the samples of src's pixel into this DeepData's pixel. Return true if ok, false if the operation could not be performed.

void DeepData::merge_overlaps ( int64_t  pixel)

Merge any adjacent samples in the pixel that exactly overlap in z range. This is only useful if the pixel has previously been split at all sample starts and ends, and sorted by Z. Note that this may change the number of samples in the pixel.

void DeepData::occlusion_cull ( int64_t  pixel)

Remove any samples hidden behind opaque samples.

float DeepData::opaque_z ( int64_t  pixel) const

Return the z depth at which the pixel reaches full opacity.

const DeepData& DeepData::operator= ( const DeepData d)

Copy assignment.

int64_t DeepData::pixels ( ) const

Retrieve the total number of pixels.

bool DeepData::same_channeltypes ( const DeepData other) const

Does this DeepData have the same channel types as other?

int DeepData::samples ( int64_t  pixel) const

Retrieve the number of samples for the given pixel index.

size_t DeepData::samplesize ( ) const

Return the size (in bytes) for all channels of one sample.

void DeepData::set_all_samples ( cspan< unsigned int samples)

Set the number of samples for all pixels. The samples.size() is required to match pixels().

void DeepData::set_capacity ( int64_t  pixel,
int  samps 
)

Set the capacity of samples for the given pixel. This must be called after init().

void DeepData::set_deep_value ( int64_t  pixel,
int  channel,
int  sample,
float  value 
)

Set the value of the given pixel, channel, and sample index, for floating-point channels.

void DeepData::set_deep_value ( int64_t  pixel,
int  channel,
int  sample,
uint32_t  value 
)

Set the value of the given pixel, channel, and sample index, for integer channels.

void DeepData::set_samples ( int64_t  pixel,
int  samps 
)

Set the number of samples for the given pixel. This must be called after init().

void DeepData::sort ( int64_t  pixel)

Sort the samples of the pixel by their Z depth.

bool DeepData::split ( int64_t  pixel,
float  depth 
)

Split all samples of that pixel at the given depth zsplit. Samples that span z (i.e. z < zsplit < zback) will be split into two samples with depth ranges [z,zsplit] and [zsplit,zback] with appropriate changes to their color and alpha values. Samples not spanning zsplit will remain intact. This operation will have no effect if there are not Z and Zback channels present. Return true if any splits occurred, false if the pixel was not modified.

int DeepData::Z_channel ( ) const
int DeepData::Zback_channel ( ) const

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