diff options
Diffstat (limited to 'xs/src/libslic3r/Rasterizer/Rasterizer.cpp')
-rw-r--r-- | xs/src/libslic3r/Rasterizer/Rasterizer.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index b0bf04343..3ff3e0949 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -37,37 +37,37 @@ public: using Origin = Raster::Origin; private: - Raster::Resolution resolution_; - Raster::PixelDim pxdim_; - TBuffer buf_; - TRawBuffer rbuf_; - TPixelRenderer pixfmt_; - TRawRenderer raw_renderer_; - TRendererAA renderer_; - Origin o_; - std::function<void(agg::path_storage&)> flipy_ = [](agg::path_storage&) {}; + Raster::Resolution m_resolution; + Raster::PixelDim m_pxdim; + TBuffer m_buf; + TRawBuffer m_rbuf; + TPixelRenderer m_pixfmt; + TRawRenderer m_raw_renderer; + TRendererAA m_renderer; + Origin m_o; + std::function<void(agg::path_storage&)> m_flipy = [](agg::path_storage&) {}; public: inline Impl(const Raster::Resolution& res, const Raster::PixelDim &pd, Origin o): - resolution_(res), pxdim_(pd), - buf_(res.pixels()), - rbuf_(reinterpret_cast<TPixelRenderer::value_type*>(buf_.data()), + m_resolution(res), m_pxdim(pd), + m_buf(res.pixels()), + m_rbuf(reinterpret_cast<TPixelRenderer::value_type*>(m_buf.data()), res.width_px, res.height_px, res.width_px*TPixelRenderer::num_components), - pixfmt_(rbuf_), - raw_renderer_(pixfmt_), - renderer_(raw_renderer_), - o_(o) + m_pixfmt(m_rbuf), + m_raw_renderer(m_pixfmt), + m_renderer(m_raw_renderer), + m_o(o) { - renderer_.color(ColorWhite); + m_renderer.color(ColorWhite); // If we would like to play around with gamma // ras.gamma(agg::gamma_power(1.0)); clear(); - if(o_ == Origin::TOP_LEFT) flipy_ = [this](agg::path_storage& path) { - path.flip_y(0, resolution_.height_px); + if(m_o == Origin::TOP_LEFT) m_flipy = [this](agg::path_storage& path) { + path.flip_y(0, m_resolution.height_px); }; } @@ -76,35 +76,35 @@ public: agg::scanline_p8 scanlines; auto&& path = to_path(poly.contour); - flipy_(path); + m_flipy(path); ras.add_path(path); for(auto h : poly.holes) { auto&& holepath = to_path(h); - flipy_(holepath); + m_flipy(holepath); ras.add_path(holepath); } - agg::render_scanlines(ras, scanlines, renderer_); + agg::render_scanlines(ras, scanlines, m_renderer); } inline void clear() { - raw_renderer_.clear(ColorBlack); + m_raw_renderer.clear(ColorBlack); } - inline TBuffer& buffer() { return buf_; } + inline TBuffer& buffer() { return m_buf; } - inline const Raster::Resolution resolution() { return resolution_; } + inline const Raster::Resolution resolution() { return m_resolution; } - inline Origin origin() const /*noexcept*/ { return o_; } + inline Origin origin() const /*noexcept*/ { return m_o; } private: double getPx(const Point& p) { - return p(0) * SCALING_FACTOR/pxdim_.w_mm; + return p(0) * SCALING_FACTOR/m_pxdim.w_mm; } double getPy(const Point& p) { - return p(1) * SCALING_FACTOR/pxdim_.h_mm; + return p(1) * SCALING_FACTOR/m_pxdim.h_mm; } agg::path_storage to_path(const Polygon& poly) { @@ -124,57 +124,57 @@ const Raster::Impl::TPixel Raster::Impl::ColorWhite = Raster::Impl::TPixel(255); const Raster::Impl::TPixel Raster::Impl::ColorBlack = Raster::Impl::TPixel(0); Raster::Raster(const Resolution &r, const PixelDim &pd, Origin o): - impl_(new Impl(r, pd, o)) {} + m_impl(new Impl(r, pd, o)) {} Raster::Raster() {} Raster::~Raster() {} Raster::Raster(Raster &&m): - impl_(std::move(m.impl_)) {} + m_impl(std::move(m.m_impl)) {} void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd) { // Free up the unnecessary memory and make sure it stays clear after // an exception - auto o = impl_? impl_->origin() : Origin::TOP_LEFT; + auto o = m_impl? m_impl->origin() : Origin::TOP_LEFT; reset(r, pd, o); } void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd, Raster::Origin o) { - impl_.reset(); - impl_.reset(new Impl(r, pd, o)); + m_impl.reset(); + m_impl.reset(new Impl(r, pd, o)); } void Raster::reset() { - impl_.reset(); + m_impl.reset(); } Raster::Resolution Raster::resolution() const { - if(impl_) return impl_->resolution(); + if(m_impl) return m_impl->resolution(); return Resolution(0, 0); } void Raster::clear() { - assert(impl_); - impl_->clear(); + assert(m_impl); + m_impl->clear(); } void Raster::draw(const ExPolygon &poly) { - assert(impl_); - impl_->draw(poly); + assert(m_impl); + m_impl->draw(poly); } void Raster::save(std::ostream& stream, Compression comp) { - assert(impl_); + assert(m_impl); switch(comp) { case Compression::PNG: { @@ -188,7 +188,7 @@ void Raster::save(std::ostream& stream, Compression comp) wr.write_info(); - auto& b = impl_->buffer(); + auto& b = m_impl->buffer(); auto ptr = reinterpret_cast<png::byte*>( b.data() ); unsigned stride = sizeof(Impl::TBuffer::value_type) * resolution().width_px; @@ -201,12 +201,12 @@ void Raster::save(std::ostream& stream, Compression comp) } case Compression::RAW: { stream << "P5 " - << impl_->resolution().width_px << " " - << impl_->resolution().height_px << " " + << m_impl->resolution().width_px << " " + << m_impl->resolution().height_px << " " << "255 "; - stream.write(reinterpret_cast<const char*>(impl_->buffer().data()), - impl_->buffer().size()*sizeof(Impl::TBuffer::value_type)); + stream.write(reinterpret_cast<const char*>(m_impl->buffer().data()), + m_impl->buffer().size()*sizeof(Impl::TBuffer::value_type)); } } } |