mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
GeoMech: Apply displacement to cell selection wireframe
This commit is contained in:
@@ -250,14 +250,24 @@ void RivFemPartGeometryGenerator::setElementVisibility( const cvf::UByteArray* c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part,
|
||||
size_t elmIdx,
|
||||
const cvf::Vec3d& displayModelOffset )
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const std::vector<cvf::Vec3f>& displacements,
|
||||
double displacementScaleFactor )
|
||||
{
|
||||
cvf::ref<cvf::Vec3fArray> quadVertices;
|
||||
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = part->nodes().coordinates;
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = part->nodes().coordinates;
|
||||
bool useDisplacements = !displacements.empty() && displacements.size() == nodeCoordinates.size();
|
||||
|
||||
auto nodePosition = [&]( int nodeIdx ) -> cvf::Vec3d
|
||||
{
|
||||
cvf::Vec3d pos = cvf::Vec3d( nodeCoordinates[nodeIdx] );
|
||||
if ( useDisplacements ) pos += cvf::Vec3d( displacements[nodeIdx] ) * displacementScaleFactor;
|
||||
return pos;
|
||||
};
|
||||
|
||||
RigElementType eType = part->elementType( elmIdx );
|
||||
int faceCount = RigFemTypes::elementFaceCount( eType );
|
||||
@@ -270,14 +280,10 @@ cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSi
|
||||
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace( eType, lfIdx, &faceNodeCount );
|
||||
if ( faceNodeCount == 4 )
|
||||
{
|
||||
vertices.push_back(
|
||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayModelOffset ) );
|
||||
vertices.push_back(
|
||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayModelOffset ) );
|
||||
vertices.push_back(
|
||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayModelOffset ) );
|
||||
vertices.push_back(
|
||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[0]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[1]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[2]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[3]] ) - displayModelOffset ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -91,8 +91,11 @@ public:
|
||||
|
||||
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p(); }
|
||||
|
||||
static cvf::ref<cvf::DrawableGeo>
|
||||
createMeshDrawableFromSingleElement( const RigFemPart* grid, size_t elementIndex, const cvf::Vec3d& displayModelOffset );
|
||||
static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement( const RigFemPart* part,
|
||||
size_t elementIndex,
|
||||
const cvf::Vec3d& displayModelOffset,
|
||||
const std::vector<cvf::Vec3f>& displacements = {},
|
||||
double displacementScaleFactor = 1.0 );
|
||||
|
||||
private:
|
||||
void computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||
|
||||
@@ -80,6 +80,15 @@ void RivSingleCellPartGenerator::setShowLgrMeshLines( bool enable )
|
||||
m_showLgrMeshLines = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSingleCellPartGenerator::setDisplacementData( double scaleFactor, const std::vector<cvf::Vec3f>& displacements )
|
||||
{
|
||||
m_displacementScaleFactor = scaleFactor;
|
||||
m_displacements = displacements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -239,7 +248,11 @@ cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
|
||||
RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex );
|
||||
CVF_ASSERT( femPart );
|
||||
|
||||
return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart, m_cellIndex, m_displayModelOffset );
|
||||
return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart,
|
||||
m_cellIndex,
|
||||
m_displayModelOffset,
|
||||
m_displacements,
|
||||
m_displacementScaleFactor );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -41,6 +44,7 @@ public:
|
||||
RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex, const cvf::Vec3d& displayModelOffset );
|
||||
|
||||
void setShowLgrMeshLines( bool enable );
|
||||
void setDisplacementData( double scaleFactor, const std::vector<cvf::Vec3f>& displacements );
|
||||
|
||||
cvf::ref<cvf::Part> createPart( const cvf::Color3f color );
|
||||
static cvf::ref<cvf::DrawableGeo> createMeshLinesOfParentGridCells( RigGridBase const* grid,
|
||||
@@ -52,10 +56,12 @@ private:
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawableFromLgrGridCells();
|
||||
|
||||
private:
|
||||
RigEclipseCaseData* m_rigCaseData;
|
||||
RimGeoMechCase* m_geoMechCase;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
bool m_showLgrMeshLines{ false };
|
||||
RigEclipseCaseData* m_rigCaseData;
|
||||
RimGeoMechCase* m_geoMechCase;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
cvf::Vec3d m_displayModelOffset;
|
||||
bool m_showLgrMeshLines{ false };
|
||||
double m_displacementScaleFactor{ 1.0 };
|
||||
std::vector<cvf::Vec3f> m_displacements;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimGeoMechPartCollection.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimIntersection.h"
|
||||
#include "RimIntersectionCollection.h"
|
||||
@@ -368,6 +370,17 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part
|
||||
geomSelItem->m_cellIndex,
|
||||
ownerCase()->displayModelOffset() );
|
||||
|
||||
auto geoMechView = dynamic_cast<RimGeoMechView*>( this );
|
||||
if ( geoMechView )
|
||||
{
|
||||
const RimGeoMechPartCollection* partsColl = geoMechView->partsCollection();
|
||||
if ( partsColl && partsColl->isDisplacementsUsed() )
|
||||
{
|
||||
partGen.setDisplacementData( partsColl->currentDisplacementScaleFactor(),
|
||||
partsColl->displacements( static_cast<int>( geomSelItem->m_gridIndex ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = partGen.createPart( geomSelItem->m_color );
|
||||
part->setTransform( scaleTransform() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user