mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
GeoMech: show deformations in grid view (#8123)
Enable support in geomech view to show grid deformations
This commit is contained in:
parent
0e620c8408
commit
7b78c2d35b
@ -404,36 +404,42 @@ float RigFemPart::characteristicElementSize() const
|
||||
{
|
||||
if ( m_characteristicElementSize != std::numeric_limits<float>::infinity() ) return m_characteristicElementSize;
|
||||
|
||||
int elmsToAverageCount = 0;
|
||||
float sumMaxEdgeLength = 0;
|
||||
for ( int elmIdx = 0; elmIdx < elementCount(); elmIdx++ )
|
||||
std::vector<RigElementType> elementPriority = { HEX8P, HEX8 };
|
||||
|
||||
for ( auto elmType : elementPriority )
|
||||
{
|
||||
RigElementType eType = this->elementType( elmIdx );
|
||||
|
||||
if ( ( eType == HEX8P ) || ( eType == HEX8 ) )
|
||||
int elmsToAverageCount = 0;
|
||||
float sumMaxEdgeLength = 0;
|
||||
for ( int elmIdx = 0; elmIdx < elementCount(); elmIdx++ )
|
||||
{
|
||||
const int* elementConn = this->connectivities( elmIdx );
|
||||
cvf::Vec3f nodePos0 = this->nodes().coordinates[elementConn[0]];
|
||||
cvf::Vec3f nodePos1 = this->nodes().coordinates[elementConn[1]];
|
||||
cvf::Vec3f nodePos3 = this->nodes().coordinates[elementConn[3]];
|
||||
cvf::Vec3f nodePos4 = this->nodes().coordinates[elementConn[4]];
|
||||
RigElementType eType = this->elementType( elmIdx );
|
||||
|
||||
float l1 = ( nodePos1 - nodePos0 ).length();
|
||||
float l3 = ( nodePos3 - nodePos0 ).length();
|
||||
float l4 = ( nodePos4 - nodePos0 ).length();
|
||||
if ( eType == elmType )
|
||||
{
|
||||
const int* elementConn = this->connectivities( elmIdx );
|
||||
cvf::Vec3f nodePos0 = this->nodes().coordinates[elementConn[0]];
|
||||
cvf::Vec3f nodePos1 = this->nodes().coordinates[elementConn[1]];
|
||||
cvf::Vec3f nodePos3 = this->nodes().coordinates[elementConn[3]];
|
||||
cvf::Vec3f nodePos4 = this->nodes().coordinates[elementConn[4]];
|
||||
|
||||
float maxLength = l1 > l3 ? l1 : l3;
|
||||
maxLength = maxLength > l4 ? maxLength : l4;
|
||||
float l1 = ( nodePos1 - nodePos0 ).length();
|
||||
float l3 = ( nodePos3 - nodePos0 ).length();
|
||||
float l4 = ( nodePos4 - nodePos0 ).length();
|
||||
|
||||
sumMaxEdgeLength += maxLength;
|
||||
++elmsToAverageCount;
|
||||
float maxLength = l1 > l3 ? l1 : l3;
|
||||
maxLength = maxLength > l4 ? maxLength : l4;
|
||||
|
||||
sumMaxEdgeLength += maxLength;
|
||||
++elmsToAverageCount;
|
||||
}
|
||||
}
|
||||
if ( elmsToAverageCount > 0 )
|
||||
{
|
||||
m_characteristicElementSize = sumMaxEdgeLength / elmsToAverageCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT( elmsToAverageCount );
|
||||
|
||||
m_characteristicElementSize = sumMaxEdgeLength / elmsToAverageCount;
|
||||
|
||||
return m_characteristicElementSize;
|
||||
}
|
||||
|
||||
|
@ -155,3 +155,24 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec
|
||||
*errorMessage = std::string( "Could not read FEM parts" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage,
|
||||
int partId,
|
||||
int timeStep,
|
||||
std::vector<cvf::Vec3f>* displacements )
|
||||
{
|
||||
CVF_ASSERT( errorMessage );
|
||||
#ifdef USE_ODB_API
|
||||
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
|
||||
{
|
||||
m_readerInterface->readDisplacements( partId, timeStep, 1, displacements );
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
*errorMessage = std::string( "Could not read displacements." );
|
||||
return false;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
bool open( std::string* errorMessage );
|
||||
bool readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames );
|
||||
bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter = std::vector<size_t>() );
|
||||
bool readDisplacements( std::string* errorMessage, int partId, int timeStep, std::vector<cvf::Vec3f>* displacements );
|
||||
|
||||
RigFemPartCollection* femParts();
|
||||
const RigFemPartCollection* femParts() const;
|
||||
|
||||
|
@ -61,9 +61,9 @@ RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator()
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface( const std::vector<cvf::Vec3f>& nodeCoordinates )
|
||||
{
|
||||
computeArrays();
|
||||
computeArrays( nodeCoordinates );
|
||||
|
||||
CVF_ASSERT( m_quadVertices.notNull() );
|
||||
|
||||
@ -126,7 +126,7 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable( double
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::computeArrays()
|
||||
void RivFemPartGeometryGenerator::computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates )
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<int>& trianglesToElements = m_triangleMapper->triangleToElmIndexMap();
|
||||
@ -148,8 +148,6 @@ void RivFemPartGeometryGenerator::computeArrays()
|
||||
trianglesToElements.reserve( estimatedQuadVxCount / 2 );
|
||||
trianglesToElementFaces.reserve( estimatedQuadVxCount / 2 );
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int elmIdx = 0; elmIdx < static_cast<int>( m_part->elementCount() ); elmIdx++ )
|
||||
{
|
||||
|
@ -21,10 +21,13 @@
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class DrawableGeo;
|
||||
@ -77,7 +80,7 @@ public:
|
||||
|
||||
// Generated geometry
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
|
||||
|
||||
@ -96,7 +99,7 @@ public:
|
||||
const cvf::Vec3d& displayModelOffset );
|
||||
|
||||
private:
|
||||
void computeArrays();
|
||||
void computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||
|
||||
private:
|
||||
// Input
|
||||
@ -106,11 +109,10 @@ private:
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
// cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmIdx;
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmIdx;
|
||||
|
||||
// Mappings
|
||||
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;
|
||||
|
@ -19,12 +19,15 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RivFemPartPartMgr.h"
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifGeoMechReaderInterface.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigFemScalarResultFrames.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
@ -103,6 +106,33 @@ void RivFemPartPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
|
||||
generatePartGeometry( m_surfaceGenerator );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::setDisplacements( bool useDisplacements,
|
||||
double scalingFactor,
|
||||
const std::vector<cvf::Vec3f>& displacements )
|
||||
{
|
||||
size_t nodeCount = m_part->nodes().coordinates.size();
|
||||
m_displacedNodeCoordinates.resize( nodeCount );
|
||||
const auto coords = m_part->nodes().coordinates;
|
||||
|
||||
if ( useDisplacements )
|
||||
{
|
||||
for ( size_t i = 0; i < nodeCount; i++ )
|
||||
{
|
||||
m_displacedNodeCoordinates[i] = coords[i] + displacements[i] * scalingFactor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0; i < nodeCount; i++ )
|
||||
{
|
||||
m_displacedNodeCoordinates[i] = coords[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -113,7 +143,7 @@ void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBu
|
||||
{
|
||||
m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface( m_displacedNodeCoordinates );
|
||||
if ( geo.notNull() )
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
@ -20,9 +20,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class StructGridInterface;
|
||||
@ -46,12 +49,14 @@ class RigFemPart;
|
||||
class RivFemPartPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartPartMgr( const RigFemPart* femPart, cvf::Vec3d displayOffset );
|
||||
explicit RivFemPartPartMgr( const RigFemPart* part, cvf::Vec3d displayOffset );
|
||||
~RivFemPartPartMgr() override;
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility; }
|
||||
|
||||
void setDisplacements( bool useDisplacements, double scalingFactor, const std::vector<cvf::Vec3f>& displacements );
|
||||
|
||||
void updateCellColor( cvf::Color4f color );
|
||||
void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
|
||||
@ -66,6 +71,8 @@ private:
|
||||
int m_partIdx;
|
||||
cvf::cref<RigFemPart> m_part;
|
||||
|
||||
std::vector<cvf::Vec3f> m_displacedNodeCoordinates;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
@ -18,13 +18,16 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "RimGeoMechPartCollection.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include <cstdlib>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -59,6 +62,17 @@ void RivGeoMechPartMgr::clearAndSetReservoir( const RigGeoMechCaseData* geoMechC
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateDisplacements( const RimGeoMechPartCollection* parts, bool showDisplacements, double scaleFactor )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); i++ )
|
||||
{
|
||||
m_femPartPartMgrs[i]->setDisplacements( showDisplacements, scaleFactor, parts->displacements( (int)i ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -33,6 +33,7 @@ class Transform;
|
||||
class RimGeoMechCellColors;
|
||||
class RigGeoMechCaseData;
|
||||
class RimGeoMechView;
|
||||
class RimGeoMechPartCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -51,6 +52,7 @@ public:
|
||||
void clearAndSetReservoir( const RigGeoMechCaseData* geoMechCase );
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( size_t partIndex, cvf::UByteArray* cellVisibilities );
|
||||
void updateDisplacements( const RimGeoMechPartCollection* parts, bool showDisplacements, double scaleFactor );
|
||||
|
||||
cvf::ref<cvf::UByteArray> cellVisibility( size_t partIndex );
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechPartCollection.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimViewController.h"
|
||||
@ -126,6 +127,21 @@ void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex )
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
m_partMgrCache->scheduleRegeneration( visiblePartMgrs[pmIdx] );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnum geometryType )
|
||||
{
|
||||
if ( geometryType == RANGE_FILTERED )
|
||||
@ -202,6 +218,10 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
|
||||
partMgrToUpdate->clearAndSetReservoir( caseData );
|
||||
}
|
||||
|
||||
partMgrToUpdate->updateDisplacements( m_geomechView->partsCollection(),
|
||||
m_geomechView->showDisplacements(),
|
||||
m_geomechView->displacementScaleFactor() );
|
||||
|
||||
partMgrToUpdate->setTransform( m_geomechView->scaleTransform() );
|
||||
|
||||
for ( int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx )
|
||||
@ -266,12 +286,11 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
{
|
||||
if ( !m_geomechView->geoMechCase() ) return;
|
||||
|
||||
size_t gridCount = m_geomechView->femParts()->partCount();
|
||||
|
||||
if ( gridCount == 0 ) return;
|
||||
int partCount = m_geomechView->femParts()->partCount();
|
||||
if ( partCount == 0 ) return;
|
||||
|
||||
int elmCount = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
for ( int i = 0; i < partCount; i++ )
|
||||
{
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
elmCount += part->elementCount();
|
||||
@ -287,7 +306,7 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
if ( partMgr )
|
||||
{
|
||||
int elmOffset = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
for ( int i = 0; i < partCount; i++ )
|
||||
{
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
void updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
void updateStaticCellColors( int timeStepIndex );
|
||||
void scheduleGeometryRegen( RivCellSetEnum geometryType );
|
||||
void scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex );
|
||||
void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex );
|
||||
std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs( int timeStepIndex ) const;
|
||||
const cvf::ref<RivGeoMechPartMgrCache> partMgrCache() const;
|
||||
|
@ -79,3 +79,19 @@ void RimGeoMechPart::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
if ( ownerView ) ownerView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPart::setDisplacements( std::vector<cvf::Vec3f>& displacements )
|
||||
{
|
||||
m_displacements = displacements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<cvf::Vec3f> RimGeoMechPart::displacements() const
|
||||
{
|
||||
return m_displacements;
|
||||
}
|
||||
|
@ -23,6 +23,10 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGeoMechPart : public RimCheckableNamedObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
@ -34,9 +38,14 @@ public:
|
||||
void setPartId( int partId );
|
||||
int partId() const;
|
||||
|
||||
void setDisplacements( std::vector<cvf::Vec3f>& displacements );
|
||||
const std::vector<cvf::Vec3f> displacements() const;
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_partId;
|
||||
|
||||
std::vector<cvf::Vec3f> m_displacements;
|
||||
};
|
||||
|
@ -36,6 +36,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechPartCollection, "GeoMechPartCollection" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechPartCollection::RimGeoMechPartCollection()
|
||||
: m_case( nullptr )
|
||||
, m_currentDisplacementTimeStep( -1 )
|
||||
, m_displacementsUsed( false )
|
||||
, m_currentScaleFactor( 1.0 )
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" );
|
||||
|
||||
@ -90,6 +93,18 @@ std::vector<RimGeoMechPart*> RimGeoMechPartCollection::parts() const
|
||||
return m_parts.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechPart* RimGeoMechPartCollection::part( int partId ) const
|
||||
{
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->partId() == partId ) return part;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -103,10 +118,88 @@ bool RimGeoMechPartCollection::shouldBeVisibleInTree() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::isPartEnabled( int partId ) const
|
||||
{
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->partId() == partId ) return part->isChecked();
|
||||
}
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) return thepart->isChecked();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPartCollection::setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
m_currentDisplacementTimeStep = currentTimeStep;
|
||||
m_displacementsUsed = showDisplacement;
|
||||
m_currentScaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGeoMechPartCollection::currentDisplacementTimeStep() const
|
||||
{
|
||||
return m_currentDisplacementTimeStep;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPartCollection::setDisplacementsForPart( int partId, std::vector<cvf::Vec3f> displacements )
|
||||
{
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) thepart->setDisplacements( displacements );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<cvf::Vec3f> RimGeoMechPartCollection::displacements( int partId ) const
|
||||
{
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) return thepart->displacements();
|
||||
|
||||
return std::vector<cvf::Vec3f>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::isDisplacementsUsed() const
|
||||
{
|
||||
return m_displacementsUsed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::shouldRebuildPartVisualization( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
// if show flag has changed, we need to rebuild grid viz.
|
||||
bool retVal = m_displacementsUsed != showDisplacement;
|
||||
|
||||
// if scaling or timestep has changed, we need to rebuild grid if the displacement should be visible
|
||||
if ( showDisplacement )
|
||||
retVal = retVal || ( m_currentDisplacementTimeStep != currentTimeStep ) ||
|
||||
( std::abs( m_currentScaleFactor - scaleFactor ) > 0.0001 );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::shouldReloadDisplacements( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
// no need to reload something we are not showing
|
||||
if ( !showDisplacement ) return false;
|
||||
|
||||
// if we have no displacements at all, we need to reload.
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->displacements().size() == 0 ) return true;
|
||||
}
|
||||
|
||||
// if timestep has changed we need to reload
|
||||
return m_currentDisplacementTimeStep != currentTimeStep;
|
||||
}
|
||||
|
@ -21,6 +21,10 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGeoMechPart;
|
||||
class RimGeoMechCase;
|
||||
|
||||
@ -34,13 +38,29 @@ public:
|
||||
|
||||
void syncWithCase( RimGeoMechCase* geoCase );
|
||||
|
||||
bool shouldRebuildPartVisualization( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool shouldReloadDisplacements( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool shouldBeVisibleInTree() const;
|
||||
|
||||
bool isPartEnabled( int partId ) const;
|
||||
|
||||
void setDisplacementsForPart( int partId, std::vector<cvf::Vec3f> displacements );
|
||||
const std::vector<cvf::Vec3f> displacements( int partId ) const;
|
||||
|
||||
void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool isDisplacementsUsed() const;
|
||||
int currentDisplacementTimeStep() const;
|
||||
double currentScaleFactor() const;
|
||||
|
||||
std::vector<RimGeoMechPart*> parts() const;
|
||||
|
||||
private:
|
||||
RimGeoMechPart* part( int partId ) const;
|
||||
|
||||
caf::PdmChildArrayField<RimGeoMechPart*> m_parts;
|
||||
RimGeoMechCase* m_case;
|
||||
|
||||
int m_currentDisplacementTimeStep;
|
||||
double m_currentScaleFactor;
|
||||
bool m_displacementsUsed;
|
||||
};
|
||||
|
@ -102,6 +102,9 @@ RimGeoMechView::RimGeoMechView( void )
|
||||
m_partsCollection = new RimGeoMechPartCollection();
|
||||
m_partsCollection.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_showDisplacement, "ShowDisplacement", false, "Show Displacement", "", "", "" );
|
||||
CAF_PDM_InitField( &m_displacementScaling, "DisplacementScaling", 1.0, "Scaling Factor", "", "", "" );
|
||||
|
||||
m_scaleTransform = new cvf::Transform();
|
||||
m_vizLogic = new RivGeoMechVizLogic( this );
|
||||
m_tensorPartMgr = new RivTensorResultPartMgr( this );
|
||||
@ -257,6 +260,8 @@ void RimGeoMechView::onCreateDisplayModel()
|
||||
theParts->part( i )->setEnabled( m_partsCollection()->isPartEnabled( i ) );
|
||||
}
|
||||
|
||||
updateElementDisplacements();
|
||||
|
||||
// Remove all existing animation frames from the viewer.
|
||||
// The parts are still cached in the RivReservoir geometry and friends
|
||||
|
||||
@ -343,6 +348,31 @@ RimPropertyFilterCollection* RimGeoMechView::nativePropertyFilterCollection()
|
||||
return m_propertyFilterCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechView::updateElementDisplacements()
|
||||
{
|
||||
if ( !m_partsCollection->shouldRebuildPartVisualization( m_currentTimeStep, m_showDisplacement, m_displacementScaling ) )
|
||||
return;
|
||||
|
||||
if ( m_partsCollection->shouldReloadDisplacements( m_currentTimeStep, m_showDisplacement, m_displacementScaling ) )
|
||||
{
|
||||
for ( auto part : m_partsCollection->parts() )
|
||||
{
|
||||
std::string errmsg;
|
||||
std::vector<cvf::Vec3f> displacements;
|
||||
m_geomechCase->geoMechData()->readDisplacements( &errmsg, part->partId(), m_currentTimeStep, &displacements );
|
||||
part->setDisplacements( displacements );
|
||||
}
|
||||
}
|
||||
// store current settings so that we know if we need to rebuild later if any of them changes
|
||||
m_partsCollection->setCurrentDisplacementSettings( m_currentTimeStep, m_showDisplacement, m_displacementScaling );
|
||||
|
||||
// tell geometry generator to regenerate grid
|
||||
m_vizLogic->scheduleGeometryRegenOfVisiblePartMgrs( m_currentTimeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -350,6 +380,8 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
|
||||
{
|
||||
onUpdateLegends();
|
||||
|
||||
updateElementDisplacements();
|
||||
|
||||
if ( this->isTimeStepDependentDataVisibleInThisOrComparisonView() )
|
||||
{
|
||||
if ( nativeOrOverrideViewer() )
|
||||
@ -800,6 +832,11 @@ bool RimGeoMechView::isTimeStepDependentDataVisible() const
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ( m_showDisplacement ) || m_partsCollection->isDisplacementsUsed() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -819,6 +856,11 @@ void RimGeoMechView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimGridView::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
|
||||
if ( ( changedField == &m_showDisplacement ) || ( ( changedField == &m_displacementScaling ) && m_showDisplacement() ) )
|
||||
{
|
||||
this->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -955,6 +997,10 @@ void RimGeoMechView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "View Name" );
|
||||
nameConfig()->uiOrdering( uiConfigName, *nameGroup );
|
||||
|
||||
auto displacementGroup = uiOrdering.addNewGroup( "Displacements" );
|
||||
displacementGroup->add( &m_showDisplacement );
|
||||
displacementGroup->add( &m_displacementScaling );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1002,3 +1048,19 @@ const RimGeoMechPartCollection* RimGeoMechView::partsCollection() const
|
||||
{
|
||||
return m_partsCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechView::displacementScaleFactor() const
|
||||
{
|
||||
return m_displacementScaling;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechView::showDisplacements() const
|
||||
{
|
||||
return m_showDisplacement;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class Rim3dOverlayInfoConfig;
|
||||
class RimCellRangeFilterCollection;
|
||||
class RimGeoMechCase;
|
||||
class RimGeoMechCellColors;
|
||||
class RimGeoMechPartCollection;
|
||||
class RimGeoMechPropertyFilterCollection;
|
||||
class RimGeoMechResultDefinition;
|
||||
class RimRegularLegendConfig;
|
||||
@ -105,6 +106,9 @@ public:
|
||||
|
||||
void convertCameraPositionFromOldProjectFiles();
|
||||
|
||||
double displacementScaleFactor() const;
|
||||
bool showDisplacements() const;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
@ -133,14 +137,18 @@ private:
|
||||
|
||||
void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex );
|
||||
|
||||
void updateElementDisplacements();
|
||||
|
||||
caf::PdmChildField<RimTensorResults*> m_tensorResults;
|
||||
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
|
||||
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;
|
||||
caf::PdmChildField<RimGeoMechPartCollection*> m_partsCollection;
|
||||
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
|
||||
caf::PdmField<bool> m_showDisplacement;
|
||||
caf::PdmField<double> m_displacementScaling;
|
||||
|
||||
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
|
||||
cvf::ref<RivGeoMechVizLogic> m_vizLogic;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
cvf::ref<RivGeoMechVizLogic> m_vizLogic;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
|
||||
cvf::ref<RivTensorResultPartMgr> m_tensorPartMgr;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user