mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00: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.
214 lines
11 KiB
C++
214 lines
11 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 "RivTernaryTextureCoordsCreator.h"
|
|
|
|
#include "RiaResultNames.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
#include "RigEclipseCaseData.h"
|
|
#include "RigEclipseResultAddress.h"
|
|
#include "RigResultAccessorFactory.h"
|
|
#include "RigTernaryResultAccessor.h"
|
|
#include "Well/RigPipeInCellEvaluator.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseResultDefinition.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimSimWellInViewCollection.h"
|
|
#include "RimTernaryLegendConfig.h"
|
|
|
|
#include "RivTernaryResultToTextureMapper.h"
|
|
#include "RivTernaryScalarMapper.h"
|
|
|
|
#include "cvfStructGridGeometryGenerator.h"
|
|
|
|
#include "cafAssert.h"
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
|
|
RimTernaryLegendConfig* ternaryLegendConfig,
|
|
RimSimWellInViewCollection* simWellInViewCollection,
|
|
size_t timeStepIndex,
|
|
size_t gridIndex,
|
|
const cvf::StructGridQuadToCellFaceMapper* quadMapper )
|
|
{
|
|
CAF_ASSERT( quadMapper );
|
|
m_quadMapper = quadMapper;
|
|
|
|
RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
|
|
|
|
size_t resTimeStepIdx = timeStepIndex;
|
|
|
|
if ( cellResultColors->hasStaticResult() ) resTimeStepIdx = 0;
|
|
|
|
RiaDefines::PorosityModelType porosityModel = cellResultColors->porosityModel();
|
|
|
|
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::soil() ) );
|
|
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::sgas() ) );
|
|
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::swat() ) );
|
|
|
|
m_resultAccessor = new RigTernaryResultAccessor();
|
|
m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() );
|
|
|
|
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval =
|
|
new RigPipeInCellEvaluator( simWellInViewCollection->resultWellGeometryVisibilities( timeStepIndex ),
|
|
eclipseCase->gridCellToResultWellIndex( gridIndex ) );
|
|
|
|
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
|
|
|
|
m_texMapper = new RivTernaryResultToTextureMapper( mapper, pipeInCellEval.p() );
|
|
CAF_ASSERT( m_texMapper.notNull() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
|
|
const RivTernaryScalarMapper* ternaryColorMapper,
|
|
size_t timeStepIndex )
|
|
: m_quadMapper( nullptr )
|
|
{
|
|
RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
|
|
|
|
size_t resTimeStepIdx = timeStepIndex;
|
|
|
|
if ( cellResultColors->hasStaticResult() ) resTimeStepIdx = 0;
|
|
|
|
RiaDefines::PorosityModelType porosityModel = cellResultColors->porosityModel();
|
|
|
|
size_t gridIndex = 0;
|
|
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::soil() ) );
|
|
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::sgas() ) );
|
|
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createFromResultAddress( eclipseCase,
|
|
gridIndex,
|
|
porosityModel,
|
|
resTimeStepIdx,
|
|
RigEclipseResultAddress( RiaResultNames::swat() ) );
|
|
|
|
m_resultAccessor = new RigTernaryResultAccessor();
|
|
m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() );
|
|
|
|
// Create a texture mapper without detecting transparency using RigPipeInCellEvaluator
|
|
m_texMapper = new RivTernaryResultToTextureMapper( ternaryColorMapper, nullptr );
|
|
CAF_ASSERT( m_texMapper.notNull() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivTernaryTextureCoordsCreator::createTextureCoords( cvf::Vec2fArray* quadTextureCoords )
|
|
{
|
|
CAF_ASSERT( m_quadMapper.notNull() );
|
|
createTextureCoords( quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivTernaryTextureCoordsCreator::createTextureCoords( cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx )
|
|
{
|
|
CAF_ASSERT( m_quadMapper.isNull() );
|
|
|
|
createTextureCoords( triTextureCoords, triangleToCellIdx, m_resultAccessor.p(), m_texMapper.p() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivTernaryTextureCoordsCreator::createTextureCoords( cvf::Vec2fArray* quadTextureCoords,
|
|
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
|
|
const RigTernaryResultAccessor* resultAccessor,
|
|
const RivTernaryResultToTextureMapper* texMapper )
|
|
{
|
|
CAF_ASSERT( quadTextureCoords && quadMapper && resultAccessor && texMapper );
|
|
|
|
size_t numVertices = quadMapper->quadCount() * 4;
|
|
quadTextureCoords->resize( numVertices );
|
|
cvf::Vec2f* rawPtr = quadTextureCoords->ptr();
|
|
|
|
#pragma omp parallel for
|
|
for ( int i = 0; i < static_cast<int>( quadMapper->quadCount() ); i++ )
|
|
{
|
|
cvf::StructGridInterface::FaceType faceId = quadMapper->cellFace( i );
|
|
size_t cellIdx = quadMapper->cellIndex( i );
|
|
|
|
cvf::Vec2d resultValue = resultAccessor->cellFaceScalar( cellIdx, faceId );
|
|
cvf::Vec2f texCoord = texMapper->getTexCoord( resultValue.x(), resultValue.y(), cellIdx );
|
|
|
|
size_t j;
|
|
for ( j = 0; j < 4; j++ )
|
|
{
|
|
rawPtr[i * 4 + j] = texCoord;
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RivTernaryTextureCoordsCreator::createTextureCoords( cvf::Vec2fArray* textureCoords,
|
|
const std::vector<size_t>& triangleToCellIdx,
|
|
const RigTernaryResultAccessor* resultAccessor,
|
|
const RivTernaryResultToTextureMapper* texMapper )
|
|
{
|
|
CAF_ASSERT( textureCoords && resultAccessor && texMapper );
|
|
|
|
size_t numVertices = triangleToCellIdx.size() * 3;
|
|
textureCoords->resize( numVertices );
|
|
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
|
|
|
#pragma omp parallel for
|
|
for ( int i = 0; i < static_cast<int>( triangleToCellIdx.size() ); i++ )
|
|
{
|
|
size_t cellIdx = triangleToCellIdx[i];
|
|
|
|
cvf::Vec2d resultValue = resultAccessor->cellScalarGlobIdx( cellIdx );
|
|
cvf::Vec2f texCoord = texMapper->getTexCoord( resultValue.x(), resultValue.y(), cellIdx );
|
|
|
|
size_t j;
|
|
for ( j = 0; j < 3; j++ )
|
|
{
|
|
rawPtr[i * 3 + j] = texCoord;
|
|
}
|
|
}
|
|
}
|