mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 15:14:07 -06:00
#2828 Allow setting curve domain range outside the range of the curve values.
* Note that this implementation simply removes vertices that are outside the range. * It would look far better to insert vertices at the boundary when a segment is heading out of range. This is more complicated.
This commit is contained in:
parent
d8afe5740b
commit
c7bf6172f3
@ -32,8 +32,6 @@
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -53,9 +51,18 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
|
||||
double planeWidth,
|
||||
const std::vector<cvf::Vec3f>& drawSurfaceVertices)
|
||||
{
|
||||
CVF_ASSERT(rim3dWellLogCurve);
|
||||
|
||||
// Make sure all drawables are cleared in case we return early to avoid a
|
||||
// previous drawable being "stuck" when changing result type.
|
||||
clearCurvePointsAndGeometry();
|
||||
|
||||
float curveUIRange = rim3dWellLogCurve->maxCurveUIValue() - rim3dWellLogCurve->minCurveUIValue();
|
||||
if (curveUIRange < 1.0e-6f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::vector<double> resultValues;
|
||||
std::vector<double> resultMds;
|
||||
@ -70,11 +77,6 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
|
||||
if (resultValues.empty()) return;
|
||||
CVF_ASSERT(resultValues.size() == resultMds.size());
|
||||
|
||||
if (rim3dWellLogCurve->maxCurveValue() - rim3dWellLogCurve->minCurveValue() < 1.0e-6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimWellPathCollection* wellPathCollection = nullptr;
|
||||
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
|
||||
|
||||
@ -117,25 +119,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
|
||||
m_curveValues = std::vector<double>(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end());
|
||||
m_curveMeasuredDepths = std::vector<double>(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end());
|
||||
|
||||
double maxClampedResult = -HUGE_VAL;
|
||||
double minClampedResult = HUGE_VAL;
|
||||
double maxVisibleResult = -std::numeric_limits<float>::max();
|
||||
double minVisibleResult = std::numeric_limits<float>::max();
|
||||
|
||||
double curveEpsilon = 1.0e-6;
|
||||
|
||||
for (double& result : m_curveValues)
|
||||
{
|
||||
if (!RigCurveDataTools::isValidValue(result, false)) continue;
|
||||
|
||||
result = cvf::Math::clamp(result, rim3dWellLogCurve->minCurveValue(), rim3dWellLogCurve->maxCurveValue());
|
||||
|
||||
maxClampedResult = std::max(result, maxClampedResult);
|
||||
minClampedResult = std::min(result, minClampedResult);
|
||||
if ((rim3dWellLogCurve->minCurveUIValue() - result) > curveEpsilon * curveUIRange)
|
||||
{
|
||||
result = -std::numeric_limits<float>::max();
|
||||
}
|
||||
else if ((result - rim3dWellLogCurve->maxCurveUIValue()) > curveEpsilon * curveUIRange)
|
||||
{
|
||||
result = std::numeric_limits<float>::max();
|
||||
}
|
||||
else
|
||||
{
|
||||
maxVisibleResult = std::max(result, maxVisibleResult);
|
||||
minVisibleResult = std::min(result, minVisibleResult);
|
||||
}
|
||||
}
|
||||
|
||||
if (minClampedResult >= maxClampedResult)
|
||||
if (minVisibleResult > maxVisibleResult)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double plotRangeToResultRangeFactor = planeWidth / (maxClampedResult - minClampedResult);
|
||||
double plotRangeToResultRangeFactor = planeWidth / curveUIRange;
|
||||
|
||||
m_curveVertices.reserve(interpolatedWellPathPoints.size());
|
||||
for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++)
|
||||
@ -144,7 +157,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
|
||||
|
||||
if (RigCurveDataTools::isValidValue(m_curveValues[i], false))
|
||||
{
|
||||
scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minClampedResult) * plotRangeToResultRangeFactor;
|
||||
scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - rim3dWellLogCurve->minCurveUIValue()) * plotRangeToResultRangeFactor;
|
||||
}
|
||||
cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]);
|
||||
m_curveVertices.push_back(cvf::Vec3f(curvePoint));
|
||||
@ -169,8 +182,12 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
|
||||
indices.reserve(m_curveVertices.size() * 2);
|
||||
for (size_t i = 0; i < m_curveVertices.size() - 1; ++i)
|
||||
{
|
||||
indices.push_back(cvf::uint(i));
|
||||
indices.push_back(cvf::uint(i + 1));
|
||||
if (RigCurveDataTools::isValidValue(m_curveValues[i], false) &&
|
||||
RigCurveDataTools::isValidValue(m_curveValues[i + 1], false))
|
||||
{
|
||||
indices.push_back(cvf::uint(i));
|
||||
indices.push_back(cvf::uint(i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
|
||||
@ -348,6 +365,15 @@ void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(con
|
||||
}
|
||||
expandedBottomVertices.insert(expandedBottomVertices.end(), extraBottomVertices.begin(), extraBottomVertices.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the invalid points and values.
|
||||
expandedCurveVertices.push_back(m_curveVertices[i]);
|
||||
expandedBottomVertices.push_back(m_bottomVertices[i]);
|
||||
expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]);
|
||||
expandedValues.push_back(m_curveValues[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(expandedCurveVertices.size() == expandedBottomVertices.size());
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -65,17 +64,15 @@ namespace caf
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dWellLogCurve::Rim3dWellLogCurve()
|
||||
: m_minCurveDataValue(-HUGE_VAL)
|
||||
, m_maxCurveDataValue(HUGE_VAL)
|
||||
: m_minCurveDataValue(-std::numeric_limits<float>::max())
|
||||
, m_maxCurveDataValue(std::numeric_limits<float>::max())
|
||||
{
|
||||
CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", "");
|
||||
m_showCurve.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitField(&m_minCurveValue, "MinCurveValue", -HUGE_VAL, "Minimum Curve Value", "", "Clip curve values below this.", "");
|
||||
CAF_PDM_InitField(&m_maxCurveValue, "MaxCurveValue", HUGE_VAL, "Maximum Curve Value", "", "Clip curve values above this.", "");
|
||||
m_minCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
||||
m_maxCurveValue.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits<float>::max(), "Minimum Curve Value", "", "Clip curve values below this.", "");
|
||||
CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits<float>::max(), "Maximum Curve Value", "", "Clip curve values above this.", "");
|
||||
|
||||
CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", "");
|
||||
CAF_PDM_InitField(&m_drawStyle, "DrawStyle", DrawStyleEnum(LINE), "Draw Style", "", "", "");
|
||||
@ -164,17 +161,17 @@ void Rim3dWellLogCurve::setColor(const cvf::Color3f& color)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double Rim3dWellLogCurve::minCurveValue() const
|
||||
float Rim3dWellLogCurve::minCurveUIValue() const
|
||||
{
|
||||
return m_minCurveValue();
|
||||
return m_minCurveUIValue();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double Rim3dWellLogCurve::maxCurveValue() const
|
||||
float Rim3dWellLogCurve::maxCurveUIValue() const
|
||||
{
|
||||
return m_maxCurveValue();
|
||||
return m_maxCurveUIValue();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -212,8 +209,8 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering)
|
||||
// Disable filled draw style in the GUI because of triangle stitching issue #2860.
|
||||
// configurationGroup->add(&m_drawStyle);
|
||||
configurationGroup->add(&m_color);
|
||||
configurationGroup->add(&m_minCurveValue);
|
||||
configurationGroup->add(&m_maxCurveValue);
|
||||
configurationGroup->add(&m_minCurveUIValue);
|
||||
configurationGroup->add(&m_maxCurveUIValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -221,24 +218,10 @@ void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
caf::PdmUiDoubleSliderEditorAttribute* sliderAttribute = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
|
||||
if (sliderAttribute)
|
||||
if (m_minCurveDataValue == -std::numeric_limits<float>::max() &&
|
||||
m_maxCurveDataValue == std::numeric_limits<float>::max())
|
||||
{
|
||||
if (m_minCurveDataValue == -HUGE_VAL &&
|
||||
m_maxCurveDataValue == HUGE_VAL)
|
||||
{
|
||||
this->resetMinMaxValues();
|
||||
}
|
||||
if (field == &m_minCurveValue)
|
||||
{
|
||||
sliderAttribute->m_minimum = m_minCurveDataValue;
|
||||
sliderAttribute->m_maximum = m_maxCurveDataValue;
|
||||
}
|
||||
else if (field == &m_maxCurveValue)
|
||||
{
|
||||
sliderAttribute->m_minimum = m_minCurveDataValue;
|
||||
sliderAttribute->m_maximum = m_maxCurveDataValue;
|
||||
}
|
||||
this->resetMinMaxValues();
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,8 +281,8 @@ void Rim3dWellLogCurve::resetMinMaxValues()
|
||||
std::vector<double> values;
|
||||
std::vector<double> measuredDepths;
|
||||
this->curveValuesAndMds(&values, &measuredDepths);
|
||||
double foundMinValue = HUGE_VAL;
|
||||
double foundMaxValue = -HUGE_VAL;
|
||||
double foundMinValue = std::numeric_limits<float>::max();
|
||||
double foundMaxValue = -std::numeric_limits<float>::max();
|
||||
for (double value : values)
|
||||
{
|
||||
if (RigCurveDataTools::isValidValue(value, false))
|
||||
@ -309,11 +292,12 @@ void Rim3dWellLogCurve::resetMinMaxValues()
|
||||
}
|
||||
}
|
||||
|
||||
// Update data boundaries
|
||||
m_minCurveDataValue = foundMinValue;
|
||||
m_maxCurveDataValue = foundMaxValue;
|
||||
|
||||
// Update selected GUI boundaries
|
||||
m_minCurveValue = m_minCurveDataValue;
|
||||
m_maxCurveValue = m_maxCurveDataValue;
|
||||
m_minCurveUIValue = m_minCurveDataValue;
|
||||
m_maxCurveUIValue = m_maxCurveDataValue;
|
||||
|
||||
m_minCurveUIValue.uiCapability()->setUiName(QString("Minimum Curve Value (%1)").arg(m_minCurveDataValue));
|
||||
m_maxCurveUIValue.uiCapability()->setUiName(QString("Maximum Curve Value (%1)").arg(m_maxCurveDataValue));
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ public:
|
||||
|
||||
void setColor(const cvf::Color3f& color);
|
||||
|
||||
double minCurveValue() const;
|
||||
double maxCurveValue() const;
|
||||
float minCurveUIValue() const;
|
||||
float maxCurveUIValue() const;
|
||||
void resetMinMaxValuesAndUpdateUI();
|
||||
bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection,
|
||||
cvf::Vec3d* closestPoint,
|
||||
@ -101,10 +101,10 @@ protected:
|
||||
caf::PdmField<DrawPlaneEnum> m_drawPlane;
|
||||
caf::PdmField<DrawStyleEnum> m_drawStyle;
|
||||
caf::PdmField<cvf::Color3f> m_color;
|
||||
caf::PdmField<double> m_minCurveValue;
|
||||
caf::PdmField<double> m_maxCurveValue;
|
||||
double m_minCurveDataValue;
|
||||
double m_maxCurveDataValue;
|
||||
caf::PdmField<float> m_minCurveUIValue;
|
||||
caf::PdmField<float> m_maxCurveUIValue;
|
||||
float m_minCurveDataValue;
|
||||
float m_maxCurveDataValue;
|
||||
cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_geometryGenerator;
|
||||
private:
|
||||
caf::PdmField<bool> m_showCurve;
|
||||
|
Loading…
Reference in New Issue
Block a user