#3939 Make sure contour smoothing doesn't cause level overlap.

This commit is contained in:
Gaute Lindkvist
2019-01-10 16:07:58 +01:00
parent 8428e848de
commit 602bca4ea6
2 changed files with 22 additions and 6 deletions

View File

@@ -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());
@@ -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();
}
}
}
} }
} }

View File

@@ -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;