25 #ifndef WTHREADEDPERVOXELOPERATION_H
26 #define WTHREADEDPERVOXELOPERATION_H
31 #include <boost/array.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/function.hpp>
35 #include "../common/WException.h"
36 #include "../common/WThreadedJobs.h"
37 #include "../common/WSharedObject.h"
38 #include "../common/WSharedSequenceContainer.h"
39 #include "WDataSetSingle.h"
40 #include "WDataSetScalar.h"
41 #include "WValueSet.h"
42 #include "WDataHandlerEnums.h"
68 template<
typename Value_T, std::
size_t numValues,
typename Output_T, std::
size_t numOutputs >
91 typedef boost::function< OutTransmitType const ( TransmitType const& ) >
FunctionType;
112 virtual void compute( boost::shared_ptr< ValueSetType const > input, std::size_t voxelNum );
119 boost::shared_ptr< WDataSetSingle >
getResult();
138 template<
typename Value_T, std::
size_t numValues,
typename Output_T, std::
size_t numOutputs >
140 boost::shared_ptr< WDataSetSingle const > dataset,
147 throw WException( std::string(
"No input dataset." ) );
149 if( !dataset->getValueSet() )
151 throw WException( std::string(
"The input dataset has no valueset." ) );
153 if( !dataset->getGrid() )
155 throw WException( std::string(
"The input dataset has no grid." ) );
157 if( dataset->getValueSet()->order() > 1 )
159 throw WException( std::string(
"An order of 2 or more is currently not supported." ) );
161 if( dataset->getValueSet()->dimension() != numValues )
163 throw WException( std::string(
"Invalid valueset dimension." ) );
167 throw WException( std::string(
"No valid function provided." ) );
175 catch( std::exception
const& e )
180 m_grid = dataset->getGrid();
183 template<
typename Value_T, std::
size_t numValues,
typename Output_T, std::
size_t numOutputs >
188 template<
typename Value_T, std::
size_t numValues,
typename Output_T, std::
size_t numOutputs >
190 std::size_t voxelNum )
192 TransmitType t = input->getSubArray( voxelNum * numValues, numValues );
194 for( std::size_t k = 0; k < numOutputs; ++k )
196 ( *m_output )[ voxelNum * numOutputs + k ] = o[ k ];
200 template<
typename Value_T, std::
size_t numValues,
typename Output_T, std::
size_t numOutputs >
203 boost::shared_ptr< OutValueSetType > values;
207 values = boost::shared_ptr< OutValueSetType >(
new OutValueSetType( 0, 1, m_output,
209 return boost::shared_ptr< WDataSetScalar >(
new WDataSetScalar( values, m_grid ) );
211 values = boost::shared_ptr< OutValueSetType >(
new OutValueSetType( 1, numOutputs, m_output,
213 return boost::shared_ptr< WDataSetSingle >(
new WDataSetSingle( values, m_grid ) );
217 #endif // WTHREADEDPERVOXELOPERATION_H