mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-31 09:02:53 +00:00
Ported Polygon->is_valid() and ExPolygon->is_valid()
This commit is contained in:
@@ -40,6 +40,16 @@ ExPolygon::area() const
|
||||
return a;
|
||||
}
|
||||
|
||||
bool
|
||||
ExPolygon::is_valid() const
|
||||
{
|
||||
if (!this->contour.is_valid() || !this->contour.is_counter_clockwise()) return false;
|
||||
for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
|
||||
if (!(*it).is_valid() || (*it).is_counter_clockwise()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SV*
|
||||
ExPolygon::to_SV() {
|
||||
const unsigned int num_holes = this->holes.size();
|
||||
|
||||
@@ -20,6 +20,7 @@ class ExPolygon
|
||||
void translate(double x, double y);
|
||||
void rotate(double angle, Point* center);
|
||||
double area() const;
|
||||
bool is_valid() const;
|
||||
};
|
||||
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
|
||||
@@ -92,4 +92,10 @@ Polygon::make_clockwise()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
Polygon::is_valid() const
|
||||
{
|
||||
return this->points.size() >= 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class Polygon : public MultiPoint {
|
||||
bool is_counter_clockwise() const;
|
||||
bool make_counter_clockwise();
|
||||
bool make_clockwise();
|
||||
bool is_valid() const;
|
||||
};
|
||||
|
||||
typedef std::vector<Polygon> Polygons;
|
||||
|
||||
Reference in New Issue
Block a user