OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
marchsq Namespace Reference

Namespaces

namespace  __impl

Classes

struct  AdaptiveTpmsField
struct  _RasterTraits< AdaptiveTpmsField >
struct  AdaptiveLevelField
struct  _RasterTraits< AdaptiveLevelField >
struct  GyroidField
struct  _RasterTraits< GyroidField >
struct  ScalarField
struct  _RasterTraits< ScalarField >
struct  _RasterTraits< Slic3r::png::ImageGreyscale >
struct  Coord
struct  _RasterTraits
struct  _Loop
struct  _Loop< Slic3r::ExecutionTBB >
struct  _RasterTraits< Slic3r::sla::RasterGrayscaleAA >

Typedefs

using coordr_t = long
using Pointf = Vec2d
using Ring = std::vector<Coord>

Functions

Polylines get_gyroid_polylines (const GyroidField &sf, const double tolerance=SCALED_EPSILON)
Polylines get_polylines (const ScalarField &sf, const double tolerance=SCALED_EPSILON)
std::ostream & operator<< (std::ostream &os, const Coord &o)
std::ostream & operator<< (std::ostream &os, const Ring &r)
template<class Raster, class ExecutionPolicy>
std::vector< marchsq::Ring > execute_with_policy (ExecutionPolicy &&policy, const Raster &raster, TRasterValue< Raster > isoval, Coord windowsize={})
template<class Raster>
std::vector< marchsq::Ring > execute (const Raster &raster, TRasterValue< Raster > isoval, Coord windowsize={})

Typedef Documentation

◆ coordr_t

using marchsq::coordr_t = long

◆ Pointf

◆ Ring

using marchsq::Ring = std::vector<Coord>

Function Documentation

◆ execute()

template<class Raster>
std::vector< marchsq::Ring > marchsq::__impl::execute ( const Raster & raster,
TRasterValue< Raster > isoval,
Coord windowsize = {} )
645 {})
646{
647 return execute_with_policy(nullptr, raster, isoval, windowsize);
648}
std::vector< marchsq::Ring > execute_with_policy(ExecutionPolicy &&policy, const Raster &raster, TRasterValue< Raster > isoval, Coord windowsize={})
Definition MarchingSquares.hpp:621

Referenced by Slic3r::anonymous_namespace{SL1.cpp}::extract_slices_from_sla_archive(), and Slic3r::sla::raster_to_polygons().

Here is the caller graph for this function:

◆ execute_with_policy()

template<class Raster, class ExecutionPolicy>
std::vector< marchsq::Ring > marchsq::__impl::execute_with_policy ( ExecutionPolicy && policy,
const Raster & raster,
TRasterValue< Raster > isoval,
Coord windowsize = {} )
624 {})
625{
626 if (!rows(raster) || !cols(raster))
627 return {};
628
629 size_t ratio = cols(raster) / rows(raster);
630
631 if (!windowsize.r)
632 windowsize.r = 2;
633 if (!windowsize.c)
634 windowsize.c = std::max(2l, long(windowsize.r * ratio));
635
636 Grid<Raster> grid{raster, windowsize};
637
638 grid.tag_grid(std::forward<ExecutionPolicy>(policy), isoval);
639 std::vector<marchsq::Ring> rings = grid.scan_rings();
640 grid.interpolate_rings(std::forward<ExecutionPolicy>(policy), rings, isoval);
641
642 return rings;
643}
std::vector< ArithmeticOnly< T > > grid(const T &start, const T &stop, const T &stride)
A set of equidistant values starting from 'start' (inclusive), ending in the closest multiple of 'str...
Definition MTUtils.hpp:127
size_t cols(const T &raster)
Definition MarchingSquares.hpp:173
size_t rows(const T &raster)
Definition MarchingSquares.hpp:171
long c
Definition MarchingSquares.hpp:96
long r
Definition MarchingSquares.hpp:96

Referenced by get_gyroid_polylines(), get_polylines(), Slic3r::make_adaptive_infill_shells(), and Slic3r::make_adaptive_tpms().

Here is the caller graph for this function:

◆ get_gyroid_polylines()

Polylines marchsq::get_gyroid_polylines ( const GyroidField & sf,
const double tolerance = SCALED_EPSILON )
inline
102{
103 std::vector<Ring> rings = execute_with_policy(ex_tbb, sf, sf.isoval, {sf.gsize, sf.gsize});
104 Polylines polys;
105 polys.reserve(rings.size());
106 for (const Ring& ring : rings) {
107 Polyline poly;
108 Points& pts = poly.points;
109 pts.reserve(ring.size() + 1);
110 for (const Coord& crd : ring)
111 pts.emplace_back(sf.to_Point(crd));
112 pts.push_back(pts.front());
113 if (tolerance >= 0.0)
114 poly.simplify(tolerance);
115 polys.emplace_back(poly);
116 }
117 return polys;
118}
Definition Polyline.hpp:25
std::vector< Polyline > Polylines
Definition Polyline.hpp:22
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
static constexpr ExecutionTBB ex_tbb
Definition ExecutionTBB.hpp:22
std::vector< Coord > Ring
Definition MarchingSquares.hpp:122
Definition MarchingSquares.hpp:95
Point to_Point(const Coord &p) const
Definition FillGyroid.cpp:87
float isoval
Definition FillGyroid.cpp:63

References Slic3r::ex_tbb, execute_with_policy(), marchsq::GyroidField::isoval, SCALED_EPSILON, and marchsq::GyroidField::to_Point().

Referenced by Slic3r::FillGyroid::_fill_surface_single().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_polylines()

Polylines marchsq::get_polylines ( const ScalarField & sf,
const double tolerance = SCALED_EPSILON )
98{
99 std::vector<Ring> rings = execute_with_policy(ex_tbb, sf, sf.isoval, {sf.gsize, sf.gsize});
100
101 Polylines polys;
102 polys.reserve(rings.size());
103 // size_t old_pts = 0, new_pts = 0;
104
105 for (const Ring& ring : rings) {
106 Polyline poly;
107 Points& pts = poly.points;
108 pts.reserve(ring.size() + 1);
109 for (const Coord& crd : ring)
110 pts.emplace_back(sf.to_Point(crd));
111 // MarchingSquare's rings are polygons, so add the first point to the end to make it a PolyLine.
112 pts.push_back(pts.front());
113 // old_pts += poly.points.size();
114 // Simplify within specified tolerance to reduce points.
115 if (tolerance >= 0.0)
116 poly.simplify(tolerance);
117 // new_pts += poly.points.size();
118 polys.emplace_back(poly);
119 }
120 // std::cerr << "MarchingSquares: poly.simplify(" << tolerance << ") reduced points from" <<
121 // old_pts << " to " << new_pts << " (" << 100*new_pts/old_pts << "%)\n";
122 return polys;
123}
Point to_Point(const Coord &p) const
Definition FillTpmsFK.cpp:72
float isoval
Definition FillTpmsFK.cpp:51

References Slic3r::ex_tbb, execute_with_policy(), marchsq::ScalarField::isoval, SCALED_EPSILON, and marchsq::ScalarField::to_Point().

Referenced by Slic3r::FillTpmsFK::_fill_surface_single().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<<() [1/2]

std::ostream & marchsq::operator<< ( std::ostream & os,
const Coord & o )
inline
119{ return os << "(r=" << o.r << ",c=" << o.c << ")"; }

References marchsq::Coord::c, and marchsq::Coord::r.

◆ operator<<() [2/2]

std::ostream & marchsq::operator<< ( std::ostream & os,
const Ring & r )
inline
125{
126 os << "[" << r.size() << "]:";
127 for (Coord c : r)
128 os << " " << c;
129 return os << "\n";
130}