mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3939 Make sure contour smoothing doesn't cause level overlap.
This commit is contained in:
@@ -352,9 +352,13 @@ void RimContourMapProjection::generateContourPolygons()
|
|||||||
}
|
}
|
||||||
contourPolygons[i].push_back(contourPolygon);
|
contourPolygons[i].push_back(contourPolygon);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < contourPolygons.size(); ++i)
|
||||||
|
{
|
||||||
if (i == 0 || m_smoothContourLines())
|
if (i == 0 || m_smoothContourLines())
|
||||||
{
|
{
|
||||||
smoothPolygonLoops(&contourPolygons[i], true);
|
const ContourPolygons* clipBy = i > 0 ? &contourPolygons[i - 1] : nullptr;
|
||||||
|
smoothContourPolygons(&contourPolygons[i], clipBy, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -782,13 +786,14 @@ bool RimContourMapProjection::checkForMapIntersection(const cvf::Vec3d& localPoi
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimContourMapProjection::smoothPolygonLoops(ContourPolygons* contourPolygons, bool favourExpansion)
|
void RimContourMapProjection::smoothContourPolygons(ContourPolygons* contourPolygons, const ContourPolygons* clipBy, bool favourExpansion)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(contourPolygons);
|
CVF_ASSERT(contourPolygons);
|
||||||
for (size_t i = 0; i < contourPolygons->size(); ++i)
|
for (size_t i = 0; i < contourPolygons->size(); ++i)
|
||||||
{
|
{
|
||||||
ContourPolygon& polygon = contourPolygons->at(i);
|
ContourPolygon& polygon = contourPolygons->at(i);
|
||||||
for (size_t n = 0; n < 50; ++n)
|
|
||||||
|
for (size_t n = 0; n < 20; ++n)
|
||||||
{
|
{
|
||||||
std::vector<cvf::Vec3d> newVertices;
|
std::vector<cvf::Vec3d> newVertices;
|
||||||
newVertices.resize(polygon.vertices.size());
|
newVertices.resize(polygon.vertices.size());
|
||||||
@@ -811,7 +816,7 @@ void RimContourMapProjection::smoothPolygonLoops(ContourPolygons* contourPolygon
|
|||||||
cvf::Vec3d delta = (modifiedVertex - v).getNormalized();
|
cvf::Vec3d delta = (modifiedVertex - v).getNormalized();
|
||||||
cvf::Vec3d tangent3d = vp1 - vm1;
|
cvf::Vec3d tangent3d = vp1 - vm1;
|
||||||
cvf::Vec2d tangent2d(tangent3d.x(), tangent3d.y());
|
cvf::Vec2d tangent2d(tangent3d.x(), tangent3d.y());
|
||||||
cvf::Vec3d norm3d (tangent2d.getNormalized().perpendicularVector());
|
cvf::Vec3d norm3d(tangent2d.getNormalized().perpendicularVector());
|
||||||
if (delta * norm3d > 0 && favourExpansion)
|
if (delta * norm3d > 0 && favourExpansion)
|
||||||
{
|
{
|
||||||
// Normal is always inwards facing so a positive dot product means inward movement
|
// Normal is always inwards facing so a positive dot product means inward movement
|
||||||
@@ -825,6 +830,17 @@ void RimContourMapProjection::smoothPolygonLoops(ContourPolygons* contourPolygon
|
|||||||
if (maxChange < m_sampleSpacing * 1.0e-2)
|
if (maxChange < m_sampleSpacing * 1.0e-2)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (clipBy)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < clipBy->size(); ++j)
|
||||||
|
{
|
||||||
|
std::vector<std::vector<cvf::Vec3d>> intersections = RigCellGeometryTools::intersectPolygons(polygon.vertices, clipBy->at(j).vertices);
|
||||||
|
if (!intersections.empty())
|
||||||
|
{
|
||||||
|
polygon.vertices = intersections.front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public:
|
|||||||
cvf::Vec3d origin3d() const;
|
cvf::Vec3d origin3d() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void smoothPolygonLoops(ContourPolygons* contourPolygons, bool favourExpansion);
|
void smoothContourPolygons(ContourPolygons* contourPolygons, const ContourPolygons* clipBy, bool favourExpansion);
|
||||||
double interpolateValue(const cvf::Vec2d& gridPosition2d) const;
|
double interpolateValue(const cvf::Vec2d& gridPosition2d) const;
|
||||||
|
|
||||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user