CTL
0.6.1
Computed Tomography Library
|
The ProjectionPipeline class is a convenience class to manage a composition of a projector and additional extensions in a simple manner. More...
#include <projectionpipeline.h>
Public Types | |
enum | { Type = 200 } |
using | ProjectorPtr = std::unique_ptr< AbstractProjector > |
Alias name for std::unique_ptr<AbstractProjector>. | |
using | ExtensionPtr = std::unique_ptr< ProjectorExtension > |
Alias name for std::unique_ptr<ProjectorExtension>. | |
![]() | |
enum | { Type = 0 } |
![]() | |
enum | { Type = -1, UserType = 65536 } |
Public Member Functions | |
int | type () const override |
void | configure (const AcquisitionSetup &setup) override |
Sets the acquisition setup for the simulation to setup. More... | |
ProjectionData | project (const VolumeData &volume) override |
Creates projection data from volume. More... | |
ProjectionData | projectComposite (const CompositeVolume &volume) override |
Creates projection data from the composite volume volume. More... | |
ProjectionData | projectSparse (const SparseVoxelVolume &volume) override |
Creates projection data from the sparse volume volume. More... | |
bool | isLinear () const override |
void | fromVariant (const QVariant &variant) override |
Sets the contents of the object based on the QVariant variant. More... | |
QVariant | toVariant () const override |
Stores the contents of this instance in a QVariant. More... | |
ProjectorNotifier * | notifier () override |
Returns a pointer to the notifier of the projector. More... | |
ProjectionPipeline (AbstractProjector *projector=nullptr) | |
ProjectionPipeline (ProjectorPtr projector) | |
void | appendExtension (ExtensionPtr extension) |
void | appendExtension (ProjectorExtension *extension) |
void | insertExtension (uint pos, ExtensionPtr extension) |
void | insertExtension (uint pos, ProjectorExtension *extension) |
ProjectorExtension * | releaseExtension (uint pos) |
void | removeExtension (uint pos) |
void | setProjector (ProjectorPtr projector) |
void | setProjector (AbstractProjector *projector) |
ExtensionPtr | takeExtension (uint pos) |
ProjectorExtension * | extension (uint pos) const |
AbstractProjector * | projector () const |
uint | nbExtensions () const |
![]() | |
AbstractProjector (const AbstractProjector &)=delete | |
AbstractProjector (AbstractProjector &&)=default | |
AbstractProjector & | operator= (const AbstractProjector &)=delete |
AbstractProjector & | operator= (AbstractProjector &&)=default |
~AbstractProjector () override=default | |
ProjectionData | configureAndProject (const AcquisitionSetup &setup, const VolumeData &volume) |
Performs a forward projection with a precedent configuration of the projector. More... | |
ProjectionData | configureAndProject (const AcquisitionSetup &setup, const CompositeVolume &volume) |
Performs a forward projection with a precedent configuration of the projector. More... | |
ProjectionData | configureAndProject (const AcquisitionSetup &setup, const SparseVoxelVolume &volume) |
Performs a forward projection with a precedent configuration of the projector. More... | |
virtual QVariant | parameter () const |
Returns the parameters of this instance as QVariant. More... | |
virtual void | setParameter (const QVariant ¶meter) |
Sets the parameters of this instance based on the passed QVariant parameter. Parameters need to follow the naming convention as described in parameter(). More... | |
void | connectNotifierToMessageHandler (bool includeProgress=false) |
Connects the notifier to the CTL's MessageHandler. More... | |
![]() | |
virtual | ~SerializationInterface ()=default |
Private Member Functions | |
void | stashExtensions (uint nbExt) |
void | restoreExtensions (uint nbExt) |
Private Attributes | |
std::vector< ProjectorExtension * > | _extensions |
(Ordered) list of pointers to all extensions. | |
ExtensionPtr | _finalProjector |
The fully-assembled projector (incl. all extensions). | |
AbstractProjector * | _projector |
Pointer to the actual projector object. | |
Friends | |
template<class > | |
struct | SerializationHelper::RegisterWithSerializationHelper |
Additional Inherited Members | |
![]() | |
SerializationInterface ()=default | |
SerializationInterface (const SerializationInterface &)=default | |
SerializationInterface (SerializationInterface &&)=default | |
SerializationInterface & | operator= (const SerializationInterface &)=default |
SerializationInterface & | operator= (SerializationInterface &&)=default |
![]() | |
VolumeData | |
Alias name for CTL::SpectralVolumeData. More... | |
std::unique_ptr< ProjectorType > | makeProjector (ConstructorArguments &&... arguments) |
The ProjectionPipeline class is a convenience class to manage a composition of a projector and additional extensions in a simple manner.
This class provides a simple means to manage a projector along with an arbitrary number of ProjectorExtension objects. It allows for manipulations of the processing pipeline in a list-like fashion.
Use appendExtension() to add another extension to the end of the current pipeline. Extensions can also be inserted at arbitrary positions within the pipeline with insertExtension() as well as removed with removeExtension(). The actual projector to be used can be set using setProjector() or directly in the constructor. All methods take ownership of the objects passed to them and destroy any previous object, in case they replace or remove it. To take extensions out of the pipeline without destroying the object, use releaseExtension() or takeExtension().
All manipulations on the pipeline are executed immediately. That means each call to either of the above mentioned methods can throw an exeption in case the pipeline that would result from the manipulation is not possible (i.e. if it internally throws an exception during use()).
To modify any settings of individual extensions (or the actual projector), pointers to the corresponding objects can be accessed with extension() and projector(). Note that the ownership remains at the ProjectionPipeline object and you need to cast the pointer to the correct type of extension or projector in order to access its full interface. Best practice is to fully prepare all settings of the extensions before adding them to the pipeline.
The ProjectorPipeline object itself can be used in the same way as any projector; use configure() to pass the AcquisitionSetup for the simulation and then call project() (or projectComposite()) with the volume dataset that shall be projected to create the simulated projections using the full processing pipeline that is managed your ProjectorPipeline object.
The following code example demonstrates the usage of a ProjectionPipeline for creating projections of a bone ball phantom. The simulation shall be done using the OCL::RayCasterProjector class as forward projector and the processing chain shall consider spectral effects followed by addition of Poisson noise.
CTL::ProjectionPipeline::ProjectionPipeline | ( | AbstractProjector * | projector = nullptr | ) |
Constructs a ProjectionPipeline object and sets the projector to projector.
This object takes ownership of projector.
CTL::ProjectionPipeline::ProjectionPipeline | ( | ProjectorPtr | projector | ) |
Convenience overload of ProjectionPipeline(AbstractProjector*) for unique_ptr arguments.
void CTL::ProjectionPipeline::appendExtension | ( | ExtensionPtr | extension | ) |
Appends the extension extension to the end of the pipeline.
This object takes ownership of extension.
void CTL::ProjectionPipeline::appendExtension | ( | ProjectorExtension * | extension | ) |
Appends the extension extension to the end of the pipeline.
This object takes ownership of extension.
|
overridevirtual |
Sets the acquisition setup for the simulation to setup.
Sets the acquisition setup for the simulation to setup. This needs to be done prior to calling project().
Implements CTL::AbstractProjector.
ProjectorExtension * CTL::ProjectionPipeline::extension | ( | uint | pos | ) | const |
Returns a (base-class) pointer to the extension at position pos in the current pipeline.
Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).
Ownership remains at this instance.
|
overridevirtual |
Sets the contents of the object based on the QVariant variant.
Implementation of the deserialization interface. This method uses setParameter() to deserialize class members.
Reimplemented from CTL::AbstractProjector.
void CTL::ProjectionPipeline::insertExtension | ( | uint | pos, |
ExtensionPtr | extension | ||
) |
Inserts the extension extension at position pos into the pipeline. If pos >= nbExtensions(), the extension is appended.
Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).
This object takes ownership of extension.
void CTL::ProjectionPipeline::insertExtension | ( | uint | pos, |
ProjectorExtension * | extension | ||
) |
Inserts the extension extension at position pos into the pipeline. If pos >= nbExtensions(), the extension is appended.
Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).
This object takes ownership of extension.
|
overridevirtual |
Returns true if the application of the full processing pipeline is linear.
Reimplemented from CTL::AbstractProjector.
uint CTL::ProjectionPipeline::nbExtensions | ( | ) | const |
Returns the number of extensions in the pipeline.
Note that the actual projector does not count towards the number of extensions, i.e. for a pipeline consisting solely of a projector, nbExtensions() is zero.
|
overridevirtual |
Returns a pointer to the notifier of the projector.
The notifier object can be used to emit the signal ProjectorNotifier::projectionFinished(int) when the calculation of the viewNb'th view has been done.
To receive emitted signals, use Qt's connect() method to connect the notifier object to any receiver object of choice. The notifier can also conveniently be connected to the MessageHandler of the CTL using connectToMessageHandler() or directly from the projector through AbstractProjector::connectNotifierToMessageHandler().
Example - sending simulation progress information to a QProgressBar:
/// Example 2 - forwarding the information text to a QStatusBar
Reimplemented from CTL::AbstractProjector.
|
overridevirtual |
Creates projection data from volume.
Creates projection data from volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().
Implements CTL::AbstractProjector.
|
overridevirtual |
Creates projection data from the composite volume volume.
Creates projection data from the composite volume volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().
Reimplemented from CTL::AbstractProjector.
AbstractProjector * CTL::ProjectionPipeline::projector | ( | ) | const |
Returns a (base-class) pointer to the projector that is currently set in the pipeline.
Ownership remains at this instance.
|
overridevirtual |
Creates projection data from the sparse volume volume.
Creates projection data from the sparse volume volume using the current processing pipeline configuration of this instance. Uses the last acquisition setup set by configure().
Reimplemented from CTL::AbstractProjector.
ProjectorExtension * CTL::ProjectionPipeline::releaseExtension | ( | uint | pos | ) |
Removes the extension at position pos from the pipeline. Throws an std::domain_error if pos >= nbExtensions().
Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).
The ownership of the released object is transfered to the caller.
void CTL::ProjectionPipeline::removeExtension | ( | uint | pos | ) |
Removes the extension at position pos from the pipeline. Throws an std::domain_error if pos >= nbExtensions().
The removed extension object is destroyed.
|
private |
Restores nbExt extensions at the end of the pipeline.
Extensions must have been removed before by stashExtensions().
void CTL::ProjectionPipeline::setProjector | ( | ProjectorPtr | projector | ) |
Sets the projector to projector. Destroys any previous projector object managed by this instance.
This object takes ownership of projector.
void CTL::ProjectionPipeline::setProjector | ( | AbstractProjector * | projector | ) |
Sets the projector to projector. Destroys any previous projector object managed by this instance.
This object takes ownership of projector.
|
private |
Temporarily removes nbExt extensions from the end of the pipeline.
The removed objects are not deleted and need to be restored later using restoreExtensions() to avoid memory leaks.
ProjectionPipeline::ExtensionPtr CTL::ProjectionPipeline::takeExtension | ( | uint | pos | ) |
Removes the extension at position pos from the pipeline. The extension object is wrapped into a unique pointer and returned to the caller. Throws an std::domain_error if pos >= nbExtensions().
Note that the position refers only to the extensions in the pipeline (i.e. the actual projector is not does not count towards the current number of extension).
|
overridevirtual |
Stores the contents of this instance in a QVariant.
Implementation of the serialization interface. Stores the object's type-id (from SerializationInterface::toVariant()).
This method uses parameter() to serialize class members.
Reimplemented from CTL::AbstractProjector.
|
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::AbstractProjector.