mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-16 10:22:15 -05:00
Add polyline filter support (#11048)
* Support selecting cells below polyline, both eclipse and geomech cases * Add some polyline intersection helpers, with tests
This commit is contained in:
1 parent
ca119af0ec
commit
8db29e0931
5 files changed
+224
-17
No files matched your search
@@ -284,6 +284,55 @@ TEST( RigCellGeometryTools, lengthCalcTestTriangle )
|
||||
EXPECT_LT( length, 1.8 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigCellGeometryTools, lineIntersectsLine2DTest )
|
||||
{
|
||||
cvf::Vec3d a1( 0, 0, 0 );
|
||||
cvf::Vec3d b1( 1, 1, 1 );
|
||||
|
||||
cvf::Vec3d a2( 0, 1, 500 );
|
||||
cvf::Vec3d b2( 1, 0, 7000 );
|
||||
|
||||
cvf::Vec3d a3( -10, -10, 0 );
|
||||
cvf::Vec3d b3( -4, -1, 0 );
|
||||
|
||||
EXPECT_TRUE( RigCellGeometryTools::lineIntersectsLine2D( a1, b1, a2, b2 ) );
|
||||
EXPECT_FALSE( RigCellGeometryTools::lineIntersectsLine2D( a1, b1, a3, b3 ) );
|
||||
|
||||
auto [intersect, point] = RigCellGeometryTools::lineLineIntersection2D( a1, b1, a2, b2 );
|
||||
EXPECT_TRUE( intersect );
|
||||
EXPECT_DOUBLE_EQ( 0.5, point.x() );
|
||||
EXPECT_DOUBLE_EQ( 0.5, point.y() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RigCellGeometryTools, lineIntersectsPolygon2DTest )
|
||||
{
|
||||
cvf::Vec3d a1( 0, 0, 0 );
|
||||
cvf::Vec3d b1( 1, 1, 1 );
|
||||
|
||||
cvf::Vec3d a2( 5, -5, 0 );
|
||||
cvf::Vec3d b2( 15, 25, 0 );
|
||||
|
||||
cvf::Vec3d p1( 10, 10, 0 );
|
||||
cvf::Vec3d p2( 11, 20, 1000 );
|
||||
cvf::Vec3d p3( 20, 7, -20 );
|
||||
cvf::Vec3d p4( 21, -1, 55 );
|
||||
|
||||
std::vector<cvf::Vec3d> polygon;
|
||||
polygon.push_back( p1 );
|
||||
polygon.push_back( p2 );
|
||||
polygon.push_back( p3 );
|
||||
polygon.push_back( p4 );
|
||||
|
||||
EXPECT_FALSE( RigCellGeometryTools::lineIntersectsPolygon2D( a1, b1, polygon ) );
|
||||
EXPECT_TRUE( RigCellGeometryTools::lineIntersectsPolygon2D( a2, b2, polygon ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user