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

[ADD] WDataSetVector added and adapted NIfTI loader and vectorplot module

parent 37123b17
//---------------------------------------------------------------------------
//
// 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 "WDataSetVector.h"
WDataSetVector::WDataSetVector( 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() == 1, "The value set does not contain vectors." );
}
WDataSetVector::~WDataSetVector()
{
}
//---------------------------------------------------------------------------
//
// 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 WDATASETVECTOR_H
#define WDATASETVECTOR_H
#include "WDataSetSingle.h"
/**
* This data set type contains vectors as values.
* \ingroup dataHandler
*/
class WDataSetVector : public WDataSetSingle
{
public:
/**
* Constructs an instance out of an appropriate value set and a grid.
*
* \param newValueSet the vector value set to use
* \param newGrid the grid which maps world space to the value set
*/
WDataSetVector( boost::shared_ptr< WValueSetBase > newValueSet,
boost::shared_ptr< WGrid > newGrid );
/**
* Destroys this DataSet instance
*/
virtual ~WDataSetVector();
protected:
private:
};
#endif // WDATASETVECTOR_H
......@@ -33,6 +33,7 @@
#include "../WDataSet.h"
#include "../WSubject.h"
#include "../WDataSetSingle.h"
#include "../WDataSetVector.h"
#include "../WGrid.h"
#include "../WGridRegular3D.h"
#include "../WValueSetBase.h"
......@@ -157,7 +158,15 @@ boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
columns, rows, frames, header->dx, header->dy, header->dz ) );
}
boost::shared_ptr< WDataSet > newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSingle( newValueSet, newGrid ) );
boost::shared_ptr< WDataSet > newDataSet;
if( vDim == 3 )
{
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetVector( newValueSet, newGrid ) );
}
else
{
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSingle( newValueSet, newGrid ) );
}
newDataSet->setFileName( m_fileName );
return newDataSet;
......
......@@ -221,11 +221,26 @@ std::set< boost::shared_ptr< WModule > > WModuleFactory::getCompatiblePrototypes
// get offered outputs
std::set<boost::shared_ptr<WModuleOutputConnector> > cons = module->getOutputConnectors();
// First add all modules with no input connector.
for( std::set< boost::shared_ptr< WModule > >::iterator listIter = m_prototypes.begin(); listIter != m_prototypes.end(); ++listIter )
{
// get connectors of this prototype
std::set<boost::shared_ptr<WModuleInputConnector> > pcons = ( *listIter )->getInputConnectors();
if( pcons.size() == 0 )
{
compatibles.insert( *listIter );
}
}
// return early if we have no output connector, because the modules with no input connector
// are already added at this point.
if( cons.size() == 0 )
{
// in this case return the empty list
return compatibles;
}
// TODO(ebaum): see ticket #178 for this
if ( cons.size() > 1 )
{
......
......@@ -69,8 +69,8 @@ const std::string WMVectorPlot::getDescription() const
void WMVectorPlot::connectors()
{
m_input = boost::shared_ptr< WModuleInputData < WDataSetSingle > >(
new WModuleInputData< WDataSetSingle >( shared_from_this(), "in", "The dataset to display" )
m_input = boost::shared_ptr< WModuleInputData < WDataSetVector > >(
new WModuleInputData< WDataSetVector >( shared_from_this(), "in", "The dataset to display" )
);
addConnector( m_input );
......@@ -128,7 +128,7 @@ void WMVectorPlot::moduleMain()
break;
}
boost::shared_ptr< WDataSetSingle > newDataSet = m_input->getData();
boost::shared_ptr< WDataSetVector > newDataSet = m_input->getData();
bool dataChanged = ( m_dataSet != newDataSet );
bool dataValid = ( newDataSet );
......
......@@ -30,6 +30,7 @@
#include <osg/Geode>
#include "../../dataHandler/WDataSetVector.h"
#include "../../graphicsEngine/WShader.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
......@@ -118,12 +119,12 @@ private:
/**
* An input connector used to get datasets from other modules. The connection management between connectors must not be handled by the module.
*/
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input;
boost::shared_ptr< WModuleInputData< WDataSetVector > > m_input;
/**
* This is a pointer to the dataset the module is currently working on.
*/
boost::shared_ptr< WDataSetSingle > m_dataSet;
boost::shared_ptr< WDataSetVector > m_dataSet;
/**
* list of positions to plot vectors on, this will come from a selection tool class
......
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