|
cgv
|
Implementation of a color_scale with a continuous input domain that maps explicit domain values to color and opacity using piecewise constant, piecewise linear or piecewise smooth (b-splines) interpolation. More...
#include <transfer_function.h>
Public Types | |
| enum class | InterpolationMode { kStep , kLinear , kSmooth } |
| The interpolation modes supported by the transfer function. More... | |
| using | color_type = cgv::rgb |
| The used color type. | |
| using | opacity_type = float |
| The used opacity type. | |
| using | color_point_type = std::pair< float, color_type > |
| The used color control point type. | |
| using | opacity_point_type = std::pair< float, opacity_type > |
| The used opacity control point type. | |
Public Member Functions | |
| transfer_function () | |
| Construct using default arguments. | |
| transfer_function (std::initializer_list< color_point_type > colors) | |
| Construct from a sequence of color control points. | |
| transfer_function (std::initializer_list< color_point_type > colors, std::initializer_list< opacity_point_type > opacities) | |
| Construct from separate sequences of color and opacity control points. | |
| bool | is_opaque () const override |
| Return whether the color scale maps to opacity. | |
| bool | is_discrete () const override |
| See color_scale::is_discrete(). | |
| bool | empty () const |
| Check whether the transfer function is empty. | |
| void | set_color_points (const std::vector< color_point_type > &colors) |
| Set the color function to use the given control points. | |
| void | set_color_points_from_scheme (const cgv::media::continuous_color_scheme &scheme, size_t n) |
| Set the color function to use n uniformly sampled points from the given color scheme. | |
| void | set_opacity_points (const std::vector< opacity_point_type > &opacities) |
| Set the opacity function to use the given control points. | |
| void | add_color_point (float x, const color_type &color) |
| Add a color point at position x. | |
| void | add_opacity_point (float x, float opacity) |
| Add an opacity point at position x. | |
| bool | remove_color_point (float x) |
| Remove the color point at position x if it exists. | |
| bool | remove_opacity_point (float x) |
| Remove the opacity point at position x if it exists. | |
| void | set_domain (cgv::vec2 domain) override |
| Set the domain. | |
| void | rescale (cgv::vec2 domain) |
| Rescale the color and opactiy functions to the new domain. | |
| float | normalize_value (float value) const override |
| See color_scale::normalize_value(). | |
| cgv::rgba | map_value (float value) const override |
| See color_scale::map_value(). | |
| cgv::rgb | get_mapped_color (float value) const override |
| See color_scale::get_mapped_color(). | |
| float | get_mapped_opacity (float value) const override |
| See color_scale::get_mapped_opacity(). | |
| std::vector< cgv::rgba > | quantize (size_t count) const override |
| See color_scale::quantize(). | |
| std::vector< cgv::rgb > | quantize_color (size_t count) const |
| Quantize the color function only. | |
| std::vector< float > | quantize_opacity (size_t count) const |
| Quantize the opacity function only. | |
| std::vector< float > | get_ticks (size_t request_count) const override |
| See color_scale::get_ticks(). | |
| void | clear () |
| Clear all color and opacity control points. | |
| void | clear_color_points () |
| Clear color control points only. | |
| void | clear_opacity_points () |
| Clear opacity control points only. | |
| const std::vector< color_point_type > & | get_color_points () const |
| Get the color control points. | |
| const std::vector< opacity_point_type > & | get_opacity_points () const |
| Get the opacity control points. | |
| void | set_interpolation (InterpolationMode interpolation) |
| Set the interpolation mode of the color and opacity function. | |
| void | set_color_interpolation (InterpolationMode interpolation) |
| Set the interpolation mode of the color function. | |
| InterpolationMode | get_color_interpolation () const |
| Get the interpolation mode of the color function. | |
| void | set_opacity_interpolation (InterpolationMode interpolation) |
| Set the interpolation mode of the opacity function. | |
| InterpolationMode | set_opacity_interpolation () const |
| Get the interpolation mode of the opacity function. | |
Public Member Functions inherited from cgv::media::color_scale | |
| virtual | ~color_scale () |
| Destruct this color scale. | |
| cgv::vec2 | get_domain () const |
| Get the input domain of scalars that will be mapped. | |
| virtual void | set_clamped (bool clamped) |
| Set whether the input values are clamped to the domain before mapping. | |
| bool | is_clamped () const |
| Get whether the input values are clamped to the domain before mapping. | |
| virtual void | set_reversed (bool reverse) |
| Set whether the output color ramp is reversed. | |
| bool | is_reversed () const |
| Get whether the output color ramp is reversed. | |
| virtual void | set_unknown_color (cgv::rgba color) |
| Set the color returned for scalars outside the domain if clamping is disabled. | |
| cgv::rgba | get_unknown_color () const |
| Get the color returned for scalars outside the domain if clamping is disabled. | |
| virtual cgv::rgba | get_indexed_color (size_t index) const |
| Map a discrete index through the lookup table and return a RGBA color. | |
| virtual size_t | get_indexed_color_count () const |
| return the number of available indexed colors. | |
| cgv::data::time_point | get_modified_time () const |
| Get the time point of the last modification of this object. | |
Additional Inherited Members | |
Protected Member Functions inherited from cgv::media::color_scale | |
| void | modified () |
| Update the object's modified time. | |
| bool | is_unknown (float value) const |
| Test whether the value is outside the domain according to the mapping options. | |
| float | map_range_safe (float value, float in_left, float in_right, float out_left, float out_right) const |
| Remap a scalar value from an input range to and output range while safely handling empty ranges. | |
Implementation of a color_scale with a continuous input domain that maps explicit domain values to color and opacity using piecewise constant, piecewise linear or piecewise smooth (b-splines) interpolation.
Control points of the color and opacity function can be controlled independent of each other.
Definition at line 21 of file transfer_function.h.
| using cgv::media::transfer_function::color_point_type = std::pair<float, color_type> |
The used color control point type.
Definition at line 35 of file transfer_function.h.
The used color type.
Definition at line 31 of file transfer_function.h.
| using cgv::media::transfer_function::opacity_point_type = std::pair<float, opacity_type> |
The used opacity control point type.
Definition at line 37 of file transfer_function.h.
| using cgv::media::transfer_function::opacity_type = float |
The used opacity type.
Definition at line 33 of file transfer_function.h.
|
strong |
The interpolation modes supported by the transfer function.
Definition at line 24 of file transfer_function.h.
|
inline |
Construct using default arguments.
Definition at line 40 of file transfer_function.h.
| cgv::media::transfer_function::transfer_function | ( | std::initializer_list< color_point_type > | colors | ) |
Construct from a sequence of color control points.
Sets the domain to the range governed by the control points.
| colors | The control points. |
Definition at line 9 of file transfer_function.cxx.
References set_color_points().
| cgv::media::transfer_function::transfer_function | ( | std::initializer_list< color_point_type > | colors, |
| std::initializer_list< opacity_point_type > | opacities | ||
| ) |
Construct from separate sequences of color and opacity control points.
Sets the domain to excatly cover the minimum and maximum position among all color and opacity control points. Additional control points are added to the ends of the individual piecwise functions if necessary.
| colors | The color control points. |
| opacities | The opacity control points. |
Definition at line 13 of file transfer_function.cxx.
References set_color_points(), and set_opacity_points().
| void cgv::media::transfer_function::add_color_point | ( | float | x, |
| const color_type & | color | ||
| ) |
Add a color point at position x.
Will replace the previous color point at position x if it exists.
| x | The control point position. |
| color | The control point color. |
Definition at line 40 of file transfer_function.cxx.
References remove_color_point().
Referenced by set_domain().
| void cgv::media::transfer_function::add_opacity_point | ( | float | x, |
| float | opacity | ||
| ) |
Add an opacity point at position x.
Will replace the previous opacity point at position x if it exists. The opacity is clamped to [0,1].
| x | The control point position. |
| opacity | The control point color. |
Definition at line 47 of file transfer_function.cxx.
References remove_opacity_point().
Referenced by set_domain().
| void cgv::media::transfer_function::clear | ( | ) |
Clear all color and opacity control points.
Definition at line 208 of file transfer_function.cxx.
| void cgv::media::transfer_function::clear_color_points | ( | ) |
Clear color control points only.
Definition at line 214 of file transfer_function.cxx.
| void cgv::media::transfer_function::clear_opacity_points | ( | ) |
Clear opacity control points only.
Definition at line 219 of file transfer_function.cxx.
|
inline |
Check whether the transfer function is empty.
Definition at line 72 of file transfer_function.h.
|
inline |
Get the interpolation mode of the color function.
| interpolation | The interpolation mode. |
Definition at line 199 of file transfer_function.h.
|
inline |
Get the color control points.
Definition at line 175 of file transfer_function.h.
|
overridevirtual |
See color_scale::get_mapped_color().
Reimplemented from cgv::media::color_scale.
Definition at line 149 of file transfer_function.cxx.
References cgv::media::color_scale::get_unknown_color(), and cgv::media::color_scale::is_unknown().
Referenced by map_value(), and set_domain().
|
overridevirtual |
See color_scale::get_mapped_opacity().
Reimplemented from cgv::media::color_scale.
Definition at line 157 of file transfer_function.cxx.
Referenced by map_value(), and set_domain().
|
inline |
Get the opacity control points.
Definition at line 182 of file transfer_function.h.
|
overridevirtual |
Implements cgv::media::color_scale.
Definition at line 195 of file transfer_function.cxx.
References cgv::media::color_scale::get_domain().
|
inlineoverridevirtual |
See color_scale::is_discrete().
Implements cgv::media::color_scale.
Definition at line 65 of file transfer_function.h.
|
inlineoverridevirtual |
Return whether the color scale maps to opacity.
Reimplemented from cgv::media::color_scale.
Definition at line 59 of file transfer_function.h.
|
overridevirtual |
Reimplemented from cgv::media::color_scale.
Definition at line 142 of file transfer_function.cxx.
References cgv::media::rgb_color_interface< color< T, cm, am > >::B(), cgv::media::rgb_color_interface< color< T, cm, am > >::G(), get_mapped_color(), get_mapped_opacity(), and cgv::media::rgb_color_interface< color< T, cm, am > >::R().
|
overridevirtual |
See color_scale::normalize_value().
Reimplemented from cgv::media::color_scale.
Definition at line 136 of file transfer_function.cxx.
References cgv::media::color_scale::get_domain(), and cgv::media::color_scale::map_range_safe().
|
overridevirtual |
Implements cgv::media::color_scale.
Definition at line 163 of file transfer_function.cxx.
References quantize_color(), and quantize_opacity().
Referenced by quantize_color(), and quantize_opacity().
| std::vector< cgv::rgb > cgv::media::transfer_function::quantize_color | ( | size_t | count | ) | const |
Quantize the color function only.
See quantize().
Definition at line 176 of file transfer_function.cxx.
References cgv::media::color_scale::is_reversed(), and quantize().
Referenced by quantize().
| std::vector< float > cgv::media::transfer_function::quantize_opacity | ( | size_t | count | ) | const |
Quantize the opacity function only.
See quantize().
Definition at line 186 of file transfer_function.cxx.
References cgv::media::color_scale::is_reversed(), and quantize().
Referenced by quantize().
| bool cgv::media::transfer_function::remove_color_point | ( | float | x | ) |
Remove the color point at position x if it exists.
| x | The position of the control point to be removed. |
Definition at line 54 of file transfer_function.cxx.
References cgv::media::color_scale::modified().
Referenced by add_color_point().
| bool cgv::media::transfer_function::remove_opacity_point | ( | float | x | ) |
Remove the opacity point at position x if it exists.
| x | The position of the control point to be removed. |
Definition at line 62 of file transfer_function.cxx.
References cgv::media::color_scale::modified().
Referenced by add_opacity_point().
| void cgv::media::transfer_function::rescale | ( | cgv::vec2 | domain | ) |
Rescale the color and opactiy functions to the new domain.
All control point positions are updated proportionally to fit inside the new domain.
| domain | The new domain. |
Definition at line 117 of file transfer_function.cxx.
References cgv::media::color_scale::get_domain(), cgv::media::color_scale::map_range_safe(), and cgv::media::color_scale::set_domain().
| void cgv::media::transfer_function::set_color_interpolation | ( | InterpolationMode | interpolation | ) |
Set the interpolation mode of the color function.
| interpolation | The interpolation mode. |
Definition at line 232 of file transfer_function.cxx.
References cgv::media::color_scale::modified().
| void cgv::media::transfer_function::set_color_points | ( | const std::vector< color_point_type > & | colors | ) |
Set the color function to use the given control points.
Extends the domain if the new control points are outside the current domain.
| colors | The control points. |
Definition at line 18 of file transfer_function.cxx.
Referenced by set_color_points_from_scheme(), transfer_function(), and transfer_function().
| void cgv::media::transfer_function::set_color_points_from_scheme | ( | const cgv::media::continuous_color_scheme & | scheme, |
| size_t | n | ||
| ) |
Set the color function to use n uniformly sampled points from the given color scheme.
Will set the domain to [0,1]. See also set_color_points().
| scheme | The color scheme. |
| n | The number of poitns to sample. |
Definition at line 25 of file transfer_function.cxx.
References cgv::media::continuous_color_scheme::quantize(), set_color_points(), cgv::utils::subdivision_sequence(), and cgv::utils::zip().
|
overridevirtual |
Set the domain.
All control points outside of the new domain will be removed. New control points will be created at the ends of the new domain if they don't already exist. Affects color and opacity functions.
| domain | The new domain. |
Reimplemented from cgv::media::color_scale.
Definition at line 70 of file transfer_function.cxx.
References add_color_point(), add_opacity_point(), cgv::media::color_scale::get_domain(), get_mapped_color(), get_mapped_opacity(), and cgv::media::color_scale::modified().
| void cgv::media::transfer_function::set_interpolation | ( | InterpolationMode | interpolation | ) |
Set the interpolation mode of the color and opacity function.
| interpolation | The interpolation mode. |
Definition at line 224 of file transfer_function.cxx.
References cgv::media::color_scale::modified().
|
inline |
Get the interpolation mode of the opacity function.
| interpolation | The interpolation mode. |
Definition at line 211 of file transfer_function.h.
| void cgv::media::transfer_function::set_opacity_interpolation | ( | InterpolationMode | interpolation | ) |
Set the interpolation mode of the opacity function.
| interpolation | The interpolation mode. |
Definition at line 239 of file transfer_function.cxx.
References cgv::media::color_scale::modified().
| void cgv::media::transfer_function::set_opacity_points | ( | const std::vector< opacity_point_type > & | opacities | ) |
Set the opacity function to use the given control points.
Extends the domain if the new control points are outside the current domain. Opacity values are clamped to [0,1].
| opacities | The control points. |
Definition at line 32 of file transfer_function.cxx.
Referenced by transfer_function().