25 #ifndef WDATASETSCALAR_TEST_H
26 #define WDATASETSCALAR_TEST_H
30 #include <cxxtest/TestSuite.h>
32 #include "../../common/WLogger.h"
34 #include "../WDataSetScalar.h"
56 boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >(
new WGridRegular3D( 5, 3, 3 ) );
57 boost::shared_ptr< std::vector< double > > data = boost::shared_ptr< std::vector< double > >(
new std::vector< double >( grid->size() ) );
58 for(
size_t i = 0; i < grid->size(); ++i )
62 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
67 TS_ASSERT_EQUALS( ds.
interpolate( WPosition::zero(), &success ), ( *data )[0] );
98 mat( 0, 0 ) = 1.0 / sqrt( 2.0 );
99 mat( 0, 1 ) = 1.0 / sqrt( 2.0 );
100 mat( 1, 0 ) = -1.0 / sqrt( 2.0 );
101 mat( 1, 1 ) = 1.0 / sqrt( 2.0 );
105 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 5, 3, 3, v ) );
106 boost::shared_ptr< std::vector< double > > data = boost::shared_ptr< std::vector< double > >(
new std::vector< double >( grid->size() ) );
107 for(
size_t i = 0; i < grid->size(); ++i )
111 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 0, 1, data, W_DT_DOUBLE ) );
114 bool success =
false;
116 TS_ASSERT_EQUALS( ds.
interpolate( WPosition::zero(), &success ), ( *data )[0] );
117 TS_ASSERT( success );
118 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 1, 0, 0 ) ), &success ), ( *data )[1], 1e-9 );
119 TS_ASSERT( success );
120 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 0, 1, 0 ) ), &success ), ( *data )[5], 1e-9 );
121 TS_ASSERT( success );
122 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 1, 1, 0 ) ), &success ), ( *data )[6], 1e-9 );
123 TS_ASSERT( success );
124 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 0, 0, 1 ) ), &success ), ( *data )[15], 1e-9 );
125 TS_ASSERT( success );
126 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 1, 0, 1 ) ), &success ), ( *data )[16], 1e-9 );
127 TS_ASSERT( success );
128 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 0, 1, 1 ) ), &success ), ( *data )[20], 1e-9 );
129 TS_ASSERT( success );
130 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 1, 1, 1 ) ), &success ), ( *data )[21], 1e-9 );
131 TS_ASSERT( success );
133 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 0.3, 0.4, 0.5 ) ), &success ), 9.8, 1e-9 );
134 TS_ASSERT( success );
135 TS_ASSERT_DELTA( ds.
interpolate( grid->getTransform().positionToWorldSpace(
WPosition( 0.5, 0.5, 0.5 ) ), &success ), 10.5, 1e-9 );
136 TS_ASSERT( success );
140 #endif // WDATASETSCALAR_TEST_H