mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
More unfinished work
This commit is contained in:
parent
518798beb3
commit
df8d889481
16 changed files with 74 additions and 48 deletions
|
@ -83,21 +83,32 @@ ExPolygon::contains_point(const Point* point) const
|
|||
}
|
||||
|
||||
Polygons
|
||||
ExPolygon::simplify(double tolerance) const
|
||||
ExPolygon::simplify_p(double tolerance) const
|
||||
{
|
||||
Polygons p;
|
||||
this->contour.simplify(tolerance, p);
|
||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it)
|
||||
it->simplify(tolerance, p);
|
||||
simplify_polygons(p, p);
|
||||
return p;
|
||||
Polygons pp(this->holes.size() + 1);
|
||||
|
||||
// contour
|
||||
Polygon p = this->contour;
|
||||
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
|
||||
pp.push_back(p);
|
||||
|
||||
// holes
|
||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
||||
p = *it;
|
||||
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
|
||||
pp.push_back(p);
|
||||
}
|
||||
simplify_polygons(pp, pp);
|
||||
return pp;
|
||||
}
|
||||
|
||||
ExPolygons
|
||||
ExPolygon::simplify(double tolerance) const
|
||||
{
|
||||
Polygons p = this->simplify(tolerance);
|
||||
return union_(p);
|
||||
Polygons pp = this->simplify_p(tolerance);
|
||||
ExPolygons expp;
|
||||
union_(pp, expp);
|
||||
return expp;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
class ExPolygon;
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
|
||||
class ExPolygon
|
||||
{
|
||||
public:
|
||||
|
@ -19,7 +22,7 @@ class ExPolygon
|
|||
bool is_valid() const;
|
||||
bool contains_line(const Line* line) const;
|
||||
bool contains_point(const Point* point) const;
|
||||
Polygons simplify(double tolerance) const;
|
||||
Polygons simplify_p(double tolerance) const;
|
||||
ExPolygons simplify(double tolerance) const;
|
||||
void simplify(double tolerance, ExPolygons &expolygons) const;
|
||||
|
||||
|
@ -33,8 +36,6 @@ class ExPolygon
|
|||
#endif
|
||||
};
|
||||
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,11 +50,11 @@ ExPolygonCollection::contains_point(const Point* point) const
|
|||
void
|
||||
ExPolygonCollection::simplify(double tolerance)
|
||||
{
|
||||
ExPolygons t;
|
||||
ExPolygons expp;
|
||||
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
|
||||
it->simplify_and_append_to(tolerance, t);
|
||||
it->simplify(tolerance, expp);
|
||||
}
|
||||
this->expolygons = t;
|
||||
this->expolygons = expp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,12 +55,6 @@ MultiPoint::is_valid() const
|
|||
return this->points.size() >= 2;
|
||||
}
|
||||
|
||||
void
|
||||
MultiPoint::simplify(double tolerance)
|
||||
{
|
||||
this->points = MultiPoint::_douglas_peucker(this->points, tolerance);
|
||||
}
|
||||
|
||||
Points
|
||||
MultiPoint::_douglas_peucker(Points &points, double tolerance)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ class MultiPoint
|
|||
virtual Lines lines() const = 0;
|
||||
double length() const;
|
||||
bool is_valid() const;
|
||||
void simplify(double tolerance);
|
||||
static Points _douglas_peucker(Points &points, double tolerance);
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
void from_SV(SV* poly_sv);
|
||||
|
@ -29,9 +29,6 @@ class MultiPoint
|
|||
SV* to_AV();
|
||||
SV* to_SV_pureperl() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static Points _douglas_peucker(Points &points, double tolerance);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -128,7 +128,21 @@ Polygon::contains_point(const Point* point) const
|
|||
Polygons
|
||||
Polygon::simplify(double tolerance) const
|
||||
{
|
||||
Polygon p = *this;
|
||||
p.points = MultiPoint::_douglas_peucker(p.points, tolerance);
|
||||
|
||||
Polygons pp;
|
||||
pp.push_back(p);
|
||||
simplify_polygons(pp, pp);
|
||||
return pp;
|
||||
}
|
||||
|
||||
void
|
||||
Polygon::simplify(double tolerance, Polygons &polygons) const
|
||||
{
|
||||
Polygons pp = this->simplify(tolerance);
|
||||
polygons.reserve(polygons.size() + pp.size());
|
||||
polygons.insert(polygons.end(), pp.begin(), pp.end());
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
class Polygon;
|
||||
typedef std::vector<Polygon> Polygons;
|
||||
|
||||
class Polygon : public MultiPoint {
|
||||
public:
|
||||
Point* last_point() const;
|
||||
|
@ -33,8 +36,6 @@ class Polygon : public MultiPoint {
|
|||
#endif
|
||||
};
|
||||
|
||||
typedef std::vector<Polygon> Polygons;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -87,6 +87,12 @@ Polyline::equally_spaced_points(double distance) const
|
|||
return pts;
|
||||
}
|
||||
|
||||
void
|
||||
Polyline::simplify(double tolerance)
|
||||
{
|
||||
this->points = MultiPoint::_douglas_peucker(this->points, tolerance);
|
||||
}
|
||||
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV*
|
||||
|
|
|
@ -17,6 +17,7 @@ class Polyline : public MultiPoint {
|
|||
void clip_end(double distance);
|
||||
void clip_start(double distance);
|
||||
Points equally_spaced_points(double distance) const;
|
||||
void simplify(double tolerance);
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV* to_SV_ref();
|
||||
|
|
13
xs/src/SurfaceCollection.cpp
Normal file
13
xs/src/SurfaceCollection.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "SurfaceCollection.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void
|
||||
simplify(double tolerance)
|
||||
{
|
||||
for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
|
||||
throw "Unimplemented";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ class SurfaceCollection
|
|||
{
|
||||
public:
|
||||
Surfaces surfaces;
|
||||
void simplify(double tolerance);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue