mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Output raster seem ok, stats broken.
This commit is contained in:
parent
8fdff97eb7
commit
440e54181b
10 changed files with 436 additions and 347 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "Rasterizer.hpp"
|
||||
#include <Polygon.hpp>
|
||||
#include <ExPolygon.hpp>
|
||||
#include <libnest2d/backends/clipper/clipper_polygon.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
@ -72,7 +73,7 @@ public:
|
|||
clear();
|
||||
}
|
||||
|
||||
void draw(const Polygon &poly) {
|
||||
template<class Geometry> inline void draw(const Geometry &poly) {
|
||||
agg::rasterizer_scanline_aa<> ras;
|
||||
agg::scanline_p8 scanlines;
|
||||
|
||||
|
@ -104,14 +105,36 @@ private:
|
|||
return p(1) * SCALING_FACTOR/m_pxdim.h_mm;
|
||||
}
|
||||
|
||||
agg::path_storage to_path(const Polygon& poly) {
|
||||
agg::path_storage to_path(const Polygon& poly)
|
||||
{
|
||||
agg::path_storage path;
|
||||
|
||||
auto it = poly.points.begin();
|
||||
path.move_to(getPx(*it), getPy(*it));
|
||||
while(++it != poly.points.end())
|
||||
while(++it != poly.points.end()) path.line_to(getPx(*it), getPy(*it));
|
||||
path.line_to(getPx(poly.points.front()), getPy(poly.points.front()));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
double getPx(const ClipperLib::IntPoint& p) {
|
||||
return p.X * SCALING_FACTOR/m_pxdim.w_mm;
|
||||
}
|
||||
|
||||
double getPy(const ClipperLib::IntPoint& p) {
|
||||
return p.Y * SCALING_FACTOR/m_pxdim.h_mm;
|
||||
}
|
||||
|
||||
agg::path_storage to_path(const ClipperLib::Path& poly)
|
||||
{
|
||||
agg::path_storage path;
|
||||
auto it = poly.begin();
|
||||
path.move_to(getPx(*it), getPy(*it));
|
||||
while(++it != poly.end())
|
||||
path.line_to(getPx(*it), getPy(*it));
|
||||
|
||||
path.line_to(getPx(poly.points.front()), getPy(poly.points.front()));
|
||||
path.line_to(getPx(poly.front()), getPy(poly.front()));
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -163,10 +186,16 @@ void Raster::clear()
|
|||
m_impl->clear();
|
||||
}
|
||||
|
||||
void Raster::draw(const Polygon &poly)
|
||||
void Raster::draw(const ExPolygon &expoly)
|
||||
{
|
||||
assert(m_impl);
|
||||
m_impl->draw(poly);
|
||||
m_impl->draw(expoly.contour);
|
||||
for(auto& h : expoly.holes) m_impl->draw(h);
|
||||
}
|
||||
|
||||
void Raster::draw(const ClipperLib::Polygon &poly)
|
||||
{
|
||||
m_impl->draw(poly.Contour);
|
||||
for(auto& h : poly.Holes) m_impl->draw(h);
|
||||
}
|
||||
|
||||
void Raster::save(std::ostream& stream, Compression comp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue