mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
#12211 Show mesh lines on fracture triangle geometry
This commit is contained in:
1 parent
432ac87862
commit
871a064289
9 files changed
+110
-7
No files matched your search
@@ -44,6 +44,7 @@
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfRenderStateBlending.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -91,6 +92,11 @@ void RivSurfacePartMgr::appendNativeGeometryPartsToModel( cvf::ModelBasicList* m
|
||||
|
||||
model->addPart( m_nativeTrianglesPart.p() );
|
||||
|
||||
if ( m_nativeMeshLinesPart.isNull() && m_surfaceInView->isMeshLinesEnabled() )
|
||||
{
|
||||
generateNativeLinesPartGeometry();
|
||||
}
|
||||
|
||||
if ( m_nativeMeshLinesPart.notNull() )
|
||||
{
|
||||
m_nativeMeshLinesPart->setTransform( scaleTransform );
|
||||
@@ -400,7 +406,7 @@ void RivSurfacePartMgr::generatePartGeometry()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSurfacePartMgr::generateNativePartGeometry()
|
||||
cvf::ref<cvf::Vec3fArray> RivSurfacePartMgr::convertToDisplayOffsetVertices( const std::vector<cvf::Vec3d>& vertices ) const
|
||||
{
|
||||
cvf::Vec3d displayModOffset( 0, 0, 0 );
|
||||
|
||||
@@ -411,17 +417,27 @@ void RivSurfacePartMgr::generateNativePartGeometry()
|
||||
if ( ownerCase ) displayModOffset = ownerCase->displayModelOffset();
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray( vertices.size() );
|
||||
for ( size_t i = 0; i < vertices.size(); ++i )
|
||||
{
|
||||
( *cvfVertices )[i] = cvf::Vec3f( vertices[i] - displayModOffset );
|
||||
}
|
||||
|
||||
return cvfVertices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSurfacePartMgr::generateNativePartGeometry()
|
||||
{
|
||||
m_usedSurfaceData = m_surfaceInView->surface()->surfaceData();
|
||||
if ( m_usedSurfaceData.isNull() ) return;
|
||||
|
||||
const std::vector<cvf::Vec3d>& vertices = m_usedSurfaceData->vertices();
|
||||
if ( vertices.empty() ) return;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray( vertices.size() );
|
||||
for ( size_t i = 0; i < vertices.size(); ++i )
|
||||
{
|
||||
( *cvfVertices )[i] = cvf::Vec3f( vertices[i] - displayModOffset );
|
||||
}
|
||||
cvf::ref<cvf::Vec3fArray> cvfVertices = convertToDisplayOffsetVertices( vertices );
|
||||
|
||||
const std::vector<unsigned>& triangleIndices = m_usedSurfaceData->triangleIndices();
|
||||
cvf::ref<cvf::UIntArray> cvfIndices = new cvf::UIntArray( triangleIndices );
|
||||
@@ -440,3 +456,43 @@ void RivSurfacePartMgr::generateNativePartGeometry()
|
||||
m_nativeTrianglesPart->setDrawable( drawGeo.p() );
|
||||
m_nativeTrianglesPart->setSourceInfo( objectSourceInfo.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivSurfacePartMgr::generateNativeLinesPartGeometry()
|
||||
{
|
||||
m_usedSurfaceData = m_surfaceInView->surface()->surfaceData();
|
||||
if ( m_usedSurfaceData.isNull() ) return;
|
||||
|
||||
const std::vector<cvf::Vec3d>& vertices = m_usedSurfaceData->vertices();
|
||||
if ( vertices.empty() ) return;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> cvfVertices = convertToDisplayOffsetVertices( vertices );
|
||||
|
||||
const std::vector<unsigned>& triangleIndices = m_usedSurfaceData->triangleIndices();
|
||||
cvf::ref<cvf::UIntArray> cvfIndices = new cvf::UIntArray( triangleIndices );
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexSet = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINE_STRIP );
|
||||
indexSet->setIndices( cvfIndices.p() );
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawGeo = new cvf::DrawableGeo;
|
||||
drawGeo->addPrimitiveSet( indexSet.p() );
|
||||
drawGeo->setVertexArray( cvfVertices.p() );
|
||||
drawGeo->computeNormals();
|
||||
|
||||
m_nativeMeshLinesPart = new cvf::Part;
|
||||
m_nativeMeshLinesPart->setName( "Mesh" );
|
||||
m_nativeMeshLinesPart->setDrawable( drawGeo.p() );
|
||||
|
||||
m_nativeMeshLinesPart->updateBoundingBox();
|
||||
m_nativeMeshLinesPart->setEnableMask( meshFaultBit );
|
||||
m_nativeMeshLinesPart->setPriority( RivPartPriority::PartType::MeshLines );
|
||||
|
||||
m_nativeMeshLinesPart->setSourceInfo( new RivMeshLinesSourceInfo( m_surfaceInView ) );
|
||||
|
||||
caf::MeshEffectGenerator lineEffGen( cvf::Color3::BLACK );
|
||||
lineEffGen.setLineWidth( 1.0f );
|
||||
cvf::ref<cvf::Effect> eff = lineEffGen.generateCachedEffect();
|
||||
m_nativeMeshLinesPart->setEffect( eff.p() );
|
||||
}
|
||||
@@ -59,6 +59,9 @@ private:
|
||||
void generatePartGeometry();
|
||||
|
||||
void generateNativePartGeometry();
|
||||
void generateNativeLinesPartGeometry();
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> convertToDisplayOffsetVertices( const std::vector<cvf::Vec3d>& vertices ) const;
|
||||
|
||||
bool m_useNativePartsOnly;
|
||||
|
||||
|
||||
@@ -239,3 +239,11 @@ void RimFractureSurface::updateMinMaxValues( RimRegularLegendConfig* legendConfi
|
||||
legendConfig->setClosestToZeroValues( globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero );
|
||||
legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFractureSurface::isMeshLinesEnabledDefault() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
std::vector<std::vector<double>> valuesForProperty( const QString& propertyName ) const;
|
||||
|
||||
void updateMinMaxValues( RimRegularLegendConfig* legend, const QString& propertyName, int currentTimeStep ) const override;
|
||||
bool isMeshLinesEnabledDefault() const override;
|
||||
|
||||
protected:
|
||||
bool updateSurfaceData() override;
|
||||
|
||||
@@ -347,3 +347,11 @@ void RimSurface::updateMinMaxValues( RimRegularLegendConfig* legend, const QStri
|
||||
legend->setAutomaticRanges( globalMin, globalMax, globalMin, globalMax );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurface::isMeshLinesEnabledDefault() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -71,6 +71,8 @@ public:
|
||||
|
||||
virtual void updateMinMaxValues( RimRegularLegendConfig* legend, const QString& propertyName, int currentTimeStep ) const;
|
||||
|
||||
virtual bool isMeshLinesEnabledDefault() const;
|
||||
|
||||
protected:
|
||||
void setSurfaceData( RigSurface* surface );
|
||||
|
||||
@@ -93,6 +95,7 @@ protected:
|
||||
|
||||
caf::PdmField<cvf::Color3f> m_color;
|
||||
caf::PdmField<bool> m_enableOpacity;
|
||||
caf::PdmField<bool> m_showMeshLines;
|
||||
caf::PdmField<double> m_opacity;
|
||||
|
||||
cvf::ref<RigSurface> m_surfaceData;
|
||||
|
||||
@@ -47,6 +47,8 @@ RimSurfaceInView::RimSurfaceInView()
|
||||
CAF_PDM_InitFieldNoDefault( &m_surface, "SurfaceRef", "Surface" );
|
||||
m_surface.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_showMeshLines, "ShowMeshLines", false, "Show Mesh Lines" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "Result Definition" );
|
||||
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
m_resultDefinition = new RimSurfaceResultDefinition;
|
||||
@@ -110,6 +112,22 @@ bool RimSurfaceInView::isNativeSurfaceResultsActive() const
|
||||
return m_resultDefinition->isChecked();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSurfaceInView::isMeshLinesEnabled() const
|
||||
{
|
||||
return m_showMeshLines();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSurfaceInView::setMeshLinesEnabled( bool meshLinesEnabled )
|
||||
{
|
||||
m_showMeshLines = meshLinesEnabled;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -223,7 +241,7 @@ void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField
|
||||
scheduleRedraw = true;
|
||||
}
|
||||
|
||||
if ( changedField == &m_showInactiveCells )
|
||||
if ( changedField == &m_showInactiveCells || changedField == &m_showMeshLines )
|
||||
{
|
||||
clearGeometry();
|
||||
scheduleRedraw = true;
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
|
||||
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
|
||||
|
||||
void setMeshLinesEnabled( bool meshLinesEnabled );
|
||||
bool isMeshLinesEnabled() const;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
@@ -72,6 +75,7 @@ private:
|
||||
|
||||
caf::PdmProxyValueField<QString> m_name;
|
||||
caf::PdmPtrField<RimSurface*> m_surface;
|
||||
caf::PdmField<bool> m_showMeshLines;
|
||||
|
||||
caf::PdmChildField<RimSurfaceResultDefinition*> m_resultDefinition;
|
||||
|
||||
|
||||
@@ -215,6 +215,8 @@ void RimSurfaceInViewCollection::syncSurfacesWithView()
|
||||
newSurfInView->setActive( false );
|
||||
}
|
||||
|
||||
newSurfInView->setMeshLinesEnabled( surf->isMeshLinesEnabledDefault() );
|
||||
|
||||
orderedSurfs.push_back( newSurfInView );
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user