From 75225b751972b8b416e88596a7463116787ca99a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 19 Dec 2013 09:08:08 +0100 Subject: [PATCH] NNC: Picking and result mapping Show NNC info in Result Info Show NNC result mapping for combined transmissibility --- .../ModelVisualization/RivFaultPartMgr.cpp | 99 +++++++++++++------ .../ModelVisualization/RivFaultPartMgr.h | 2 + .../ModelVisualization/RivGridPartMgr.cpp | 3 +- .../ProjectDataModel/RimReservoirView.cpp | 25 +++++ .../ProjectDataModel/RimReservoirView.h | 1 + ApplicationCode/UserInterface/RiuViewer.cpp | 67 ++++++++----- 6 files changed, 137 insertions(+), 60 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 018e7075ee..f379eaf3a4 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -46,6 +46,7 @@ #include "cvfPrimitiveSetDirect.h" #include "RivGridPartMgr.h" #include "cvfRenderStateDepth.h" +#include "RivSourceInfo.h" @@ -102,6 +103,8 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* { CVF_ASSERT(cellResultSlot); + updateNNCColors(cellResultSlot); + size_t scalarSetIndex = cellResultSlot->gridScalarIndex(); const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); @@ -247,7 +250,7 @@ void RivFaultPartMgr::generatePartGeometry() part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - part->setSourceInfo(m_nativeFaultGenerator->triangleToSourceGridCellMap().p()); + part->setSourceInfo(RivSourceInfo::fromCellIndices(m_nativeFaultGenerator->triangleToSourceGridCellMap().p()).p()); part->updateBoundingBox(); part->setEnableMask(faultBit); @@ -298,7 +301,7 @@ void RivFaultPartMgr::generatePartGeometry() part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - part->setSourceInfo(m_oppositeFaultGenerator->triangleToSourceGridCellMap().p()); + part->setSourceInfo(RivSourceInfo::fromCellIndices(m_oppositeFaultGenerator->triangleToSourceGridCellMap().p()).p()); part->updateBoundingBox(); part->setEnableMask(faultBit); @@ -347,7 +350,7 @@ void RivFaultPartMgr::generatePartGeometry() part->setDrawable(geo.p()); // Set mapping from triangle face index to cell index - part->setSourceInfo(m_NNCGenerator->triangleToNNCIndex().p()); + part->setSourceInfo(RivSourceInfo::fromNNCIndices(m_NNCGenerator->triangleToNNCIndex().p()).p()); part->updateBoundingBox(); part->setEnableMask(faultBit); @@ -368,11 +371,8 @@ void RivFaultPartMgr::generatePartGeometry() //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::updatePartEffect() { - cvf::Color3f partColor = m_defaultColor; - // Set default effect - caf::SurfaceEffectGenerator geometryEffgen(partColor, caf::PO_1); - + caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1); geometryEffgen.setCullBackfaces(faceCullingMode()); cvf::ref geometryOnlyEffect = geometryEffgen.generateEffect(); @@ -387,31 +387,7 @@ void RivFaultPartMgr::updatePartEffect() m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p()); } - // NNC faces a bit lighter than the fault for now - - cvf::Color3f nncColor = partColor; - nncColor.r() += (1.0 - nncColor.r()) * 0.2; - nncColor.g() += (1.0 - nncColor.g()) * 0.2; - nncColor.g() += (1.0 - nncColor.b()) * 0.2; - - cvf::ref nncEffect; - - if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces) - { - caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_NEG_LARGE); - nncEffgen.enableDepthWrite(false); - nncEffect = nncEffgen.generateEffect(); - } - else - { - caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_1); - nncEffect = nncEffgen.generateEffect(); - } - - if (m_NNCFaces.notNull()) - { - m_NNCFaces->setEffect(nncEffect.p()); - } + updateNNCColors(NULL); // Update mesh colors as well, in case of change RiaPreferences* prefs = RiaApplication::instance()->preferences(); @@ -674,3 +650,62 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const } return caf::FC_NONE; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFaultPartMgr::updateNNCColors(RimResultSlot* cellResultSlot) +{ + if (m_NNCFaces.isNull()) return; + + if (cellResultSlot && cellResultSlot->resultVariable() == RimDefines::combinedTransmissibilityResultName()) + { + const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper(); + + m_NNCGenerator->textureCoordinates(m_NNCTextureCoords.p(), mapper); + + cvf::ref nncEffect; + + if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces) + { + caf::ScalarMapperEffectGenerator nncEffgen(mapper, caf::PO_NEG_LARGE); + nncEffgen.enableDepthWrite(false); + nncEffect = nncEffgen.generateEffect(); + } + else + { + caf::ScalarMapperEffectGenerator nncEffgen(mapper, caf::PO_NEG_LARGE); + nncEffect = nncEffgen.generateEffect(); + } + + cvf::DrawableGeo* dg = dynamic_cast(m_NNCFaces->drawable()); + if (dg) dg->setTextureCoordArray(m_NNCTextureCoords.p()); + + m_NNCFaces->setEffect(nncEffect.p()); + } + else + { + // NNC faces a bit lighter than the fault for now + cvf::Color3f nncColor = m_defaultColor; + nncColor.r() += (1.0 - nncColor.r()) * 0.2; + nncColor.g() += (1.0 - nncColor.g()) * 0.2; + nncColor.g() += (1.0 - nncColor.b()) * 0.2; + + cvf::ref nncEffect; + + if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces) + { + caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_NEG_LARGE); + nncEffgen.enableDepthWrite(false); + nncEffect = nncEffgen.generateEffect(); + } + else + { + caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_1); + nncEffect = nncEffgen.generateEffect(); + } + + m_NNCFaces->setEffect(nncEffect.p()); + } +} + diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h index b7da2bd06a..79900075b4 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h @@ -66,6 +66,8 @@ private: void generatePartGeometry(); void updatePartEffect(); + void updateNNCColors(RimResultSlot* cellResultSlot); + cvf::ref cellResultEffect(const cvf::ScalarMapper* mapper) const; caf::FaceCulling faceCullingMode() const; diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index bfeaa112b8..2a2456c4c5 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -40,6 +40,7 @@ #include "RimCellPropertyFilterCollection.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirCellResultsCacher.h" +#include "RivSourceInfo.h" @@ -114,7 +115,7 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB part->setTransform(m_scaleTransform.p()); // Set mapping from triangle face index to cell index - part->setSourceInfo(geoBuilder.triangleToSourceGridCellMap().p()); + part->setSourceInfo(RivSourceInfo::fromCellIndices(geoBuilder.triangleToSourceGridCellMap().p()).p()); part->updateBoundingBox(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 7f32f67a02..dafb4a7aeb 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -1815,3 +1815,28 @@ void RimReservoirView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering cellGroup->add(&showInvalidCells); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirView::appendNNCResultInfo(size_t gridIndex, size_t nncIndex, QString* resultInfo) +{ + if (gridIndex != 0) + { + return; + } + + if (m_reservoir && m_reservoir->reservoirData()) + { + RigCaseData* eclipseCase = m_reservoir->reservoirData(); + RigMainGrid* grid = eclipseCase->mainGrid(); + + RigNNCData* nncData = grid->nncData(); + + const RigConnection& conn = nncData->connections()[nncIndex]; + + resultInfo->append(QString("NNC Transmissibility : %1\n").arg(conn.m_transmissibility)); + resultInfo->append(QString("NNC Cell 1 : %1\n").arg(conn.m_c1GlobIdx)); + resultInfo->append(QString("NNC Cell 2 : %1\n").arg(conn.m_c2GlobIdx)); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index bea358dab1..cd215e60e9 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -159,6 +159,7 @@ public: // Picking info bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const; void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) ; + void appendNNCResultInfo( size_t gridIndex, size_t nncIndex, QString* resultInfo ); // Does this belong here, really ? void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index edbd6ddee4..c21458d49e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -46,6 +46,7 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" +#include "RivSourceInfo.h" using cvf::ManipulatorTrackball; @@ -270,17 +271,20 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event) { if (firstHitPart->sourceInfo()) { - const cvf::Array* cellIndices = dynamic_cast*>(firstHitPart->sourceInfo()); - if (cellIndices) + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + if (rivSourceInfo) { - m_currentGridIdx = firstHitPart->id(); - m_currentCellIndex = cellIndices->get(faceIndex); + if (rivSourceInfo->m_cellIndices->size() > 0) + { + m_currentGridIdx = firstHitPart->id(); + m_currentCellIndex = rivSourceInfo->m_cellIndices->get(faceIndex); - QMenu menu; - menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI())); - menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ())); - menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK())); - menu.exec(event->globalPos()); + QMenu menu; + menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI())); + menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ())); + menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK())); + menu.exec(event->globalPos()); + } } } } @@ -430,27 +434,36 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY) size_t cellIndex = cvf::UNDEFINED_SIZE_T; if (firstHitPart->sourceInfo()) { - const cvf::Array* cellIndices = dynamic_cast*>(firstHitPart->sourceInfo()); - if (cellIndices) + const RivSourceInfo* rivSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + if (rivSourceInfo) { - cellIndex = cellIndices->get(faceIndex); - - m_reservoirView->pickInfo(gridIndex, cellIndex, localIntersectionPoint, &pickInfo); - m_reservoirView->appendCellResultInfo(gridIndex, cellIndex, &resultInfo); -#if 0 - const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); - const RigGridBase* grid = reservoir->grid(gridIndex); - const RigCell& cell = grid->cell(cellIndex); - const caf::SizeTArray8& cellNodeIndices = cell.cornerIndices(); - const std::vector& nodes = reservoir->mainGrid()->nodes(); - for (int i = 0; i < 8; ++i) + if (rivSourceInfo->m_cellIndices.notNull()) { - resultInfo += QString::number(i) + " : "; - for (int j = 0; j < 3; ++j) - resultInfo += QString::number(nodes[cellNodeIndices[i]][j], 'g', 10) + " "; - resultInfo += "\n"; - } + cellIndex = rivSourceInfo->m_cellIndices->get(faceIndex); + + m_reservoirView->pickInfo(gridIndex, cellIndex, localIntersectionPoint, &pickInfo); + m_reservoirView->appendCellResultInfo(gridIndex, cellIndex, &resultInfo); +#if 0 + const RigCaseData* reservoir = m_reservoirView->eclipseCase()->reservoirData(); + const RigGridBase* grid = reservoir->grid(gridIndex); + const RigCell& cell = grid->cell(cellIndex); + const caf::SizeTArray8& cellNodeIndices = cell.cornerIndices(); + const std::vector& nodes = reservoir->mainGrid()->nodes(); + for (int i = 0; i < 8; ++i) + { + resultInfo += QString::number(i) + " : "; + for (int j = 0; j < 3; ++j) + resultInfo += QString::number(nodes[cellNodeIndices[i]][j], 'g', 10) + " "; + resultInfo += "\n"; + } #endif + } + else if (rivSourceInfo->m_NNCIndices.notNull()) + { + size_t nncIndex = rivSourceInfo->m_NNCIndices->get(faceIndex); + + m_reservoirView->appendNNCResultInfo(gridIndex, nncIndex, &resultInfo); + } } } }