From 5cad6cd376e25b350442175e976966b6a9189a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Thu, 8 Jun 2017 13:01:12 +0200 Subject: [PATCH] Use previously created functionality to get corner vertices from a cell --- .../RigWellPathIntersectionTools.cpp | 45 ++++--------------- .../RigWellPathIntersectionTools.h | 3 -- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index 2f78c9473c..a691a20ec3 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -109,16 +109,16 @@ std::vector RigWellPathIntersectionTools::getIntersectedCel std::vector closeCells = findCloseCells(grid, bb); - cvf::Vec3d hexCorners[8]; + std::array hexCorners; for (size_t closeCell : closeCells) { const RigCell& cell = grid->globalCellArray()[closeCell]; if (cell.isInvalid()) continue; - setHexCorners(cell, nodeCoords, hexCorners); + grid->cellCornerVertices(closeCell, hexCorners.data()); - RigHexIntersector::lineHexCellIntersection(coords[i], coords[i + 1], hexCorners, closeCell, &intersections); + RigHexIntersector::lineHexCellIntersection(coords[i], coords[i + 1], hexCorners.data(), closeCell, &intersections); } } @@ -149,7 +149,8 @@ cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const std::array< //-------------------------------------------------------------------------------------------------- cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const RigMainGrid* grid, size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint) { - std::array hexCorners = getCellHexCorners(grid, cellIndex); + std::array hexCorners; + grid->cellCornerVertices(cellIndex, hexCorners.data()); return calculateLengthInCell(hexCorners, startPoint, endPoint); } @@ -174,16 +175,16 @@ size_t RigWellPathIntersectionTools::findCellFromCoords(const RigMainGrid* grid, cvf::BoundingBox bb; bb.add(coords); std::vector closeCells = findCloseCells(grid, bb); - cvf::Vec3d hexCorners[8]; + std::array hexCorners; for (size_t closeCell : closeCells) { const RigCell& cell = grid->globalCellArray()[closeCell]; if (cell.isInvalid()) continue; - setHexCorners(cell, nodeCoords, hexCorners); + grid->cellCornerVertices(closeCell, hexCorners.data()); - if (RigHexIntersector::isPointInCell(coords, hexCorners)) + if (RigHexIntersector::isPointInCell(coords, hexCorners.data())) { *foundCell = true; return closeCell; @@ -194,36 +195,6 @@ size_t RigWellPathIntersectionTools::findCellFromCoords(const RigMainGrid* grid, return 0; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::array RigWellPathIntersectionTools::getCellHexCorners(const RigMainGrid* grid, size_t cellIndex) -{ - const std::vector& nodeCoords = grid->nodes(); - std::array corners; - const RigCell& cell = grid->globalCellArray()[cellIndex]; - setHexCorners(cell, nodeCoords, corners.data()); - - return corners; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigWellPathIntersectionTools::setHexCorners(const RigCell& cell, const std::vector& nodeCoords, cvf::Vec3d* hexCorners) -{ - const caf::SizeTArray8& cornerIndices = cell.cornerIndices(); - - hexCorners[0] = nodeCoords[cornerIndices[0]]; - hexCorners[1] = nodeCoords[cornerIndices[1]]; - hexCorners[2] = nodeCoords[cornerIndices[2]]; - hexCorners[3] = nodeCoords[cornerIndices[3]]; - hexCorners[4] = nodeCoords[cornerIndices[4]]; - hexCorners[5] = nodeCoords[cornerIndices[5]]; - hexCorners[6] = nodeCoords[cornerIndices[6]]; - hexCorners[7] = nodeCoords[cornerIndices[7]]; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index 7068371f2c..80536bb00a 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -63,9 +63,6 @@ public: static std::vector findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); static size_t findCellFromCoords(const RigMainGrid* caseData, const cvf::Vec3d& coords, bool* foundCell); - static std::array getCellHexCorners(const RigMainGrid* grid, size_t cellIndex); - static void setHexCorners(const RigCell& cell, const std::vector& nodeCoords, cvf::Vec3d* hexCorners); - private: static void removeEnteringIntersections(std::vector* intersections); };