Commit 27407a27 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD #252] this new module contains the fiber filter feature from fiberDisplay...

[ADD #252] this new module contains the fiber filter feature from fiberDisplay making fiberDisplay completely obsolete.
parent 90387f13
......@@ -36,14 +36,22 @@
#include "WKdTree.h"
/**
* Adaptor class between the roi manager and the fiber display
*/
class WFiberSelector // NOLINT
{
public:
/**
* Fiber selector pointer
*/
typedef boost::shared_ptr< WFiberSelector > SPtr;
/**
* Const fiber selector pointer.
*/
typedef boost::shared_ptr< const WFiberSelector > ConstSPtr;
/**
* constructor
* \param fibers pointer to the datset this selector works on
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "core/kernel/WKernel.h"
#include "WMFiberFilterROI.h"
// This line is needed by the module loader to actually find your module. You need to add this to your module too. Do NOT add a ";" here.
W_LOADABLE_MODULE( WMFiberFilterROI )
WMFiberFilterROI::WMFiberFilterROI():
WModule()
{
// Init
}
WMFiberFilterROI::~WMFiberFilterROI()
{
// Cleanup!
}
boost::shared_ptr< WModule > WMFiberFilterROI::factory() const
{
return boost::shared_ptr< WModule >( new WMFiberFilterROI() );
}
const std::string WMFiberFilterROI::getName() const
{
// Specify your module name here. This name must be UNIQUE!
return "Fiber Filter ROI";
}
const std::string WMFiberFilterROI::getDescription() const
{
// Specify your module description here. Be detailed. This text is read by the user.
return "This module provides fiber data filtered by the current ROI configuration.";
}
void WMFiberFilterROI::connectors()
{
m_input = WModuleInputData< WDataSetFibers >::createAndAdd( shared_from_this(), "in", "The dataset to filter" );
m_output = WModuleOutputData < WDataSetFibers >::createAndAdd( shared_from_this(), "out", "The filtered dataset" );
// call WModule's initialization
WModule::connectors();
}
void WMFiberFilterROI::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_aTrigger = m_properties->addProperty( "Update", "Trigger an update of your result data.", WPVBaseTypes::PV_TRIGGER_READY,
m_propCondition );
WModule::properties();
}
void WMFiberFilterROI::moduleMain()
{
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
// Signal ready state. Now your module can be connected by the container, which owns the module.
ready();
waitRestored();
// main loop
while( !m_shutdownFlag() )
{
m_moduleState.wait();
// woke up since the module is requested to finish
if( m_shutdownFlag() )
{
break;
}
// Remember the above criteria. We now need to check if the data is valid. After a connect-update, it might be NULL.
boost::shared_ptr< WDataSetFibers > dataSet = m_input->getData();
bool dataValid = ( dataSet );
bool dataChanged = dataSet != m_fibers;
// do something with the data
if( dataChanged )
{
m_fibers = dataSet;
if( dataValid )
{
// The data is valid and we received an update. The data is not NULL but may be the same as in previous loops.
debugLog() << "Received new data. Creating new selector.";
m_fiberSelector = WFiberSelector::SPtr( new WFiberSelector( m_fibers ) );
debugLog() << "Data changed. Recalculating output.";
updateOutput();
}
else
{
m_fiberSelector.reset();
}
}
if( m_aTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
updateOutput();
m_aTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false );
}
}
}
void WMFiberFilterROI::updateOutput()
{
// target memory
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
boost::shared_ptr< std::vector< float > >vertices = boost::shared_ptr< std::vector< float > >( new std::vector< float >() );
boost::shared_ptr< std::vector< size_t > > lineStartIndexes = boost::shared_ptr< std::vector< size_t > > ( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > lineLengths = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > verticesReverse = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
boost::shared_ptr< WProgress > progress1 = boost::shared_ptr< WProgress >( new WProgress( "Filtering", active->size() ) );
m_progress->addSubProgress( progress1 );
size_t countLines = 0;
for( size_t l = 0; l < active->size(); ++l )
{
if( ( *active )[l] )
{
size_t pc = m_fibers->getLineStartIndexes()->at( l ) * 3;
lineStartIndexes->push_back( vertices->size() / 3 );
lineLengths->push_back( m_fibers->getLineLengths()->at( l ) );
for( size_t j = 0; j < m_fibers->getLineLengths()->at( l ); ++j )
{
vertices->push_back( m_fibers->getVertices()->at( pc ) );
++pc;
vertices->push_back( m_fibers->getVertices()->at( pc ) );
++pc;
vertices->push_back( m_fibers->getVertices()->at( pc ) );
++pc;
verticesReverse->push_back( countLines );
}
++countLines;
}
}
boost::shared_ptr< WDataSetFibers> newOutput( new WDataSetFibers( vertices, lineStartIndexes, lineLengths, verticesReverse,
m_fibers->getBoundingBox() ) );
m_output->updateData( newOutput );
progress1->finish();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMFIBERFILTERROI_H
#define WMFIBERFILTERROI_H
#include <string>
#include "core/dataHandler/WDataSetFibers.h"
#include "core/kernel/WFiberSelector.h"
#include "core/kernel/WModule.h"
#include "core/kernel/WModuleInputData.h"
#include "core/kernel/WModuleOutputData.h"
/**
* This module is intended to allow the user to filter a fiber dataset using the current ROI config
*
* \ingroup modules
*/
class WMFiberFilterROI: public WModule
{
public:
/**
* Default constructor.
*/
WMFiberFilterROI();
/**
* Destructor.
*/
virtual ~WMFiberFilterROI();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description to module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
private:
/**
* An input for the fiber data.
*/
boost::shared_ptr< WModuleInputData< WDataSetFibers > > m_input;
/**
* The output connector for the filtered data.
*/
boost::shared_ptr< WModuleOutputData< WDataSetFibers > > m_output;
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
/**
* Trigger output update
*/
WPropTrigger m_aTrigger;
/**
* Selector for the current fiber data or NULL of none.
*/
WFiberSelector::SPtr m_fiberSelector;
/**
* Fiber data.
*/
WDataSetFibers::SPtr m_fibers;
/**
* Updates the output using the ROI configuration.
*/
void updateOutput();
};
#endif // WMFIBERFILTERROI_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
// Provide additional material and descriptions for your module. You can
// provide this for multiple modules if you like.
// NOTE: everything but the module name is optional, even if this makes no
// sense at all.
// This defines some properties of the module "Template". This must
// match the name specified in WMTemplate::getName().
"Fiber Filter ROI"
{
// Provide an icon. If the icon exists, it overrides the one provided by your
// getXPMIcon method. This path is relative to your module's resource directory.
icon="WMFiberFilterROI.png";
// Where to find the module?
website = "http://www.openwalnut.org";
// Provide a description, If you do so, this description overrides the one
// provided by your getDescription method.
// HINT: multi-line strings are not supported. Please provide long texts in
// one line.
description = "This module provides fiber daza filtered by the current ROI configuration.";
// Provide a list of authors. These authors can have further information associated with them.
author = "OpenWalnut Project";
// Provide author information. Especially a contact address is very handy.
// This associates some URL and Mail contact info to "OpenWalnut Project".
"OpenWalnut Project"
{
url="http://www.openwalnut.org";
email="contact@openwalnut.org";
what="Design, Development and Bug fixing";
};
};
......@@ -13,6 +13,7 @@ ADD_MODULE( dataTypeConversion )
ADD_MODULE( deterministicFTMori )
ADD_MODULE( effectiveConnectivityCluster )
ADD_MODULE( eigenSystem )
ADD_MODULE( fiberFilterROI )
ADD_MODULE( fiberParameterColoring )
ADD_MODULE( fiberSelection )
ADD_MODULE( fiberTransform )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment