Files
ResInsight/ApplicationLibCode/ReservoirDataModel/RigHexIntersectionTools.h
T
Kristian Bendiksen 10182e99a7 Refactor: Change RigGridBase::cellCornerVertices to return std::array
Refactored RigGridBase::cellCornerVertices to return std::array<cvf::Vec3d, 8> by value instead of taking a reference to std::array as an output parameter. This change improves code readability and leverages modern C++ return value optimizations.

Updated all call sites across the codebase to reflect the new function signature.
2025-09-03 14:21:19 +02:00

73 lines
3.3 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfPlane.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include <array>
#include <list>
//==================================================================================================
/// Internal class for intersection point info
//==================================================================================================
struct HexIntersectionInfo
{
public:
HexIntersectionInfo( cvf::Vec3d intersectionPoint, bool isIntersectionEntering, cvf::StructGridInterface::FaceType face, size_t hexIndex )
: m_intersectionPoint( intersectionPoint )
, m_isIntersectionEntering( isIntersectionEntering )
, m_face( face )
, m_hexIndex( hexIndex )
{
}
cvf::Vec3d m_intersectionPoint;
bool m_isIntersectionEntering;
cvf::StructGridInterface::FaceType m_face;
size_t m_hexIndex;
};
bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2 );
//--------------------------------------------------------------------------------------------------
/// Specialized Line - Hex intersection
//--------------------------------------------------------------------------------------------------
struct RigHexIntersectionTools
{
static int lineHexCellIntersection( const cvf::Vec3d& p1,
const cvf::Vec3d& p2,
const std::array<cvf::Vec3d, 8>& hexCorners,
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections );
static bool lineIntersectsHexCell( const cvf::Vec3d& p1, const cvf::Vec3d& p2, const std::array<cvf::Vec3d, 8>& hexCorners );
static bool isPointInCell( const cvf::Vec3d& point, const std::array<cvf::Vec3d, 8>& hexCorners );
static bool planeHexCellIntersection( const std::array<cvf::Vec3d, 8>& hexCorners,
const cvf::Plane& fracturePlane,
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments );
static bool planeHexIntersectionPolygons( const std::array<cvf::Vec3d, 8>& hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d>>& polygons );
};