Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-12-23 19:33:05 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:03:17 +0300
commitf6ac3786d755afde9534b28e9a1977e38b3aa470 (patch)
tree239acb986e517ef84c31d4991a37df7f6d3bc4c1 /geometry/geometry_tests
parent8c57791e1d87fa500b3f7bb1b13f45282edc0cf1 (diff)
Refactored some geometry functions.
Correct implementation of feature::GetMinDistanceMeters().
Diffstat (limited to 'geometry/geometry_tests')
-rw-r--r--geometry/geometry_tests/point_test.cpp4
-rw-r--r--geometry/geometry_tests/polygon_test.cpp7
-rw-r--r--geometry/geometry_tests/robust_test.cpp33
-rw-r--r--geometry/geometry_tests/segments_intersect_test.cpp20
4 files changed, 47 insertions, 17 deletions
diff --git a/geometry/geometry_tests/point_test.cpp b/geometry/geometry_tests/point_test.cpp
index 116c8ef246..0c15ef621b 100644
--- a/geometry/geometry_tests/point_test.cpp
+++ b/geometry/geometry_tests/point_test.cpp
@@ -1,7 +1,9 @@
-#include "base/SRC_FIRST.hpp"
#include "testing/testing.hpp"
+
#include "geometry/geometry_tests/equality.hpp"
#include "geometry/point2d.hpp"
+#include "geometry/triangle2d.hpp"
+
UNIT_TEST(Point_Rotate)
{
diff --git a/geometry/geometry_tests/polygon_test.cpp b/geometry/geometry_tests/polygon_test.cpp
index 8fd6d5970d..6f62603c97 100644
--- a/geometry/geometry_tests/polygon_test.cpp
+++ b/geometry/geometry_tests/polygon_test.cpp
@@ -9,10 +9,9 @@
#include "std/algorithm.hpp"
-namespace
-{
- typedef m2::PointD P;
-}
+namespace { typedef m2::PointD P; }
+
+using namespace m2::robust;
UNIT_TEST(IsSegmentInCone)
{
diff --git a/geometry/geometry_tests/robust_test.cpp b/geometry/geometry_tests/robust_test.cpp
index 04e5f356c2..0eb3d79091 100644
--- a/geometry/geometry_tests/robust_test.cpp
+++ b/geometry/geometry_tests/robust_test.cpp
@@ -1,20 +1,47 @@
#include "testing/testing.hpp"
#include "geometry/robust_orientation.hpp"
+#include "geometry/triangle2d.hpp"
-typedef m2::PointD P;
+using namespace m2::robust;
namespace
{
+ typedef m2::PointD P;
+
template <typename IterT> void CheckSelfIntersections(IterT beg, IterT end, bool res)
{
- TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(beg, end), res, ());
+ TEST_EQUAL(CheckPolygonSelfIntersections(beg, end), res, ());
typedef std::reverse_iterator<IterT> ReverseIterT;
- TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(ReverseIterT(end), ReverseIterT(beg)), res, ());
+ TEST_EQUAL(CheckPolygonSelfIntersections(ReverseIterT(end), ReverseIterT(beg)), res, ());
}
}
+UNIT_TEST(OrientedS_Smoke)
+{
+ m2::PointD arr[] = {{-1, -1}, {0, 0}, {1, -1}};
+ TEST(OrientedS(arr[0], arr[2], arr[1]) > 0, ());
+ TEST(OrientedS(arr[2], arr[0], arr[1]) < 0, ());
+}
+
+UNIT_TEST(Triangle_Smoke)
+{
+ m2::PointD arr[] = {{0, 0}, {0, 3}, {3, 0}};
+
+ TEST(IsPointInsideTriangle(arr[0], arr[0], arr[1], arr[2]), ());
+ TEST(IsPointInsideTriangle(arr[1], arr[0], arr[1], arr[2]), ());
+ TEST(IsPointInsideTriangle(arr[2], arr[0], arr[1], arr[2]), ());
+ TEST(IsPointInsideTriangle({1, 1}, arr[0], arr[1], arr[2]), ());
+ TEST(IsPointInsideTriangle({1, 2}, arr[0], arr[1], arr[2]), ());
+ TEST(IsPointInsideTriangle({2, 1}, arr[0], arr[1], arr[2]), ());
+
+ double constexpr eps = 1.0E-10;
+ TEST(!IsPointInsideTriangle({-eps, -eps}, arr[0], arr[1], arr[2]), ());
+ TEST(!IsPointInsideTriangle({1 + eps, 2}, arr[0], arr[1], arr[2]), ());
+ TEST(!IsPointInsideTriangle({2, 1 + eps}, arr[0], arr[1], arr[2]), ());
+}
+
UNIT_TEST(PolygonSelfIntersections_IntersectSmoke)
{
{
diff --git a/geometry/geometry_tests/segments_intersect_test.cpp b/geometry/geometry_tests/segments_intersect_test.cpp
index a92c62c163..d10369864f 100644
--- a/geometry/geometry_tests/segments_intersect_test.cpp
+++ b/geometry/geometry_tests/segments_intersect_test.cpp
@@ -1,18 +1,20 @@
#include "testing/testing.hpp"
-#include "geometry/point2d.hpp"
+
+#include "geometry/robust_orientation.hpp"
+
typedef m2::PointD P;
bool SegmentsIntersect(P a, P b, P c, P d)
{
- bool res = m2::SegmentsIntersect(a, b, c, d);
- TEST_EQUAL(res, m2::SegmentsIntersect(a, b, d, c), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(b, a, c, d), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(b, a, d, c), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(c, d, a, b), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(c, d, b, a), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(d, c, a, b), (a, b, c, d));
- TEST_EQUAL(res, m2::SegmentsIntersect(d, c, b, a), (a, b, c, d));
+ bool const res = m2::robust::SegmentsIntersect(a, b, c, d);
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(a, b, d, c), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(b, a, c, d), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(b, a, d, c), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(c, d, a, b), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(c, d, b, a), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(d, c, a, b), (a, b, c, d));
+ TEST_EQUAL(res, m2::robust::SegmentsIntersect(d, c, b, a), (a, b, c, d));
return res;
}