From 600f3da30a785300538ed0eb4939c888da7dba03 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Wed, 7 Dec 2016 12:01:31 +0100 Subject: [PATCH] #1025 Established geometry for all well cell centers --- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivReservoirWellSpheresPartMgr.cpp | 74 +++------ .../RivReservoirWellSpheresPartMgr.h | 9 +- .../RivWellSpheresPartMgr.cpp | 157 ++++++++++++++++++ .../RivWellSpheresPartMgr.h | 74 +++++++++ .../ProjectDataModel/RimEclipseView.cpp | 11 +- .../ProjectDataModel/RimEclipseView.h | 4 +- .../RimEclipseWellCollection.cpp | 8 + 8 files changed, 284 insertions(+), 55 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 0baaa6a2ce..25a45707bd 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -35,6 +35,7 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h ${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h ${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h ${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.h +${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -66,6 +67,7 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp ${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp ${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp ${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.cpp +${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp index cf6bb51d5f..d73fc876e6 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.cpp @@ -1,8 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS +// Copyright (C) 2016- Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,15 +18,10 @@ #include "RivReservoirWellSpheresPartMgr.h" -// #include "Rim3dOverlayInfoConfig.h" -// #include "RimCellEdgeColors.h" -// #include "RimCellRangeFilterCollection.h" -// #include "RimEclipseCellColors.h" -// #include "RimEclipsePropertyFilterCollection.h" -// #include "RimEclipseView.h" -// #include "RimEclipseWell.h" -// #include "RimEclipseWellCollection.h" +#include "RivWellSpheresPartMgr.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" @@ -42,9 +35,9 @@ //-------------------------------------------------------------------------------------------------- RivReservoirWellSpheresPartMgr::RivReservoirWellSpheresPartMgr(RimEclipseView* reservoirView) { -// m_reservoirView = reservoirView; -// -// m_scaleTransform = new cvf::Transform(); + m_reservoirView = reservoirView; + + m_scaleTransform = new cvf::Transform(); } //-------------------------------------------------------------------------------------------------- @@ -62,15 +55,6 @@ void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTra { m_scaleTransform = scaleTransform; -// for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) -// { -// m_wellPipesPartMgrs[wIdx]->setScaleTransform(scaleTransform); -// } -// -// for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) -// { -// m_wellHeadPartMgrs[wIdx]->setScaleTransform(scaleTransform); -// } } //-------------------------------------------------------------------------------------------------- @@ -78,32 +62,22 @@ void RivReservoirWellSpheresPartMgr::setScaleTransform(cvf::Transform * scaleTra //-------------------------------------------------------------------------------------------------- void RivReservoirWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) { -// if (!m_reservoirView->wellCollection()->isActive()) return; -// -// if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimEclipseWellCollection::PIPES_FORCE_ALL_OFF) return; -// -// if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) -// { -// clearGeometryCache(); -// -// for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) -// { -// RivWellPipesPartMgr * wppmgr = new RivWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); -// m_wellPipesPartMgrs.push_back(wppmgr); -// wppmgr->setScaleTransform(m_scaleTransform.p()); -// -// RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); -// m_wellHeadPartMgrs.push_back(wellHeadMgr); -// wellHeadMgr->setScaleTransform(m_scaleTransform.p()); -// } -// } -// -// for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) -// { -// m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); -// m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); -// } + if (!m_reservoirView->wellCollection()->showCellCenterSpheres) return; + + if (m_reservoirView->wellCollection()->wells.size() != m_wellSpheresPartMgrs.size()) + { + + for (RimEclipseWell* rimWell : m_reservoirView->wellCollection()->wells()) + { + RivWellSpheresPartMgr* wppmgr = new RivWellSpheresPartMgr(m_reservoirView, rimWell); + m_wellSpheresPartMgrs.push_back(wppmgr); + wppmgr->setScaleTransform(m_scaleTransform.p()); + } + } + + for (size_t i = 0; i < m_wellSpheresPartMgrs.size(); i++) + { + m_wellSpheresPartMgrs.at(i)->appendDynamicGeometryPartsToModel(model, frameIndex); + } } - - diff --git a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.h index a7f2368ed9..68f84bb377 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirWellSpheresPartMgr.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// Copyright (C) 2016- Statoil ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ namespace cvf } class RimEclipseView; +class RivWellSpheresPartMgr; class RivReservoirWellSpheresPartMgr : public cvf::Object { @@ -42,9 +43,13 @@ public: void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); +private: + + private: caf::PdmPointer m_reservoirView; cvf::ref m_scaleTransform; - + cvf::Collection< RivWellSpheresPartMgr > m_wellSpheresPartMgrs; + }; diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp new file mode 100644 index 0000000000..dd6f6bd035 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.cpp @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellSpheresPartMgr.h" + +#include "RigCaseData.h" +#include "RigMainGrid.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" + +#include "cafEffectGenerator.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" + +#include "cvfDrawableGeo.h" +#include "cvfGeometryBuilderFaceList.h" +#include "cvfGeometryUtils.h" +#include "cvfModelBasicList.h" +#include "cvfObject.h" +#include "cvfPart.h" + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellSpheresPartMgr::RivWellSpheresPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well) +{ + m_rimReservoirView = reservoirView; + m_rimWell = well; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellSpheresPartMgr::~RivWellSpheresPartMgr() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +{ + if (m_rimReservoirView.isNull()) return; + if (!m_rimReservoirView->eclipseCase()) return; + if (!m_rimReservoirView->eclipseCase()->reservoirData()) return; + + const RigMainGrid* mainGrid = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid(); + CVF_ASSERT(mainGrid); + + RigSingleWellResultsData* rigWellResult = m_rimWell->wellResults(); + if (!rigWellResult) return; + + if (!rigWellResult->hasWellResult(frameIndex)) return; + + const RigWellResultFrame& wellResultFrame = rigWellResult->wellResultFrame(frameIndex); + + std::vector cellCenters; + + for (const RigWellResultBranch& wellResultBranch : wellResultFrame.m_wellResultBranches) + { + for (const RigWellResultPoint& wellResultPoint : wellResultBranch.m_branchResultPoints) + { + size_t gridIndex = wellResultPoint.m_gridIndex; + size_t gridCellIndex = wellResultPoint.m_gridCellIndex; + + const RigGridBase* rigGrid = mainGrid->gridByIndex(gridIndex); + const RigCell& rigCell = rigGrid->cell(gridCellIndex); + + cvf::Vec3d center = rigCell.center(); + + cellCenters.push_back(center); + } + } + + + for (cvf::Vec3d c : cellCenters) + { + cvf::Vec4d transfCoord = m_scaleTransform->worldTransform() * cvf::Vec4d(c - mainGrid->displayModelOffset(), 1); + + cvf::Vec3d displayCoord; + displayCoord[0] = transfCoord[0]; + displayCoord[1] = transfCoord[1]; + displayCoord[2] = transfCoord[2]; + + cvf::ref geo = createSphere(10, displayCoord); + cvf::ref part = createPart(geo.p()); + + model->addPart(part.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellSpheresPartMgr::createSphere(double radius, const cvf::Vec3d& pos) +{ + cvf::Vec3f posFloat(pos); + + cvf::ref geo = new cvf::DrawableGeo; + + cvf::GeometryBuilderFaceList builder; + cvf::GeometryUtils::createSphere(radius, 4, 5, &builder); + + cvf::ref vertices = builder.vertices(); + + // Move sphere coordinates to the destination location + for (size_t i = 0; i < vertices->size(); i++) + { + vertices->set(i, vertices->val(i) + posFloat); + } + + cvf::ref faceList = builder.faceList(); + + geo->setVertexArray(vertices.p()); + geo->setFromFaceList(*faceList); + geo->computeNormals(); + + return geo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellSpheresPartMgr::createPart(cvf::DrawableGeo* geo) +{ + cvf::ref part = new cvf::Part; + part->setDrawable(geo); + + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(cvf::Color3f::GREEN), caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); + + part->setEffect(eff.p()); + + return part; +} + diff --git a/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h new file mode 100644 index 0000000000..f67a132a55 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellSpheresPartMgr.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cafPdmPointer.h" +#include +#include "RigSingleWellResultsData.h" + +namespace cvf +{ + class Part; + class ModelBasicList; + class Transform; + class Effect; + class DrawableGeo; + class ScalarMapper; +} + +class RivPipeGeometryGenerator; +class RimEclipseView; +class RimEclipseWell; + +class RivWellSpheresPartMgr : public cvf::Object +{ +public: + RivWellSpheresPartMgr(RimEclipseView* reservoirView, RimEclipseWell* well); + ~RivWellSpheresPartMgr(); + + void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; scheduleGeometryRegen();} + + void scheduleGeometryRegen() { m_needsTransformUpdate = true; } + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + + +private: + static cvf::ref createSphere(double radius, const cvf::Vec3d& pos); + cvf::ref createPart(cvf::DrawableGeo* geo); + +private: + caf::PdmPointer m_rimReservoirView; + caf::PdmPointer m_rimWell; + + + struct RivPipeBranchData + { + cvf::ref m_surfacePart; + cvf::ref m_surfaceDrawable; + }; + + + cvf::ref m_scaleTransform; + bool m_needsTransformUpdate; +}; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 4a7c8af8a7..d7d6542251 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -55,6 +55,7 @@ #include "RiuViewer.h" #include "RivReservoirPipesPartMgr.h" +#include "RivReservoirWellSpheresPartMgr.h" #include "RivSingleCellPartGenerator.h" #include "RivTernarySaturationOverlayItem.h" #include "RivWellPathCollectionPartMgr.h" @@ -129,9 +130,11 @@ RimEclipseView::RimEclipseView() this->faultResultSettings()->setReservoirView(this); m_reservoirGridPartManager = new RivReservoirViewPartMgr(this); - m_pipesPartManager = new RivReservoirPipesPartMgr(this); - m_reservoir = NULL; + m_wellSpheresPartManager = new RivReservoirWellSpheresPartMgr(this); + + + m_reservoir = NULL; } //-------------------------------------------------------------------------------------------------- @@ -267,6 +270,8 @@ void RimEclipseView::updateScaleTransform() this->scaleTransform()->setLocalTransform(scale); m_pipesPartManager->setScaleTransform(this->scaleTransform()); + m_wellSpheresPartManager->setScaleTransform(this->scaleTransform()); + if (m_viewer) m_viewer->updateCachedValuesInScene(); } @@ -662,6 +667,8 @@ void RimEclipseView::updateCurrentTimeStep() wellPipeModelBasicList->setName("SimWellPipeMod"); m_pipesPartManager->appendDynamicGeometryPartsToModel(wellPipeModelBasicList.p(), m_currentTimeStep); + m_wellSpheresPartManager->appendDynamicGeometryPartsToModel(wellPipeModelBasicList.p(), m_currentTimeStep); + wellPipeModelBasicList->updateBoundingBoxesRecursive(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 30abe0e99d..3c47423f2d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -55,6 +55,7 @@ class RimEclipseCellColors; class RimEclipseWellCollection; class RiuViewer; class RivReservoirPipesPartMgr; +class RivReservoirWellSpheresPartMgr; class RivIntersectionPartMgr; namespace cvf @@ -178,7 +179,8 @@ private: cvf::ref m_reservoirGridPartManager; cvf::ref m_pipesPartManager; - + cvf::ref m_wellSpheresPartManager; + std::vector m_visibleGridParts; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp index e9e4a38035..0a1f6ea9de 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWellCollection.cpp @@ -227,6 +227,14 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } } + else if (&showCellCenterSpheres == changedField) + { + if (m_reservoirView) + { + m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + } + } + else if (&wellCellFenceType == changedField) { if (m_reservoirView)