#7892 Basic support for display of surface lines and bands on intersections

Guard divide by zero issues
2D Intersection View: Do not add parts with wrong coordinates
Add bounding box search tree
Add support display of intersection lines for selected surfaces
Show band between two first intersection lines
This commit is contained in:
Magne Sjaastad 2021-08-26 08:13:03 +02:00 committed by GitHub
parent 61ea190920
commit 2fc65a3b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 826 additions and 358 deletions

View File

@ -110,8 +110,7 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo()
RimExtrudedCurveIntersection* intersection = new RimExtrudedCurveIntersection();
intersection->setName( "Azimuth and Dip" );
intersection->type = RimExtrudedCurveIntersection::CS_AZIMUTHLINE;
intersection->inputTwoAzimuthPointsFromViewerEnabled = true;
intersection->configureForAzimuthLine();
RimCase* rimCase;
m_intersectionCollection->firstAncestorOrThisOfTypeAsserted( rimCase );

View File

@ -109,8 +109,7 @@ void RicNewPolylineIntersectionFeatureCmd::redo()
RimExtrudedCurveIntersection* intersection = new RimExtrudedCurveIntersection();
intersection->setName( "Polyline" );
intersection->type = RimExtrudedCurveIntersection::CS_POLYLINE;
intersection->inputPolyLineFromViewerEnabled = true;
intersection->configureForPolyLine();
m_intersectionCollection->appendIntersectionAndUpdate( intersection, false );

View File

@ -105,8 +105,7 @@ void RicNewSimWellIntersectionCmd::redo()
RimExtrudedCurveIntersection* intersection = new RimExtrudedCurveIntersection();
intersection->setName( m_simWell->name );
intersection->type = RimExtrudedCurveIntersection::CS_SIMULATION_WELL;
intersection->simulationWell = m_simWell;
intersection->configureForSimulationWell( m_simWell );
m_intersectionCollection->appendIntersectionAndUpdate( intersection, false );
}

View File

@ -114,8 +114,7 @@ void RicNewWellPathIntersectionFeatureCmd::redo()
RimExtrudedCurveIntersection* intersection = new RimExtrudedCurveIntersection();
intersection->setName( m_wellPath->name() );
intersection->type = RimExtrudedCurveIntersection::CS_WELL_PATH;
intersection->wellPath = m_wellPath;
intersection->configureForWellPath( m_wellPath );
m_intersectionCollection->appendIntersectionAndUpdate( intersection, false );
}

View File

@ -62,7 +62,7 @@ void RicNewIntersectionViewFeature::onActionTriggered( bool isChecked )
intersection->firstAncestorOrThisOfType( rimCase );
if ( rimCase )
{
if ( intersection->direction() != RimExtrudedCurveIntersection::CS_VERTICAL )
if ( intersection->direction() != RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_VERTICAL )
{
QString text = QString( "The intersection view only supports vertical intersections.\n"
"The intersection '%1' is not vertical but a converted version will be shown "

View File

@ -22,6 +22,7 @@
#include "RigWellPath.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimModeledWellPath.h"
@ -75,6 +76,10 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
auto* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
// TODO: The location of the well target must be updated before displayed in the 2D intersection view. Currently
// disabled.
if ( dynamic_cast<Rim2dIntersectionView*>( view ) ) return;
if ( !target || !target->isEnabled() || !view )
{
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();

View File

@ -8,7 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.h
${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattener.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -20,7 +20,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.cpp
${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattener.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -21,15 +21,20 @@
#include "RigMainGrid.h"
#include "RigResultAccessor.h"
#include "RigSurface.h"
#include "RigSurfaceResampler.h"
#include "RigWellPath.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGridView.h"
#include "RimSurface.h"
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "RivHexGridIntersectionTools.h"
#include "RivPolylineGenerator.h"
#include "RivSectionFlattener.h"
#include "cafDisplayCoordTransform.h"
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
@ -42,8 +47,6 @@
#include "cvfRay.h"
#include "cvfScalarMapper.h"
#include "RivSectionFlattner.h"
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform( const RimExtrudedCurveIntersection* intersection )
{
Rim3dView* rimView = nullptr;
@ -66,7 +69,7 @@ RivExtrudedCurveIntersectionGeometryGenerator::RivExtrudedCurveIntersectionGeome
bool isFlattened,
const cvf::Vec3d& flattenedPolylineStartPoint )
: m_intersection( crossSection )
, m_polyLines( polylines )
, m_polylines( polylines )
, m_extrusionDirection( extrusionDirection )
, m_hexGrid( grid )
, m_isFlattened( isFlattened )
@ -89,28 +92,27 @@ RivExtrudedCurveIntersectionGeometryGenerator::~RivExtrudedCurveIntersectionGeom
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivExtrudedCurveIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint()
void RivExtrudedCurveIntersectionGeometryGenerator::calculateLineSegementTransforms()
{
if ( m_isFlattened )
{
if ( !( m_polyLines.size() && m_polyLines.back().size() ) ) return;
if ( m_polylines.empty() || m_polylines.back().empty() ) return;
cvf::Vec3d startOffset = m_flattenedPolylineStartPoint;
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
for ( const std::vector<cvf::Vec3d>& polyLine : m_polylines )
{
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
startOffset.z() = polyLine[0].z();
m_segementTransformPrLinePoint.emplace_back(
RivSectionFlattner::calculateFlatteningCSsForPolyline( polyLine,
m_extrusionDirection,
startOffset,
&startOffset ) );
startOffset.z() = polyLine[0].z();
m_lineSegmentTransforms.emplace_back(
RivSectionFlattener::calculateFlatteningCSsForPolyline( polyLine,
m_extrusionDirection,
startOffset,
&startOffset ) );
}
}
else
{
m_segementTransformPrLinePoint.clear();
m_lineSegmentTransforms.clear();
cvf::Vec3d displayOffset( 0, 0, 0 );
{
@ -124,10 +126,10 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateSegementTransformPr
cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation( -displayOffset );
for ( const auto& polyLine : m_polyLines )
for ( const auto& polyLine : m_polylines )
{
m_segementTransformPrLinePoint.emplace_back();
std::vector<cvf::Mat4d>& segmentTransforms = m_segementTransformPrLinePoint.back();
m_lineSegmentTransforms.emplace_back();
std::vector<cvf::Mat4d>& segmentTransforms = m_lineSegmentTransforms.back();
for ( size_t lIdx = 0; lIdx < polyLine.size(); ++lIdx )
{
segmentTransforms.push_back( invSectionCS );
@ -139,21 +141,60 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateSegementTransformPr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivExtrudedCurveIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline()
void RivExtrudedCurveIntersectionGeometryGenerator::calculateTransformedPolyline()
{
CVF_ASSERT( m_segementTransformPrLinePoint.size() == m_polyLines.size() );
CVF_ASSERT( m_lineSegmentTransforms.size() == m_polylines.size() );
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
for ( size_t lineIdx = 0; lineIdx < m_polylines.size(); ++lineIdx )
{
m_flattenedOrOffsettedPolyLines.emplace_back();
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
auto flatPolyline = m_transformedPolyLines.emplace_back();
const auto& polyline = m_polylines[lineIdx];
CVF_ASSERT( polyLine.size() == m_polyLines[pLineIdx].size() );
for ( size_t pIdx = 0; pIdx < polyLine.size(); ++pIdx )
for ( size_t index = 0; index < polyline.size(); ++index )
{
m_flattenedOrOffsettedPolyLines.back().push_back(
polyLine[pIdx].getTransformedPoint( m_segementTransformPrLinePoint[pLineIdx][pIdx] ) );
flatPolyline.push_back( transformPointByPolylineSegmentIndex( polyline[index], lineIdx, index ) );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivExtrudedCurveIntersectionGeometryGenerator::calculateSurfaceIntersectionPoints()
{
m_transformedSurfaceIntersectionPolylines.clear();
if ( !m_polylines.empty() )
{
auto firstPolyLine = m_polylines.front();
for ( auto rimSurface : m_intersection->annotatedSurfaces() )
{
if ( !rimSurface ) return;
rimSurface->loadDataIfRequired();
auto surface = rimSurface->surfaceData();
std::vector<cvf::Vec3d> transformedSurfacePolyline;
// Resample polyline to required resolution
const double maxLineSegmentLength = 1.0;
auto resampledPolyline = computeResampledPolyline( firstPolyLine, maxLineSegmentLength );
for ( auto [point, segmentIndex] : 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::resamplePoint( surface, pointAbove, pointBelow, intersectionPoint );
if ( !foundMatch )
intersectionPoint = cvf::Vec3d( point.x(), point.y(), std::numeric_limits<double>::infinity() );
const size_t lineIndex = 0;
transformedSurfacePolyline.push_back(
transformPointByPolylineSegmentIndex( intersectionPoint, lineIndex, segmentIndex ) );
}
m_transformedSurfaceIntersectionPolylines[rimSurface] = transformedSurfacePolyline;
}
}
}
@ -228,12 +269,12 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
calculateSegementTransformPrLinePoint();
calculateFlattenedOrOffsetedPolyline();
calculateLineSegementTransforms();
calculateTransformedPolyline();
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
for ( size_t pLineIdx = 0; pLineIdx < m_polylines.size(); ++pLineIdx )
{
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
const std::vector<cvf::Vec3d>& polyLine = m_polylines[pLineIdx];
if ( polyLine.size() < 2 ) continue;
@ -241,7 +282,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
size_t lIdx = 0;
while ( lIdx < lineCount - 1 )
{
size_t idxToNextP = RivSectionFlattner::indexToNextValidPoint( polyLine, m_extrusionDirection, lIdx );
size_t idxToNextP = RivSectionFlattener::indexToNextValidPoint( polyLine, m_extrusionDirection, lIdx );
if ( idxToNextP == size_t( -1 ) ) break;
@ -257,7 +298,7 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
double maxSectionHeightUp = 0;
double maxSectionHeightDown = 0;
if ( m_intersection->type == RimExtrudedCurveIntersection::CS_AZIMUTHLINE )
if ( m_intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE )
{
maxSectionHeightUp = m_intersection->lengthUp();
maxSectionHeightDown = m_intersection->lengthDown();
@ -305,12 +346,10 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
cvf::Vec3d cellCorners[8];
size_t cornerIndices[8];
cvf::Mat4d invSectionCS = m_segementTransformPrLinePoint[pLineIdx][lIdx];
cvf::Mat4d invSectionCS = m_lineSegmentTransforms[pLineIdx][lIdx];
for ( size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx )
for ( auto globalCellIdx : columnCellCandidates )
{
size_t globalCellIdx = columnCellCandidates[cccIdx];
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
hexPlaneCutTriangleVxes.clear();
@ -323,10 +362,10 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
&hexPlaneCutTriangleVxes,
&cellFaceForEachTriangleEdge );
if ( m_intersection->type == RimExtrudedCurveIntersection::CS_AZIMUTHLINE )
if ( m_intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE )
{
bool hasAnyPointsOnSurface = false;
for ( caf::HexGridIntersectionTools::ClipVx vertex : hexPlaneCutTriangleVxes )
for ( const caf::HexGridIntersectionTools::ClipVx& vertex : hexPlaneCutTriangleVxes )
{
cvf::Vec3d temp = vertex.vx - p1;
double dot = temp.dot( m_extrusionDirection );
@ -400,22 +439,22 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
if ( cvx.isVxIdsNative )
{
m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights( cvx.clippedEdgeVx1Id,
cvx.clippedEdgeVx2Id,
cvx.normDistFromEdgeVx1 ) );
m_triVxToCellCornerWeights.emplace_back( cvx.clippedEdgeVx1Id,
cvx.clippedEdgeVx2Id,
cvx.normDistFromEdgeVx1 );
}
else
{
caf::HexGridIntersectionTools::ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
caf::HexGridIntersectionTools::ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights( cvx1.clippedEdgeVx1Id,
cvx1.clippedEdgeVx2Id,
cvx1.normDistFromEdgeVx1,
cvx2.clippedEdgeVx1Id,
cvx2.clippedEdgeVx2Id,
cvx2.normDistFromEdgeVx1,
cvx.normDistFromEdgeVx1 ) );
m_triVxToCellCornerWeights.emplace_back( cvx1.clippedEdgeVx1Id,
cvx1.clippedEdgeVx2Id,
cvx1.normDistFromEdgeVx1,
cvx2.clippedEdgeVx1Id,
cvx2.clippedEdgeVx2Id,
cvx2.normDistFromEdgeVx1,
cvx.normDistFromEdgeVx1 );
}
}
}
@ -430,8 +469,10 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays()
for ( const auto& it : meshAcc.faultToHighestFaultMeshVxMap )
{
m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } );
m_faultMeshLabelAndAnchorPositions.emplace_back( it.first->name(), it.second );
}
calculateSurfaceIntersectionPoints();
}
//--------------------------------------------------------------------------------------------------
@ -491,7 +532,7 @@ cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::create
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::createLineAlongPolylineDrawable()
{
return RivPolylineGenerator::createLineAlongPolylineDrawable( m_flattenedOrOffsettedPolyLines );
return RivPolylineGenerator::createLineAlongPolylineDrawable( m_transformedPolyLines );
}
//--------------------------------------------------------------------------------------------------
@ -517,7 +558,7 @@ cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::create
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::createPointsFromPolylineDrawable()
{
return RivPolylineGenerator::createPointsFromPolylineDrawable( m_flattenedOrOffsettedPolyLines );
return RivPolylineGenerator::createPointsFromPolylineDrawable( m_transformedPolyLines );
}
//--------------------------------------------------------------------------------------------------
@ -538,6 +579,23 @@ cvf::ref<cvf::DrawableGeo> RivExtrudedCurveIntersectionGeometryGenerator::create
std::vector<std::vector<cvf::Vec3d>>( { displayCoords } ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<std::vector<cvf::Vec3d>>& RivExtrudedCurveIntersectionGeometryGenerator::flattenedOrOffsettedPolyLines()
{
return m_transformedPolyLines;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<std::pair<QString, cvf::Vec3d>>&
RivExtrudedCurveIntersectionGeometryGenerator::faultMeshLabelAndAnchorPositions()
{
return m_faultMeshLabelAndAnchorPositions;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -574,6 +632,75 @@ RimExtrudedCurveIntersection* RivExtrudedCurveIntersectionGeometryGenerator::int
return m_intersection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivExtrudedCurveIntersectionGeometryGenerator::transformPointByPolylineSegmentIndex( const cvf::Vec3d& domainCoord,
size_t lineIndex,
size_t segmentIndex )
{
CVF_ASSERT( lineIndex < m_lineSegmentTransforms.size() );
CVF_ASSERT( segmentIndex < m_lineSegmentTransforms[lineIndex].size() );
// Each line segment along the polyline has a transformation matrix representing the transformation from 3D into
// flat 2D. Return the transformed domain coord using the required transformation matrix
return domainCoord.getTransformedPoint( m_lineSegmentTransforms[lineIndex][segmentIndex] );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::pair<cvf::Vec3d, size_t>>
RivExtrudedCurveIntersectionGeometryGenerator::computeResampledPolyline( const std::vector<cvf::Vec3d>& polyline,
double resamplingDistance )
{
// Segments along the original polyline must be provided to be able to find the associated transform matrix
std::vector<std::pair<cvf::Vec3d, size_t>> resampledPolyline;
if ( polyline.size() > 1 )
{
std::vector<double> measuredDepth;
{
double aggregatedLength = 0.0;
cvf::Vec3d previousPoint = polyline.front();
measuredDepth.push_back( aggregatedLength );
for ( size_t i = 1; i < polyline.size(); i++ )
{
aggregatedLength += ( previousPoint - polyline[i] ).length();
previousPoint = polyline[i];
measuredDepth.push_back( aggregatedLength );
}
}
// Use RigWellPath to perform the interpolation along a line based on measured depth
RigWellPath dummyWellPath( polyline, measuredDepth );
for ( size_t i = 1; i < polyline.size(); i++ )
{
const auto& lineSegmentStart = polyline[i - 1];
const auto& lineSegmentEnd = polyline[i];
auto startMD = measuredDepth[i - 1];
auto endMD = measuredDepth[i];
const size_t segmentIndex = i - 1;
resampledPolyline.emplace_back( lineSegmentStart, segmentIndex );
for ( auto md = startMD + resamplingDistance; md < endMD; md += resamplingDistance )
{
resampledPolyline.emplace_back( dummyWellPath.interpolatedPointAlongWellPath( md ), segmentIndex );
}
resampledPolyline.emplace_back( lineSegmentEnd, segmentIndex );
}
}
return resampledPolyline;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -582,20 +709,20 @@ cvf::Mat4d
{
cvf::Mat4d flattenMx = cvf::Mat4d::IDENTITY;
for ( size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++ )
for ( size_t pLineIdx = 0; pLineIdx < m_transformedPolyLines.size(); pLineIdx++ )
{
const std::vector<cvf::Vec3d>& polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx];
const std::vector<cvf::Vec3d>& polyLine = m_transformedPolyLines[pLineIdx];
for ( size_t pIdx = 0; pIdx < polyLine.size(); pIdx++ )
{
if ( polyLine[pIdx].x() >= intersectionPointFlat.x() )
{
size_t csIdx = pIdx > 0 ? pIdx - 1 : 0;
flattenMx = m_segementTransformPrLinePoint[pLineIdx][csIdx];
flattenMx = m_lineSegmentTransforms[pLineIdx][csIdx];
break;
}
else if ( pIdx == polyLine.size() - 1 )
if ( pIdx == polyLine.size() - 1 )
{
flattenMx = m_segementTransformPrLinePoint[pLineIdx][pIdx];
flattenMx = m_lineSegmentTransforms[pLineIdx][pIdx];
}
}
}
@ -612,8 +739,15 @@ bool RivExtrudedCurveIntersectionGeometryGenerator::isAnyGeometryPresent() const
{
return false;
}
else
{
return true;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<RimSurface*, std::vector<cvf::Vec3d>>
RivExtrudedCurveIntersectionGeometryGenerator::transformedSurfaceIntersectionPolylines() const
{
return m_transformedSurfaceIntersectionPolylines;
}

View File

@ -39,6 +39,7 @@ class RigResultAccessor;
class RimExtrudedCurveIntersection;
class RivIntersectionHexGridInterface;
class RivIntersectionVertexWeights;
class RimSurface;
namespace cvf
{
@ -68,34 +69,37 @@ public:
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable( const std::vector<cvf::Vec3d>& extrusionLine );
const std::vector<std::vector<cvf::Vec3d>>& flattenedOrOffsettedPolyLines()
{
return m_flattenedOrOffsettedPolyLines;
}
const std::vector<std::pair<QString, cvf::Vec3d>>& faultMeshLabelAndAnchorPositions()
{
return m_faultMeshLabelAndAnchorPositions;
}
RimExtrudedCurveIntersection* intersection() const;
const std::vector<std::pair<QString, cvf::Vec3d>>& faultMeshLabelAndAnchorPositions();
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat ) const;
// GeomGen Interface
bool isAnyGeometryPresent() const override;
std::map<RimSurface*, std::vector<cvf::Vec3d>> transformedSurfaceIntersectionPolylines() const;
const std::vector<size_t>& triangleToCellIndex() const override;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const override;
const cvf::Vec3fArray* triangleVxes() const override;
private:
void calculateArrays();
void calculateSegementTransformPrLinePoint();
void calculateFlattenedOrOffsetedPolyline();
void calculateLineSegementTransforms();
void calculateTransformedPolyline();
void calculateSurfaceIntersectionPoints();
RimExtrudedCurveIntersection* intersection() const;
const std::vector<std::vector<cvf::Vec3d>>& flattenedOrOffsettedPolyLines();
cvf::Vec3d transformPointByPolylineSegmentIndex( const cvf::Vec3d& domainCoord, size_t lineIndex, size_t segmentIndex );
static std::vector<std::pair<cvf::Vec3d, size_t>> computeResampledPolyline( const std::vector<cvf::Vec3d>& polyline,
double resamplingDistance );
private:
RimExtrudedCurveIntersection* m_intersection;
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
const std::vector<std::vector<cvf::Vec3d>> m_polyLines;
const std::vector<std::vector<cvf::Vec3d>> m_polylines;
cvf::Vec3d m_extrusionDirection;
bool m_isFlattened;
cvf::Vec3d m_flattenedPolylineStartPoint;
@ -106,8 +110,10 @@ private:
cvf::ref<cvf::Vec3fArray> m_faultCellBorderLineVxes;
std::vector<size_t> m_triangleToCellIdxMap;
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
std::vector<std::vector<cvf::Vec3d>> m_flattenedOrOffsettedPolyLines;
std::vector<std::vector<cvf::Mat4d>> m_segementTransformPrLinePoint;
std::vector<std::vector<cvf::Vec3d>> m_transformedPolyLines;
std::vector<std::vector<cvf::Mat4d>> m_lineSegmentTransforms;
std::vector<std::pair<QString, cvf::Vec3d>> m_faultMeshLabelAndAnchorPositions;
std::map<RimSurface*, std::vector<cvf::Vec3d>> m_transformedSurfaceIntersectionPolylines;
};

View File

@ -42,6 +42,7 @@
#include "RimGeoMechView.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
#include "RimSurface.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
@ -55,6 +56,7 @@
#include "RivObjectSourceInfo.h"
#include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h"
#include "RivPolylineGenerator.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
#include "RivSimWellPipeSourceInfo.h"
@ -66,6 +68,7 @@
#include "cvfDrawableGeo.h"
#include "cvfDrawableText.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfGeometryTools.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
@ -94,7 +97,7 @@ RivExtrudedCurveIntersectionPartMgr::RivExtrudedCurveIntersectionPartMgr( RimExt
cvf::Vec3d flattenedPolylineStartPoint;
std::vector<std::vector<cvf::Vec3d>> polyLines = m_rimIntersection->polyLines( &flattenedPolylineStartPoint );
if ( polyLines.size() > 0 )
if ( !polyLines.empty() )
{
cvf::Vec3d direction = m_rimIntersection->extrusionDirection();
cvf::ref<RivIntersectionHexGridInterface> hexGrid = m_rimIntersection->createHexGridInterface();
@ -175,7 +178,7 @@ void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMech
{
textureCoords->resize( vertexWeights.size() );
if ( resultValues.size() == 0 )
if ( resultValues.empty() )
{
textureCoords->setAll( cvf::Vec2f( 0.0, 1.0f ) );
}
@ -249,7 +252,7 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry()
// Set mapping from triangle face index to cell index
cvf::ref<RivExtrudedCurveIntersectionSourceInfo> si =
new RivExtrudedCurveIntersectionSourceInfo( m_intersectionGenerator.p() );
new RivExtrudedCurveIntersectionSourceInfo( m_intersectionGenerator.p(), m_rimIntersection );
part->setSourceInfo( si.p() );
part->updateBoundingBox();
@ -314,6 +317,8 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry()
if ( m_isFlattened ) createFaultLabelParts( m_intersectionGenerator->faultMeshLabelAndAnchorPositions() );
applySingleColorEffect();
createAnnotationSurfaceParts( useBufferObjects );
}
//--------------------------------------------------------------------------------------------------
@ -324,7 +329,7 @@ void RivExtrudedCurveIntersectionPartMgr::createFaultLabelParts( const std::vect
m_faultMeshLabels = nullptr;
m_faultMeshLabelLines = nullptr;
if ( !labelAndAnchors.size() ) return;
if ( labelAndAnchors.empty() ) return;
RimFaultInViewCollection* faultInViewColl = nullptr;
@ -375,7 +380,7 @@ void RivExtrudedCurveIntersectionPartMgr::createFaultLabelParts( const std::vect
textCoord.z() += labelZOffset;
drawableText->addText( cvfString, textCoord );
lineVertices.push_back( cvf::Vec3f( labelAndAnchorPair.second ) );
lineVertices.emplace_back( labelAndAnchorPair.second );
lineVertices.push_back( textCoord );
visibleFaultNameCount++;
}
@ -433,8 +438,8 @@ void RivExtrudedCurveIntersectionPartMgr::createPolyLineParts( bool useBufferObj
m_highlightLineAlongPolyline = nullptr;
m_highlightPointsForPolyline = nullptr;
if ( m_rimIntersection->type == RimExtrudedCurveIntersection::CS_POLYLINE ||
m_rimIntersection->type == RimExtrudedCurveIntersection::CS_AZIMUTHLINE )
if ( m_rimIntersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ||
m_rimIntersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE )
{
{
cvf::ref<cvf::DrawableGeo> polylineGeo = m_intersectionGenerator->createLineAlongPolylineDrawable();
@ -514,7 +519,7 @@ void RivExtrudedCurveIntersectionPartMgr::createExtrusionDirParts( bool useBuffe
m_highlightLineAlongExtrusionDir = nullptr;
m_highlightPointsForExtrusionDir = nullptr;
if ( m_rimIntersection->direction() == RimExtrudedCurveIntersection::CS_TWO_POINTS )
if ( m_rimIntersection->direction() == RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_TWO_POINTS )
{
{
cvf::ref<cvf::DrawableGeo> polylineGeo = m_intersectionGenerator->createLineAlongExtrusionLineDrawable(
@ -588,6 +593,99 @@ void RivExtrudedCurveIntersectionPartMgr::createExtrusionDirParts( bool useBuffe
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivExtrudedCurveIntersectionPartMgr::createAnnotationSurfaceParts( bool useBufferObjects )
{
m_annotationParts.clear();
auto surfPolys = m_intersectionGenerator->transformedSurfaceIntersectionPolylines();
for ( auto [surface, polylines] : surfPolys )
{
if ( !surface ) continue;
auto polylineGeo = RivPolylineGenerator::createLineAlongPolylineDrawable( polylines );
if ( polylineGeo.notNull() )
{
if ( useBufferObjects )
{
polylineGeo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "Intersection " + surface->userDescription().toStdString() );
part->setDrawable( polylineGeo.p() );
part->updateBoundingBox();
part->setPriority( RivPartPriority::PartType::Highlight );
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen( surface->color() );
lineEffGen.setLineWidth( 5.0f );
eff = lineEffGen.generateUnCachedEffect();
part->setEffect( eff.p() );
m_annotationParts.push_back( part.p() );
}
}
if ( surfPolys.size() > 1 )
{
// Create a quad strip between the two first polylines
auto firstSurfaceItem = surfPolys.begin();
auto secondSurfaceItem = firstSurfaceItem++;
auto polylineA = firstSurfaceItem->second;
auto polylineB = secondSurfaceItem->second;
size_t pointCount = std::min( polylineA.size(), polylineB.size() );
if ( pointCount > 1 )
{
cvf::GeometryBuilderDrawableGeo geoBuilder;
for ( size_t i = 1; i < pointCount; i++ )
{
const auto& pA0 = polylineA[i - 1];
const auto& pA1 = polylineA[i];
const auto& pB0 = polylineB[i - 1];
const auto& pB1 = polylineB[i];
geoBuilder.addQuadByVertices( cvf::Vec3f( pA0 ), cvf::Vec3f( pA1 ), cvf::Vec3f( pB1 ), cvf::Vec3f( pB0 ) );
}
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.drawableGeo();
if ( geo.notNull() )
{
geo->computeNormals();
if ( useBufferObjects )
{
geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "Surface Intersection Band" );
part->setDrawable( geo.p() );
part->updateBoundingBox();
part->setEnableMask( intersectionCellFaceBit );
part->setPriority( RivPartPriority::PartType::Transparent );
auto color = cvf::Color4f( cvf::Color3f::OLIVE, 0.5f );
caf::SurfaceEffectGenerator geometryEffgen( color, caf::PO_NEG_LARGE );
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
part->setEffect( geometryOnlyEffect.p() );
m_annotationParts.push_back( part.p() );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -649,9 +747,9 @@ void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView&
cvf::ModelBasicList* model,
cvf::Transform* scaleTransform )
{
Rim2dIntersectionView* curr2dView = dynamic_cast<Rim2dIntersectionView*>( &view );
auto* curr2dView = dynamic_cast<Rim2dIntersectionView*>( &view );
if ( m_rimIntersection->inputPolyLineFromViewerEnabled || ( curr2dView && curr2dView->showDefiningPoints() ) )
if ( m_rimIntersection->inputPolyLineFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) )
{
if ( m_highlightLineAlongPolyline.notNull() )
{
@ -666,7 +764,7 @@ void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView&
}
}
if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled )
if ( m_rimIntersection->inputExtrusionPointsFromViewerEnabled() )
{
if ( m_highlightLineAlongExtrusionDir.notNull() )
{
@ -681,7 +779,7 @@ void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView&
}
}
if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled || ( curr2dView && curr2dView->showDefiningPoints() ) )
if ( m_rimIntersection->inputTwoAzimuthPointsFromViewerEnabled() || ( curr2dView && curr2dView->showDefiningPoints() ) )
{
if ( m_highlightLineAlongPolyline.notNull() )
{
@ -695,14 +793,16 @@ void RivExtrudedCurveIntersectionPartMgr::appendPolylinePartsToModel( Rim3dView&
model->addPart( m_highlightPointsForPolyline.p() );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimExtrudedCurveIntersection* RivExtrudedCurveIntersectionPartMgr::intersection() const
{
return m_rimIntersection.p();
for ( size_t i = 0; i < m_annotationParts.size(); i++ )
{
auto part = m_annotationParts[i];
if ( part.notNull() )
{
part->setTransform( scaleTransform );
model->addPart( part.p() );
}
}
}
//--------------------------------------------------------------------------------------------------
@ -720,5 +820,5 @@ const RivIntersectionGeometryGeneratorIF* RivExtrudedCurveIntersectionPartMgr::i
{
if ( m_intersectionGenerator.notNull() ) return m_intersectionGenerator.p();
return NULL;
return nullptr;
}

View File

@ -26,6 +26,7 @@
#include "cvfVector3.h"
#include "cafPdmPointer.h"
#include "cvfCollection.h"
#include <QString>
@ -76,18 +77,16 @@ public:
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
const RimExtrudedCurveIntersection* intersection() const;
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat ) const;
const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const;
public:
private:
void generatePartGeometry();
void createFaultLabelParts( const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors );
void createPolyLineParts( bool useBufferObjects );
void createExtrusionDirParts( bool useBufferObjects );
void createAnnotationSurfaceParts( bool useBufferObjects );
private:
caf::PdmPointer<RimExtrudedCurveIntersection> m_rimIntersection;
@ -104,6 +103,8 @@ private:
cvf::ref<cvf::Part> m_highlightLineAlongExtrusionDir;
cvf::ref<cvf::Part> m_highlightPointsForExtrusionDir;
cvf::Collection<cvf::Part> m_annotationParts;
cvf::ref<cvf::Vec2fArray> m_intersectionFacesTextureCoords;
struct RivPipeBranchData

View File

@ -19,14 +19,17 @@
#include "RivExtrudedCurveIntersectionSourceInfo.h"
#include "RimExtrudedCurveIntersection.h"
#include "RivExtrudedCurveIntersectionGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivExtrudedCurveIntersectionSourceInfo::RivExtrudedCurveIntersectionSourceInfo(
RivExtrudedCurveIntersectionGeometryGenerator* geometryGenerator )
RivExtrudedCurveIntersectionGeometryGenerator* geometryGenerator,
RimExtrudedCurveIntersection* intersection )
: m_intersectionGeometryGenerator( geometryGenerator )
, m_intersection( intersection )
{
CVF_ASSERT( m_intersectionGeometryGenerator.notNull() );
}
@ -59,5 +62,5 @@ std::array<cvf::Vec3f, 3> RivExtrudedCurveIntersectionSourceInfo::triangle( int
//--------------------------------------------------------------------------------------------------
RimExtrudedCurveIntersection* RivExtrudedCurveIntersectionSourceInfo::intersection() const
{
return m_intersectionGeometryGenerator->intersection();
return m_intersection;
}

View File

@ -19,8 +19,11 @@
#pragma once
#include "cafPdmPointer.h"
#include "cvfArray.h"
#include "cvfObject.h"
#include <array>
class RivExtrudedCurveIntersectionGeometryGenerator;
@ -29,7 +32,8 @@ class RimExtrudedCurveIntersection;
class RivExtrudedCurveIntersectionSourceInfo : public cvf::Object
{
public:
explicit RivExtrudedCurveIntersectionSourceInfo( RivExtrudedCurveIntersectionGeometryGenerator* geometryGenerator );
explicit RivExtrudedCurveIntersectionSourceInfo( RivExtrudedCurveIntersectionGeometryGenerator* geometryGenerator,
RimExtrudedCurveIntersection* intersection );
const std::vector<size_t>& triangleToCellIndex() const;
std::array<cvf::Vec3f, 3> triangle( int triangleIdx ) const;
@ -37,4 +41,5 @@ public:
private:
cvf::cref<RivExtrudedCurveIntersectionGeometryGenerator> m_intersectionGeometryGenerator;
caf::PdmPointer<RimExtrudedCurveIntersection> m_intersection;
};

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivSectionFlattner.h"
#include "RivSectionFlattener.h"
#include "cvfGeometryTools.h"
//--------------------------------------------------------------------------------------------------
@ -25,9 +25,9 @@
///
/// Returns size_t(-1) if no point is found
//--------------------------------------------------------------------------------------------------
size_t RivSectionFlattner::indexToNextValidPoint( const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d extrDir,
size_t idxToStartOfLineSegment )
size_t RivSectionFlattener::indexToNextValidPoint( const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d extrDir,
size_t idxToStartOfLineSegment )
{
size_t lineCount = polyLine.size();
if ( !( idxToStartOfLineSegment + 1 < lineCount ) ) return -1;
@ -51,10 +51,10 @@ size_t RivSectionFlattner::indexToNextValidPoint( const std::vector<cvf::Vec3d>&
//--------------------------------------------------------------------------------------------------
/// Returns one CS pr point, valid for the next segment
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline( const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d& extrusionDir,
const cvf::Vec3d& startOffset,
cvf::Vec3d* endOffset )
std::vector<cvf::Mat4d> RivSectionFlattener::calculateFlatteningCSsForPolyline( const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d& extrusionDir,
const cvf::Vec3d& startOffset,
cvf::Vec3d* endOffset )
{
CVF_ASSERT( endOffset );
size_t pointCount = polyLine.size();
@ -128,9 +128,9 @@ std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline( c
/// Ey normal to the section plane
/// Ex in plane along p1-p2
//--------------------------------------------------------------------------------------------------
cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS( const cvf::Vec3d& p1,
const cvf::Vec3d& p2,
const cvf::Vec3d& extrusionDir )
cvf::Mat4d RivSectionFlattener::calculateSectionLocalFlatteningCS( const cvf::Vec3d& p1,
const cvf::Vec3d& p2,
const cvf::Vec3d& extrusionDir )
{
using namespace cvf;

View File

@ -22,7 +22,7 @@
#include <vector>
class RivSectionFlattner
class RivSectionFlattener
{
public:
static size_t indexToNextValidPoint( const std::vector<cvf::Vec3d>& polyLine,

View File

@ -37,7 +37,7 @@
#include "RimVirtualPerforationResults.h"
#include "RivPipeGeometryGenerator.h"
#include "RivSectionFlattner.h"
#include "RivSectionFlattener.h"
#include "RivSimWellConnectionSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivWellConnectionFactorGeometryGenerator.h"
@ -203,10 +203,10 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
if ( doFlatten )
{
std::vector<cvf::Mat4d> flatningCSs =
RivSectionFlattner::calculateFlatteningCSsForPolyline( m_pipeBranchesCLCoords[brIdx],
cvf::Vec3d::Z_AXIS,
flattenedStartOffset,
&flattenedStartOffset );
RivSectionFlattener::calculateFlatteningCSsForPolyline( m_pipeBranchesCLCoords[brIdx],
cvf::Vec3d::Z_AXIS,
flattenedStartOffset,
&flattenedStartOffset );
for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx )
{
( *cvfCoords )[cIdx] = ( ( *cvfCoords )[cIdx] ).getTransformedPoint( flatningCSs[cIdx] );

View File

@ -33,7 +33,7 @@
#include "RivDiskGeometryGenerator.h"
#include "RivPartPriority.h"
#include "RivSectionFlattner.h"
#include "RivSectionFlattener.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivTextLabelSourceInfo.h"

View File

@ -36,7 +36,7 @@
#include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h"
#include "RivSectionFlattner.h"
#include "RivSectionFlattener.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivTextLabelSourceInfo.h"

View File

@ -58,7 +58,7 @@
#include "RivObjectSourceInfo.h"
#include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h"
#include "RivSectionFlattner.h"
#include "RivSectionFlattener.h"
#include "RivTextLabelSourceInfo.h"
#include "RivWellConnectionFactorPartMgr.h"
#include "RivWellFracturePartMgr.h"
@ -438,12 +438,12 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
{
cvf::Vec3d dummy;
vector<cvf::Mat4d> flatningCSs =
RivSectionFlattner::calculateFlatteningCSsForPolyline( perfIntervalCL,
cvf::Vec3d::Z_AXIS,
{ horizontalLengthAlongWellPath,
0.0,
perfIntervalCL[0].z() },
&dummy );
RivSectionFlattener::calculateFlatteningCSsForPolyline( perfIntervalCL,
cvf::Vec3d::Z_AXIS,
{ horizontalLengthAlongWellPath,
0.0,
perfIntervalCL[0].z() },
&dummy );
for ( size_t cIdx = 0; cIdx < perfIntervalCL.size(); ++cIdx )
{
@ -668,12 +668,12 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d
{
cvf::Vec3d dummy;
std::vector<cvf::Mat4d> flatningCSs =
RivSectionFlattner::calculateFlatteningCSsForPolyline( clippedWellPathCenterLine,
cvf::Vec3d::Z_AXIS,
{ horizontalLengthAlongWellToClipPoint,
0.0,
clippedWellPathCenterLine[0].z() },
&dummy );
RivSectionFlattener::calculateFlatteningCSsForPolyline( clippedWellPathCenterLine,
cvf::Vec3d::Z_AXIS,
{ horizontalLengthAlongWellToClipPoint,
0.0,
clippedWellPathCenterLine[0].z() },
&dummy );
for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx )
{
@ -814,11 +814,8 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d
cvf::GeometryBuilderTriangles builder;
cvf::GeometryUtils::createSphere( cellRadius, 15, 15, &builder );
vectorDrawable->setGlyph( builder.trianglesUShort().p(), builder.vertices().p() );
{
vectorDrawable->setRadius( cellRadius );
vectorDrawable->setCenterCoords( vertices.p() );
}
vectorDrawable->setRadius( cellRadius );
vectorDrawable->setCenterCoords( vertices.p() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivWellPathPartMgr_WellTargetSpheres" );
@ -906,10 +903,16 @@ void RivWellPathPartMgr::appendFlattenedStaticGeometryPartsToModel( cvf::ModelBa
model->addPart( m_wellLabelPart.p() );
}
if ( m_spherePart.notNull() )
{
model->addPart( m_spherePart.p() );
}
/*
// TODO: Currently not supported.
// Require coordinate transformations of the spheres similar to RivWellPathPartMgr::buildWellPathParts
// https://github.com/OPM/ResInsight/issues/7891
//
if ( m_spherePart.notNull() )
{
model->addPart( m_spherePart.p() );
}
*/
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,6 +19,8 @@
#include "RivSurfaceIntersectionGeometryGenerator.h"
#include "RiaLogging.h"
#include "RigMainGrid.h"
#include "RigResultAccessor.h"
@ -32,10 +34,13 @@
#include "RivExtrudedCurveIntersectionPartMgr.h"
#include "RivHexGridIntersectionTools.h"
#include "RivPolylineGenerator.h"
#include "RivSectionFlattener.h"
#include "cafDisplayCoordTransform.h"
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
#include "../cafHexInterpolator/cafHexInterpolator.h" // Use relative path, as this is a header only file not part of a library
#include "cvfDrawableGeo.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
@ -44,12 +49,6 @@
#include "cvfRay.h"
#include "cvfScalarMapper.h"
#include "../cafHexInterpolator/cafHexInterpolator.h"
#include "RivSectionFlattner.h"
#include "RiaLogging.h"
#include "clipper.hpp"
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform( const RimIntersection* intersection )
{
Rim3dView* rimView = nullptr;
@ -206,10 +205,8 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
std::array<cvf::Vec3d, 8> cellCorners;
std::array<size_t, 8> cornerIndices;
for ( size_t ticIdx = 0; ticIdx < triIntersectedCellCandidates.size(); ++ticIdx )
for ( size_t globalCellIdx : triIntersectedCellCandidates )
{
size_t globalCellIdx = triIntersectedCellCandidates[ticIdx];
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
hexPlaneCutTriangleVxes.clear();
@ -309,7 +306,7 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays()
for ( const auto& it : meshAcc.faultToHighestFaultMeshVxMap )
{
m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } );
m_faultMeshLabelAndAnchorPositions.emplace_back( it.first->name(), it.second );
}
}
@ -417,8 +414,6 @@ bool RivSurfaceIntersectionGeometryGenerator::isAnyGeometryPresent() const
{
return false;
}
else
{
return true;
}
return true;
}

View File

@ -132,6 +132,9 @@ void RivWindowEdgeAxesOverlayItem::updateFromCamera( const Camera* camera )
windowMaxInDomain = m_dispalyCoordsTransform->transformToDomainCoord( windowMaxInDomain );
}
// For extreme zoom factors we might end up with both variables as zero. Return to avoid divide by zero.
if ( windowOrigoInDomain == windowMaxInDomain ) return;
double domainMinX = windowOrigoInDomain.x();
double domainMaxX = windowMaxInDomain.x();

View File

@ -562,7 +562,8 @@ void Rim2dIntersectionView::onCreateDisplayModel()
m_flatSimWellPipePartMgr = nullptr;
m_flatWellHeadPartMgr = nullptr;
if ( m_intersection->type() == RimExtrudedCurveIntersection::CS_SIMULATION_WELL && m_intersection->simulationWell() )
if ( m_intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL &&
m_intersection->simulationWell() )
{
RimEclipseView* eclipseView = nullptr;
m_intersection->firstAncestorOrThisOfType( eclipseView );
@ -575,7 +576,8 @@ void Rim2dIntersectionView::onCreateDisplayModel()
}
m_flatWellpathPartMgr = nullptr;
if ( m_intersection->type() == RimExtrudedCurveIntersection::CS_WELL_PATH && m_intersection->wellPath() )
if ( m_intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH &&
m_intersection->wellPath() )
{
Rim3dView* settingsView = nullptr;
m_intersection->firstAncestorOrThisOfType( settingsView );

View File

@ -22,14 +22,21 @@
#include "RigEclipseCaseData.h"
#include "RigWellPath.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEnsembleSurface.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
#include "RimSurface.h"
#include "RimSurfaceCollection.h"
#include "RimTools.h"
#include "RimWellPath.h"
@ -42,10 +49,7 @@
#include "cafPdmUiListEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "Rim2dIntersectionView.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
@ -55,20 +59,20 @@ namespace caf
template <>
void caf::AppEnum<RimExtrudedCurveIntersection::CrossSectionEnum>::setUp()
{
addItem( RimExtrudedCurveIntersection::CS_WELL_PATH, "CS_WELL_PATH", "Well Path" );
addItem( RimExtrudedCurveIntersection::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" );
addItem( RimExtrudedCurveIntersection::CS_POLYLINE, "CS_POLYLINE", "Polyline" );
addItem( RimExtrudedCurveIntersection::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" );
setDefault( RimExtrudedCurveIntersection::CS_WELL_PATH );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH, "CS_WELL_PATH", "Well Path" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE, "CS_POLYLINE", "Polyline" );
addItem( RimExtrudedCurveIntersection::CrossSectionEnum::CS_AZIMUTHLINE, "CS_AZIMUTHLINE", "Azimuth and Dip" );
setDefault( RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH );
}
template <>
void caf::AppEnum<RimExtrudedCurveIntersection::CrossSectionDirEnum>::setUp()
{
addItem( RimExtrudedCurveIntersection::CS_VERTICAL, "CS_VERTICAL", "Vertical" );
addItem( RimExtrudedCurveIntersection::CS_HORIZONTAL, "CS_HORIZONTAL", "Horizontal" );
addItem( RimExtrudedCurveIntersection::CS_TWO_POINTS, "CS_TWO_POINTS", "Defined by Two Points" );
setDefault( RimExtrudedCurveIntersection::CS_VERTICAL );
addItem( RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_VERTICAL, "CS_VERTICAL", "Vertical" );
addItem( RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_HORIZONTAL, "CS_HORIZONTAL", "Horizontal" );
addItem( RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_TWO_POINTS, "CS_TWO_POINTS", "Defined by Two Points" );
setDefault( RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_VERTICAL );
}
} // namespace caf
@ -85,6 +89,98 @@ const RivIntersectionGeometryGeneratorIF* RimExtrudedCurveIntersection::intersec
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimExtrudedCurveIntersection::CrossSectionEnum RimExtrudedCurveIntersection::type() const
{
return m_type();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimExtrudedCurveIntersection::CrossSectionDirEnum RimExtrudedCurveIntersection::direction() const
{
return m_direction();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimExtrudedCurveIntersection::wellPath() const
{
return m_wellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSimWellInView* RimExtrudedCurveIntersection::simulationWell() const
{
return m_simulationWell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimExtrudedCurveIntersection::inputPolyLineFromViewerEnabled() const
{
return m_inputPolylineFromViewerEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimExtrudedCurveIntersection::inputExtrusionPointsFromViewerEnabled() const
{
return m_inputExtrusionPointsFromViewerEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimExtrudedCurveIntersection::inputTwoAzimuthPointsFromViewerEnabled() const
{
return m_inputTwoAzimuthPointsFromViewerEnabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForSimulationWell( RimSimWellInView* simWell )
{
m_type = CrossSectionEnum::CS_SIMULATION_WELL;
m_simulationWell = simWell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForWellPath( RimWellPath* wellPath )
{
m_type = CrossSectionEnum::CS_WELL_PATH;
m_wellPath = wellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForPolyLine()
{
m_type = CrossSectionEnum::CS_POLYLINE;
m_inputPolylineFromViewerEnabled = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::configureForAzimuthLine()
{
m_type = CrossSectionEnum::CS_AZIMUTHLINE;
m_inputTwoAzimuthPointsFromViewerEnabled = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -93,10 +189,10 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitObject( "Intersection", ":/CrossSection16x16.png", "", "" );
CAF_PDM_InitField( &m_name, "UserDescription", QString( "Intersection Name" ), "Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &type, "Type", "Type", "", "", "" );
CAF_PDM_InitFieldNoDefault( &direction, "Direction", "Direction", "", "", "" );
CAF_PDM_InitFieldNoDefault( &wellPath, "WellPath", "Well Path ", "", "", "" );
CAF_PDM_InitFieldNoDefault( &simulationWell, "SimulationWell", "Simulation Well", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_type, "Type", "Type", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_direction, "Direction", "Direction", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path ", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_simulationWell, "SimulationWell", "Simulation Well", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_userPolyline, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "" );
CAF_PDM_InitField( &m_azimuthAngle, "AzimuthAngle", 0.0, "Azimuth", "", "", "" );
@ -118,22 +214,30 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection()
CAF_PDM_InitField( &m_lengthUp, "lengthUp", 1000.0, "Length Up", "", "", "" );
CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down", "", "", "" );
CAF_PDM_InitFieldNoDefault( &inputPolyLineFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &inputPolyLineFromViewerEnabled );
inputPolyLineFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputPolylineFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputPolylineFromViewerEnabled );
m_inputPolylineFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &inputExtrusionPointsFromViewerEnabled, "inputExtrusionPointsFromViewerEnabled", "", "", "", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &inputExtrusionPointsFromViewerEnabled );
inputExtrusionPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_inputExtrusionPointsFromViewerEnabled,
"inputExtrusionPointsFromViewerEnabled",
"",
"",
"",
"" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputExtrusionPointsFromViewerEnabled );
m_inputExtrusionPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &inputTwoAzimuthPointsFromViewerEnabled,
CAF_PDM_InitFieldNoDefault( &m_inputTwoAzimuthPointsFromViewerEnabled,
"inputTwoAzimuthPointsFromViewerEnabled",
"",
"",
"",
"" );
caf::PdmUiPushButtonEditor::configureEditorForField( &inputTwoAzimuthPointsFromViewerEnabled );
inputTwoAzimuthPointsFromViewerEnabled = false;
caf::PdmUiPushButtonEditor::configureEditorForField( &m_inputTwoAzimuthPointsFromViewerEnabled );
m_inputTwoAzimuthPointsFromViewerEnabled = false;
CAF_PDM_InitFieldNoDefault( &m_annotationSurfaces, "annotationSurfaces", "", "", "", "" );
m_annotationSurfaces.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
uiCapability()->setUiTreeChildrenHidden( true );
@ -178,30 +282,21 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
const QVariant& oldValue,
const QVariant& newValue )
{
// clang-format off
if ( changedField == &m_isActive ||
changedField == &type ||
changedField == &direction ||
changedField == &wellPath ||
changedField == &simulationWell ||
changedField == &m_branchIndex ||
changedField == &m_extentLength ||
changedField == &m_lengthUp ||
changedField == &m_lengthDown ||
changedField == &m_showInactiveCells ||
changedField == &m_useSeparateDataSource ||
if ( changedField == &m_isActive || changedField == &m_type || changedField == &m_direction ||
changedField == &m_wellPath || changedField == &m_simulationWell || changedField == &m_branchIndex ||
changedField == &m_extentLength || changedField == &m_lengthUp || changedField == &m_lengthDown ||
changedField == &m_showInactiveCells || changedField == &m_useSeparateDataSource ||
changedField == &m_separateDataSource )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
// clang-format on
if ( changedField == &simulationWell || changedField == &m_isActive || changedField == &type )
if ( changedField == &m_simulationWell || changedField == &m_isActive || changedField == &m_type )
{
recomputeSimulationWellBranchData();
}
if ( changedField == &simulationWell || changedField == &wellPath || changedField == &m_branchIndex )
if ( changedField == &m_simulationWell || changedField == &m_wellPath || changedField == &m_branchIndex )
{
updateName();
}
@ -216,34 +311,34 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
}
}
if ( changedField == &inputPolyLineFromViewerEnabled || changedField == &m_userPolyline )
if ( changedField == &m_inputPolylineFromViewerEnabled || changedField == &m_userPolyline )
{
if ( inputPolyLineFromViewerEnabled )
if ( m_inputPolylineFromViewerEnabled )
{
inputExtrusionPointsFromViewerEnabled = false;
inputTwoAzimuthPointsFromViewerEnabled = false;
m_inputExtrusionPointsFromViewerEnabled = false;
m_inputTwoAzimuthPointsFromViewerEnabled = false;
}
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &inputExtrusionPointsFromViewerEnabled || changedField == &m_customExtrusionPoints )
if ( changedField == &m_inputExtrusionPointsFromViewerEnabled || changedField == &m_customExtrusionPoints )
{
if ( inputExtrusionPointsFromViewerEnabled )
if ( m_inputExtrusionPointsFromViewerEnabled )
{
inputPolyLineFromViewerEnabled = false;
inputTwoAzimuthPointsFromViewerEnabled = false;
m_inputPolylineFromViewerEnabled = false;
m_inputTwoAzimuthPointsFromViewerEnabled = false;
}
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &inputTwoAzimuthPointsFromViewerEnabled || changedField == &m_twoAzimuthPoints )
if ( changedField == &m_inputTwoAzimuthPointsFromViewerEnabled || changedField == &m_twoAzimuthPoints )
{
if ( inputTwoAzimuthPointsFromViewerEnabled )
if ( m_inputTwoAzimuthPointsFromViewerEnabled )
{
inputPolyLineFromViewerEnabled = false;
inputExtrusionPointsFromViewerEnabled = false;
m_inputPolylineFromViewerEnabled = false;
m_inputExtrusionPointsFromViewerEnabled = false;
}
rebuildGeometryAndScheduleCreateDisplayModel();
@ -259,6 +354,12 @@ void RimExtrudedCurveIntersection::fieldChangedByUi( const caf::PdmFieldHandle*
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
if ( changedField == &m_annotationSurfaces )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
}
//--------------------------------------------------------------------------------------------------
@ -268,56 +369,56 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
{
uiOrdering.add( &m_name );
caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup( "Intersecting Geometry" );
geometryGroup->add( &type );
geometryGroup->add( &m_type );
if ( type == CS_WELL_PATH )
if ( m_type() == CrossSectionEnum::CS_WELL_PATH )
{
geometryGroup->add( &wellPath );
geometryGroup->add( &m_wellPath );
}
else if ( type == CS_SIMULATION_WELL )
else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
geometryGroup->add( &simulationWell );
geometryGroup->add( &m_simulationWell );
updateSimulationWellCenterline();
if ( simulationWell() && m_simulationWellBranchCenterlines.size() > 1 )
if ( m_simulationWell() && m_simulationWellBranchCenterlines.size() > 1 )
{
geometryGroup->add( &m_branchIndex );
}
}
else if ( type == CS_POLYLINE )
else if ( type() == CrossSectionEnum::CS_POLYLINE )
{
geometryGroup->add( &m_userPolyline );
geometryGroup->add( &inputPolyLineFromViewerEnabled );
geometryGroup->add( &m_inputPolylineFromViewerEnabled );
}
else if ( type == CS_AZIMUTHLINE )
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
geometryGroup->add( &m_twoAzimuthPoints );
geometryGroup->add( &inputTwoAzimuthPointsFromViewerEnabled );
geometryGroup->add( &m_inputTwoAzimuthPointsFromViewerEnabled );
geometryGroup->add( &m_azimuthAngle );
geometryGroup->add( &m_dipAngle );
}
caf::PdmUiGroup* optionsGroup = uiOrdering.addNewGroup( "Options" );
if ( type == CS_AZIMUTHLINE )
if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
optionsGroup->add( &m_lengthUp );
optionsGroup->add( &m_lengthDown );
}
else
{
optionsGroup->add( &direction );
optionsGroup->add( &m_direction );
optionsGroup->add( &m_extentLength );
}
if ( direction == CS_TWO_POINTS )
if ( direction() == CrossSectionDirEnum::CS_TWO_POINTS )
{
optionsGroup->add( &m_customExtrusionPoints );
optionsGroup->add( &inputExtrusionPointsFromViewerEnabled );
optionsGroup->add( &m_inputExtrusionPointsFromViewerEnabled );
}
optionsGroup->add( &m_showInactiveCells );
if ( type == CS_POLYLINE )
if ( type() == CrossSectionEnum::CS_POLYLINE )
{
m_extentLength.uiCapability()->setUiReadOnly( true );
}
@ -326,6 +427,9 @@ void RimExtrudedCurveIntersection::defineUiOrdering( QString uiConfigName, caf::
m_extentLength.uiCapability()->setUiReadOnly( false );
}
caf::PdmUiGroup* surfaceGroup = uiOrdering.addNewGroup( "Surfaces" );
surfaceGroup->add( &m_annotationSurfaces );
this->defineSeparateDataSourceUi( uiConfigName, uiOrdering );
uiOrdering.skipRemainingFields( true );
@ -340,16 +444,16 @@ QList<caf::PdmOptionItemInfo>
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &wellPath )
if ( fieldNeedingOptions == &m_wellPath )
{
RimTools::wellPathOptionItems( &options );
if ( options.size() > 0 )
if ( !options.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
}
else if ( fieldNeedingOptions == &simulationWell )
else if ( fieldNeedingOptions == &m_simulationWell )
{
RimSimWellInViewCollection* coll = simulationWellCollection();
if ( coll )
@ -363,7 +467,7 @@ QList<caf::PdmOptionItemInfo>
}
}
if ( options.size() == 0 )
if ( options.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
@ -381,6 +485,23 @@ QList<caf::PdmOptionItemInfo>
options.push_back( caf::PdmOptionItemInfo( QString::number( bIdx + 1 ), QVariant::fromValue( bIdx ) ) );
}
}
else if ( fieldNeedingOptions == &m_annotationSurfaces )
{
RimSurfaceCollection* surfColl = RimProject::current()->activeOilField()->surfaceCollection();
caf::IconProvider surfaceIcon( ":/ReservoirSurface16x16.png" );
for ( auto surf : surfColl->surfaces() )
{
options.push_back( caf::PdmOptionItemInfo( surf->userDescription(), surf, false, surfaceIcon ) );
}
for ( auto ensambleSurf : surfColl->ensembleSurfaces() )
{
for ( auto surf : ensambleSurf->surfaces() )
{
options.push_back( caf::PdmOptionItemInfo( surf->userDescription(), surf, false, surfaceIcon ) );
}
}
}
else
{
options = RimIntersection::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
@ -438,11 +559,11 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
double horizontalProjectedLengthAlongWellPathToClipPoint = 0.0;
if ( type == CS_WELL_PATH )
if ( type() == CrossSectionEnum::CS_WELL_PATH )
{
if ( wellPath() && wellPath->wellPathGeometry() )
if ( m_wellPath() && wellPath()->wellPathGeometry() )
{
lines.push_back( wellPath->wellPathGeometry()->wellPathPoints() );
lines.push_back( wellPath()->wellPathGeometry()->wellPathPoints() );
RimCase* ownerCase = nullptr;
this->firstAncestorOrThisOfType( ownerCase );
if ( ownerCase )
@ -455,9 +576,9 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
}
}
}
else if ( type == CS_SIMULATION_WELL )
else if ( type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
if ( simulationWell() )
if ( m_simulationWell() )
{
updateSimulationWellCenterline();
@ -474,37 +595,35 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
}
}
}
else if ( type == CS_POLYLINE )
else if ( type() == CrossSectionEnum::CS_POLYLINE )
{
lines.push_back( m_userPolyline );
}
else if ( type == CS_AZIMUTHLINE )
else if ( type() == CrossSectionEnum::CS_AZIMUTHLINE )
{
lines.push_back( m_twoAzimuthPoints );
}
if ( type == CS_WELL_PATH || type == CS_SIMULATION_WELL )
if ( type() == CrossSectionEnum::CS_WELL_PATH || type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
if ( type == CS_SIMULATION_WELL && simulationWell() )
if ( type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
cvf::Vec3d top, bottom;
simulationWell->wellHeadTopBottomPosition( -1, &top, &bottom );
m_simulationWell->wellHeadTopBottomPosition( -1, &top, &bottom );
for ( size_t lIdx = 0; lIdx < lines.size(); ++lIdx )
for ( std::vector<cvf::Vec3d>& polyLine : lines )
{
std::vector<cvf::Vec3d>& polyLine = lines[lIdx];
polyLine.insert( polyLine.begin(), top );
}
}
for ( size_t lIdx = 0; lIdx < lines.size(); ++lIdx )
for ( std::vector<cvf::Vec3d>& polyLine : lines )
{
std::vector<cvf::Vec3d>& polyLine = lines[lIdx];
addExtents( polyLine );
}
if ( flattenedPolylineStartPoint && lines.size() && lines[0].size() > 1 )
if ( flattenedPolylineStartPoint && !lines.empty() && lines[0].size() > 1 )
{
( *flattenedPolylineStartPoint )[0] = horizontalProjectedLengthAlongWellPathToClipPoint - m_extentLength;
( *flattenedPolylineStartPoint )[2] = lines[0][1].z(); // Depth of first point in first polyline
@ -512,7 +631,7 @@ std::vector<std::vector<cvf::Vec3d>> RimExtrudedCurveIntersection::polyLines( cv
}
else
{
if ( flattenedPolylineStartPoint && lines.size() && lines[0].size() )
if ( flattenedPolylineStartPoint && !lines.empty() && !( lines[0] ).empty() )
{
( *flattenedPolylineStartPoint )[2] = lines[0][0].z(); // Depth of first point in first polyline
}
@ -551,11 +670,11 @@ std::vector<cvf::Vec3d> RimExtrudedCurveIntersection::polyLinesForExtrusionDirec
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateSimulationWellCenterline() const
{
if ( m_isActive() && type == CS_SIMULATION_WELL && simulationWell() )
if ( m_isActive() && type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
if ( m_simulationWellBranchCenterlines.empty() )
{
auto branches = simulationWell->wellPipeBranches();
auto branches = m_simulationWell->wellPipeBranches();
for ( const auto& branch : branches )
{
m_simulationWellBranchCenterlines.push_back( branch->wellPathPoints() );
@ -629,17 +748,17 @@ void RimExtrudedCurveIntersection::addExtents( std::vector<cvf::Vec3d>& polyLine
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::updateName()
{
if ( type == CS_SIMULATION_WELL && simulationWell() )
if ( type() == CrossSectionEnum::CS_SIMULATION_WELL && m_simulationWell() )
{
m_name = simulationWell()->name();
m_name = m_simulationWell()->name();
if ( branchIndex() != -1 )
{
m_name = m_name() + " Branch " + QString::number( branchIndex() + 1 );
}
}
else if ( type() == CS_WELL_PATH && wellPath() )
else if ( m_type() == CrossSectionEnum::CS_WELL_PATH && m_wellPath() )
{
m_name = wellPath()->name();
m_name = m_wellPath()->name();
}
Rim2dIntersectionView* iView = correspondingIntersectionView();
@ -708,8 +827,7 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
caf::PdmUiDoubleSliderEditorAttribute* doubleSliderAttrib =
dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
auto* doubleSliderAttrib = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
if ( doubleSliderAttrib )
{
if ( field == &m_azimuthAngle )
@ -725,31 +843,32 @@ void RimExtrudedCurveIntersection::defineEditorAttribute( const caf::PdmFieldHan
doubleSliderAttrib->m_sliderTickCount = 180;
}
}
else if ( field == &inputPolyLineFromViewerEnabled )
else if ( field == &m_inputPolylineFromViewerEnabled )
{
setPushButtonText( inputPolyLineFromViewerEnabled, dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) );
setPushButtonText( m_inputPolylineFromViewerEnabled,
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) );
}
else if ( field == &m_userPolyline )
{
setBaseColor( inputPolyLineFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
setBaseColor( m_inputPolylineFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
}
else if ( field == &inputTwoAzimuthPointsFromViewerEnabled )
else if ( field == &m_inputTwoAzimuthPointsFromViewerEnabled )
{
setPushButtonText( inputTwoAzimuthPointsFromViewerEnabled,
setPushButtonText( m_inputTwoAzimuthPointsFromViewerEnabled,
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) );
}
else if ( field == &m_twoAzimuthPoints )
{
setBaseColor( inputTwoAzimuthPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
setBaseColor( m_inputTwoAzimuthPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
}
else if ( field == &inputExtrusionPointsFromViewerEnabled )
else if ( field == &m_inputExtrusionPointsFromViewerEnabled )
{
setPushButtonText( inputExtrusionPointsFromViewerEnabled,
setPushButtonText( m_inputExtrusionPointsFromViewerEnabled,
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) );
}
else if ( field == &m_customExtrusionPoints )
{
setBaseColor( inputExtrusionPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
setBaseColor( m_inputExtrusionPointsFromViewerEnabled, dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute ) );
}
}
@ -768,7 +887,7 @@ void RimExtrudedCurveIntersection::appendPointToPolyLine( const cvf::Vec3d& poin
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim2dIntersectionView* RimExtrudedCurveIntersection::correspondingIntersectionView()
Rim2dIntersectionView* RimExtrudedCurveIntersection::correspondingIntersectionView() const
{
std::vector<Rim2dIntersectionView*> objects;
this->objectsWithReferringPtrFieldsOfType( objects );
@ -831,10 +950,10 @@ cvf::Vec3d RimExtrudedCurveIntersection::extrusionDirection() const
{
cvf::Vec3d dir = cvf::Vec3d::Z_AXIS;
if ( direction() == RimExtrudedCurveIntersection::CS_HORIZONTAL )
if ( m_direction() == RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_HORIZONTAL )
{
std::vector<std::vector<cvf::Vec3d>> lines = this->polyLines();
if ( lines.size() > 0 && lines[0].size() > 1 )
if ( !lines.empty() && lines[0].size() > 1 )
{
std::vector<cvf::Vec3d> firstLine = lines[0];
@ -846,7 +965,8 @@ cvf::Vec3d RimExtrudedCurveIntersection::extrusionDirection() const
dir = polyLineDir ^ up;
}
}
else if ( direction() == RimExtrudedCurveIntersection::CS_TWO_POINTS && m_customExtrusionPoints().size() > 1 )
else if ( m_direction() == RimExtrudedCurveIntersection::CrossSectionDirEnum::CS_TWO_POINTS &&
m_customExtrusionPoints().size() > 1 )
{
dir = m_customExtrusionPoints()[m_customExtrusionPoints().size() - 1] - m_customExtrusionPoints()[0];
}
@ -902,7 +1022,7 @@ double RimExtrudedCurveIntersection::extentLength()
//--------------------------------------------------------------------------------------------------
void RimExtrudedCurveIntersection::recomputeSimulationWellBranchData()
{
if ( type() == CS_SIMULATION_WELL )
if ( m_type() == CrossSectionEnum::CS_SIMULATION_WELL )
{
m_simulationWellBranchCenterlines.clear();
updateSimulationWellCenterline();
@ -916,7 +1036,15 @@ void RimExtrudedCurveIntersection::recomputeSimulationWellBranchData()
//--------------------------------------------------------------------------------------------------
bool RimExtrudedCurveIntersection::hasDefiningPoints() const
{
return type == CS_POLYLINE || type == CS_AZIMUTHLINE;
return m_type() == CrossSectionEnum::CS_POLYLINE || m_type() == CrossSectionEnum::CS_AZIMUTHLINE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSurface*> RimExtrudedCurveIntersection::annotatedSurfaces() const
{
return m_annotationSurfaces.ptrReferencedObjects();
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,15 +19,9 @@
#pragma once
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "RimIntersection.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cafPdmPtrArrayField.h"
class RimWellPath;
class RivExtrudedCurveIntersectionPartMgr;
@ -35,6 +29,7 @@ class RimIntersectionResultDefinition;
class RimSimWellInView;
class RimSimWellInViewCollection;
class Rim2dIntersectionView;
class RimSurface;
namespace caf
{
@ -52,7 +47,7 @@ class RimExtrudedCurveIntersection : public RimIntersection
CAF_PDM_HEADER_INIT;
public:
enum CrossSectionEnum
enum class CrossSectionEnum
{
CS_WELL_PATH,
CS_SIMULATION_WELL,
@ -60,7 +55,7 @@ public:
CS_AZIMUTHLINE
};
enum CrossSectionDirEnum
enum class CrossSectionDirEnum
{
CS_VERTICAL,
CS_HORIZONTAL,
@ -71,23 +66,27 @@ public:
RimExtrudedCurveIntersection();
~RimExtrudedCurveIntersection() override;
caf::PdmField<caf::AppEnum<CrossSectionEnum>> type;
caf::PdmField<caf::AppEnum<CrossSectionDirEnum>> direction;
caf::PdmPtrField<RimWellPath*> wellPath;
caf::PdmPtrField<RimSimWellInView*> simulationWell;
caf::PdmField<bool> inputPolyLineFromViewerEnabled;
caf::PdmField<bool> inputExtrusionPointsFromViewerEnabled;
caf::PdmField<bool> inputTwoAzimuthPointsFromViewerEnabled;
QString name() const override;
void setName( const QString& newName );
RimExtrudedCurveIntersection::CrossSectionEnum type() const;
RimExtrudedCurveIntersection::CrossSectionDirEnum direction() const;
RimWellPath* wellPath() const;
RimSimWellInView* simulationWell() const;
bool inputPolyLineFromViewerEnabled() const;
bool inputExtrusionPointsFromViewerEnabled() const;
bool inputTwoAzimuthPointsFromViewerEnabled() const;
void configureForSimulationWell( RimSimWellInView* simWell );
void configureForWellPath( RimWellPath* wellPath );
void configureForPolyLine();
void configureForAzimuthLine();
std::vector<std::vector<cvf::Vec3d>> polyLines( cvf::Vec3d* flattenedPolylineStartPoint = nullptr ) const;
void appendPointToPolyLine( const cvf::Vec3d& point );
Rim2dIntersectionView* correspondingIntersectionView();
Rim2dIntersectionView* correspondingIntersectionView() const;
RivExtrudedCurveIntersectionPartMgr* intersectionPartMgr();
void rebuildGeometry();
const RivIntersectionGeometryGeneratorIF* intersectionGeometryGenerator() const override;
@ -106,6 +105,8 @@ public:
void recomputeSimulationWellBranchData();
bool hasDefiningPoints() const;
std::vector<RimSurface*> annotatedSurfaces() const;
int branchIndex() const;
void rebuildGeometryAndScheduleCreateDisplayModel();
@ -119,9 +120,30 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute );
static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute );
RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine();
void updateSimulationWellCenterline() const;
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName();
static double azimuthInRadians( cvf::Vec3d vec );
private:
caf::PdmField<QString> m_name;
caf::PdmField<caf::AppEnum<CrossSectionEnum>> m_type;
caf::PdmField<caf::AppEnum<CrossSectionDirEnum>> m_direction;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimSimWellInView*> m_simulationWell;
caf::PdmField<bool> m_inputPolylineFromViewerEnabled;
caf::PdmField<bool> m_inputExtrusionPointsFromViewerEnabled;
caf::PdmField<bool> m_inputTwoAzimuthPointsFromViewerEnabled;
caf::PdmField<int> m_branchIndex;
caf::PdmField<double> m_extentLength;
caf::PdmField<double> m_azimuthAngle;
@ -133,17 +155,9 @@ private:
caf::PdmField<std::vector<cvf::Vec3d>> m_customExtrusionPoints;
caf::PdmField<std::vector<cvf::Vec3d>> m_twoAzimuthPoints;
static void setPushButtonText( bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute );
static void setBaseColor( bool enable, caf::PdmUiListEditorAttribute* attribute );
// Surface intersection annotations
caf::PdmPtrArrayField<RimSurface*> m_annotationSurfaces;
RimSimWellInViewCollection* simulationWellCollection() const;
void updateAzimuthLine();
void updateSimulationWellCenterline() const;
void addExtents( std::vector<cvf::Vec3d>& polyLine ) const;
void updateName();
static double azimuthInRadians( cvf::Vec3d vec );
private:
cvf::ref<RivExtrudedCurveIntersectionPartMgr> m_crossSectionPartMgr;
mutable std::vector<std::vector<cvf::Vec3d>> m_simulationWellBranchCenterlines;

View File

@ -170,7 +170,7 @@ void RimIntersection::updateDefaultSeparateDataSource()
{
std::vector<RimIntersectionResultDefinition*> iResDefs = defcoll->intersectionResultsDefinitions();
if ( iResDefs.size() )
if ( !iResDefs.empty() )
{
m_separateDataSource = iResDefs[0];
}
@ -188,7 +188,7 @@ cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterfac
{
// Eclipse case
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( resDef->activeCase() );
auto* eclipseCase = dynamic_cast<RimEclipseCase*>( resDef->activeCase() );
if ( eclipseCase && eclipseCase->eclipseCaseData() )
{
return new RivEclipseIntersectionGrid( eclipseCase->eclipseCaseData()->mainGrid(),
@ -199,7 +199,7 @@ cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterfac
// Geomech case
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( resDef->activeCase() );
auto* geomCase = dynamic_cast<RimGeoMechCase*>( resDef->activeCase() );
if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() )
{

View File

@ -364,7 +364,7 @@ bool RimIntersectionCollection::hasActiveIntersectionForSimulationWell( const Ri
for ( RimExtrudedCurveIntersection* cs : m_intersections )
{
if ( cs->isActive() && cs->type() == RimExtrudedCurveIntersection::CS_SIMULATION_WELL &&
if ( cs->isActive() && cs->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_SIMULATION_WELL &&
cs->simulationWell() == simWell )
{
return true;

View File

@ -15,21 +15,22 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigSurface.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigSurface::RigSurface()
{
}
#include "cafAssert.h"
#include "cvfBoundingBox.h"
#include "cvfBoundingBoxTree.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigSurface::~RigSurface()
{
}
RigSurface::RigSurface() = default;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigSurface::~RigSurface() = default;
//--------------------------------------------------------------------------------------------------
///
@ -92,3 +93,50 @@ std::vector<QString> RigSurface::propertyNames() const
return names;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigSurface::findIntersectingTriangles( const cvf::BoundingBox& inputBB, std::vector<size_t>* triangleStartIndices ) const
{
CAF_ASSERT( m_surfaceBoundingBoxTree.notNull() );
m_surfaceBoundingBoxTree->findIntersections( inputBB, triangleStartIndices );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigSurface::ensureIntersectionSearchTreeIsBuilt()
{
if ( m_surfaceBoundingBoxTree.isNull() )
{
size_t itemCount = triangleCount();
std::vector<cvf::BoundingBox> cellBoundingBoxes;
std::vector<size_t> boundingBoxIds;
cellBoundingBoxes.resize( itemCount );
boundingBoxIds.resize( itemCount );
for ( size_t triangleIdx = 0; triangleIdx < itemCount; ++triangleIdx )
{
cvf::BoundingBox& cellBB = cellBoundingBoxes[triangleIdx];
cellBB.add( m_vertices[m_triangleIndices[triangleIdx * 3 + 0]] );
cellBB.add( m_vertices[m_triangleIndices[triangleIdx * 3 + 1]] );
cellBB.add( m_vertices[m_triangleIndices[triangleIdx * 3 + 2]] );
boundingBoxIds[triangleIdx] = triangleIdx * 3;
}
m_surfaceBoundingBoxTree = new cvf::BoundingBoxTree;
m_surfaceBoundingBoxTree->buildTreeFromBoundingBoxes( cellBoundingBoxes, &boundingBoxIds );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigSurface::triangleCount() const
{
return m_triangleIndices.size() / 3;
}

View File

@ -25,6 +25,12 @@
#include <map>
#include <vector>
namespace cvf
{
class BoundingBox;
class BoundingBoxTree;
} // namespace cvf
class RigSurface : public cvf::Object
{
public:
@ -40,8 +46,16 @@ public:
std::vector<float> propertyValues( const QString& propertyName ) const;
std::vector<QString> propertyNames() const;
void ensureIntersectionSearchTreeIsBuilt();
void findIntersectingTriangles( const cvf::BoundingBox& inputBB, std::vector<size_t>* triangleStartIndices ) const;
private:
size_t triangleCount() const;
private:
std::vector<unsigned> m_triangleIndices;
std::vector<cvf::Vec3d> m_vertices;
std::map<QString, std::vector<float>> m_verticeResults;
cvf::ref<cvf::BoundingBoxTree> m_surfaceBoundingBoxTree;
};

View File

@ -15,11 +15,14 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigSurfaceResampler.h"
#include "cvfGeometryTools.h"
#include "cvfBoundingBox.h"
#include "cvfObject.h"
#include <limits>
//--------------------------------------------------------------------------------------------------
@ -40,8 +43,7 @@ cvf::ref<RigSurface> RigSurfaceResampler::resampleSurface( cvf::ref<RigSurface>
cvf::Vec3d pointBelow = cvf::Vec3d( targetVert.x(), targetVert.y(), -10000.0 );
cvf::Vec3d intersectionPoint;
bool foundMatch =
resamplePoint( pointAbove, pointBelow, surface->triangleIndices(), surface->vertices(), intersectionPoint );
bool foundMatch = resamplePoint( surface.p(), pointAbove, pointBelow, intersectionPoint );
if ( !foundMatch )
intersectionPoint = cvf::Vec3d( targetVert.x(), targetVert.y(), std::numeric_limits<double>::infinity() );
@ -56,23 +58,37 @@ cvf::ref<RigSurface> RigSurfaceResampler::resampleSurface( cvf::ref<RigSurface>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigSurfaceResampler::resamplePoint( const cvf::Vec3d& pointAbove,
const cvf::Vec3d& pointBelow,
const std::vector<unsigned int>& indices,
const std::vector<cvf::Vec3d>& vertices,
cvf::Vec3d& intersectionPoint )
bool RigSurfaceResampler::resamplePoint( RigSurface* surface,
const cvf::Vec3d& pointAbove,
const cvf::Vec3d& pointBelow,
cvf::Vec3d& intersectionPoint )
{
for ( size_t i = 0; i < indices.size(); i += 3 )
surface->ensureIntersectionSearchTreeIsBuilt();
cvf::BoundingBox bb;
bb.add( pointAbove );
bb.add( pointBelow );
std::vector<size_t> triangleStartIndices;
surface->findIntersectingTriangles( bb, &triangleStartIndices );
const std::vector<unsigned int>& indices = surface->triangleIndices();
const std::vector<cvf::Vec3d>& vertices = surface->vertices();
if ( !triangleStartIndices.empty() )
{
bool isLineDirDotNormalNegative = false;
if ( cvf::GeometryTools::intersectLineSegmentTriangle( pointAbove,
pointBelow,
vertices[indices[i]],
vertices[indices[i + 1]],
vertices[indices[i + 2]],
&intersectionPoint,
&isLineDirDotNormalNegative ) == 1 )
return true;
for ( auto triangleStartIndex : triangleStartIndices )
{
bool isLineDirDotNormalNegative = false;
if ( cvf::GeometryTools::intersectLineSegmentTriangle( pointAbove,
pointBelow,
vertices[indices[triangleStartIndex + 0]],
vertices[indices[triangleStartIndex + 1]],
vertices[indices[triangleStartIndex + 2]],
&intersectionPoint,
&isLineDirDotNormalNegative ) == 1 )
return true;
}
}
// Handle cases where no match is found due to floating point imprecision,

View File

@ -29,11 +29,10 @@ class RigSurfaceResampler
public:
static cvf::ref<RigSurface> resampleSurface( cvf::ref<RigSurface> targetSurface, cvf::ref<RigSurface> surface );
static bool resamplePoint( const cvf::Vec3d& pointAbove,
const cvf::Vec3d& pointBelow,
const std::vector<unsigned int>& indices,
const std::vector<cvf::Vec3d>& vertices,
cvf::Vec3d& intersectionPoint );
static bool resamplePoint( RigSurface* surface,
const cvf::Vec3d& pointAbove,
const cvf::Vec3d& pointBelow,
cvf::Vec3d& intersectionPoint );
private:
static bool findClosestPointXY( const cvf::Vec3d& targetPoint,

View File

@ -17,25 +17,18 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuPvtPlotUpdater.h"
#include "Riu3dSelectionManager.h"
#include "RiuPvtPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "Rim2dIntersectionView.h"
#include "Rim3dView.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimEclipseResultDefinition.h"
//#include "cvfTrace.h"
#include "Riu3dSelectionManager.h"
#include "RiuPvtPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include <cmath>

View File

@ -731,6 +731,9 @@ void OverlayScaleLegend::updateFromCamera( const Camera* camera )
windowMaxInDomain = m_dispalyCoordsTransform->transformToDomainCoord( windowMaxInDomain );
}
// For extreme zoom factors we might end up with both variables as zero. Return to avoid divide by zero.
if ( windowMaxInDomain == windowOrigoInDomain ) return;
Vec3d windowOrigoPoint;
Vec3d windowMaxPoint;
camera->project( windowOrigoInDomain, &windowOrigoPoint );