mirror of
				https://github.com/OPM/ResInsight.git
				synced 2025-02-25 18:55:39 -06:00 
			
		
		
		
	#2633 3D well log curves: Clip grid on well path bounding box
This commit is contained in:
		@@ -21,6 +21,7 @@
 | 
			
		||||
#include "RimCase.h"
 | 
			
		||||
#include "RimGridView.h"
 | 
			
		||||
#include "RimWellPath.h"
 | 
			
		||||
#include "RimWellPathCollection.h"
 | 
			
		||||
 | 
			
		||||
#include "RigCurveDataTools.h"
 | 
			
		||||
#include "RigWellPath.h"
 | 
			
		||||
@@ -28,6 +29,8 @@
 | 
			
		||||
#include "cafDisplayCoordTransform.h"
 | 
			
		||||
#include "cvfPrimitiveSetIndexedUInt.h"
 | 
			
		||||
 | 
			
		||||
#include "cvfBoundingBox.h"
 | 
			
		||||
 | 
			
		||||
#include <cmath>
 | 
			
		||||
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
@@ -65,32 +68,47 @@ cvf::ref<cvf::DrawableGeo>
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
 | 
			
		||||
                                                                          const cvf::BoundingBox& wellPathClipBoundingBox,
 | 
			
		||||
                                                                          const Rim3dWellLogCurve::DrawPlane drawPlane,
 | 
			
		||||
                                                                          double                             gridIntervalSize) const
 | 
			
		||||
{
 | 
			
		||||
    CVF_ASSERT(gridIntervalSize > 0);
 | 
			
		||||
 | 
			
		||||
    if (!wellPathGeometry()) return nullptr;
 | 
			
		||||
    if (!wellPathClipBoundingBox.isValid()) return nullptr;
 | 
			
		||||
 | 
			
		||||
    RimWellPathCollection* wellPathCollection = nullptr;
 | 
			
		||||
    m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
 | 
			
		||||
 | 
			
		||||
    std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
 | 
			
		||||
    if (wellPathPoints.empty()) return nullptr;
 | 
			
		||||
 | 
			
		||||
    const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized();
 | 
			
		||||
    const cvf::Vec3d up(0, 0, 1);
 | 
			
		||||
    size_t originalWellPathSize = wellPathPoints.size();
 | 
			
		||||
 | 
			
		||||
    if (wellPathCollection->wellPathClip)
 | 
			
		||||
    {
 | 
			
		||||
        double horizontalLengthAlongWellToClipPoint;
 | 
			
		||||
        double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
 | 
			
		||||
        wellPathPoints =
 | 
			
		||||
            RigWellPath::clipPolylineStartAboveZ(wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint);
 | 
			
		||||
    }
 | 
			
		||||
    if (wellPathPoints.empty()) return nullptr;
 | 
			
		||||
 | 
			
		||||
    std::vector<cvf::Vec3d> pointNormals;
 | 
			
		||||
    std::vector<cvf::Vec3d> gridPoints;
 | 
			
		||||
 | 
			
		||||
    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)
 | 
			
		||||
    size_t newStartIndex = originalWellPathSize - wellPathPoints.size();
 | 
			
		||||
    double firstMd       = wellPathGeometry()->m_measuredDepths.at(newStartIndex);
 | 
			
		||||
    double lastMd        = wellPathGeometry()->m_measuredDepths.back();
 | 
			
		||||
 | 
			
		||||
    double md = lastMd;
 | 
			
		||||
    while (md >= firstMd)
 | 
			
		||||
    {
 | 
			
		||||
        cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md);
 | 
			
		||||
        gridPoints.push_back(point);
 | 
			
		||||
        md += gridIntervalSize;
 | 
			
		||||
        md -= gridIntervalSize;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pointNormals = calculatePointNormals(drawPlane, gridPoints);
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,11 @@ namespace caf
 | 
			
		||||
class DisplayCoordTransform;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace cvf
 | 
			
		||||
{
 | 
			
		||||
class BoundingBox;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class RigWellPath;
 | 
			
		||||
class RimGridView;
 | 
			
		||||
class RimWellPath;
 | 
			
		||||
@@ -48,6 +53,7 @@ public:
 | 
			
		||||
                                               const Rim3dWellLogCurve*          rim3dWellLogCurve) const;
 | 
			
		||||
 | 
			
		||||
    cvf::ref<cvf::DrawableGeo> createGrid(const caf::DisplayCoordTransform*  displayCoordTransform,
 | 
			
		||||
                                          const cvf::BoundingBox&            wellPathClipBoundingBox,
 | 
			
		||||
                                          const Rim3dWellLogCurve::DrawPlane drawPlane,
 | 
			
		||||
                                          double                             gridIntervalSize) const;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@
 | 
			
		||||
#include "cafDisplayCoordTransform.h"
 | 
			
		||||
#include "cafEffectGenerator.h"
 | 
			
		||||
 | 
			
		||||
#include "cvfBoundingBox.h"
 | 
			
		||||
#include "cvfColor3.h"
 | 
			
		||||
#include "cvfDrawableGeo.h"
 | 
			
		||||
#include "cvfModelBasicList.h"
 | 
			
		||||
@@ -35,7 +36,8 @@
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView)
 | 
			
		||||
    :m_wellPath(wellPath), m_gridView(gridView)
 | 
			
		||||
    : m_wellPath(wellPath)
 | 
			
		||||
    , m_gridView(gridView)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -58,7 +60,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
 | 
			
		||||
    {
 | 
			
		||||
        if (!rim3dWellLogCurve->toggleState()) continue;
 | 
			
		||||
 | 
			
		||||
        cvf::ref<cvf::Drawable> curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve);
 | 
			
		||||
        cvf::ref<cvf::Drawable> curveDrawable =
 | 
			
		||||
            m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve);
 | 
			
		||||
 | 
			
		||||
        if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid())
 | 
			
		||||
        {
 | 
			
		||||
@@ -95,7 +98,10 @@ cvf::ref<cvf::Part> Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
///
 | 
			
		||||
//--------------------------------------------------------------------------------------------------
 | 
			
		||||
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize)
 | 
			
		||||
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*              model,
 | 
			
		||||
                                                 const caf::DisplayCoordTransform* displayCoordTransform,
 | 
			
		||||
                                                 const cvf::BoundingBox&           wellPathClipBoundingBox,
 | 
			
		||||
                                                 double                            gridIntervalSize)
 | 
			
		||||
{
 | 
			
		||||
    if (m_3dWellLogCurveGeometryGenerator.isNull())
 | 
			
		||||
    {
 | 
			
		||||
@@ -105,7 +111,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con
 | 
			
		||||
    caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize);
 | 
			
		||||
        cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(
 | 
			
		||||
            displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize);
 | 
			
		||||
 | 
			
		||||
        cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
 | 
			
		||||
        cvf::ref<cvf::Part>   part   = createPart(gridHorizontalDrawable.p(), effect.p());
 | 
			
		||||
@@ -116,7 +123,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    {
 | 
			
		||||
        cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize);
 | 
			
		||||
        cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(
 | 
			
		||||
            displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize);
 | 
			
		||||
 | 
			
		||||
        cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
 | 
			
		||||
        cvf::ref<cvf::Part>   part   = createPart(gridHorizontalDrawable.p(), effect.p());
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,8 @@ namespace cvf
 | 
			
		||||
class Drawable;
 | 
			
		||||
class Effect;
 | 
			
		||||
class Part;
 | 
			
		||||
}
 | 
			
		||||
class BoundingBox;
 | 
			
		||||
} // namespace cvf
 | 
			
		||||
 | 
			
		||||
namespace caf
 | 
			
		||||
{
 | 
			
		||||
@@ -55,9 +56,12 @@ public:
 | 
			
		||||
 | 
			
		||||
    void appendGridToModel(cvf::ModelBasicList*              model,
 | 
			
		||||
                           const caf::DisplayCoordTransform* displayCoordTransform,
 | 
			
		||||
                           const cvf::BoundingBox&           wellPathClipBoundingBox,
 | 
			
		||||
                           double                            gridIntervalSize);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    cvf::ref<cvf::Part> createPart(cvf::Drawable* drawable, cvf::Effect* effect);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_3dWellLogCurveGeometryGenerator;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -548,7 +548,7 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
 | 
			
		||||
 | 
			
		||||
    if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid())
 | 
			
		||||
    {
 | 
			
		||||
        m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, 200);
 | 
			
		||||
        m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 200);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user