(#404) Added display of picked well path text in Result Info

This commit is contained in:
Magne Sjaastad 2015-12-04 12:05:43 +01:00
parent 622e49fe69
commit 27206cab3b
3 changed files with 112 additions and 21 deletions

View File

@ -19,18 +19,20 @@
#include "RivWellPathSourceInfo.h"
#include "RimCase.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RivPipeQuadToSegmentMapper.h"
#include "RivWellPathPartMgr.h"
#include "cvfGeometryTools.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath/*, RivPipeQuadToSegmentMapper* quadToSegmentMapper*/)
RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath)
{
m_wellPath = wellPath;
//m_quadToSegmentMapper = quadToSegmentMapper;
}
//--------------------------------------------------------------------------------------------------
@ -40,3 +42,67 @@ RimWellPath* RivWellPathSourceInfo::wellPath() const
{
return m_wellPath.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RivWellPathSourceInfo::measuredDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const
{
size_t firstSegmentIndex = cvf::UNDEFINED_SIZE_T;
double norm = 0.0;
normalizedIntersection(triangleIndex, globalIntersection, &firstSegmentIndex, &norm);
double firstDepth = m_wellPath->wellPathGeometry()->m_measuredDepths[firstSegmentIndex];
double secDepth = m_wellPath->wellPathGeometry()->m_measuredDepths[firstSegmentIndex + 1];
return firstDepth * (1.0 - norm) + norm * secDepth;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivWellPathSourceInfo::trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const
{
size_t firstSegmentIndex = cvf::UNDEFINED_SIZE_T;
double norm = 0.0;
normalizedIntersection(triangleIndex, globalIntersection, &firstSegmentIndex, &norm);
cvf::Vec3d firstDepth = m_wellPath->wellPathGeometry()->m_wellPathPoints[firstSegmentIndex];
cvf::Vec3d secDepth = m_wellPath->wellPathGeometry()->m_wellPathPoints[firstSegmentIndex + 1];
return firstDepth * (1.0 - norm) + norm * secDepth;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const cvf::Vec3d& globalIntersection,
size_t* firstSegmentIndex, double* normalizedSegmentIntersection) const
{
size_t segIndex = segmentIndex(triangleIndex);
RigWellPath* rigWellPath = m_wellPath->wellPathGeometry();
cvf::Vec3d segmentStart = rigWellPath->m_wellPathPoints[segIndex];
cvf::Vec3d segmentEnd = rigWellPath->m_wellPathPoints[segIndex + 1];
double norm = 0.0;
cvf::Vec3d pointOnLine = cvf::GeometryTools::projectPointOnLine(segmentStart, segmentEnd, globalIntersection, &norm);
CVF_ASSERT(0.0 < norm && norm < 1.0);
cvf::Math::clamp(norm, 0.0, 1.0);
*firstSegmentIndex = segIndex;
*normalizedSegmentIntersection = norm;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const
{
return m_wellPath->partMgr()->segmentIndexFromTriangleIndex(triangleIndex);
}

View File

@ -19,25 +19,32 @@
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
class RimWellPath;
//class RivPipeQuadToSegmentMapper;
//==================================================================================================
///
/// TODO: Implement and add RivPipeQuadToSegmentMapper
//==================================================================================================
class RivWellPathSourceInfo : public cvf::Object
{
public:
RivWellPathSourceInfo(RimWellPath* wellPath/*, RivPipeQuadToSegmentMapper* quadToSegmentMapper*/);
RivWellPathSourceInfo(RimWellPath* wellPath);
RimWellPath* wellPath() const;
private:
caf::PdmPointer<RimWellPath> m_wellPath;
//RivPipeQuadToSegmentMapper* m_quadToSegmentMapper;
size_t segmentIndex(size_t triangleIndex) const;
double measuredDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const;
cvf::Vec3d trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const;
private:
void normalizedIntersection(size_t triangleIndex, const cvf::Vec3d& globalIntersection,
size_t* firstSegmentIndex, double* normalizedSegmentIntersection) const;
private:
caf::PdmPointer<RimWellPath> m_wellPath;
};

View File

@ -417,7 +417,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
RimWellPath* wellPath = NULL;
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
@ -473,7 +472,34 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
}
else if (wellPathSourceInfo)
{
wellPath = wellPathSourceInfo->wellPath();
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
RimCase* rimCase = NULL;
m_reservoirView->firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
displayModelOffset = rimCase->displayModelOffset();
}
cvf::Vec3d unscaledIntersection = localIntersectionPoint;
unscaledIntersection.z() /= m_reservoirView->scaleZ;
size_t wellSegmentIndex = wellPathSourceInfo->segmentIndex(firstPartTriangleIndex);
double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
QString wellPathText;
wellPathText += wellPathSourceInfo->wellPath()->name;
wellPathText += "\n";
wellPathText += QString("Well path segment index : %1\n").arg(wellSegmentIndex);
wellPathText += QString("Measured depth : %1\n").arg(measuredDepth);
QString formattedText;
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z());
wellPathText += formattedText;
RiuMainWindow::instance()->setResultInfo(wellPathText);
}
else if (crossSectionSourceInfo)
{
@ -536,14 +562,6 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
RiuSelectionManager::instance()->setSelectedItem(selItem);
}
}
if (wellPath)
{
QString pickInfo = QString("Well path hit: %1").arg(wellPath->name());
RiuMainWindow* mainWnd = RiuMainWindow::instance();
mainWnd->statusBar()->showMessage(pickInfo);
}
}
//--------------------------------------------------------------------------------------------------