Commit 443fd10b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added clone functionality to datasets to make the datasetManipulator output work properly.

parent 140d95e0
......@@ -42,6 +42,20 @@ WDataSetDTI::~WDataSetDTI()
{
}
WDataSetSingle::SPtr WDataSetDTI::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetDTI( newValueSet, getGrid() ) );
}
WDataSetSingle::SPtr WDataSetDTI::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetDTI( getValueSet(), newGrid ) );
}
WDataSetSingle::SPtr WDataSetDTI::clone() const
{
return WDataSetSingle::SPtr( new WDataSetDTI( getValueSet(), getGrid() ) );
}
wmath::WTensorSym< 2, 3, float > WDataSetDTI::getTensor( size_t index ) const
{
......
......@@ -50,6 +50,34 @@ public:
*/
~WDataSetDTI();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* Retrieves the i'th tensor.
*
......
......@@ -55,6 +55,21 @@ WDataSetRawHARDI::~WDataSetRawHARDI()
{
}
WDataSetSingle::SPtr WDataSetRawHARDI::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetRawHARDI( newValueSet, getGrid(), m_gradients, getDiffusionBValue() ) );
}
WDataSetSingle::SPtr WDataSetRawHARDI::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetRawHARDI( getValueSet(), newGrid, m_gradients, getDiffusionBValue() ) );
}
WDataSetSingle::SPtr WDataSetRawHARDI::clone() const
{
return WDataSetSingle::SPtr( new WDataSetRawHARDI( getValueSet(), getGrid(), m_gradients, getDiffusionBValue() ) );
}
boost::shared_ptr< WPrototyped > WDataSetRawHARDI::getPrototype()
{
if ( !m_prototype )
......
......@@ -66,6 +66,34 @@ public:
*/
virtual ~WDataSetRawHARDI();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* Returns a prototype instantiated with the true type of the deriving class.
*
......
......@@ -55,6 +55,21 @@ WDataSetScalar::~WDataSetScalar()
{
}
WDataSetSingle::SPtr WDataSetScalar::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetScalar( newValueSet, getGrid() ) );
}
WDataSetSingle::SPtr WDataSetScalar::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetScalar( getValueSet(), newGrid ) );
}
WDataSetSingle::SPtr WDataSetScalar::clone() const
{
return WDataSetSingle::SPtr( new WDataSetScalar( getValueSet(), getGrid() ) );
}
double WDataSetScalar::getMax() const
{
return m_valueSet->getMaximumValue();
......
......@@ -62,6 +62,34 @@ public:
*/
virtual ~WDataSetScalar();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* Returns the largest of the scalars stored in the data set
*/
......
......@@ -77,6 +77,21 @@ WDataSetSingle::~WDataSetSingle()
{
}
WDataSetSingle::SPtr WDataSetSingle::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetSingle( newValueSet, getGrid() ) );
}
WDataSetSingle::SPtr WDataSetSingle::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetSingle( getValueSet(), newGrid ) );
}
WDataSetSingle::SPtr WDataSetSingle::clone() const
{
return WDataSetSingle::SPtr( new WDataSetSingle( getValueSet(), getGrid() ) );
}
boost::shared_ptr< WValueSetBase > WDataSetSingle::getValueSet() const
{
return m_valueSet;
......@@ -90,7 +105,7 @@ boost::shared_ptr< WGrid > WDataSetSingle::getGrid() const
bool WDataSetSingle::isTexture() const
{
// TODO(all): this is not sophisticated. This should depend on type of data (vectors? scalars? tensors?)
return true;
return m_texture;
}
boost::shared_ptr< WDataTexture3D > WDataSetSingle::getTexture()
......
......@@ -48,6 +48,17 @@ class WDataTexture3D_2;
class OWDATAHANDLER_EXPORT WDataSetSingle : public WDataSet // NOLINT
{
public:
/**
* Convenience typedef for a boost::shared_ptr
*/
typedef boost::shared_ptr< WDataSetSingle > SPtr;
/**
* Convenience typedef for a boost::shared_ptr; const
*/
typedef boost::shared_ptr< const WDataSetSingle > ConstSPtr;
/**
* Constructs an instance out of a value set and a grid.
*
......@@ -67,6 +78,34 @@ public:
*/
virtual ~WDataSetSingle();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* \return Reference to its WValueSet
*/
......
......@@ -51,6 +51,21 @@ WDataSetSphericalHarmonics::~WDataSetSphericalHarmonics()
{
}
WDataSetSingle::SPtr WDataSetSphericalHarmonics::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetSphericalHarmonics( newValueSet, getGrid() ) );
}
WDataSetSingle::SPtr WDataSetSphericalHarmonics::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetSphericalHarmonics( getValueSet(), newGrid ) );
}
WDataSetSingle::SPtr WDataSetSphericalHarmonics::clone() const
{
return WDataSetSingle::SPtr( new WDataSetSphericalHarmonics( getValueSet(), getGrid() ) );
}
boost::shared_ptr< WPrototyped > WDataSetSphericalHarmonics::getPrototype()
{
if ( !m_prototype )
......
......@@ -62,6 +62,34 @@ public:
*/
virtual ~WDataSetSphericalHarmonics();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* Returns a prototype instantiated with the true type of the deriving class.
*
......
......@@ -53,6 +53,21 @@ WDataSetVector::~WDataSetVector()
{
}
WDataSetSingle::SPtr WDataSetVector::clone( boost::shared_ptr< WValueSetBase > newValueSet ) const
{
return WDataSetSingle::SPtr( new WDataSetVector( newValueSet, getGrid() ) );
}
WDataSetSingle::SPtr WDataSetVector::clone( boost::shared_ptr< WGrid > newGrid ) const
{
return WDataSetSingle::SPtr( new WDataSetVector( getValueSet(), newGrid ) );
}
WDataSetSingle::SPtr WDataSetVector::clone() const
{
return WDataSetSingle::SPtr( new WDataSetVector( getValueSet(), getGrid() ) );
}
boost::shared_ptr< WPrototyped > WDataSetVector::getPrototype()
{
if ( !m_prototype )
......
......@@ -55,6 +55,34 @@ public:
*/
virtual ~WDataSetVector();
/**
* Creates a copy (clone) of this instance but allows to change the valueset. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newValueSet the new valueset.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WValueSetBase > newValueSet ) const;
/**
* Creates a copy (clone) of this instance but allows to change the grid. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \param newGrid the new grid.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone( boost::shared_ptr< WGrid > newGrid ) const;
/**
* Creates a copy (clone) of this instance. Unlike copy construction, this is a very useful function if you
* want to keep the dynamic type of your dataset even if you just have a WDataSetSingle.
*
* \return the clone
*/
virtual WDataSetSingle::SPtr clone() const;
/**
* Returns a prototype instantiated with the true type of the deriving class.
*
......
......@@ -422,7 +422,10 @@ void WMDatasetManipulator::moduleMain()
m_grid->getNbCoordsY(),
m_grid->getNbCoordsZ(),
*m_transform ) );
m_output->updateData( boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( m_dataSet->getValueSet(), newGrid ) ) );
// NOTE: we NEED to use clone here as we need to keep the dynamic type of the input data set.
// This means: clone a WDataSetSingle which was constructed as WDataSetVector -> result is a WDataSetSingle which was constructed
// as WDataSetVector too.
m_output->updateData( m_dataSet->clone( newGrid ) );
}
boost::shared_ptr< WDataSetSingle > newDataSet = m_input->getData();
......
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