From ee8988af2ecc120321eeeb4539d5c0df03277ecc Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 3 Jan 2024 09:34:09 +0100 Subject: [PATCH] Refactor: improve interface for finding intersecting cells. --- .../GeoMech/GeoMechDataModel/RigFemPart.cpp | 10 ++++++---- .../GeoMech/GeoMechDataModel/RigFemPart.h | 4 ++-- .../GeoMechDataModel/RigFemPartCollection.cpp | 14 +++++++------- .../GeoMechDataModel/RigFemPartCollection.h | 3 +-- .../RigFemPartResultCalculatorCompaction.cpp | 3 +-- .../RivBoxIntersectionGeometryGenerator.cpp | 3 +-- .../Intersections/RivEclipseIntersectionGrid.cpp | 4 ++-- .../Intersections/RivEclipseIntersectionGrid.h | 16 ++++++++-------- ...xtrudedCurveIntersectionGeometryGenerator.cpp | 3 +-- .../Intersections/RivFemIntersectionGrid.cpp | 7 ++----- .../Intersections/RivFemIntersectionGrid.h | 16 ++++++++-------- .../RivIntersectionHexGridInterface.h | 12 ++++++------ .../RivWellFracturePartMgr.cpp | 6 ++---- .../RivSurfaceIntersectionGeometryGenerator.cpp | 6 ++---- .../CellFilters/RimPolygonFilter.cpp | 3 +-- .../ProjectDataModel/Completions/RimFracture.cpp | 8 ++------ .../GeoMech/RimGeoMechContourMapProjection.cpp | 4 +--- .../RimGeoMechFaultReactivationResult.cpp | 2 +- .../RimEclipseContourMapProjection.cpp | 4 +--- .../WellPath/RimWellIADataAccess.cpp | 3 +-- ...eToStimPlanCellTransmissibilityCalculator.cpp | 6 ++---- .../RigCaseToCaseCellMapper.cpp | 3 +-- .../RigCaseToCaseRangeFilterMapper.cpp | 9 +++------ .../RigCellFaceGeometryTools.cpp | 3 +-- .../RigEclipseWellLogExtractor.cpp | 4 +--- .../RigGeoMechWellLogExtractor.cpp | 7 +++---- .../ReservoirDataModel/RigMainGrid.cpp | 10 +++++----- .../ReservoirDataModel/RigMainGrid.h | 4 ++-- .../ReservoirDataModel/RigStimPlanModelTools.cpp | 3 +-- 29 files changed, 75 insertions(+), 105 deletions(-) diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp index 29258b93ba..9a98cf625f 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -516,19 +516,21 @@ cvf::BoundingBox RigFemPart::boundingBox() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigFemPart::findIntersectingElementIndices( const cvf::BoundingBox& inputBB, std::vector* elementIndices ) const +std::vector RigFemPart::findIntersectingElementIndices( const cvf::BoundingBox& inputBB ) const { ensureIntersectionSearchTreeIsBuilt(); - findIntersectingElementsWithExistingSearchTree( inputBB, elementIndices ); + return findIntersectingElementsWithExistingSearchTree( inputBB ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigFemPart::findIntersectingElementsWithExistingSearchTree( const cvf::BoundingBox& inputBB, std::vector* elementIndices ) const +std::vector RigFemPart::findIntersectingElementsWithExistingSearchTree( const cvf::BoundingBox& inputBB ) const { CVF_ASSERT( m_elementSearchTree.notNull() ); - m_elementSearchTree->findIntersections( inputBB, elementIndices ); + std::vector elementIndices; + m_elementSearchTree->findIntersections( inputBB, &elementIndices ); + return elementIndices; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h index 11c83aa732..94ce09cbd9 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -87,8 +87,8 @@ class RigFemPart : public cvf::Object cvf::BoundingBox boundingBox() const; float characteristicElementSize() const; const std::vector& possibleGridCornerElements() const; - void findIntersectingElementIndices( const cvf::BoundingBox& inputBB, std::vector* elementIndices ) const; - void findIntersectingElementsWithExistingSearchTree( const cvf::BoundingBox& inputBB, std::vector* elementIndices ) const; + std::vector findIntersectingElementIndices( const cvf::BoundingBox& inputBB ) const; + std::vector findIntersectingElementsWithExistingSearchTree( const cvf::BoundingBox& inputBB ) const; void ensureIntersectionSearchTreeIsBuilt() const; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp index bff4ff5b2e..1890dafe2f 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp @@ -169,19 +169,20 @@ size_t RigFemPartCollection::globalElementIndex( int partId, size_t localIndex ) //-------------------------------------------------------------------------------------------------- /// Find intersecting global element indexes for a given bounding box //-------------------------------------------------------------------------------------------------- -void RigFemPartCollection::findIntersectingGlobalElementIndices( const cvf::BoundingBox& intersectingBB, - std::vector* intersectedGlobalElementIndices ) const +std::vector RigFemPartCollection::findIntersectingGlobalElementIndices( const cvf::BoundingBox& intersectingBB ) const { + std::vector intersectedGlobalElementIndices; for ( const auto& part : m_femParts ) { - std::vector foundElements; - part->findIntersectingElementIndices( intersectingBB, &foundElements ); + std::vector foundElements = part->findIntersectingElementIndices( intersectingBB ); for ( const auto& foundElement : foundElements ) { const size_t globalIdx = globalElementIndex( part->elementPartId(), foundElement ); - intersectedGlobalElementIndices->push_back( globalIdx ); + intersectedGlobalElementIndices.push_back( globalIdx ); } } + + return intersectedGlobalElementIndices; } //-------------------------------------------------------------------------------------------------- @@ -193,8 +194,7 @@ int RigFemPartCollection::getPartIndexFromPoint( const cvf::Vec3d& point ) const // Find candidates for intersected global elements const cvf::BoundingBox intersectingBb( point, point ); - std::vector intersectedGlobalElementIndexCandidates; - findIntersectingGlobalElementIndices( intersectingBb, &intersectedGlobalElementIndexCandidates ); + std::vector intersectedGlobalElementIndexCandidates = findIntersectingGlobalElementIndices( intersectingBb ); if ( intersectedGlobalElementIndexCandidates.empty() ) return idx; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h index 694d72d301..2c23bb008c 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h @@ -42,8 +42,7 @@ class RigFemPartCollection : public cvf::Object std::pair partAndElementIndex( size_t globalIndex ) const; size_t globalElementIndex( int partId, size_t localIndex ) const; - void findIntersectingGlobalElementIndices( const cvf::BoundingBox& intersectingBB, - std::vector* intersectedGlobalElementIndices ) const; + std::vector findIntersectingGlobalElementIndices( const cvf::BoundingBox& intersectingBB ) const; int nodeIdxFromElementNodeResultIdx( size_t globalResultIdx ) const; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp index 29a19cb77a..bc09c421bf 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp @@ -163,8 +163,7 @@ void findReferenceElementForNode( const RigFemPart& part, size_t nodeIdx, size_t bb.add( p1 ); bb.add( p2 ); - std::vector refElementCandidates; - part.findIntersectingElementIndices( bb, &refElementCandidates ); + std::vector refElementCandidates = part.findIntersectingElementIndices( bb ); const RigFemPartGrid* grid = part.getOrCreateStructGrid(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp index b4d4c7d91d..8f50a5bb9d 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp @@ -289,8 +289,7 @@ void RivBoxIntersectionGeometryGenerator::calculateArrays( cvf::UByteArray* visi // Similar code as IntersectionGenerator : - std::vector columnCellCandidates; - m_hexGrid->findIntersectingCells( sectionBBox, &columnCellCandidates ); + std::vector columnCellCandidates = m_hexGrid->findIntersectingCells( sectionBBox ); std::vector hexPlaneCutTriangleVxes; hexPlaneCutTriangleVxes.reserve( 5 * 3 ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp index 3287749199..04c9d8ebed 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp @@ -51,9 +51,9 @@ cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivEclipseIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, std::vector* intersectedCells ) const +std::vector RivEclipseIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const { - m_mainGrid->findIntersectingCells( intersectingBB, intersectedCells ); + return m_mainGrid->findIntersectingCells( intersectingBB ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h index 4d65c1b3fb..8e607a5e46 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h @@ -40,14 +40,14 @@ class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface public: RivEclipseIntersectionGrid( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells ); - cvf::Vec3d displayOffset() const override; - cvf::BoundingBox boundingBox() const override; - void findIntersectingCells( const cvf::BoundingBox& intersectingBB, std::vector* intersectedCells ) const override; - bool useCell( size_t cellIndex ) const override; - void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override; - void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override; - const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override; - void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override; + cvf::Vec3d displayOffset() const override; + cvf::BoundingBox boundingBox() const override; + std::vector findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override; + bool useCell( size_t cellIndex ) const override; + void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override; + void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override; + const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override; + void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override; private: cvf::cref m_mainGrid; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index adbf53ba60..d30e0b6d9c 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -363,8 +363,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays( cvf::UByteA sectionBBox.cutBelow( bottomDepth ); sectionBBox.cutAbove( topDepth ); - std::vector columnCellCandidates; - m_hexGrid->findIntersectingCells( sectionBBox, &columnCellCandidates ); + std::vector columnCellCandidates = m_hexGrid->findIntersectingCells( sectionBBox ); cvf::Plane plane; plane.setFromPoints( p1, p2, p2 + maxHeightVec ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp index 854fb7d564..3ea150cc26 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp @@ -51,14 +51,11 @@ cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFemIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, std::vector* intersectedCells ) const +std::vector RivFemIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const { // For FEM models the term element is used instead of cell. // Each FEM part has a local element index which is transformed into global index for a FEM part collection. - std::vector intersectedGlobalElementIndices; - m_femParts->findIntersectingGlobalElementIndices( intersectingBB, &intersectedGlobalElementIndices ); - - *intersectedCells = intersectedGlobalElementIndices; + return m_femParts->findIntersectingGlobalElementIndices( intersectingBB ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h index 5a3d03f0aa..f2751a9814 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h @@ -38,14 +38,14 @@ class RivFemIntersectionGrid : public RivIntersectionHexGridInterface public: explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts ); - cvf::Vec3d displayOffset() const override; - cvf::BoundingBox boundingBox() const override; - void findIntersectingCells( const cvf::BoundingBox& intersectingBB, std::vector* intersectedCells ) const override; - bool useCell( size_t cellIndex ) const override; - void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override; - void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override; - const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override; - void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override; + cvf::Vec3d displayOffset() const override; + cvf::BoundingBox boundingBox() const override; + std::vector findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const override; + bool useCell( size_t cellIndex ) const override; + void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override; + void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override; + const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const override; + void setKIntervalFilter( bool enabled, std::string kIntervalStr ) override; private: cvf::cref m_femParts; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h index 41e86c8d79..0fcf5ed761 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h @@ -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 void findIntersectingCells( const cvf::BoundingBox& intersectingBB, std::vector* intersectedCells ) const = 0; - virtual bool useCell( size_t cellIndex ) const = 0; - virtual void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const = 0; - virtual void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const = 0; + virtual cvf::Vec3d displayOffset() const = 0; + virtual cvf::BoundingBox boundingBox() const = 0; + virtual std::vector findIntersectingCells( const cvf::BoundingBox& intersectingBB ) const = 0; + virtual bool useCell( size_t cellIndex ) const = 0; + virtual void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const = 0; + virtual void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const = 0; virtual const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const = 0; virtual void setKIntervalFilter( bool enabled, std::string kIntervalStr ) = 0; }; diff --git a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp index 6c176fee00..2580c08c48 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -653,8 +653,7 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart( const Rim frBBox.add( pvd ); } - std::vector cellCandidates; - activeView.mainGrid()->findIntersectingCells( frBBox, &cellCandidates ); + std::vector cellCandidates = activeView.mainGrid()->findIntersectingCells( frBBox ); auto displCoordTrans = activeView.displayCoordTransform(); @@ -780,8 +779,7 @@ cvf::ref RivWellFracturePartMgr::createMaskOfFractureOutsideGrid( con std::vector> clippedPolygons; - std::vector cellCandidates; - activeView.mainGrid()->findIntersectingCells( frBBox, &cellCandidates ); + std::vector cellCandidates = activeView.mainGrid()->findIntersectingCells( frBBox ); if ( cellCandidates.empty() ) { clippedPolygons.push_back( borderOfFractureCellPolygonLocalCsd ); diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp index 9898fe28d6..a799cffe53 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp @@ -154,8 +154,7 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays() // Ensure AABB search tree is constructed outside parallel loop { - std::vector triIntersectedCellCandidates; - m_hexGrid->findIntersectingCells( cvf::BoundingBox(), &triIntersectedCellCandidates ); + std::vector triIntersectedCellCandidates = m_hexGrid->findIntersectingCells( cvf::BoundingBox() ); } #pragma omp parallel num_threads( 6 ) // More threads have nearly no effect @@ -193,8 +192,7 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d maxHeightVec; - std::vector triIntersectedCellCandidates; - m_hexGrid->findIntersectingCells( triangleBBox, &triIntersectedCellCandidates ); + std::vector triIntersectedCellCandidates = m_hexGrid->findIntersectingCells( triangleBBox ); cvf::Plane plane; plane.setFromPoints( p0, p1, p2 ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 77e4599511..1cc0af5fb7 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -914,8 +914,7 @@ int RimPolygonFilter::findEclipseKLayer( const std::vector& points, rayBBox.add( lowestPoint ); // Find the cells intersecting the ray - std::vector allCellIndices; - mainGrid->findIntersectingCells( rayBBox, &allCellIndices ); + std::vector allCellIndices = mainGrid->findIntersectingCells( rayBBox ); // Get the minimum K layer index int minK = std::numeric_limits::max(); diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp index d1c7cb6227..bbc536d936 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFracture.cpp @@ -203,14 +203,10 @@ void RimFracture::setStimPlanTimeIndexToPlot( int timeIndex ) //-------------------------------------------------------------------------------------------------- std::vector RimFracture::getPotentiallyFracturedCells( const RigMainGrid* mainGrid ) const { - std::vector cellindecies; - if ( !mainGrid ) return cellindecies; + if ( !mainGrid ) return {}; cvf::BoundingBox fractureBBox = boundingBoxInDomainCoords(); - - mainGrid->findIntersectingCells( fractureBBox, &cellindecies ); - - return cellindecies; + return mainGrid->findIntersectingCells( fractureBBox ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp index 1575ea7963..1d092dc7b5 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp @@ -451,9 +451,7 @@ RimGridView* RimGeoMechContourMapProjection::baseView() const //-------------------------------------------------------------------------------------------------- std::vector RimGeoMechContourMapProjection::findIntersectingCells( const cvf::BoundingBox& bbox ) const { - std::vector allCellIndices; - m_femPart->findIntersectingElementsWithExistingSearchTree( bbox, &allCellIndices ); - return allCellIndices; + return m_femPart->findIntersectingElementsWithExistingSearchTree( bbox ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp index 2e0ceb1e32..e4e6570253 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechFaultReactivationResult.cpp @@ -327,7 +327,7 @@ void RimGeoMechFaultReactivationResult::createWellLogCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogExtractionCurve* RimGeoMechFaultReactivationResult::createWellLogExtractionCurveAndAddToTrack( RimWellLogTrack* track, +RimWellLogExtractionCurve* RimGeoMechFaultReactivationResult::createWellLogExtractionCurveAndAddToTrack( RimWellLogTrack* track, const RigFemResultAddress& resultAddress, RimModeledWellPath* wellPath, int partId ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp index 207adb36e3..a7a82ef301 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapProjection.cpp @@ -402,9 +402,7 @@ RimGridView* RimEclipseContourMapProjection::baseView() const //-------------------------------------------------------------------------------------------------- std::vector RimEclipseContourMapProjection::findIntersectingCells( const cvf::BoundingBox& bbox ) const { - std::vector allCellIndices; - m_mainGrid->findIntersectingCells( bbox, &allCellIndices ); - return allCellIndices; + return m_mainGrid->findIntersectingCells( bbox ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp index c2bcf99ee3..5a2060c417 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp @@ -71,8 +71,7 @@ int RimWellIADataAccess::elementIndex( cvf::Vec3d position ) auto part = m_caseData->femParts()->part( 0 ); - std::vector closeElements; - part->findIntersectingElementIndices( bb, &closeElements ); + std::vector closeElements = part->findIntersectingElementIndices( bb ); if ( closeElements.empty() ) return -1; for ( auto elmIdx : closeElements ) diff --git a/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp index 25f5470e55..70ae0e861a 100644 --- a/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp @@ -343,10 +343,8 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM std::vector RigEclipseToStimPlanCellTransmissibilityCalculator::getPotentiallyFracturedCellsForPolygon( const std::vector& polygon ) const { - std::vector cellIndices; - const RigMainGrid* mainGrid = m_case->eclipseCaseData()->mainGrid(); - if ( !mainGrid ) return cellIndices; + if ( !mainGrid ) return {}; cvf::BoundingBox polygonBBox; for ( const cvf::Vec3d& nodeCoord : polygon ) @@ -354,7 +352,7 @@ std::vector polygonBBox.add( nodeCoord ); } - mainGrid->findIntersectingCells( polygonBBox, &cellIndices ); + std::vector cellIndices = mainGrid->findIntersectingCells( polygonBBox ); std::vector cellIndicesToLeafCells; for ( const size_t& index : cellIndices ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp index 9d1eb68647..356651abce 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp @@ -159,8 +159,7 @@ void RigCaseToCaseCellMapper::calculateEclToGeomCellMapping( RigMainGrid* master for ( int i = 0; i < 8; ++i ) elmBBox.add( geoMechConvertedEclCell[i] ); - std::vector closeElements; - dependentFemPart->findIntersectingElementIndices( elmBBox, &closeElements ); + std::vector closeElements = dependentFemPart->findIntersectingElementIndices( elmBBox ); for ( size_t ccIdx = 0; ccIdx < closeElements.size(); ++ccIdx ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp index 6e9698f9a9..f69eaa0933 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseToCaseRangeFilterMapper.cpp @@ -382,8 +382,7 @@ RigCaseToCaseRangeFilterMapper::CellMatchType RigCaseToCaseRangeFilterMapper::fi for ( int i = 0; i < 8; ++i ) elmBBox.add( geoMechConvertedEclCell[i] ); - std::vector closeElements; - dependentFemPart->findIntersectingElementIndices( elmBBox, &closeElements ); + std::vector closeElements = dependentFemPart->findIntersectingElementIndices( elmBBox ); cvf::Vec3d elmCorners[8]; int elmIdxToBestMatch = -1; @@ -465,10 +464,8 @@ RigCaseToCaseRangeFilterMapper::CellMatchType RigCaseToCaseRangeFilterMapper::fi for ( int i = 0; i < 8; ++i ) elmBBox.add( elmCorners[i] ); - std::vector closeCells; - masterEclGrid->findIntersectingCells( elmBBox, - &closeCells ); // This might actually miss the exact one, but we have no other - // alternative yet. + // This might actually miss the exact one, but we have no other alternative yet. + std::vector closeCells = masterEclGrid->findIntersectingCells( elmBBox ); size_t globCellIdxToBestMatch = cvf::UNDEFINED_SIZE_T; double sqDistToClosestCellCenter = HUGE_VAL; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 6aacf9d7f0..e01fc78421 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -236,8 +236,7 @@ void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultF bb.add( mainGridNodes[sourceFaceIndices[2]] ); bb.add( mainGridNodes[sourceFaceIndices[3]] ); - std::vector closeCells; - mainGrid->findIntersectingCells( bb, &closeCells ); + std::vector closeCells = mainGrid->findIntersectingCells( bb ); cvf::StructGridInterface::FaceType candidateFace = cvf::StructGridInterface::oppositeFace( sourceCellFace ); diff --git a/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index 571e27babe..88d02f9312 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -193,9 +193,7 @@ void RigEclipseWellLogExtractor::curveData( const RigResultAccessor* resultAcces //-------------------------------------------------------------------------------------------------- std::vector RigEclipseWellLogExtractor::findCloseCellIndices( const cvf::BoundingBox& bb ) { - std::vector closeCells; - m_caseData->mainGrid()->findIntersectingCells( bb, &closeCells ); - return closeCells; + return m_caseData->mainGrid()->findIntersectingCells( bb ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 9c2fd324db..a1f2cf6a55 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -1025,13 +1025,12 @@ void RigGeoMechWellLogExtractor::calculateIntersection() //-------------------------------------------------------------------------------------------------- std::vector RigGeoMechWellLogExtractor::findCloseCells( const cvf::BoundingBox& bb ) { - std::vector closeCells; - if ( m_caseData->femParts()->partCount() ) { - m_caseData->femParts()->part( m_partId )->findIntersectingElementIndices( bb, &closeCells ); + return m_caseData->femParts()->part( m_partId )->findIntersectingElementIndices( bb ); } - return closeCells; + + return {}; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp index b3cfba5026..24c1d6c33d 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.cpp @@ -151,8 +151,7 @@ size_t RigMainGrid::findReservoirCellIndexFromPoint( const cvf::Vec3d& point ) c cvf::BoundingBox pointBBox; pointBBox.add( point ); - std::vector cellIndices; - m_mainGrid->findIntersectingCells( pointBBox, &cellIndices ); + std::vector cellIndices = m_mainGrid->findIntersectingCells( pointBBox ); cvf::Vec3d hexCorners[8]; for ( size_t cellIndex : cellIndices ) @@ -781,11 +780,12 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace( size_t reservoir //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigMainGrid::findIntersectingCells( const cvf::BoundingBox& inputBB, std::vector* cellIndices ) const +std::vector RigMainGrid::findIntersectingCells( const cvf::BoundingBox& inputBB ) const { CVF_ASSERT( m_cellSearchTree.notNull() ); - - m_cellSearchTree->findIntersections( inputBB, cellIndices ); + std::vector cellIndices; + m_cellSearchTree->findIntersections( inputBB, &cellIndices ); + return cellIndices; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h index bc38322b7b..dc0b682603 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationLibCode/ReservoirDataModel/RigMainGrid.h @@ -94,8 +94,8 @@ class RigMainGrid : public RigGridBase cvf::Vec3d displayModelOffset() const override; void setDisplayModelOffset( cvf::Vec3d offset ); - void setFlipAxis( bool flipXAxis, bool flipYAxis ); - void findIntersectingCells( const cvf::BoundingBox& inputBB, std::vector* cellIndices ) const; + void setFlipAxis( bool flipXAxis, bool flipYAxis ); + std::vector findIntersectingCells( const cvf::BoundingBox& inputBB ) const; cvf::BoundingBox boundingBox() const; diff --git a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp index 47c6eb515f..5c3f423a5b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigStimPlanModelTools.cpp @@ -54,8 +54,7 @@ cvf::Vec3d RigStimPlanModelTools::calculateTSTDirection( RigEclipseCaseData* ecl // Find upper face of cells close to the anchor point cvf::BoundingBox boundingBox( anchorPosition - boundingBoxSize, anchorPosition + boundingBoxSize ); - std::vector closeCells; - mainGrid->findIntersectingCells( boundingBox, &closeCells ); + std::vector closeCells = mainGrid->findIntersectingCells( boundingBox ); // The stratigraphic thickness is the averge of normals of the top face cvf::Vec3d direction = cvf::Vec3d::ZERO;