ResInsight/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp

310 lines
11 KiB
C++
Raw Normal View History

2013-12-10 00:56:58 -06:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-24 00:14:52 -05:00
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
2013-12-10 00:56:58 -06:00
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivReservoirFaultsPartMgr.h"
2016-07-16 09:31:55 -05:00
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipseView.h"
#include "RimFaultInView.h"
#include "RimFaultInViewCollection.h"
2016-07-16 09:31:55 -05:00
#include "RivFaultPartMgr.h"
2013-12-10 00:56:58 -06:00
#include "cvfColor3.h"
2016-07-16 09:31:55 -05:00
#include "cvfModelBasicList.h"
#include "cvfPart.h"
2013-12-10 00:56:58 -06:00
#include "cvfTransform.h"
#include "cafPdmFieldCvfColor.h"
2016-11-17 07:37:10 -06:00
#include <QDebug>
2013-12-10 00:56:58 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr(const RigMainGrid* grid, RimEclipseView* reservoirView)
: m_reservoirView(reservoirView)
2013-12-10 00:56:58 -06:00
{
CVF_ASSERT(grid);
if (reservoirView)
2013-12-10 00:56:58 -06:00
{
RimFaultInViewCollection* faultCollection = reservoirView->faultCollection();
2014-07-31 03:53:38 -05:00
if (faultCollection)
2013-12-10 00:56:58 -06:00
{
2014-07-31 03:53:38 -05:00
for (size_t i = 0; i < faultCollection->faults.size(); i++)
{
m_faultParts.push_back(new RivFaultPartMgr(grid, faultCollection, faultCollection->faults[i]));
}
2013-12-10 00:56:58 -06:00
}
}
2016-11-17 07:37:10 -06:00
m_forceWatertightGeometry = false;
2013-12-10 00:56:58 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::~RivReservoirFaultsPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setTransform(cvf::Transform* scaleTransform)
{
m_scaleTransform = scaleTransform;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(cellVisibilities);
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts.at(i)->setCellVisibility(cellVisibilities);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
2018-02-18 11:56:43 -06:00
CVF_ASSERT(model != nullptr);
2013-12-10 00:56:58 -06:00
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
if (!faultCollection) return;
2013-12-10 00:56:58 -06:00
bool isShowingGrid = m_reservoirView->isMainGridVisible();
if (!faultCollection->showFaultCollection() && !isShowingGrid) return;
2013-12-10 00:56:58 -06:00
// Check match between model fault count and fault parts
CVF_ASSERT(faultCollection->faults.size() == m_faultParts.size());
2013-12-10 00:56:58 -06:00
2016-11-17 07:37:10 -06:00
// Parts that is overridden by the grid settings
bool forceDisplayOfFault = false;
if (!faultCollection->isShowingFaultsAndFaultsOutsideFilters())
2016-11-17 07:37:10 -06:00
{
forceDisplayOfFault = isShowingGrid;
}
if (m_forceWatertightGeometry && isShowingGrid)
{
forceDisplayOfFault = true;
}
//qDebug() << forceDisplayOfFault;
2013-12-10 00:56:58 -06:00
cvf::ModelBasicList parts;
for (size_t i = 0; i < faultCollection->faults.size(); i++)
2013-12-10 00:56:58 -06:00
{
const RimFaultInView* rimFault = faultCollection->faults[i];
2013-12-10 00:56:58 -06:00
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
CVF_ASSERT(rivFaultPart.notNull());
2014-08-01 07:48:37 -05:00
if ( (faultCollection->showFaultCollection() && rimFault->showFault()) || forceDisplayOfFault)
{
if (faultCollection->showFaultFaces() || forceDisplayOfFault)
2013-12-10 00:56:58 -06:00
{
rivFaultPart->appendNativeFaultFacesToModel(&parts);
}
if (faultCollection->showOppositeFaultFaces() || forceDisplayOfFault)
2013-12-10 00:56:58 -06:00
{
rivFaultPart->appendOppositeFaultFacesToModel(&parts);
}
if (faultCollection->showFaultFaces() || faultCollection->showOppositeFaultFaces() || faultCollection->showNNCs() || forceDisplayOfFault)
2013-12-10 00:56:58 -06:00
{
rivFaultPart->appendMeshLinePartsToModel(&parts);
2013-12-10 00:56:58 -06:00
}
}
// Parts that is not overridden by the grid settings
RimEclipseFaultColors* faultResultColors = m_reservoirView->faultResultSettings();
RimEclipseCellColors* cellResultColors = m_reservoirView->cellResult();
2013-12-10 00:56:58 -06:00
if (rimFault->showFault() && faultCollection->showFaultCollection())
{
if (faultCollection->showNNCs())
2013-12-16 04:29:48 -06:00
{
bool showNncs = true;
if (faultCollection->hideNncsWhenNoResultIsAvailable())
{
RigEclipseResultAddress scalarResultIndex;
if (faultResultColors->showCustomFaultResult())
{
2019-01-23 07:24:12 -06:00
scalarResultIndex = faultResultColors->customFaultResult()->eclipseResultAddress();
}
else
{
2019-01-23 07:24:12 -06:00
scalarResultIndex = cellResultColors->eclipseResultAddress();
}
RigMainGrid* mainGrid = m_reservoirView->mainGrid();
if (!(mainGrid && mainGrid->nncData()->hasScalarValues(scalarResultIndex.scalarResultIndex)))
{
showNncs = false;
}
}
if (showNncs)
{
rivFaultPart->appendNNCFacesToModel(&parts);
}
2013-12-16 04:29:48 -06:00
}
2013-12-10 00:56:58 -06:00
}
}
for (size_t i = 0; i < parts.partCount(); i++)
{
cvf::Part* part = parts.part(i);
part->setTransform(m_scaleTransform.p());
model->addPart(part);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2014-01-02 04:21:35 -06:00
void RivReservoirFaultsPartMgr::applySingleColorEffect()
2013-12-10 00:56:58 -06:00
{
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->applySingleColorEffect();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
2013-12-10 00:56:58 -06:00
{
if (!m_reservoirView) return;
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
CVF_ASSERT(faultCollection);
for (size_t i = 0; i < faultCollection->faults.size(); i++)
2014-01-02 04:21:35 -06:00
{
if (cellResultColors && (cellResultColors->hasResult() || cellResultColors->isTernarySaturationSelected()) )
2014-01-02 04:21:35 -06:00
{
m_faultParts[i]->updateCellResultColor(timeStepIndex, cellResultColors);
}
else
{
m_faultParts[i]->applySingleColorEffect();
2014-01-02 04:21:35 -06:00
}
}
2013-12-10 00:56:58 -06:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors)
2013-12-10 00:56:58 -06:00
{
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->updateCellEdgeResultColor(timeStepIndex, cellResultColors, cellEdgeResultColors);
2013-12-10 00:56:58 -06:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
{
2018-02-18 11:56:43 -06:00
CVF_ASSERT(model != nullptr);
if (!m_reservoirView) return;
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
CVF_ASSERT(faultCollection);
if (!faultCollection->showFaultCollection()) return;
if (!faultCollection->showFaultLabel() ) return;
// Check match between model fault count and fault parts
CVF_ASSERT(faultCollection->faults.size() == m_faultParts.size());
cvf::ModelBasicList parts;
for (size_t i = 0; i < faultCollection->faults.size(); i++)
{
const RimFaultInView* rimFault = faultCollection->faults[i];
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
CVF_ASSERT(rivFaultPart.notNull());
if (rimFault->showFault())
{
rivFaultPart->appendLabelPartsToModel(&parts);
}
}
for (size_t i = 0; i < parts.partCount(); i++)
{
cvf::Part* part = parts.part(i);
part->setTransform(m_scaleTransform.p());
model->addPart(part);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::forceWatertightGeometryOn()
{
m_forceWatertightGeometry = true;
}
2016-11-18 08:57:57 -06:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::clearWatertightGeometryFlag()
{
m_forceWatertightGeometry = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setOpacityLevel(float opacity)
{
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->setOpacityLevel(opacity);
}
}