mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user