83 const double R = 5.0,
r = 2.0;
84 for (
int i = 0; i < 5; ++i)
86 double angle_out = M_PI / 2.0 + i * 2.0 * M_PI / 5.0;
87 double angle_in = angle_out + M_PI / 5.0;
101 const double R = 4.0;
102 for (
int i = 0; i < 5; ++i)
104 double a = M_PI / 2.0 + i * 2.0 * M_PI / 5.0;
131 ASSERT_FALSE(result.is_empty());
136 EXPECT_EQ(result.polygons(0).size(), 4);
144 ASSERT_FALSE(result.is_empty());
156 ASSERT_FALSE(result.is_empty());
160 EXPECT_GT(new_area, orig_area);
168 ASSERT_FALSE(result.is_empty());
172 EXPECT_LT(new_area, orig_area);
180 ASSERT_EQ(result.size(),
size_t(1));
192 EXPECT_TRUE(result.is_empty());
200 ASSERT_FALSE(result.is_empty());
204 EXPECT_GT(new_area, orig_area);
212 ASSERT_FALSE(result.is_empty());
216 EXPECT_LT(new_area, orig_area);
224 ASSERT_FALSE(result.is_empty());
229 for (
size_t i = 0; i < result.size(); ++i)
231 EXPECT_GT(total, orig_area);
242 for (
size_t i = 0; i < shapes.
size(); ++i)
245 ASSERT_FALSE(result.is_empty()) <<
"shape " << i;
259 for (
size_t i = 0; i < shapes.
size(); ++i)
262 ASSERT_FALSE(result.is_empty()) <<
"shape " << i;
274 ASSERT_FALSE(
out.is_empty());
275 EXPECT_TRUE(is_ccw(
out.polygons(0)));
278 ASSERT_FALSE(in.is_empty());
279 EXPECT_TRUE(is_ccw(in.polygons(0)));
287 auto miter = off(sq,
Geom_Number(1), PolygonOffset::JoinType::Miter);
288 auto bevel = off(sq,
Geom_Number(1), PolygonOffset::JoinType::Bevel);
289 ASSERT_FALSE(miter.is_empty());
290 ASSERT_FALSE(bevel.is_empty());
293 EXPECT_GT(bevel.polygons(0).size(), miter.polygons(0).size());
300 auto result = off(sq,
Geom_Number(1), PolygonOffset::JoinType::Bevel);
301 ASSERT_FALSE(result.is_empty());
304 EXPECT_EQ(result.polygons(0).size(),
size_t(8));
307 auto miter = off(sq,
Geom_Number(1), PolygonOffset::JoinType::Miter);
325 ASSERT_FALSE(result.is_empty());
330 ASSERT_FALSE(result_high.is_empty());
333 EXPECT_GE(result.polygons(0).size(), result_high.polygons(0).size());
342 for (
int d = 1; d <= 3; ++d)
345 ASSERT_FALSE(result.is_empty()) <<
"d=" << d;
347 EXPECT_GT(a, prev_area) <<
"d=" << d;
357 ASSERT_FALSE(gen_result.is_empty());
376 EXPECT_TRUE(result.is_empty());
385 ASSERT_FALSE(
out.is_empty());
389 ASSERT_FALSE(in.is_empty());
400 ASSERT_FALSE(result.is_empty());
405 EXPECT_TRUE(collapsed.is_empty());
size_t size_t int32_t * out
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
T & append(const T &data)
Append a copy of data
static Polygon outward(const Polygon &convex_poly, const Geom_Number &distance)
Outward offset (dilation) of a convex polygon.
Represents a point with rectangular coordinates in a 2D plane.
Offset (inflate/deflate) an arbitrary simple polygon.
A general (irregular) 2D polygon defined by a sequence of vertices.
void add_vertex(const Point &point)
Add a vertex to the polygon.
void close()
Close the polygon.
static Polygon make_L_shape()
L-shaped polygon (non-convex, one reflex vertex).
static Polygon make_square(Geom_Number cx, Geom_Number cy, Geom_Number half)
static Polygon make_triangle()
TEST_F(GeomAlgorithmsTest, Offset_SquareOutward)
static Polygon make_narrow_corridor()
Narrow horizontal corridor: width 1, length 10.
static Polygon make_pentagon()
Regular pentagon (convex).
static Polygon make_star()
Star-shaped polygon with 5 reflex vertices.
Main namespace for Aleph-w library functions.
mpq_class Geom_Number
Numeric type used by the geometry module.
static Geom_Number polygon_area(const Polygon &poly)