diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h index ec0b6d5b97..0cefe536eb 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h @@ -91,10 +91,12 @@ struct RigHexIntersector return intersectionCount; } - static bool isPointInCell(const cvf::Vec3d point, const cvf::Vec3d hexCorners[8], const size_t hexIndex) + static bool isPointInCell(const cvf::Vec3d point, const cvf::Vec3d hexCorners[8]) { cvf::Ray ray; ray.setOrigin(point); + size_t intersections = 0; + for (int face = 0; face < 6; ++face) { cvf::ubyte faceVertexIndices[4]; @@ -106,11 +108,11 @@ struct RigHexIntersector int next = i < 3 ? i + 1 : 0; if (ray.triangleIntersect(hexCorners[faceVertexIndices[i]], hexCorners[faceVertexIndices[next]], faceCenter)) { - return true; + ++intersections; } } } - return false; + return intersections % 2 == 1; } static bool isEqualDepth(double d1, double d2) diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index 2ac140af9a..6dda6eebe7 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -115,7 +115,7 @@ std::vector RigWellPathIntersectionTools::getIntersectedCel } //-------------------------------------------------------------------------------------------------- -/// Calculates direction vectors for each axis in the cell. +/// Calculates main axis vectors for each axis in the cell. //-------------------------------------------------------------------------------------------------- void RigWellPathIntersectionTools::calculateCellMainAxisVectors(const std::array& hexCorners, cvf::Vec3d* iAxisDirection, cvf::Vec3d* jAxisDirection, cvf::Vec3d* kAxisDirection) { @@ -125,7 +125,7 @@ void RigWellPathIntersectionTools::calculateCellMainAxisVectors(const std::array } //-------------------------------------------------------------------------------------------------- -/// +/// Calculate the main axis vector for one axis in the cell, fron `negativeFace` to `positiveFace` //-------------------------------------------------------------------------------------------------- cvf::Vec3d RigWellPathIntersectionTools::calculateCellMainAxisVector(const std::array& hexCorners, cvf::StructGridInterface::FaceType negativeFace, @@ -244,7 +244,7 @@ size_t RigWellPathIntersectionTools::findCellFromCoords(const RigMainGrid* grid, setHexCorners(cell, nodeCoords, hexCorners); - if (RigHexIntersector::isPointInCell(coords, hexCorners, closeCell)) + if (RigHexIntersector::isPointInCell(coords, hexCorners)) { return closeCell; }