BTK  0.3dev.0
Open-source library to visualize/process biomechanical data
List of all members | Public Types | Public Member Functions | Protected Member Functions
btk::ProcessObject Class Referenceabstract

Interface to create a filter/process in a pipeline. More...

#include <btkProcessObject.h>

Inheritance diagram for btk::ProcessObject:
Inheritance graph
[legend]

Public Types

typedef btkSharedPtr< const
ProcessObject
ConstPointer
 
typedef btkSharedPtr
< ProcessObject
Pointer
 
- Public Types inherited from btk::Object
typedef btkSharedPtr< const
Object
ConstPointer
 
typedef btkSharedPtr< ObjectPointer
 

Public Member Functions

int GetInputNumber () const
 
int GetOutputNumber () const
 
int GetValidInputNumber () const
 
void ResetState ()
 
void Update ()
 
- Public Member Functions inherited from btk::Object
unsigned long int GetTimestamp () const
 

Protected Member Functions

virtual void GenerateData ()=0
 
int GetInputIndex (DataObject::Pointer input)
 
DataObject::Pointer GetNthInput (int idx)
 
DataObject::ConstPointer GetNthInput (int idx) const
 
DataObject::Pointer GetNthOutput (int idx)
 
DataObject::ConstPointer GetNthOutput (int idx) const
 
int GetOutputIndex (DataObject::Pointer output)
 
bool IsModified () const
 
virtual DataObject::Pointer MakeOutput (int idx)=0
 
void Modified ()
 
 ProcessObject ()
 
void SetInputNumber (int num)
 
virtual void SetNthInput (int idx, DataObject::Pointer input)
 
virtual void SetNthOutput (int idx, DataObject::Pointer output)
 
void SetOutputNumber (int num)
 
virtual ~ProcessObject ()
 
- Protected Member Functions inherited from btk::Object
 Object ()
 
 Object (const Object &toCopy)
 
virtual ~Object ()
 

Additional Inherited Members

- Protected Attributes inherited from btk::Object
unsigned long int m_Timestamp
 

Detailed Description

Interface to create a filter/process in a pipeline.

An inherited class has to implement the GenerateData() method and the MakeOutput() metod. GenerateData() is the core of the process as it compute the outputs based on the inputs and its algorithms. The method MakeOutput() is used in the SetOutputNumber() and SetNthOutput() to create newly valid output.

The following code presents the minimum required to use the pipeline principle.

* class Source : public btk::DataObject
* {
* public:
* typedef btkSharedPtr<Source> Pointer;
* static Pointer New() {return Pointer(new Source());};
* int GetValue() {return this->m_Val;};
* void SetValue(int val)
* {
* this->m_Val = val;
* this->Modified();
* };
* private:
* Source() {this->m_Val = 0;};
* int m_Val;
* };
*
* class Filter : public btk::ProcessObject
* {
* public:
* typedef btkSharedPtr<Filter> Pointer;
* static Pointer New() {return Pointer(new Filter());};
* void SetInc(int inc)
* {
* this->m_Inc = inc;
* this->Modified();
* };
* Source::Pointer GetInput() {return this->GetInput(0);};
* void SetInput(Source::Pointer input) {this->SetNthInput(0, input);};
* Source::Pointer GetOutput() {return this->GetOutput(0);};
*
* protected:
* Source::Pointer GetInput(int idx) {return static_pointer_cast<Source>(this->GetNthInput(idx));};
* Source::Pointer GetOutput(int idx) {return static_pointer_cast<Source>(this->GetNthOutput(idx));};
* {
* return Source::New();
* };
* virtual void GenerateData()
* {
* // simple algorithm : O = I + inc
* this->GetOutput()->SetValue(this->GetInput()->GetValue() + this->m_Inc);
* };
*
* private:
* Filter()
* {
* this->SetInputNumber(1);
* this->SetOutputNumber(1);
* this->m_Inc = 1;
* };
*
* int m_Inc;
* };
*
*
* int main ()
* {
* Source::Pointer src = Source::New();
* Filter::Pointer incFilt = Filter::New();
* incFilt->SetInput(src);
* Source::Pointer res = incFilt->GetOutput();
* incFilt->Update(); // same than res->Update();
* return 0;
* }
*

Member Typedef Documentation

Smart pointer associated with a const ProcessObject object.

Smart pointer associated with a ProcessObject object.

Constructor & Destructor Documentation

btk::ProcessObject::ProcessObject ( )
protected

Process constructor with zero input and output. The inherited class set the number of inputs/ouputs with the functions SetInputNumber() and SetOutputNumber().

btk::ProcessObject::~ProcessObject ( )
protectedvirtual

This destructor doesn't delete its ouptuts (which can be used as input by others process). In fact, it says that they are disconnected of their source.

Member Function Documentation

void btk::ProcessObject::GenerateData ( )
protectedpure virtual
int btk::ProcessObject::GetInputIndex ( DataObject::Pointer  input)
protected

Returns the index of the DataObject given in input. If no DataObject corresponds, then the method returns -1.

int btk::ProcessObject::GetInputNumber ( ) const
inline

Returns the number of inputs.

DataObject::Pointer btk::ProcessObject::GetNthInput ( int  idx)
protected

Gets the input at index idx or an empty Pointer if idx is out of range.

DataObject::ConstPointer btk::ProcessObject::GetNthInput ( int  idx) const
protected

Gets the input at index idx or an empty ConstPointer if idx is out of range.

DataObject::Pointer btk::ProcessObject::GetNthOutput ( int  idx)
protected

Gets the output at idx or a empty Pointer if idx is out of range.

DataObject::ConstPointer btk::ProcessObject::GetNthOutput ( int  idx) const
protected

Gets the output at idx or a empty ConstPointer if idx is out of range.

int btk::ProcessObject::GetOutputIndex ( DataObject::Pointer  output)
protected

Returns the index of the DataObject given in input. If no DataObject corresponds, then the method returns -1.

int btk::ProcessObject::GetOutputNumber ( ) const
inline

Returns the number of outputs.

int btk::ProcessObject::GetValidInputNumber ( ) const

Returns the number of inputs which are valid (i.e. not null).

bool btk::ProcessObject::IsModified ( ) const
inlineprotected

Indicates if the process is modified or not.

DataObject::Pointer btk::ProcessObject::MakeOutput ( int  idx)
protectedpure virtual
void btk::ProcessObject::Modified ( )
protectedvirtual

This method has to be called each time that the ProcessObject is modified.

Reimplemented from btk::Object.

void btk::ProcessObject::ResetState ( )

Reset the state of the process. Usefull when an exception was thrown during the generation of the data.

void btk::ProcessObject::SetInputNumber ( int  num)
protected

Sets the number of inputs.

void btk::ProcessObject::SetNthInput ( int  idx,
DataObject::Pointer  input 
)
protectedvirtual

Sets an input of the filter. If necessary, the size of inputs is increased if idx is greater or equal than the number of inputs.

void btk::ProcessObject::SetNthOutput ( int  idx,
DataObject::Pointer  output 
)
protectedvirtual

Set the output at the index idx or create a new output from the method MakeOutput() if the pointer in output is null. If necessary, the size of the outputs is increased if idx is greater or equal than the number of outputs.

void btk::ProcessObject::SetOutputNumber ( int  num)
protected

Sets the number of outputs. The outputs generated used the MakeOutput() method.

void btk::ProcessObject::Update ( )

Recursive method which 1) determines the processes to update and 2) generate the data by using the GenerateData() method.