mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3934 Implement area threshold for contour polygons
This commit is contained in:
parent
c8f9505d1e
commit
7fccdf7153
@ -268,6 +268,8 @@ void RimContourMapProjection::generateContourPolygons()
|
|||||||
{
|
{
|
||||||
std::vector<ContourPolygons> contourPolygons;
|
std::vector<ContourPolygons> contourPolygons;
|
||||||
|
|
||||||
|
const double areaTreshold = 1.5 * m_sampleSpacing * m_sampleSpacing;
|
||||||
|
|
||||||
if (minValue() != std::numeric_limits<double>::infinity() &&
|
if (minValue() != std::numeric_limits<double>::infinity() &&
|
||||||
maxValue() != -std::numeric_limits<double>::infinity() &&
|
maxValue() != -std::numeric_limits<double>::infinity() &&
|
||||||
std::fabs(maxValue() - minValue()) > 1.0e-8)
|
std::fabs(maxValue() - minValue()) > 1.0e-8)
|
||||||
@ -280,7 +282,7 @@ void RimContourMapProjection::generateContourPolygons()
|
|||||||
if (nContourLevels > 2)
|
if (nContourLevels > 2)
|
||||||
{
|
{
|
||||||
std::vector<caf::ContourLines::ClosedPolygons> closedContourLines =
|
std::vector<caf::ContourLines::ClosedPolygons> closedContourLines =
|
||||||
caf::ContourLines::create(m_aggregatedVertexResults, xVertexPositions(), yVertexPositions(), contourLevels);
|
caf::ContourLines::create(m_aggregatedVertexResults, xVertexPositions(), yVertexPositions(), contourLevels, areaTreshold);
|
||||||
|
|
||||||
contourPolygons.resize(closedContourLines.size());
|
contourPolygons.resize(closedContourLines.size());
|
||||||
|
|
||||||
@ -300,7 +302,6 @@ void RimContourMapProjection::generateContourPolygons()
|
|||||||
contourPolygons[i].push_back(contourPolygon);
|
contourPolygons[i].push_back(contourPolygon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
smoothPolygonLoops(&contourPolygons[0]);
|
smoothPolygonLoops(&contourPolygons[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,8 @@ void caf::ContourLines::create(const std::vector<double>& dataXY, const std::vec
|
|||||||
std::vector<caf::ContourLines::ClosedPolygons> caf::ContourLines::create(const std::vector<double>& dataXY,
|
std::vector<caf::ContourLines::ClosedPolygons> caf::ContourLines::create(const std::vector<double>& dataXY,
|
||||||
const std::vector<double>& xPositions,
|
const std::vector<double>& xPositions,
|
||||||
const std::vector<double>& yPositions,
|
const std::vector<double>& yPositions,
|
||||||
const std::vector<double>& contourLevels)
|
const std::vector<double>& contourLevels,
|
||||||
|
double areaThreshold)
|
||||||
{
|
{
|
||||||
const double eps = 1.0e-4;
|
const double eps = 1.0e-4;
|
||||||
std::vector<std::vector<cvf::Vec2d>> contourLineSegments;
|
std::vector<std::vector<cvf::Vec2d>> contourLineSegments;
|
||||||
@ -291,15 +292,17 @@ std::vector<caf::ContourLines::ClosedPolygons> caf::ContourLines::create(const s
|
|||||||
signedArea += (closedPolygonDeque[j + 1].x() - closedPolygonDeque[j].x()) *
|
signedArea += (closedPolygonDeque[j + 1].x() - closedPolygonDeque[j].x()) *
|
||||||
(closedPolygonDeque[j + 1].y() + closedPolygonDeque[j].y());
|
(closedPolygonDeque[j + 1].y() + closedPolygonDeque[j].y());
|
||||||
}
|
}
|
||||||
if (signedArea < 0.0)
|
if (std::abs(signedArea) > areaThreshold)
|
||||||
{
|
{
|
||||||
closedPolygonsPerLevel[i].emplace_back(closedPolygonDeque.rbegin(), closedPolygonDeque.rend());
|
if (signedArea < 0.0)
|
||||||
|
{
|
||||||
|
closedPolygonsPerLevel[i].emplace_back(closedPolygonDeque.rbegin(), closedPolygonDeque.rend());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
closedPolygonsPerLevel[i].emplace_back(closedPolygonDeque.begin(), closedPolygonDeque.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
closedPolygonsPerLevel[i].emplace_back(closedPolygonDeque.begin(), closedPolygonDeque.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
closedPolygonDeque.clear();
|
closedPolygonDeque.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfVector2.h"
|
#include "cvfVector2.h"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
@ -39,7 +41,8 @@ public:
|
|||||||
static std::vector<ClosedPolygons> create(const std::vector<double>& dataXY,
|
static std::vector<ClosedPolygons> create(const std::vector<double>& dataXY,
|
||||||
const std::vector<double>& xPositions,
|
const std::vector<double>& xPositions,
|
||||||
const std::vector<double>& yPositions,
|
const std::vector<double>& yPositions,
|
||||||
const std::vector<double>& contourLevels);
|
const std::vector<double>& contourLevels,
|
||||||
|
double areaTreshold = std::numeric_limits<double>::infinity());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void create(const std::vector<double>& dataXY,
|
static void create(const std::vector<double>& dataXY,
|
||||||
|
Loading…
Reference in New Issue
Block a user