diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 6213d8535b..03c8d21e92 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -23,6 +23,8 @@ ${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.h ${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.h ${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h ${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h +${CEE_CURRENT_LIST_DIR}RivCompletionTypeResultToTextureMapper.h +${CEE_CURRENT_LIST_DIR}RivDefaultResultToTextureMapper.h ${CEE_CURRENT_LIST_DIR}RivTernaryResultToTextureMapper.h ${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.h ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.h diff --git a/ApplicationCode/ModelVisualization/RivCompletionTypeResultToTextureMapper.h b/ApplicationCode/ModelVisualization/RivCompletionTypeResultToTextureMapper.h new file mode 100644 index 0000000000..9dcf297a4e --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivCompletionTypeResultToTextureMapper.h @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RivResultToTextureMapper.h" + +#include "RigPipeInCellEvaluator.h" + +#include "cvfVector2.h" +#include "cvfScalarMapper.h" +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfStructGrid.h" + +#include + +class RivCompletionTypeResultToTextureMapper : public RivResultToTextureMapper +{ +public: + using RivResultToTextureMapper::RivResultToTextureMapper; + + cvf::Vec2f getTexCoord(double resultValue, size_t cellIndex) const + { + cvf::Vec2f texCoord(0, 0); + + if (resultValue == HUGE_VAL || resultValue != resultValue) // a != a is true for NAN's + { + if (m_pipeInCellEvaluator->isWellPipeInCell(cellIndex)) + { + texCoord[1] = 0.5f; + } + else + { + texCoord[1] = 1.0f; + } + return texCoord; + } + + texCoord = m_scalarMapper->mapToTextureCoord(resultValue); + texCoord[1] = 0.5f; + + return texCoord; + } +}; + + diff --git a/ApplicationCode/ModelVisualization/RivDefaultResultToTextureMapper.h b/ApplicationCode/ModelVisualization/RivDefaultResultToTextureMapper.h new file mode 100644 index 0000000000..3dfe032e03 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivDefaultResultToTextureMapper.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RigPipeInCellEvaluator.h" +#include "RivResultToTextureMapper.h" + +#include "cvfVector2.h" +#include "cvfScalarMapper.h" +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfStructGrid.h" + +#include + +class RivDefaultResultToTextureMapper : public RivResultToTextureMapper +{ +public: + using RivResultToTextureMapper::RivResultToTextureMapper; + + cvf::Vec2f getTexCoord(double resultValue, size_t cellIndex) const + { + cvf::Vec2f texCoord(0,0); + + if (resultValue == HUGE_VAL || resultValue != resultValue) // a != a is true for NAN's + { + texCoord[1] = 1.0f; + return texCoord; + } + + texCoord = m_scalarMapper->mapToTextureCoord(resultValue); + + if (!m_pipeInCellEvaluator->isWellPipeInCell(cellIndex)) + { + texCoord[1] = 0; // Set the Y texture coordinate to the opaque line in the texture + } + + return texCoord; + } +}; + + diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index dc57e4e516..e8f9c15b01 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -44,6 +44,7 @@ #include "RivTernaryScalarMapperEffectGenerator.h" #include "RivTernaryTextureCoordsCreator.h" #include "RivTextureCoordsCreator.h" +#include "RivCompletionTypeResultToTextureMapper.h" #include "cafEffectGenerator.h" #include "cafPdmFieldCvfColor.h" @@ -260,18 +261,17 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellC return; } - texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); - if (cellResultColors->isCompletionTypeSelected()) { - cvf::Vec2fArray& surfaceCoords = *m_surfaceFacesTextureCoords.p(); - for (cvf::Vec2f& vec : surfaceCoords) - { - vec[1] = 0.5; - } + cvf::ref pipeInCellEval = RivTextureCoordsCreator::createPipeInCellEvaluator(cellResultColors, timeStepIndex, m_grid->gridIndex()); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + + texturer.setResultToTextureMapper(new RivCompletionTypeResultToTextureMapper(mapper, pipeInCellEval.p())); m_opacityLevel = 0.5; } + texturer.createTextureCoords(m_surfaceFacesTextureCoords.p()); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), diff --git a/ApplicationCode/ModelVisualization/RivResultToTextureMapper.h b/ApplicationCode/ModelVisualization/RivResultToTextureMapper.h index e70ac7d6f3..52ee510106 100644 --- a/ApplicationCode/ModelVisualization/RivResultToTextureMapper.h +++ b/ApplicationCode/ModelVisualization/RivResultToTextureMapper.h @@ -32,32 +32,14 @@ class RivResultToTextureMapper : public cvf::Object { public: - RivResultToTextureMapper(const cvf::ScalarMapper* scalarMapper, + explicit RivResultToTextureMapper(const cvf::ScalarMapper* scalarMapper, const RigPipeInCellEvaluator* pipeInCellEvaluator) : m_scalarMapper(scalarMapper), m_pipeInCellEvaluator(pipeInCellEvaluator) {} - - cvf::Vec2f getTexCoord(double resultValue, size_t cellIndex) const - { - cvf::Vec2f texCoord(0,0); - if (resultValue == HUGE_VAL || resultValue != resultValue) // a != a is true for NAN's - { - texCoord[1] = 1.0f; - return texCoord; - } - - texCoord = m_scalarMapper->mapToTextureCoord(resultValue); + virtual cvf::Vec2f getTexCoord(double resultValue, size_t cellIndex) const = 0; - if (!m_pipeInCellEvaluator->isWellPipeInCell(cellIndex)) - { - texCoord[1] = 0; // Set the Y texture coordinate to the opaque line in the texture - } - - return texCoord; - } - -private: +protected: cvf::cref m_scalarMapper; cvf::cref m_pipeInCellEvaluator; }; diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp index 5403cfa84a..855ada5898 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp @@ -31,6 +31,7 @@ #include "RimLegendConfig.h" #include "RivResultToTextureMapper.h" +#include "RivDefaultResultToTextureMapper.h" #include "cvfStructGridGeometryGenerator.h" @@ -47,13 +48,11 @@ RivTextureCoordsCreator::RivTextureCoordsCreator(RimEclipseCellColors* cellResul m_resultAccessor = RigResultAccessorFactory::createFromResultDefinition(eclipseCase, gridIndex, timeStepIndex, cellResultColors); - cvf::ref pipeInCellEval = - new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->resultWellGeometryVisibilities(timeStepIndex), - eclipseCase->gridCellToResultWellIndex(gridIndex)); + cvf::ref pipeInCellEval = createPipeInCellEvaluator(cellResultColors, timeStepIndex, gridIndex); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - m_texMapper = new RivResultToTextureMapper(mapper, pipeInCellEval.p()); + m_texMapper = new RivDefaultResultToTextureMapper(mapper, pipeInCellEval.p()); CVF_ASSERT(m_texMapper.notNull()); } @@ -78,6 +77,23 @@ void RivTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCo createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTextureCoordsCreator::setResultToTextureMapper(RivResultToTextureMapper* textureMapper) +{ + m_texMapper = textureMapper; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigPipeInCellEvaluator * RivTextureCoordsCreator::createPipeInCellEvaluator(RimEclipseCellColors* cellColors, size_t timeStep, size_t gridIndex) +{ + return new RigPipeInCellEvaluator(cellColors->reservoirView()->wellCollection()->resultWellGeometryVisibilities(timeStep), + cellColors->reservoirView()->eclipseCase()->eclipseCaseData()->gridCellToResultWellIndex(gridIndex)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h index 9394a8b551..898c4fdf41 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h @@ -26,6 +26,7 @@ class RimEclipseCellColors; class RigResultAccessor; class RivResultToTextureMapper; +class RigPipeInCellEvaluator; namespace cvf { @@ -44,6 +45,9 @@ public: bool isValid(); void createTextureCoords(cvf::Vec2fArray* quadTextureCoords); + void setResultToTextureMapper(RivResultToTextureMapper* textureMapper); + + static RigPipeInCellEvaluator* createPipeInCellEvaluator(RimEclipseCellColors* cellColors, size_t timeStep, size_t gridIndex); private: @@ -52,7 +56,7 @@ private: const RigResultAccessor* resultAccessor, const RivResultToTextureMapper* texMapper); cvf::cref m_quadMapper; - cvf::ref m_resultAccessor; + cvf::ref m_resultAccessor; cvf::ref m_texMapper; };