46#include <gtest/gtest.h>
142 const Dlink * link = &v;
274 Polygon poly = create_square();
357 const Vertex & first = poly.get_first_vertex();
364 const Vertex & last = poly.get_last_vertex();
383 const Vertex & first = poly.get_first_vertex();
395 const Vertex & first = poly.get_first_vertex();
396 const Vertex &
next = poly.get_next_vertex(first);
404 const Vertex & last = poly.get_last_vertex();
405 const Vertex & prev = poly.get_prev_vertex(last);
430 Segment first = poly.get_first_segment();
438 Segment last = poly.get_last_segment();
740 const Vertex & v = poly.get_first_vertex();
741 poly.remove_vertex(v);
843 hex = std::make_unique<Regular_Polygon>(Point(0, 0), 100.0, 6);
846 std::unique_ptr<Regular_Polygon>
hex;
851 for (
size_t i = 0; i < hex->size(); ++i)
863 Point first = hex->get_first_vertex();
871 Point last = hex->get_last_vertex();
879 double r = hex->radius();
881 for (
size_t i = 0; i < hex->size(); ++i)
883 Point v = hex->get_vertex(i);
884 Point center = hex->get_center();
885 double dist = std::sqrt(
903 sq = std::make_unique<Regular_Polygon>(Point(0, 0), 100.0, 4);
906 std::unique_ptr<Regular_Polygon>
sq;
911 Segment first = sq->get_first_segment();
921 Segment last = sq->get_last_segment();
931 double expected = sq->get_side_size();
933 for (
size_t i = 0; i < sq->size(); ++i)
935 Point v1 = sq->get_vertex(i);
936 Point v2 = sq->get_vertex((i + 1) % sq->size());
952 pentagon = std::make_unique<Regular_Polygon>(Point(0, 0), 50.0, 5);
979 for (
size_t i = 0; i < 5; ++i)
989 for (
size_t i = 0; i < 5; ++i)
1004 triangle = std::make_unique<Regular_Polygon>(Point(0, 0), 100.0, 3);
1024 Point v0 = triangle->get_vertex(0);
1025 Point v1 = triangle->get_vertex(1);
1034 for (
size_t i = 0; i < 3; ++i)
1044 for (
size_t i = 0; i < 3; ++i)
1060 hex = std::make_unique<Regular_Polygon>(Point(100, 100), 100.0, 6);
1063 std::unique_ptr<Regular_Polygon>
hex;
1069 Point center = hex->get_center();
1070 double r = hex->radius();
1078 Point center = hex->get_center();
1079 double r = hex->radius();
1087 Point center = hex->get_center();
1088 double r = hex->radius();
1096 Point center = hex->get_center();
1097 double r = hex->radius();
1137 for (
size_t i = 0; i < hex.
size(); ++i)
1140 double dist = std::sqrt(
1197 EXPECT_TRUE(std::is_nothrow_move_constructible<Polygon>::value);
1202 EXPECT_TRUE(std::is_nothrow_move_assignable<Polygon>::value);
1212 const size_t N = 1000;
1215 for (
size_t i = 0; i <
N; ++i)
1217 double angle = 2.0 *
PI * i /
N;
1218 double x = 1000.0 *
cos(angle);
1219 double y = 1000.0 *
sin(angle);
1239 double r = poly.
radius();
1240 for (
size_t i = 0; i < poly.
size(); ++i)
1243 double dist = std::sqrt(
1281 ::testing::InitGoogleTest(&
argc,
argv);
Graph create_triangle()
Creates a triangle (K_3) - the simplest non-bipartite graph.
Doubly linked circular list node.
size_t size() const noexcept
Count the number of elements of the list.
Rectangular point in the plane.
const Geom_Number & get_y() const
Returns y value.
const Point & highest_point() const
const Point & leftmost_point() const
const Point & rightmost_point() const
const Point & lowest_point() const
const Geom_Number & get_x() const
Returns x value.
Polygon create_triangle()
Iterator over the edges (segments) of a polygon.
Segment get_current_segment() const
Get the current segment (edge).
bool has_curr() const
Check if there is a current segment.
A general (irregular) 2D polygon defined by a sequence of vertices.
Segment get_first_segment()
Get the first edge (segment) of the polygon.
void close()
Close the polygon.
const Vertex & get_last_vertex() const
Get the last vertex of the polygon.
const Point & rightmost_point() const
Get the vertex with the maximum x-coordinate.
const bool & is_closed() const
Check if the polygon is closed.
const size_t & size() const
Get the number of vertices.
const Point & leftmost_point() const
Get the vertex with the minimum x-coordinate.
const Vertex & get_first_vertex() const
Get the first vertex of the polygon.
void add_vertex(const Point &point)
Add a vertex to the polygon.
const Point & highest_point() const
Get the vertex with the maximum y-coordinate.
bool contains_to(const Point &p)
Check if a point is inside the polygon.
const Point & lowest_point() const
Get the vertex with the minimum y-coordinate.
std::unique_ptr< Regular_Polygon > hex
std::unique_ptr< Regular_Polygon > triangle
std::unique_ptr< Regular_Polygon > sq
std::unique_ptr< Regular_Polygon > pentagon
std::unique_ptr< Regular_Polygon > hex
Iterator over the edges (segments) of a regular polygon.
void next_ne() noexcept
Advance to next segment (no exception on overflow).
const Segment get_current_segment() const
Get the current segment (edge).
void next()
Advance to next segment.
bool has_curr() const
Check if there is a current segment.
Iterator over the vertices of a regular polygon.
bool has_curr() const
Check if there is a current vertex.
void next_ne() noexcept
Advance to next vertex (no exception on overflow).
Vertex & get_current_vertex()
Get the current vertex.
void next()
Advance to next vertex.
A regular polygon defined by center, side length, and vertex count.
const Point & get_center() const
Get the center point.
const size_t & size() const
Get the number of vertices.
const double & get_side_size() const
Get the side length.
const Point get_vertex(const size_t &i) const
Get the i-th vertex of the polygon.
const double & radius() const
Get the circumradius.
Fundamental segment defined by two points.
const Point & get_tgt_point() const
Geom_Number size() const
Return the Euclidean length of the segment (distance between endpoints).
const Point & get_src_point() const
A vertex in a polygon's doubly-linked vertex list.
static Vertex * dlink_to_vertex(Dlink *link)
Convert a Dlink pointer to a Vertex pointer.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_cos_function > > cos(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sin_function > > sin(const __gmp_expr< T, U > &expr)
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
void next()
Advance all underlying iterators (bounds-checked).
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
mpq_class Geom_Number
Numeric type used by the geometry module.
2D polygon representation and geometric operations.
bool points_equal(const Point &a, const Point &b, double tol=EPSILON)
TEST_F(VertexTest, DefaultConstruction)
bool approx_equal(const Geom_Number &a, const Geom_Number &b, double tol=EPSILON)
Iterator over the vertices of a polygon.
Vertex & get_current_vertex()
Get the current vertex.