diff --git a/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp b/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp index bf77b8ffb4..096b41332a 100644 --- a/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaGeometryCommands.cpp @@ -42,7 +42,30 @@ #include +//-------------------------------------------------------------------------------------------------- +/// Convert internal ResInsight representation of cells with negative depth to positive depth. +//-------------------------------------------------------------------------------------------------- +static inline void convertVec3dToPositiveDepth(cvf::Vec3d* vec) +{ + double& z = vec->z(); + z *= -1; +} +//-------------------------------------------------------------------------------------------------- +/// Retrieve a cell corner where the depth is represented as negative converted to positive depth. +//-------------------------------------------------------------------------------------------------- +static inline double getCellCornerWithPositiveDepth(const cvf::Vec3d *cornerVerts, size_t cornerIndexMapping, int coordIdx) +{ + if (coordIdx == 2) + { + // Z-value aka depth + return -1 * cornerVerts[cornerIndexMapping][coordIdx]; + } + else + { + return cornerVerts[cornerIndexMapping][coordIdx]; + } +} //-------------------------------------------------------------------------------------------------- /// @@ -108,6 +131,8 @@ public: size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK(i, j, k); cvf::Vec3d center = rigGrid->cell(gridLocalCellIndex).center(); + convertVec3dToPositiveDepth(¢er); + doubleValues[valueIndex++] = center[coordIdx]; } } @@ -187,6 +212,8 @@ public: cvf::Vec3d center = mainGrid->globalCellArray()[reservoirCellIndex].center(); + convertVec3dToPositiveDepth(¢er); + doubleValues[valueIndex++] = center[coordIdx]; } @@ -275,7 +302,7 @@ public: size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK(i, j, k); rigGrid->cellCornerVertices(gridLocalCellIndex, cornerVerts); - doubleValues[valueIndex++] = cornerVerts[cornerIndexMapping][coordIdx]; + doubleValues[valueIndex++] = getCellCornerWithPositiveDepth(cornerVerts, cornerIndexMapping, coordIdx); } } } @@ -361,7 +388,7 @@ public: mainGrid->cellCornerVertices(reservoirCellIndex, cornerVerts); - doubleValues[valueIndex++] = cornerVerts[cornerIndexMapping][coordIdx]; + doubleValues[valueIndex++] = getCellCornerWithPositiveDepth(cornerVerts, cornerIndexMapping, coordIdx); } CVF_ASSERT(valueIndex == activeCellCount);