CTL  0.6.1
Computed Tomography Library
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
CTL::SeparableProductModel Class Reference

The SeparableProductModel class represents the product of individual (1D) models in each dimension. More...

#include <datamodels2d.h>

Inheritance diagram for CTL::SeparableProductModel:
Inheritance graph
[legend]
Collaboration diagram for CTL::SeparableProductModel:
Collaboration graph
[legend]

Public Types

enum  { Type = 1100 }
 
- Public Types inherited from CTL::AbstractDataModel2D
enum  { Type = 1000 }
 
- Public Types inherited from CTL::SerializationInterface
enum  { Type = -1, UserType = 65536 }
 

Public Member Functions

int type () const override
 
float valueAt (float x, float y) const override
 Returns the value from the model at position (x, y). More...
 
AbstractDataModel2Dclone () const override
 
 SeparableProductModel (std::shared_ptr< AbstractDataModel > xModel, std::shared_ptr< AbstractDataModel > yModel)
 Constructs a SeparableProductModel; a model representing the product of two one-dimensional models. More...
 
AbstractDataModelxModel ()
 Returns a (modifiable) reference to the model in x-dimension. More...
 
AbstractDataModelyModel ()
 Returns a (modifiable) reference to the model in y-dimension. More...
 
QVariant parameter () const override
 
void setParameter (const QVariant &parameter) override
 Sets the parameters contained in parameter (a QVariantMap). More...
 
QVariant toVariant () const override
 
- Public Member Functions inherited from CTL::AbstractDataModel2D
void setParameter (const QString &name, const QVariant &value)
 
void fromVariant (const QVariant &variant) override
 
QString name () const
 
void setName (const QString &name)
 
Chunk2D< float > sampleChunk (const SamplingRange &xRange, const SamplingRange &yRange, uint nbSamplesX, uint nbSamplesY) const
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Private Attributes

std::shared_ptr< AbstractDataModel_xModel
 
std::shared_ptr< AbstractDataModel_yModel
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- Protected Member Functions inherited from CTL::AbstractDataModel2D
 AbstractDataModel2D (const AbstractDataModel2D &)=default
 
 AbstractDataModel2D (AbstractDataModel2D &&)=default
 
AbstractDataModel2Doperator= (const AbstractDataModel2D &)=default
 
AbstractDataModel2Doperator= (AbstractDataModel2D &&)=default
 
- Protected Member Functions inherited from CTL::SerializationInterface
 SerializationInterface ()=default
 
 SerializationInterface (const SerializationInterface &)=default
 
 SerializationInterface (SerializationInterface &&)=default
 
SerializationInterfaceoperator= (const SerializationInterface &)=default
 
SerializationInterfaceoperator= (SerializationInterface &&)=default
 

Detailed Description

The SeparableProductModel class represents the product of individual (1D) models in each dimension.

This model maps input in each dimension according to the corresponding model and returns the product of both values. This can be used to construct models that have no inter-dependency between both dimensions (i.e. they are separable).

Constructor & Destructor Documentation

◆ SeparableProductModel()

CTL::SeparableProductModel::SeparableProductModel ( std::shared_ptr< AbstractDataModel xModel,
std::shared_ptr< AbstractDataModel yModel 
)

Constructs a SeparableProductModel; a model representing the product of two one-dimensional models.

This creates a model that is defined by the two one-dimensional models xModel and yModel that describe the function individually in each dimension.

This model maps input in each dimension according to the corresponding model and returns the product of both values. This can be used to construct models that have no inter-dependency between both dimensions (i.e. they are separable).

Example: create a product of a 1D Gaussian (in x direction) and a rect function (in y direction)

auto gaussian = std::make_shared<GaussianModel1D>();
auto rect = std::make_shared<RectFunctionModel>();
auto product = std::make_shared<SeparableProductModel>(gaussian, rect);

Member Function Documentation

◆ parameter()

QVariant CTL::SeparableProductModel::parameter ( ) const
overridevirtual

Returns the parameters of this model as a QVariant.

Default implementation returns an empty QVariant. Override in custom classes to encode all relevant information from the class' members. The returned QVariant must contain all information to fully specify the objects state. In particular, calling setParameter(parameter()) should not change the state of an object.

Reimplemented from CTL::AbstractDataModel2D.

◆ setParameter()

void CTL::SeparableProductModel::setParameter ( const QVariant &  parameter)
overridevirtual

Sets the parameters contained in parameter (a QVariantMap).

The value passed to parameter must be a QVariantMap containing two (key, value)-pairs:

-("x model", [QVariant] variant of xModel), -("y model", [QVariant] variant of yModel).

Note that the QVariants for xModel and yModel must be instances carrying the full serialization information (such as it would be returned, e.g., from xModel().toVariant()).

Direct use of this method is not recommended. To set individual parameters of the two underlying data models, consider using their individual setParameter() methods.

Example: create a product of a 1D Gaussian and a rect function; set the standard deviation of the Gaussian to 4.0 and its amplitude to 10.0.

auto gaussian = std::make_shared<GaussianModel1D>();
auto rect = std::make_shared<RectFunctionModel>();
auto product = std::make_shared<SeparableProductModel>(gaussian, rect);
product->xModel().setParameter(QVariantMap{ { "std", 4.0f },
{ "amplitude", 10.0f } } );
// note that in this situation, using the shared_ptr directly leads to the same result
gaussian->setParameter(QVariantMap{ { "std", 4.0f },
{ "amplitude", 10.0f } } );

Reimplemented from CTL::AbstractDataModel2D.

◆ toVariant()

QVariant CTL::SeparableProductModel::toVariant ( ) const
overridevirtual

Interface to store all member variables in a QVariant.

Stores the object's type-id.

Reimplement this method such that it stores all newly introduced object data when sub-classing. This needs to cover everything that is necessary to fully determine the state of an object. Best practice is to invoke the base class version of this method to take care of all content originating from underlying base classes.

A typical reimplementation in sub-classes might look like this:

QVariantMap ret = DirectBaseClass::toVariant().toMap();
ret.insert("my member variable", _myMemberVariable);
return ret;

Reimplemented from CTL::AbstractDataModel2D.

◆ type()

int CTL::SeparableProductModel::type ( ) const
inlineoverridevirtual

Returns the type-id of the serializable object. Used in deserialization to determine the proper object type.

Add derived classes to the enumeration using the CTL_TYPE_ID macro.

Reimplemented from CTL::AbstractDataModel2D.

◆ valueAt()

float CTL::SeparableProductModel::valueAt ( float  x,
float  y 
) const
overridevirtual

Returns the value from the model at position (x, y).

Returns the product of the value returned by the individual models given their corresponding input values.

Same as: xModel().valueAt(x) * yModel().valueAt(y)

Implements CTL::AbstractDataModel2D.

◆ xModel()

AbstractDataModel & CTL::SeparableProductModel::xModel ( )

Returns a (modifiable) reference to the model in x-dimension.

This can be used to change the parameters of the x model.

◆ yModel()

AbstractDataModel & CTL::SeparableProductModel::yModel ( )

Returns a (modifiable) reference to the model in y-dimension.

This can be used to change the parameters of the y model.


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