This filter creates mitk::PointSet objects from mitk::NavigaitionData objects. More...
#include <mitkNavigationDataToPointSetFilter.h>
Public Types | |
enum | OperationMode { Mode3D, Mode3DMean, Mode4D } |
There are two different operation modes. More... | |
typedef NavigationDataToPointSetFilter | Self |
typedef PointSetSource | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | SetRingBufferSize (unsigned int _arg) |
Sets the size for the ring buffer. | |
virtual void | GenerateData () |
filter execute method | |
virtual void | SetInput (const mitk::NavigationData *NavigationData) |
Sets one input NavigationData. | |
virtual void | SetInput (unsigned int idx, const NavigationData *nd) |
Sets the input NavigationData at a specific index. | |
const mitk::NavigationData * | GetInput () |
Returns the input of this filter. | |
const mitk::NavigationData * | GetInput (unsigned int idx) |
Returns the input number idx of this filter. | |
virtual void | SetOperationMode (OperationMode mode) |
Sets the mode of this filter. | |
virtual OperationMode | GetOperationMode () const |
returns the mode of this filter. | |
void | GenerateOutputInformation () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
NavigationDataToPointSetFilter () | |
empty implementation to prevent calling of the superclass method that would try to copy information from the input NavigationData to the output PointSet, which makes no sense! | |
virtual | ~NavigationDataToPointSetFilter () |
virtual void | GenerateDataMode3D () |
Generates the output for Mode3D. | |
virtual void | GenerateDataMode3DMean () |
Generates the output for Mode3DMean. | |
virtual void | GenerateDataMode4D () |
Generates the output for Mode4D. | |
virtual void | CreateOutputsForAllInputs () |
create output objects according to OperationMode for all inputs | |
Protected Attributes | |
OperationMode | m_OperationMode |
Stores the mode. See enum OperationMode. | |
unsigned int | m_RingBufferSize |
Stores the ringbuffer size. | |
unsigned int | m_CurrentTimeStep |
Indicates the current timestamp. |
This filter creates mitk::PointSet objects from mitk::NavigaitionData objects.
Documentation
This filter has two modes that can be set with SetOperationMode().
Definition at line 39 of file mitkNavigationDataToPointSetFilter.h.
typedef itk::SmartPointer<const Self> mitk::NavigationDataToPointSetFilter::ConstPointer |
Definition at line 42 of file mitkNavigationDataToPointSetFilter.h.
typedef itk::SmartPointer<Self> mitk::NavigationDataToPointSetFilter::Pointer |
Definition at line 42 of file mitkNavigationDataToPointSetFilter.h.
Definition at line 42 of file mitkNavigationDataToPointSetFilter.h.
Definition at line 42 of file mitkNavigationDataToPointSetFilter.h.
There are two different operation modes.
Documentation
Definition at line 53 of file mitkNavigationDataToPointSetFilter.h.
{ Mode3D, Mode3DMean, Mode4D };
mitk::NavigationDataToPointSetFilter::NavigationDataToPointSetFilter | ( | ) | [protected] |
empty implementation to prevent calling of the superclass method that would try to copy information from the input NavigationData to the output PointSet, which makes no sense!
Definition at line 24 of file mitkNavigationDataToPointSetFilter.cpp.
References m_CurrentTimeStep, m_OperationMode, m_RingBufferSize, and Mode3D.
{ this->SetNumberOfRequiredInputs(1); m_OperationMode = Mode3D; m_CurrentTimeStep = 0; m_RingBufferSize = 50; //the default ring buffer size }
mitk::NavigationDataToPointSetFilter::~NavigationDataToPointSetFilter | ( | ) | [protected, virtual] |
Definition at line 34 of file mitkNavigationDataToPointSetFilter.cpp.
{ }
void mitk::NavigationDataToPointSetFilter::CreateOutputsForAllInputs | ( | ) | [protected, virtual] |
create output objects according to OperationMode for all inputs
Definition at line 89 of file mitkNavigationDataToPointSetFilter.cpp.
{ switch (m_OperationMode) { case Mode3D: this->SetNumberOfOutputs(this->GetNumberOfInputs()); // create one pointset output for each navigation data input break; case Mode3DMean: this->SetNumberOfOutputs(this->GetNumberOfInputs()); // create one pointset output for each navigation data input break; case Mode4D: this->SetNumberOfOutputs(1); // create just one output pointset that will contain all input navigation data objects break; default: break; } for (unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx) if (this->GetOutput(idx) == NULL) { DataObjectPointer newOutput = this->MakeOutput(idx); this->SetNthOutput(idx, newOutput); } this->Modified(); }
void mitk::NavigationDataToPointSetFilter::GenerateData | ( | ) | [virtual] |
filter execute method
Definition at line 38 of file mitkNavigationDataToPointSetFilter.cpp.
{ switch (m_OperationMode) { case Mode3D: GenerateDataMode3D(); break; case Mode3DMean: GenerateDataMode3DMean(); break; case Mode4D: GenerateDataMode4D(); break; default: break; } }
void mitk::NavigationDataToPointSetFilter::GenerateDataMode3D | ( | ) | [protected, virtual] |
Generates the output for Mode3D.
Definition at line 116 of file mitkNavigationDataToPointSetFilter.cpp.
References mitk::NavigationData::GetPosition(), mitk::PointSet::GetSize(), mitk::PointSet::InsertPoint(), and mitk::NavigationData::IsDataValid().
{ for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i) // for each output PointSet { mitk::PointSet* output = this->GetOutput(i); assert(output); const mitk::NavigationData* input = this->GetInput(i); assert(input); if (input->IsDataValid() == false) // don't add point if input is invalid continue; mitk::PointSet::PointType pos = input->GetPosition(); // NavigationData::PositionType must be compatible with PointSet::PointType! output->InsertPoint(output->GetSize(), pos); // add point with current position of input NavigationData to the output PointSet // \TODO: regard ringbuffersize } }
void mitk::NavigationDataToPointSetFilter::GenerateDataMode3DMean | ( | ) | [protected, virtual] |
Generates the output for Mode3DMean.
read n times all connected inputs and sum them into outputs. Finish with dividing each output by n.
Definition at line 135 of file mitkNavigationDataToPointSetFilter.cpp.
References mitk::PointSet::GetPoint(), mitk::NavigationData::GetPosition(), mitk::PointSet::InsertPoint(), mitk::NavigationData::IsDataValid(), MBI_INFO, and mitk::PointSet::SetPoint().
{ //make it editable through a Set method if needed const unsigned int numberforMean = 100; //check for outputs and inputs for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i) // for each output PointSet; change through pointsets to collect all navigation data in order { assert(this->GetOutput(i)); assert(this->GetInput(i)); } //vector of counters for each output std::vector<unsigned int> counterVec(this->GetNumberOfOutputs()); //use first Output to get the size of the pointsets. All output pointssets have to have the same size! mitk::PointSet::PointIdentifier newPointId = this->GetOutput(0)->GetSize(); for (unsigned int counter = 0; counter < numberforMean; counter++) { for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i) // for each output PointSet; change through pointsets to collect all navigation data in order { mitk::PointSet* output = this->GetOutput(i); const mitk::NavigationData* input = this->GetInput(i); if (input->IsDataValid() == false) // don't add point if input is invalid continue;//do not store mitk::PointSet::PointType pos; if (counter == 0) //first Element must be inserted { //no need to call an update pos = input->GetPosition(); // NavigationData::PositionType must be compatible with PointSet::PointType! output->InsertPoint(newPointId, pos); // add point with current position of input NavigationData to the output PointSet counterVec[i]++; } else { //manually call an update to track new positions this->ProcessObject::GetInput(i)->Update(); pos = input->GetPosition(); // NavigationData::PositionType must be compatible with PointSet::PointType! //calculate the summ of the old position and the current coordinate mitk::Vector3D vec; vec.SetVnlVector(pos.GetVnlVector()); mitk::PointSet::PointType oPoint = output->GetPoint(newPointId); oPoint += vec;//summ up output->SetPoint(newPointId, oPoint); //store in counterVec to know how many have been added (and not skipped because of invalid data) counterVec[i]++; } // \TODO: regard ringbuffersize } //wait some time to be sure, that we receive new coordinates itksys::SystemTools::Delay(25); } //divide with counterVec for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i) // for each output PointSet; change through pointsets to collect all navigation data in order { mitk::PointSet* output = this->GetOutput(i); mitk::PointSet::PointType oPoint = output->GetPoint(newPointId); for (unsigned int index = 0; index < oPoint.Size(); index++) oPoint[index] = oPoint[index] / counterVec[i]; output->SetPoint(newPointId, oPoint); MBI_INFO << "For output # " << i << " " << counterVec[i] << " tracked positions used for averaging"; } }
void mitk::NavigationDataToPointSetFilter::GenerateDataMode4D | ( | ) | [protected, virtual] |
Generates the output for Mode4D.
Definition at line 206 of file mitkNavigationDataToPointSetFilter.cpp.
References mitk::NavigationData::GetPosition(), and mitk::PointSet::SetPoint().
{ mitk::PointSet* output = GetOutput(); assert(output); for (unsigned int index = 0; index < this->GetNumberOfInputs(); index++) { const mitk::NavigationData* nd = GetInput(index); assert(nd); mitk::NavigationData::PositionType point = nd->GetPosition(); //get the position output->SetPoint( index, point, m_CurrentTimeStep); //store it in the pointset always at the current time step } if (m_CurrentTimeStep == m_RingBufferSize - 1) // update ring buffer index m_CurrentTimeStep = 0; else m_CurrentTimeStep++; }
void mitk::NavigationDataToPointSetFilter::GenerateOutputInformation | ( | void | ) | [inline] |
Definition at line 110 of file mitkNavigationDataToPointSetFilter.h.
{};
virtual const char* mitk::NavigationDataToPointSetFilter::GetClassName | ( | ) | const [virtual] |
const mitk::NavigationData * mitk::NavigationDataToPointSetFilter::GetInput | ( | unsigned int | idx ) |
Returns the input number idx of this filter.
Definition at line 81 of file mitkNavigationDataToPointSetFilter.cpp.
{ if (this->GetNumberOfInputs() < 1) return NULL; return static_cast<const NavigationData*>(this->ProcessObject::GetInput(idx)); }
const mitk::NavigationData * mitk::NavigationDataToPointSetFilter::GetInput | ( | void | ) |
Returns the input of this filter.
Definition at line 73 of file mitkNavigationDataToPointSetFilter.cpp.
{ if (this->GetNumberOfInputs() < 1) return NULL; return static_cast<const NavigationData*>(this->ProcessObject::GetInput(0)); }
virtual OperationMode mitk::NavigationDataToPointSetFilter::GetOperationMode | ( | ) | const [virtual] |
returns the mode of this filter.
See OperationMode for the behavior in the different modes
static Pointer mitk::NavigationDataToPointSetFilter::New | ( | ) | [static] |
Reimplemented from mitk::PointSetSource.
Referenced by mitkNavigationDataToPointSetFilterTest(), QmitkIGTExampleView::OnPlayingToggle(), QmitkIGTExampleView::OnTestNavigation(), and QmitkIGTRecorderView::SetupIGTPipeline().
void mitk::NavigationDataToPointSetFilter::SetInput | ( | unsigned int | idx, |
const NavigationData * | nd | ||
) | [virtual] |
Sets the input NavigationData at a specific index.
Definition at line 65 of file mitkNavigationDataToPointSetFilter.cpp.
{ // Process object is not const-correct so the const_cast is required here this->ProcessObject::SetNthInput(idx, const_cast<NavigationData*>(nd)); this->CreateOutputsForAllInputs(); }
void mitk::NavigationDataToPointSetFilter::SetInput | ( | const mitk::NavigationData * | NavigationData ) | [virtual] |
Sets one input NavigationData.
Definition at line 57 of file mitkNavigationDataToPointSetFilter.cpp.
{ // Process object is not const-correct so the const_cast is required here this->ProcessObject::SetNthInput(0, const_cast<NavigationData*>(nd)); this->CreateOutputsForAllInputs(); }
void mitk::NavigationDataToPointSetFilter::SetOperationMode | ( | OperationMode | mode ) | [virtual] |
Sets the mode of this filter.
See OperationMode for the behavior in the different modes A call to this method will change the number of outputs of the filter. After calling this method, all previously acquired pointers to outputs are invalid Always set the operation mode first, then get the outputs with GetOutput()
Definition at line 224 of file mitkNavigationDataToPointSetFilter.cpp.
{ m_OperationMode = mode; //Initialize 4D Mode if (m_OperationMode == Mode4D) m_CurrentTimeStep = 0; this->Modified(); this->CreateOutputsForAllInputs(); }
virtual void mitk::NavigationDataToPointSetFilter::SetRingBufferSize | ( | unsigned int | _arg ) | [virtual] |
Sets the size for the ring buffer.
Documentation The size determines the maximum number of timesteps in 4D mode and the number of points in 3D mode of the output PointSet
unsigned int mitk::NavigationDataToPointSetFilter::m_CurrentTimeStep [protected] |
Indicates the current timestamp.
Definition at line 141 of file mitkNavigationDataToPointSetFilter.h.
Referenced by NavigationDataToPointSetFilter().
Stores the mode. See enum OperationMode.
Definition at line 139 of file mitkNavigationDataToPointSetFilter.h.
Referenced by NavigationDataToPointSetFilter().
unsigned int mitk::NavigationDataToPointSetFilter::m_RingBufferSize [protected] |
Stores the ringbuffer size.
Definition at line 140 of file mitkNavigationDataToPointSetFilter.h.
Referenced by NavigationDataToPointSetFilter().