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:
@@ -1,8 +1,10 @@
|
||||
#include "Riv2dGridProjectionPartMgr.h"
|
||||
|
||||
#include "RiaWeightedMeanCalculator.h"
|
||||
#include "RivMeshLinesSourceInfo.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
|
||||
#include "Rim2dEclipseView.h"
|
||||
#include "Rim2dGridProjection.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
@@ -16,9 +18,10 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Riv2dGridProjectionPartMgr::Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection)
|
||||
Riv2dGridProjectionPartMgr::Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection, Rim2dEclipseView* contourMap)
|
||||
{
|
||||
m_2dGridProjection = gridProjection;
|
||||
m_parentContourMap = contourMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -34,7 +37,7 @@ void Riv2dGridProjectionPartMgr::appendProjectionToModel(cvf::ModelBasicList* mo
|
||||
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = createTextureCoords();
|
||||
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()));
|
||||
|
||||
@@ -82,7 +85,38 @@ cvf::ref<cvf::Vec2fArray> Riv2dGridProjectionPartMgr::createTextureCoords() cons
|
||||
}
|
||||
else
|
||||
{
|
||||
(*textureCoords)[i + j * patchSize.x()] = cvf::Vec2f(1.0, 1.0);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,17 +132,17 @@ void Riv2dGridProjectionPartMgr::removeTrianglesWithNoResult(cvf::UIntArray* ver
|
||||
|
||||
for (size_t n = 0; n < vertices->size(); n += 3)
|
||||
{
|
||||
bool anyInvalid = false;
|
||||
for (size_t t = 0; !anyInvalid && t < 3; ++t)
|
||||
bool anyValid = false;
|
||||
for (size_t t = 0; !anyValid && t < 3; ++t)
|
||||
{
|
||||
cvf::uint vertexNumber = (*vertices)[n + t];
|
||||
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];
|
||||
trianglesWithResult.push_back(vertexNumber);
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
class Rim2dEclipseView;
|
||||
class Rim2dGridProjection;
|
||||
|
||||
class Riv2dGridProjectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection);
|
||||
Riv2dGridProjectionPartMgr(Rim2dGridProjection* gridProjection, Rim2dEclipseView* contourMap);
|
||||
|
||||
void appendProjectionToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
@@ -43,6 +44,7 @@ private:
|
||||
cvf::ref<cvf::DrawableGeo> createDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
std::vector<cvf::ref<cvf::DrawableGeo>> createContourPolygons(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
private:
|
||||
caf::PdmPointer<Rim2dGridProjection> m_2dGridProjection;
|
||||
caf::PdmPointer<Rim2dGridProjection> m_2dGridProjection;
|
||||
caf::PdmPointer<Rim2dEclipseView> m_parentContourMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include "RivScalarMapperUtils.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimEclipseCellColors.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::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(part->drawable());
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -130,7 +128,7 @@ cvf::ref<cvf::Effect> RivScalarMapperUtils::createScalarMapperEffect(const cvf::
|
||||
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset);
|
||||
scalarEffgen.setOpacityLevel(opacityLevel);
|
||||
scalarEffgen.setFaceCulling(faceCulling);
|
||||
scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor());
|
||||
scalarEffgen.setUndefinedColor(undefColor);
|
||||
scalarEffgen.disableLighting(disableLighting);
|
||||
|
||||
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateCachedEffect();
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
@@ -43,7 +45,7 @@ class RimCellEdgeColors;
|
||||
class RivScalarMapperUtils
|
||||
{
|
||||
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 cvf::ref<cvf::Effect> createCellEdgeEffect(cvf::DrawableGeo* dg,
|
||||
@@ -58,7 +60,7 @@ public:
|
||||
bool disableLighting);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user