mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 16:51:21 -06:00
Implemented utility functions to operate over lines, polylines, polygons,
surfaces.
This commit is contained in:
parent
aac968162b
commit
5a81731577
13 changed files with 495 additions and 66 deletions
|
|
@ -36,6 +36,33 @@ class Polyline : public MultiPoint {
|
|||
extern BoundingBox get_extents(const Polyline &polyline);
|
||||
extern BoundingBox get_extents(const Polylines &polylines);
|
||||
|
||||
inline Lines to_lines(const Polyline &poly)
|
||||
{
|
||||
Lines lines;
|
||||
if (poly.points.size() >= 2) {
|
||||
lines.reserve(poly.points.size() - 1);
|
||||
for (Points::const_iterator it = poly.points.begin(); it != poly.points.end()-1; ++it)
|
||||
lines.push_back(Line(*it, *(it + 1)));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
inline Lines to_lines(const Polylines &polys)
|
||||
{
|
||||
size_t n_lines = 0;
|
||||
for (size_t i = 0; i < polys.size(); ++ i)
|
||||
if (polys[i].points.size() > 1)
|
||||
n_lines += polys[i].points.size() - 1;
|
||||
Lines lines;
|
||||
lines.reserve(n_lines);
|
||||
for (size_t i = 0; i < polys.size(); ++ i) {
|
||||
const Polyline &poly = polys[i];
|
||||
for (Points::const_iterator it = poly.points.begin(); it != poly.points.end()-1; ++it)
|
||||
lines.push_back(Line(*it, *(it + 1)));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
class ThickPolyline : public Polyline {
|
||||
public:
|
||||
std::vector<coordf_t> width;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue