From f22bcd1c8d76afb0368f6b39091b1a30ae6b3f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Fri, 7 Apr 2017 13:14:22 +0200 Subject: [PATCH] #117 Convert to cell positions to positive depth when sending to Octave --- .../SocketInterface/RiaGeometryCommands.cpp | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) 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);