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:
Kristian Bendiksen committed 2025-09-03 14:21:19 +02:00
1 parent da69eef72b
commit 10182e99a7
41 files changed
+148 -214

No files matched your search

@@ -242,8 +242,7 @@ void RicCreateTemporaryLgrFeature::createLgr( const LgrInfo& lgrInfo, RigMainGri
// Corner coordinates
{
size_t cIdx;
std::array<cvf::Vec3d, 8> vertices;
mainGrid->cellCornerVertices( mainCellIndex, vertices );
std::array<cvf::Vec3d, 8> vertices = mainGrid->cellCornerVertices( mainCellIndex );
auto cellCounts = lgrInfo.sizesPerMainGridCell();
auto lgrCoords = RiaCellDividingTools::createHexCornerCoords( vertices, cellCounts.i(), cellCounts.j(), cellCounts.k() );
@@ -223,7 +223,7 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
if ( eclipseView && eclipseView->mainGrid() )
{
RigGridBase* hitGrid = eclipseView->mainGrid()->gridByIndex( gridIndex );
hitGrid->cellCornerVertices( cellIndex, cornerVertices );
cornerVertices = hitGrid->cellCornerVertices( cellIndex );
}
}
}
@@ -244,7 +244,7 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
{
cellIndex = elementIndex;
const RigFemPartGrid* femGrid = femPart->getOrCreateStructGrid();
femGrid->cellCornerVertices( cellIndex, cornerVertices );
cornerVertices = femGrid->cellCornerVertices( cellIndex );
}
}
}
@@ -253,7 +253,7 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
if ( cellIndex )
{
std::vector<HexIntersectionInfo> intersectionInfo;
RigHexIntersectionTools::lineHexCellIntersection( domainRayOrigin, domainRayEnd, cornerVertices.data(), cellIndex, &intersectionInfo );
RigHexIntersectionTools::lineHexCellIntersection( domainRayOrigin, domainRayEnd, cornerVertices, cellIndex, &intersectionInfo );
if ( intersectionInfo.empty() ) return cvf::Vec3d::UNDEFINED;
@@ -291,8 +291,7 @@ bool RifEclipseInputFileTools::exportGrid( const QString& fileName,
{
active = ( *cellVisibilityOverrideForActnum )[mainIndex];
}
std::array<cvf::Vec3d, 8> cellCorners;
mainGrid->cellCornerVertices( mainIndex, cellCorners );
std::array<cvf::Vec3d, 8> cellCorners = mainGrid->cellCornerVertices( mainIndex );
if ( mainGrid->useMapAxes() )
{
@@ -652,11 +652,10 @@ void RifReaderEclipseWell::readWellCells( RifEclipseRestartDataAccess* restartDa
well_conn_type* ert_connection = well_conn_collection_iget( connections, 0 );
RigWellResultPoint point =
RifReaderEclipseWell::createWellResultPoint( eclipseCaseData, grids[gridNr], ert_connection, segment, wellName );
lastConnectionPos = grids[gridNr]->cell( point.cellIndex() ).center();
std::array<cvf::Vec3d, 8> cellVxes;
grids[gridNr]->cellCornerVertices( point.cellIndex(), cellVxes );
lastConnectionCellCorner = cellVxes[0];
lastConnectionCellSize = ( lastConnectionPos - cellVxes[0] ).length();
lastConnectionPos = grids[gridNr]->cell( point.cellIndex() ).center();
std::array<cvf::Vec3d, 8> cellVxes = grids[gridNr]->cellCornerVertices( point.cellIndex() );
lastConnectionCellCorner = cellVxes[0];
lastConnectionCellSize = ( lastConnectionPos - cellVxes[0] ).length();
lastConnectionSegmentId = well_segment_get_id( segment );
accLengthFromLastConnection = well_segment_get_length( segment ) / ( connectionCount + 1 );
@@ -440,15 +440,17 @@ bool RigFemPartGrid::cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartGrid::cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& vertices ) const
std::array<cvf::Vec3d, 8> RigFemPartGrid::cellCornerVertices( size_t cellIndex ) const
{
const std::vector<cvf::Vec3f>& nodeCoords = m_femPart->nodes().coordinates;
const int* cornerIndices = m_femPart->connectivities( cellIndex );
std::array<cvf::Vec3d, 8> vertices;
for ( size_t i = 0; i < 8; ++i )
{
vertices[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] );
}
return vertices;
}
//--------------------------------------------------------------------------------------------------
@@ -456,8 +458,7 @@ void RigFemPartGrid::cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigFemPartGrid::cellCentroid( size_t cellIndex ) const
{
std::array<cvf::Vec3d, 8> cellVertices;
cellCornerVertices( cellIndex, cellVertices );
std::array<cvf::Vec3d, 8> cellVertices = cellCornerVertices( cellIndex );
cvf::Vec3d centroid( 0.0, 0.0, 0.0 );
for ( int i = 0; i < 8; ++i )
@@ -43,7 +43,7 @@ public:
cvf::Vec3i findMainIJKFaces( int elementIndex ) const;
std::pair<cvf::Vec3st, cvf::Vec3st> reservoirIJKBoundingBox() const;
void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& vertices ) const override;
std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const override;
cvf::Vec3d cellCentroid( size_t cellIndex ) const override;
private:
@@ -44,9 +44,9 @@ public:
std::vector<size_t> elementFaceNodeIdxs;
};
static std::vector<cvf::Vec3d> coordsFromNodeIndices( const RigFemPart& part, const std::vector<size_t>& nodeIdxs );
static std::vector<size_t> nodesForElement( const RigFemPart& part, size_t elementIdx );
static float horizontalDistance( const cvf::Vec3f& p1, const cvf::Vec3f& p2 );
static std::array<cvf::Vec3d, 8> coordsFromNodeIndices( const RigFemPart& part, const std::array<size_t, 8>& nodeIdxs );
static std::array<size_t, 8> nodesForElement( const RigFemPart& part, size_t elementIdx );
static float horizontalDistance( const cvf::Vec3f& p1, const cvf::Vec3f& p2 );
static void findReferenceElementForNode( const RigFemPart& part, size_t nodeIdx, size_t kRefLayer, RefElement* refElement );
//--------------------------------------------------------------------------------------------------
@@ -175,13 +175,13 @@ void findReferenceElementForNode( const RigFemPart& part, size_t nodeIdx, size_t
bool validIndex = grid->ijkFromCellIndex( elemIdx, &i, &j, &k );
if ( validIndex && k == kRefLayer )
{
const std::vector<size_t> nodeIndices = nodesForElement( part, elemIdx );
const std::array<size_t, 8> nodeIndices = nodesForElement( part, elemIdx );
CVF_ASSERT( nodeIndices.size() == 8 );
std::vector<HexIntersectionInfo> intersections;
RigHexIntersectionTools::lineHexCellIntersection( cvf::Vec3d( p1 ),
cvf::Vec3d( p2 ),
coordsFromNodeIndices( part, nodeIndices ).data(),
coordsFromNodeIndices( part, nodeIndices ),
elemIdx,
&intersections );
@@ -210,23 +210,23 @@ void findReferenceElementForNode( const RigFemPart& part, size_t nodeIdx, size_t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> coordsFromNodeIndices( const RigFemPart& part, const std::vector<size_t>& nodeIdxs )
std::array<cvf::Vec3d, 8> coordsFromNodeIndices( const RigFemPart& part, const std::array<size_t, 8>& nodeIdxs )
{
std::vector<cvf::Vec3d> out;
for ( const auto& nodeIdx : nodeIdxs )
out.push_back( cvf::Vec3d( part.nodes().coordinates[nodeIdx] ) );
std::array<cvf::Vec3d, 8> out;
for ( size_t i = 0; i < nodeIdxs.size(); i++ )
out[i] = cvf::Vec3d( part.nodes().coordinates[nodeIdxs[i]] );
return out;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<size_t> nodesForElement( const RigFemPart& part, size_t elementIdx )
std::array<size_t, 8> nodesForElement( const RigFemPart& part, size_t elementIdx )
{
std::vector<size_t> nodeIdxs;
const int* nodeConn = part.connectivities( elementIdx );
std::array<size_t, 8> nodeIdxs;
const int* nodeConn = part.connectivities( elementIdx );
for ( int n = 0; n < 8; n++ )
nodeIdxs.push_back( nodeConn[n] );
nodeIdxs[n] = nodeConn[n];
return nodeIdxs;
}
@@ -178,8 +178,7 @@ void RivFaultGeometryGenerator::computeArrays( bool onlyShowFacesWithDefinedNeig
{
int myThread = RiaOpenMPTools::currentThreadIndex();
std::array<cvf::Vec3d, 8> cornerVerts;
cvf::ubyte faceConn[4];
cvf::ubyte faceConn[4];
// NB! We are inside a parallel section, do not use "parallel for" here
#pragma omp for
@@ -200,7 +199,7 @@ void RivFaultGeometryGenerator::computeArrays( bool onlyShowFacesWithDefinedNeig
if ( onlyShowFacesWithDefinedNeighbors && !hasConnection( cellIndex, face, connections, connIndices ) ) continue;
m_grid->cellCornerVertices( cellIndex, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = m_grid->cellCornerVertices( cellIndex );
cvf::StructGridInterface::cellFaceVertexIndices( face, faceConn );
for ( int n = 0; n < 4; n++ )
@@ -295,8 +295,6 @@ void RivBoxIntersectionGeometryGenerator::calculateArrays( cvf::UByteArray* visi
hexPlaneCutTriangleVxes.reserve( 5 * 3 );
std::vector<int> cellFaceForEachTriangleEdge;
cellFaceForEachTriangleEdge.reserve( 5 * 3 );
std::array<cvf::Vec3d, 8> cellCorners;
std::array<size_t, 8> cornerIndices;
for ( size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx )
{
@@ -306,8 +304,8 @@ void RivBoxIntersectionGeometryGenerator::calculateArrays( cvf::UByteArray* visi
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
hexPlaneCutTriangleVxes.clear();
m_hexGrid->cellCornerVertices( globalCellIdx, cellCorners );
m_hexGrid->cellCornerIndices( globalCellIdx, cornerIndices );
const std::array<cvf::Vec3d, 8> cellCorners = m_hexGrid->cellCornerVertices( globalCellIdx );
const std::array<size_t, 8> cornerIndices = m_hexGrid->cellCornerIndices( globalCellIdx );
caf::HexGridIntersectionTools::planeHexIntersectionMC( plane,
cellCorners,
@@ -78,19 +78,17 @@ bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& cellCorners ) const
std::array<cvf::Vec3d, 8> RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex ) const
{
m_mainGrid->cellCornerVertices( cellIndex, cellCorners );
return m_mainGrid->cellCornerVertices( cellIndex );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex, std::array<size_t, 8>& cornerIndices ) const
std::array<size_t, 8> RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex ) const
{
const std::array<size_t, 8>& cornerIndicesSource = m_mainGrid->cell( cellIndex ).cornerIndices();
cornerIndices = cornerIndicesSource;
return m_mainGrid->cell( cellIndex ).cornerIndices();
}
//--------------------------------------------------------------------------------------------------
@@ -40,12 +40,12 @@ class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface
public:
RivEclipseIntersectionGrid( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells );
cvf::Vec3d displayOffset() const override;
cvf::BoundingBox boundingBox() const override;
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override;
bool useCell( size_t cellIndex ) const override;
void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& cellCorners ) const override;
void cellCornerIndices( size_t cellIndex, std::array<size_t, 8>& cornerIndices ) const override;
cvf::Vec3d displayOffset() const override;
cvf::BoundingBox boundingBox() const override;
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override;
bool useCell( size_t cellIndex ) const override;
std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const override;
std::array<size_t, 8> cellCornerIndices( size_t cellIndex ) const override;
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override;
void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override;
@@ -377,8 +377,6 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays( cvf::UByteA
hexPlaneCutTriangleVxes.reserve( 5 * 3 );
std::vector<int> cellFaceForEachTriangleEdge;
cellFaceForEachTriangleEdge.reserve( 5 * 3 );
std::array<cvf::Vec3d, 8> cellCorners;
std::array<size_t, 8> cornerIndices;
cvf::Mat4d invSectionCS = m_lineSegmentTransforms[pLineIdx][lIdx];
@@ -388,8 +386,8 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays( cvf::UByteA
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
hexPlaneCutTriangleVxes.clear();
m_hexGrid->cellCornerVertices( globalCellIdx, cellCorners );
m_hexGrid->cellCornerIndices( globalCellIdx, cornerIndices );
std::array<cvf::Vec3d, 8> cellCorners = m_hexGrid->cellCornerVertices( globalCellIdx );
std::array<size_t, 8> cornerIndices = m_hexGrid->cellCornerIndices( globalCellIdx );
caf::HexGridIntersectionTools::planeHexIntersectionMC( plane,
cellCorners,
@@ -71,7 +71,7 @@ bool RivFemIntersectionGrid::useCell( size_t globalCellIndex ) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, std::array<cvf::Vec3d, 8>& cellCorners ) const
std::array<cvf::Vec3d, 8> RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex ) const
{
auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex );
@@ -80,6 +80,7 @@ void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, std::ar
const std::vector<cvf::Vec3f>& nodeCoords = part->nodes().coordinates;
const int* cornerIndices = part->connectivities( elementIdx );
std::array<cvf::Vec3d, 8> cellCorners;
if ( useDisplacements )
{
const double scaleFactor = m_parts->currentDisplacementScaleFactor();
@@ -97,25 +98,29 @@ void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, std::ar
cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] );
}
}
return cellCorners;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemIntersectionGrid::cellCornerIndices( size_t globalCellIndex, std::array<size_t, 8>& cornerIndices ) const
std::array<size_t, 8> RivFemIntersectionGrid::cellCornerIndices( size_t globalCellIndex ) const
{
auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex );
RigElementType elmType = part->elementType( elementIdx );
if ( !RigFemTypes::is8NodeElement( elmType ) ) return;
if ( !RigFemTypes::is8NodeElement( elmType ) ) return {};
int elmIdx = static_cast<int>( elementIdx );
const int partId = part->elementPartId();
std::array<size_t, 8> cornerIndices;
for ( int i = 0; i < 8; i++ )
{
cornerIndices[i] = m_femParts->globalElementNodeResultIdx( partId, elmIdx, i );
}
return cornerIndices;
}
//--------------------------------------------------------------------------------------------------
@@ -38,12 +38,12 @@ class RivFemIntersectionGrid : public RivIntersectionHexGridInterface
public:
explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts );
cvf::Vec3d displayOffset() const override;
cvf::BoundingBox boundingBox() const override;
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override;
bool useCell( size_t cellIndex ) const override;
void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& cellCorners ) const override;
void cellCornerIndices( size_t cellIndex, std::array<size_t, 8>& cornerIndices ) const override;
cvf::Vec3d displayOffset() const override;
cvf::BoundingBox boundingBox() const override;
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override;
bool useCell( size_t cellIndex ) const override;
std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const override;
std::array<size_t, 8> cellCornerIndices( size_t cellIndex ) const override;
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override;
void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override;
@@ -35,12 +35,12 @@ class RigFault;
class RivIntersectionHexGridInterface : public cvf::Object
{
public:
virtual cvf::Vec3d displayOffset() const = 0;
virtual cvf::BoundingBox boundingBox() const = 0;
virtual std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const = 0;
virtual bool useCell( size_t cellIndex ) const = 0;
virtual void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& cellCorners ) const = 0;
virtual void cellCornerIndices( size_t cellIndex, std::array<size_t, 8>& cornerIndices ) const = 0;
virtual cvf::Vec3d displayOffset() const = 0;
virtual cvf::BoundingBox boundingBox() const = 0;
virtual std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const = 0;
virtual bool useCell( size_t cellIndex ) const = 0;
virtual std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const = 0;
virtual std::array<size_t, 8> cellCornerIndices( size_t cellIndex ) const = 0;
virtual const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const = 0;
virtual void setKIntervalFilter( bool enabled, std::string kIntervalStr ) = 0;
};
@@ -669,8 +669,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart( const Rim
{
// Calculate Eclipse cell intersection with fracture plane
std::array<cvf::Vec3d, 8> corners;
activeView.mainGrid()->cellCornerVertices( resCellIdx, corners );
std::array<cvf::Vec3d, 8> corners = activeView.mainGrid()->cellCornerVertices( resCellIdx );
std::vector<std::vector<cvf::Vec3d>> eclCellPolygons;
bool hasIntersection = RigHexIntersectionTools::planeHexIntersectionPolygons( corners, frMx, eclCellPolygons );
@@ -796,11 +795,9 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid( con
bool pointInsideGrid = false;
RigMainGrid* mainGrid = activeView.mainGrid();
std::array<cvf::Vec3d, 8> corners;
for ( size_t cellIndex : cellCandidates )
{
mainGrid->cellCornerVertices( cellIndex, corners );
std::array<cvf::Vec3d, 8> corners = mainGrid->cellCornerVertices( cellIndex );
if ( RigHexIntersectionTools::isPointInCell( pointInDomainCoords, corners ) )
{
pointInsideGrid = true;
@@ -822,8 +819,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid( con
{
// Calculate Eclipse cell intersection with fracture plane
std::array<cvf::Vec3d, 8> corners;
activeView.mainGrid()->cellCornerVertices( resCellIdx, corners );
std::array<cvf::Vec3d, 8> corners = activeView.mainGrid()->cellCornerVertices( resCellIdx );
std::vector<std::vector<cvf::Vec3d>> eclCellPolygons;
bool hasIntersection = RigHexIntersectionTools::planeHexIntersectionPolygons( corners, frMx, eclCellPolygons );
@@ -197,9 +197,6 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
cvf::Plane plane;
plane.setFromPoints( p0, p1, p2 );
std::array<cvf::Vec3d, 8> cellCorners;
std::array<size_t, 8> cornerIndices;
for ( size_t globalCellIdx : triIntersectedCellCandidates )
{
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
@@ -208,8 +205,8 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
cellFaceForEachTriangleEdge.clear();
cellCutTriangles.clear();
m_hexGrid->cellCornerVertices( globalCellIdx, cellCorners );
m_hexGrid->cellCornerIndices( globalCellIdx, cornerIndices );
const std::array<cvf::Vec3d, 8> cellCorners = m_hexGrid->cellCornerVertices( globalCellIdx );
const std::array<size_t, 8> cornerIndices = m_hexGrid->cellCornerIndices( globalCellIdx );
int triangleCount = caf::HexGridIntersectionTools::planeHexIntersectionMCTet( plane,
cellCorners,
@@ -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() );
{
@@ -195,8 +195,7 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
const RigMainGrid* mainGrid = m_case->eclipseCaseData()->mainGrid();
if ( !m_fracture->isEclipseCellOpenForFlow( mainGrid, reservoirCellIndicesOpenForFlow, reservoirCellIndex ) ) continue;
std::array<cvf::Vec3d, 8> hexCorners;
mainGrid->cellCornerVertices( reservoirCellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = mainGrid->cellCornerVertices( reservoirCellIndex );
std::vector<std::vector<cvf::Vec3d>> planeCellPolygons;
bool isPlanIntersected = RigHexIntersectionTools::planeHexIntersectionPolygons( hexCorners, m_fractureTransform, planeCellPolygons );
@@ -257,14 +257,12 @@ size_t RigEclipseContourMapProjection::kLayers() const
//--------------------------------------------------------------------------------------------------
double RigEclipseContourMapProjection::calculateOverlapVolume( size_t globalCellIdx, const cvf::BoundingBox& bbox ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
const RigCell& cell = m_mainGrid->cell( globalCellIdx );
size_t localCellIdx = cell.gridLocalCellIndex();
RigGridBase* localGrid = cell.hostGrid();
localGrid->cellCornerVertices( localCellIdx, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = localGrid->cellCornerVertices( localCellIdx );
cvf::BoundingBox overlapBBox;
std::array<cvf::Vec3d, 8> overlapCorners;
@@ -283,17 +281,15 @@ double RigEclipseContourMapProjection::calculateRayLengthInCell( size_t
const cvf::Vec3d& highestPoint,
const cvf::Vec3d& lowestPoint ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
const RigCell& cell = m_mainGrid->cell( globalCellIdx );
size_t localCellIdx = cell.gridLocalCellIndex();
RigGridBase* localGrid = cell.hostGrid();
localGrid->cellCornerVertices( localCellIdx, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = localGrid->cellCornerVertices( localCellIdx );
std::vector<HexIntersectionInfo> intersections;
if ( RigHexIntersectionTools::lineHexCellIntersection( highestPoint, lowestPoint, hexCorners.data(), 0, &intersections ) )
if ( RigHexIntersectionTools::lineHexCellIntersection( highestPoint, lowestPoint, hexCorners, 0, &intersections ) )
{
double lengthInCell = ( intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint ).length();
return lengthInCell;
@@ -89,8 +89,7 @@ cvf::BoundingBox RigGeoMechContourMapProjection::calculateExpandedPorBarBBox( Ri
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] );
@@ -287,8 +286,7 @@ size_t RigGeoMechContourMapProjection::kLayers() const
//--------------------------------------------------------------------------------------------------
double RigGeoMechContourMapProjection::calculateOverlapVolume( size_t globalCellIdx, const cvf::BoundingBox& bbox ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
m_femPartGrid->cellCornerVertices( globalCellIdx, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_femPartGrid->cellCornerVertices( globalCellIdx );
cvf::BoundingBox overlapBBox;
std::array<cvf::Vec3d, 8> overlapCorners;
@@ -307,23 +305,11 @@ double RigGeoMechContourMapProjection::calculateRayLengthInCell( size_t
const cvf::Vec3d& highestPoint,
const cvf::Vec3d& lowestPoint ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
const std::vector<cvf::Vec3f>& nodeCoords = m_femPart->nodes().coordinates;
const int* cornerIndices = m_femPart->connectivities( globalCellIdx );
hexCorners[0] = cvf::Vec3d( nodeCoords[cornerIndices[0]] );
hexCorners[1] = cvf::Vec3d( nodeCoords[cornerIndices[1]] );
hexCorners[2] = cvf::Vec3d( nodeCoords[cornerIndices[2]] );
hexCorners[3] = cvf::Vec3d( nodeCoords[cornerIndices[3]] );
hexCorners[4] = cvf::Vec3d( nodeCoords[cornerIndices[4]] );
hexCorners[5] = cvf::Vec3d( nodeCoords[cornerIndices[5]] );
hexCorners[6] = cvf::Vec3d( nodeCoords[cornerIndices[6]] );
hexCorners[7] = cvf::Vec3d( nodeCoords[cornerIndices[7]] );
std::array<cvf::Vec3d, 8> hexCorners = m_femPartGrid->cellCornerVertices( globalCellIdx );
std::vector<HexIntersectionInfo> intersections;
if ( RigHexIntersectionTools::lineHexCellIntersection( highestPoint, lowestPoint, hexCorners.data(), 0, &intersections ) )
if ( RigHexIntersectionTools::lineHexCellIntersection( highestPoint, lowestPoint, hexCorners, 0, &intersections ) )
{
double lengthInCell = ( intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint ).length();
return lengthInCell;
@@ -417,17 +417,17 @@ void RigCell::faceIndices( cvf::StructGridInterface::FaceType face, std::array<s
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigCell::boundingBox() const
{
cvf::BoundingBox bb;
std::array<cvf::Vec3d, 8> hexCorners;
cvf::BoundingBox bb;
if ( m_hostGrid )
{
m_hostGrid->cellCornerVertices( m_gridLocalCellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_hostGrid->cellCornerVertices( m_gridLocalCellIndex );
for ( const auto& corner : hexCorners )
{
bb.add( corner );
}
}
return bb;
}
@@ -663,12 +663,11 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxSlow()
}
else
{
std::array<cvf::Vec3d, 8> hexCorners;
for ( size_t i = 0; i < m_mainGrid->cellCount(); i++ )
{
if ( activeInfos[acIdx]->isActive( i ) )
{
m_mainGrid->cellCornerVertices( i, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_mainGrid->cellCornerVertices( i );
for ( const auto& corner : hexCorners )
{
bb.add( corner );
@@ -731,8 +730,7 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxOptimized()
{
size_t cellIndex = m_mainGrid->cellIndexFromIJK( i, j, k );
std::array<cvf::Vec3d, 8> hexCorners;
m_mainGrid->cellCornerVertices( cellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_mainGrid->cellCornerVertices( cellIndex );
for ( const auto& corner : hexCorners )
{
bb.add( corner );
@@ -167,8 +167,9 @@ void RigGridBase::initSubCellsMainGridCellIndex()
/// the cell() call retreives correct cell, because main grid has offset of 0, and we access the global
/// cell array in main grid.
//--------------------------------------------------------------------------------------------------
void RigGridBase::cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& vertices ) const
std::array<cvf::Vec3d, 8> RigGridBase::cellCornerVertices( size_t cellIndex ) const
{
std::array<cvf::Vec3d, 8> vertices;
const std::array<size_t, 8>& indices = cell( cellIndex ).cornerIndices();
vertices[0].set( m_mainGrid->nodes()[indices[0]] );
@@ -179,6 +180,8 @@ void RigGridBase::cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8
vertices[5].set( m_mainGrid->nodes()[indices[5]] );
vertices[6].set( m_mainGrid->nodes()[indices[6]] );
vertices[7].set( m_mainGrid->nodes()[indices[7]] );
return vertices;
}
//--------------------------------------------------------------------------------------------------
@@ -493,12 +496,9 @@ cvf::BoundingBox RigGridBase::boundingBox()
{
if ( !m_boundingBox.isValid() )
{
std::array<cvf::Vec3d, 8> cornerVerts;
for ( size_t i = 0; i < cellCount(); i++ )
{
cellCornerVertices( i, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = cellCornerVertices( i );
for ( size_t j = 0; j < 8; j++ )
{
m_boundingBox.add( cornerVerts[j] );
@@ -104,8 +104,8 @@ public:
bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override; // unused
void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const override; // unused
void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& vertices ) const override;
cvf::Vec3d cellCentroid( size_t cellIndex ) const override;
std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const override;
cvf::Vec3d cellCentroid( size_t cellIndex ) const override;
size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const override;
cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const override;
@@ -28,9 +28,9 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d& p1,
const cvf::Vec3d& p2,
const std::array<cvf::Vec3d, 8>& hexCorners,
const size_t hexIndex,
std::vector<HexIntersectionInfo>* intersections )
{
@@ -82,7 +82,7 @@ int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::lineIntersectsHexCell( const cvf::Vec3d p1, const cvf::Vec3d p2, const cvf::Vec3d hexCorners[8] )
bool RigHexIntersectionTools::lineIntersectsHexCell( const cvf::Vec3d& p1, const cvf::Vec3d& p2, const std::array<cvf::Vec3d, 8>& hexCorners )
{
for ( int face = 0; face < 6; ++face )
{
@@ -119,7 +119,7 @@ bool RigHexIntersectionTools::lineIntersectsHexCell( const cvf::Vec3d p1, const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::isPointInCell( const cvf::Vec3d point, const std::array<cvf::Vec3d, 8>& hexCorners )
bool RigHexIntersectionTools::isPointInCell( const cvf::Vec3d& point, const std::array<cvf::Vec3d, 8>& hexCorners )
{
cvf::Ray ray;
ray.setOrigin( point );
@@ -149,7 +149,7 @@ bool RigHexIntersectionTools::isPointInCell( const cvf::Vec3d point, const std::
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::planeHexCellIntersection( cvf::Vec3d* hexCorners,
bool RigHexIntersectionTools::planeHexCellIntersection( const std::array<cvf::Vec3d, 8>& hexCorners,
const cvf::Plane& fracturePlane,
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments )
{
@@ -196,7 +196,7 @@ bool RigHexIntersectionTools::planeHexCellIntersection( cvf::Vec3d*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigHexIntersectionTools::planeHexIntersectionPolygons( std::array<cvf::Vec3d, 8> hexCorners,
bool RigHexIntersectionTools::planeHexIntersectionPolygons( const std::array<cvf::Vec3d, 8>& hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d>>& polygons )
{
@@ -208,7 +208,7 @@ bool RigHexIntersectionTools::planeHexIntersectionPolygons( std::array<cvf::Vec3
// Find line-segments where cell and fracture plane intersects
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>> intersectionLineSegments;
isCellIntersected = planeHexCellIntersection( hexCorners.data(), fracturePlane, intersectionLineSegments );
isCellIntersected = planeHexCellIntersection( hexCorners, fracturePlane, intersectionLineSegments );
RigCellGeometryTools::createPolygonFromLineSegments( intersectionLineSegments, polygons );
@@ -52,21 +52,21 @@ bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2 )
//--------------------------------------------------------------------------------------------------
struct RigHexIntersectionTools
{
static int lineHexCellIntersection( const cvf::Vec3d p1,
const cvf::Vec3d p2,
const cvf::Vec3d hexCorners[8],
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 cvf::Vec3d hexCorners[8] );
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 isPointInCell( const cvf::Vec3d& point, const std::array<cvf::Vec3d, 8>& hexCorners );
static bool planeHexCellIntersection( cvf::Vec3d* 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( std::array<cvf::Vec3d, 8> hexCorners,
static bool planeHexIntersectionPolygons( const std::array<cvf::Vec3d, 8>& hexCorners,
cvf::Mat4d transformMatrixForPlane,
std::vector<std::vector<cvf::Vec3d>>& polygons );
};
@@ -156,26 +156,21 @@ size_t RigMainGrid::reservoirCellIndexByGridAndGridLocalCellIndex( size_t gridId
//--------------------------------------------------------------------------------------------------
size_t RigMainGrid::findReservoirCellIndexFromPoint( const cvf::Vec3d& point ) const
{
size_t cellContainingPoint = cvf::UNDEFINED_SIZE_T;
cvf::BoundingBox pointBBox;
pointBBox.add( point );
std::vector<size_t> cellIndices = m_mainGrid->findIntersectingCells( pointBBox );
std::array<cvf::Vec3d, 8> hexCorners;
for ( size_t cellIndex : cellIndices )
{
m_mainGrid->cellCornerVertices( cellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_mainGrid->cellCornerVertices( cellIndex );
if ( RigHexIntersectionTools::isPointInCell( point, hexCorners ) )
{
cellContainingPoint = cellIndex;
break;
return cellIndex;
}
}
return cellContainingPoint;
return cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
@@ -75,16 +75,14 @@ void RigEclipseWellLogExtractor::calculateIntersection()
std::vector<size_t> closeCellIndices = findCloseCellIndices( bb );
std::array<cvf::Vec3d, 8> hexCorners;
for ( const auto& globalCellIndex : closeCellIndices )
{
const RigCell& cell = m_caseData->mainGrid()->cell( globalCellIndex );
if ( cell.isInvalid() || cell.subGrid() != nullptr ) continue;
m_caseData->mainGrid()->cellCornerVertices( globalCellIndex, hexCorners );
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners.data(), globalCellIndex, &intersections );
std::array<cvf::Vec3d, 8> hexCorners = m_caseData->mainGrid()->cellCornerVertices( globalCellIndex );
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners, globalCellIndex, &intersections );
}
if ( !isCellFaceNormalsOut )
@@ -121,15 +119,13 @@ void RigEclipseWellLogExtractor::calculateIntersection()
std::vector<size_t> closeCellIndices = findCloseCellIndices( bb );
std::array<cvf::Vec3d, 8> hexCorners;
for ( const auto& globalCellIndex : closeCellIndices )
{
const RigCell& cell = m_caseData->mainGrid()->cell( globalCellIndex );
if ( cell.isInvalid() ) continue;
m_caseData->mainGrid()->cellCornerVertices( globalCellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_caseData->mainGrid()->cellCornerVertices( globalCellIndex );
if ( RigHexIntersectionTools::isPointInCell( firstPoint, hexCorners ) )
{
if ( RigHexIntersectionTools::isPointInCell( lastPoint, hexCorners ) )
@@ -202,8 +198,7 @@ std::vector<size_t> RigEclipseWellLogExtractor::findCloseCellIndices( const cvf:
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell( size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint ) const
{
std::array<cvf::Vec3d, 8> hexCorners;
m_caseData->mainGrid()->cellCornerVertices( cellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = m_caseData->mainGrid()->cellCornerVertices( cellIndex );
return RigWellPathIntersectionTools::calculateLengthInCell( hexCorners, startPoint, endPoint );
}
@@ -1139,7 +1139,6 @@ void RigGeoMechWellLogExtractor::calculateIntersection()
std::vector<size_t> closeCells = findCloseCells( bb );
cvf::Vec3d hexCorners[8];
for ( size_t ccIdx = 0; ccIdx < closeCells.size(); ++ccIdx )
{
RigElementType elmType = femPart->elementType( closeCells[ccIdx] );
@@ -1147,6 +1146,8 @@ void RigGeoMechWellLogExtractor::calculateIntersection()
const int* cornerIndices = femPart->connectivities( closeCells[ccIdx] );
std::array<cvf::Vec3d, 8> hexCorners;
hexCorners[0] = cvf::Vec3d( nodeCoords[cornerIndices[0]] );
hexCorners[1] = cvf::Vec3d( nodeCoords[cornerIndices[1]] );
hexCorners[2] = cvf::Vec3d( nodeCoords[cornerIndices[2]] );
@@ -142,8 +142,7 @@ cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell( const RigMainGri
const cvf::Vec3d& startPoint,
const cvf::Vec3d& endPoint )
{
std::array<cvf::Vec3d, 8> hexCorners;
grid->cellCornerVertices( cellIndex, hexCorners );
std::array<cvf::Vec3d, 8> hexCorners = grid->cellCornerVertices( cellIndex );
return calculateLengthInCell( hexCorners, startPoint, endPoint );
}
@@ -279,9 +279,8 @@ public:
// dv(3) = 8;
// dv(4) = 3;
std::array<cvf::Vec3d, 8> cornerVerts;
size_t blockByteCount = cellCount * sizeof( double );
std::vector<double> doubleValues( blockByteCount );
size_t blockByteCount = cellCount * sizeof( double );
std::vector<double> doubleValues( blockByteCount );
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
{
@@ -298,8 +297,8 @@ public:
for ( size_t i = 0; i < cellCountI; i++ )
{
size_t gridLocalCellIndex = rigGrid->cellIndexFromIJK( i, j, k );
rigGrid->cellCornerVertices( gridLocalCellIndex, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = rigGrid->cellCornerVertices( gridLocalCellIndex );
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts, cornerIndexMapping, coordIdx );
}
}
@@ -367,9 +366,8 @@ public:
// dv(1) = 8;
// dv(2) = 3;
std::array<cvf::Vec3d, 8> cornerVerts;
size_t blockByteCount = activeCellCount * sizeof( double );
std::vector<double> doubleValues( blockByteCount );
size_t blockByteCount = activeCellCount * sizeof( double );
std::vector<double> doubleValues( blockByteCount );
for ( int coordIdx = 0; coordIdx < 3; coordIdx++ )
{
@@ -383,9 +381,8 @@ public:
{
if ( !actCellInfo->isActive( reservoirCellIndex ) ) continue;
mainGrid->cellCornerVertices( reservoirCellIndex, cornerVerts );
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts, cornerIndexMapping, coordIdx );
std::array<cvf::Vec3d, 8> cornerVerts = mainGrid->cellCornerVertices( reservoirCellIndex );
doubleValues[valueIndex++] = getCellCornerWithPositiveDepth( cornerVerts, cornerIndexMapping, coordIdx );
}
CVF_ASSERT( valueIndex == activeCellCount );
@@ -29,7 +29,7 @@
//--------------------------------------------------------------------------------------------------
TEST( RigHexIntersectionTools, planeHexCellIntersectionTest )
{
cvf::Vec3d hexCorners[8];
std::array<cvf::Vec3d, 8> hexCorners;
hexCorners[0] = cvf::Vec3d( 0, 0, 0 );
hexCorners[1] = cvf::Vec3d( 1, 0, 0 );
hexCorners[2] = cvf::Vec3d( 0, 1, 0 );
@@ -57,7 +57,7 @@ TEST( RigHexIntersectionTools, planeHexCellIntersectionTest )
//--------------------------------------------------------------------------------------------------
TEST( RigHexIntersectionTools, DISABLED_planeHexCellIntersectionPerformanceTest )
{
cvf::Vec3d hexCorners[8];
std::array<cvf::Vec3d, 8> hexCorners;
hexCorners[0] = cvf::Vec3d( 0, 0, 0 );
hexCorners[1] = cvf::Vec3d( 1, 0, 0 );
hexCorners[2] = cvf::Vec3d( 0, 1, 0 );
+2 -3
View File
@@ -373,8 +373,7 @@ void StructGridInterface::computeCharacteristicCellSize( const std::vector<size_
double jLengthAccumulated = 0.0;
double kLengthAccumulated = 0.0;
std::array<cvf::Vec3d, 8> cornerVerts;
size_t evaluatedCellCount = 0;
size_t evaluatedCellCount = 0;
// Evaluate N-th cells, compute the stride between each index
size_t stride = std::max( size_t( 1 ), globalCellIndices.size() / 100 );
@@ -387,7 +386,7 @@ void StructGridInterface::computeCharacteristicCellSize( const std::vector<size_
ijkFromCellIndex( cellIndex, &i, &j, &k );
if ( isCellValid( i, j, k ) )
{
cellCornerVertices( cellIndex, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = cellCornerVertices( cellIndex );
cvf::BoundingBox bb;
for ( const auto& v : cornerVerts )
+2 -2
View File
@@ -101,8 +101,8 @@ public:
virtual bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const = 0;
virtual void cellCornerVertices( size_t cellIndex, std::array<cvf::Vec3d, 8>& vertices ) const = 0;
virtual cvf::Vec3d cellCentroid( size_t cellIndex ) const = 0;
virtual std::array<cvf::Vec3d, 8> cellCornerVertices( size_t cellIndex ) const = 0;
virtual cvf::Vec3d cellCentroid( size_t cellIndex ) const = 0;
virtual void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const = 0;
virtual size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const = 0;
@@ -276,8 +276,7 @@ ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(
size_t cellIndex,
const cvf::Vec3d& displayModelOffset )
{
std::array<cvf::Vec3d, 8> cornerVerts;
grid->cellCornerVertices( cellIndex, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = grid->cellCornerVertices( cellIndex );
std::vector<Vec3f> vertices;
@@ -415,8 +414,7 @@ void StructGridGeometryGenerator::computeArrays()
if ( !visibleFaces.empty() )
{
std::array<cvf::Vec3d, 8> cornerVerts;
m_grid->cellCornerVertices( cellIndex, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = m_grid->cellCornerVertices( cellIndex );
size_t idx;
for ( idx = 0; idx < visibleFaces.size(); idx++ )
+2 -3
View File
@@ -311,9 +311,8 @@ void RiaActiveCellInfoStateHandler::assignCellCorners( rips::CellCorners*
const std::vector<RigCell>& reservoirCells,
size_t cellIdx )
{
std::array<cvf::Vec3d, 8> cornerVerts;
RigGridBase* grid = m_eclipseCase->eclipseCaseData()->mainGrid();
grid->cellCornerVertices( cellIdx, cornerVerts );
RigGridBase* grid = m_eclipseCase->eclipseCaseData()->mainGrid();
std::array<cvf::Vec3d, 8> cornerVerts = grid->cellCornerVertices( cellIdx );
for ( cvf::Vec3d& corner : cornerVerts )
{
RiaGrpcHelper::convertVec3dToPositiveDepth( &corner );
+1 -2
View File
@@ -104,10 +104,9 @@ grpc::Status RiaCellCenterStateHandler::assignCornersReply( rips::CellCornersArr
size_t indexInPackage = 0u;
reply->mutable_cells()->Reserve( (int)packageSize );
std::array<cvf::Vec3d, 8> cornerVerts;
for ( ; indexInPackage < packageSize && m_currentCellIdx < m_grid->cellCount(); ++indexInPackage )
{
m_grid->cellCornerVertices( m_currentCellIdx, cornerVerts );
std::array<cvf::Vec3d, 8> cornerVerts = m_grid->cellCornerVertices( m_currentCellIdx );
for ( cvf::Vec3d& corner : cornerVerts )
{
RiaGrpcHelper::convertVec3dToPositiveDepth( &corner );