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>2011-04-24 17:41:31 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:16:17 +0300
commit69c15b4fb0dd95737300362e31f8b48ea69e7144 (patch)
treecfdf00a50b7459058759906635e4f51834ac9b58 /geometry/geometry_tests/robust_test.cpp
parentd0361b1bb21f770ec2374ae8d0b77f2d7941c65a (diff)
- Add robust algorithms (OrientedS, SegmentsIntersect, PolygonSelfIntersections).
- Move IsSegmentInCone to point2d.hpp. - Use robust OrientedS in IsPolygonCCW function.
Diffstat (limited to 'geometry/geometry_tests/robust_test.cpp')
-rw-r--r--geometry/geometry_tests/robust_test.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/geometry/geometry_tests/robust_test.cpp b/geometry/geometry_tests/robust_test.cpp
new file mode 100644
index 0000000000..cc3e2cd29c
--- /dev/null
+++ b/geometry/geometry_tests/robust_test.cpp
@@ -0,0 +1,37 @@
+#include "../../testing/testing.hpp"
+
+#include "../robust_orientation.hpp"
+
+
+typedef m2::PointD P;
+
+namespace
+{
+ template <typename IterT> void CheckSelfIntersections(IterT beg, IterT end, bool res)
+ {
+ TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(beg, end), res, ());
+ typedef std::reverse_iterator<IterT> ReverseIterT;
+ TEST_EQUAL(m2::robust::CheckPolygonSelfIntersections(ReverseIterT(end), ReverseIterT(beg)), res, ());
+ }
+}
+
+UNIT_TEST(PolygonSelfIntersections_IntersectSmoke)
+{
+ {
+ P arr[] = { P(0, 1), P(2, -1), P(2, 1), P(0, -1) };
+ CheckSelfIntersections(&arr[0], arr + ARRAY_SIZE(arr), true);
+ }
+}
+
+UNIT_TEST(PolygonSelfIntersections_TangentSmoke)
+{
+ {
+ P arr[] = { P(0, 1), P(1, 0), P(2, 1), P(2, -1), P(1, 0), P(0, -1) };
+ CheckSelfIntersections(&arr[0], arr + ARRAY_SIZE(arr), false);
+ }
+
+ {
+ P arr[] = { P(0, 0), P(2, 0), P(2, 1), P(1, 0), P(0, 1) };
+ CheckSelfIntersections(&arr[0], arr + ARRAY_SIZE(arr), false);
+ }
+}