Commit acd127d2 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] WDataSetScalar added and adapted loader and Gauss filtering module

parent b31df395
//---------------------------------------------------------------------------
//
// 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 "../common/WAssert.h"
#include "WDataSetSingle.h"
#include "WDataSetScalar.h"
WDataSetScalar::WDataSetScalar( boost::shared_ptr< WValueSetBase > newValueSet,
boost::shared_ptr< WGrid > newGrid )
: WDataSetSingle( newValueSet, newGrid )
{
WAssert( newValueSet, "No value set given." );
WAssert( newGrid, "No grid given." );
WAssert( newValueSet->size() == newGrid->size(), "Number of values unequal number of positions in grid." );
WAssert( newValueSet->order() == 0, "The value set does not contain scalars." );
}
WDataSetScalar::~WDataSetScalar()
{
}
//---------------------------------------------------------------------------
//
// 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 WDATASETSCALAR_H
#define WDATASETSCALAR_H
#include "WDataSetSingle.h"
/**
* This data set type contains scalars as values.
* \ingroup dataHandler
*/
class WDataSetScalar : public WDataSetSingle
{
public:
/**
* Constructs an instance out of an appropriate value set and a grid.
*
* \param newValueSet the scalar value set to use
* \param newGrid the grid which maps world space to the value set
*/
WDataSetScalar( boost::shared_ptr< WValueSetBase > newValueSet,
boost::shared_ptr< WGrid > newGrid );
/**
* Destroys this DataSet instance
*/
virtual ~WDataSetScalar();
protected:
private:
};
#endif // WDATASETSCALAR_H
......@@ -34,6 +34,7 @@
#include "../WSubject.h"
#include "../WDataSetSingle.h"
#include "../WDataSetVector.h"
#include "../WDataSetScalar.h"
#include "../WGrid.h"
#include "../WGridRegular3D.h"
#include "../WValueSetBase.h"
......@@ -163,6 +164,10 @@ boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
{
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetVector( newValueSet, newGrid ) );
}
else if( vDim == 1 )
{
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetScalar( newValueSet, newGrid ) );
}
else
{
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSingle( newValueSet, newGrid ) );
......
......@@ -199,7 +199,7 @@ void WMGaussFiltering::moduleMain()
}
// has the data changed?
boost::shared_ptr< WDataSetSingle > newDataSet = m_input->getData();
boost::shared_ptr< WDataSetScalar > newDataSet = m_input->getData();
bool dataChanged = ( m_dataSet != newDataSet );
if ( dataChanged || !m_dataSet )
// this condition will become true whenever the new data is different from the current one or our actual data is NULL. This handles all
......@@ -275,7 +275,7 @@ void WMGaussFiltering::moduleMain()
assert( false && "Unknown data type in Gauss Filtering module" );
}
m_output->updateData( boost::shared_ptr<WDataSetSingle>( new WDataSetSingle( newValueSet, m_dataSet->getGrid() ) ) );
m_output->updateData( boost::shared_ptr<WDataSetScalar>( new WDataSetScalar( newValueSet, m_dataSet->getGrid() ) ) );
}
// if the number of iterations is 0 -> simply set the input as output
......@@ -289,16 +289,16 @@ void WMGaussFiltering::moduleMain()
void WMGaussFiltering::connectors()
{
// initialize connectors
m_input = boost::shared_ptr<WModuleInputData<WDataSetSingle> >(
new WModuleInputData<WDataSetSingle> ( shared_from_this(), "in",
m_input = boost::shared_ptr<WModuleInputData<WDataSetScalar> >(
new WModuleInputData<WDataSetScalar> ( shared_from_this(), "in",
"The dataset to filter" ) );
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
addConnector( m_input );
// initialize connectors
m_output = boost::shared_ptr<WModuleOutputData<WDataSetSingle> >(
new WModuleOutputData<WDataSetSingle> ( shared_from_this(), "out",
m_output = boost::shared_ptr<WModuleOutputData<WDataSetScalar> >(
new WModuleOutputData<WDataSetScalar> ( shared_from_this(), "out",
"The filtered data set." ) );
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
......
......@@ -38,8 +38,10 @@
#include "../../common/math/WVector3D.h"
#include "../../dataHandler/WDataSetScalar.h"
/**
* Gauss filtering for WDataSetSingle
* Gauss filtering for WDataSetScalar
*
* \problem It works only on double value sets so far.
* \reminder The boundary values will not be touched an considered to be zero.
......@@ -141,7 +143,7 @@ private:
* \return the filtered array of values.
*/
template< typename T > std::vector< double > filterField( boost::shared_ptr< WValueSet< T > > vals,
boost::shared_ptr<WGridRegular3D> grid,
boost::shared_ptr< WGridRegular3D > grid,
boost::shared_ptr< WProgress > prog );
/**
......@@ -155,8 +157,8 @@ private:
template< typename T > boost::shared_ptr< WValueSet< double > > iterativeFilterField( boost::shared_ptr< WValueSet< T > > vals,
unsigned int iterations );
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
boost::shared_ptr< WModuleOutputData< WDataSetSingle > > m_output; //!< The only output of this filter module.
boost::shared_ptr< WDataSetSingle > m_dataSet; //!< Pointer providing access to the treated data set in the whole module.
boost::shared_ptr< WModuleInputData< WDataSetScalar > > m_input; //!< Input connector required by this module.
boost::shared_ptr< WModuleOutputData< WDataSetScalar > > m_output; //!< The only output of this filter module.
boost::shared_ptr< WDataSetScalar > m_dataSet; //!< Pointer providing access to the treated data set in the whole module.
};
#endif // WMGAUSSFILTERING_H
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