mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #203 from OPM/dev-Summer2014
Update dev from dev-Summer2014
This commit is contained in:
commit
a3ab2bdec4
@ -73,6 +73,8 @@ bool readDoubleValues(RigCaseData* reservoir, size_t resultIndex, ecl_kw_type* e
|
||||
newPropertyData.push_back(std::vector<double>());
|
||||
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
|
||||
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -110,6 +112,8 @@ bool readDoubleValuesForActiveCells(RigCaseData* reservoir, size_t resultIndex,
|
||||
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
|
||||
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,8 +78,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
size_t gridIndex,
|
||||
float opacityLevel)
|
||||
{
|
||||
const std::vector<size_t>& quadToCell = generator->quadToGridCellIndices();
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadToFace = generator->quadToFace();
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadToCellFace = generator->quadToCellFaceMapper();
|
||||
|
||||
size_t vertexCount = geo->vertexArray()->size();
|
||||
size_t quadCount = vertexCount / 4;
|
||||
@ -166,13 +165,13 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
localCoords->set(quadIdx * 4 + 2, cvf::Vec2f(1, 1));
|
||||
localCoords->set(quadIdx * 4 + 3, cvf::Vec2f(0, 1));
|
||||
|
||||
faceIndexArray->set(quadIdx * 4 + 0, quadToFace[quadIdx] );
|
||||
faceIndexArray->set(quadIdx * 4 + 1, quadToFace[quadIdx] );
|
||||
faceIndexArray->set(quadIdx * 4 + 2, quadToFace[quadIdx] );
|
||||
faceIndexArray->set(quadIdx * 4 + 3, quadToFace[quadIdx] );
|
||||
faceIndexArray->set(quadIdx * 4 + 0, quadToCellFace->cellFace(quadIdx) );
|
||||
faceIndexArray->set(quadIdx * 4 + 1, quadToCellFace->cellFace(quadIdx) );
|
||||
faceIndexArray->set(quadIdx * 4 + 2, quadToCellFace->cellFace(quadIdx) );
|
||||
faceIndexArray->set(quadIdx * 4 + 3, quadToCellFace->cellFace(quadIdx) );
|
||||
|
||||
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
|
||||
size_t cellIndex = quadToCell[quadIdx];
|
||||
size_t cellIndex = quadToCellFace->cellIndex(quadIdx);
|
||||
|
||||
{
|
||||
double scalarValue = HUGE_VAL;
|
||||
|
@ -43,7 +43,64 @@ public:
|
||||
float opacityLevel);
|
||||
};
|
||||
|
||||
/*
|
||||
Thoughts on organizing the texture coords generation a bit.
|
||||
|
||||
Conceptually several mappings takes place:
|
||||
|
||||
1. ResultValues to ResultPointValues <-- Eg. Cell Center values to CellFace Values
|
||||
2. ResultPointValues to GeometryPointValues <-- Eg. CellCenter Values to Triangle Vertex
|
||||
3. GeometryPointValues to TextureCoordinates/Colors <-- Handled by ScalarMapper
|
||||
|
||||
When evaluating, we normally use the geometry as starting point, as that often is
|
||||
a subset of the total results/geometry domain.
|
||||
|
||||
To make this efficient, a minimum of internal storage should be used, so we want
|
||||
to make the mappings as a set of functions called for each (or a few) texture
|
||||
coordinate positions
|
||||
|
||||
The mapping is then actually accessed in the opposite way of the above, while calculated in the 1-3 order
|
||||
|
||||
Accessing correct values:
|
||||
GeometryPointIdx->ResultPointIdx->ResultValueIdx
|
||||
Calculating color:
|
||||
ResultValue->ResultPointValue->GeometryPointValue->Texture/ColorValue
|
||||
|
||||
In ResInsight (for now)
|
||||
the ResultPointValue will be the same for all the corresponding GeometryPoints,
|
||||
which means each quadvertex has the same texcoord for all corners.
|
||||
|
||||
Proposal:
|
||||
----------
|
||||
Let the FaceValue to Face vertex texture coordinate mapping be the same for all.
|
||||
Extract that from the code floating around.
|
||||
|
||||
Create a PrimitiveFaceIdx to CellIdx with Face mapper class that handles the lookup,
|
||||
created by the geometry generation
|
||||
|
||||
Create separate calculators/mappers/Strategies to create FaceValues from results.
|
||||
|
||||
Test Code
|
||||
-----------
|
||||
// Example code
|
||||
// 1. CellCenterToCellFace
|
||||
// 2. CellFace to Quad Corners
|
||||
// 3. Quad Corner Values to tex coords
|
||||
|
||||
texCoords.resize(m_quadsToGridCells.size()*4);
|
||||
for (i = 0; i < m_quadsToGridCells.size(); ++i)
|
||||
{
|
||||
cvf::Vec2f texCoord = scalarMapper->mapToTextureCoord(dataAccessObject->cellScalar(m_quadsToGridCells[i]));
|
||||
ResValue ResPoint To ResValue
|
||||
texCoords[i*4 + 0] = texCoord;
|
||||
texCoords[i*4 + 1] = texCoord;
|
||||
texCoords[i*4 + 2] = texCoord;
|
||||
texCoords[i*4 + 3] = texCoord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfOutlineEdgeExtractor.h"
|
||||
#include "cvfStructGridScalarDataAccess.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include "RigFault.h"
|
||||
@ -38,6 +40,8 @@ RivFaultGeometryGenerator::RivFaultGeometryGenerator(const cvf::StructGridInterf
|
||||
m_fault(fault),
|
||||
m_computeNativeFaultFaces(computeNativeFaultFaces)
|
||||
{
|
||||
m_quadMapper = new cvf::StructGridQuadToCellFaceMapper;
|
||||
m_triangleMapper = new cvf::StuctGridTriangleToCellFaceMapper(m_quadMapper.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -149,8 +153,8 @@ cvf::ref<cvf::UIntArray> RivFaultGeometryGenerator::lineIndicesFromQuadVertexArr
|
||||
void RivFaultGeometryGenerator::computeArrays()
|
||||
{
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
m_quadsToGridCells.clear();
|
||||
m_quadsToFace.clear();
|
||||
m_quadMapper->quadToCellIndexMap().clear();
|
||||
m_quadMapper->quadToCellFaceMap().clear();
|
||||
|
||||
cvf::Vec3d offset = m_grid->displayModelOffset();
|
||||
|
||||
@ -186,8 +190,8 @@ void RivFaultGeometryGenerator::computeArrays()
|
||||
}
|
||||
|
||||
// Keep track of the source cell index per quad
|
||||
m_quadsToGridCells.push_back(cellIndex);
|
||||
m_quadsToFace.push_back(face);
|
||||
m_quadMapper->quadToCellIndexMap().push_back(cellIndex);
|
||||
m_quadMapper->quadToCellFaceMap().push_back(face);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +207,7 @@ void RivFaultGeometryGenerator::textureCoordinates(cvf::Vec2fArray* textureCoord
|
||||
{
|
||||
if (!dataAccessObject) return;
|
||||
|
||||
size_t numVertices = m_quadsToGridCells.size()*4;
|
||||
size_t numVertices = m_quadMapper->quadCount()*4;
|
||||
|
||||
textureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
@ -212,9 +216,9 @@ void RivFaultGeometryGenerator::textureCoordinates(cvf::Vec2fArray* textureCoord
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, cellScalarValue)
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
|
||||
for (int i = 0; i < static_cast<int>(m_quadMapper->quadCount()); i++)
|
||||
{
|
||||
cellScalarValue = dataAccessObject->cellScalar(m_quadsToGridCells[i]);
|
||||
cellScalarValue = dataAccessObject->cellScalar(m_quadMapper->cellIndex(i));
|
||||
texCoord = mapper->mapToTextureCoord(cellScalarValue);
|
||||
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
|
||||
{
|
||||
@ -229,38 +233,6 @@ void RivFaultGeometryGenerator::textureCoordinates(cvf::Vec2fArray* textureCoord
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Array<size_t> > RivFaultGeometryGenerator::triangleToSourceGridCellMap() const
|
||||
{
|
||||
cvf::ref<cvf::Array<size_t> > triangles = new cvf::Array<size_t>(2*m_quadsToGridCells.size());
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
|
||||
{
|
||||
triangles->set(i*2, m_quadsToGridCells[i]);
|
||||
triangles->set(i*2+1, m_quadsToGridCells[i]);
|
||||
}
|
||||
|
||||
return triangles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> > RivFaultGeometryGenerator::triangleToFaceType() const
|
||||
{
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> > triangles = new cvf::Array<cvf::StructGridInterface::FaceType>(2*m_quadsToFace.size());
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToFace.size()); i++)
|
||||
{
|
||||
triangles->set(i*2, m_quadsToFace[i]);
|
||||
triangles->set(i*2+1, m_quadsToFace[i]);
|
||||
}
|
||||
|
||||
return triangles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -268,20 +240,3 @@ void RivFaultGeometryGenerator::setCellVisibility(const cvf::UByteArray* cellVis
|
||||
{
|
||||
m_cellVisibility = cellVisibility;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivFaultGeometryGenerator::quadToGridCellIndices() const
|
||||
{
|
||||
return m_quadsToGridCells;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& RivFaultGeometryGenerator::quadToFace() const
|
||||
{
|
||||
return m_quadsToFace;
|
||||
}
|
||||
|
||||
|
@ -52,11 +52,9 @@ public:
|
||||
const cvf::ScalarMapper* mapper) const;
|
||||
|
||||
// Mapping between cells and geometry
|
||||
cvf::ref<cvf::Array<size_t> > triangleToSourceGridCellMap() const;
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> > triangleToFaceType() const;
|
||||
|
||||
const std::vector<size_t>& quadToGridCellIndices() const;
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadToFace() const;
|
||||
const cvf::StructGridQuadToCellFaceMapper * cellFromQuadMapper() { return m_quadMapper.p(); }
|
||||
const cvf::StuctGridTriangleToCellFaceMapper * cellFromTriangleMapper() { return m_triangleMapper.p(); }
|
||||
|
||||
// Generated geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
@ -70,18 +68,19 @@ private:
|
||||
|
||||
private:
|
||||
// Input
|
||||
cvf::cref<cvf::StructGridInterface> m_grid;
|
||||
cvf::cref<RigFault> m_fault;
|
||||
cvf::cref<cvf::UByteArray> m_cellVisibility;
|
||||
cvf::cref<cvf::StructGridInterface> m_grid;
|
||||
cvf::cref<RigFault> m_fault;
|
||||
cvf::cref<cvf::UByteArray> m_cellVisibility;
|
||||
|
||||
bool m_computeNativeFaultFaces;
|
||||
bool m_computeNativeFaultFaces;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||
|
||||
// Mappings
|
||||
std::vector<size_t> m_triangleIndexToGridCellIndex;
|
||||
std::vector<size_t> m_quadsToGridCells;
|
||||
std::vector<size_t> m_quadsToGridCells;
|
||||
std::vector<cvf::StructGridInterface::FaceType> m_quadsToFace;
|
||||
std::vector<cvf::StructGridInterface::FaceType> m_triangleToFace;
|
||||
|
||||
cvf::ref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
cvf::ref<cvf::StuctGridTriangleToCellFaceMapper> m_triangleMapper;
|
||||
};
|
||||
|
@ -126,17 +126,15 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
surfaceFacesColorArray = new cvf::Color3ubArray;
|
||||
|
||||
const std::vector<size_t>& quadsToGridCells = m_nativeFaultGenerator->quadToGridCellIndices();
|
||||
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(),
|
||||
surfaceFacesColorArray.p(), m_nativeFaultGenerator->cellFromQuadMapper());
|
||||
}
|
||||
else if (cellResultSlot->resultVariable().compare(RimDefines::combinedTransmissibilityResultName(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadsToFaceTypes = m_nativeFaultGenerator->quadToFace();
|
||||
const std::vector<size_t>& quadsToGridCells = m_nativeFaultGenerator->quadToGridCellIndices();
|
||||
cvf::Vec2fArray* textureCoords = m_nativeFaultFacesTextureCoords.p();
|
||||
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords, quadsToFaceTypes, quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords,
|
||||
m_nativeFaultGenerator->cellFromQuadMapper());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,14 +150,15 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
|
||||
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
|
||||
const std::vector<size_t>& quadsToGridCells = m_nativeFaultGenerator->quadToGridCellIndices();
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadsToGridCells = m_nativeFaultGenerator->cellFromQuadMapper();
|
||||
|
||||
for(size_t i = 0; i < m_nativeFaultFacesTextureCoords->size(); ++i)
|
||||
{
|
||||
if ((*m_nativeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
|
||||
|
||||
size_t quadIdx = i/4;
|
||||
size_t cellIndex = quadsToGridCells[quadIdx];
|
||||
size_t cellIndex = quadsToGridCells->cellIndex(quadIdx);
|
||||
|
||||
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
@ -202,17 +201,13 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
surfaceFacesColorArray = new cvf::Color3ubArray;
|
||||
|
||||
const std::vector<size_t>& quadsToGridCells = m_oppositeFaultGenerator->quadToGridCellIndices();
|
||||
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), m_oppositeFaultGenerator->cellFromQuadMapper());
|
||||
}
|
||||
else if (cellResultSlot->resultVariable().compare(RimDefines::combinedTransmissibilityResultName(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadsToFaceTypes = m_oppositeFaultGenerator->quadToFace();
|
||||
const std::vector<size_t>& quadsToGridCells = m_oppositeFaultGenerator->quadToGridCellIndices();
|
||||
cvf::Vec2fArray* textureCoords = m_oppositeFaultFacesTextureCoords.p();
|
||||
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords, quadsToFaceTypes, quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords, m_oppositeFaultGenerator->cellFromQuadMapper());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -228,14 +223,14 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
|
||||
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
|
||||
const std::vector<size_t>& quadsToGridCells = m_oppositeFaultGenerator->quadToGridCellIndices();
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadsToGridCells = m_oppositeFaultGenerator->cellFromQuadMapper();
|
||||
|
||||
for(size_t i = 0; i < m_oppositeFaultFacesTextureCoords->size(); ++i)
|
||||
{
|
||||
if ((*m_oppositeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
|
||||
|
||||
size_t quadIdx = i/4;
|
||||
size_t cellIndex = quadsToGridCells[quadIdx];
|
||||
size_t cellIndex = quadsToGridCells->cellIndex(quadIdx);
|
||||
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
@ -311,8 +306,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = m_nativeFaultGenerator->triangleToSourceGridCellMap().p();
|
||||
si->m_faceTypes = m_nativeFaultGenerator->triangleToFaceType().p();
|
||||
si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->cellFromTriangleMapper();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
@ -365,8 +359,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = m_oppositeFaultGenerator->triangleToSourceGridCellMap().p();
|
||||
si->m_faceTypes = m_oppositeFaultGenerator->triangleToFaceType().p();
|
||||
si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->cellFromTriangleMapper();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
@ -123,8 +123,8 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = geoBuilder.triangleToSourceGridCellMap().p();
|
||||
si->m_faceTypes = geoBuilder.triangleToFaceTypes().p();
|
||||
si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper();
|
||||
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
@ -269,17 +269,12 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
{
|
||||
surfaceFacesColorArray = new cvf::Color3ubArray;
|
||||
|
||||
const std::vector<size_t>& quadsToGridCells = m_surfaceGenerator.quadToGridCellIndices();
|
||||
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateTernarySaturationColorArray(timeStepIndex, cellResultSlot, m_grid.p(), surfaceFacesColorArray.p(), m_surfaceGenerator.quadToCellFaceMapper());
|
||||
}
|
||||
else if (cellResultSlot->resultVariable().compare(RimDefines::combinedTransmissibilityResultName(), Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadsToFaceTypes = m_surfaceGenerator.quadToFace();
|
||||
const std::vector<size_t>& quadsToGridCells = m_surfaceGenerator.quadToGridCellIndices();
|
||||
cvf::Vec2fArray* textureCoords = m_surfaceFacesTextureCoords.p();
|
||||
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords, quadsToFaceTypes, quadsToGridCells);
|
||||
RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(cellResultSlot, m_grid.p(), textureCoords, m_surfaceGenerator.quadToCellFaceMapper());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -296,36 +291,16 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
m_surfaceGenerator.textureCoordinates(m_surfaceFacesTextureCoords.p(), dataAccessObject.p(), mapper);
|
||||
}
|
||||
|
||||
// if this gridpart manager is set to have some transparency, we
|
||||
// interpret it as we are displaying beeing wellcells. The cells are then transparent by default, but
|
||||
// we turn that off for particular cells, if the well pipe is not shown for that cell
|
||||
|
||||
if (m_opacityLevel < 1.0f )
|
||||
{
|
||||
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
|
||||
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
|
||||
const std::vector<size_t>& quadsToGridCells = m_surfaceGenerator.quadToGridCellIndices();
|
||||
setResultsTransparentForWellCells(
|
||||
cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
eclipseCase->gridCellToWellIndex(m_grid->gridIndex()),
|
||||
m_surfaceGenerator.quadToCellFaceMapper(),
|
||||
m_surfaceFacesTextureCoords.p());
|
||||
|
||||
for(size_t i = 0; i < m_surfaceFacesTextureCoords->size(); ++i)
|
||||
{
|
||||
if ((*m_surfaceFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
|
||||
|
||||
size_t quadIdx = i/4;
|
||||
size_t cellIndex = quadsToGridCells[quadIdx];
|
||||
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
if ( !isWellPipeVisible[wellIndex])
|
||||
{
|
||||
(*m_surfaceFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
|
||||
if (surfaceFacesColorArray.notNull())
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
|
||||
if (dg)
|
||||
{
|
||||
dg->setColorArray(surfaceFacesColorArray.p());
|
||||
@ -338,19 +313,7 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dg)
|
||||
{
|
||||
dg->setTextureCoordArray(m_surfaceFacesTextureCoords.p());
|
||||
}
|
||||
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
|
||||
scalarEffgen.setOpacityLevel(m_opacityLevel);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
|
||||
m_surfaceFaces->setEffect(scalarEffect.p());
|
||||
applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper );
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,40 +332,70 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
|
||||
m_faultGenerator.textureCoordinates(m_faultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
|
||||
|
||||
if (m_opacityLevel < 1.0f )
|
||||
setResultsTransparentForWellCells(
|
||||
cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
|
||||
eclipseCase->gridCellToWellIndex(m_grid->gridIndex()),
|
||||
m_surfaceGenerator.quadToCellFaceMapper(),
|
||||
m_faultFacesTextureCoords.p());
|
||||
|
||||
|
||||
applyTextureResultsToPart(m_faultFaces.p(), m_faultFacesTextureCoords.p(), mapper);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
cvf::ref<cvf::Effect> RivGridPartMgr::createScalarMapperEffect(const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
scalarEffgen.setOpacityLevel(m_opacityLevel);
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
return scalarEffect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
void RivGridPartMgr::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
||||
if (dg) dg->setTextureCoordArray(textureCoords);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = createScalarMapperEffect(mapper);
|
||||
part->setEffect(scalarEffect.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// if this gridpart manager is set to have some transparency, we
|
||||
/// interpret it as we are displaying beeing wellcells. The cells are then transparent by default, but
|
||||
/// we turn that off for particular cells, if the well pipe is not shown for that cell
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridPartMgr::setResultsTransparentForWellCells(const std::vector<cvf::ubyte>& isWellPipeVisibleForWellIndex,
|
||||
const cvf::UIntArray* gridCellToWellIndexMap,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadsToCellFaceMapper,
|
||||
cvf::Vec2fArray* resultTextureCoords)
|
||||
{
|
||||
if (m_opacityLevel < 1.0f )
|
||||
{
|
||||
for(size_t i = 0; i < resultTextureCoords->size(); ++i)
|
||||
{
|
||||
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
|
||||
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
|
||||
const std::vector<size_t>& quadsToGridCells = m_faultGenerator.quadToGridCellIndices();
|
||||
if ((*resultTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
|
||||
|
||||
for(size_t i = 0; i < m_faultFacesTextureCoords->size(); ++i)
|
||||
size_t quadIdx = i/4;
|
||||
size_t cellIndex = quadsToCellFaceMapper->cellIndex(quadIdx);
|
||||
cvf::uint wellIndex = gridCellToWellIndexMap->get(cellIndex);
|
||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
if ((*m_faultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
|
||||
|
||||
size_t quadIdx = i/4;
|
||||
size_t cellIndex = quadsToGridCells[quadIdx];
|
||||
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
|
||||
if (wellIndex != cvf::UNDEFINED_UINT)
|
||||
if ( !isWellPipeVisibleForWellIndex[wellIndex])
|
||||
{
|
||||
if ( !isWellPipeVisible[wellIndex])
|
||||
{
|
||||
(*m_faultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
|
||||
}
|
||||
(*resultTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_faultFaces->drawable());
|
||||
if (dg) dg->setTextureCoordArray(m_faultFacesTextureCoords.p());
|
||||
|
||||
caf::PolygonOffset polygonOffset = caf::PO_1;
|
||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
|
||||
scalarEffgen.setOpacityLevel(m_opacityLevel);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
|
||||
|
||||
m_faultFaces->setEffect(scalarEffect.p());
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,6 +404,7 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
|
||||
{
|
||||
/*
|
||||
if (m_surfaceFaces.notNull())
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
|
||||
@ -431,6 +425,20 @@ void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSl
|
||||
m_surfaceFaces->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
*/
|
||||
updateCellEdgeResultColorOnPart(
|
||||
m_surfaceFaces.p(),
|
||||
&m_surfaceGenerator,
|
||||
timeStepIndex, cellResultSlot, cellEdgeResultSlot);
|
||||
|
||||
if (m_faultFaces.notNull())
|
||||
{
|
||||
updateCellEdgeResultColorOnPart(
|
||||
m_faultFaces.p(),
|
||||
&m_faultGenerator,
|
||||
timeStepIndex, cellResultSlot, cellEdgeResultSlot);
|
||||
}
|
||||
/*
|
||||
if (m_faultFaces.notNull())
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_faultFaces->drawable());
|
||||
@ -451,6 +459,37 @@ void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSl
|
||||
m_faultFaces->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGridPartMgr::updateCellEdgeResultColorOnPart( cvf::Part* facePart,
|
||||
cvf::StructGridGeometryGenerator* surfaceGenerator,
|
||||
size_t timeStepIndex,
|
||||
RimResultSlot* cellResultSlot,
|
||||
RimCellEdgeResultSlot* cellEdgeResultSlot)
|
||||
{
|
||||
if (facePart)
|
||||
{
|
||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(facePart->drawable());
|
||||
if (dg)
|
||||
{
|
||||
RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultSlot, cellEdgeResultSlot,
|
||||
surfaceGenerator, dg, m_grid->gridIndex(), m_opacityLevel );
|
||||
|
||||
cvf::ScalarMapper* cellScalarMapper = NULL;
|
||||
if (cellResultSlot->hasResult()) cellScalarMapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||
|
||||
CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultSlot->legendConfig()->scalarMapper(), cellScalarMapper);
|
||||
cellFaceEffectGen.setOpacityLevel(m_opacityLevel);
|
||||
cellFaceEffectGen.setDefaultCellColor(m_defaultColor);
|
||||
|
||||
cvf::ref<cvf::Effect> eff = cellFaceEffectGen.generateEffect();
|
||||
|
||||
facePart->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -520,8 +559,7 @@ cvf::ref<cvf::Effect> RivGridPartMgr::createPerVertexColoringEffect(float opacit
|
||||
void RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordinates(RimResultSlot* cellResultSlot,
|
||||
const RigGridBase* grid,
|
||||
cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadsToFaceTypes,
|
||||
const std::vector<size_t>& quadsToGridCells)
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper)
|
||||
{
|
||||
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||
if (!mapper) return;
|
||||
@ -545,7 +583,8 @@ void RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordi
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectTranZ = eclipseCase->dataAccessObject(grid, porosityModel, resTimeStepIdx, tranPosZScalarSetIndex);
|
||||
|
||||
|
||||
size_t numVertices = quadsToGridCells.size()*4;
|
||||
int quadCount = static_cast<int>(quadToCellFaceMapper->quadCount());
|
||||
size_t numVertices = quadCount*4;
|
||||
|
||||
textureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
@ -554,53 +593,68 @@ void RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordi
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, cellScalarValue)
|
||||
for (int idx = 0; idx < static_cast<int>(quadsToGridCells.size()); idx++)
|
||||
for (int quadIdx = 0; quadIdx < quadCount; quadIdx++)
|
||||
{
|
||||
cellScalarValue = HUGE_VAL;
|
||||
|
||||
if (quadsToFaceTypes[idx] == cvf::StructGridInterface::POS_I)
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranX->cellScalar(quadsToGridCells[idx]);
|
||||
}
|
||||
else if (quadsToFaceTypes[idx] == cvf::StructGridInterface::NEG_I)
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(quadsToGridCells[idx], &i, &j, &k);
|
||||
size_t cellIndex = quadToCellFaceMapper->cellIndex(quadIdx);
|
||||
cvf::StructGridInterface::FaceType cellFace = quadToCellFaceMapper->cellFace(quadIdx);
|
||||
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_I, &neighborGridCellIdx))
|
||||
switch (cellFace)
|
||||
{
|
||||
case cvf::StructGridInterface::POS_I:
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranX->cellScalar(neighborGridCellIdx);
|
||||
cellScalarValue = dataAccessObjectTranX->cellScalar(cellIndex);
|
||||
}
|
||||
}
|
||||
else if (quadsToFaceTypes[idx] == cvf::StructGridInterface::POS_J)
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranY->cellScalar(quadsToGridCells[idx]);
|
||||
}
|
||||
else if (quadsToFaceTypes[idx] == cvf::StructGridInterface::NEG_J)
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(quadsToGridCells[idx], &i, &j, &k);
|
||||
break;
|
||||
case cvf::StructGridInterface::NEG_I:
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(cellIndex, &i, &j, &k);
|
||||
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_J, &neighborGridCellIdx))
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranY->cellScalar(neighborGridCellIdx);
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_I, &neighborGridCellIdx))
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranX->cellScalar(neighborGridCellIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (quadsToFaceTypes[idx] == cvf::StructGridInterface::POS_K)
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranZ->cellScalar(quadsToGridCells[idx]);
|
||||
}
|
||||
else if (quadsToFaceTypes[idx] == cvf::StructGridInterface::NEG_K)
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(quadsToGridCells[idx], &i, &j, &k);
|
||||
break;
|
||||
case cvf::StructGridInterface::POS_J:
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranY->cellScalar(cellIndex);
|
||||
}
|
||||
break;
|
||||
case cvf::StructGridInterface::NEG_J:
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(cellIndex, &i, &j, &k);
|
||||
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_K, &neighborGridCellIdx))
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranZ->cellScalar(neighborGridCellIdx);
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_J, &neighborGridCellIdx))
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranY->cellScalar(neighborGridCellIdx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case cvf::StructGridInterface::POS_K:
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranZ->cellScalar(cellIndex);
|
||||
}
|
||||
break;
|
||||
case cvf::StructGridInterface::NEG_K:
|
||||
{
|
||||
size_t i, j, k, neighborGridCellIdx;
|
||||
grid->ijkFromCellIndex(cellIndex, &i, &j, &k);
|
||||
|
||||
if(grid->cellIJKNeighbor(i, j, k, cvf::StructGridInterface::NEG_K, &neighborGridCellIdx))
|
||||
{
|
||||
cellScalarValue = dataAccessObjectTranZ->cellScalar(neighborGridCellIdx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
|
||||
texCoord = mapper->mapToTextureCoord(cellScalarValue);
|
||||
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
|
||||
{
|
||||
@ -610,7 +664,7 @@ void RivTransmissibilityColorMapper::updateCombinedTransmissibilityTextureCoordi
|
||||
size_t j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
rawPtr[idx*4 + j] = texCoord;
|
||||
rawPtr[quadIdx*4 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,7 +694,9 @@ public:
|
||||
/// Loads ternary saturation results SOIL, SWAT and SGAS
|
||||
/// If any of these are not present, the values for a missing component is set to 0.0
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTransmissibilityColorMapper::updateTernarySaturationColorArray(size_t timeStepIndex, RimResultSlot* cellResultSlot, const RigGridBase* grid, cvf::Color3ubArray* colorArray, const std::vector<size_t>& quadsToGridCells)
|
||||
void RivTransmissibilityColorMapper::updateTernarySaturationColorArray(size_t timeStepIndex, RimResultSlot* cellResultSlot,
|
||||
const RigGridBase* grid, cvf::Color3ubArray* colorArray,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper)
|
||||
{
|
||||
RimReservoirCellResultsStorage* gridCellResults = cellResultSlot->currentGridCellResults();
|
||||
if (!gridCellResults) return;
|
||||
@ -690,7 +746,7 @@ void RivTransmissibilityColorMapper::updateTernarySaturationColorArray(size_t ti
|
||||
double swatRange = swatMax - swatMin;
|
||||
double swatFactor = 255.0 / swatRange;
|
||||
|
||||
size_t numVertices = quadsToGridCells.size()*4;
|
||||
size_t numVertices = quadToCellFaceMapper->quadCount()*4;
|
||||
|
||||
colorArray->resize(numVertices);
|
||||
|
||||
@ -698,9 +754,9 @@ void RivTransmissibilityColorMapper::updateTernarySaturationColorArray(size_t ti
|
||||
double v, vNormalized;
|
||||
|
||||
#pragma omp parallel for private(ternaryColorByte, v, vNormalized)
|
||||
for (int idx = 0; idx < static_cast<int>(quadsToGridCells.size()); idx++)
|
||||
for (int quadIdx = 0; quadIdx < static_cast<int>(quadToCellFaceMapper->quadCount()); quadIdx++)
|
||||
{
|
||||
size_t gridCellIndex = quadsToGridCells[idx];
|
||||
size_t gridCellIndex = quadToCellFaceMapper->cellIndex(quadIdx);
|
||||
|
||||
{
|
||||
v = dataAccessObjectSgas->cellScalar(gridCellIndex);
|
||||
@ -729,7 +785,7 @@ void RivTransmissibilityColorMapper::updateTernarySaturationColorArray(size_t ti
|
||||
size_t j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
colorArray->set(idx*4 + j, ternaryColorByte);
|
||||
colorArray->set(quadIdx*4 + j, ternaryColorByte);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,15 +49,14 @@ public:
|
||||
RimResultSlot* cellResultSlot,
|
||||
const RigGridBase* grid,
|
||||
cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<cvf::StructGridInterface::FaceType>& quadsToFaceTypes,
|
||||
const std::vector<size_t>& quadsToGridCells);
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper);
|
||||
|
||||
static void updateTernarySaturationColorArray(
|
||||
size_t timeStepIndex,
|
||||
RimResultSlot* cellResultSlot,
|
||||
const RigGridBase* grid,
|
||||
cvf::Color3ubArray* colorArray,
|
||||
const std::vector<size_t>& quadsToGridCells);
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper);
|
||||
};
|
||||
|
||||
|
||||
@ -91,7 +90,17 @@ public:
|
||||
|
||||
private:
|
||||
void generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder, bool faultGeometry);
|
||||
|
||||
void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper);
|
||||
cvf::ref<cvf::Effect> createScalarMapperEffect(const cvf::ScalarMapper* mapper);
|
||||
void setResultsTransparentForWellCells(const std::vector<cvf::ubyte>& isWellPipeVisibleForWellIndex,
|
||||
const cvf::UIntArray* gridCellToWellIndexMap,
|
||||
const cvf::StructGridQuadToCellFaceMapper* quadsToCellFaceMapper,
|
||||
cvf::Vec2fArray* resultTextureCoords);
|
||||
void updateCellEdgeResultColorOnPart(cvf::Part* facePart,
|
||||
cvf::StructGridGeometryGenerator* surfaceGenerator,
|
||||
size_t timeStepIndex,
|
||||
RimResultSlot* cellResultSlot,
|
||||
RimCellEdgeResultSlot* cellEdgeResultSlot);
|
||||
private:
|
||||
size_t m_gridIdx;
|
||||
cvf::cref<RigGridBase> m_grid;
|
||||
@ -108,7 +117,7 @@ private:
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceGridLines;
|
||||
|
||||
// Fault visualization
|
||||
// Fault visualization: Dead ?? JJS
|
||||
cvf::StructGridGeometryGenerator m_faultGenerator;
|
||||
RigFaultFaceVisibilityFilter m_faultFaceFilter;
|
||||
cvf::ref<cvf::Part> m_faultFaces;
|
||||
|
@ -17,14 +17,15 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivSourceInfo.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivSourceInfo::hasCellIndices() const
|
||||
bool RivSourceInfo::hasCellFaceMapping() const
|
||||
{
|
||||
return m_cellIndices.notNull();
|
||||
return m_cellFaceFromTriangleMapper.notNull();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,17 +21,15 @@
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
class RivSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
bool hasCellIndices() const;
|
||||
bool hasCellFaceMapping() const;
|
||||
bool hasNNCIndices() const;
|
||||
|
||||
public:
|
||||
cvf::ref<cvf::Array<size_t> > m_cellIndices;
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> > m_faceTypes;
|
||||
|
||||
cvf::ref<cvf::Array<size_t> > m_NNCIndices;
|
||||
cvf::cref<cvf::StuctGridTriangleToCellFaceMapper> m_cellFaceFromTriangleMapper;
|
||||
cvf::ref<cvf::Array<size_t> > m_NNCIndices;
|
||||
};
|
||||
|
@ -274,10 +274,10 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo->hasCellIndices())
|
||||
if (rivSourceInfo->hasCellFaceMapping())
|
||||
{
|
||||
m_currentGridIdx = firstHitPart->id();
|
||||
m_currentCellIndex = rivSourceInfo->m_cellIndices->get(faceIndex);
|
||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
||||
@ -436,13 +436,14 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY)
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo->hasCellIndices())
|
||||
if (rivSourceInfo->hasCellFaceMapping())
|
||||
{
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cellIndex = rivSourceInfo->m_cellIndices->get(faceIndex);
|
||||
CVF_ASSERT(rivSourceInfo->m_cellFaceFromTriangleMapper.notNull());
|
||||
|
||||
CVF_ASSERT(rivSourceInfo->m_faceTypes.notNull());
|
||||
cvf::StructGridInterface::FaceType face = rivSourceInfo->m_faceTypes->get(faceIndex);
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
|
||||
cvf::StructGridInterface::FaceType face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||
|
||||
m_reservoirView->pickInfo(gridIndex, cellIndex, face, localIntersectionPoint, &pickInfo);
|
||||
|
||||
|
@ -159,6 +159,8 @@ StructGridGeometryGenerator::StructGridGeometryGenerator(const StructGridInterfa
|
||||
: m_grid(grid)
|
||||
{
|
||||
CVF_ASSERT(grid);
|
||||
m_quadMapper = new StructGridQuadToCellFaceMapper;
|
||||
m_triangleMapper = new StuctGridTriangleToCellFaceMapper(m_quadMapper.p());
|
||||
}
|
||||
|
||||
|
||||
@ -309,8 +311,8 @@ bool StructGridGeometryGenerator::isCellFaceVisible(size_t i, size_t j, size_t k
|
||||
void StructGridGeometryGenerator::computeArrays()
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
m_quadsToGridCells.clear();
|
||||
m_quadsToFace.clear();
|
||||
m_quadMapper->quadToCellIndexMap().clear();
|
||||
m_quadMapper->quadToCellFaceMap().clear();
|
||||
|
||||
cvf::Vec3d offset = m_grid->displayModelOffset();
|
||||
|
||||
@ -362,8 +364,8 @@ void StructGridGeometryGenerator::computeArrays()
|
||||
}
|
||||
|
||||
// Keep track of the source cell index per quad
|
||||
m_quadsToGridCells.push_back(cellIndex);
|
||||
m_quadsToFace.push_back(face);
|
||||
m_quadMapper->quadToCellIndexMap().push_back(cellIndex);
|
||||
m_quadMapper->quadToCellFaceMap().push_back(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,7 +387,7 @@ void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords,
|
||||
{
|
||||
if (!dataAccessObject) return;
|
||||
|
||||
size_t numVertices = m_quadsToGridCells.size()*4;
|
||||
size_t numVertices = m_quadMapper->quadCount()*4;
|
||||
|
||||
textureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
@ -394,9 +396,9 @@ void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords,
|
||||
cvf::Vec2f texCoord;
|
||||
|
||||
#pragma omp parallel for private(texCoord, cellScalarValue)
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
|
||||
for (int i = 0; i < static_cast<int>(m_quadMapper->quadCount()); i++)
|
||||
{
|
||||
cellScalarValue = dataAccessObject->cellScalar(m_quadsToGridCells[i]);
|
||||
cellScalarValue = dataAccessObject->cellScalar(m_quadMapper->cellIndex(i));
|
||||
texCoord = mapper->mapToTextureCoord(cellScalarValue);
|
||||
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
|
||||
{
|
||||
@ -411,37 +413,43 @@ void StructGridGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<cvf::Array<size_t> > StructGridGeometryGenerator::triangleToSourceGridCellMap() const
|
||||
{
|
||||
ref<Array<size_t> > triangles = new Array<size_t>(2*m_quadsToGridCells.size());
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToGridCells.size()); i++)
|
||||
{
|
||||
triangles->set(i*2, m_quadsToGridCells[i]);
|
||||
triangles->set(i*2+1, m_quadsToGridCells[i]);
|
||||
}
|
||||
|
||||
return triangles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> > StructGridGeometryGenerator::triangleToFaceTypes() const
|
||||
void StructGridGeometryGenerator::textureCoordinatesFromSingleFaceValues(Vec2fArray* textureCoords, const ScalarMapper* mapper, const CellFaceValueCalculator* dataAccessObject) const
|
||||
{
|
||||
ref<Array<cvf::StructGridInterface::FaceType> > triangles = new Array<cvf::StructGridInterface::FaceType>(2*m_quadsToFace.size());
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < static_cast<int>(m_quadsToFace.size()); i++)
|
||||
{
|
||||
triangles->set(i*2, m_quadsToFace[i]);
|
||||
triangles->set(i*2+1, m_quadsToFace[i]);
|
||||
}
|
||||
if (!dataAccessObject) return;
|
||||
|
||||
return triangles;
|
||||
textureCoords->resize(m_quadMapper->quadCount()*4);
|
||||
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
|
||||
double cellFaceValue;
|
||||
cvf::Vec2f texCoord;
|
||||
int quadCount = static_cast<int>(m_quadMapper->quadCount());
|
||||
|
||||
#pragma omp parallel for private(texCoord, cellFaceValue)
|
||||
for (int qIdx = 0; qIdx < quadCount; qIdx++)
|
||||
{
|
||||
cellFaceValue = dataAccessObject->cellFaceScalar(m_quadMapper->cellIndex(qIdx), m_quadMapper->faceType(qIdx));
|
||||
|
||||
texCoord = mapper->mapToTextureCoord(cellFaceValue);
|
||||
|
||||
if (cellFaceValue == HUGE_VAL || cellFaceValue != cellFaceValue) // a != a is true for NAN's
|
||||
{
|
||||
texCoord[1] = 1.0f;
|
||||
}
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
rawPtr[qIdx*4 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -451,21 +459,5 @@ void StructGridGeometryGenerator::setCellVisibility(const UByteArray* cellVisibi
|
||||
m_cellVisibility = cellVisibility;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& StructGridGeometryGenerator::quadToGridCellIndices() const
|
||||
{
|
||||
return m_quadsToGridCells;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<StructGridInterface::FaceType>& StructGridGeometryGenerator::quadToFace() const
|
||||
{
|
||||
return m_quadsToFace;
|
||||
}
|
||||
|
||||
} // namespace cvf
|
||||
|
||||
|
@ -121,6 +121,37 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class StructGridQuadToCellFaceMapper : public Object
|
||||
{
|
||||
public:
|
||||
size_t quadCount() const { return m_quadsToCells.size();}
|
||||
|
||||
size_t cellIndex(size_t quadIdx) const {return m_quadsToCells[quadIdx]; }
|
||||
StructGridInterface::FaceType cellFace(size_t quadIdx) const {return m_quadsToFace[quadIdx]; }
|
||||
|
||||
// Interface for building the mappings
|
||||
std::vector<size_t>& quadToCellIndexMap() { return m_quadsToCells; }
|
||||
std::vector<StructGridInterface::FaceType>& quadToCellFaceMap() { return m_quadsToFace; }
|
||||
|
||||
private:
|
||||
std::vector<size_t> m_quadsToCells;
|
||||
std::vector<StructGridInterface::FaceType> m_quadsToFace;
|
||||
};
|
||||
|
||||
|
||||
class StuctGridTriangleToCellFaceMapper : public Object
|
||||
{
|
||||
public:
|
||||
StuctGridTriangleToCellFaceMapper(const StructGridQuadToCellFaceMapper* quadMapper) { m_quadMapper = quadMapper; }
|
||||
size_t triangleCount() const { return 2* m_quadMapper->quadCount();}
|
||||
|
||||
size_t cellIndex(size_t triangleIdx) const {return m_quadMapper->cellIndex(triangleIdx/2); }
|
||||
StructGridInterface::FaceType cellFace(size_t triangleIdx) const {return m_quadMapper->cellFace(triangleIdx/2); }
|
||||
|
||||
private:
|
||||
cref<StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -145,16 +176,9 @@ public:
|
||||
void textureCoordinates(Vec2fArray* textureCoords, const StructGridScalarDataAccess* dataAccessObject, const ScalarMapper* mapper) const;
|
||||
|
||||
// Mapping between cells and geometry
|
||||
ref<cvf::Array<size_t> >
|
||||
triangleToSourceGridCellMap() const;
|
||||
|
||||
cvf::ref<cvf::Array<cvf::StructGridInterface::FaceType> >
|
||||
triangleToFaceTypes() const;
|
||||
|
||||
const std::vector<size_t>&
|
||||
quadToGridCellIndices() const;
|
||||
const std::vector<StructGridInterface::FaceType>&
|
||||
quadToFace() const;
|
||||
const StructGridQuadToCellFaceMapper * quadToCellFaceMapper() { return m_quadMapper.p(); }
|
||||
const StuctGridTriangleToCellFaceMapper * triangleToCellFaceMapper() { return m_triangleMapper.p(); }
|
||||
|
||||
// Generated geometry
|
||||
ref<DrawableGeo> generateSurface();
|
||||
@ -176,11 +200,10 @@ private:
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||
// Mappings
|
||||
std::vector<size_t> m_triangleIndexToGridCellIndex;
|
||||
std::vector<size_t> m_quadsToGridCells;
|
||||
std::vector<StructGridInterface::FaceType> m_quadsToFace;
|
||||
|
||||
// Mappings
|
||||
ref<StructGridQuadToCellFaceMapper> m_quadMapper;
|
||||
ref<StuctGridTriangleToCellFaceMapper> m_triangleMapper;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
|
||||
set(CMAKE_MAJOR_VERSION 1)
|
||||
set(CMAKE_MINOR_VERSION 2)
|
||||
set(CMAKE_MINOR_VERSION 3)
|
||||
set(CMAKE_PATCH_VERSION 0)
|
||||
set(DEV_VERSION "-dev")
|
||||
|
||||
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
|
||||
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
|
||||
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}${DEV_VERSION})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user