forked from Heeks/libarea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Area.h
91 lines (82 loc) · 2.87 KB
/
Area.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Area.h
// Copyright 2011, Dan Heeks
// This program is released under the BSD license. See the file COPYING for details.
// repository now moved to github
#ifndef AREA_HEADER
#define AREA_HEADER
#include "Curve.h"
enum PocketMode
{
SpiralPocketMode,
ZigZagPocketMode,
SingleOffsetPocketMode,
ZigZagThenSingleOffsetPocketMode,
};
struct CAreaPocketParams
{
double tool_radius;
double extra_offset;
double stepover;
bool from_center;
PocketMode mode;
double zig_angle;
bool only_cut_first_offset;
CAreaPocketParams(double Tool_radius, double Extra_offset, double Stepover, bool From_center, PocketMode Mode, double Zig_angle)
{
tool_radius = Tool_radius;
extra_offset = Extra_offset;
stepover = Stepover;
from_center = From_center;
mode = Mode;
zig_angle = Zig_angle;
}
};
class CArea
{
public:
std::list<CCurve> m_curves;
static double m_accuracy;
static double m_units; // 1.0 for mm, 25.4 for inches. All points are multiplied by this before going to the engine
static bool m_fit_arcs;
static double m_processing_done; // 0.0 to 100.0, set inside MakeOnePocketCurve
static double m_single_area_processing_length;
static double m_after_MakeOffsets_length;
static double m_MakeOffsets_increment;
static double m_split_processing_length;
static bool m_set_processing_length_in_split;
static bool m_please_abort; // the user sets this from another thread, to tell MakeOnePocketCurve to finish with no result.
void append(const CCurve& curve);
void Subtract(const CArea& a2);
void Intersect(const CArea& a2);
void Union(const CArea& a2);
static CArea UniteCurves(std::list<CCurve> &curves);
void Xor(const CArea& a2);
void Offset(double inwards_value);
void Thicken(double value);
void FitArcs();
unsigned int num_curves(){return m_curves.size();}
Point NearestPoint(const Point& p)const;
void GetBox(CBox2D &box);
void Reorder();
void MakePocketToolpath(std::list<CCurve> &toolpath, const CAreaPocketParams ¶ms)const;
void SplitAndMakePocketToolpath(std::list<CCurve> &toolpath, const CAreaPocketParams ¶ms)const;
void MakeOnePocketCurve(std::list<CCurve> &curve_list, const CAreaPocketParams ¶ms)const;
static bool HolesLinked();
void Split(std::list<CArea> &m_areas)const;
double GetArea(bool always_add = false)const;
void SpanIntersections(const Span& span, std::list<Point> &pts)const;
void CurveIntersections(const CCurve& curve, std::list<Point> &pts)const;
void InsideCurves(const CCurve& curve, std::list<CCurve> &curves_inside)const;
};
enum eOverlapType
{
eOutside,
eInside,
eSiblings,
eCrossing,
};
eOverlapType GetOverlapType(const CCurve& c1, const CCurve& c2);
eOverlapType GetOverlapType(const CArea& a1, const CArea& a2);
bool IsInside(const Point& p, const CCurve& c);
bool IsInside(const Point& p, const CArea& a);
#endif // #define AREA_HEADER