mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-29 08:30:17 -05:00
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every use of cvfAssert.h. CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites become CAF_ASSERT( false && "message" ), preserving the message with the idiom already used elsewhere in the code base. Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0, CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0. Include handling: files that included cvfAssert.h directly now include cafAssert.h instead, includes left dead by the migration are removed, and files that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files that reach cafAssert.h through another caf header are left unchanged; a missing include here is a compile error, not a silently disabled assert. ResultStatisticsCache links only LibCore and therefore had no path to cafAssert.h. Add the cafPdmCore directory as a private include path rather than linking the library, since cafAssert.h is header only. Note that this stops these asserts from firing in Release and RelWithDebInfo, where CVF_ASSERT was previously active.
344 lines
12 KiB
C++
344 lines
12 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RivReservoirFaultsPartMgr.h"
|
|
|
|
#include "RiaResultNames.h"
|
|
|
|
#include "RigEclipseResultAddress.h"
|
|
#include "RigMainGrid.h"
|
|
#include "RigNNCData.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseCellColors.h"
|
|
#include "RimEclipseFaultColors.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimFaultInView.h"
|
|
#include "RimFaultInViewCollection.h"
|
|
|
|
#include "RivFaultPartMgr.h"
|
|
|
|
#include "cvfColor3.h"
|
|
#include "cvfModelBasicList.h"
|
|
#include "cvfPart.h"
|
|
#include "cvfTransform.h"
|
|
|
|
#include "cafPdmFieldCvfColor.h"
|
|
|
|
#include <QDebug>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr( const RigMainGrid* grid, RimEclipseView* reservoirView )
|
|
: m_reservoirView( reservoirView )
|
|
{
|
|
CAF_ASSERT( grid );
|
|
|
|
if ( reservoirView )
|
|
{
|
|
RimFaultInViewCollection* faultCollection = reservoirView->faultCollection();
|
|
if ( faultCollection )
|
|
{
|
|
for ( auto fault : faultCollection->faults() )
|
|
{
|
|
m_faultParts.push_back( new RivFaultPartMgr( grid, faultCollection, fault ) );
|
|
}
|
|
}
|
|
}
|
|
|
|
m_forceWatertightGeometry = false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RivReservoirFaultsPartMgr::~RivReservoirFaultsPartMgr()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::setTransform( cvf::Transform* scaleTransform )
|
|
{
|
|
m_scaleTransform = scaleTransform;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
|
|
{
|
|
CAF_ASSERT( cellVisibilities );
|
|
|
|
for ( auto& faultPart : m_faultParts )
|
|
{
|
|
faultPart->setCellVisibility( cellVisibilities );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
|
{
|
|
CAF_ASSERT( model != nullptr );
|
|
|
|
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
|
|
if ( !faultCollection ) return;
|
|
|
|
bool isShowingGrid = m_reservoirView->isMainGridVisible();
|
|
if ( !faultCollection->isActive() && !isShowingGrid ) return;
|
|
|
|
// Check match between model fault count and fault parts
|
|
CAF_ASSERT( faultCollection->faults().size() == m_faultParts.size() );
|
|
|
|
// Parts that is overridden by the grid settings
|
|
bool forceDisplayOfFault = false;
|
|
if ( faultCollection->shouldApplyCellFiltersToFaults() )
|
|
{
|
|
forceDisplayOfFault = isShowingGrid;
|
|
}
|
|
|
|
if ( m_forceWatertightGeometry && isShowingGrid )
|
|
{
|
|
forceDisplayOfFault = true;
|
|
}
|
|
|
|
cvf::ModelBasicList parts;
|
|
|
|
int i = 0;
|
|
for ( const auto rimFault : faultCollection->faults() )
|
|
{
|
|
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i++];
|
|
CAF_ASSERT( rivFaultPart.notNull() );
|
|
|
|
if ( ( faultCollection->isActive() && rimFault->showFault() ) || forceDisplayOfFault )
|
|
{
|
|
if ( faultCollection->showFaultFaces() || forceDisplayOfFault )
|
|
{
|
|
rivFaultPart->appendNativeFaultFacesToModel( &parts );
|
|
}
|
|
|
|
if ( faultCollection->showOppositeFaultFaces() || forceDisplayOfFault )
|
|
{
|
|
rivFaultPart->appendOppositeFaultFacesToModel( &parts );
|
|
}
|
|
|
|
if ( faultCollection->showFaultFaces() || faultCollection->showOppositeFaultFaces() || faultCollection->showNNCs() ||
|
|
forceDisplayOfFault )
|
|
{
|
|
rivFaultPart->appendMeshLinePartsToModel( &parts );
|
|
}
|
|
}
|
|
|
|
// Parts that is not overridden by the grid settings
|
|
RimEclipseFaultColors* faultResultColors = m_reservoirView->faultResultSettings();
|
|
RimEclipseCellColors* cellResultColors = m_reservoirView->cellResult();
|
|
|
|
if ( rimFault->showFault() && faultCollection->isActive() )
|
|
{
|
|
if ( faultCollection->showNNCs() )
|
|
{
|
|
bool showNncs = true;
|
|
bool showCompleteNncGeo = false;
|
|
|
|
RigEclipseResultAddress eclipseResultAddress;
|
|
if ( faultResultColors->showCustomFaultResult() )
|
|
{
|
|
eclipseResultAddress = faultResultColors->customFaultResult()->eclipseResultAddress();
|
|
}
|
|
else
|
|
{
|
|
eclipseResultAddress = cellResultColors->eclipseResultAddress();
|
|
}
|
|
|
|
if ( eclipseResultAddress.resultCatType() == RiaDefines::ResultCatType::ALLAN_DIAGRAMS )
|
|
{
|
|
showCompleteNncGeo = true;
|
|
}
|
|
|
|
{
|
|
QStringList stringsToMatch{ RiaResultNames::combinedRiTranResultName(),
|
|
RiaResultNames::combinedRiMultResultName(),
|
|
RiaResultNames::combinedRiAreaNormTranResultName(),
|
|
RiaResultNames::combinedTransmissibilityResultName(),
|
|
RiaResultNames::combinedMultResultName() };
|
|
|
|
for ( const auto& s : stringsToMatch )
|
|
{
|
|
if ( eclipseResultAddress.resultName().contains( s, Qt::CaseInsensitive ) )
|
|
{
|
|
showCompleteNncGeo = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( faultCollection->hideNNCsWhenNoResultIsAvailable() )
|
|
{
|
|
RigMainGrid* mainGrid = m_reservoirView->mainGrid();
|
|
if ( !( mainGrid && mainGrid->nncData()->hasScalarValues( eclipseResultAddress ) ) )
|
|
{
|
|
showNncs = false;
|
|
}
|
|
}
|
|
|
|
if ( showNncs )
|
|
{
|
|
RigMainGrid* mainGrid = m_reservoirView->mainGrid();
|
|
mainGrid->nncData()->ensureAllConnectionDataIsProcessed();
|
|
|
|
if ( showCompleteNncGeo )
|
|
{
|
|
rivFaultPart->appendCompleteNNCFacesToModel( &parts );
|
|
}
|
|
else
|
|
{
|
|
rivFaultPart->appendNativeNNCFacesToModel( &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::applySingleColorEffect()
|
|
{
|
|
for ( auto& faultPart : m_faultParts )
|
|
{
|
|
faultPart->applySingleColorEffect();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::updateColors( size_t timeStepIndex, RimEclipseCellColors* cellResultColors )
|
|
{
|
|
if ( !m_reservoirView ) return;
|
|
|
|
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
|
|
CAF_ASSERT( faultCollection );
|
|
|
|
for ( auto& faultPart : m_faultParts )
|
|
{
|
|
if ( cellResultColors && ( cellResultColors->hasResult() || cellResultColors->isTernarySaturationSelected() ) )
|
|
{
|
|
faultPart->updateCellResultColor( timeStepIndex, cellResultColors );
|
|
}
|
|
else
|
|
{
|
|
faultPart->applySingleColorEffect();
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::updateCellEdgeResultColor( size_t timeStepIndex,
|
|
RimEclipseCellColors* cellResultColors,
|
|
RimCellEdgeColors* cellEdgeResultColors )
|
|
{
|
|
for ( auto& faultPart : m_faultParts )
|
|
{
|
|
faultPart->updateCellEdgeResultColor( timeStepIndex, cellResultColors, cellEdgeResultColors );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::appendLabelPartsToModel( cvf::ModelBasicList* model )
|
|
{
|
|
CAF_ASSERT( model != nullptr );
|
|
if ( !m_reservoirView ) return;
|
|
|
|
RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection();
|
|
CAF_ASSERT( faultCollection );
|
|
|
|
if ( !faultCollection->isActive() ) return;
|
|
|
|
if ( !faultCollection->showFaultLabel() ) return;
|
|
|
|
// Check match between model fault count and fault parts
|
|
CAF_ASSERT( faultCollection->faults().size() == m_faultParts.size() );
|
|
|
|
cvf::ModelBasicList parts;
|
|
|
|
int i = 0;
|
|
for ( const auto rimFault : faultCollection->faults() )
|
|
{
|
|
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i++];
|
|
CAF_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;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::clearWatertightGeometryFlag()
|
|
{
|
|
m_forceWatertightGeometry = false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivReservoirFaultsPartMgr::setOpacityLevel( float opacity )
|
|
{
|
|
for ( auto& faultPart : m_faultParts )
|
|
{
|
|
faultPart->setOpacityLevel( opacity );
|
|
}
|
|
}
|