Commit 4e83ac68 authored by schurade's avatar schurade

[MERGE] with c354c5edb69f262f07f1e944afdfcc1234bdb691

parents 039a6b75 d2bf6846
...@@ -396,7 +396,7 @@ int WGridRegular3D::getNVoxelCoord( const wmath::WPosition& pos, size_t axis ) c ...@@ -396,7 +396,7 @@ int WGridRegular3D::getNVoxelCoord( const wmath::WPosition& pos, size_t axis ) c
break; break;
default : WAssert( false, "Invalid axis selected, must be between 0 and 2, including 0 and 2." ); default : WAssert( false, "Invalid axis selected, must be between 0 and 2, including 0 and 2." );
} }
if( result < 0 || result > offsetAxis * ( nbAxisPos - 1 ) ) if( result < 0 || result >= offsetAxis * ( nbAxisPos - 1 ) )
{ {
return -1; return -1;
} }
......
...@@ -277,7 +277,7 @@ public: ...@@ -277,7 +277,7 @@ public:
\endverbatim \endverbatim
* *
* Please note the first voxel has only 1/8 of the size a normal voxel * Please note the first voxel has only 1/8 of the size a normal voxel
* would have since all positions outside the grid does not belonging * would have since all positions outside the grid do not belong
* to any voxel. Note: a cell is different to a voxel in terms of position. * to any voxel. Note: a cell is different to a voxel in terms of position.
* A voxel has a grid point as center whereas a cell has grid points as * A voxel has a grid point as center whereas a cell has grid points as
* corners. * corners.
...@@ -338,7 +338,8 @@ public: ...@@ -338,7 +338,8 @@ public:
wmath::WValue< int > getVoxelCoord( const wmath::WPosition& pos ) const; wmath::WValue< int > getVoxelCoord( const wmath::WPosition& pos ) const;
/** /**
* Computes the id of the cell containing the position pos. * Computes the id of the cell containing the position pos. Note that the upper
* bound of the grid does not belong to any cell
* *
* \param pos The position selecting the cell. * \param pos The position selecting the cell.
* \param success True if the position pos is inside the grid. * \param success True if the position pos is inside the grid.
......
...@@ -564,9 +564,24 @@ public: ...@@ -564,9 +564,24 @@ public:
void testEnclosesQuery( void ) void testEnclosesQuery( void )
{ {
WGridRegular3D g( 2, 2, 2, 1., 1., 1. ); WGridRegular3D g( 2, 2, 2, 1., 1., 1. );
// Test bounds for X direction
TS_ASSERT( !g.encloses( wmath::WPosition( 0 - wlimits::FLT_EPS, 0, 0 ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 0, 0, 0 ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 1.0 - wlimits::FLT_EPS, 0.5, 0.5 ) ) );
TS_ASSERT( !g.encloses( wmath::WPosition( 1, 0.5, 0.5 ) ) );
// Test bounds for Y direction
TS_ASSERT( !g.encloses( wmath::WPosition( 0, 0 - wlimits::FLT_EPS, 0 ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 0, 0, 0 ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 0.5, 1.0 - wlimits::FLT_EPS, 0.5 ) ) );
TS_ASSERT( !g.encloses( wmath::WPosition( 0.5, 1.0, 0.5 ) ) );
// Test bounds for Z direction
TS_ASSERT( !g.encloses( wmath::WPosition( 0, 0, 0 - wlimits::FLT_EPS ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 0, 0, 0 ) ) ); TS_ASSERT( g.encloses( wmath::WPosition( 0, 0, 0 ) ) );
TS_ASSERT( g.encloses( wmath::WPosition( 1, 1, 1 ) ) ); TS_ASSERT( g.encloses( wmath::WPosition( 0.5, 0.5, 1.0 - wlimits::FLT_EPS ) ) );
TS_ASSERT( !g.encloses( wmath::WPosition( 1, 1, 1.0 + wlimits::DBL_EPS ) ) ); TS_ASSERT( !g.encloses( wmath::WPosition( 0.5, 0.5, 1 ) ) );
} }
private: private:
......
...@@ -173,8 +173,9 @@ public: ...@@ -173,8 +173,9 @@ public:
m_algo->m_values[0] = m_algo->m_values[4] = m_algo->m_values[7] = 0.0; m_algo->m_values[0] = m_algo->m_values[4] = m_algo->m_values[7] = 0.0;
wmath::WLine k; wmath::WLine k;
// These two points are supposed to be voxel centers
k.push_back( wmath::WPosition( 0.0, 0.0, 0.0 ) ); k.push_back( wmath::WPosition( 0.0, 0.0, 0.0 ) );
k.push_back( wmath::WPosition( 1.0, 2.0, 0.0 ) ); k.push_back( wmath::WPosition( 1.0, 2.0 - wlimits::DBL_EPS, 0.0 ) );
m_algo->raster( k ); m_algo->raster( k );
expected[3] = 1.0; expected[3] = 1.0;
expected[4] = 0.0; expected[4] = 0.0;
......
...@@ -174,8 +174,9 @@ public: ...@@ -174,8 +174,9 @@ public:
m_algo->m_values[7] = 0.0; m_algo->m_values[7] = 0.0;
wmath::WLine k; wmath::WLine k;
// These two are supposed to be the voxel centers.
k.push_back( wmath::WPosition( 0.0, 0.0, 0.0 ) ); k.push_back( wmath::WPosition( 0.0, 0.0, 0.0 ) );
k.push_back( wmath::WPosition( 1.0, 2.0, 0.0 ) ); k.push_back( wmath::WPosition( 1.0, 2.0 - wlimits::DBL_EPS , 0.0 ) );
m_algo->raster( k ); m_algo->raster( k );
TS_ASSERT_EQUALS( m_algo->m_values, expected ); TS_ASSERT_EQUALS( m_algo->m_values, expected );
} }
......
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