///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2021 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "gtest/gtest.h" #include "RigSurface.h" #include "RigSurfaceStatisticsCalculator.h" #include "cvfObject.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST( RigSurfaceStatisticsTests, computeStatistics ) { std::vector> surfaces; for ( size_t i = 0; i < 100; i++ ) { cvf::ref surface = cvf::make_ref(); std::vector indices = { 2, 1, 0 }; std::vector vertices = { cvf::Vec3d( -1.0, -1.0, i ), cvf::Vec3d( 1.0, -1.0, i ), cvf::Vec3d( -1.0, 1.0, i ) }; surface->setTriangleData( indices, vertices ); surfaces.push_back( surface ); } cvf::ref statSurface = RigSurfaceStatisticsCalculator::computeStatistics( surfaces ); ASSERT_TRUE( statSurface.notNull() ); ASSERT_EQ( statSurface->triangleIndices().size(), surfaces[0]->triangleIndices().size() ); const std::vector& propertyNames = statSurface->propertyNames(); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "MEAN" ) != propertyNames.end() ); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "MIN" ) != propertyNames.end() ); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "MAX" ) != propertyNames.end() ); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "P10" ) != propertyNames.end() ); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "P50" ) != propertyNames.end() ); ASSERT_TRUE( std::find( propertyNames.begin(), propertyNames.end(), "P90" ) != propertyNames.end() ); const std::vector& meanValues = statSurface->propertyValues( "MEAN" ); const std::vector& minValues = statSurface->propertyValues( "MIN" ); const std::vector& maxValues = statSurface->propertyValues( "MAX" ); const std::vector& p10Values = statSurface->propertyValues( "P10" ); const std::vector& p50Values = statSurface->propertyValues( "P50" ); const std::vector& p90Values = statSurface->propertyValues( "P90" ); // One value per vertex ASSERT_EQ( 3u, meanValues.size() ); ASSERT_EQ( 3u, minValues.size() ); ASSERT_EQ( 3u, maxValues.size() ); ASSERT_EQ( 3u, p10Values.size() ); ASSERT_EQ( 3u, p50Values.size() ); ASSERT_EQ( 3u, p90Values.size() ); for ( size_t i = 0; i < 3u; i++ ) { ASSERT_EQ( 49.5, meanValues[i] ); ASSERT_EQ( 0, minValues[i] ); ASSERT_EQ( 99, maxValues[i] ); ASSERT_NEAR( 9.1, p90Values[i], 0.0001 ); ASSERT_NEAR( 49.5, p50Values[i], 0.0001 ); ASSERT_NEAR( 89.9, p10Values[i], 0.0001 ); } }