-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsheet.h
38 lines (38 loc) · 1.17 KB
/
sheet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "basic.h"
namespace nesting {
struct Sheet {
geo::FT width;
geo::FT height;
geo::Polygon_with_holes_2 sheet;
// 构造函数
explicit Sheet(geo::FT _width, geo::FT _height)
: width(_width), height(_height) {
auto& outer = sheet.outer_boundary();
outer.push_back(geo::Point_2(0, 0));
outer.push_back(geo::Point_2(_width, 0));
outer.push_back(geo::Point_2(_width, _height));
outer.push_back(geo::Point_2(0, _height));
}
// 将sheet的宽度变为_width
inline void set_width(geo::FT _width) {
width = _width;
auto& outer = sheet.outer_boundary();
auto p1 = outer.vertices_begin() + 1;
outer.erase(p1);
outer.erase(p1);
outer.insert(p1, geo::Point_2(_width, height));
outer.insert(p1, geo::Point_2(_width, 0));
}
// 将sheet的高度变为_height
inline void set_height(geo::FT _height) {
height = _height;
auto& outer = sheet.outer_boundary();
auto p1 = outer.vertices_begin() + 2;
outer.erase(p1);
outer.erase(p1);
outer.insert(p1, geo::Point_2(0, _height));
outer.insert(p1, geo::Point_2(width, _height));
}
};
} // namespace nesting