Add optional surface intersection lines onto seismic geometry

This commit is contained in:
Magne Sjaastad
2023-08-30 10:56:11 +02:00
parent fb75d0471e
commit 6a8b15daa8
4 changed files with 170 additions and 8 deletions

View File

@@ -20,18 +20,23 @@
#include "RiaGuiApplication.h"
#include "RivPartPriority.h"
#include "RivPolylinePartMgr.h"
#include "RivSeismicSectionSourceInfo.h"
#include "Rim3dView.h"
#include "RimRegularLegendConfig.h"
#include "RimSeismicAlphaMapper.h"
#include "RimSeismicSection.h"
#include "RimSeismicSectionCollection.h"
#include "RimSurface.h"
#include "RimSurfaceCollection.h"
#include "RimTools.h"
#include "RigSurfaceResampler.h"
#include "RigTexturedSection.h"
#include "RivPartPriority.h"
#include "RivPolylineGenerator.h"
#include "RivPolylinePartMgr.h"
#include "RivSeismicSectionSourceInfo.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cafPdmObject.h"
@@ -87,7 +92,7 @@ void RivSeismicSectionPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList*
auto texSection = m_section->texturedSection();
for ( int i = 0; i < (int)texSection->partsCount(); i++ )
for ( int i = 0; i < texSection->partsCount(); i++ )
{
auto& part = texSection->part( i );
@@ -236,3 +241,102 @@ cvf::TextureImage* RivSeismicSectionPartMgr::createImageFromData( ZGYAccess::Sei
return textureImage;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>>
RivSeismicSectionPartMgr::projectPolyLineOntoSurface( std::vector<cvf::Vec3d> polyLine,
RimSurface* surface,
const caf::DisplayCoordTransform* displayCoordTransform )
{
std::vector<std::vector<cvf::Vec3d>> displayPolygonCurves;
const double resamplingDistance = 5.0;
std::vector<cvf::Vec3d> resampledPolyline = RigSurfaceResampler::computeResampledPolyline( polyLine, resamplingDistance );
std::vector<cvf::Vec3d> domainCurvePoints;
for ( const auto& point : resampledPolyline )
{
cvf::Vec3d pointAbove = cvf::Vec3d( point.x(), point.y(), 10000.0 );
cvf::Vec3d pointBelow = cvf::Vec3d( point.x(), point.y(), -10000.0 );
cvf::Vec3d intersectionPoint;
bool foundMatch = RigSurfaceResampler::computeIntersectionWithLine( surface->surfaceData(), pointAbove, pointBelow, intersectionPoint );
if ( foundMatch )
{
domainCurvePoints.emplace_back( intersectionPoint );
}
else
{
if ( domainCurvePoints.size() > 1 )
{
// Add intersection curve in display coordinates
auto displayCoords = displayCoordTransform->transformToDisplayCoords( domainCurvePoints );
displayPolygonCurves.push_back( displayCoords );
}
// Start a new line
domainCurvePoints.clear();
}
}
return displayPolygonCurves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSeismicSectionPartMgr::appendSurfaceIntersectionLines( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
double lineThickness,
const std::vector<RimSurface*>& surfaces )
{
for ( auto surface : surfaces )
{
if ( !surface ) continue;
surface->loadDataIfRequired();
if ( !surface->surfaceData() ) continue;
auto texSection = m_section->texturedSection();
for ( int i = 0; i < texSection->partsCount(); i++ )
{
const auto& texturePart = texSection->part( i );
std::vector<cvf::Vec3d> polyLine;
// Each part of the seismic section is a rectangle, use two corners of the rectangle to create a polyline
polyLine.push_back( texturePart.rect[0] );
polyLine.push_back( texturePart.rect[1] );
bool closePolyLine = false;
auto polyLineDisplayCoords = projectPolyLineOntoSurface( polyLine, surface, displayCoordTransform );
cvf::ref<cvf::DrawableGeo> drawableGeo =
RivPolylineGenerator::createLineAlongPolylineDrawable( polyLineDisplayCoords, closePolyLine );
if ( drawableGeo.isNull() ) continue;
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivSeismicSectionPartMgr::SurfaceIntersectionLine" );
part->setDrawable( drawableGeo.p() );
caf::MeshEffectGenerator effgen( surface->color() );
effgen.setLineWidth( lineThickness );
cvf::ref<cvf::Effect> eff = effgen.generateCachedEffect();
cvf::ref<cvf::RenderStatePolygonOffset> polyOffset = new cvf::RenderStatePolygonOffset;
polyOffset->enableFillMode( true );
polyOffset->setFactor( -5 );
const double maxOffsetFactor = -1000;
polyOffset->setUnits( maxOffsetFactor );
eff->setRenderState( polyOffset.p() );
part->setEffect( eff.p() );
part->setPriority( RivPartPriority::PartType::MeshLines );
model->addPart( part.p() );
}
}
}

View File

@@ -20,6 +20,7 @@
#include "cafPdmPointer.h"
#include "cvfArray.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf
{
@@ -45,6 +46,7 @@ class SeismicSliceData;
class RimSeismicSectionCollection;
class RimSeismicSection;
class RimSurface;
class Rim3dView;
class RivPolylinePartMgr;
@@ -62,12 +64,21 @@ public:
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox );
protected:
void appendSurfaceIntersectionLines( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
double lineThickness,
const std::vector<RimSurface*>& surfaces );
private:
cvf::ref<cvf::DrawableGeo> createXYPlaneQuadGeoWithTexCoords( const cvf::Vec3dArray& cornerPoints );
cvf::ref<cvf::Part> createSingleTexturedQuadPart( const cvf::Vec3dArray& cornerPoints, cvf::ref<cvf::TextureImage> image );
cvf::TextureImage* createImageFromData( ZGYAccess::SeismicSliceData* data );
static std::vector<std::vector<cvf::Vec3d>> projectPolyLineOntoSurface( std::vector<cvf::Vec3d> polyLine,
RimSurface* surface,
const caf::DisplayCoordTransform* displayCoordTransform );
private:
caf::PdmPointer<RimSeismicSection> m_section;
cvf::ref<RivPolylinePartMgr> m_polylinePartMgr;