mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8696 Cell filter: fix for IJ Index polygon for non-intersecting filter points
Now the minimum K-layer directly below any of the filter points are used when the filter points does not intersect with the cells. Fixes #8696.
This commit is contained in:
parent
8e3289a432
commit
29fdc29eb0
@ -54,6 +54,8 @@
|
|||||||
|
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
template <>
|
template <>
|
||||||
@ -902,6 +904,45 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector<cvf::Vec3d>& points,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto findKLayerBelowPoint = []( const cvf::Vec3d& point, RigMainGrid* mainGrid ) {
|
||||||
|
// Create a bounding box (ie a ray) from the point down to minimum of grid
|
||||||
|
cvf::Vec3d lowestPoint( point.x(), point.y(), mainGrid->boundingBox().min().z() );
|
||||||
|
|
||||||
|
cvf::BoundingBox rayBBox;
|
||||||
|
rayBBox.add( point );
|
||||||
|
rayBBox.add( lowestPoint );
|
||||||
|
|
||||||
|
// Find the cells intersecting the ray
|
||||||
|
std::vector<size_t> allCellIndices;
|
||||||
|
mainGrid->findIntersectingCells( rayBBox, &allCellIndices );
|
||||||
|
|
||||||
|
// Get the minimum K layer index
|
||||||
|
int minK = std::numeric_limits<int>::max();
|
||||||
|
bool anyHits = false;
|
||||||
|
for ( size_t cIdx : allCellIndices )
|
||||||
|
{
|
||||||
|
if ( cIdx != cvf::UNDEFINED_SIZE_T )
|
||||||
|
{
|
||||||
|
size_t ni, nj, nk;
|
||||||
|
mainGrid->ijkFromCellIndexUnguarded( cIdx, &ni, &nj, &nk );
|
||||||
|
if ( mainGrid->isCellValid( ni, nj, nk ) )
|
||||||
|
{
|
||||||
|
anyHits = true;
|
||||||
|
minK = std::min( minK, static_cast<int>( nk ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyHits ? minK : -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
// shoot a ray down from each point to try to find a valid hit there
|
||||||
|
for ( size_t p = 0; p < points.size() - 1; p++ )
|
||||||
|
{
|
||||||
|
int k = findKLayerBelowPoint( points[p], data->mainGrid() );
|
||||||
|
if ( k != -1 ) return k;
|
||||||
|
}
|
||||||
|
|
||||||
// loop over all sub-grids to find one with a cell hit in case main grid search failed
|
// loop over all sub-grids to find one with a cell hit in case main grid search failed
|
||||||
for ( size_t gridIndex = 1; gridIndex < data->gridCount(); gridIndex++ )
|
for ( size_t gridIndex = 1; gridIndex < data->gridCount(); gridIndex++ )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user