mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3591 Improve edges on contour map.
This commit is contained in:
parent
f87f1430dc
commit
ee388ca4b0
@ -1,8 +1,10 @@
|
|||||||
#include "Riv2dGridProjectionPartMgr.h"
|
#include "Riv2dGridProjectionPartMgr.h"
|
||||||
|
|
||||||
|
#include "RiaWeightedMeanCalculator.h"
|
||||||
#include "RivMeshLinesSourceInfo.h"
|
#include "RivMeshLinesSourceInfo.h"
|
||||||
#include "RivScalarMapperUtils.h"
|
#include "RivScalarMapperUtils.h"
|
||||||
|
|
||||||
|
#include "Rim2dEclipseView.h"
|
||||||
#include "Rim2dGridProjection.h"
|
#include "Rim2dGridProjection.h"
|
||||||
|
|
||||||
#include "cafEffectGenerator.h"
|
#include "cafEffectGenerator.h"
|
||||||
@ -16,9 +18,10 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
Riv2dGridProjectionPartMgr::Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection)
|
Riv2dGridProjectionPartMgr::Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection, Rim2dEclipseView* contourMap)
|
||||||
{
|
{
|
||||||
m_2dGridProjection = gridProjection;
|
m_2dGridProjection = gridProjection;
|
||||||
|
m_parentContourMap = contourMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -34,7 +37,7 @@ void Riv2dGridProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList* mo
|
|||||||
|
|
||||||
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords();
|
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords();
|
||||||
cvf::ScalarMapper* mapper = m_2dGridProjection->legendConfig()->scalarMapper();
|
cvf::ScalarMapper* mapper = m_2dGridProjection->legendConfig()->scalarMapper();
|
||||||
RivScalarMapperUtils::applyTextureResultsToPart(part.p(), textureCoords.p(), mapper, 1.0f, caf::FC_NONE, true);
|
RivScalarMapperUtils::applyTextureResultsToPart(part.p(), textureCoords.p(), mapper, 1.0f, caf::FC_NONE, true, m_parentContourMap->backgroundColor());
|
||||||
|
|
||||||
part->setSourceInfo(new RivMeshLinesSourceInfo(m_2dGridProjection.p()));
|
part->setSourceInfo(new RivMeshLinesSourceInfo(m_2dGridProjection.p()));
|
||||||
|
|
||||||
@ -81,11 +84,42 @@ cvf::ref<cvf::Vec2fArray> Riv2dGridProjectionPartMgr::createTextureCoords() cons
|
|||||||
m_2dGridProjection->legendConfig()->scalarMapper()->mapToTextureCoord(value);
|
m_2dGridProjection->legendConfig()->scalarMapper()->mapToTextureCoord(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// Perform weighted averaging of the valid neighbors
|
||||||
|
RiaWeightedMeanCalculator<double> calc;
|
||||||
|
for (int dj = -1; dj <= 1; ++dj)
|
||||||
|
{
|
||||||
|
int fullJ = static_cast<int>(j) + dj;
|
||||||
|
if (fullJ >= 0 && fullJ < static_cast<int>(patchSize.y()))
|
||||||
|
{
|
||||||
|
for (int di = -1; di <= 1; ++di)
|
||||||
|
{
|
||||||
|
if (di == 0 && dj == 0) continue;
|
||||||
|
|
||||||
|
int fullI = static_cast<int>(i) + di;
|
||||||
|
if (fullI >= 0 && fullI < static_cast<int>(patchSize.x()))
|
||||||
|
{
|
||||||
|
if (m_2dGridProjection->hasResultAt(fullI, fullJ))
|
||||||
|
{
|
||||||
|
double value = m_2dGridProjection->value(fullI, fullJ);
|
||||||
|
calc.addValueAndWeight(value, 1.0 / std::sqrt(di*di + dj * dj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (calc.validAggregatedWeight())
|
||||||
|
{
|
||||||
|
(*textureCoords)[i + j * patchSize.x()] =
|
||||||
|
m_2dGridProjection->legendConfig()->scalarMapper()->mapToTextureCoord(calc.weightedMean());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
(*textureCoords)[i + j * patchSize.x()] = cvf::Vec2f(1.0, 1.0);
|
(*textureCoords)[i + j * patchSize.x()] = cvf::Vec2f(1.0, 1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return textureCoords;
|
return textureCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,17 +132,17 @@ void Riv2dGridProjectionPartMgr::removeTrianglesWithNoResult(cvf::UIntArray* ver
|
|||||||
|
|
||||||
for (size_t n = 0; n < vertices->size(); n += 3)
|
for (size_t n = 0; n < vertices->size(); n += 3)
|
||||||
{
|
{
|
||||||
bool anyInvalid = false;
|
bool anyValid = false;
|
||||||
for (size_t t = 0; !anyInvalid && t < 3; ++t)
|
for (size_t t = 0; !anyValid && t < 3; ++t)
|
||||||
{
|
{
|
||||||
cvf::uint vertexNumber = (*vertices)[n + t];
|
cvf::uint vertexNumber = (*vertices)[n + t];
|
||||||
cvf::Vec2ui ij = m_2dGridProjection->ijFromGridIndex(vertexNumber);
|
cvf::Vec2ui ij = m_2dGridProjection->ijFromGridIndex(vertexNumber);
|
||||||
if (!m_2dGridProjection->hasResultAt(ij.x(), ij.y()))
|
if (m_2dGridProjection->hasResultAt(ij.x(), ij.y()))
|
||||||
{
|
{
|
||||||
anyInvalid = true;
|
anyValid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t t = 0; !anyInvalid && t < 3; ++t)
|
for (size_t t = 0; anyValid && t < 3; ++t)
|
||||||
{
|
{
|
||||||
cvf::uint vertexNumber = (*vertices)[n + t];
|
cvf::uint vertexNumber = (*vertices)[n + t];
|
||||||
trianglesWithResult.push_back(vertexNumber);
|
trianglesWithResult.push_back(vertexNumber);
|
||||||
|
@ -26,12 +26,13 @@
|
|||||||
#include "cvfModelBasicList.h"
|
#include "cvfModelBasicList.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
|
|
||||||
|
class Rim2dEclipseView;
|
||||||
class Rim2dGridProjection;
|
class Rim2dGridProjection;
|
||||||
|
|
||||||
class Riv2dGridProjectionPartMgr : public cvf::Object
|
class Riv2dGridProjectionPartMgr : public cvf::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection);
|
Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection, Rim2dEclipseView* contourMap);
|
||||||
|
|
||||||
void appendProjectionToModel(cvf::ModelBasicList* model,
|
void appendProjectionToModel(cvf::ModelBasicList* model,
|
||||||
const caf::DisplayCoordTransform* displayCoordTransform) const;
|
const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||||
@ -44,5 +45,6 @@ private:
|
|||||||
std::vector<cvf::ref<cvf::DrawableGeo>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
std::vector<cvf::ref<cvf::DrawableGeo>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||||
private:
|
private:
|
||||||
caf::PdmPointer<Rim2dGridProjection> m_2dGridProjection;
|
caf::PdmPointer<Rim2dGridProjection> m_2dGridProjection;
|
||||||
|
caf::PdmPointer<Rim2dEclipseView> m_parentContourMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#include "RivScalarMapperUtils.h"
|
#include "RivScalarMapperUtils.h"
|
||||||
|
|
||||||
#include "RiaColorTables.h"
|
|
||||||
|
|
||||||
#include "RimCellEdgeColors.h"
|
#include "RimCellEdgeColors.h"
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
#include "RimEclipseView.h"
|
#include "RimEclipseView.h"
|
||||||
@ -41,14 +39,14 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting)
|
void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting, const cvf::Color3f& undefColor)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(part && textureCoords && mapper);
|
CVF_ASSERT(part && textureCoords && mapper);
|
||||||
|
|
||||||
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
||||||
if (dg) dg->setTextureCoordArray(textureCoords);
|
if (dg) dg->setTextureCoordArray(textureCoords);
|
||||||
|
|
||||||
cvf::ref<cvf::Effect> scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting);
|
cvf::ref<cvf::Effect> scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting, undefColor);
|
||||||
part->setEffect(scalarEffect.p());
|
part->setEffect(scalarEffect.p());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +120,7 @@ cvf::ref<cvf::Effect> RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::ref<cvf::Effect> RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting)
|
cvf::ref<cvf::Effect> RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting, const cvf::Color3f& undefColor)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(mapper);
|
CVF_ASSERT(mapper);
|
||||||
|
|
||||||
@ -130,7 +128,7 @@ cvf::ref<cvf::Effect> RivScalarMapperUtils::createScalarMapperEffect(const cvf::
|
|||||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||||
scalarEffgen.setOpacityLevel(opacityLevel);
|
scalarEffgen.setOpacityLevel(opacityLevel);
|
||||||
scalarEffgen.setFaceCulling(faceCulling);
|
scalarEffgen.setFaceCulling(faceCulling);
|
||||||
scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor());
|
scalarEffgen.setUndefinedColor(undefColor);
|
||||||
scalarEffgen.disableLighting(disableLighting);
|
scalarEffgen.disableLighting(disableLighting);
|
||||||
|
|
||||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateCachedEffect();
|
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateCachedEffect();
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiaColorTables.h"
|
||||||
|
|
||||||
#include "cafEffectGenerator.h"
|
#include "cafEffectGenerator.h"
|
||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
@ -43,7 +45,7 @@ class RimCellEdgeColors;
|
|||||||
class RivScalarMapperUtils
|
class RivScalarMapperUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting, const cvf::Color3f& undefColor = cvf::Color3f(RiaColorTables::undefinedCellColor()));
|
||||||
static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
||||||
|
|
||||||
static cvf::ref<cvf::Effect> createCellEdgeEffect(cvf::DrawableGeo* dg,
|
static cvf::ref<cvf::Effect> createCellEdgeEffect(cvf::DrawableGeo* dg,
|
||||||
@ -58,7 +60,7 @@ public:
|
|||||||
bool disableLighting);
|
bool disableLighting);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static cvf::ref<cvf::Effect> createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
static cvf::ref<cvf::Effect> createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting, const cvf::Color3f& undefColor = cvf::Color3f(RiaColorTables::undefinedCellColor()));
|
||||||
static cvf::ref<cvf::Effect> createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
static cvf::ref<cvf::Effect> createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ Rim2dEclipseView::Rim2dEclipseView()
|
|||||||
wellCollection()->isActive = false;
|
wellCollection()->isActive = false;
|
||||||
faultCollection()->showFaultCollection = false;
|
faultCollection()->showFaultCollection = false;
|
||||||
|
|
||||||
m_grid2dProjectionPartMgr = new Riv2dGridProjectionPartMgr(grid2dProjection());
|
m_grid2dProjectionPartMgr = new Riv2dGridProjectionPartMgr(grid2dProjection(), this);
|
||||||
|
|
||||||
((RiuViewerToViewInterface*)this)->setCameraPosition(defaultViewMatrix);
|
((RiuViewerToViewInterface*)this)->setCameraPosition(defaultViewMatrix);
|
||||||
}
|
}
|
||||||
@ -81,6 +81,7 @@ void Rim2dEclipseView::initAfterRead()
|
|||||||
setShowGridBox(false);
|
setShowGridBox(false);
|
||||||
meshMode.setValue(NO_MESH);
|
meshMode.setValue(NO_MESH);
|
||||||
surfaceMode.setValue(FAULTS);
|
surfaceMode.setValue(FAULTS);
|
||||||
|
scheduleCreateDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -129,12 +130,13 @@ void Rim2dEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrderi
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void Rim2dEclipseView::updateCurrentTimeStep()
|
void Rim2dEclipseView::updateCurrentTimeStep()
|
||||||
{
|
{
|
||||||
RimEclipseView::updateCurrentTimeStep();
|
|
||||||
if (m_2dGridProjection->isChecked())
|
if (m_2dGridProjection->isChecked())
|
||||||
{
|
{
|
||||||
m_2dGridProjection->generateResults();
|
m_2dGridProjection->generateResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RimEclipseView::updateCurrentTimeStep();
|
||||||
|
|
||||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||||
|
|
||||||
if (m_2dGridProjection->isChecked())
|
if (m_2dGridProjection->isChecked())
|
||||||
@ -166,12 +168,15 @@ void Rim2dEclipseView::updateLegends()
|
|||||||
if (m_2dGridProjection && m_2dGridProjection->isChecked())
|
if (m_2dGridProjection && m_2dGridProjection->isChecked())
|
||||||
{
|
{
|
||||||
RimRegularLegendConfig* projectionLegend = m_2dGridProjection->legendConfig();
|
RimRegularLegendConfig* projectionLegend = m_2dGridProjection->legendConfig();
|
||||||
if (projectionLegend && projectionLegend->showLegend())
|
if (projectionLegend)
|
||||||
{
|
{
|
||||||
m_2dGridProjection->updateLegend();
|
m_2dGridProjection->updateLegend();
|
||||||
|
if (projectionLegend->showLegend())
|
||||||
|
{
|
||||||
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
|
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -212,13 +217,15 @@ void Rim2dEclipseView::onLoadDataAndUpdate()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void Rim2dEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
void Rim2dEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||||
{
|
{
|
||||||
|
RimEclipseView::fieldChangedByUi(changedField, oldValue, newValue);
|
||||||
|
|
||||||
if (changedField == &m_showAxisLines)
|
if (changedField == &m_showAxisLines)
|
||||||
{
|
{
|
||||||
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
||||||
scheduleCreateDisplayModelAndRedraw();
|
scheduleCreateDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
else
|
else if (changedField == backgroundColorField())
|
||||||
{
|
{
|
||||||
RimEclipseView::fieldChangedByUi(changedField, oldValue, newValue);
|
scheduleCreateDisplayModelAndRedraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,16 @@ Rim2dGridProjection::~Rim2dGridProjection()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::BoundingBox Rim2dGridProjection::expandedBoundingBox() const
|
||||||
|
{
|
||||||
|
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
||||||
|
//boundingBox.expand(m_sampleSpacing * 0.5);
|
||||||
|
return boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -79,8 +89,7 @@ void Rim2dGridProjection::generateGridMapping()
|
|||||||
calculateCellRangeVisibility();
|
calculateCellRangeVisibility();
|
||||||
calculatePropertyFilterVisibility();
|
calculatePropertyFilterVisibility();
|
||||||
|
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::Vec3d gridExtent = expandedBoundingBox().extent();
|
||||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
|
||||||
|
|
||||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||||
|
|
||||||
@ -110,7 +119,7 @@ void Rim2dGridProjection::generateVertices(cvf::Vec3fArray* vertices, const caf:
|
|||||||
vertices->resize(vertexCount());
|
vertices->resize(vertexCount());
|
||||||
|
|
||||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
|
|
||||||
int nVertices = vertexCount();
|
int nVertices = vertexCount();
|
||||||
|
|
||||||
@ -135,7 +144,7 @@ Rim2dGridProjection::ContourPolygons Rim2dGridProjection::generateContourPolygon
|
|||||||
{
|
{
|
||||||
std::vector<cvf::ref<cvf::Vec3fArray>> contourPolygons;
|
std::vector<cvf::ref<cvf::Vec3fArray>> contourPolygons;
|
||||||
|
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
|
|
||||||
std::vector<double> contourLevels;
|
std::vector<double> contourLevels;
|
||||||
legendConfig()->scalarMapper()->majorTickValues(&contourLevels);
|
legendConfig()->scalarMapper()->majorTickValues(&contourLevels);
|
||||||
@ -149,6 +158,8 @@ Rim2dGridProjection::ContourPolygons Rim2dGridProjection::generateContourPolygon
|
|||||||
|
|
||||||
contourPolygons.reserve(contourLines.size());
|
contourPolygons.reserve(contourLines.size());
|
||||||
for (size_t i = 0; i < contourLines.size(); ++i)
|
for (size_t i = 0; i < contourLines.size(); ++i)
|
||||||
|
{
|
||||||
|
if (!contourLines[i].empty())
|
||||||
{
|
{
|
||||||
cvf::ref<cvf::Vec3fArray> contourPolygon = new cvf::Vec3fArray(contourLines[i].size());
|
cvf::ref<cvf::Vec3fArray> contourPolygon = new cvf::Vec3fArray(contourLines[i].size());
|
||||||
for (size_t j = 0; j < contourLines[i].size(); ++j)
|
for (size_t j = 0; j < contourLines[i].size(); ++j)
|
||||||
@ -160,6 +171,7 @@ Rim2dGridProjection::ContourPolygons Rim2dGridProjection::generateContourPolygon
|
|||||||
contourPolygons.push_back(contourPolygon);
|
contourPolygons.push_back(contourPolygon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return contourPolygons;
|
return contourPolygons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +343,7 @@ bool Rim2dGridProjection::hasResultAt(uint i, uint j) const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::Vec2ui Rim2dGridProjection::surfaceGridSize() const
|
cvf::Vec2ui Rim2dGridProjection::surfaceGridSize() const
|
||||||
{
|
{
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||||
|
|
||||||
uint projectionSizeX = static_cast<uint>(std::ceil(gridExtent.x() / m_sampleSpacing)) + 1u;
|
uint projectionSizeX = static_cast<uint>(std::ceil(gridExtent.x() / m_sampleSpacing)) + 1u;
|
||||||
@ -425,7 +437,7 @@ void Rim2dGridProjection::calculatePropertyFilterVisibility()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::Vec2d Rim2dGridProjection::globalPos2d(uint i, uint j) const
|
cvf::Vec2d Rim2dGridProjection::globalPos2d(uint i, uint j) const
|
||||||
{
|
{
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||||
cvf::Vec2d origin(boundingBox.min().x(), boundingBox.min().y());
|
cvf::Vec2d origin(boundingBox.min().x(), boundingBox.min().y());
|
||||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||||
@ -447,7 +459,7 @@ const std::vector<std::pair<size_t, float>>& Rim2dGridProjection::cellsAtPos2d(u
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<std::pair<size_t, float>> Rim2dGridProjection::visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d) const
|
std::vector<std::pair<size_t, float>> Rim2dGridProjection::visibleCellsAndWeightMatching2dPoint(const cvf::Vec2d& globalPos2d) const
|
||||||
{
|
{
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
cvf::Vec3d highestPoint(globalPos2d, boundingBox.max().z());
|
cvf::Vec3d highestPoint(globalPos2d, boundingBox.max().z());
|
||||||
cvf::Vec3d lowestPoint(globalPos2d, boundingBox.min().z());
|
cvf::Vec3d lowestPoint(globalPos2d, boundingBox.min().z());
|
||||||
|
|
||||||
@ -471,7 +483,7 @@ std::vector<std::pair<size_t, float>> Rim2dGridProjection::visibleCellsAndWeight
|
|||||||
localGrid->cellCornerVertices(localCellIdx, hexCorners);
|
localGrid->cellCornerVertices(localCellIdx, hexCorners);
|
||||||
std::vector<HexIntersectionInfo> intersections;
|
std::vector<HexIntersectionInfo> intersections;
|
||||||
float weight = 1.0f;
|
float weight = 1.0f;
|
||||||
if (false && RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections))
|
if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections))
|
||||||
{
|
{
|
||||||
weight = std::max(1.0, (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length());
|
weight = std::max(1.0, (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length());
|
||||||
}
|
}
|
||||||
@ -539,7 +551,7 @@ void Rim2dGridProjection::updateLegend()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<double> Rim2dGridProjection::xPositions() const
|
std::vector<double> Rim2dGridProjection::xPositions() const
|
||||||
{
|
{
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||||
double origin = boundingBox.min().x();
|
double origin = boundingBox.min().x();
|
||||||
|
|
||||||
@ -560,7 +572,7 @@ std::vector<double> Rim2dGridProjection::xPositions() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<double> Rim2dGridProjection::yPositions() const
|
std::vector<double> Rim2dGridProjection::yPositions() const
|
||||||
{
|
{
|
||||||
cvf::BoundingBox boundingBox = eclipseCase()->activeCellsBoundingBox();
|
cvf::BoundingBox boundingBox = expandedBoundingBox();
|
||||||
cvf::Vec3d gridExtent = boundingBox.extent();
|
cvf::Vec3d gridExtent = boundingBox.extent();
|
||||||
double origin = boundingBox.min().y();
|
double origin = boundingBox.min().y();
|
||||||
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
cvf::Vec2ui gridSize2d = surfaceGridSize();
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "cafPdmField.h"
|
#include "cafPdmField.h"
|
||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
|
|
||||||
|
#include "cvfBoundingBox.h"
|
||||||
#include "cvfGeometryBuilderFaceList.h"
|
#include "cvfGeometryBuilderFaceList.h"
|
||||||
#include "cvfVector2.h"
|
#include "cvfVector2.h"
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ public:
|
|||||||
void updateLegend();
|
void updateLegend();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
cvf::BoundingBox expandedBoundingBox() const;
|
||||||
void generateGridMapping();
|
void generateGridMapping();
|
||||||
void calculateCellRangeVisibility();
|
void calculateCellRangeVisibility();
|
||||||
void calculatePropertyFilterVisibility();
|
void calculatePropertyFilterVisibility();
|
||||||
|
@ -101,6 +101,9 @@ public:
|
|||||||
|
|
||||||
void setName(const QString& name);
|
void setName(const QString& name);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
// Implementation of RiuViewerToViewInterface
|
||||||
|
cvf::Color3f backgroundColor() const override { return m_backgroundColor(); }
|
||||||
|
|
||||||
void setMeshOnlyDrawstyle();
|
void setMeshOnlyDrawstyle();
|
||||||
void setMeshSurfDrawstyle();
|
void setMeshSurfDrawstyle();
|
||||||
void setSurfOnlyDrawstyle();
|
void setSurfOnlyDrawstyle();
|
||||||
@ -166,7 +169,6 @@ protected:
|
|||||||
void createHighlightAndGridBoxDisplayModel();
|
void createHighlightAndGridBoxDisplayModel();
|
||||||
|
|
||||||
// Implementation of RiuViewerToViewInterface
|
// Implementation of RiuViewerToViewInterface
|
||||||
cvf::Color3f backgroundColor() const override { return m_backgroundColor(); }
|
|
||||||
void applyBackgroundColor();
|
void applyBackgroundColor();
|
||||||
|
|
||||||
// Abstract methods to implement in subclasses
|
// Abstract methods to implement in subclasses
|
||||||
|
@ -361,6 +361,7 @@ Rim2dEclipseView* RimEclipseCase::create2dContourMap()
|
|||||||
contourMap->fractureColors()->setDefaultResultName();
|
contourMap->fractureColors()->setDefaultResultName();
|
||||||
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
||||||
contourMap->initAfterReadRecursively();
|
contourMap->initAfterReadRecursively();
|
||||||
|
contourMap->zoomAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
||||||
|
@ -67,7 +67,7 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
|
|||||||
temp2 = std::max(saneValue(gridIndex1d(i + 1, j, nx), dataXY, contourLevels),
|
temp2 = std::max(saneValue(gridIndex1d(i + 1, j, nx), dataXY, contourLevels),
|
||||||
saneValue(gridIndex1d(i + 1, j + 1, nx), dataXY, contourLevels));
|
saneValue(gridIndex1d(i + 1, j + 1, nx), dataXY, contourLevels));
|
||||||
double dmax = std::max(temp1, temp2);
|
double dmax = std::max(temp1, temp2);
|
||||||
if (dmax < contourLevels[0] && dmin > contourLevels[nContourLevels - 1])
|
if (dmax < contourLevels[0] || dmin > contourLevels[nContourLevels - 1])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int k = 0; k < nContourLevels; k++)
|
for (int k = 0; k < nContourLevels; k++)
|
||||||
@ -78,7 +78,15 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
|
|||||||
{
|
{
|
||||||
if (m > 0)
|
if (m > 0)
|
||||||
{
|
{
|
||||||
h[m] = saneValue(gridIndex1d(i + im[m - 1], j + jm[m - 1], nx), dataXY, contourLevels) - contourLevels[k];
|
double value = saneValue(gridIndex1d(i + im[m - 1], j + jm[m - 1], nx), dataXY, contourLevels);
|
||||||
|
if (value == invalidValue(contourLevels))
|
||||||
|
{
|
||||||
|
h[m] = invalidValue(contourLevels);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
h[m] = value - contourLevels[k];
|
||||||
|
}
|
||||||
xh[m] = xCoords[i + im[m - 1]];
|
xh[m] = xCoords[i + im[m - 1]];
|
||||||
yh[m] = yCoords[j + jm[m - 1]];
|
yh[m] = yCoords[j + jm[m - 1]];
|
||||||
}
|
}
|
||||||
@ -198,18 +206,34 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
|
|||||||
} /* j */
|
} /* j */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double caf::ContourLines::contourRange(const std::vector<double>& contourLevels)
|
||||||
|
{
|
||||||
|
return std::max(1.0, contourLevels.back() - contourLevels.front());
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
double caf::ContourLines::invalidValue(const std::vector<double>& contourLevels)
|
||||||
|
{
|
||||||
|
return contourLevels.front() - 1000.0*contourRange(contourLevels);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
double caf::ContourLines::saneValue(int index, const std::vector<double>& dataXY, const std::vector<double>& contourLevels)
|
double caf::ContourLines::saneValue(int index, const std::vector<double>& dataXY, const std::vector<double>& contourLevels)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(index >= 0 && index < static_cast<int>(dataXY.size()));
|
CVF_ASSERT(index >= 0 && index < static_cast<int>(dataXY.size()));
|
||||||
double range = std::max(1.0, contourLevels.back() - contourLevels.front());
|
|
||||||
// Place all invalid values below the bottom contour level.
|
// Place all invalid values below the bottom contour level.
|
||||||
if (dataXY[index] == -std::numeric_limits<double>::infinity() ||
|
if (dataXY[index] == -std::numeric_limits<double>::infinity() ||
|
||||||
dataXY[index] == std::numeric_limits<double>::infinity())
|
dataXY[index] == std::numeric_limits<double>::infinity())
|
||||||
{
|
{
|
||||||
return contourLevels.front() - range;
|
return invalidValue(contourLevels);
|
||||||
}
|
}
|
||||||
return dataXY[index];
|
return dataXY[index];
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ public:
|
|||||||
const std::vector<double>& contourLevels,
|
const std::vector<double>& contourLevels,
|
||||||
std::vector<std::vector<cvf::Vec2d>>* polygons);
|
std::vector<std::vector<cvf::Vec2d>>* polygons);
|
||||||
private:
|
private:
|
||||||
|
static double contourRange(const std::vector<double>& contourLevels);
|
||||||
|
static double invalidValue(const std::vector<double>& contourLevels);
|
||||||
static double saneValue(int index, const std::vector<double>& dataXY, const std::vector<double>& contourLevels);
|
static double saneValue(int index, const std::vector<double>& dataXY, const std::vector<double>& contourLevels);
|
||||||
static double xsect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
|
static double xsect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
|
||||||
static double ysect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
|
static double ysect(int p1, int p2, const std::vector<double>& h, const std::vector<double>& xh, const std::vector<double>& yh);
|
||||||
|
Loading…
Reference in New Issue
Block a user