diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp index e331c5c948..c76a157c17 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.cpp @@ -21,11 +21,14 @@ #include "RigFemPart.h" #include "RigFemPartCollection.h" +#include "RimGeoMechPartCollection.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPartCollection* femParts ) +RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts ) : m_femParts( femParts ) + , m_parts( parts ) { } @@ -83,12 +86,27 @@ void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, cvf::Ve { auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex ); + const bool useDisplacements = m_parts->isDisplacementsUsed(); + const std::vector& nodeCoords = part->nodes().coordinates; const int* cornerIndices = part->connectivities( elementIdx ); - for ( int i = 0; i < 8; i++ ) + if ( useDisplacements ) { - cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); + const double scaleFactor = m_parts->currentDisplacementScaleFactor(); + const std::vector& displacements = m_parts->displacements( part->elementPartId() ); + for ( int i = 0; i < 8; i++ ) + { + const int idx = cornerIndices[i]; + cellCorners[i] = cvf::Vec3d( nodeCoords[idx] + displacements[idx] * scaleFactor ); + } + } + else + { + for ( int i = 0; i < 8; i++ ) + { + cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); + } } } diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h index eb5c4f0ed6..406135e011 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivFemIntersectionGrid.h @@ -31,11 +31,12 @@ class RigFemPart; class RigFemPartCollection; class RigFault; +class RimGeoMechPartCollection; class RivFemIntersectionGrid : public RivIntersectionHexGridInterface { public: - explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts ); + explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts ); cvf::Vec3d displayOffset() const override; cvf::BoundingBox boundingBox() const override; @@ -49,4 +50,5 @@ public: private: cvf::cref m_femParts; + const RimGeoMechPartCollection* m_parts; }; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp index 4f781abeb5..ab35aa23d6 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.cpp @@ -91,7 +91,7 @@ void RimGeoMechPart::setDisplacements( const std::vector& displaceme //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector RimGeoMechPart::displacements() const +const std::vector& RimGeoMechPart::displacements() const { return m_displacements; } diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.h index bfdcebe387..9b6b915c80 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPart.h @@ -38,8 +38,8 @@ public: void setPartId( int partId ); int partId() const; - void setDisplacements( const std::vector& displacements ); - const std::vector displacements() const; + void setDisplacements( const std::vector& displacements ); + const std::vector& displacements() const; protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp index 66a45a3b3f..f26cd94e5b 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.cpp @@ -39,6 +39,7 @@ RimGeoMechPartCollection::RimGeoMechPartCollection() , m_currentDisplacementTimeStep( -1 ) , m_displacementsUsed( false ) , m_currentScaleFactor( 1.0 ) + , m_noDisplacements() { CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" ); @@ -145,12 +146,20 @@ int RimGeoMechPartCollection::currentDisplacementTimeStep() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector RimGeoMechPartCollection::displacements( int partId ) const +double RimGeoMechPartCollection::currentDisplacementScaleFactor() const +{ + return m_currentScaleFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RimGeoMechPartCollection::displacements( int partId ) const { RimGeoMechPart* thepart = part( partId ); if ( thepart ) return thepart->displacements(); - return std::vector(); + return m_noDisplacements; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.h index 36aa9d6e02..a095ca5c5b 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechPartCollection.h @@ -44,11 +44,12 @@ public: bool isPartEnabled( int partId ) const; - const std::vector displacements( int partId ) const; + const std::vector& displacements( int partId ) const; - void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor ); - bool isDisplacementsUsed() const; - int currentDisplacementTimeStep() const; + void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor ); + bool isDisplacementsUsed() const; + int currentDisplacementTimeStep() const; + double currentDisplacementScaleFactor() const; std::vector parts() const; @@ -61,4 +62,6 @@ private: int m_currentDisplacementTimeStep; double m_currentScaleFactor; bool m_displacementsUsed; + + std::vector m_noDisplacements; }; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index a6a4c59f8d..ccc83ddd65 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -434,14 +434,21 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep() } } - if ( this->cellResult()->hasResult() ) + bool hasGeneralCellResult = this->cellResult()->hasResult(); + + if ( hasGeneralCellResult ) m_vizLogic->updateCellResultColor( m_currentTimeStep(), this->cellResult() ); else m_vizLogic->updateStaticCellColors( m_currentTimeStep() ); - bool hasGeneralCellResult = this->cellResult()->hasResult(); + // Intersections + { + m_intersectionVizModel->removeAllParts(); + m_intersectionCollection->rebuildGeometry(); + m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() ); + m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); + } - m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); if ( m_surfaceCollection ) { m_surfaceCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); diff --git a/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp b/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp index 4fa34ca858..78544f6fa7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimIntersection.cpp @@ -185,6 +185,9 @@ void RimIntersection::updateDefaultSeparateDataSource() //-------------------------------------------------------------------------------------------------- cvf::ref RimIntersection::createHexGridInterface() { + RimGeoMechView* geoView; + this->firstAncestorOrThisOfType( geoView ); + RimIntersectionResultDefinition* resDef = activeSeparateResultDefinition(); if ( resDef && resDef->activeCase() ) { @@ -203,9 +206,9 @@ cvf::ref RimIntersection::createHexGridInterfac auto* geomCase = dynamic_cast( resDef->activeCase() ); - if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() ) + if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() && geoView ) { - return new RivFemIntersectionGrid( geomCase->geoMechData()->femParts() ); + return new RivFemIntersectionGrid( geomCase->geoMechData()->femParts(), geoView->partsCollection() ); } } @@ -218,11 +221,9 @@ cvf::ref RimIntersection::createHexGridInterfac return new RivEclipseIntersectionGrid( grid, eclipseView->currentActiveCellInfo(), this->isInactiveCellsVisible() ); } - RimGeoMechView* geoView; - this->firstAncestorOrThisOfType( geoView ); if ( geoView && geoView->femParts() ) { - return new RivFemIntersectionGrid( geoView->femParts() ); + return new RivFemIntersectionGrid( geoView->femParts(), geoView->partsCollection() ); } return nullptr;