mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add optional surface intersection lines onto seismic geometry
This commit is contained in:
parent
fb75d0471e
commit
6a8b15daa8
@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include "RimSeismicData.h"
|
||||
#include "RimSeismicDataCollection.h"
|
||||
#include "RimSeismicSection.h"
|
||||
#include "RimSurface.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "RivSeismicSectionPartMgr.h"
|
||||
|
||||
@ -34,6 +37,7 @@
|
||||
#include "cvfModelBasicList.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSeismicSectionCollection, "SeismicSectionCollection" );
|
||||
|
||||
@ -49,6 +53,11 @@ RimSeismicSectionCollection::RimSeismicSectionCollection()
|
||||
CAF_PDM_InitFieldNoDefault( &m_seismicSections, "SeismicSections", "SeismicSections" );
|
||||
m_seismicSections.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_surfaceIntersectionLinesScaleFactor, "SurfaceIntersectionLinesScaleFactor", 5.0, "Line Scale Factor ( >= 1.0 )" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_visibleSurfaceLines, "VisibleSurfaceLines", "Visible Surface Lines" );
|
||||
m_visibleSurfaceLines.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
|
||||
setName( "Seismic Sections" );
|
||||
}
|
||||
|
||||
@ -137,6 +146,9 @@ caf::PdmFieldHandle* RimSeismicSectionCollection::userDescriptionField()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSeismicSectionCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_surfaceIntersectionLinesScaleFactor );
|
||||
uiOrdering.add( &m_visibleSurfaceLines );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
@ -165,6 +177,14 @@ void RimSeismicSectionCollection::appendPartsToModel( Rim3dView*
|
||||
if ( section->seismicData() != nullptr )
|
||||
{
|
||||
section->partMgr()->appendGeometryPartsToModel( model, transform, boundingBox );
|
||||
|
||||
std::vector<RimSurface*> surfaces;
|
||||
for ( const auto& surf : m_visibleSurfaceLines.value() )
|
||||
{
|
||||
surfaces.push_back( surf );
|
||||
}
|
||||
|
||||
section->partMgr()->appendSurfaceIntersectionLines( model, transform, m_surfaceIntersectionLinesScaleFactor(), surfaces );
|
||||
}
|
||||
section->partMgr()->appendPolylinePartsToModel( view, model, transform, boundingBox );
|
||||
}
|
||||
@ -178,10 +198,12 @@ void RimSeismicSectionCollection::appendPartsToModel( Rim3dView*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSeismicSectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == objectToggleField() )
|
||||
if ( changedField == &m_surfaceIntersectionLinesScaleFactor )
|
||||
{
|
||||
updateView();
|
||||
m_surfaceIntersectionLinesScaleFactor = std::max( 1.0, m_surfaceIntersectionLinesScaleFactor() );
|
||||
}
|
||||
|
||||
updateView();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -240,6 +262,25 @@ void RimSeismicSectionCollection::updateLegendRangesTextAndVisibility( RiuViewer
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimSeismicSectionCollection::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_visibleSurfaceLines )
|
||||
{
|
||||
auto surfaceCollection = RimTools::surfaceCollection();
|
||||
for ( auto surface : surfaceCollection->surfaces() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( surface->fullName(), surface ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "RimCheckableNamedObject.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -29,6 +30,7 @@ class RimRegularLegendConfig;
|
||||
class RimSeismicSection;
|
||||
class Rim3dView;
|
||||
class RiuViewer;
|
||||
class RimSurface;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@ -75,6 +77,7 @@ protected:
|
||||
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
|
||||
|
||||
@ -83,4 +86,7 @@ protected:
|
||||
private:
|
||||
caf::PdmField<QString> m_userDescription;
|
||||
caf::PdmChildArrayField<RimSeismicSection*> m_seismicSections;
|
||||
|
||||
caf::PdmField<double> m_surfaceIntersectionLinesScaleFactor;
|
||||
caf::PdmPtrArrayField<RimSurface*> m_visibleSurfaceLines;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user