| 11 | #define ASSERT_EXPECTED( expr ) if ( auto res = ( expr ); !res ) { ASSERT_TRUE( ( (void)#expr, res ) ) << "Unexpected value: " << res.error(); } |
| 12 | |
| 13 | TEST( MRCuda, PointsProjector ) |
| 14 | { |
| 15 | const auto cube = makeCube(); |
| 16 | const auto torus = makeTorus(); |
| 17 | |
| 18 | PointCloud torusPoints; |
| 19 | torusPoints.points = torus.points; |
| 20 | torusPoints.validPoints.resize( torus.points.size(), true ); |
| 21 | torusPoints.invalidateCaches(); |
| 22 | |
| 23 | std::vector<PointsProjectionResult> cpuResults; |
| 24 | { |
| 25 | PointsProjector cpuProjector; |
| 26 | ASSERT_EXPECTED( cpuProjector.setPointCloud( torusPoints ) ); |
| 27 | ASSERT_EXPECTED( cpuProjector.findProjections( cpuResults, cube.points.vec_, {} ) ); |
| 28 | } |
| 29 | ASSERT_EQ( cpuResults.size(), cube.points.size() ); |
| 30 | for ( auto i = 0; i < cube.points.size(); ++i ) |
| 31 | ASSERT_LT( cpuResults[i].distSq, FLT_MAX ) << "Incorrect result at index " << i; |
| 32 | |
| 33 | std::vector<PointsProjectionResult> cudaResults; |
| 34 | { |
| 35 | Cuda::PointsProjector cudaProjector; |
| 36 | ASSERT_EXPECTED( cudaProjector.setPointCloud( torusPoints ) ); |
| 37 | ASSERT_EXPECTED( cudaProjector.findProjections( cudaResults, cube.points.vec_, {} ) ); |
| 38 | } |
| 39 | ASSERT_EQ( cudaResults.size(), cube.points.size() ); |
| 40 | for ( auto i = 0; i < cube.points.size(); ++i ) |
| 41 | { |
| 42 | ASSERT_NEAR( cudaResults[i].distSq, cpuResults[i].distSq, 1e-6f ) << "Incorrect result at index " << i; |
| 43 | ASSERT_EQ( cudaResults[i].vId, cpuResults[i].vId ) << "Incorrect result at index " << i; |
| 44 | } |
| 45 | } |
nothing calls this directly
no test coverage detected