From 0291dd223736e5f51d6dc900f046eb1754ec395b Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 1 Nov 2018 13:21:13 +0100 Subject: [PATCH] #3600 Fix crash with 2d Maps and LGRs. --- .../ProjectDataModel/Rim2dGridProjection.cpp | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim2dGridProjection.cpp b/ApplicationCode/ProjectDataModel/Rim2dGridProjection.cpp index e4744ea27b..4ebf9e23aa 100644 --- a/ApplicationCode/ProjectDataModel/Rim2dGridProjection.cpp +++ b/ApplicationCode/ProjectDataModel/Rim2dGridProjection.cpp @@ -3,6 +3,7 @@ #include "RiaWeightedMeanCalculator.h" #include "RigActiveCellInfo.h" +#include "RigCell.h" #include "RigEclipseCaseData.h" #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" @@ -475,19 +476,21 @@ std::vector> Rim2dGridProjection::visibleCellsAndWeight cvf::Vec3d hexCorners[8]; for (size_t globalCellIdx : allCellIndices) { - if ((*m_cellVisibility)[globalCellIdx]) + size_t localCellIdx = 0u; + RigGridBase* localGrid = mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIdx, &localCellIdx); + if (localGrid == mainGrid()) { - size_t localCellIdx = 0u; - RigGridBase* localGrid = mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIdx, &localCellIdx); - - localGrid->cellCornerVertices(localCellIdx, hexCorners); - std::vector intersections; - float weight = 1.0f; - if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections)) + if ((*m_cellVisibility)[globalCellIdx]) { - weight = std::max(1.0, (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length()); + localGrid->cellCornerVertices(localCellIdx, hexCorners); + std::vector intersections; + float weight = 1.0f; + if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections)) + { + weight = std::max(1.0, (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length()); + } + matchingVisibleCellsAndWeight.push_back(std::make_pair(globalCellIdx, weight)); } - matchingVisibleCellsAndWeight.push_back(std::make_pair(globalCellIdx, weight)); } }