mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-14 19:12:38 -07:00
Ported Polygon->is_counter_clockwise() and rearranged code in .cpp files
This commit is contained in:
55
xs/src/Polygon.cpp
Normal file
55
xs/src/Polygon.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <myinit.h>
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Polygon.hpp"
|
||||
#include "Polyline.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
SV*
|
||||
Polygon::to_SV_ref() {
|
||||
SV* sv = newSV(0);
|
||||
sv_setref_pv( sv, "Slic3r::Polygon", new Polygon(*this) );
|
||||
return sv;
|
||||
}
|
||||
|
||||
Lines
|
||||
Polygon::lines()
|
||||
{
|
||||
Lines lines;
|
||||
for (int i = 0; i < this->points.size()-1; i++) {
|
||||
lines.push_back(Line(this->points[i], this->points[i+1]));
|
||||
}
|
||||
lines.push_back(Line(this->points.back(), this->points.front()));
|
||||
return lines;
|
||||
}
|
||||
|
||||
Polyline*
|
||||
Polygon::split_at_index(int index)
|
||||
{
|
||||
Polyline* poly = new Polyline;
|
||||
for (int i = index; i < this->points.size(); i++) {
|
||||
poly->points.push_back( this->points[i] );
|
||||
}
|
||||
for (int i = 0; i <= index; i++) {
|
||||
poly->points.push_back( this->points[i] );
|
||||
}
|
||||
return poly;
|
||||
}
|
||||
|
||||
Polyline*
|
||||
Polygon::split_at_first_point()
|
||||
{
|
||||
return this->split_at_index(0);
|
||||
}
|
||||
|
||||
bool
|
||||
Polygon::is_counter_clockwise()
|
||||
{
|
||||
ClipperLib::Polygon* p = new ClipperLib::Polygon();
|
||||
Slic3rPolygon_to_ClipperPolygon(*this, *p);
|
||||
bool orientation = ClipperLib::Orientation(*p);
|
||||
delete p;
|
||||
return orientation;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user