From 5919cb20fb3fb934bf0f0aebf919e9e079beb942 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Feb 2018 13:23:14 +0100 Subject: [PATCH] #2431 : Refactor of well part manager --- .../ModelVisualization/RivWellPathPartMgr.cpp | 28 +++++++++++++++---- .../ModelVisualization/RivWellPathPartMgr.h | 11 ++++++-- .../RivWellPathSourceInfo.cpp | 8 ++++-- .../RivWellPathSourceInfo.h | 4 ++- .../ProjectDataModel/RimWellPath.cpp | 3 ++ .../RimWellPathCollection.cpp | 2 ++ 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 5e20adcc48..723d005145 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -57,15 +57,18 @@ #include "cvfFont.h" #include "cvfModelBasicList.h" #include "cvfPart.h" +#include "cvfScalarMapperDiscreteLinear.h" +#include "cvfTransform.h" #include "cvfqtUtils.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath) +RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view) { m_rimWellPath = wellPath; + m_rimView = view; } //-------------------------------------------------------------------------------------------------- @@ -80,15 +83,18 @@ RivWellPathPartMgr::~RivWellPathPartMgr() /// //-------------------------------------------------------------------------------------------------- #ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const Rim3dView* rimView) { + const RimEclipseView* eclView = dynamic_cast(rimView); + if (!eclView) return; + if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return; for (RimWellPathFracture* f : m_rimWellPath->fractureCollection()->fractures()) { CVF_ASSERT(f); - f->fracturePartManager()->appendGeometryPartsToModel(model, eclView); + f->fracturePartManager()->appendGeometryPartsToModel(model, *eclView); } } #endif // USE_PROTOTYPE_FEATURE_FRACTURES @@ -156,13 +162,16 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD { if (!m_rimWellPath || !m_rimWellPath->perforationIntervalCollection()->isChecked()) return; + RimWellPathCollection* wellPathCollection = this->wellPathCollection(); + if (!wellPathCollection) return; + RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; // Since we're using the index of measured depths to find the index of a point, ensure they're equal CVF_ASSERT(wellPathGeometry->m_measuredDepths.size() == wellPathGeometry->m_wellPathPoints.size()); - double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); double perforationRadius = wellPathRadius * 1.1; RivPipeGeometryGenerator geoGenerator; @@ -211,7 +220,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di if (wellPathGeometry->m_wellPathPoints.size() < 2) return; clearAllBranchData(); - double wellPathRadius = m_rimWellPath->wellPathRadius(characteristicCellSize); + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); cvf::Vec3d textPosition; @@ -293,7 +302,7 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di pbd.m_surfacePart = new cvf::Part; pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath); + RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_rimView); pbd.m_surfacePart->setSourceInfo(sourceInfo); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); @@ -448,3 +457,10 @@ RimWellPathCollection* RivWellPathPartMgr::wellPathCollection() return wellPathCollection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellPathPartMgr::wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection) +{ + return wellPathCollection->wellPathRadiusScaleFactor() * m_rimWellPath->wellPathRadiusScaleFactor() * characteristicCellSize; +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index a41768c2e8..d5cbcaea15 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -28,7 +28,10 @@ namespace cvf { class Part; class ModelBasicList; + class Transform; + class Effect; class DrawableGeo; + class ScalarMapper; } namespace caf @@ -41,14 +44,14 @@ class RimProject; class RimWellPath; class RivFishbonesSubsPartMgr; class RimWellPathCollection; -class RimEclipseView; +class Rim3dView; class QDateTime; class RivWellPathPartMgr : public cvf::Object { public: - explicit RivWellPathPartMgr(RimWellPath* wellPath); + explicit RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view); ~RivWellPathPartMgr(); void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, @@ -58,7 +61,7 @@ public: #ifdef USE_PROTOTYPE_FEATURE_FRACTURES void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView); + const Rim3dView* eclView); #endif // USE_PROTOTYPE_FEATURE_FRACTURES void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, @@ -90,9 +93,11 @@ private: void clearAllBranchData(); inline RimWellPathCollection* wellPathCollection(); + inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); private: caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_rimView; struct RivPipeBranchData { diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp index 41b008e230..5637ef32bb 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp @@ -23,6 +23,7 @@ #include "RimCase.h" #include "RimWellPath.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RivWellPathPartMgr.h" @@ -32,9 +33,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath) +RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view) { m_wellPath = wellPath; + m_view = view; } //-------------------------------------------------------------------------------------------------- @@ -103,6 +105,8 @@ void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const c //-------------------------------------------------------------------------------------------------- size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const { - return m_wellPath->partMgr()->segmentIndexFromTriangleIndex(triangleIndex); + return -1; + + //return m_view->wellPathSegmentIndexFromTriangleIndex(triangleIndex, m_wellPath); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h index 6bb3935cdf..716bf92ee5 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h @@ -26,6 +26,7 @@ #include "cvfVector3.h" class RimWellPath; +class Rim3dView; //================================================================================================== /// @@ -33,7 +34,7 @@ class RimWellPath; class RivWellPathSourceInfo : public cvf::Object { public: - explicit RivWellPathSourceInfo(RimWellPath* wellPath); + explicit RivWellPathSourceInfo(RimWellPath* wellPath, Rim3dView* view); RimWellPath* wellPath() const; @@ -47,4 +48,5 @@ private: private: caf::PdmPointer m_wellPath; + caf::PdmPointer m_view; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index e92f474504..d5fa25138e 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -305,6 +305,7 @@ const RigWellPath* RimWellPath::wellPathGeometry() const //-------------------------------------------------------------------------------------------------- RivWellPathPartMgr* RimWellPath::partMgr() { +/* if (m_wellPathPartMgr.isNull()) { RimWellPathCollection* wpColl; @@ -313,6 +314,8 @@ RivWellPathPartMgr* RimWellPath::partMgr() } return m_wellPathPartMgr.p(); +*/ + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index f02e2528af..af136d4da1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -437,6 +437,7 @@ void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) { +/* if (!this->isActive()) return; if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; @@ -445,6 +446,7 @@ void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); partMgr->appendStaticFracturePartsToModel(model, eclView); } +*/ } #endif // USE_PROTOTYPE_FEATURE_FRACTURES