#3970 Contour Maps: improve edge look

* Remove excess tiny triangles around edges
* Remove labels from contour lines that overlap inner contour lines
This commit is contained in:
Gaute Lindkvist
2019-01-17 19:27:49 +01:00
parent 5d9ef00067
commit b1ad93f4b9
11 changed files with 216 additions and 121 deletions

View File

@@ -156,6 +156,26 @@ double GeometryTools::getAngle(const cvf::Vec3d& v1, const cvf::Vec3d& v2)
return angle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double GeometryTools::signedAreaPlanarPolygon(const cvf::Vec3d& planeNormal, const std::vector<cvf::Vec3d>& polygon)
{
int Z = findClosestAxis(planeNormal);
int X = (Z + 1) % 3;
int Y = (Z + 2) % 3;
// Use Shoelace formula to calculate signed area.
// https://en.wikipedia.org/wiki/Shoelace_formula
double signedArea = 0.0;
for (size_t i = 0; i < polygon.size(); ++i)
{
signedArea += (polygon[(i + 1) % polygon.size()][X] - polygon[i][X]) *
(polygon[(i + 1) % polygon.size()][Y] + polygon[i][Y]);
}
return signedArea;
}
/*
Determine the intersection point of two line segments
From Paul Bourke, but modified to really handle coincident lines
@@ -178,7 +198,7 @@ GeometryTools::IntersectionStatus inPlaneLineIntersect(
numera = (x4-x3) * (y1-y3) - (y4-y3) * (x1-x3);
numerb = (x2-x1) * (y1-y3) - (y2-y1) * (x1-x3);
double EPS = 1e-40;
double EPS = 1e-40;
// Are the line coincident?
if (fabs(numera) < EPS && fabs(numerb) < EPS && fabs(denom) < EPS)
@@ -199,7 +219,7 @@ GeometryTools::IntersectionStatus inPlaneLineIntersect(
// Check if the p1 p2 line is a point
if (length12 < EPS )
if (length12 < EPS)
{
*x = x1;
*y = y1;