diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp index 4a92132d88..347dcb9221 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -92,6 +92,14 @@ int RigFemPart::elementCount() const return static_cast( m_elementId.size() ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPart::allConnectivitiesCount() const +{ + return static_cast( m_allElementConnectivities.size() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h index 3ec2c7b986..c68189c9f8 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -57,6 +57,7 @@ public: void appendElement( RigElementType elmType, int elementId, const int* connectivities ); int elementCount() const; + int allConnectivitiesCount() const; int elmId( size_t elementIdx ) const; RigElementType elementType( size_t elementIdx ) const; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp index 48e46ee577..3d37813160 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp @@ -39,7 +39,24 @@ RigFemPartCollection::~RigFemPartCollection() //-------------------------------------------------------------------------------------------------- void RigFemPartCollection::addFemPart( RigFemPart* part ) { + size_t globalElementOffset = 0; + size_t globalNodeOffset = 0; + size_t globalConnectivityOffset = 0; + if ( m_femParts.size() > 0 ) + { + size_t lastIndex = m_femParts.size() - 1; + globalElementOffset += m_femParts[lastIndex]->elementCount(); + globalElementOffset += m_partElementOffset[lastIndex]; + globalNodeOffset += m_femParts[lastIndex]->nodes().nodeIds.size(); + globalNodeOffset += m_partNodeOffset[lastIndex]; + globalConnectivityOffset += m_femParts[lastIndex]->allConnectivitiesCount(); + globalConnectivityOffset += m_partConnectivityOffset[lastIndex]; + } + m_femParts.push_back( part ); + m_partElementOffset.push_back( globalElementOffset ); + m_partNodeOffset.push_back( globalNodeOffset ); + m_partConnectivityOffset.push_back( globalConnectivityOffset ); } //-------------------------------------------------------------------------------------------------- @@ -108,3 +125,74 @@ cvf::BoundingBox RigFemPartCollection::boundingBox() const } return bBox; } + +//-------------------------------------------------------------------------------------------------- +/// convert from global element index to part and part-local index +//-------------------------------------------------------------------------------------------------- +std::pair RigFemPartCollection::partIdAndElementIndex( size_t globalIndex ) const +{ + const size_t nParts = m_partElementOffset.size(); + + CVF_ASSERT( nParts > 0 ); + + for ( size_t i = 1; i < nParts; i++ ) + { + if ( globalIndex < m_partElementOffset[i] ) + { + return std::make_pair( (int)( i - 1 ), globalIndex - m_partElementOffset[i - 1] ); + } + } + + return std::make_pair( (int)( nParts - 1 ), globalIndex - m_partElementOffset.back() ); +} + +//-------------------------------------------------------------------------------------------------- +/// convert from global element index to part and part-local index +//-------------------------------------------------------------------------------------------------- +std::pair RigFemPartCollection::partAndElementIndex( size_t globalIndex ) const +{ + auto [partId, elementIdx] = partIdAndElementIndex( globalIndex ); + return std::make_pair( part( partId ), elementIdx ); +} + +//-------------------------------------------------------------------------------------------------- +/// convert from part and part-local index to global index +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartCollection::globalIndex( int partId, size_t localIndex ) const +{ + return localIndex + m_partElementOffset[partId]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartCollection::nodeIdxFromElementNodeResultIdx( size_t globalIndex ) const +{ + const size_t nParts = m_partConnectivityOffset.size(); + CVF_ASSERT( nParts > 0 ); + + int partId = (int)( nParts - 1 ); + size_t partIdx = globalIndex - m_partConnectivityOffset.back(); + + for ( size_t i = 1; i < nParts; i++ ) + { + if ( globalIndex < m_partConnectivityOffset[i] ) + { + partId = (int)( i - 1 ); + partIdx = globalIndex - m_partConnectivityOffset[i - 1]; + break; + } + } + + const RigFemPart* part = this->part( partId ); + + return (int)m_partNodeOffset[partId] + part->nodeIdxFromElementNodeResultIdx( partIdx ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFemPartCollection::globalElementNodeResultIdx( int partId, int elementIdx, int elmLocalNodeIdx ) const +{ + return m_partElementOffset[partId] * 8 + part( partId )->elementNodeResultIdx( elementIdx, elmLocalNodeIdx ); +} diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h index 8ab8419d9f..2c17667b8c 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h @@ -38,6 +38,19 @@ public: float characteristicElementSize() const; cvf::BoundingBox boundingBox() const; + std::pair partIdAndElementIndex( size_t globalIndex ) const; + std::pair partAndElementIndex( size_t globalIndex ) const; + size_t globalIndex( int partId, size_t localIndex ) const; + + std::pair partIdAndNodeIndex( size_t globalNodeIndex ) const; + + int nodeIdxFromElementNodeResultIdx( size_t globalResultIdx ) const; + + size_t globalElementNodeResultIdx( int part, int elementIdx, int elmLocalNodeIdx ) const; + private: cvf::Collection m_femParts; + std::vector m_partElementOffset; + std::vector m_partNodeOffset; + std::vector m_partConnectivityOffset; }; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp index 220885c86a..2837a9f112 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp @@ -146,6 +146,8 @@ RigFemScalarResultFrames* for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) { const std::vector& s11 = s11Frames->frameData( fIdx ); + if ( s11.empty() ) continue; + const std::vector& s22 = s22Frames->frameData( fIdx ); const std::vector& s33 = s33Frames->frameData( fIdx ); const std::vector& s12 = s12Frames->frameData( fIdx ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 04ac5fcf92..f5b951adf6 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -1043,6 +1043,54 @@ const std::vector& return scalarResults->frameData( frameIndex ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& resVarAddr, + int timeStepIndex, + std::vector& resultValues ) +{ + CVF_ASSERT( resVarAddr.isValid() ); + + for ( int i = 0; i < partCount(); i++ ) + { + const std::vector& partResults = this->resultValues( resVarAddr, i, (int)timeStepIndex ); + if ( partResults.empty() ) + { + size_t expectedSize = 0; + + switch ( resVarAddr.resultPosType ) + { + case RIG_NODAL: + expectedSize = m_femParts->part( i )->nodes().nodeIds.size(); + break; + + case RIG_ELEMENT_NODAL: + case RIG_INTEGRATION_POINT: + expectedSize = m_femParts->part( i )->elementNodeResultCount(); + break; + + case RIG_ELEMENT_NODAL_FACE: + expectedSize = m_femParts->part( i )->elementCount() * 6; + break; + + case RIG_ELEMENT: + expectedSize = m_femParts->part( i )->elementCount(); + break; + + default: + break; + } + + resultValues.resize( resultValues.size() + expectedSize, NAN ); + } + else + { + resultValues.insert( resultValues.end(), partResults.begin(), partResults.end() ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 45a832ba88..a940e8b7f9 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -125,7 +125,9 @@ public: std::vector loadedResults() const; const std::vector& resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); - std::vector tensors( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); + void globalResultValues( const RigFemResultAddress& resVarAddr, int timeStepIndex, std::vector& resultValues ); + + std::vector tensors( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); const RigFemPartCollection* parts() const; int partCount() const; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/CMakeLists_files.cmake b/ApplicationLibCode/ModelVisualization/Intersections/CMakeLists_files.cmake index d85cff4774..b5c295808d 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/CMakeLists_files.cmake +++ b/ApplicationLibCode/ModelVisualization/Intersections/CMakeLists_files.cmake @@ -8,6 +8,9 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionPartMgr.h ${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattener.h + ${CMAKE_CURRENT_LIST_DIR}/RivEclipseIntersectionGrid.h + ${CMAKE_CURRENT_LIST_DIR}/RivFemIntersectionGrid.h + ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGeneratorInterface.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -15,11 +18,12 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RivExtrudedCurveIntersectionPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivExtrudedCurveIntersectionSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivIntersectionResultsColoringTools.cpp - ${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionGeometryGenerator.cpp ${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionPartMgr.cpp ${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattener.cpp + ${CMAKE_CURRENT_LIST_DIR}/RivEclipseIntersectionGrid.cpp + ${CMAKE_CURRENT_LIST_DIR}/RivFemIntersectionGrid.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp index e4af05cec0..3e60fdd555 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.cpp @@ -18,6 +18,8 @@ #include "RivBoxIntersectionGeometryGenerator.h" +#include "RivIntersectionHexGridInterface.h" + #include "RimBoxIntersection.h" #include "RimCase.h" #include "RimGridView.h" diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h index abb6c3a89a..1caa9dba43 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionGeometryGenerator.h @@ -18,7 +18,7 @@ #pragma once -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionGeometryGeneratorInterface.h" #include "cafPdmPointer.h" @@ -30,6 +30,7 @@ #include class RimBoxIntersection; +class RivIntersectionHexGridInterface; namespace cvf { @@ -37,7 +38,7 @@ class ScalarMapper; class DrawableGeo; } // namespace cvf -class RivBoxIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF +class RivBoxIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorInterface { public: RivBoxIntersectionGeometryGenerator( RimBoxIntersection* intersectionBox, const RivIntersectionHexGridInterface* grid ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp index 8867ef5620..237ab76f87 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp @@ -36,6 +36,8 @@ #include "RivBoxIntersectionSourceInfo.h" #include "RivExtrudedCurveIntersectionPartMgr.h" +#include "RivIntersectionGeometryGeneratorInterface.h" +#include "RivIntersectionHexGridInterface.h" #include "RivIntersectionResultsColoringTools.h" #include "RivMeshLinesSourceInfo.h" #include "RivPartPriority.h" @@ -219,7 +221,7 @@ void RivBoxIntersectionPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RivBoxIntersectionPartMgr::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RivBoxIntersectionPartMgr::intersectionGeometryGenerator() const { if ( m_intersectionBoxGenerator.notNull() ) return m_intersectionBoxGenerator.p(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h index 54c3e15026..9bcfaeffeb 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h @@ -34,6 +34,7 @@ class RigMainGrid; class RigResultAccessor; class RivTernaryScalarMapper; +class RivIntersectionGeometryGeneratorInterface; class RimCellEdgeColors; class RimEclipseCellColors; @@ -60,7 +61,7 @@ public: void appendNativeIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const; + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const; private: void updatePartEffect(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp new file mode 100644 index 0000000000..7e74dd44d4 --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.cpp @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivEclipseIntersectionGrid.h" + +#include "RigActiveCellInfo.h" +#include "RigFemPart.h" +#include "RigMainGrid.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivEclipseIntersectionGrid::RivEclipseIntersectionGrid( const RigMainGrid* mainGrid, + const RigActiveCellInfo* activeCellInfo, + bool showInactiveCells ) + : m_mainGrid( mainGrid ) + , m_activeCellInfo( activeCellInfo ) + , m_showInactiveCells( showInactiveCells ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RivEclipseIntersectionGrid::displayOffset() const +{ + return m_mainGrid->displayModelOffset(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const +{ + return m_mainGrid->boundingBox(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivEclipseIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, + std::vector* intersectedCells ) const +{ + m_mainGrid->findIntersectingCells( intersectingBB, intersectedCells ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const +{ + const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex]; + if ( m_showInactiveCells ) + return !( cell.isInvalid() || ( cell.subGrid() != nullptr ) ); + else + return m_activeCellInfo->isActive( cellIndex ) && ( cell.subGrid() == nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const +{ + m_mainGrid->cellCornerVertices( cellIndex, cellCorners ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const +{ + const std::array& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices(); + + for ( size_t i = 0; i < 8; i++ ) + { + cornerIndices[i] = cornerIndicesSource[i]; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face ) const +{ + return m_mainGrid->findFaultFromCellIndexAndCellFace( reservoirCellIndex, face ); +} diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h new file mode 100644 index 0000000000..9526c3385e --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEclipseIntersectionGrid.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RivIntersectionHexGridInterface.h" + +#include "cvfBoundingBox.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cvfStructGrid.h" + +#include +#include + +class RigActiveCellInfo; +class RigMainGrid; +class RigFault; + +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; + +private: + cvf::cref m_mainGrid; + cvf::cref m_activeCellInfo; + bool m_showInactiveCells; +}; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index b33a190509..0fcd42c618 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -34,7 +34,7 @@ #include "RimSurfaceIntersectionCurve.h" #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionHexGridInterface.h" #include "RivPolylineGenerator.h" #include "RivSectionFlattener.h" diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h index 00a216eca1..14c75d1038 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.h @@ -21,7 +21,7 @@ #include "cafPdmPointer.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionGeometryGeneratorInterface.h" #include "cvfArray.h" @@ -47,7 +47,7 @@ class ScalarMapper; class DrawableGeo; } // namespace cvf -class RivExtrudedCurveIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF +class RivExtrudedCurveIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorInterface { public: RivExtrudedCurveIntersectionGeometryGenerator( RimExtrudedCurveIntersection* intersection, diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index 2eb8f7eb6c..a3126df53e 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -53,7 +53,7 @@ #include "RivExtrudedCurveIntersectionGeometryGenerator.h" #include "RivExtrudedCurveIntersectionSourceInfo.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionHexGridInterface.h" #include "RivIntersectionResultsColoringTools.h" #include "RivMeshLinesSourceInfo.h" #include "RivObjectSourceInfo.h" @@ -176,7 +176,7 @@ void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMech const std::vector& vertexWeights, const std::vector& resultValues, bool isElementNodalResult, - const RigFemPart* femPart, + const RigFemPartCollection* femParts, const cvf::ScalarMapper* mapper ) { textureCoords->resize( vertexWeights.size() ); @@ -210,7 +210,7 @@ void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMech } else { - resIdx = femPart->nodeIdxFromElementNodeResultIdx( vertexWeights[triangleVxIdx].vxId( wIdx ) ); + resIdx = femParts->nodeIdxFromElementNodeResultIdx( vertexWeights[triangleVxIdx].vxId( wIdx ) ); } resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight( wIdx ); @@ -895,7 +895,7 @@ cvf::Mat4d RivExtrudedCurveIntersectionPartMgr::unflattenTransformMatrix( const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RivExtrudedCurveIntersectionPartMgr::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RivExtrudedCurveIntersectionPartMgr::intersectionGeometryGenerator() const { if ( m_intersectionGenerator.notNull() ) return m_intersectionGenerator.p(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h index f9afd3f991..22ea6f91c3 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h @@ -56,7 +56,7 @@ class RivExtrudedCurveIntersectionGeometryGenerator; class RivIntersectionHexGridInterface; class RivIntersectionVertexWeights; class RivPipeGeometryGenerator; -class RivIntersectionGeometryGeneratorIF; +class RivIntersectionGeometryGeneratorInterface; //================================================================================================== /// @@ -79,7 +79,7 @@ public: cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat ) const; - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const; + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const; private: void generatePartGeometry(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp new file mode 100644 index 0000000000..e331c5c948 --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivFemIntersectionGrid.h" + +#include "RigFemPart.h" +#include "RigFemPartCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPartCollection* femParts ) + : m_femParts( femParts ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RivFemIntersectionGrid::displayOffset() const +{ + return m_femParts->boundingBox().min(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const +{ + return m_femParts->boundingBox(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, + std::vector* intersectedCells ) const +{ + for ( int i = 0; i < m_femParts->partCount(); i++ ) + { + const RigFemPart* part = m_femParts->part( i ); + std::vector foundElements; + part->findIntersectingCells( intersectingBB, &foundElements ); + + for ( size_t t = 0; t < foundElements.size(); t++ ) + { + size_t globalIdx = m_femParts->globalIndex( i, foundElements[t] ); + intersectedCells->push_back( globalIdx ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivFemIntersectionGrid::useCell( size_t globalCellIndex ) const +{ + auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex ); + + return ( ( part->elementType( elementIdx ) == RigElementType::HEX8 ) || + ( part->elementType( elementIdx ) == RigElementType::HEX8P ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, cvf::Vec3d cellCorners[8] ) const +{ + auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex ); + + const std::vector& nodeCoords = part->nodes().coordinates; + const int* cornerIndices = part->connectivities( elementIdx ); + + for ( int i = 0; i < 8; i++ ) + { + cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemIntersectionGrid::cellCornerIndices( size_t globalCellIndex, size_t cornerIndices[8] ) const +{ + auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex ); + + RigElementType elmType = part->elementType( elementIdx ); + if ( !( elmType == HEX8 || elmType == HEX8P ) ) return; + + int elmIdx = static_cast( elementIdx ); + const int partId = part->elementPartId(); + + for ( int i = 0; i < 8; i++ ) + { + cornerIndices[i] = m_femParts->globalElementNodeResultIdx( partId, elmIdx, i ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face ) const +{ + return nullptr; +} diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h new file mode 100644 index 0000000000..eb5c4f0ed6 --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RivIntersectionHexGridInterface.h" + +#include "cvfBoundingBox.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cvfStructGrid.h" + +#include + +class RigFemPart; +class RigFemPartCollection; +class RigFault; + +class RivFemIntersectionGrid : public RivIntersectionHexGridInterface +{ +public: + explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts ); + + 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; + +private: + cvf::cref m_femParts; +}; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp deleted file mode 100644 index 6cb9a6008a..0000000000 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ /dev/null @@ -1,195 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RivHexGridIntersectionTools.h" - -#include "RigActiveCellInfo.h" -#include "RigFemPart.h" -#include "RigMainGrid.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivEclipseIntersectionGrid::RivEclipseIntersectionGrid( const RigMainGrid* mainGrid, - const RigActiveCellInfo* activeCellInfo, - bool showInactiveCells ) - : m_mainGrid( mainGrid ) - , m_activeCellInfo( activeCellInfo ) - , m_showInactiveCells( showInactiveCells ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec3d RivEclipseIntersectionGrid::displayOffset() const -{ - return m_mainGrid->displayModelOffset(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const -{ - return m_mainGrid->boundingBox(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivEclipseIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, - std::vector* intersectedCells ) const -{ - m_mainGrid->findIntersectingCells( intersectingBB, intersectedCells ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const -{ - const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex]; - if ( m_showInactiveCells ) - return !( cell.isInvalid() || ( cell.subGrid() != nullptr ) ); - else - return m_activeCellInfo->isActive( cellIndex ) && ( cell.subGrid() == nullptr ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const -{ - m_mainGrid->cellCornerVertices( cellIndex, cellCorners ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const -{ - const std::array& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices(); - - for ( size_t i = 0; i < 8; i++ ) - { - cornerIndices[i] = cornerIndicesSource[i]; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, - cvf::StructGridInterface::FaceType face ) const -{ - return m_mainGrid->findFaultFromCellIndexAndCellFace( reservoirCellIndex, face ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPart* femPart ) - : m_femPart( femPart ) -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec3d RivFemIntersectionGrid::displayOffset() const -{ - return m_femPart->boundingBox().min(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const -{ - return m_femPart->boundingBox(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivFemIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB, - std::vector* intersectedCells ) const -{ - m_femPart->findIntersectingCells( intersectingBB, intersectedCells ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RivFemIntersectionGrid::useCell( size_t cellIndex ) const -{ - RigElementType elmType = m_femPart->elementType( cellIndex ); - - if ( !( elmType == HEX8 || elmType == HEX8P ) ) return false; - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivFemIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const -{ - RigElementType elmType = m_femPart->elementType( cellIndex ); - if ( !( elmType == HEX8 || elmType == HEX8P ) ) return; - - const std::vector& nodeCoords = m_femPart->nodes().coordinates; - const int* cornerIndices = m_femPart->connectivities( cellIndex ); - - cellCorners[0] = cvf::Vec3d( nodeCoords[cornerIndices[0]] ); - cellCorners[1] = cvf::Vec3d( nodeCoords[cornerIndices[1]] ); - cellCorners[2] = cvf::Vec3d( nodeCoords[cornerIndices[2]] ); - cellCorners[3] = cvf::Vec3d( nodeCoords[cornerIndices[3]] ); - cellCorners[4] = cvf::Vec3d( nodeCoords[cornerIndices[4]] ); - cellCorners[5] = cvf::Vec3d( nodeCoords[cornerIndices[5]] ); - cellCorners[6] = cvf::Vec3d( nodeCoords[cornerIndices[6]] ); - cellCorners[7] = cvf::Vec3d( nodeCoords[cornerIndices[7]] ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivFemIntersectionGrid::cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const -{ - RigElementType elmType = m_femPart->elementType( cellIndex ); - if ( !( elmType == HEX8 || elmType == HEX8P ) ) return; - int elmIdx = static_cast( cellIndex ); - cornerIndices[0] = m_femPart->elementNodeResultIdx( elmIdx, 0 ); - cornerIndices[1] = m_femPart->elementNodeResultIdx( elmIdx, 1 ); - cornerIndices[2] = m_femPart->elementNodeResultIdx( elmIdx, 2 ); - cornerIndices[3] = m_femPart->elementNodeResultIdx( elmIdx, 3 ); - cornerIndices[4] = m_femPart->elementNodeResultIdx( elmIdx, 4 ); - cornerIndices[5] = m_femPart->elementNodeResultIdx( elmIdx, 5 ); - cornerIndices[6] = m_femPart->elementNodeResultIdx( elmIdx, 6 ); - cornerIndices[7] = m_femPart->elementNodeResultIdx( elmIdx, 7 ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, - cvf::StructGridInterface::FaceType face ) const -{ - return nullptr; -} diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionGeometryGeneratorInterface.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionGeometryGeneratorInterface.h new file mode 100644 index 0000000000..e3e42259eb --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionGeometryGeneratorInterface.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RivIntersectionVertexWeights.h" + +#include "cvfArray.h" + +#include + +class RivIntersectionGeometryGeneratorInterface +{ +public: + virtual bool isAnyGeometryPresent() const = 0; + virtual const std::vector& triangleToCellIndex() const = 0; + virtual const std::vector& triangleVxToCellCornerInterpolationWeights() const = 0; + virtual const cvf::Vec3fArray* triangleVxes() const = 0; +}; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h new file mode 100644 index 0000000000..0d5b4eb5e8 --- /dev/null +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionHexGridInterface.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBoundingBox.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cvfStructGrid.h" + +#include + +class RigFault; + +//-------------------------------------------------------------------------------------------------- +/// Interface definition used to compute the geometry for planes intersecting a grid +//-------------------------------------------------------------------------------------------------- +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 const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face ) const = 0; +}; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp index b56ab56b48..7692c46199 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp @@ -37,6 +37,8 @@ #include "RigGeoMechCaseData.h" #include "RigResultAccessorFactory.h" +#include "RivIntersectionGeometryGeneratorInterface.h" +#include "RivIntersectionVertexWeights.h" #include "RivScalarMapperUtils.h" #include "RivTernaryTextureCoordsCreator.h" @@ -49,14 +51,14 @@ /// //-------------------------------------------------------------------------------------------------- void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( - size_t timeStepIndex, - bool useSeparateIntersectionResDefTimeStep, - RimIntersection* rimIntersectionHandle, - const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF, - const cvf::ScalarMapper* explicitScalarColorMapper, - const RivTernaryScalarMapper* explicitTernaryColorMapper, - cvf::Part* intersectionFacesPart, - cvf::Vec2fArray* intersectionFacesTextureCoords ) + size_t timeStepIndex, + bool useSeparateIntersectionResDefTimeStep, + RimIntersection* rimIntersectionHandle, + const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, + const cvf::ScalarMapper* explicitScalarColorMapper, + const RivTernaryScalarMapper* explicitTernaryColorMapper, + cvf::Part* intersectionFacesPart, + cvf::Vec2fArray* intersectionFacesTextureCoords ) { if ( !intersectionGeomGenIF || !intersectionGeomGenIF->isAnyGeometryPresent() ) return; @@ -223,13 +225,14 @@ void RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, - size_t timeStepIndex, - const cvf::ScalarMapper* scalarColorMapper, - bool isLightingDisabled, - const RivIntersectionGeometryGeneratorIF* geomGenerator, - cvf::Part* intersectionFacesPart, - cvf::Vec2fArray* intersectionFacesTextureCoords ) +void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( + const RimGeoMechResultDefinition* geomResultDef, + size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + bool isLightingDisabled, + const RivIntersectionGeometryGeneratorInterface* geomGenerator, + cvf::Part* intersectionFacesPart, + cvf::Vec2fArray* intersectionFacesTextureCoords ) { RigGeoMechCaseData* caseData = nullptr; RigFemResultAddress resVarAddress; @@ -247,35 +250,53 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( const R if ( resVarAddress.resultPosType == RIG_ELEMENT ) { - const std::vector& resultValues = - caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); + if ( caseData->femPartResults()->partCount() == 1 ) + { + const std::vector& resultValues = + caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); - RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, - resultValues, - triangleToCellIdx, - scalarColorMapper ); + RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, + resultValues, + triangleToCellIdx, + scalarColorMapper ); + } + else + { + std::vector resultValues; + caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); + + RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, + resultValues, + triangleToCellIdx, + scalarColorMapper ); + } } else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE ) { // Special direction sensitive result calculation - if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + if ( caseData->femPartResults()->partCount() == 1 ) // only supported for single-part geomech cases { - RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords, - triangelVxes, - resVarAddress, - scalarColorMapper ); + if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + { + RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords, + triangelVxes, + resVarAddress, + scalarColorMapper ); + } + else + { + RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords, + triangelVxes, + vertexWeights, + caseData, + resVarAddress, + (int)timeStepIndex, + scalarColorMapper ); + } } else - { - RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords, - triangelVxes, - vertexWeights, - caseData, - resVarAddress, - (int)timeStepIndex, - scalarColorMapper ); - } + return; } else { @@ -285,19 +306,31 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( const R { resVarAddress.resultPosType = RIG_ELEMENT_NODAL; } + bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL ); - const std::vector& resultValues = - caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); + if ( caseData->femPartResults()->partCount() == 1 ) + { + const std::vector& resultValues = + caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); + RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, + vertexWeights, + resultValues, + isElementNodalResult, + caseData->femParts(), + scalarColorMapper ); + } + else + { + std::vector resultValues; + caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); - RigFemPart* femPart = caseData->femParts()->part( 0 ); - bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL ); - - RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, - vertexWeights, - resultValues, - isElementNodalResult, - femPart, - scalarColorMapper ); + RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, + vertexWeights, + resultValues, + isElementNodalResult, + caseData->femParts(), + scalarColorMapper ); + } } RivScalarMapperUtils::applyTextureResultsToPart( intersectionFacesPart, diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h index a488bce0b9..ef9d4b84a8 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h @@ -20,17 +20,16 @@ #include "cvfArray.h" -#include "RivHexGridIntersectionTools.h" - class RimEclipseResultDefinition; class RimGeoMechResultDefinition; class RimIntersection; -class RivIntersectionGeometryGeneratorIF; +class RivIntersectionGeometryGeneratorInterface; +class RivIntersectionVertexWeights; class RivTernaryScalarMapper; class RigResultAccessor; -class RigFemPart; +class RigFemPartCollection; class RigGeoMechCaseData; class RigFemResultAddress; @@ -46,11 +45,11 @@ public: static void calculateIntersectionResultColors( size_t timeStepIndex, bool useSeparateIntersectionResDefTimeStep, RimIntersection* rimIntersectionHandle, - const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF, - const cvf::ScalarMapper* explicitScalarColorMapper, - const RivTernaryScalarMapper* explicitTernaryColorMapper, - cvf::Part* intersectionFacesPart, - cvf::Vec2fArray* intersectionFacesTextureCoords ); + const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, + const cvf::ScalarMapper* explicitScalarColorMapper, + const RivTernaryScalarMapper* explicitTernaryColorMapper, + cvf::Part* intersectionFacesPart, + cvf::Vec2fArray* intersectionFacesTextureCoords ); private: static void updateEclipseCellResultColors( const RimEclipseResultDefinition* eclipseResDef, @@ -69,12 +68,12 @@ private: cvf::Part* m_intersectionBoxFaces, cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords ); - static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, - size_t timeStepIndex, - const cvf::ScalarMapper* scalarColorMapper, - bool isLightingDisabled, - const RivIntersectionGeometryGeneratorIF* geomGenerator, - cvf::Part* m_intersectionBoxFaces, + static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, + size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + bool isLightingDisabled, + const RivIntersectionGeometryGeneratorInterface* geomGenerator, + cvf::Part* m_intersectionBoxFaces, cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords ); static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords, @@ -85,10 +84,10 @@ private: static void calculateNodeOrElementNodeBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords, const std::vector& vertexWeights, - const std::vector& resultValues, - bool isElementNodalResult, - const RigFemPart* femPart, - const cvf::ScalarMapper* mapper ); + const std::vector& resultValues, + bool isElementNodalResult, + const RigFemPartCollection* femParts, + const cvf::ScalarMapper* mapper ); static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords, const std::vector& resultValues, diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionVertexWeights.h similarity index 54% rename from ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h rename to ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionVertexWeights.h index f45058497d..28aa52d805 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionVertexWeights.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) Statoil ASA +// Copyright (C) 2021 - Equinor 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 @@ -18,82 +18,8 @@ #pragma once -#include "cvfBoundingBox.h" -#include "cvfObject.h" -#include "cvfVector3.h" - -#include "cvfStructGrid.h" - #include -#include - -class RigActiveCellInfo; -class RigFemPart; -class RigMainGrid; -class RigFault; - -//-------------------------------------------------------------------------------------------------- -/// Interface definition used to compute the geometry for planes intersecting a grid -//-------------------------------------------------------------------------------------------------- -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 const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, - cvf::StructGridInterface::FaceType face ) const = 0; -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -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; - -private: - cvf::cref m_mainGrid; - cvf::cref m_activeCellInfo; - bool m_showInactiveCells; -}; - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RivFemIntersectionGrid : public RivIntersectionHexGridInterface -{ -public: - explicit RivFemIntersectionGrid( const RigFemPart* femPart ); - - 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; - -private: - cvf::cref m_femPart; -}; +#include //-------------------------------------------------------------------------------------------------- /// @@ -222,12 +148,3 @@ private: std::array m_weights; int m_count; }; - -class RivIntersectionGeometryGeneratorIF -{ -public: - virtual bool isAnyGeometryPresent() const = 0; - virtual const std::vector& triangleToCellIndex() const = 0; - virtual const std::vector& triangleVxToCellCornerInterpolationWeights() const = 0; - virtual const cvf::Vec3fArray* triangleVxes() const = 0; -}; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivSectionFlattener.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivSectionFlattener.cpp index d8d6f6c533..57c339a99d 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivSectionFlattener.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivSectionFlattener.cpp @@ -39,7 +39,7 @@ size_t RivSectionFlattener::indexToNextValidPoint( const std::vector cvf::Vec3d p2 = polyLine[lIdx]; cvf::Vec3d p1p2 = p2 - p1; - if ( ( p1p2 - ( p1p2 * extrDir ) * extrDir ).length() > 0.1 ) + if ( ( p1p2 - ( p1p2 * extrDir ) * extrDir ).length() > 0.001 ) { return lIdx; } diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp index 179c4fb99a..e6f9d216e0 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp @@ -32,7 +32,8 @@ #include "RimSurfaceInView.h" #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionHexGridInterface.h" +#include "RivIntersectionVertexWeights.h" #include "RivPolylineGenerator.h" #include "RivSectionFlattener.h" diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.h b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.h index 97a6dd1f03..17b72f28ab 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.h @@ -21,7 +21,7 @@ #include "cafPdmPointer.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionGeometryGeneratorInterface.h" #include "cvfArray.h" #include "cvfBoundingBox.h" @@ -47,7 +47,7 @@ class ScalarMapper; class DrawableGeo; } // namespace cvf -class RivSurfaceIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF +class RivSurfaceIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorInterface { public: RivSurfaceIntersectionGeometryGenerator( RimSurfaceInView* surfInView, const RivIntersectionHexGridInterface* grid ); diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp index 06eeac7b6b..ffe5c3c56b 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp @@ -28,6 +28,8 @@ #include "RimSurfaceInView.h" #include "RimSurfaceResultDefinition.h" +#include "RivIntersectionGeometryGeneratorInterface.h" +#include "RivIntersectionHexGridInterface.h" #include "RivIntersectionResultsColoringTools.h" #include "RivMeshLinesSourceInfo.h" #include "RivPartPriority.h" @@ -271,7 +273,7 @@ QString RivSurfacePartMgr::resultInfoText( Rim3dView* view, uint hitPart, cvf::V //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RivSurfacePartMgr::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RivSurfacePartMgr::intersectionGeometryGenerator() const { if ( m_intersectionGenerator.notNull() ) return m_intersectionGenerator.p(); diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h index 08795ae59f..d1e221b5ae 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h @@ -36,7 +36,7 @@ class RigResultAccessor; class Rim3dView; class RivSurfaceIntersectionGeometryGenerator; -class RivIntersectionGeometryGeneratorIF; +class RivIntersectionGeometryGeneratorInterface; class RivSurfacePartMgr : public cvf::Object { @@ -51,7 +51,7 @@ public: QString resultInfoText( Rim3dView* view, uint hitPart, cvf::Vec3d hitPoint ); - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const; + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const; private: void generatePartGeometry(); diff --git a/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.cpp index de0dbbd4e4..ea6c0bd8b0 100644 --- a/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.cpp @@ -51,7 +51,7 @@ CAF_PDM_SOURCE_INIT( RimBoxIntersection, "IntersectionBox" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RimBoxIntersection::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RimBoxIntersection::intersectionGeometryGenerator() const { if ( m_intersectionBoxPartMgr.notNull() ) return m_intersectionBoxPartMgr->intersectionGeometryGenerator(); diff --git a/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.h b/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.h index 9669a29a2d..ef15deae18 100644 --- a/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/RimBoxIntersection.h @@ -78,7 +78,7 @@ public: void setToDefaultSizeBox(); void setToDefaultSizeSlice( SinglePlaneState plane, const cvf::Vec3d& position ); - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const override; + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const override; protected: caf::PdmFieldHandle* userDescriptionField() final; diff --git a/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.cpp index a6cf6a3317..8cd98bb21d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.cpp @@ -86,7 +86,7 @@ CAF_PDM_SOURCE_INIT( RimExtrudedCurveIntersection, "CrossSection" ); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RimExtrudedCurveIntersection::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RimExtrudedCurveIntersection::intersectionGeometryGenerator() const { if ( m_crossSectionPartMgr.notNull() ) return m_crossSectionPartMgr->intersectionGeometryGenerator(); diff --git a/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.h index 8429cbda32..727e0482d2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/RimExtrudedCurveIntersection.h @@ -91,10 +91,10 @@ public: std::vector> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const; void appendPointToPolyLine( const cvf::Vec3d& point ); - Rim2dIntersectionView* correspondingIntersectionView() const; - RivExtrudedCurveIntersectionPartMgr* intersectionPartMgr(); - void rebuildGeometry(); - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const override; + Rim2dIntersectionView* correspondingIntersectionView() const; + RivExtrudedCurveIntersectionPartMgr* intersectionPartMgr(); + void rebuildGeometry(); + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const override; std::vector polyLinesForExtrusionDirection() const; void appendPointToExtrusionDirection( const cvf::Vec3d& point ); diff --git a/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp b/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp index 81ec42bcf1..4fa34ca858 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp @@ -29,7 +29,9 @@ #include "RimGridView.h" #include "RimIntersectionResultDefinition.h" #include "RimIntersectionResultsDefinitionCollection.h" -#include "RivHexGridIntersectionTools.h" + +#include "RivEclipseIntersectionGrid.h" +#include "RivFemIntersectionGrid.h" CAF_PDM_ABSTRACT_SOURCE_INIT( RimIntersection, "RimIntersectionHandle" ); @@ -203,8 +205,7 @@ cvf::ref RimIntersection::createHexGridInterfac if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() ) { - RigFemPart* femPart = geomCase->geoMechData()->femParts()->part( 0 ); - return new RivFemIntersectionGrid( femPart ); + return new RivFemIntersectionGrid( geomCase->geoMechData()->femParts() ); } } @@ -219,11 +220,9 @@ cvf::ref RimIntersection::createHexGridInterfac RimGeoMechView* geoView; this->firstAncestorOrThisOfType( geoView ); - if ( geoView && geoView->femParts() && geoView->femParts()->partCount() ) + if ( geoView && geoView->femParts() ) { - RigFemPart* femPart = geoView->femParts()->part( 0 ); - - return new RivFemIntersectionGrid( femPart ); + return new RivFemIntersectionGrid( geoView->femParts() ); } return nullptr; diff --git a/ApplicationLibCode/ProjectDataModel/RimIntersection.h b/ApplicationLibCode/ProjectDataModel/RimIntersection.h index bc2bab0f2b..bb8258f08a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/RimIntersection.h @@ -27,7 +27,7 @@ class RimIntersectionResultDefinition; class RivIntersectionHexGridInterface; class RimIntersectionResultsDefinitionCollection; -class RivIntersectionGeometryGeneratorIF; +class RivIntersectionGeometryGeneratorInterface; class RimIntersection : public caf::PdmObject { @@ -46,7 +46,7 @@ public: RimIntersectionResultDefinition* activeSeparateResultDefinition(); cvf::ref createHexGridInterface(); - virtual const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const = 0; + virtual const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const = 0; protected: virtual RimIntersectionResultsDefinitionCollection* findSeparateResultsCollection(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp index d399df4139..bc1ce70d24 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp @@ -30,7 +30,6 @@ #include "RiuViewer.h" -#include "RivHexGridIntersectionTools.h" #include "RivSurfacePartMgr.h" #include "cafPdmUiDoubleSliderEditor.h" @@ -144,7 +143,7 @@ RivSurfacePartMgr* RimSurfaceInView::surfacePartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RivIntersectionGeometryGeneratorIF* RimSurfaceInView::intersectionGeometryGenerator() const +const RivIntersectionGeometryGeneratorInterface* RimSurfaceInView::intersectionGeometryGenerator() const { if ( m_surfacePartMgr.notNull() ) return m_surfacePartMgr->intersectionGeometryGenerator(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.h index 258135abfe..da2c73c618 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInView.h @@ -51,9 +51,9 @@ public: bool isNativeSurfaceResultsActive() const; RimSurfaceResultDefinition* surfaceResultDefinition(); - void clearGeometry(); - RivSurfacePartMgr* surfacePartMgr(); - const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const override; + void clearGeometry(); + RivSurfacePartMgr* surfacePartMgr(); + const RivIntersectionGeometryGeneratorInterface* intersectionGeometryGenerator() const override; void loadDataAndUpdate(); diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp index 56ebe03085..96e5ba59d1 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp @@ -516,9 +516,9 @@ std::vector RimSurfaceInViewCollection::legendConfigs() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimSurfaceInViewCollection::intersectionGeometryGenerators() const +std::vector RimSurfaceInViewCollection::intersectionGeometryGenerators() const { - std::vector generators; + std::vector generators; for ( auto surf : m_surfacesInView ) { diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h index 817b6c5476..3da396645a 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h @@ -38,7 +38,7 @@ class RimSurfaceCollection; class RimEnsembleSurface; class RimRegularLegendConfig; class RiuViewer; -class RivIntersectionGeometryGeneratorIF; +class RivIntersectionGeometryGeneratorInterface; class RimSurfaceInViewCollection : public RimCheckableNamedObject { @@ -66,14 +66,13 @@ public: std::vector legendConfigs(); - std::vector intersectionGeometryGenerators() const; + std::vector intersectionGeometryGenerators() const; protected: void initAfterRead() override; caf::PdmFieldHandle* userDescriptionField() override; - - void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp index cddb86932e..10b9aa00f2 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp @@ -45,7 +45,7 @@ #include "RimSurfaceInView.h" #include "RimSurfaceInViewCollection.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionGeometryGeneratorInterface.h" #include @@ -199,7 +199,7 @@ void RigVisibleCategoriesCalculator::appendVisibleFaultCells( RimEclipseView* ec void RigVisibleCategoriesCalculator::appendVisibleIntersectionCells( RimEclipseView* eclView, std::set& visibleCells ) { // Intersections - std::vector intersectionGeoGenerators; + std::vector intersectionGeoGenerators; if ( !eclView->separateIntersectionResultsCollection()->isActive() ) { diff --git a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp index 8b5876a413..1cf7c0965b 100644 --- a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp +++ b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp @@ -18,7 +18,7 @@ #include "RiuGeoMechXfTensorResultAccessor.h" #include "RigFemPartResultsCollection.h" -#include "RivHexGridIntersectionTools.h" +#include "RivIntersectionVertexWeights.h" #include "cvfAssert.h" #include "cvfGeometryTools.h" diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index cd2a03eda6..b6634ca133 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -1077,6 +1077,7 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m { CVF_ASSERT( cellIndex && gridIndex ); RimEclipseCase* eclipseCase = nullptr; + RimGeoMechCase* geomechCase = dynamic_cast( mainOrComparisonView->ownerCase() ); if ( sepInterResDef ) { @@ -1096,6 +1097,13 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } + else if ( geomechCase ) + { + RigFemPartCollection* parts = geomechCase->geoMechData()->femParts(); + auto [partId, elementIdx] = parts->partIdAndElementIndex( globalCellIndex ); + *cellIndex = elementIdx; + *gridIndex = (size_t)partId; + } else { *cellIndex = globalCellIndex;