25 #ifndef WDATASETVECTOR_TEST_H
26 #define WDATASETVECTOR_TEST_H
31 #include <boost/array.hpp>
33 #include <cxxtest/TestSuite.h>
35 #include "../../common/WLogger.h"
36 #include "../WDataSetVector.h"
57 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 2, 2, 2 ) );
58 boost::array< WPosition, 8 > d = { {
WPosition( 0, 1, 2 ),
WPosition( 3, 4, 5 ),
WPosition( 6, 7, 8 ),
59 WPosition( 9,10,11 ),
WPosition( 12,13,14 ),
WPosition( 15,16,17 ),
WPosition( 18,19,20 ),
WPosition( 21,22,23 ) } };
61 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
62 for(
size_t i = 0; i < grid->size() * 3; ++i )
68 boost::array< WPosition, 8 > gridPos = { {
WPosition( 0, 0, 0 ),
WPosition( almost1, 0, 0 ),
WPosition( 0, almost1, 0 ),
72 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
76 for(
size_t i = 0; i < 8; ++i )
81 ss <<
"i:" << i <<
" gridPos(i):" << gridPos[i] <<
" d(i):" << d[i] <<
" interpol:" << ds.
interpolate( gridPos[i], &success ) <<
"\n";
123 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
124 boost::array< WPosition, 8 > d = { {
WPosition( -1, 0, 0 ),
133 for(
size_t i = 0; i < grid->size(); ++i )
135 data->push_back( d[i][0] );
136 data->push_back( d[i][1] );
137 data->push_back( d[i][2] );
139 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
142 bool success =
false;
144 TS_ASSERT( success );
146 TS_ASSERT( success );
148 TS_ASSERT( success );
150 TS_ASSERT( success );
152 TS_ASSERT( success );
154 TS_ASSERT( success );
163 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 3, 4, 5 ) );
164 bool success =
false;
165 boost::shared_ptr< std::vector< double > > data(
new std::vector< double >( grid->size() * 3 ) );
166 for(
size_t i = 0; i < grid->size() * 3; ++i )
170 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
173 TS_ASSERT( !success );
184 mat( 0, 0 ) = 1.0 / sqrt( 2.0 );
185 mat( 0, 1 ) = 1.0 / sqrt( 2.0 );
186 mat( 1, 0 ) = -1.0 / sqrt( 2.0 );
187 mat( 1, 1 ) = 1.0 / sqrt( 2.0 );
191 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 2, 2, 2, v ) );
192 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
193 boost::array< WPosition, 8 > d = { {
WPosition( -1, 0, 0 ),
202 for(
size_t i = 0; i < grid->size(); ++i )
204 data->push_back( d[i][0] );
205 data->push_back( d[i][1] );
206 data->push_back( d[i][2] );
208 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
211 bool success =
false;
212 WPosition pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.0, 0.0, 0.0 ) );
213 TS_ASSERT_EQUALS( ds.
interpolate( pos, &success ), d[0] );
214 TS_ASSERT( success );
215 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.9999, 0.9999, 0.9999 ) );
217 TS_ASSERT( success );
218 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.5, 0.5, 0.5 ) );
220 TS_ASSERT( success );
221 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.0, 0.0, 0.0 ) );
223 TS_ASSERT( success );
224 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.9999, 0.9999, 0.9999 ) );
226 TS_ASSERT( success );
227 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.5, 0.5, 0.5 ) );
229 TS_ASSERT( success );
245 for(
int i = 0; result && ( i < 3 ); ++i )
247 result = result && ( std::abs( lhs[i] - rhs[i] ) <= d );
250 std::cout.precision( 10 );
251 std::cout.setf( std::ios::fixed, std::ios::floatfield );
252 std::cout <<
"delta failed! => lhs:" << lhs <<
" rhs:" << rhs <<
" failed: abs(lhs[" << i <<
"] - rhs["
253 << i <<
"])=" << std::abs( lhs[i] - rhs[i] ) <<
", but should be: " << d <<
"\n";
260 #endif // WDATASETVECTOR_TEST_H
This data set type contains vectors as values.
A grid that has parallelepiped cells which all have the same proportion.
WMatrix & makeIdentity()
Makes the matrix contain the identity matrix, i.e.
WVector3d interpolate(const WPosition &pos, bool *success) const
Interpolates the vector field at the given position.
void setUp(void)
Constructs unit test environment.
This only is a 3d double vector.
bool delta(WVector3d lhs, WVector3d rhs, double d)
Computes if both vectors are almost similar and their components do not differ from a certain given d...
void testRotatedGridInterpolate(void)
When the grid for this dataset was rotated the interpolation should still work.
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
void testEigenVectorInterpolate(void)
Checks if the reorientation of the vectors is applied in eigenVectorInterpolate().
const double DBL_EPS
Smallest double such: 1.0 + DBL_EPS == 1.0 is still true.
WVector3d eigenVectorInterpolate(const WPosition &pos, bool *success) const
Interpolates the very same way as interpolate but it assures that all vecs are aligned to point into ...
void testInterpolate(void)
An interpolate of an vector is as if every components were interpolated.
Base Class for all value set types.
void testBoundary_ticket313(void)
Using interpolate on Positions on the boundary of the grid the success flag is true but there should ...
Test basic functionality of WDataSetVector.