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

The StepFunctionModel class represents a step (Heaviside) function. More...

#include <datamodels1d.h>

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

Public Types

enum  { Type = 50 }
 
enum  StepDirection { RightIsZero = 0, Downwards = 0, LeftIsZero = 1, Upwards = 1 }
 
- Public Types inherited from CTL::AbstractDataModel
enum  { Type = 0 }
 
- Public Types inherited from CTL::SerializationInterface
enum  { Type = -1, UserType = 65536 }
 

Public Member Functions

int type () const override
 
float valueAt (float position) const override
 Returns the value from the model at position. More...
 
float binIntegral (float position, float binWidth) const override
 Returns the integral over model values in the interval [position - 0.5 * binWidth, position + 0.5 * binWidth]. More...
 
AbstractIntegrableDataModelclone () const override
 
 StepFunctionModel (float threshold=0.0f, float amplitude=1.0f, StepDirection stepDirection=LeftIsZero)
 Creates a data model representing a step (Heaviside) function. More...
 
QVariant parameter () const override
 
void setParameter (const QVariant &parameter) override
 
- Public Member Functions inherited from CTL::AbstractIntegrableDataModel
float meanValue (float position, float binWidth) const
 
- Public Member Functions inherited from CTL::AbstractDataModel
void fromVariant (const QVariant &variant) override
 
QVariant toVariant () const override
 
bool isIntegrable () const
 
void setName (const QString &name)
 
const QString & name () const
 
- Public Member Functions inherited from CTL::SerializationInterface
virtual ~SerializationInterface ()=default
 

Private Attributes

float _threshold
 
float _amplitude
 
StepDirection _stepDirection
 

Friends

template<class >
struct SerializationHelper::RegisterWithSerializationHelper
 

Additional Inherited Members

- Protected Member Functions inherited from CTL::AbstractIntegrableDataModel
 AbstractIntegrableDataModel (const AbstractIntegrableDataModel &)=default
 
 AbstractIntegrableDataModel (AbstractIntegrableDataModel &&)=default
 
AbstractIntegrableDataModeloperator= (const AbstractIntegrableDataModel &)=default
 
AbstractIntegrableDataModeloperator= (AbstractIntegrableDataModel &&)=default
 
- Protected Member Functions inherited from CTL::AbstractDataModel
 AbstractDataModel (const AbstractDataModel &)=default
 
 AbstractDataModel (AbstractDataModel &&)=default
 
AbstractDataModeloperator= (const AbstractDataModel &)=default
 
AbstractDataModeloperator= (AbstractDataModel &&)=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 StepFunctionModel class represents a step (Heaviside) function.

This model maps input values according to a step function. The direction, position, and height of the step can be specified in the constructor of using setParameter().

Constructor & Destructor Documentation

◆ StepFunctionModel()

CTL::StepFunctionModel::StepFunctionModel ( float  threshold = 0.0f,
float  amplitude = 1.0f,
StepDirection  stepDirection = LeftIsZero 
)
explicit

Creates a data model representing a step (Heaviside) function.

The created step function has its step position at threshold. If stepDirection = LeftIsZero, values below threshold are mapped to zero and all input larger that threshold is mapped to amplitude. Behaves the other way round for stepDirection = RightIsZero.

Member Function Documentation

◆ binIntegral()

float CTL::StepFunctionModel::binIntegral ( float  position,
float  binWidth 
) const
overridevirtual

Returns the integral over model values in the interval [position - 0.5 * binWidth, position + 0.5 * binWidth].

If the model output to input parameter \( x \) is given by \( f(x) \), this method computes and returns:

\( \begin{align*} \int_{position-\frac{binWidth}{2}}^{position+\frac{binWidth}{2}} f(x) \,dx \end{align*} \)

Implements CTL::AbstractIntegrableDataModel.

◆ clone()

AbstractIntegrableDataModel * CTL::StepFunctionModel::clone ( ) const
overridevirtual

Creates a copy of this instance and returns a base class pointer to the new object.

Implements CTL::AbstractIntegrableDataModel.

◆ parameter()

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

Returns the parameters of this instance as QVariant.

This returns a QVariantMap with three key-value-pairs, representing threshold, amplitude, and which side of the step is zero.

Reimplemented from CTL::AbstractDataModel.

◆ setParameter()

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

Sets the parameters of this instance based on the passed QVariant parameter.

Parameters can be passed by either of the following two options:

  1. As a QVariantMap with three key-value-pairs: ("Threshold", threshold), ("Amplitude", amplitude), and ("Left is zero", stepDirection)
  2. As a QVariantList: In this case, the list must contain two floating point values and one boolean sorted in the following order: threshold, amplitude, stepDirection.

Reimplemented from CTL::AbstractDataModel.

◆ type()

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

Returns the type id of this instance.

Reimplemented from CTL::AbstractDataModel.

◆ valueAt()

float CTL::StepFunctionModel::valueAt ( float  position) const
overridevirtual

Returns the value from the model at position.

The resulting value is described by the follwoing relation:

For step direction LeftIsZero (see StepFunctionModel()): \( f(x)=\begin{cases} 0 & x<threshold\\ amplitude & x\geq threshold \end{cases} \)

Implements CTL::AbstractDataModel.


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