diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index dc5a2430b6..54450f2614 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -800,8 +800,6 @@ void RivIntersectionPartMgr::appendWellPipePartsToModel(cvf::ModelBasicList* mod if (!wellPath) return; - RigWellPath* wellPathGeometry = wellPath->wellPathGeometry(); - RimGridView* gridView = nullptr; m_rimCrossSection->firstAncestorOrThisOfTypeAsserted(gridView); double cellSize = gridView->ownerCase()->characteristicCellSize(); diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index fd1500a409..961b8bb55f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -18,6 +18,10 @@ #include "Riv3dWellLogCurveGeomertyGenerator.h" +#include "RimCase.h" +#include "RimGridView.h" +#include "RimWellPath.h" + #include "RigCurveDataTools.h" #include "RigWellPath.h" @@ -66,9 +70,9 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const { CVF_ASSERT(gridIntervalSize > 0); - if (m_wellPathGeometry.isNull()) return nullptr; + if (!wellPathGeometry()) return nullptr; - std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; if (wellPathPoints.empty()) return nullptr; const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); @@ -77,14 +81,14 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector pointNormals; std::vector gridPoints; - double firstMd = m_wellPathGeometry->m_measuredDepths.front(); - double lastMd = m_wellPathGeometry->m_measuredDepths.back(); - if (m_wellPathGeometry->m_measuredDepths.empty()) return nullptr; + double firstMd = wellPathGeometry()->m_measuredDepths.front(); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; double md = firstMd; while (md <= lastMd) { - cvf::Vec3d point = m_wellPathGeometry->interpolatedPointAlongWellPath(md); + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); gridPoints.push_back(point); md += gridIntervalSize; } @@ -100,15 +104,41 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint counter = 0; + double offsetFromWellPathCenter = wellPathRadius()*1.2; + double gridWidth = 100; + + // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i]))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * 100))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter+gridWidth)))); indices.push_back(counter++); indices.push_back(counter++); } + std::vector wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane); + + // Line along and close to well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); + indices.push_back(counter); + indices.push_back(++counter); + } + indices.pop_back(); + indices.pop_back(); + + // Line along and far away from well + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth)))); + indices.push_back(counter); + indices.push_back(++counter); + } + indices.pop_back(); + indices.pop_back(); + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); cvf::ref indexArray = new cvf::UIntArray(indices); @@ -131,7 +161,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim std::vector* vertices, std::vector* indices) const { - if (m_wellPathGeometry.isNull()) return; + if (!wellPathGeometry()) return; std::vector resultValues; std::vector mds; @@ -141,14 +171,14 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim CVF_ASSERT(resultValues.size() == mds.size()); cvf::Vec3d globalDirection = - (m_wellPathGeometry->m_wellPathPoints.back() - m_wellPathGeometry->m_wellPathPoints.front()).getNormalized(); + (wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); std::vector interpolatedWellPathPoints; interpolatedWellPathPoints.reserve(mds.size()); for (double md : mds) { - interpolatedWellPathPoints.push_back(m_wellPathGeometry->interpolatedPointAlongWellPath(md)); + interpolatedWellPathPoints.push_back(wellPathGeometry()->interpolatedPointAlongWellPath(md)); } std::vector pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); @@ -168,8 +198,8 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim vertices->resize(interpolatedWellPathPoints.size()); double range = maxResult - minResult; - double factor = 60.0 / range; - double offset = 30.0; + double offset = wellPathRadius()*1.2; + double factor = 2 * offset / range; if (minResult < 0) { @@ -210,7 +240,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal { std::vector pointNormals; - if (m_wellPathGeometry.isNull()) return pointNormals; + if (!wellPathGeometry()) return pointNormals; pointNormals.reserve(points.size()); const cvf::Vec3d globalDirection = (points.back() - points.front()).getNormalized(); @@ -220,7 +250,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal { cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED; cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED; - m_wellPathGeometry->twoClosestPoints(point, &p1, &p2); + wellPathGeometry()->twoClosestPoints(point, &p1, &p2); if (p1.isUndefined() || p2.isUndefined()) continue; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -266,3 +296,89 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal return pointNormals; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const +{ + std::vector wellSegmentNormals; + + if (!wellPathGeometry()) return wellSegmentNormals; + + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + + const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); + const cvf::Vec3d up(0, 0, 1); + + cvf::Vec3d normal; + + for (size_t i = 0; i < wellPathPoints.size()-1; i++) + { + cvf::Vec3d p1 = wellPathPoints[i]; + cvf::Vec3d p2 = wellPathPoints[i + 1]; + + if (p1.isUndefined() || p2.isUndefined()) continue; + + cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); + + double dotProduct = up * vecAlongPath; + + cvf::Vec3d Ex; + + if (cvf::Math::abs(dotProduct) > 0.7071) + { + Ex = globalDirection; + } + else + { + Ex = vecAlongPath; + } + + cvf::Vec3d Ey = (up ^ Ex).getNormalized(); + cvf::Vec3d Ez = (Ex ^ Ey).getNormalized(); + + + switch (drawPlane) + { + case Rim3dWellLogCurve::HORIZONTAL_LEFT: + normal = -Ey; + break; + case Rim3dWellLogCurve::HORIZONTAL_RIGHT: + normal = Ey; + break; + case Rim3dWellLogCurve::VERTICAL_ABOVE: + normal = Ez; + break; + case Rim3dWellLogCurve::VERTICAL_BELOW: + normal = -Ez; + break; + default: + break; + } + + wellSegmentNormals.push_back(normal); + } + + wellSegmentNormals.push_back(normal); + + return wellSegmentNormals; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogCurveGeometryGenerator::wellPathRadius() const +{ + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + + return m_wellPath->wellPathRadius(cellSize); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const +{ + return m_wellPath->wellPathGeometry(); +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 2c1a2a9cd7..2376f78645 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -35,12 +35,14 @@ class DisplayCoordTransform; } class RigWellPath; +class RimGridView; +class RimWellPath; class Riv3dWellLogCurveGeometryGenerator : public cvf::Object { public: - Riv3dWellLogCurveGeometryGenerator(RigWellPath* wellPathGeometry) - : m_wellPathGeometry(wellPathGeometry){}; + Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView) + : m_wellPath(wellPath), m_gridView(gridView) {}; cvf::ref createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, const Rim3dWellLogCurve* rim3dWellLogCurve) const; @@ -58,6 +60,13 @@ private: std::vector calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane, const std::vector& points) const; + std::vector calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const; + + double wellPathRadius() const; + + const RigWellPath* wellPathGeometry() const; + private: - cvf::ref m_wellPathGeometry; + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; }; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index f3d1fe2a66..a763f5fba4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -18,7 +18,8 @@ #include "Riv3dWellLogPlanePartMgr.h" -#include "RigWellPath.h" +#include "RimGridView.h" +#include "RimWellPath.h" #include "Riv3dWellLogCurveGeomertyGenerator.h" @@ -33,8 +34,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry) - :m_wellPathGeometry(wellPathGeometry) +Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView) + :m_wellPath(wellPath), m_gridView(gridView) { } @@ -46,9 +47,9 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* std::vector rim3dWellLogCurves) { if (rim3dWellLogCurves.empty()) return; - if (m_wellPathGeometry.isNull()) return; + if (m_wellPath.isNull()) return; - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPathGeometry.p()); + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index 918f5c7c9c..350ae98733 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -40,13 +40,14 @@ namespace caf class DisplayCoordTransform; } +class RimGridView; +class RimWellPath; class Riv3dWellLogCurveGeometryGenerator; -class RigWellPath; class Riv3dWellLogPlanePartMgr : public cvf::Object { public: - Riv3dWellLogPlanePartMgr(RigWellPath* wellPathGeometry); + Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView); void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, @@ -59,5 +60,7 @@ private: cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); private: cvf::ref m_3dWellLogCurveGeometryGenerator; - cvf::ref m_wellPathGeometry; -}; \ No newline at end of file + + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 935e03602f..bcbd6fc382 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -471,7 +471,10 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; - m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath->wellPathGeometry()); + RimGridView* gridView = dynamic_cast(m_rimView.p()); + if (!gridView) return; + + m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid())