![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/CroppingMask.h>
Simple axis-aligned cropping mask with optional roundness. More...
Simple axis-aligned cropping mask with optional roundness.
Public Types | |
enum class | RoundDims { XY , YZ , XZ , XYZ } |
Enum to define to which dimensions/axes the roundness parameter should be applied. | |
![]() | |
enum class | CreateOption { DeepCopy , ShallowCopyIfPossible } |
Enumeration of available behavior for createExplicitMask() More... | |
![]() | |
using | MultiIncludeType |
Alias for type of a multi-include instance of the original include. | |
Public Member Functions | |
CroppingMask (const vec3i &imageDimensions) | |
Construct the mask with image pixel dimensions. | |
CroppingMask (const CroppingMask &other) | |
CroppingMask & | operator= (const CroppingMask &other) |
const vec3i & | dimensions () const |
Return the assumed image pixel dimensions. | |
void | setBorder (const vec3i &lower, const vec3i &upper) |
Set the number of pixels cropped away. | |
std::pair< vec3i, vec3i > | border () const |
Retrieve the number of pixels cropped away starting from the lower-left-front corner and the upper-right-back corners. | |
void | border (vec3i &lowerOut, vec3i &upperOut) const |
Retrieve the number of pixels cropped away starting from the lower-left-front corner and the upper-right-back corners. | |
void | setRoundness (float percent) |
Define roundness in percent. | |
float | roundness () const |
Retrieve the roundness parameter. | |
void | setRoundnessDims (RoundDims roundDims) |
Define to which dimensions the roundness parameter should be applied. | |
RoundDims | roundnessDims () const |
Retrieve to which dimensions the roundness parameter is applied. | |
void | setIsInverted (bool flag) |
Inverts the mask. | |
bool | isInverted () const |
Retrieve if the mask is inverted. | |
std::unique_ptr< TypedImage< uint8_t > > | createExplicitMask (const SharedImage &image, CreateOption createOption=CreateOption::DeepCopy) const override |
Creates an explicit mask representation of this mask for a given image. | |
void | configure (const Properties *p) override |
Set one or multiple properties. | |
void | configuration (Properties *p) const override |
Retrieve the properties of this object. | |
uint8_t | maskValue (const vec3i &coord, const vec4f &) const override |
Returns 0 if the given pixel is outside the mask (i.e. | |
bool | isCompatible (const SharedImage *image) const override |
Returns true if the mask can be used with the given image or false otherwise. | |
bool | requiresPixelValue () const override |
Returns true if the maskValue() rely on the pixel value. | |
std::unique_ptr< Mask > | resizedMask (const SharedImage &original, const Image &target) const override |
Creates a copy of the current mask, resized to the dimensions of the target image. | |
int | setIncludeArguments (GL::Program &p, const std::string &prefix="mask") const override |
Called by users of GlMask in order to correctly setup the mask shader. | |
GlMask * | glMask () override |
Returns the OpenGL-based implementation of the mask interface if available. | |
![]() | |
uint8_t | maskValue (const vec3i &coord, float value=-1.0f) const |
Convenience overload that calls maskValue(coord, vec4f(value, value, value, 1.0f)) . | |
![]() | |
virtual void | configureDefaults () |
Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
void | registerParameter (ParameterBase *param) |
Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
void | unregisterParameter (const ParameterBase *param) |
Remove the given Parameter or SubProperty from the list of registered parameters. | |
Configurable (const Configurable &rhs) | |
Configurable (Configurable &&rhs) noexcept | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
![]() | |
GlMask (const std::string &includePath) | |
Instantiates a new GL::AbstractInclude using IMAGE_MASK as defineName and the given path the to retrieve the GLSL source code from. | |
virtual std::unique_ptr< GlImage > | createExplicitMaskGl (const GlImage &inputImage, bool normalized=false) |
Creates an explicit mask representation of this mask when applied to the given image. | |
![]() | |
AbstractInclude (const std::string &defineName, const std::string &includePath) | |
Creates a AbstractInclude for the given define and with the corresponding GLSL file at includePath. | |
const std::string & | defineName () const |
Returns the name of define used by this include. | |
const std::string & | includePath () const |
Returns the path to the included shader file. | |
virtual std::function< std::string(const std::string &)> | includeCodeSubstitution () const |
Optionally the abstract include can provide a function to change the shader code. | |
virtual std::vector< AbstractInclude * > | dependentIncludes () const |
Returns a list of dependent abstract includes that need to be included as well. | |
virtual Fingerprint | fingerprint () const |
Provides a finger print of the include. | |
![]() | |
std::shared_ptr< MultiIncludeType > | createMultiInclude (const std::string &replacementToken) |
Instantiates a new AbstractInclude instance where all occurrences of baseToken provided during construction are replaces with replacementToken according to the specified replacementScheme. | |
virtual int | setIncludeArguments (Program &prog, IncludeArgumentsTypes... includeArgs, const std::string &token) const=0 |
Interface that multi includes should use to configure the shader include (such as setting uniforms, binding textures, etc). | |
Additional Inherited Members | |
![]() | |
static std::string | defineName () |
Returns "IMAGE_MASK". | |
static std::string | defineSuffix () |
Returns "MASK". | |
static std::string | multiIncludeDefine (const std::string &replacementToken) |
Returns "IMAGE_" + toUpper(replacementToken) | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
![]() | |
MultiIncludable (GlMask *crtpInstance, const std::string &baseToken, Flags< ShaderTextReplacement > replacementScheme) | |
Instantiate and configure the MultiIncludable interface. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
void setBorder | ( | const vec3i & | lower, |
const vec3i & | upper ) |
Set the number of pixels cropped away.
lower | Number of pixels cropped when starting from the lower-left-front corner |
upper | Number of pixels cropped when starting from the lower-left-front corner |
|
inline |
Define roundness in percent.
A value of 100 yields an ellipse, a value of 0 yields a rectangle, and all values in between yield a rectangle with rounded edges.
|
overridevirtual |
Creates an explicit mask representation of this mask for a given image.
The parameters are ignored in this specific overload, the dimensions used when constructing the cropping mask are used for the output
Reimplemented from Mask.
|
overridevirtual |
Set one or multiple properties.
Reimplemented from Configurable.
|
overridevirtual |
Retrieve the properties of this object.
Reimplemented from Configurable.
|
overridevirtual |
Returns 0 if the given pixel is outside the mask (i.e.
invisible/to be ignored) or a non-zero value if it is inside the mask (i.e. visible/to be considered).
This function takes both the pixel coordinate and pixel value as input. Concrete implementations of the Mask interface are free to use only either input for their decision if it makes sense. Also, it is up to the implementation whether it supports multi-channel images or not. Subclasses only supporting grayscale images should only use the first channel.
coord | Pixel coordinate to be tested against the mask, can be outside of the image. |
color | Pixel value (not normalized) to be tested against the mask. This parameter is only needed if requiresPixelValue() returns true , which can allow for optimizations where pixel lookup is expensive. |
Implements Mask.
|
overridevirtual |
Returns true
if the mask can be used with the given image or false
otherwise.
Implements Mask.
|
overridevirtual |
Returns true if the maskValue() rely on the pixel value.
If this method returns false
, the maskValue() method can be safely used with only the coordinate. This is useful to avoid an otherwise unnecessary and expensive pixel lookup.
Implements Mask.
|
overridevirtual |
Creates a copy of the current mask, resized to the dimensions of the target image.
The default implementation calls createExplicitMask and resamples the result. Returns nullptr if the mask cannot be resized.
Reimplemented from Mask.
|
overridevirtual |
Called by users of GlMask in order to correctly setup the mask shader.
Subclasses should implement this function so that it correctly sets all needed uniforms and input textures to be used by the OpenGL shader instance. Make sure to use the given prefix argument instead of a hardcoded "mask" when defining uniform names to support multi-includes where the prefixes have been replaced with unique alternatives. Example:
Implements GlMask.
|
overridevirtual |
Returns the OpenGL-based implementation of the mask interface if available.
This function may return nullptr
if this is not implemented (default).
Reimplemented from Mask.