25 #ifndef WDATASETVECTOR_TEST_H
26 #define WDATASETVECTOR_TEST_H
32 #include <boost/array.hpp>
35 #include <cxxtest/TestSuite.h>
37 #include "../../common/WLogger.h"
38 #include "../WDataSetVector.h"
59 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 2, 2, 2 ) );
60 boost::array< WPosition, 8 > d = { {
WPosition( 0, 1, 2 ),
WPosition( 3, 4, 5 ),
WPosition( 6, 7, 8 ),
61 WPosition( 9,10,11 ),
WPosition( 12,13,14 ),
WPosition( 15,16,17 ),
WPosition( 18,19,20 ),
WPosition( 21,22,23 ) } };
63 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
64 for(
size_t i = 0; i < grid->size() * 3; ++i )
70 boost::array< WPosition, 8 > gridPos = { {
WPosition( 0, 0, 0 ),
WPosition( almost1, 0, 0 ),
WPosition( 0, almost1, 0 ),
74 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
78 for(
size_t i = 0; i < 8; ++i )
83 ss <<
"i:" << i <<
" gridPos(i):" << gridPos[i] <<
" d(i):" << d[i] <<
" interpol:" << ds.
interpolate( gridPos[i], &success ) <<
"\n";
125 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
126 boost::array< WPosition, 8 > d = { {
WPosition( -1, 0, 0 ),
135 for(
size_t i = 0; i < grid->size(); ++i )
137 data->push_back( d[i][0] );
138 data->push_back( d[i][1] );
139 data->push_back( d[i][2] );
141 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
144 bool success =
false;
146 TS_ASSERT( success );
148 TS_ASSERT( success );
150 TS_ASSERT( success );
152 TS_ASSERT( success );
154 TS_ASSERT( success );
156 TS_ASSERT( success );
165 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 3, 4, 5 ) );
166 bool success =
false;
167 boost::shared_ptr< std::vector< double > > data(
new std::vector< double >( grid->size() * 3 ) );
168 for(
size_t i = 0; i < grid->size() * 3; ++i )
172 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
175 TS_ASSERT( !success );
186 mat( 0, 0 ) = 1.0 / sqrt( 2.0 );
187 mat( 0, 1 ) = 1.0 / sqrt( 2.0 );
188 mat( 1, 0 ) = -1.0 / sqrt( 2.0 );
189 mat( 1, 1 ) = 1.0 / sqrt( 2.0 );
193 boost::shared_ptr< WGridRegular3D > grid(
new WGridRegular3D( 2, 2, 2, v ) );
194 boost::shared_ptr< std::vector< double > > data(
new std::vector< double > );
195 boost::array< WPosition, 8 > d = { {
WPosition( -1, 0, 0 ),
204 for(
size_t i = 0; i < grid->size(); ++i )
206 data->push_back( d[i][0] );
207 data->push_back( d[i][1] );
208 data->push_back( d[i][2] );
210 boost::shared_ptr< WValueSet< double > > valueSet(
new WValueSet< double >( 1, 3, data, W_DT_DOUBLE ) );
213 bool success =
false;
214 WPosition pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.0, 0.0, 0.0 ) );
215 TS_ASSERT_EQUALS( ds.
interpolate( pos, &success ), d[0] );
216 TS_ASSERT( success );
217 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.9999, 0.9999, 0.9999 ) );
219 TS_ASSERT( success );
220 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.5, 0.5, 0.5 ) );
222 TS_ASSERT( success );
223 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.0, 0.0, 0.0 ) );
225 TS_ASSERT( success );
226 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.9999, 0.9999, 0.9999 ) );
228 TS_ASSERT( success );
229 pos = grid->getTransform().positionToWorldSpace(
WPosition( 0.5, 0.5, 0.5 ) );
231 TS_ASSERT( success );
247 for(
int i = 0; result && ( i < 3 ); ++i )
249 result = result && ( std::abs( lhs[i] - rhs[i] ) <= d );
252 std::cout.precision( 10 );
253 std::cout.setf( std::ios::fixed, std::ios::floatfield );
254 std::cout <<
"delta failed! => lhs:" << lhs <<
" rhs:" << rhs <<
" failed: abs(lhs[" << i <<
"] - rhs["
255 << i <<
"])=" << std::abs( lhs[i] - rhs[i] ) <<
", but should be: " << d <<
"\n";
262 #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.