mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 15:36:09 -06:00
#3700 Add visual picking marker and improve map results
* Fix "off by half a cell" errors and improve smoothness using averaging and interpolation
This commit is contained in:
parent
71f90b1337
commit
42d3e65416
@ -62,19 +62,26 @@ bool RicContourMapPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventO
|
||||
contourMap->firstAncestorOrThisOfTypeAsserted(view);
|
||||
|
||||
cvf::Vec2d pickedPoint;
|
||||
cvf::Vec2ui pickedCell;
|
||||
double valueAtPoint = 0.0;
|
||||
if (contourMap->checkForMapIntersection(firstPickedItem.globalPickedPoint(), &pickedPoint, &valueAtPoint))
|
||||
if (contourMap->checkForMapIntersection(firstPickedItem.globalPickedPoint(), &pickedPoint, &pickedCell, &valueAtPoint))
|
||||
{
|
||||
QString curveText;
|
||||
curveText += QString("%1\n").arg(view->createAutoName());
|
||||
curveText += QString("Picked Point X, Y: %1, %2\n").arg(pickedPoint.x(), 5, 'f', 0).arg(pickedPoint.y(), 5, 'f', 0);
|
||||
curveText += QString("Picked Cell I, J: %1, %2\n").arg(pickedCell.x()).arg(pickedCell.y());
|
||||
curveText += QString("Result Type: %1\n").arg(contourMap->resultDescriptionText());
|
||||
curveText += QString("Aggregated Value: %1\n").arg(valueAtPoint);
|
||||
|
||||
RiuMainWindow::instance()->setResultInfo(curveText);
|
||||
|
||||
contourMap->setPickPoint(pickedPoint);
|
||||
view->updateCurrentTimeStepAndRedraw();
|
||||
return true;
|
||||
}
|
||||
contourMap->setPickPoint(cvf::Vec2d::UNDEFINED);
|
||||
view->updateCurrentTimeStepAndRedraw();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -31,7 +31,7 @@ RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr(RimContourMapProj
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createDrawable(displayCoordTransform);
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createProjectionMapDrawable(displayCoordTransform);
|
||||
if (drawable.notNull() && drawable->boundingBox().isValid())
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
@ -55,7 +55,7 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
{
|
||||
caf::MeshEffectGenerator meshEffectGen(cvf::Color3::BLACK);
|
||||
meshEffectGen.setLineWidth(1.0f);
|
||||
meshEffectGen.createAndConfigurePolygonOffsetRenderState(caf::PO_2);
|
||||
meshEffectGen.createAndConfigurePolygonOffsetRenderState(caf::PO_1);
|
||||
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
@ -69,28 +69,79 @@ void RivContourMapProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::appendPickPointVisToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> drawable = createPickPointVisDrawable(displayCoordTransform);
|
||||
if (drawable.notNull() && drawable->boundingBox().isValid())
|
||||
{
|
||||
caf::MeshEffectGenerator meshEffectGen(cvf::Color3::MAGENTA);
|
||||
meshEffectGen.setLineWidth(2.0f);
|
||||
meshEffectGen.createAndConfigurePolygonOffsetRenderState(caf::PO_2);
|
||||
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setDrawable(drawable.p());
|
||||
part->setEffect(effect.p());
|
||||
part->setSourceInfo(new RivMeshLinesSourceInfo(m_contourMapProjection.p()));
|
||||
|
||||
model->addPart(part.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords() const
|
||||
{
|
||||
cvf::Vec2ui patchSize = m_contourMapProjection->surfaceGridSize();
|
||||
cvf::Vec2ui patchSize = m_contourMapProjection->vertexGridSize();
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray(m_contourMapProjection->vertexCount());
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray(m_contourMapProjection->numberOfVertices());
|
||||
|
||||
for (uint j = 0; j < patchSize.y(); ++j)
|
||||
#pragma omp parallel for
|
||||
for (int j = 0; j < static_cast<int>(patchSize.y()); ++j)
|
||||
{
|
||||
for (uint i = 0; i < patchSize.x(); ++i)
|
||||
for (int i = 0; i < static_cast<int>(patchSize.x()); ++i)
|
||||
{
|
||||
if (m_contourMapProjection->hasResultAt(i, j))
|
||||
if (m_contourMapProjection->hasResultAtVertex(i, j))
|
||||
{
|
||||
double value = m_contourMapProjection->value(i, j);
|
||||
(*textureCoords)[i + j * patchSize.x()] =
|
||||
m_contourMapProjection->legendConfig()->scalarMapper()->mapToTextureCoord(value);
|
||||
double value = m_contourMapProjection->valueAtVertex(i, j);
|
||||
cvf::Vec2f textureCoord = m_contourMapProjection->legendConfig()->scalarMapper()->mapToTextureCoord(value);
|
||||
textureCoord.y() = 0.0;
|
||||
(*textureCoords)[i + j * patchSize.x()] = textureCoord;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*textureCoords)[i + j * patchSize.x()] = cvf::Vec2f(1.0, 1.0);
|
||||
RiaWeightedMeanCalculator<double> calc;
|
||||
for (int jj = j - 1; jj <= j + 1; ++jj)
|
||||
{
|
||||
for (int ii = i - 1; ii <= i + 1; ++ii)
|
||||
{
|
||||
if (jj >= 0 && ii >= 0 && jj < static_cast<int>(patchSize.y()) && ii < static_cast<int>(patchSize.x()))
|
||||
{
|
||||
if (!(ii == i && jj == j) && m_contourMapProjection->hasResultAtVertex(ii, jj))
|
||||
{
|
||||
double value = m_contourMapProjection->valueAtVertex(ii, jj);
|
||||
calc.addValueAndWeight(value, 1. / std::sqrt((i - ii)*(i - ii) + (j - jj)*(j - jj)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (calc.validAggregatedWeight())
|
||||
{
|
||||
const double maxTheoreticalWeightSum = 4.0 + 4.0 / std::sqrt(2.0);
|
||||
double value = calc.weightedMean();
|
||||
cvf::Vec2f textureCoord = m_contourMapProjection->legendConfig()->scalarMapper()->mapToTextureCoord(value);
|
||||
textureCoord.y() = 1.0 - calc.aggregatedWeight() / maxTheoreticalWeightSum;
|
||||
(*textureCoords)[i + j * patchSize.x()] = textureCoord;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*textureCoords)[i + j * patchSize.x()] = cvf::Vec2f(0.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,46 +151,16 @@ cvf::ref<cvf::Vec2fArray> RivContourMapProjectionPartMgr::createTextureCoords()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivContourMapProjectionPartMgr::removeTrianglesWithNoResult(cvf::UIntArray* vertices) const
|
||||
{
|
||||
std::vector<cvf::uint> trianglesWithResult;
|
||||
|
||||
for (size_t n = 0; n < vertices->size(); n += 3)
|
||||
{
|
||||
bool anyInvalid = false;
|
||||
for (size_t t = 0; !anyInvalid && t < 3; ++t)
|
||||
{
|
||||
cvf::uint vertexNumber = (*vertices)[n + t];
|
||||
cvf::Vec2ui ij = m_contourMapProjection->ijFromGridIndex(vertexNumber);
|
||||
if (!m_contourMapProjection->hasResultAt(ij.x(), ij.y()))
|
||||
{
|
||||
anyInvalid = true;
|
||||
}
|
||||
}
|
||||
for (size_t t = 0; !anyInvalid && t < 3; ++t)
|
||||
{
|
||||
cvf::uint vertexNumber = (*vertices)[n + t];
|
||||
trianglesWithResult.push_back(vertexNumber);
|
||||
}
|
||||
}
|
||||
(*vertices) = cvf::UIntArray(trianglesWithResult);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivContourMapProjectionPartMgr::createDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
cvf::ref<cvf::DrawableGeo> RivContourMapProjectionPartMgr::createProjectionMapDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray;
|
||||
m_contourMapProjection->generateVertices(vertexArray.p(), displayCoordTransform);
|
||||
cvf::Vec2ui patchSize = m_contourMapProjection->surfaceGridSize();
|
||||
cvf::Vec2ui patchSize = m_contourMapProjection->vertexGridSize();
|
||||
|
||||
// Surface
|
||||
cvf::ref<cvf::UIntArray> faceList = new cvf::UIntArray;
|
||||
cvf::GeometryUtils::tesselatePatchAsTriangles(patchSize.x(), patchSize.y(), 0u, true, faceList.p());
|
||||
|
||||
removeTrianglesWithNoResult(faceList.p());
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLES, faceList.p());
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
@ -179,3 +200,33 @@ std::vector<cvf::ref<cvf::DrawableGeo>> RivContourMapProjectionPartMgr::createCo
|
||||
}
|
||||
return contourDrawables;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RivContourMapProjectionPartMgr::createPickPointVisDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geo = nullptr;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> pickPointPolygon = m_contourMapProjection->generatePickPointPolygon(displayCoordTransform);
|
||||
if (pickPointPolygon.notNull() && pickPointPolygon->size() > 0u)
|
||||
{
|
||||
std::vector<cvf::uint> indices;
|
||||
indices.reserve(pickPointPolygon->size());
|
||||
for (cvf::uint j = 0; j < pickPointPolygon->size(); ++j)
|
||||
{
|
||||
indices.push_back(j);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
|
||||
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
|
||||
indexedUInt->setIndices(indexArray.p());
|
||||
|
||||
geo = new cvf::DrawableGeo;
|
||||
|
||||
geo->addPrimitiveSet(indexedUInt.p());
|
||||
geo->setVertexArray(pickPointPolygon.p());
|
||||
}
|
||||
return geo;
|
||||
}
|
||||
|
@ -36,13 +36,16 @@ public:
|
||||
|
||||
void appendProjectionToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
void appendPickPointVisToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> createTextureCoords() const;
|
||||
|
||||
void removeTrianglesWithNoResult(cvf::UIntArray* uintArray) const;
|
||||
private:
|
||||
cvf::ref<cvf::DrawableGeo> createDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
cvf::ref<cvf::DrawableGeo> createProjectionMapDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
std::vector<cvf::ref<cvf::DrawableGeo>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
private:
|
||||
caf::PdmPointer<RimContourMapProjection> m_contourMapProjection;
|
||||
caf::PdmPointer<RimContourMapView> m_parentContourMap;
|
||||
|
@ -284,7 +284,7 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimC
|
||||
|
||||
if (contourMap)
|
||||
{
|
||||
bool isResultsInfoRelevant = contourMap->contourMapProjection()->validVertexCount() > 0u;
|
||||
bool isResultsInfoRelevant = contourMap->contourMapProjection()->numberOfValidCells() > 0u;
|
||||
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
@ -499,11 +499,11 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimEclipseView* eclipseView)
|
||||
RimContourMapView* contourMap = dynamic_cast<RimContourMapView*>(eclipseView);
|
||||
if (contourMap && contourMap->contourMapProjection())
|
||||
{
|
||||
QString totCellCount = QString::number(contourMap->contourMapProjection()->vertexCount());
|
||||
cvf::uint validCellCount = contourMap->contourMapProjection()->validVertexCount();
|
||||
QString totCellCount = QString::number(contourMap->contourMapProjection()->numberOfCells());
|
||||
cvf::uint validCellCount = contourMap->contourMapProjection()->numberOfValidCells();
|
||||
QString activeCellCountText = QString::number(validCellCount);
|
||||
QString iSize = QString::number(contourMap->contourMapProjection()->surfaceGridSize().x());
|
||||
QString jSize = QString::number(contourMap->contourMapProjection()->surfaceGridSize().y());
|
||||
QString iSize = QString::number(contourMap->contourMapProjection()->mapSize().x());
|
||||
QString jSize = QString::number(contourMap->contourMapProjection()->mapSize().y());
|
||||
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
|
||||
QString weightingParameterString;
|
||||
if (contourMap->contourMapProjection()->weightingParameter() != "None")
|
||||
@ -582,7 +582,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, Ri
|
||||
|
||||
if (contourMap)
|
||||
{
|
||||
bool isResultsInfoRelevant = contourMap->contourMapProjection()->validVertexCount() > 0u;
|
||||
bool isResultsInfoRelevant = contourMap->contourMapProjection()->numberOfValidCells() > 0u;
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
QString propName = eclipseView->cellResult()->resultVariableUiShortName();
|
||||
|
@ -31,11 +31,10 @@
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfCellRange.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace caf
|
||||
@ -64,6 +63,9 @@ CAF_PDM_SOURCE_INIT(RimContourMapProjection, "RimContourMapProjection");
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimContourMapProjection::RimContourMapProjection()
|
||||
: m_pickPoint(cvf::Vec2d::UNDEFINED),
|
||||
m_mapSize(cvf::Vec2ui(0u, 0u)),
|
||||
m_sampleSpacing(-1.0)
|
||||
{
|
||||
CAF_PDM_InitObject("RimContourMapProjection", ":/draw_style_meshlines_24x24.png", "", "");
|
||||
|
||||
@ -94,16 +96,6 @@ RimContourMapProjection::~RimContourMapProjection()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RimContourMapProjection::expandedBoundingBox() const
|
||||
{
|
||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
||||
boundingBox.expand(sampleSpacing() * 0.5);
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -111,16 +103,11 @@ void RimContourMapProjection::generateGridMapping()
|
||||
{
|
||||
calculateTotalCellVisibility();
|
||||
|
||||
cvf::Vec3d gridExtent = expandedBoundingBox().extent();
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
|
||||
RimEclipseResultCase* eclipseCase = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(eclipseCase);
|
||||
|
||||
m_projected3dGridIndices.resize(vertexCount());
|
||||
|
||||
int nVertices = vertexCount();
|
||||
int nCells = numberOfCells();
|
||||
m_projected3dGridIndices.resize(nCells);
|
||||
|
||||
const std::vector<double>* weightingResultValues = nullptr;
|
||||
if (m_weightByParameter())
|
||||
@ -141,22 +128,22 @@ void RimContourMapProjection::generateGridMapping()
|
||||
|
||||
if (isStraightSummationResult())
|
||||
{
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(index);
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = globalPos2d(ij.x(), ij.y());
|
||||
cvf::Vec2d globalPos = cellCenterPos(ij.x(), ij.y());
|
||||
m_projected3dGridIndices[index] = visibleCellsAndLengthInCellFrom2dPoint(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(index);
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = globalPos2d(ij.x(), ij.y());
|
||||
cvf::Vec2d globalPos = cellCenterPos(ij.x(), ij.y());
|
||||
m_projected3dGridIndices[index] = visibleCellsAndOverlapVolumeFrom2dPoint(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
@ -168,20 +155,19 @@ void RimContourMapProjection::generateGridMapping()
|
||||
void RimContourMapProjection::generateVertices(cvf::Vec3fArray* vertices, const caf::DisplayCoordTransform* displayCoordTransform)
|
||||
{
|
||||
CVF_ASSERT(vertices);
|
||||
vertices->resize(vertexCount());
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
|
||||
int nVertices = vertexCount();
|
||||
size_t nVertices = numberOfVertices();
|
||||
vertices->resize(nVertices);
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(index);
|
||||
cvf::Vec2ui ij = ijFromVertexIndex(index);
|
||||
cvf::Vec2d globalPos = cellCenterPos(ij.x(), ij.y());
|
||||
// Shift away from sample point to vertex
|
||||
globalPos.x() -= m_sampleSpacing * 0.5;
|
||||
globalPos.y() -= m_sampleSpacing * 0.5;
|
||||
|
||||
cvf::Vec2d globalPos = globalPos2d(ij.x(), ij.y());
|
||||
cvf::Vec3d globalVertexPos(globalPos, boundingBox.min().z() - 1.0);
|
||||
cvf::Vec3d globalVertexPos(globalPos, m_fullBoundingBox.min().z() - 1.0);
|
||||
cvf::Vec3f displayVertexPos(displayCoordTransform->transformToDisplayCoord(globalVertexPos));
|
||||
(*vertices)[index] = displayVertexPos;
|
||||
}
|
||||
@ -199,8 +185,6 @@ RimContourMapProjection::ContourPolygons RimContourMapProjection::generateContou
|
||||
maxValue() != -std::numeric_limits<double>::infinity() &&
|
||||
std::fabs(maxValue() - minValue()) > 1.0e-8)
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
|
||||
std::vector<double> contourLevels;
|
||||
legendConfig()->scalarMapper()->majorTickValues(&contourLevels);
|
||||
int nContourLevels = static_cast<int>(contourLevels.size());
|
||||
@ -209,7 +193,7 @@ RimContourMapProjection::ContourPolygons RimContourMapProjection::generateContou
|
||||
contourLevels[0] += (contourLevels[1] - contourLevels[0]) * 0.01;
|
||||
contourLevels[nContourLevels - 1] -= (contourLevels[nContourLevels - 1] - contourLevels[nContourLevels - 2]) * 0.01;
|
||||
std::vector<std::vector<cvf::Vec2d>> contourLines;
|
||||
caf::ContourLines::create(m_aggregatedResults, xPositions(), yPositions(), contourLevels, &contourLines);
|
||||
caf::ContourLines::create(m_aggregatedVertexResults, xVertexPositions(), yVertexPositions(), contourLevels, &contourLines);
|
||||
|
||||
contourPolygons.reserve(contourLines.size());
|
||||
for (size_t i = 0; i < contourLines.size(); ++i)
|
||||
@ -219,7 +203,7 @@ RimContourMapProjection::ContourPolygons RimContourMapProjection::generateContou
|
||||
cvf::ref<cvf::Vec3fArray> contourPolygon = new cvf::Vec3fArray(contourLines[i].size());
|
||||
for (size_t j = 0; j < contourLines[i].size(); ++j)
|
||||
{
|
||||
cvf::Vec3d contourPoint3d = cvf::Vec3d(contourLines[i][j], boundingBox.min().z());
|
||||
cvf::Vec3d contourPoint3d = cvf::Vec3d(contourLines[i][j], m_fullBoundingBox.min().z());
|
||||
cvf::Vec3d displayPoint3d = displayCoordTransform->transformToDisplayCoord(contourPoint3d);
|
||||
(*contourPolygon)[j] = cvf::Vec3f(displayPoint3d);
|
||||
}
|
||||
@ -231,15 +215,48 @@ RimContourMapProjection::ContourPolygons RimContourMapProjection::generateContou
|
||||
return contourPolygons;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Vec3fArray>
|
||||
RimContourMapProjection::generatePickPointPolygon(const caf::DisplayCoordTransform* displayCoordTransform)
|
||||
{
|
||||
cvf::ref<cvf::Vec3fArray> pickPolygon;
|
||||
if (!m_pickPoint.isUndefined())
|
||||
{
|
||||
double zPos = m_cellCenterBoundingBox.min().z();
|
||||
|
||||
std::vector<cvf::Vec3d> points;
|
||||
points.push_back(cvf::Vec3d(m_pickPoint - cvf::Vec2d(0.5*m_sampleSpacing, 0.0), zPos));
|
||||
points.push_back(cvf::Vec3d(m_pickPoint + cvf::Vec2d(0.5*m_sampleSpacing, 0.0), zPos));
|
||||
points.push_back(cvf::Vec3d(m_pickPoint - cvf::Vec2d(0.0, 0.5*m_sampleSpacing), zPos));
|
||||
points.push_back(cvf::Vec3d(m_pickPoint + cvf::Vec2d(0.0, 0.5*m_sampleSpacing), zPos));
|
||||
|
||||
pickPolygon = new cvf::Vec3fArray(points.size());
|
||||
|
||||
for (size_t i = 0; i < points.size(); ++i)
|
||||
{
|
||||
cvf::Vec3d displayPoint = displayCoordTransform->transformToDisplayCoord(points[i]);
|
||||
(*pickPolygon)[i] = cvf::Vec3f(displayPoint);
|
||||
}
|
||||
}
|
||||
return pickPolygon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::generateResults()
|
||||
{
|
||||
generateGridMapping();
|
||||
int nVertices = vertexCount();
|
||||
m_aggregatedResults = std::vector<double>(nVertices, std::numeric_limits<double>::infinity());
|
||||
updateGridInformation();
|
||||
|
||||
generateGridMapping();
|
||||
|
||||
size_t nCells = numberOfCells();
|
||||
size_t nVertices = numberOfVertices();
|
||||
|
||||
m_aggregatedResults = std::vector<double>(nCells, std::numeric_limits<double>::infinity());
|
||||
m_aggregatedVertexResults = std::vector<double>(nVertices, std::numeric_limits<double>::infinity());
|
||||
int timeStep = view()->currentTimeStep();
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
@ -275,10 +292,17 @@ void RimContourMapProjection::generateResults()
|
||||
}
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (int index = 0; index < static_cast<int>(nCells); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(index);
|
||||
m_aggregatedResults[index] = calculateValue(ij.x(), ij.y());
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
m_aggregatedResults[index] = calculateValueInCell(ij.x(), ij.y());
|
||||
}
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < static_cast<int>(nVertices); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromVertexIndex(index);
|
||||
m_aggregatedVertexResults[index] = calculateValueAtVertex(ij.x(), ij.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +315,7 @@ double RimContourMapProjection::maxValue() const
|
||||
{
|
||||
double maxV = -std::numeric_limits<double>::infinity();
|
||||
|
||||
int nVertices = vertexCount();
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
{
|
||||
@ -310,7 +334,7 @@ double RimContourMapProjection::minValue() const
|
||||
{
|
||||
double minV = std::numeric_limits<double>::infinity();
|
||||
|
||||
int nVertices = vertexCount();
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
{
|
||||
@ -327,7 +351,7 @@ double RimContourMapProjection::minValue() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::meanValue() const
|
||||
{
|
||||
return sumAllValues() / validVertexCount();
|
||||
return sumAllValues() / numberOfValidCells();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -337,7 +361,7 @@ double RimContourMapProjection::sumAllValues() const
|
||||
{
|
||||
double sum = 0.0;
|
||||
|
||||
int nVertices = vertexCount();
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
{
|
||||
@ -354,7 +378,7 @@ double RimContourMapProjection::sumAllValues() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::sampleSpacing() const
|
||||
{
|
||||
return m_relativeSampleSpacing * mainGrid()->characteristicIJCellSize();
|
||||
return m_sampleSpacing;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -365,6 +389,25 @@ double RimContourMapProjection::sampleSpacingFactor() const
|
||||
return m_relativeSampleSpacing();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::mapSize() const
|
||||
{
|
||||
return m_mapSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::vertexGridSize() const
|
||||
{
|
||||
cvf::Vec2ui mapSize = this->mapSize();
|
||||
mapSize.x() += 1u;
|
||||
mapSize.y() += 1u;
|
||||
return mapSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -417,7 +460,18 @@ bool RimContourMapProjection::isSummationResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::isStraightSummationResult() const
|
||||
{
|
||||
return isColumnResult() || m_resultAggregation() == RESULTS_SUM;
|
||||
return isStraightSummationResult(m_resultAggregation());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::isStraightSummationResult(ResultAggregationEnum aggregationType)
|
||||
{
|
||||
return aggregationType == RESULTS_OIL_COLUMN ||
|
||||
aggregationType == RESULTS_GAS_COLUMN ||
|
||||
aggregationType == RESULTS_HC_COLUMN ||
|
||||
aggregationType == RESULTS_SUM;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -433,12 +487,53 @@ bool RimContourMapProjection::isColumnResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::value(uint i, uint j) const
|
||||
double RimContourMapProjection::valueAtVertex(uint i, uint j) const
|
||||
{
|
||||
size_t index = gridIndex(i, j);
|
||||
if (index < vertexCount())
|
||||
size_t index = vertexIndex(i, j);
|
||||
if (index < numberOfVertices())
|
||||
{
|
||||
return m_aggregatedResults.at(gridIndex(i, j));
|
||||
return m_aggregatedVertexResults.at(index);
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::hasResultAtVertex(uint i, uint j) const
|
||||
{
|
||||
size_t index = vertexIndex(i, j);
|
||||
return m_aggregatedVertexResults[index] != std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::calculateValueAtVertex(uint vi, uint vj) const
|
||||
{
|
||||
std::vector<uint> averageIs;
|
||||
std::vector<uint> averageJs;
|
||||
|
||||
if (vi > 0u) averageIs.push_back(vi - 1);
|
||||
if (vj > 0u) averageJs.push_back(vj - 1);
|
||||
if (vi < m_mapSize.x()) averageIs.push_back(vi);
|
||||
if (vj < m_mapSize.y()) averageJs.push_back(vj);
|
||||
|
||||
RiaWeightedMeanCalculator<double> calc;
|
||||
for (uint j : averageJs)
|
||||
{
|
||||
for (uint i : averageIs)
|
||||
{
|
||||
if (hasResultInCell(i, j))
|
||||
{
|
||||
calc.addValueAndWeight(valueInCell(i, j), 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (calc.validAggregatedWeight())
|
||||
{
|
||||
return calc.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
@ -446,7 +541,7 @@ double RimContourMapProjection::value(uint i, uint j) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::calculateValue(uint i, uint j) const
|
||||
double RimContourMapProjection::calculateValueInCell(uint i, uint j) const
|
||||
{
|
||||
if (!isColumnResult() && view()->cellResult()->scalarResultIndex() == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
@ -493,7 +588,6 @@ double RimContourMapProjection::calculateValue(uint i, uint j) const
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
qDebug() << calculator.weightedMean();
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
@ -574,7 +668,20 @@ double RimContourMapProjection::calculateValue(uint i, uint j) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::hasResultAt(uint i, uint j) const
|
||||
double RimContourMapProjection::valueInCell(uint i, uint j) const
|
||||
{
|
||||
size_t index = cellIndex(i, j);
|
||||
if (index < numberOfCells())
|
||||
{
|
||||
return m_aggregatedResults.at(index);
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::hasResultInCell(uint i, uint j) const
|
||||
{
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
@ -588,36 +695,21 @@ bool RimContourMapProjection::hasResultAt(uint i, uint j) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::surfaceGridSize() const
|
||||
uint RimContourMapProjection::numberOfCells() const
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||
|
||||
uint projectionSizeX = static_cast<uint>(std::ceil(gridExtent.x() / sampleSpacing())) + 1u;
|
||||
uint projectionSizeY = static_cast<uint>(std::ceil(gridExtent.y() / sampleSpacing())) + 1u;
|
||||
|
||||
return cvf::Vec2ui(projectionSizeX, projectionSizeY);
|
||||
return m_mapSize.x() * m_mapSize.y();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
uint RimContourMapProjection::vertexCount() const
|
||||
{
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
return gridSize2d.x() * gridSize2d.y();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
uint RimContourMapProjection::validVertexCount() const
|
||||
uint RimContourMapProjection::numberOfValidCells() const
|
||||
{
|
||||
uint validCount = 0u;
|
||||
for (uint i = 0; i < vertexCount(); ++i)
|
||||
for (uint i = 0; i < numberOfCells(); ++i)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromGridIndex(i);
|
||||
if (hasResultAt(ij.x(), ij.y()))
|
||||
cvf::Vec2ui ij = ijFromCellIndex(i);
|
||||
if (hasResultInCell(ij.x(), ij.y()))
|
||||
{
|
||||
validCount++;
|
||||
}
|
||||
@ -644,15 +736,13 @@ void RimContourMapProjection::calculateTotalCellVisibility()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2d RimContourMapProjection::globalPos2d(uint i, uint j) const
|
||||
cvf::Vec2d RimContourMapProjection::cellCenterPos(uint i, uint j) const
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||
cvf::Vec2d origin(boundingBox.min().x(), boundingBox.min().y());
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
cvf::Vec3d gridExtent = m_cellCenterBoundingBox.extent();
|
||||
cvf::Vec2d origin(m_cellCenterBoundingBox.min().x(), m_cellCenterBoundingBox.min().y());
|
||||
|
||||
return origin + cvf::Vec2d((i * gridExtent.x()) / (gridSize2d.x() - 1),
|
||||
(j * gridExtent.y()) / (gridSize2d.y() - 1));
|
||||
return origin + cvf::Vec2d((i * gridExtent.x()) / (m_mapSize.x() - 1),
|
||||
(j * gridExtent.y()) / (m_mapSize.y() - 1));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -660,16 +750,21 @@ cvf::Vec2d RimContourMapProjection::globalPos2d(uint i, uint j) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::ijFromLocalPos(const cvf::Vec2d& localPos2d) const
|
||||
{
|
||||
cvf::Vec2ui ijCoords(localPos2d.x() / sampleSpacing(), localPos2d.y() / sampleSpacing());
|
||||
cvf::Vec2ui ijCoords(localPos2d.x() / m_sampleSpacing, localPos2d.y() / m_sampleSpacing);
|
||||
return ijCoords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<std::pair<size_t, double>>& RimContourMapProjection::cellsAtPos2d(uint i, uint j) const
|
||||
std::vector<std::pair<size_t, double>> RimContourMapProjection::cellsAtPos2d(uint i, uint j) const
|
||||
{
|
||||
return m_projected3dGridIndices[gridIndex(i, j)];
|
||||
size_t cellIndex = this->cellIndex(i, j);
|
||||
if (cellIndex < m_projected3dGridIndices.size())
|
||||
{
|
||||
return m_projected3dGridIndices[cellIndex];
|
||||
}
|
||||
return std::vector<std::pair<size_t, double>>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -677,10 +772,9 @@ const std::vector<std::pair<size_t, double>>& RimContourMapProjection::cellsAtPo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndOverlapVolumeFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues) const
|
||||
{
|
||||
cvf::BoundingBox gridBoundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d top2dElementCentroid(globalPos2d, gridBoundingBox.max().z());
|
||||
cvf::Vec3d bottom2dElementCentroid(globalPos2d, gridBoundingBox.min().z());
|
||||
cvf::Vec3d planarDiagonalVector(0.5 * sampleSpacing(), 0.5 * sampleSpacing(), 0.0);
|
||||
cvf::Vec3d top2dElementCentroid(globalPos2d, m_cellCenterBoundingBox.max().z());
|
||||
cvf::Vec3d bottom2dElementCentroid(globalPos2d, m_cellCenterBoundingBox.min().z());
|
||||
cvf::Vec3d planarDiagonalVector(0.5 * m_sampleSpacing, 0.5 * m_sampleSpacing, 0.0);
|
||||
cvf::Vec3d topNECorner = top2dElementCentroid + planarDiagonalVector;
|
||||
cvf::Vec3d bottomSWCorner = bottom2dElementCentroid - planarDiagonalVector;
|
||||
|
||||
@ -752,9 +846,8 @@ std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndO
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>> RimContourMapProjection::visibleCellsAndLengthInCellFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues /*= nullptr*/) const
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d highestPoint(globalPos2d, boundingBox.max().z());
|
||||
cvf::Vec3d lowestPoint(globalPos2d, boundingBox.min().z());
|
||||
cvf::Vec3d highestPoint(globalPos2d, m_cellCenterBoundingBox.max().z());
|
||||
cvf::Vec3d lowestPoint(globalPos2d, m_cellCenterBoundingBox.min().z());
|
||||
|
||||
cvf::BoundingBox rayBBox;
|
||||
rayBBox.add(highestPoint);
|
||||
@ -898,27 +991,44 @@ RimContourMapView* RimContourMapProjection::view() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimContourMapProjection::gridIndex(uint i, uint j) const
|
||||
size_t RimContourMapProjection::cellIndex(uint i, uint j) const
|
||||
{
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
CVF_ASSERT(i < m_mapSize.x());
|
||||
CVF_ASSERT(j < m_mapSize.y());
|
||||
|
||||
CVF_ASSERT(i < gridSize2d.x());
|
||||
CVF_ASSERT(j < gridSize2d.y());
|
||||
|
||||
return i + j * gridSize2d.x();
|
||||
return i + j * m_mapSize.x();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::ijFromGridIndex(size_t index) const
|
||||
size_t RimContourMapProjection::vertexIndex(uint i, uint j) const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(index < vertexCount());
|
||||
return i + j * (m_mapSize.x() + 1);
|
||||
}
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::ijFromVertexIndex(size_t gridIndex) const
|
||||
{
|
||||
cvf::Vec2ui gridSize = vertexGridSize();
|
||||
|
||||
uint quotientX = static_cast<uint>(index) / gridSize2d.x();
|
||||
uint remainderX = static_cast<uint>(index) % gridSize2d.x();
|
||||
uint quotientX = static_cast<uint>(gridIndex) / gridSize.x();
|
||||
uint remainderX = static_cast<uint>(gridIndex) % gridSize.x();
|
||||
|
||||
return cvf::Vec2ui(remainderX, quotientX);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::ijFromCellIndex(size_t cellIndex) const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(cellIndex < numberOfCells());
|
||||
|
||||
uint quotientX = static_cast<uint>(cellIndex) / m_mapSize.x();
|
||||
uint remainderX = static_cast<uint>(cellIndex) % m_mapSize.x();
|
||||
|
||||
return cvf::Vec2ui(remainderX, quotientX);
|
||||
}
|
||||
@ -961,6 +1071,15 @@ void RimContourMapProjection::updateLegend()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimContourMapProjection::numberOfVertices() const
|
||||
{
|
||||
cvf::Vec2ui gridSize = vertexGridSize();
|
||||
return static_cast<size_t>(gridSize.x()) * static_cast<size_t>(gridSize.y());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1008,37 +1127,68 @@ void RimContourMapProjection::updatedWeightingResult()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimContourMapProjection::checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint) const
|
||||
bool RimContourMapProjection::checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, cvf::Vec2ui* contourMapCell, double* valueAtPoint) const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(contourMapPoint);
|
||||
CVF_TIGHT_ASSERT(valueAtPoint);
|
||||
cvf::Vec2d localPos2d(localPoint3d.x(), localPoint3d.y());
|
||||
cvf::Vec2ui pickedCellIJ = ijFromLocalPos(localPos2d);
|
||||
*valueAtPoint = value(pickedCellIJ.x(), pickedCellIJ.y());
|
||||
cvf::Vec3d localPos3d(localPoint3d.x(), localPoint3d.y(), 0.0);
|
||||
cvf::Vec2d localPos2d(localPos3d.x(), localPos3d.y());
|
||||
cvf::Vec2ui pickedCell = ijFromLocalPos(localPos2d);
|
||||
*contourMapCell = pickedCell;
|
||||
|
||||
if (hasResultInCell(pickedCell.x(), pickedCell.y()))
|
||||
{
|
||||
cvf::Vec2d gridorigin(m_fullBoundingBox.min().x(), m_fullBoundingBox.min().y());
|
||||
cvf::Vec2d cellCenter = cellCenterPos(pickedCell.x(), pickedCell.y()) - gridorigin;
|
||||
std::array <cvf::Vec3d, 4> x;
|
||||
x[0] = cvf::Vec3d(cellCenter + cvf::Vec2d(-m_sampleSpacing * 0.5, -m_sampleSpacing * 0.5), 0.0);
|
||||
x[1] = cvf::Vec3d(cellCenter + cvf::Vec2d(m_sampleSpacing*0.5, -m_sampleSpacing * 0.5), 0.0);
|
||||
x[2] = cvf::Vec3d(cellCenter + cvf::Vec2d(m_sampleSpacing*0.5, m_sampleSpacing * 0.5), 0.0);
|
||||
x[3] = cvf::Vec3d(cellCenter + cvf::Vec2d(-m_sampleSpacing * 0.5, m_sampleSpacing * 0.5), 0.0);
|
||||
cvf::Vec4d baryCentricCoords = cvf::GeometryTools::barycentricCoords(x[0], x[1], x[2], x[3], localPos3d);
|
||||
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec2d origin(boundingBox.min().x(), boundingBox.min().y());
|
||||
*contourMapPoint = localPos2d + origin;
|
||||
std::array<cvf::Vec2ui, 4> v;
|
||||
v[0] = pickedCell;
|
||||
v[1] = cvf::Vec2ui(pickedCell.x() + 1u, pickedCell.y());
|
||||
v[2] = cvf::Vec2ui(pickedCell.x() + 1u, pickedCell.y() + 1u);
|
||||
v[3] = cvf::Vec2ui(pickedCell.x(), pickedCell.y() + 1u);
|
||||
|
||||
return true;
|
||||
double value = 0.0;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
value += baryCentricCoords[i] * valueAtVertex(v[i].x(), v[i].y());
|
||||
}
|
||||
|
||||
*valueAtPoint = value;
|
||||
*contourMapPoint = localPos2d + gridorigin;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimContourMapProjection::xPositions() const
|
||||
void RimContourMapProjection::setPickPoint(cvf::Vec2d pickedPoint)
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||
double origin = boundingBox.min().x();
|
||||
m_pickPoint = pickedPoint;
|
||||
}
|
||||
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimContourMapProjection::xVertexPositions() const
|
||||
{
|
||||
double gridExtent = m_fullBoundingBox.extent().x();
|
||||
double origin = m_fullBoundingBox.min().x();
|
||||
|
||||
cvf::Vec2ui gridSize = vertexGridSize();
|
||||
std::vector<double> positions;
|
||||
positions.reserve(gridSize2d.x());
|
||||
for (uint i = 0; i < gridSize2d.x(); ++i)
|
||||
positions.reserve(gridSize.x());
|
||||
for (uint i = 0; i < gridSize.x(); ++i)
|
||||
{
|
||||
positions.push_back(origin + (i * gridExtent.x()) / (gridSize2d.x() - 1));
|
||||
positions.push_back(origin + (i * gridExtent) / (gridSize.x() - 1));
|
||||
}
|
||||
|
||||
return positions;
|
||||
@ -1047,18 +1197,17 @@ std::vector<double> RimContourMapProjection::xPositions() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimContourMapProjection::yPositions() const
|
||||
std::vector<double> RimContourMapProjection::yVertexPositions() const
|
||||
{
|
||||
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||
double origin = boundingBox.min().y();
|
||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||
double gridExtent = m_fullBoundingBox.extent().y();
|
||||
double origin = m_fullBoundingBox.min().y();
|
||||
|
||||
cvf::Vec2ui gridSize = vertexGridSize();
|
||||
std::vector<double> positions;
|
||||
positions.reserve(gridSize2d.y());
|
||||
for (uint j = 0; j < gridSize2d.y(); ++j)
|
||||
positions.reserve(gridSize.y());
|
||||
for (uint j = 0; j < gridSize.y(); ++j)
|
||||
{
|
||||
positions.push_back(origin + (j * gridExtent.y()) / (gridSize2d.y() - 1));
|
||||
positions.push_back(origin + (j * gridExtent) / (gridSize.y() - 1));
|
||||
}
|
||||
|
||||
return positions;
|
||||
@ -1169,3 +1318,38 @@ bool RimContourMapProjection::getLegendRangeFrom3dGrid() const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::updateGridInformation()
|
||||
{
|
||||
m_sampleSpacing = m_relativeSampleSpacing * mainGrid()->characteristicIJCellSize();
|
||||
|
||||
m_fullBoundingBox = eclipseCase()->activeCellsBoundingBox();
|
||||
cvf::Vec3d minPoint = m_fullBoundingBox.min();
|
||||
cvf::Vec3d maxPoint = m_fullBoundingBox.max();
|
||||
|
||||
double shrinkage = m_sampleSpacing * 0.5;
|
||||
minPoint.x() += shrinkage;
|
||||
minPoint.y() += shrinkage;
|
||||
maxPoint.x() -= shrinkage;
|
||||
maxPoint.y() -= shrinkage;
|
||||
m_cellCenterBoundingBox = cvf::BoundingBox(minPoint, maxPoint);
|
||||
|
||||
m_mapSize = calculateMapSize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec2ui RimContourMapProjection::calculateMapSize() const
|
||||
{
|
||||
cvf::Vec3d gridExtent = m_cellCenterBoundingBox.extent();
|
||||
|
||||
uint projectionSizeX = static_cast<uint>(std::ceil(gridExtent.x() / m_sampleSpacing));
|
||||
uint projectionSizeY = static_cast<uint>(std::ceil(gridExtent.y() / m_sampleSpacing));
|
||||
|
||||
return cvf::Vec2ui(projectionSizeX, projectionSizeY);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
void generateVertices(cvf::Vec3fArray* vertices, const caf::DisplayCoordTransform* displayCoordTransform);
|
||||
|
||||
ContourPolygons generateContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform);
|
||||
cvf::ref<cvf::Vec3fArray> generatePickPointPolygon(const caf::DisplayCoordTransform* displayCoordTransform);
|
||||
|
||||
void generateResults();
|
||||
double maxValue() const;
|
||||
double minValue() const;
|
||||
@ -75,6 +77,9 @@ public:
|
||||
double sumAllValues() const;
|
||||
double sampleSpacing() const;
|
||||
double sampleSpacingFactor() const;
|
||||
cvf::Vec2ui mapSize() const;
|
||||
cvf::Vec2ui vertexGridSize() const;
|
||||
|
||||
bool showContourLines() const;
|
||||
|
||||
const std::vector<double>& aggregatedResults() const;
|
||||
@ -82,40 +87,47 @@ public:
|
||||
bool isMeanResult() const;
|
||||
bool isSummationResult() const;
|
||||
bool isStraightSummationResult() const;
|
||||
static bool isStraightSummationResult(ResultAggregationEnum aggregationType);
|
||||
bool isColumnResult() const;
|
||||
|
||||
double value(uint i, uint j) const;
|
||||
double valueAtVertex(uint i, uint j) const;
|
||||
bool hasResultAtVertex(uint i, uint j) const;
|
||||
|
||||
bool hasResultAt(uint i, uint j) const;
|
||||
|
||||
cvf::Vec2ui surfaceGridSize() const;
|
||||
uint vertexCount() const;
|
||||
uint validVertexCount() const;
|
||||
RimRegularLegendConfig* legendConfig() const;
|
||||
|
||||
size_t gridIndex(uint i, uint j) const;
|
||||
cvf::Vec2ui ijFromGridIndex(size_t gridIndex) const;
|
||||
size_t cellIndex(uint i, uint j) const;
|
||||
size_t vertexIndex(uint i, uint j) const;
|
||||
cvf::Vec2ui ijFromVertexIndex(size_t gridIndex) const;
|
||||
cvf::Vec2ui ijFromCellIndex(size_t mapIndex) const;
|
||||
void updateLegend();
|
||||
|
||||
size_t numberOfVertices() const;
|
||||
uint numberOfCells() const;
|
||||
uint numberOfValidCells() const;
|
||||
|
||||
ResultAggregation resultAggregation() const;
|
||||
QString resultAggregationText() const;
|
||||
QString resultDescriptionText() const;
|
||||
void updatedWeightingResult();
|
||||
|
||||
bool checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint) const;
|
||||
bool checkForMapIntersection(const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, cvf::Vec2ui* contourMapCell, double* valueAtPoint) const;
|
||||
void setPickPoint(cvf::Vec2d pickedPoint);
|
||||
|
||||
protected:
|
||||
double calculateValue(uint i, uint j) const;
|
||||
|
||||
cvf::BoundingBox expandedBoundingBox() const;
|
||||
double valueInCell(uint i, uint j) const;
|
||||
bool hasResultInCell(uint i, uint j) const;
|
||||
|
||||
double calculateValueInCell(uint i, uint j) const;
|
||||
double calculateValueAtVertex(uint i, uint j) const;
|
||||
|
||||
void generateGridMapping();
|
||||
void calculateTotalCellVisibility();
|
||||
cvf::Vec2d globalPos2d(uint i, uint j) const;
|
||||
cvf::Vec2d cellCenterPos(uint i, uint j) const;
|
||||
cvf::Vec2ui ijFromLocalPos(const cvf::Vec2d& localPos2d) const;
|
||||
|
||||
const std::vector<std::pair<size_t, double>>& cellsAtPos2d(uint i, uint j) const;
|
||||
std::vector<double> xPositions() const;
|
||||
std::vector<double> yPositions() const;
|
||||
std::vector<std::pair<size_t, double>> cellsAtPos2d(uint i, uint j) const;
|
||||
std::vector<double> xVertexPositions() const;
|
||||
std::vector<double> yVertexPositions() const;
|
||||
|
||||
std::vector<std::pair<size_t, double>> visibleCellsAndOverlapVolumeFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues = nullptr) const;
|
||||
std::vector<std::pair<size_t, double>> visibleCellsAndLengthInCellFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues = nullptr) const;
|
||||
@ -131,6 +143,9 @@ protected:
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
void initAfterRead() override;
|
||||
bool getLegendRangeFrom3dGrid() const;
|
||||
void updateGridInformation();
|
||||
cvf::Vec2ui calculateMapSize() const;
|
||||
|
||||
protected:
|
||||
caf::PdmField<double> m_relativeSampleSpacing;
|
||||
caf::PdmField<ResultAggregation> m_resultAggregation;
|
||||
@ -139,9 +154,17 @@ protected:
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_weightingResult;
|
||||
cvf::ref<cvf::UByteArray> m_cellGridIdxVisibility;
|
||||
|
||||
std::vector<double> m_aggregatedResults;
|
||||
std::vector<double> m_aggregatedResults;
|
||||
std::vector<double> m_aggregatedVertexResults;
|
||||
|
||||
std::vector<std::vector<std::pair<size_t, double>>> m_projected3dGridIndices;
|
||||
|
||||
cvf::ref<RigResultAccessor> m_resultAccessor;
|
||||
|
||||
|
||||
cvf::Vec2d m_pickPoint;
|
||||
|
||||
cvf::Vec2ui m_mapSize;
|
||||
cvf::BoundingBox m_cellCenterBoundingBox;
|
||||
cvf::BoundingBox m_fullBoundingBox;
|
||||
double m_sampleSpacing;
|
||||
};
|
||||
|
@ -200,18 +200,19 @@ void RimContourMapView::updateCurrentTimeStep()
|
||||
static_cast<RimEclipsePropertyFilterCollection*>(nativePropertyFilterCollection())->updateFromCurrentTimeStep();
|
||||
|
||||
this->updateVisibleGeometriesAndCellColors();
|
||||
|
||||
|
||||
if (m_contourMapProjection->isChecked())
|
||||
{
|
||||
m_contourMapProjection->generateResults();
|
||||
}
|
||||
|
||||
updateLegends(); // To make sure the scalar mappers are set up correctly
|
||||
|
||||
appendWellsAndFracturesToModel();
|
||||
|
||||
appendContourMapProjectionToModel();
|
||||
|
||||
appendPickPointVisToModel();
|
||||
|
||||
if (m_overlayInfoConfig->isActive())
|
||||
{
|
||||
m_overlayInfoConfig()->update3DInfo();
|
||||
@ -255,6 +256,31 @@ void RimContourMapView::appendContourMapProjectionToModel()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapView::appendPickPointVisToModel()
|
||||
{
|
||||
if (m_viewer && m_contourMapProjection->isChecked())
|
||||
{
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::String name = "ContourMapPickPoint";
|
||||
this->removeModelByName(frameScene, name);
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> contourMapProjectionModelBasicList = new cvf::ModelBasicList;
|
||||
contourMapProjectionModelBasicList->setName(name);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = this->displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel(contourMapProjectionModelBasicList.p(), transForm.p());
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(contourMapProjectionModelBasicList.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
|
||||
void setFaultVisParameters();
|
||||
void appendContourMapProjectionToModel();
|
||||
|
||||
void appendPickPointVisToModel();
|
||||
void updateLegends() override;
|
||||
void updateViewWidgetAfterCreation() override;
|
||||
void updateViewFollowingRangeFilterUpdates() override;
|
||||
@ -53,12 +53,11 @@ protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
virtual std::set<RivCellSetEnum> allVisibleFaultGeometryTypes() const override;
|
||||
|
||||
|
||||
private:
|
||||
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
|
||||
caf::PdmChildField<RimContourMapProjection*> m_contourMapProjection;
|
||||
caf::PdmField<bool> m_showAxisLines;
|
||||
caf::PdmChildField<RimContourMapNameConfig*> m_nameConfig;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user