mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
New classes for the generalized texturing
This commit is contained in:
parent
e1b67b15e0
commit
33ab16f7d7
@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigPipeInCellEvaluator.h"
|
||||
|
||||
#include "cvfVector2.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class RivResultToTextureMapper : public cvf::Object
|
||||
{
|
||||
public:
|
||||
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);
|
||||
|
||||
if (!m_pipeInCellEvaluator->isWellPipeInCell(cellIndex))
|
||||
{
|
||||
texCoord[1] = 0; // Set the Y texture coordinate to the opaque line in the texture
|
||||
}
|
||||
|
||||
return texCoord;
|
||||
}
|
||||
|
||||
private:
|
||||
cvf::cref<cvf::ScalarMapper> m_scalarMapper;
|
||||
cvf::cref<RigPipeInCellEvaluator> m_pipeInCellEvaluator;
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, 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 "RivTextureCoordsCreator.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RigPipeInCellEvaluator.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RigResultAccessor.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTextureCoordsCreator::RivTextureCoordsCreator(RimResultSlot* cellResultSlot, size_t timeStepIndex, size_t gridIndex, const cvf::StructGridQuadToCellFaceMapper* quadMapper)
|
||||
{
|
||||
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
|
||||
|
||||
m_quadMapper = quadMapper;
|
||||
CVF_ASSERT(quadMapper && eclipseCase );
|
||||
|
||||
size_t resTimeStepIdx = timeStepIndex;
|
||||
|
||||
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
|
||||
|
||||
m_resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, cellResultSlot->resultVariable());
|
||||
CVF_ASSERT(m_resultAccessor.notNull());
|
||||
|
||||
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator( cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
eclipseCase->gridCellToWellIndex(gridIndex));
|
||||
|
||||
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||
|
||||
m_texMapper = new RivResultToTextureMapper(mapper, pipeInCellEval.p());
|
||||
CVF_ASSERT(m_texMapper.notNull());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCoords, const cvf::StructGridQuadToCellFaceMapper* quadMapper, const RigResultAccessor* resultAccessor, const RivResultToTextureMapper* texMapper)
|
||||
{
|
||||
CVF_ASSERT(quadTextureCoords && quadMapper && resultAccessor && texMapper);
|
||||
|
||||
size_t numVertices = quadMapper->quadCount()*4;
|
||||
quadTextureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = quadTextureCoords->ptr();
|
||||
|
||||
double resultValue;
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, resultValue)
|
||||
for (int i = 0; i < static_cast<int>(quadMapper->quadCount()); i++)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType faceId = quadMapper->cellFace(i);
|
||||
size_t cellIdx = quadMapper->cellIndex(i);
|
||||
|
||||
resultValue = resultAccessor->cellFaceScalar(cellIdx, faceId);
|
||||
texCoord = texMapper->getTexCoord(resultValue, cellIdx);
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
rawPtr[i*4 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
62
ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h
Normal file
62
ApplicationCode/ModelVisualization/RivTextureCoordsCreator.h
Normal file
@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
class RimResultSlot;
|
||||
class RigResultAccessor;
|
||||
class RivResultToTextureMapper;
|
||||
|
||||
namespace cvf{
|
||||
class StructGridQuadToCellFaceMapper;
|
||||
|
||||
}
|
||||
|
||||
|
||||
class RivTextureCoordsCreator
|
||||
{
|
||||
public:
|
||||
RivTextureCoordsCreator(RimResultSlot* cellResultSlot,
|
||||
size_t timeStepIndex,
|
||||
size_t gridIndex,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
|
||||
|
||||
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
|
||||
{
|
||||
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const RivResultToTextureMapper* texMapper);
|
||||
|
||||
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
cvf::ref<RigResultAccessor> m_resultAccessor;
|
||||
cvf::ref<RivResultToTextureMapper> m_texMapper;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
52
ApplicationCode/ReservoirDataModel/RigPipeInCellEvaluator.h
Normal file
52
ApplicationCode/ReservoirDataModel/RigPipeInCellEvaluator.h
Normal file
@ -0,0 +1,52 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA, 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
class RigPipeInCellEvaluator: public cvf::Object
|
||||
{
|
||||
public:
|
||||
RigPipeInCellEvaluator(const std::vector<cvf::ubyte>& isWellPipeVisibleForWellIndex,
|
||||
const cvf::UIntArray* gridCellToWellIndexMap)
|
||||
: m_isWellPipeVisibleForWellIndex(isWellPipeVisibleForWellIndex),
|
||||
m_gridCellToWellIndexMap(gridCellToWellIndexMap)
|
||||
{
|
||||
}
|
||||
|
||||
bool isWellPipeInCell( size_t cellIndex) const
|
||||
{
|
||||
cvf::uint wellIndex = m_gridCellToWellIndexMap->get(cellIndex);
|
||||
|
||||
if (wellIndex == cvf::UNDEFINED_UINT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_isWellPipeVisibleForWellIndex[wellIndex];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const std::vector<cvf::ubyte>& m_isWellPipeVisibleForWellIndex;
|
||||
const cvf::UIntArray* m_gridCellToWellIndexMap;
|
||||
};
|
Loading…
Reference in New Issue
Block a user