mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
Ported ExPolygon->area()
This commit is contained in:
parent
792fcba7be
commit
706851f836
7 changed files with 19 additions and 12 deletions
|
@ -30,6 +30,16 @@ ExPolygon::rotate(double angle, Point* center)
|
|||
}
|
||||
}
|
||||
|
||||
double
|
||||
ExPolygon::area() const
|
||||
{
|
||||
double a = this->contour.area();
|
||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
||||
a -= -(*it).area(); // holes have negative area
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
SV*
|
||||
ExPolygon::to_SV() {
|
||||
const unsigned int num_holes = this->holes.size();
|
||||
|
|
|
@ -19,6 +19,7 @@ class ExPolygon
|
|||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void rotate(double angle, Point* center);
|
||||
double area() const;
|
||||
};
|
||||
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
|
|
|
@ -55,7 +55,7 @@ Polygon::split_at_first_point()
|
|||
}
|
||||
|
||||
double
|
||||
Polygon::area()
|
||||
Polygon::area() const
|
||||
{
|
||||
ClipperLib::Polygon p;
|
||||
Slic3rPolygon_to_ClipperPolygon(*this, p);
|
||||
|
@ -63,7 +63,7 @@ Polygon::area()
|
|||
}
|
||||
|
||||
bool
|
||||
Polygon::is_counter_clockwise()
|
||||
Polygon::is_counter_clockwise() const
|
||||
{
|
||||
ClipperLib::Polygon* p = new ClipperLib::Polygon();
|
||||
Slic3rPolygon_to_ClipperPolygon(*this, *p);
|
||||
|
|
|
@ -16,8 +16,8 @@ class Polygon : public MultiPoint {
|
|||
Polyline* split_at(const Point* point);
|
||||
Polyline* split_at_index(int index);
|
||||
Polyline* split_at_first_point();
|
||||
double area();
|
||||
bool is_counter_clockwise();
|
||||
double area() const;
|
||||
bool is_counter_clockwise() const;
|
||||
bool make_counter_clockwise();
|
||||
bool make_clockwise();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue