1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
25
#ifndef WITKIMAGECONVERSION_TEST_H
26
#define WITKIMAGECONVERSION_TEST_H
30
#include <boost/shared_ptr.hpp>
32
#include <cxxtest/TestSuite.h>
34
#include "../../common/WLogger.h"
35
#include "../WITKImageConversion.h"
38
* Test functionality of WITKConversion class.
40
class WITKImageConversionTest : public CxxTest::TestSuite
44
* Setup logger and other stuff for each test.
52
* Converting a dataset into an itk image and then converting it back into a
53
* dataset should yield the same dataset.
59
boost::shared_ptr< std::vector< int > > values( new std::vector< int >( 27, 0 ) );
60
for( int k = 0; k < 27; ++k )
62
( *values )[ k ] = 27 - k;
64
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3 ) );
65
boost::shared_ptr< WValueSet< int > > v( new WValueSet< int >( 0, 1, values, W_DT_SIGNED_INT ) );
66
boost::shared_ptr< WDataSetScalar > ds( new WDataSetScalar( v, g ) );
68
itk::Image< int, 3 >::Pointer i = makeImageFromDataSet< int >( ds );
69
boost::shared_ptr< WDataSetScalar > newds = makeDataSetFromImage< int >( i );
71
TS_ASSERT_SAME_DATA( boost::dynamic_pointer_cast< WValueSet< int > >( ds->getValueSet() )->rawData(),
72
boost::dynamic_pointer_cast< WValueSet< int > >( newds->getValueSet() )->rawData(), sizeof( int ) * 27 );
77
#endif // WITKIMAGECONVERSION_TEST_H