mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 20:30:46 -06:00
GeoMech: Apply displacement to cell selection wireframe
This commit is contained in:
1 parent
5fef232b36
commit
b4d0c92d74
5 files changed
+60
-19
No files matched your search
@@ -250,14 +250,24 @@ void RivFemPartGeometryGenerator::setElementVisibility( const cvf::UByteArray* c
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part,
|
cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part,
|
||||||
size_t elmIdx,
|
size_t elmIdx,
|
||||||
const cvf::Vec3d& displayModelOffset )
|
const cvf::Vec3d& displayModelOffset,
|
||||||
|
const std::vector<cvf::Vec3f>& displacements,
|
||||||
|
double displacementScaleFactor )
|
||||||
{
|
{
|
||||||
cvf::ref<cvf::Vec3fArray> quadVertices;
|
cvf::ref<cvf::Vec3fArray> quadVertices;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<Vec3f> vertices;
|
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 );
|
RigElementType eType = part->elementType( elmIdx );
|
||||||
int faceCount = RigFemTypes::elementFaceCount( eType );
|
int faceCount = RigFemTypes::elementFaceCount( eType );
|
||||||
@@ -270,14 +280,10 @@ cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSi
|
|||||||
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace( eType, lfIdx, &faceNodeCount );
|
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace( eType, lfIdx, &faceNodeCount );
|
||||||
if ( faceNodeCount == 4 )
|
if ( faceNodeCount == 4 )
|
||||||
{
|
{
|
||||||
vertices.push_back(
|
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[0]] ) - displayModelOffset ) );
|
||||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayModelOffset ) );
|
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[1]] ) - displayModelOffset ) );
|
||||||
vertices.push_back(
|
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[2]] ) - displayModelOffset ) );
|
||||||
cvf::Vec3f( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayModelOffset ) );
|
vertices.push_back( cvf::Vec3f( nodePosition( elmNodeIndices[localElmNodeIndicesForFace[3]] ) - 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 ) );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,8 +91,11 @@ public:
|
|||||||
|
|
||||||
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p(); }
|
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p(); }
|
||||||
|
|
||||||
static cvf::ref<cvf::DrawableGeo>
|
static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement( const RigFemPart* part,
|
||||||
createMeshDrawableFromSingleElement( const RigFemPart* grid, size_t elementIndex, const cvf::Vec3d& displayModelOffset );
|
size_t elementIndex,
|
||||||
|
const cvf::Vec3d& displayModelOffset,
|
||||||
|
const std::vector<cvf::Vec3f>& displacements = {},
|
||||||
|
double displacementScaleFactor = 1.0 );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
void computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||||
|
|||||||
@@ -80,6 +80,15 @@ void RivSingleCellPartGenerator::setShowLgrMeshLines( bool enable )
|
|||||||
m_showLgrMeshLines = 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 );
|
RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex );
|
||||||
CVF_ASSERT( femPart );
|
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;
|
return nullptr;
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace cvf
|
namespace cvf
|
||||||
{
|
{
|
||||||
@@ -41,6 +44,7 @@ public:
|
|||||||
RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex, const cvf::Vec3d& displayModelOffset );
|
RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex, const cvf::Vec3d& displayModelOffset );
|
||||||
|
|
||||||
void setShowLgrMeshLines( bool enable );
|
void setShowLgrMeshLines( bool enable );
|
||||||
|
void setDisplacementData( double scaleFactor, const std::vector<cvf::Vec3f>& displacements );
|
||||||
|
|
||||||
cvf::ref<cvf::Part> createPart( const cvf::Color3f color );
|
cvf::ref<cvf::Part> createPart( const cvf::Color3f color );
|
||||||
static cvf::ref<cvf::DrawableGeo> createMeshLinesOfParentGridCells( RigGridBase const* grid,
|
static cvf::ref<cvf::DrawableGeo> createMeshLinesOfParentGridCells( RigGridBase const* grid,
|
||||||
@@ -52,10 +56,12 @@ private:
|
|||||||
cvf::ref<cvf::DrawableGeo> createMeshDrawableFromLgrGridCells();
|
cvf::ref<cvf::DrawableGeo> createMeshDrawableFromLgrGridCells();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RigEclipseCaseData* m_rigCaseData;
|
RigEclipseCaseData* m_rigCaseData;
|
||||||
RimGeoMechCase* m_geoMechCase;
|
RimGeoMechCase* m_geoMechCase;
|
||||||
size_t m_gridIndex;
|
size_t m_gridIndex;
|
||||||
size_t m_cellIndex;
|
size_t m_cellIndex;
|
||||||
cvf::Vec3d m_displayModelOffset;
|
cvf::Vec3d m_displayModelOffset;
|
||||||
bool m_showLgrMeshLines{ false };
|
bool m_showLgrMeshLines{ false };
|
||||||
|
double m_displacementScaleFactor{ 1.0 };
|
||||||
|
std::vector<cvf::Vec3f> m_displacements;
|
||||||
};
|
};
|
||||||
@@ -22,7 +22,9 @@
|
|||||||
#include "RimCellFilterCollection.h"
|
#include "RimCellFilterCollection.h"
|
||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseResultDefinition.h"
|
#include "RimEclipseResultDefinition.h"
|
||||||
|
#include "RimGeoMechPartCollection.h"
|
||||||
#include "RimGeoMechResultDefinition.h"
|
#include "RimGeoMechResultDefinition.h"
|
||||||
|
#include "RimGeoMechView.h"
|
||||||
#include "RimGridCollection.h"
|
#include "RimGridCollection.h"
|
||||||
#include "RimIntersection.h"
|
#include "RimIntersection.h"
|
||||||
#include "RimIntersectionCollection.h"
|
#include "RimIntersectionCollection.h"
|
||||||
@@ -368,6 +370,17 @@ void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part
|
|||||||
geomSelItem->m_cellIndex,
|
geomSelItem->m_cellIndex,
|
||||||
ownerCase()->displayModelOffset() );
|
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 );
|
cvf::ref<cvf::Part> part = partGen.createPart( geomSelItem->m_color );
|
||||||
part->setTransform( scaleTransform() );
|
part->setTransform( scaleTransform() );
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user