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:
parent
8428e848de
commit
602bca4ea6
@ -352,9 +352,13 @@ void RimContourMapProjection::generateContourPolygons()
|
||||
}
|
||||
contourPolygons[i].push_back(contourPolygon);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < contourPolygons.size(); ++i)
|
||||
{
|
||||
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);
|
||||
for (size_t i = 0; i < contourPolygons->size(); ++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;
|
||||
newVertices.resize(polygon.vertices.size());
|
||||
@ -811,7 +816,7 @@ void RimContourMapProjection::smoothPolygonLoops(ContourPolygons* contourPolygon
|
||||
cvf::Vec3d delta = (modifiedVertex - v).getNormalized();
|
||||
cvf::Vec3d tangent3d = vp1 - vm1;
|
||||
cvf::Vec2d tangent2d(tangent3d.x(), tangent3d.y());
|
||||
cvf::Vec3d norm3d (tangent2d.getNormalized().perpendicularVector());
|
||||
cvf::Vec3d norm3d(tangent2d.getNormalized().perpendicularVector());
|
||||
if (delta * norm3d > 0 && favourExpansion)
|
||||
{
|
||||
// Normal is always inwards facing so a positive dot product means inward movement
|
||||
@ -819,12 +824,23 @@ void RimContourMapProjection::smoothPolygonLoops(ContourPolygons* contourPolygon
|
||||
modifiedVertex = v + 0.5 *delta;
|
||||
}
|
||||
newVertices[j] = modifiedVertex;
|
||||
maxChange = std::max(maxChange, (modifiedVertex - v).length());
|
||||
maxChange = std::max(maxChange, (modifiedVertex - v).length());
|
||||
}
|
||||
polygon.vertices.swap(newVertices);
|
||||
if (maxChange < m_sampleSpacing * 1.0e-2)
|
||||
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;
|
||||
|
||||
protected:
|
||||
void smoothPolygonLoops(ContourPolygons* contourPolygons, bool favourExpansion);
|
||||
void smoothContourPolygons(ContourPolygons* contourPolygons, const ContourPolygons* clipBy, bool favourExpansion);
|
||||
double interpolateValue(const cvf::Vec2d& gridPosition2d) const;
|
||||
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
Loading…
Reference in New Issue
Block a user