From 1890ff19f91cdcca59015fcaa2f524867397c1e0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 24 Nov 2015 14:14:14 +0100 Subject: [PATCH] (#664) Picking on intersections for eclipse and geo models --- .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivCrossSectionPartMgr.cpp | 6 +-- .../RivCrossSectionSourceInfo.cpp | 42 +++++++++++++++++++ .../RivCrossSectionSourceInfo.h | 37 ++++++++++++++++ .../UserInterface/RiuViewerCommands.cpp | 21 ++++++++++ 5 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.cpp create mode 100644 ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.h diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index d3ab43480f..3672d3312c 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -36,6 +36,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}RivCrossSectionSourceInfo.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -68,6 +69,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}RivCrossSectionSourceInfo.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp b/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp index f5b2407fe1..10990afa34 100644 --- a/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivCrossSectionPartMgr.cpp @@ -36,6 +36,7 @@ #include "RimGeoMechView.h" #include "RimTernaryLegendConfig.h" +#include "RivCrossSectionSourceInfo.h" #include "RivResultToTextureMapper.h" #include "RivScalarMapperUtils.h" #include "RivTernaryScalarMapper.h" @@ -303,9 +304,8 @@ void RivCrossSectionPartMgr::generatePartGeometry() part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - //cvf::ref si = new RivSourceInfo(m_grid->gridIndex()); - //si->m_cellFaceFromTriangleMapper = m_nativeCrossSectionGenerator->triangleToCellFaceMapper(); - //part->setSourceInfo(si.p()); + cvf::ref si = new RivCrossSectionSourceInfo(m_crossSectionGenerator.p()); + part->setSourceInfo(si.p()); part->updateBoundingBox(); part->setEnableMask(surfaceBit); diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.cpp new file mode 100644 index 0000000000..2a9f4889fc --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.cpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivCrossSectionSourceInfo.h" + +#include "RivCrossSectionGeometryGenerator.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivCrossSectionSourceInfo::RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator) + : m_crossSectionGeometryGenerator(geometryGenerator) +{ + CVF_ASSERT(m_crossSectionGeometryGenerator.notNull()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RivCrossSectionSourceInfo::triangleToCellIndex() const +{ + CVF_ASSERT(m_crossSectionGeometryGenerator.notNull()); + + return m_crossSectionGeometryGenerator->triangleToCellIndex(); +} diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.h new file mode 100644 index 0000000000..c402319657 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivCrossSectionSourceInfo.h @@ -0,0 +1,37 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// Copyright (C) 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfArray.h" + +class RivCrossSectionGeometryGenerator; + +class RivCrossSectionSourceInfo : public cvf::Object +{ +public: + RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator); + + const std::vector& triangleToCellIndex() const; + +private: + cvf::cref m_crossSectionGeometryGenerator; +}; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index c4eafb763e..fd8a0441c9 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -62,6 +62,7 @@ #include "RiuSelectionManager.h" #include "RiuViewer.h" +#include "RivCrossSectionSourceInfo.h" #include "RivFemPartGeometryGenerator.h" #include "RivFemPickSourceInfo.h" #include "RivSourceInfo.h" @@ -418,6 +419,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivFemPickSourceInfo* femSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivCrossSectionSourceInfo* crossSectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); if (rivSourceInfo) { @@ -439,6 +441,25 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM { wellPath = wellPathSourceInfo->wellPath(); } + else if (crossSectionSourceInfo) + { + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); + + if (eclipseView) + { + size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; + + const RigCell& cell = eclipseView->eclipseCase()->reservoirData()->mainGrid()->cells()[globalCellIndex]; + cellIndex = cell.gridLocalCellIndex(); + gridIndex = cell.hostGrid()->gridIndex(); + } + else if (geomView) + { + cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; + gridIndex = 0; + } + } } if (firstNncHitPart && firstNncHitPart->sourceInfo())