mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
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.
This commit is contained in:
1 parent
da69eef72b
commit
10182e99a7
41 files changed
+148
-214
No files matched your search
@@ -478,8 +478,7 @@ void RimPolygonFilter::updateCellsDepthEclipse( const std::vector<cvf::Vec3d>& p
|
||||
if ( cell.isInvalid() ) continue;
|
||||
|
||||
// get corner coordinates
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
grid->cellCornerVertices( n, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = grid->cellCornerVertices( n );
|
||||
|
||||
// get cell ijk for k filter
|
||||
size_t i, j, k;
|
||||
@@ -521,8 +520,7 @@ void RimPolygonFilter::updateCellsKIndexEclipse( const std::vector<cvf::Vec3d>&
|
||||
if ( cell.isInvalid() ) continue;
|
||||
|
||||
// get corner coordinates
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
grid->cellCornerVertices( cellIdx, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = grid->cellCornerVertices( cellIdx );
|
||||
|
||||
if ( closedPolygon )
|
||||
{
|
||||
@@ -624,16 +622,11 @@ void RimPolygonFilter::updateCellsDepthGeoMech( const std::vector<cvf::Vec3d>& p
|
||||
size_t cellIdx = grid->cellIndexFromIJK( i, j, k );
|
||||
if ( cellIdx == cvf::UNDEFINED_SIZE_T ) continue;
|
||||
|
||||
std::array<cvf::Vec3d, 8> vertices;
|
||||
grid->cellCornerVertices( cellIdx, vertices );
|
||||
cvf::Vec3d center = grid->cellCentroid( cellIdx );
|
||||
|
||||
std::array<cvf::Vec3d, 8> corners;
|
||||
for ( size_t n = 0; n < 8; n++ )
|
||||
corners[n] = vertices[n];
|
||||
std::array<cvf::Vec3d, 8> vertices = grid->cellCornerVertices( cellIdx );
|
||||
cvf::Vec3d center = grid->cellCentroid( cellIdx );
|
||||
|
||||
// check if the polygon includes the cell
|
||||
if ( cellInsidePolygon2D( center, corners, points ) )
|
||||
if ( cellInsidePolygon2D( center, vertices, points ) )
|
||||
{
|
||||
#pragma omp critical
|
||||
m_cells[partId].push_back( cellIdx );
|
||||
@@ -673,9 +666,8 @@ void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector<cvf::Vec3d>&
|
||||
size_t cellIdx = grid->cellIndexFromIJK( i, j, k );
|
||||
if ( cellIdx == cvf::UNDEFINED_SIZE_T ) continue;
|
||||
|
||||
cvf::BoundingBox bb;
|
||||
std::array<cvf::Vec3d, 8> vertices;
|
||||
grid->cellCornerVertices( cellIdx, vertices );
|
||||
cvf::BoundingBox bb;
|
||||
std::array<cvf::Vec3d, 8> vertices = grid->cellCornerVertices( cellIdx );
|
||||
for ( const auto& point : vertices )
|
||||
bb.add( point );
|
||||
|
||||
@@ -714,9 +706,8 @@ void RimPolygonFilter::updateCellsKIndexGeoMech( const std::vector<cvf::Vec3d>&
|
||||
if ( cellIdx == cvf::UNDEFINED_SIZE_T ) continue;
|
||||
|
||||
// get corner coordinates
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
grid->cellCornerVertices( cellIdx, hexCorners );
|
||||
cvf::Vec3d center = grid->cellCentroid( cellIdx );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = grid->cellCornerVertices( cellIdx );
|
||||
cvf::Vec3d center = grid->cellCentroid( cellIdx );
|
||||
|
||||
if ( closedPolygon )
|
||||
{
|
||||
@@ -1112,8 +1103,7 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector<cvf::Vec3d>& points,
|
||||
|
||||
// is the point inside cell bb?
|
||||
cvf::BoundingBox bb;
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
grid->cellCornerVertices( i, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = grid->cellCornerVertices( i );
|
||||
for ( const auto& corner : hexCorners )
|
||||
{
|
||||
bb.add( corner );
|
||||
|
||||
@@ -87,8 +87,7 @@ void RimFractureContainmentTools::appendNeighborCellForFace( const std::set<size
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double computeAverageZForTwoDeepestZ( const RigMainGrid* mainGrid, size_t globalReservoirCellIndex, cvf::StructGridInterface::FaceType face )
|
||||
{
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
mainGrid->cellCornerVertices( globalReservoirCellIndex, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = mainGrid->cellCornerVertices( globalReservoirCellIndex );
|
||||
|
||||
double avgZ = 0.0;
|
||||
|
||||
@@ -250,8 +249,7 @@ std::set<size_t> RimFractureContainmentTools::getCellsIntersectingFracturePlane(
|
||||
|
||||
for ( const auto& globalCellIndex : indicesToPotentiallyFracturedCells )
|
||||
{
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
mainGrid->cellCornerVertices( globalCellIndex, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = mainGrid->cellCornerVertices( globalCellIndex );
|
||||
std::vector<std::vector<cvf::Vec3d>> planeCellPolygons;
|
||||
|
||||
bool isPlanIntersected =
|
||||
|
||||
@@ -514,8 +514,7 @@ cvf::BoundingBox RimGeoMechCase::reservoirBoundingBox()
|
||||
|
||||
if ( validPorValue )
|
||||
{
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
femPartGrid->cellCornerVertices( i, hexCorners );
|
||||
std::array<cvf::Vec3d, 8> hexCorners = femPartGrid->cellCornerVertices( i );
|
||||
for ( size_t c = 0; c < 8; ++c )
|
||||
{
|
||||
boundingBox.add( hexCorners[c] );
|
||||
|
||||
@@ -240,8 +240,7 @@ void RimGridCaseSurface::extractStructuredSurfaceFromGridData()
|
||||
size_t cellFaceIndex = 0;
|
||||
if ( !findValidCellIndex( grid, faceType, cellIndex, row, column, zeroBasedLayerIndex, cellFaceIndex ) ) return;
|
||||
|
||||
std::array<cvf::Vec3d, 8> cornerVerts;
|
||||
grid->cellCornerVertices( cellIndex, cornerVerts );
|
||||
std::array<cvf::Vec3d, 8> cornerVerts = grid->cellCornerVertices( cellIndex );
|
||||
|
||||
cvf::ubyte faceConn[4];
|
||||
RigMainGrid::cellFaceVertexIndices( faceType, faceConn );
|
||||
@@ -317,11 +316,10 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
|
||||
if ( m_watertight ) skipInactiveCells = false;
|
||||
if ( skipInactiveCells && activeCells && !activeCells->isActive( currentCellIndex ) ) continue;
|
||||
|
||||
std::array<cvf::Vec3d, 8> currentCornerVerts;
|
||||
std::array<cvf::Vec3d, 8> currentCornerVerts = grid->cellCornerVertices( currentCellIndex );
|
||||
|
||||
{
|
||||
cvf::ubyte currentFaceConn[4];
|
||||
grid->cellCornerVertices( currentCellIndex, currentCornerVerts );
|
||||
RigMainGrid::cellFaceVertexIndices( extractionFace, currentFaceConn );
|
||||
|
||||
auto currentCellStartIndex = static_cast<unsigned>( vertices.size() );
|
||||
@@ -382,9 +380,8 @@ void RimGridCaseSurface::addGeometryForFaultFaces( const RigMainGrid*
|
||||
auto nextCell = grid->cell( currentCellIndex ).neighborCell( faultFace );
|
||||
if ( !nextCell.isInvalid() )
|
||||
{
|
||||
size_t nextCellIndex = nextCell.mainGridCellIndex();
|
||||
std::array<cvf::Vec3d, 8> nextCellCornerVerts;
|
||||
grid->cellCornerVertices( nextCellIndex, nextCellCornerVerts );
|
||||
size_t nextCellIndex = nextCell.mainGridCellIndex();
|
||||
std::array<cvf::Vec3d, 8> nextCellCornerVerts = grid->cellCornerVertices( nextCellIndex );
|
||||
|
||||
auto startIndex = static_cast<unsigned>( vertices.size() );
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user