mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1462 Add functionality to check if a given coordinate is within a cell
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfRay.h"
|
||||
|
||||
//==================================================================================================
|
||||
/// Internal class for intersection point info
|
||||
@@ -90,6 +91,28 @@ struct RigHexIntersector
|
||||
return intersectionCount;
|
||||
}
|
||||
|
||||
static bool isPointInCell(const cvf::Vec3d point, const cvf::Vec3d hexCorners[8], const size_t hexIndex)
|
||||
{
|
||||
cvf::Ray ray;
|
||||
ray.setOrigin(point);
|
||||
for (int face = 0; face < 6; ++face)
|
||||
{
|
||||
cvf::ubyte faceVertexIndices[4];
|
||||
cvf::StructGridInterface::cellFaceVertexIndices(static_cast<cvf::StructGridInterface::FaceType>(face), faceVertexIndices);
|
||||
cvf::Vec3d faceCenter = cvf::GeometryTools::computeFaceCenter(hexCorners[faceVertexIndices[0]], hexCorners[faceVertexIndices[1]], hexCorners[faceVertexIndices[2]], hexCorners[faceVertexIndices[3]]);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
int next = i < 3 ? i + 1 : 0;
|
||||
if (ray.triangleIntersect(hexCorners[faceVertexIndices[i]], hexCorners[faceVertexIndices[next]], faceCenter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isEqualDepth(double d1, double d2)
|
||||
{
|
||||
double depthDiff = d1 - d2;
|
||||
|
||||
Reference in New Issue
Block a user