Commit b8f76fdf authored by Alexander Wiebel's avatar Alexander Wiebel

[FIX #347] encloses now accepts and rejects the points as desired. Adapted

test accordingly
parent a58d2c86
...@@ -389,7 +389,7 @@ int WGridRegular3D::getNVoxelCoord( const wmath::WPosition& pos, size_t axis ) c ...@@ -389,7 +389,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:
......
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