HDK
|
#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 DeepData & | operator= (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) |
void * | data_ptr (int64_t pixel, int channel, int sample) |
const void * | data_ptr (int64_t pixel, int channel, int sample) const |
cspan< TypeDesc > | all_channeltypes () const |
cspan< unsigned int > | all_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... | |
A DeepData
holds the contents of an image of ``deep'' pixels (multiple depth samples per pixel).
Definition at line 24 of file deepdata.h.
DeepData::DeepData | ( | ) |
Construct an empty DeepData.
DeepData::DeepData | ( | const DeepData & | src | ) |
Copy constructor.
Copy constructor with change of channel types.
DeepData::DeepData | ( | DeepData && | src | ) |
Move constructor.
DeepData::~DeepData | ( | ) |
int DeepData::A_channel | ( | ) | const |
int DeepData::AB_channel | ( | ) | const |
int DeepData::AG_channel | ( | ) | const |
cspan<char> DeepData::all_data | ( | ) | 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
.
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.
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.
Retrieve the value of the given pixel, channel, and sample index, cast to a float
.
Retrieve the value of the given pixel, channel, and sample index, cast to a uint32
.
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.
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.
bool DeepData::initialized | ( | ) | const |
Is the DeepData initialized?
Insert n
samples of the specified pixel, betinning at the sample position index. After insertion, the new samples will have uninitialized values.
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.
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.
Set the number of samples for all pixels. The samples.size() is required to match pixels().
Set the capacity of samples for the given pixel. This must be called after init().
Set the value of the given pixel, channel, and sample index, for floating-point channels.
Set the value of the given pixel, channel, and sample index, for integer channels.
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 |