3D Well Log Curves(#2676): Enable pick selection of the 3D Tracks and curves

This commit is contained in:
Gaute Lindkvist 2018-04-20 16:08:17 +02:00
parent e2d5dd0381
commit 803b6b8179
12 changed files with 348 additions and 129 deletions

View File

@ -27,6 +27,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h ${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h
${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.h
) )
set (SOURCE_GROUP_SOURCE_FILES set (SOURCE_GROUP_SOURCE_FILES
@ -57,6 +58,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Ric3dWellLogCurveViewerEventHandler.h"
#include "Rim3dWellLogCurve.h"
#include "Rim3dWellLogCurveCollection.h"
#include "RiuMainWindow.h"
#include "RivObjectSourceInfo.h"
#include "cvfPart.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Ric3dWellLogCurveViewerEventHandler* Ric3dWellLogCurveViewerEventHandler::instance()
{
static Ric3dWellLogCurveViewerEventHandler* singleton = new Ric3dWellLogCurveViewerEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject)
{
if (eventObject.m_partAndTriangleIndexPairs.empty()) return false;
cvf::uint triangleIndex = cvf::UNDEFINED_UINT;
const auto& partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
const cvf::Part* part = partAndTriangleIndexPair.first;
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
if (sourceInfo)
{
Rim3dWellLogCurveCollection* curveCollection = dynamic_cast<Rim3dWellLogCurveCollection*>(sourceInfo->object());
if (curveCollection)
{
cvf::Vec3d closestPoint;
double measuredDepthAtPoint;
double valueAtPoint;
Rim3dWellLogCurve* curve = curveCollection->checkForCurveIntersection(
eventObject.m_globalIntersectionPoint, &closestPoint, &measuredDepthAtPoint, &valueAtPoint);
if (curve)
{
RiuMainWindow::instance()->selectAsCurrentItem(curve);
}
else
{
RiuMainWindow::instance()->selectAsCurrentItem(curveCollection);
}
return true;
}
}
return false;
}

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicViewerEventInterface.h"
//==================================================================================================
///
//==================================================================================================
class Ric3dWellLogCurveViewerEventHandler : public RicViewerEventInterface
{
public:
static Ric3dWellLogCurveViewerEventHandler* instance();
bool handleEvent(const RicViewerEventObject& eventObject) override;
};

View File

@ -29,6 +29,7 @@
#include "cvfPrimitiveSetIndexedUInt.h" #include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfBoundingBox.h" #include "cvfBoundingBox.h"
#include "cvfMath.h"
#include <cmath> #include <cmath>
@ -37,72 +38,25 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath) Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath)
: m_wellPath(wellPath) : m_wellPath(wellPath)
, m_planeWidth(0.0)
{ {
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform,
Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const cvf::BoundingBox& wellPathClipBoundingBox,
const cvf::BoundingBox& wellPathClipBoundingBox, const std::vector<double>& resultValues,
const std::vector<double>& resultValues, const std::vector<double>& resultMds,
const std::vector<double>& resultMds, double minResultValue,
double minResultValue, double maxResultValue,
double maxResultValue, double planeAngle,
double planeAngle, double planeOffsetFromWellPathCenter,
double planeOffsetFromWellPathCenter, double planeWidth)
double planeWidth) const
{ {
std::vector<cvf::Vec3f> vertices; m_planeWidth = planeWidth;
std::vector<cvf::uint> indices;
createCurveVerticesAndIndices(resultValues,
resultMds,
minResultValue,
maxResultValue,
planeAngle,
planeOffsetFromWellPathCenter,
planeWidth,
displayCoordTransform,
wellPathClipBoundingBox,
&vertices,
&indices);
if (vertices.empty() || indices.empty())
{
return nullptr;
}
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
indexedUInt->setIndices(indexArray.p());
drawable->addPrimitiveSet(indexedUInt.p());
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(vertices);
drawable->setVertexArray(vertexArray.p());
return drawable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector<double>& resultValues,
const std::vector<double>& resultMds,
double minResultValue,
double maxResultValue,
double planeAngle,
double planeOffsetFromWellPathCenter,
double planeWidth,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const
{
if (!wellPathGeometry()) return; if (!wellPathGeometry()) return;
if (wellPathGeometry()->m_wellPathPoints.empty()) return; if (wellPathGeometry()->m_wellPathPoints.empty()) return;
if (!wellPathClipBoundingBox.isValid()) return; if (!wellPathClipBoundingBox.isValid()) return;
@ -153,13 +107,15 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std
std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end()); std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end());
// The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size
std::vector<double> resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(), m_curveValues = std::vector<double>(resultValues.end() - interpolatedWellPathPoints.size(),
resultValues.end()); resultValues.end());
m_curveMeasuredDepths = std::vector<double>(resultMds.end() - interpolatedWellPathPoints.size(),
resultMds.end());
double maxClampedResult = -HUGE_VAL; double maxClampedResult = -HUGE_VAL;
double minClampedResult = HUGE_VAL; double minClampedResult = HUGE_VAL;
for (double& result : resultValuesForInterpolatedPoints) for (double& result : m_curveValues)
{ {
if (!RigCurveDataTools::isValidValue(result, false)) continue; if (!RigCurveDataTools::isValidValue(result, false)) continue;
@ -174,34 +130,54 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std
return; return;
} }
vertices->resize(interpolatedWellPathPoints.size()); m_curveVertices = std::vector<cvf::Vec3f>();
m_curveVertices.reserve(interpolatedWellPathPoints.size());
double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult); double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult);
for (size_t i = 0; i < interpolatedCurveNormals.size(); i++) for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++)
{ {
double scaledResult = 0; double scaledResult = 0;
if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false)) if (RigCurveDataTools::isValidValue(m_curveValues[i], false))
{ {
scaledResult = scaledResult =
planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minClampedResult) * plotRangeToResultRangeFactor; planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor;
} }
cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]);
(*vertices)[i] = cvf::Vec3f(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); m_curveVertices.push_back(cvf::Vec3f(curvePoint));
} }
std::vector<std::pair<size_t, size_t>> valuesIntervals = std::vector<cvf::uint> indices;
RigCurveDataTools::calculateIntervalsOfValidValues(resultValuesForInterpolatedPoints, false); indices.reserve(interpolatedWellPathPoints.size());
for (size_t i = 0; i < m_curveValues.size() - 1; ++i)
for (const std::pair<size_t, size_t>& interval : valuesIntervals)
{ {
for (size_t i = interval.first; i < interval.second; i++) if (RigCurveDataTools::isValidValue(m_curveValues[i], false) &&
RigCurveDataTools::isValidValue(m_curveValues[i + 1], false))
{ {
indices->push_back(cvf::uint(i)); indices.push_back(cvf::uint(i));
indices->push_back(cvf::uint(i + 1)); indices.push_back(cvf::uint(i + 1));
} }
} }
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
m_curveDrawable = new cvf::DrawableGeo();
indexedUInt->setIndices(indexArray.p());
m_curveDrawable->addPrimitiveSet(indexedUInt.p());
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(m_curveVertices);
m_curveDrawable->setVertexArray(vertexArray.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::curveDrawable()
{
return m_curveDrawable;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -211,3 +187,49 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const
{ {
return m_wellPath->wellPathGeometry(); return m_wellPath->wellPathGeometry();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtClosestPoint) const
{
cvf::Vec3f globalIntersectionFloat(globalIntersection);
float closestDistance = m_planeWidth * 0.1;
*closestPoint = cvf::Vec3d::UNDEFINED;
*measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE;
*valueAtClosestPoint = cvf::UNDEFINED_DOUBLE;
if (m_curveVertices.size() < 2u) false;
CVF_ASSERT(m_curveVertices.size() == m_curveValues.size());
for (size_t i = 1; i < m_curveVertices.size(); ++i)
{
bool validCurveSegment = RigCurveDataTools::isValidValue(m_curveValues[i], false) &&
RigCurveDataTools::isValidValue(m_curveValues[i - 1], false);
if (validCurveSegment)
{
cvf::Vec3f a = m_curveVertices[i - 1];
cvf::Vec3f b = m_curveVertices[i];
cvf::Vec3f ap = globalIntersectionFloat - a;
cvf::Vec3f ab = b - a;
// Projected point is clamped to one of the end points of the segment.
float distanceToProjectedPointAlongAB = ap * ab / (ab * ab);
float clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0f, 1.0f);
cvf::Vec3f projectionOfGlobalIntersection = a + clampedDistance * ab;
float distance = (projectionOfGlobalIntersection - globalIntersectionFloat).length();
if (distance < closestDistance)
{
*closestPoint = cvf::Vec3d(projectionOfGlobalIntersection);
closestDistance = distance;
*measuredDepthAtPoint = m_curveMeasuredDepths[i - 1] * (1.0f - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance;
*valueAtClosestPoint = m_curveValues[i - 1] * (1.0f - clampedDistance) + m_curveValues[i] * clampedDistance;
}
}
}
if (closestPoint->isUndefined())
return false;
return true;
}

View File

@ -43,32 +43,33 @@ class RimWellPath;
class Riv3dWellLogCurveGeometryGenerator : public cvf::Object class Riv3dWellLogCurveGeometryGenerator : public cvf::Object
{ {
public: public:
typedef std::pair<cvf::Vec3d, double> PointValuePair;
Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath); Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath);
cvf::ref<cvf::DrawableGeo> createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, void createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox, const cvf::BoundingBox& wellPathClipBoundingBox,
const std::vector<double>& resultValues, const std::vector<double>& resultValues,
const std::vector<double>& resultMds, const std::vector<double>& resultMds,
double planeAngle, double planeAngle,
double planeOffsetFromWellPathCenter, double planeOffsetFromWellPathCenter,
double planeWidth, double planeWidth,
double minResultValue, double minResultValue,
double maxResultValue) const; double maxResultValue);
private:
void createCurveVerticesAndIndices(const std::vector<double>& resultValues,
const std::vector<double>& resultMds,
double minResultValue,
double maxResultValue,
double planeAngle,
double planeOffsetFromWellPathCenter,
double planeWidth,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const;
const RigWellPath* wellPathGeometry() const; const RigWellPath* wellPathGeometry() const;
cvf::ref<cvf::DrawableGeo> curveDrawable();
bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtClosestPoint) const;
private: private:
caf::PdmPointer<RimWellPath> m_wellPath; caf::PdmPointer<RimWellPath> m_wellPath;
cvf::ref<cvf::DrawableGeo> m_curveDrawable;
std::vector<cvf::Vec3f> m_curveVertices;
std::vector<double> m_curveMeasuredDepths;
std::vector<double> m_curveValues;
double m_planeWidth;
}; };

View File

@ -29,6 +29,7 @@
#include "Riv3dWellLogCurveGeomertyGenerator.h" #include "Riv3dWellLogCurveGeomertyGenerator.h"
#include "Riv3dWellLogGridGeomertyGenerator.h" #include "Riv3dWellLogGridGeomertyGenerator.h"
#include "RivObjectSourceInfo.h"
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
@ -51,7 +52,6 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri
, m_gridView(gridView) , m_gridView(gridView)
{ {
CVF_ASSERT(m_wellPath.notNull()); CVF_ASSERT(m_wellPath.notNull());
m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p());
m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p()); m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p());
} }
@ -89,29 +89,34 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
if (!m_wellPath->rim3dWellLogCurveCollection()) return; if (!m_wellPath->rim3dWellLogCurveCollection()) return;
if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return;
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
size_t colorIndex = 0;
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
{ {
colorIndex++; cvf::ref<Riv3dWellLogCurveGeometryGenerator> generator = rim3dWellLogCurve->geometryGenerator();
if (generator.isNull())
{
generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p());
rim3dWellLogCurve->setGeometryGenerator(generator.p());
}
if (!rim3dWellLogCurve->isShowingCurve()) continue; if (!rim3dWellLogCurve->isShowingCurve()) continue;
std::vector<double> resultValues; std::vector<double> resultValues;
std::vector<double> resultMds; std::vector<double> resultMds;
rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds);
cvf::ref<cvf::Drawable> curveDrawable = generator->createCurveDrawables(displayCoordTransform,
m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, wellPathClipBoundingBox,
wellPathClipBoundingBox, resultValues,
resultValues, resultMds,
resultMds, rim3dWellLogCurve->minCurveValue(),
rim3dWellLogCurve->minCurveValue(), rim3dWellLogCurve->maxCurveValue(),
rim3dWellLogCurve->maxCurveValue(), planeAngle(curveCollection, rim3dWellLogCurve),
planeAngle(curveCollection, rim3dWellLogCurve), wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve),
wellPathCenterToPlotStartOffset(curveCollection, rim3dWellLogCurve), planeWidth());
planeWidth());
cvf::ref<cvf::DrawableGeo> curveDrawable = generator->curveDrawable();
if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid())
{ {
@ -226,9 +231,9 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
const Rim3dWellLogCurve* rim3dWellLogCurve, const Rim3dWellLogCurve* rim3dWellLogCurve,
double gridIntervalSize) double gridIntervalSize)
{ {
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
bool showGrid = curveCollection->isShowingGrid(); bool showGrid = curveCollection->isShowingGrid();
bool showBackground = curveCollection->isShowingBackground(); bool showBackground = curveCollection->isShowingBackground();
cvf::Color3f gridColor(0.4f, 0.4f, 0.4f); cvf::Color3f gridColor(0.4f, 0.4f, 0.4f);
caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2);
@ -249,12 +254,14 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect();
cvf::ref<cvf::DrawableGeo> background = m_3dWellLogGridGeometryGenerator->background(); cvf::ref<cvf::DrawableGeo> background = m_3dWellLogGridGeometryGenerator->background();
cvf::ref<RivObjectSourceInfo> sourceInfo = new RivObjectSourceInfo(curveCollection);
if (showBackground && background.notNull()) if (showBackground && background.notNull())
{ {
cvf::ref<cvf::Part> part = createPart(background.p(), backgroundEffect.p()); cvf::ref<cvf::Part> part = createPart(background.p(), backgroundEffect.p());
if (part.notNull()) if (part.notNull())
{ {
model->addPart(part.p()); model->addPart(part.p());
part->setSourceInfo(sourceInfo.p());
} }
} }
@ -282,6 +289,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
if (part.notNull()) if (part.notNull())
{ {
model->addPart(part.p()); model->addPart(part.p());
part->setSourceInfo(sourceInfo.p());
} }
} }
} }

View File

@ -20,13 +20,13 @@
#include "cvfBase.h" #include "cvfBase.h"
#include "cvfObject.h" #include "cvfObject.h"
#include "cvfVector3.h"
#include "Rim3dWellLogCurve.h" #include "Rim3dWellLogCurve.h"
#include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogCurveCollection.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include <vector>
namespace cvf namespace cvf
{ {
@ -45,7 +45,6 @@ class DisplayCoordTransform;
class RimGridView; class RimGridView;
class RimWellPath; class RimWellPath;
class Riv3dWellLogCurveGeometryGenerator;
class Riv3dWellLogGridGeometryGenerator; class Riv3dWellLogGridGeometryGenerator;
class Riv3dWellLogPlanePartMgr : public cvf::Object class Riv3dWellLogPlanePartMgr : public cvf::Object
@ -74,9 +73,8 @@ private:
double planeWidth() const; double planeWidth() const;
private: private:
cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_3dWellLogCurveGeometryGenerator; cvf::ref<Riv3dWellLogGridGeometryGenerator> m_3dWellLogGridGeometryGenerator;
cvf::ref<Riv3dWellLogGridGeometryGenerator> m_3dWellLogGridGeometryGenerator;
caf::PdmPointer<RimWellPath> m_wellPath;
caf::PdmPointer<RimWellPath> m_wellPath; caf::PdmPointer<RimGridView> m_gridView;
caf::PdmPointer<RimGridView> m_gridView;
}; };

View File

@ -24,6 +24,7 @@
#include "RimProject.h" #include "RimProject.h"
#include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiDoubleSliderEditor.h"
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection");
@ -176,6 +177,36 @@ void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dWellLogCurve* Rim3dWellLogCurveCollection::checkForCurveIntersection(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtPoint)
{
double smallestDistance = std::numeric_limits<double>::max();
Rim3dWellLogCurve* closestCurve = nullptr;
for (auto& wellLogCurve : m_3dWellLogCurves)
{
cvf::Vec3d closestPointOnCurve;
double measuredDepthAtPointOnCurve;
double valueAtPointOnCurve;
if (wellLogCurve->findClosestPointOnCurve(globalIntersection, &closestPointOnCurve, &measuredDepthAtPointOnCurve, &valueAtPointOnCurve))
{
double distance = globalIntersection.pointDistance(closestPointOnCurve);
if (distance < smallestDistance)
{
closestCurve = wellLogCurve.p();
*closestPoint = closestPointOnCurve;
*measuredDepthAtPoint = measuredDepthAtPointOnCurve;
*valueAtPoint = valueAtPointOnCurve;
}
}
}
return closestCurve;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,9 @@
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cvfBase.h"
#include "cvfVector3.h"
class Rim3dWellLogCurve; class Rim3dWellLogCurve;
//================================================================================================== //==================================================================================================
@ -58,6 +61,10 @@ public:
std::vector<Rim3dWellLogCurve*> vectorOf3dWellLogCurves() const; std::vector<Rim3dWellLogCurve*> vectorOf3dWellLogCurves() const;
void redrawAffectedViewsAndEditors(); void redrawAffectedViewsAndEditors();
Rim3dWellLogCurve* checkForCurveIntersection(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtPoint);
private: private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;

View File

@ -19,12 +19,15 @@
#include "Rim3dWellLogCurve.h" #include "Rim3dWellLogCurve.h"
#include "RigCurveDataTools.h" #include "RigCurveDataTools.h"
#include "Riv3dWellLogCurveGeomertyGenerator.h"
#include "Rim3dWellLogCurveCollection.h" #include "Rim3dWellLogCurveCollection.h"
#include "RimProject.h" #include "RimProject.h"
#include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiDoubleSliderEditor.h"
#include "cvfVector3.h"
#include <algorithm> #include <algorithm>
#include <cmath> // Needed for HUGE_VAL on Linux #include <cmath> // Needed for HUGE_VAL on Linux
@ -244,6 +247,28 @@ void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI()
this->updateConnectedEditors(); this->updateConnectedEditors();
} }
void Rim3dWellLogCurve::setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator)
{
m_geometryGenerator = generator;
}
bool Rim3dWellLogCurve::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtPoint) const
{
if (m_geometryGenerator.notNull())
{
return m_geometryGenerator->findClosestPointOnCurve(globalIntersection, closestPoint, measuredDepthAtPoint, valueAtPoint);
}
return false;
}
cvf::ref<Riv3dWellLogCurveGeometryGenerator> Rim3dWellLogCurve::geometryGenerator()
{
return m_geometryGenerator;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -24,6 +24,11 @@
#include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfColor.h"
#include "cvfObject.h"
#include "cvfVector3.h"
class Riv3dWellLogCurveGeometryGenerator;
//================================================================================================== //==================================================================================================
/// ///
/// ///
@ -47,17 +52,26 @@ public:
void updateCurveIn3dView(); void updateCurveIn3dView();
DrawPlane drawPlane() const; DrawPlane drawPlane() const;
cvf::Color3f color() const; cvf::Color3f color() const;
bool isShowingCurve() const; bool isShowingCurve() const;
virtual void curveValuesAndMds(std::vector<double>* values, std::vector<double>* measuredDepthValues) const = 0; virtual void curveValuesAndMds(std::vector<double>* values, std::vector<double>* measuredDepthValues) const = 0;
void setColor(const cvf::Color3f& color); void setColor(const cvf::Color3f& color);
double minCurveValue() const; double minCurveValue() const;
double maxCurveValue() const; double maxCurveValue() const;
void resetMinMaxValuesAndUpdateUI(); void resetMinMaxValuesAndUpdateUI();
bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection,
cvf::Vec3d* closestPoint,
double* measuredDepthAtPoint,
double* valueAtPoint) const;
void setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator);
cvf::ref<Riv3dWellLogCurveGeometryGenerator> geometryGenerator();
protected: protected:
virtual caf::PdmFieldHandle* objectToggleField() override; virtual caf::PdmFieldHandle* objectToggleField() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
@ -75,7 +89,7 @@ protected:
caf::PdmField<double> m_maxCurveValue; caf::PdmField<double> m_maxCurveValue;
double m_minCurveDataValue; double m_minCurveDataValue;
double m_maxCurveDataValue; double m_maxCurveDataValue;
cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_geometryGenerator;
private: private:
caf::PdmField<bool> m_showCurve; caf::PdmField<bool> m_showCurve;

View File

@ -26,6 +26,7 @@
#include "RicEclipsePropertyFilterNewExec.h" #include "RicEclipsePropertyFilterNewExec.h"
#include "RicGeoMechPropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h"
#include "RicViewerEventInterface.h" #include "RicViewerEventInterface.h"
#include "WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h"
#include "WellPathCommands/RicIntersectionViewerEventHandler.h" #include "WellPathCommands/RicIntersectionViewerEventHandler.h"
#include "WellPathCommands/RicWellPathViewerEventHandler.h" #include "WellPathCommands/RicWellPathViewerEventHandler.h"
@ -121,6 +122,10 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(RicIntersectionViewerEventHandler::instance())); m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(RicIntersectionViewerEventHandler::instance()));
} }
{
m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(Ric3dWellLogCurveViewerEventHandler::instance()));
}
{ {
m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(RicWellPathViewerEventHandler::instance())); m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(RicWellPathViewerEventHandler::instance()));
} }