OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SVG Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/SVG.hpp>

Collaboration diagram for Slic3r::SVG:

Classes

struct  ExPolygonAttributes

Public Member Functions

 SVG ()=default
 SVG (const char *afilename)
 SVG (const char *afilename, const BoundingBox &bbox, const coord_t bbox_offset=scale_(1.), bool flipY=true)
 SVG (const std::string &filename)
 SVG (const std::string &filename, const BoundingBox &bbox, const coord_t bbox_offset=scale_(1.), bool flipY=true)
 ~SVG ()
bool open (const char *filename)
bool open (const char *filename, const BoundingBox &bbox, const coord_t bbox_offset=scale_(1.), bool flipY=true)
bool open (const std::string &filename)
bool open (const std::string &filename, const BoundingBox &bbox, const coord_t bbox_offset=scale_(1.), bool flipY=true)
bool is_opened ()
void draw (const Line &line, std::string stroke="black", coordf_t stroke_width=0)
void draw (const ThickLine &line, const std::string &fill, const std::string &stroke, coordf_t stroke_width=0)
void draw (const Lines &lines, std::string stroke="black", coordf_t stroke_width=0)
void draw (const ExPolygon &expolygon, std::string fill="grey", const float fill_opacity=1.f)
void draw_outline (const ExPolygon &polygon, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
void draw (const ExPolygons &expolygons, std::string fill="grey", const float fill_opacity=1.f)
void draw_outline (const ExPolygons &polygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
void draw (const Surface &surface, std::string fill="grey", const float fill_opacity=1.f)
void draw_outline (const Surface &surface, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
void draw (const Surfaces &surfaces, std::string fill="grey", const float fill_opacity=1.f)
void draw_outline (const Surfaces &surfaces, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
void draw (const SurfacesPtr &surfaces, std::string fill="grey", const float fill_opacity=1.f)
void draw_outline (const SurfacesPtr &surfaces, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
void draw (const Polygon &polygon, std::string fill="grey")
void draw_outline (const Polygon &polygon, std::string stroke="black", coordf_t stroke_width=0)
void draw (const Polygons &polygons, std::string fill="grey")
void draw_outline (const Polygons &polygons, std::string stroke="black", coordf_t stroke_width=0)
void draw (const Polyline &polyline, std::string stroke="black", coordf_t stroke_width=0)
void draw (const Polylines &polylines, std::string stroke="black", coordf_t stroke_width=0)
void draw (const ThickLines &thicklines, const std::string &fill="lime", const std::string &stroke="black", coordf_t stroke_width=0)
void draw (const ThickPolylines &polylines, const std::string &stroke="black", coordf_t stroke_width=0)
void draw (const ThickPolylines &thickpolylines, const std::string &fill, const std::string &stroke, coordf_t stroke_width)
void draw (const Point &point, std::string fill="black", coord_t radius=0)
void draw (const Points &points, std::string fill="black", coord_t radius=0)
void draw (const Points &polygon, double scale, std::string fill="grey", coordf_t stroke_width=0)
void draw (const VecOfPoints &polygons, double scale, std::string fill="grey", coordf_t stroke_width=0)
void draw_text (const Point &pt, const char *text, const char *color, int font_size=20)
void draw_legend (const Point &pt, const char *text, const char *color)
void draw_grid (const BoundingBox &bbox, const std::string &stroke="black", coordf_t stroke_width=scale_(0.05), coordf_t step=scale_(1.0))
void add_comment (const std::string comment)
void Close ()

Static Public Member Functions

static void export_expolygons (const char *path, const BoundingBox &bbox, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
static void export_expolygons (const std::string &path, const BoundingBox &bbox, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
static void export_expolygons (const char *path, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
static void export_expolygons (const std::string &path, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
static void export_expolygons (const char *path, const std::vector< std::pair< Slic3r::ExPolygons, ExPolygonAttributes > > &expolygons_with_attributes)
static void export_expolygons (const std::string &path, const std::vector< std::pair< Slic3r::ExPolygons, ExPolygonAttributes > > &expolygons_with_attributes)

Public Attributes

bool arrows
std::string fill
std::string stroke
Point origin
float height
bool flipY

Private Member Functions

void path (const std::string &d, bool fill, coordf_t stroke_width, const float fill_opacity)
std::string get_path_d (const MultiPoint &mp, bool closed=false) const
std::string get_path_d (const Points &mp, double scale, bool closed=false) const
float to_svg_y (float x) const throw ()

Static Private Member Functions

static float to_svg_coord (float x) throw ()
static float to_svg_x (float x) throw ()

Private Attributes

std::string filename
FILE * f

Detailed Description

Constructor & Destructor Documentation

◆ SVG() [1/5]

Slic3r::SVG::SVG ( )
default

Referenced by export_expolygons(), and export_expolygons().

Here is the caller graph for this function:

◆ SVG() [2/5]

Slic3r::SVG::SVG ( const char * afilename)
inline
31 :
32 arrows(false), fill("grey"), stroke("black"), filename(afilename), flipY(false)
33 { open(filename); }
std::string fill
Definition SVG.hpp:25
std::string stroke
Definition SVG.hpp:25
bool flipY
Definition SVG.hpp:28
bool open(const char *filename)
Definition SVG.cpp:45
std::string filename
Definition SVG.hpp:94
bool arrows
Definition SVG.hpp:24

References arrows, filename, fill, flipY, open(), and stroke.

Here is the call graph for this function:

◆ SVG() [3/5]

Slic3r::SVG::SVG ( const char * afilename,
const BoundingBox & bbox,
const coord_t bbox_offset = scale_(1.),
bool flipY = true )
inline
34 :
35 arrows(false), fill("grey"), stroke("black"), filename(afilename), origin(bbox.min - Point(bbox_offset, bbox_offset)), flipY(flipY)
36 { open(filename, bbox, bbox_offset, flipY); }
Point origin
Definition SVG.hpp:26
Kernel::Point_3 Point
Definition MeshRepair.cpp:81

References arrows, filename, fill, flipY, open(), origin, and stroke.

Here is the call graph for this function:

◆ SVG() [4/5]

Slic3r::SVG::SVG ( const std::string & filename)
inline
37 :
38 arrows(false), fill("grey"), stroke("black"), filename(filename), flipY(false)
39 { open(filename); }

References arrows, filename, fill, flipY, open(), and stroke.

Here is the call graph for this function:

◆ SVG() [5/5]

Slic3r::SVG::SVG ( const std::string & filename,
const BoundingBox & bbox,
const coord_t bbox_offset = scale_(1.),
bool flipY = true )
inline
40 :
41 arrows(false), fill("grey"), stroke("black"), filename(filename), origin(bbox.min - Point(bbox_offset, bbox_offset)), flipY(flipY)
42 { open(filename, bbox, bbox_offset, flipY); }

References arrows, filename, fill, flipY, open(), origin, and stroke.

Here is the call graph for this function:

◆ ~SVG()

Slic3r::SVG::~SVG ( )
inline
43{ if (f != NULL) Close(); }
FILE * f
Definition SVG.hpp:95
void Close()
Definition SVG.cpp:373

References Close(), and f.

Here is the call graph for this function:

Member Function Documentation

◆ add_comment()

void Slic3r::SVG::add_comment ( const std::string comment)
369{
370 fprintf(this->f, "<!-- %s -->\n", comment.c_str());
371}

References f.

Referenced by Slic3r::GUI::ArrangeJob::prepare().

Here is the caller graph for this function:

◆ Close()

◆ draw() [1/19]

void Slic3r::SVG::draw ( const ExPolygon & expolygon,
std::string fill = "grey",
const float fill_opacity = 1.f )
126{
127 this->fill = fill;
128
129 std::string d;
130 for (const Polygon &p : to_polygons(expolygon))
131 d += this->get_path_d(p, true) + " ";
132 this->path(d, true, 0, fill_opacity);
133}
void path(const std::string &d, bool fill, coordf_t stroke_width, const float fill_opacity)
Definition SVG.cpp:277
std::string get_path_d(const MultiPoint &mp, bool closed=false) const
Definition SVG.cpp:295
Polygons to_polygons(const ExPolygon &src)
Definition ExPolygon.hpp:307

References fill, get_path_d(), path(), and Slic3r::to_polygons().

Here is the call graph for this function:

◆ draw() [2/19]

void Slic3r::SVG::draw ( const ExPolygons & expolygons,
std::string fill = "grey",
const float fill_opacity = 1.f )
144{
145 for (ExPolygons::const_iterator it = expolygons.begin(); it != expolygons.end(); ++it)
146 this->draw(*it, fill, fill_opacity);
147}
void draw(const Line &line, std::string stroke="black", coordf_t stroke_width=0)
Definition SVG.cpp:88

References draw(), and fill.

Here is the call graph for this function:

◆ draw() [3/19]

void Slic3r::SVG::draw ( const Line & line,
std::string stroke = "black",
coordf_t stroke_width = 0 )
89{
90 fprintf(this->f,
91 " <line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke: %s; stroke-width: %f\"",
92 to_svg_x(line.a(0) - origin(0)), to_svg_y(line.a(1) - origin(1)), to_svg_x(line.b(0) - origin(0)), to_svg_y(line.b(1) - origin(1)), stroke.c_str(), (stroke_width == 0) ? 1.f : to_svg_coord(stroke_width));
93 if (this->arrows)
94 fprintf(this->f, " marker-end=\"url(#endArrow)\"");
95 fprintf(this->f, "/>\n");
96}
float to_svg_y(float x) const
Definition SVG.hpp:185
static float to_svg_x(float x)
Definition SVG.hpp:184
static float to_svg_coord(float x)
Definition SVG.hpp:183

References Slic3r::Line::a, arrows, Slic3r::Line::b, f, origin, stroke, to_svg_coord(), to_svg_x(), and to_svg_y().

Referenced by Slic3r::TreeSupport::TreeSupport(), Slic3r::MultiPoint3::_douglas_peucker(), Slic3r::MultiPoint::_douglas_peucker(), Slic3r::Feature::FuzzySkin::apply_fuzzy_skin(), Slic3r::Feature::FuzzySkin::apply_fuzzy_skin(), Slic3r::ExPolygon::contains(), Slic3r::contour_distance(), Slic3r::contour_distance2(), anonymous_namespace{EmbossJob.cpp}::create_mesh_per_glyph(), Slic3r::sla::anonymous_namespace{Pad.cpp}::create_pad_geometry(), Slic3r::detect_bridge_directions(), Slic3r::PrintObject::discover_vertical_shells(), Slic3r::ArcFitter::do_arc_fitting(), Slic3r::Algorithm::do_split_line(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw(), draw_grid(), Slic3r::FillLightning::Node::draw_tree(), Slic3r::draw_two_overhangs_to_svg(), Slic3r::dump_voronoi_to_svg(), export_expolygons(), export_expolygons(), Slic3r::export_intersections_to_svg(), Slic3r::Layer::export_region_fill_surfaces_to_svg(), Slic3r::LayerRegion::export_region_fill_surfaces_to_svg(), Slic3r::Layer::export_region_slices_to_svg(), Slic3r::LayerRegion::export_region_slices_to_svg(), Slic3r::export_to_svg(), Slic3r::SurfaceCollection::export_to_svg(), Slic3r::SupportGridPattern::extract_support(), Slic3r::FillRectilinear::fill_surface_by_lines(), Slic3r::generate_extra_perimeters_over_overhangs(), Slic3r::line_rounded_thick_segment_collision(), Slic3r::make_loops(), Slic3r::mark_boundary_segments_touching_infill(), Slic3r::Algorithm::merge_expansions_into_expolygons(), Slic3r::modulate_extrusion_by_overlapping_layers(), Slic3r::ExPolygon::overlaps(), Slic3r::PerimeterGenerator::process_classic(), priv::select_patches(), Slic3r::slice_mesh(), Slic3r::slice_region_by_vertical_lines(), Slic3r::Arachne::WallToolPaths::stitchToolPaths(), Slic3r::PrintObjectSupportMaterial::top_contact_layers(), and Slic3r::sla::SupportPointGenerator::uniformly_cover().

Here is the call graph for this function:

◆ draw() [4/19]

void Slic3r::SVG::draw ( const Lines & lines,
std::string stroke = "black",
coordf_t stroke_width = 0 )
120{
121 for (const Line &l : lines)
122 this->draw(l, stroke, stroke_width);
123}

References draw(), and stroke.

Here is the call graph for this function:

◆ draw() [5/19]

void Slic3r::SVG::draw ( const Point & point,
std::string fill = "black",
coord_t radius = 0 )
237{
238 float radius = (iradius == 0) ? 3.f : to_svg_coord(iradius);
239 std::ostringstream svg;
240 svg << " <circle cx=\"" << to_svg_x(point(0) - origin(0)) << "\" cy=\"" << to_svg_y(point(1) - origin(1))
241 << "\" r=\"" << radius << "\" "
242 << "style=\"stroke: none; fill: " << fill << "\" />";
243
244 fprintf(this->f, "%s\n", svg.str().c_str());
245}

References f, fill, origin, to_svg_coord(), to_svg_x(), and to_svg_y().

Here is the call graph for this function:

◆ draw() [6/19]

void Slic3r::SVG::draw ( const Points & points,
std::string fill = "black",
coord_t radius = 0 )
248{
249 for (Points::const_iterator it = points.begin(); it != points.end(); ++it)
250 this->draw(*it, fill, radius);
251}

References draw(), and fill.

Here is the call graph for this function:

◆ draw() [7/19]

void Slic3r::SVG::draw ( const Points & polygon,
double scale,
std::string fill = "grey",
coordf_t stroke_width = 0 )
254{
255 this->stroke = stroke;
256 this->path(this->get_path_d(polygon, scale, true), false, stroke_width, 1.f);
257}
int scale(const int val)
Definition WipeTowerDialog.cpp:58

References get_path_d(), path(), scale(), and stroke.

Here is the call graph for this function:

◆ draw() [8/19]

void Slic3r::SVG::draw ( const Polygon & polygon,
std::string fill = "grey" )
190{
191 this->fill = fill;
192 this->path(this->get_path_d(polygon, true), !fill.empty(), 0, 1.f);
193}

References fill, get_path_d(), and path().

Here is the call graph for this function:

◆ draw() [9/19]

void Slic3r::SVG::draw ( const Polygons & polygons,
std::string fill = "grey" )
196{
197 for (Polygons::const_iterator it = polygons.begin(); it != polygons.end(); ++it) {
198 // BBS
199 if (it->is_counter_clockwise())
200 this->draw(*it, fill);
201 else
202 this->draw(*it, "white");
203 }
204}

References draw(), and fill.

Here is the call graph for this function:

◆ draw() [10/19]

void Slic3r::SVG::draw ( const Polyline & polyline,
std::string stroke = "black",
coordf_t stroke_width = 0 )
207{
208 this->stroke = stroke;
209 this->path(this->get_path_d(polyline, false), false, stroke_width, 1.f);
210}

References get_path_d(), path(), and stroke.

Here is the call graph for this function:

◆ draw() [11/19]

void Slic3r::SVG::draw ( const Polylines & polylines,
std::string stroke = "black",
coordf_t stroke_width = 0 )
213{
214 for (Polylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it)
215 this->draw(*it, stroke, stroke_width);
216}

References draw(), and stroke.

Here is the call graph for this function:

◆ draw() [12/19]

void Slic3r::SVG::draw ( const Surface & surface,
std::string fill = "grey",
const float fill_opacity = 1.f )
156{
157 draw(surface.expolygon, fill, fill_opacity);
158}

References draw(), Slic3r::Surface::expolygon, and fill.

Here is the call graph for this function:

◆ draw() [13/19]

void Slic3r::SVG::draw ( const Surfaces & surfaces,
std::string fill = "grey",
const float fill_opacity = 1.f )
166{
167 for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
168 this->draw(*it, fill, fill_opacity);
169}

References draw(), and fill.

Here is the call graph for this function:

◆ draw() [14/19]

void Slic3r::SVG::draw ( const SurfacesPtr & surfaces,
std::string fill = "grey",
const float fill_opacity = 1.f )
178{
179 for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
180 this->draw(*(*it), fill, fill_opacity);
181}

References draw(), and fill.

Here is the call graph for this function:

◆ draw() [15/19]

void Slic3r::SVG::draw ( const ThickLine & line,
const std::string & fill,
const std::string & stroke,
coordf_t stroke_width = 0 )
99{
100 Vec2d dir(line.b(0)-line.a(0), line.b(1)-line.a(1));
101 Vec2d perp(-dir(1), dir(0));
102 coordf_t len = sqrt(perp(0)*perp(0) + perp(1)*perp(1));
103 coordf_t da = coordf_t(0.5)*line.a_width/len;
104 coordf_t db = coordf_t(0.5)*line.b_width/len;
105 fprintf(this->f,
106 " <polygon points=\"%f,%f %f,%f %f,%f %f,%f\" style=\"fill:%s; stroke: %s; stroke-width: %f\"/>\n",
107 to_svg_x(line.a(0)-da*perp(0)-origin(0)),
108 to_svg_y(line.a(1)-da*perp(1)-origin(1)),
109 to_svg_x(line.b(0)-db*perp(0)-origin(0)),
110 to_svg_y(line.b(1)-db*perp(1)-origin(1)),
111 to_svg_x(line.b(0)+db*perp(0)-origin(0)),
112 to_svg_y(line.b(1)+db*perp(1)-origin(1)),
113 to_svg_x(line.a(0)+da*perp(0)-origin(0)),
114 to_svg_y(line.a(1)+da*perp(1)-origin(1)),
115 fill.c_str(), stroke.c_str(),
116 (stroke_width == 0) ? 1.f : to_svg_coord(stroke_width));
117}
double coordf_t
Definition GUI_ObjectList.hpp:46
Eigen::Matrix< typename Derived::Scalar, 2, 1, Eigen::DontAlign > perp(const Eigen::MatrixBase< Derived > &v)
Definition Point.hpp:130
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References Slic3r::Line::a, Slic3r::ThickLine::a_width, Slic3r::Line::b, Slic3r::ThickLine::b_width, f, fill, origin, Slic3r::perp(), stroke, to_svg_coord(), to_svg_x(), and to_svg_y().

Here is the call graph for this function:

◆ draw() [16/19]

void Slic3r::SVG::draw ( const ThickLines & thicklines,
const std::string & fill = "lime",
const std::string & stroke = "black",
coordf_t stroke_width = 0 )
219{
220 for (ThickLines::const_iterator it = thicklines.begin(); it != thicklines.end(); ++it)
221 this->draw(*it, fill, stroke, stroke_width);
222}

References draw(), fill, and stroke.

Here is the call graph for this function:

◆ draw() [17/19]

void Slic3r::SVG::draw ( const ThickPolylines & polylines,
const std::string & stroke = "black",
coordf_t stroke_width = 0 )
225{
226 for (ThickPolylines::const_iterator it = polylines.begin(); it != polylines.end(); ++it)
227 this->draw((Polyline)*it, stroke, stroke_width);
228}

References draw(), and stroke.

Here is the call graph for this function:

◆ draw() [18/19]

void Slic3r::SVG::draw ( const ThickPolylines & thickpolylines,
const std::string & fill,
const std::string & stroke,
coordf_t stroke_width )
231{
232 for (ThickPolylines::const_iterator it = thickpolylines.begin(); it != thickpolylines.end(); ++ it)
233 draw(it->thicklines(), fill, stroke, stroke_width);
234}

References draw(), fill, and stroke.

Here is the call graph for this function:

◆ draw() [19/19]

void Slic3r::SVG::draw ( const VecOfPoints & polygons,
double scale,
std::string fill = "grey",
coordf_t stroke_width = 0 )
260{
261 for (VecOfPoints::const_iterator it = polygons.begin(); it != polygons.end(); ++ it)
262 draw(*it, scale, stroke, stroke_width);
263}

References draw(), scale(), and stroke.

Here is the call graph for this function:

◆ draw_grid()

void Slic3r::SVG::draw_grid ( const BoundingBox & bbox,
const std::string & stroke = "black",
coordf_t stroke_width = scale_(0.05),
coordf_t step = scale_(1.0) )
345{
346 // draw grid
347 Point bbox_size = bbox.size();
348 if (bbox_size(0) < step || bbox_size(1) < step)
349 return;
350
351 Point start_pt(bbox.min(0), bbox.min(1));
352 Point end_pt(bbox.max(1), bbox.min(1));
353 for (coordf_t y = bbox.min(1); y <= bbox.max(1); y += step) {
354 start_pt(1) = y;
355 end_pt(1) = y;
356 draw(Line(start_pt, end_pt), stroke, stroke_width);
357 }
358
359 start_pt(1) = bbox.min(1);
360 end_pt(1) = bbox.max(1);
361 for (coordf_t x = bbox.min(0); x <= bbox.max(0); x += step) {
362 start_pt(0) = x;
363 end_pt(0) = x;
364 draw(Line(start_pt, end_pt), stroke, stroke_width);
365 }
366}

References draw(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::BoundingBoxBase< PointType, APointsType >::size(), and stroke.

Here is the call graph for this function:

◆ draw_legend()

void Slic3r::SVG::draw_legend ( const Point & pt,
const char * text,
const char * color )
330{
331 fprintf(this->f,
332 "<circle cx=\"%f\" cy=\"%f\" r=\"10\" fill=\"%s\"/>",
333 to_svg_x(pt(0)-origin(0)),
334 to_svg_y(pt(1)-origin(1)),
335 color);
336 fprintf(this->f,
337 "<text x=\"%f\" y=\"%f\" font-family=\"sans-serif\" font-size=\"10px\" fill=\"%s\">%s</text>",
338 to_svg_x(pt(0)-origin(0)) + 20.f,
339 to_svg_y(pt(1)-origin(1)),
340 "black", text);
341}

References f, origin, to_svg_x(), and to_svg_y().

Referenced by export_expolygons(), and Slic3r::export_surface_type_legend_to_svg().

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

◆ draw_outline() [1/7]

void Slic3r::SVG::draw_outline ( const ExPolygon & polygon,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
136{
137 draw_outline(expolygon.contour, stroke_outer, stroke_width);
138 for (Polygons::const_iterator it = expolygon.holes.begin(); it != expolygon.holes.end(); ++ it) {
139 draw_outline(*it, stroke_holes, stroke_width);
140 }
141}
void draw_outline(const ExPolygon &polygon, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
Definition SVG.cpp:135

References Slic3r::ExPolygon::contour, draw_outline(), and Slic3r::ExPolygon::holes.

Referenced by Slic3r::Feature::FuzzySkin::apply_fuzzy_skin(), Slic3r::Feature::FuzzySkin::apply_fuzzy_skin(), Slic3r::GUI::ArrangeJob::check_unprintable(), Slic3r::Arachne::SkeletalTrapezoidation::constructFromPolygons(), Slic3r::ExPolygon::contains(), Slic3r::contour_distance(), Slic3r::contour_distance2(), Slic3r::PrintObject::discover_vertical_shells(), Slic3r::Algorithm::do_split_line(), draw_outline(), draw_outline(), draw_outline(), draw_outline(), draw_outline(), draw_outline(), Slic3r::dump_voronoi_to_svg(), export_expolygons(), export_expolygons(), Slic3r::export_intersections_to_svg(), Slic3r::LayerRegion::export_region_fill_surfaces_to_svg(), Slic3r::SupportGridPattern::extract_support(), Slic3r::Algorithm::merge_expansions_into_expolygons(), Slic3r::ExPolygon::overlaps(), Slic3r::GUI::ArrangeJob::prepare(), Slic3r::slice_mesh(), Slic3r::slice_region_by_vertical_lines(), and Slic3r::Arachne::WallToolPaths::stitchToolPaths().

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

◆ draw_outline() [2/7]

void Slic3r::SVG::draw_outline ( const ExPolygons & polygons,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
150{
151 for (ExPolygons::const_iterator it = expolygons.begin(); it != expolygons.end(); ++ it)
152 draw_outline(*it, stroke_outer, stroke_holes, stroke_width);
153}

References draw_outline().

Here is the call graph for this function:

◆ draw_outline() [3/7]

void Slic3r::SVG::draw_outline ( const Polygon & polygon,
std::string stroke = "black",
coordf_t stroke_width = 0 )
266{
267 this->stroke = stroke;
268 this->path(this->get_path_d(polygon, true), false, stroke_width, 1.f);
269}

References get_path_d(), path(), and stroke.

Here is the call graph for this function:

◆ draw_outline() [4/7]

void Slic3r::SVG::draw_outline ( const Polygons & polygons,
std::string stroke = "black",
coordf_t stroke_width = 0 )
272{
273 for (Polygons::const_iterator it = polygons.begin(); it != polygons.end(); ++ it)
274 draw_outline(*it, stroke, stroke_width);
275}

References draw_outline(), and stroke.

Here is the call graph for this function:

◆ draw_outline() [5/7]

void Slic3r::SVG::draw_outline ( const Surface & surface,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
161{
162 draw_outline(surface.expolygon, stroke_outer, stroke_holes, stroke_width);
163}

References draw_outline(), and Slic3r::Surface::expolygon.

Here is the call graph for this function:

◆ draw_outline() [6/7]

void Slic3r::SVG::draw_outline ( const Surfaces & surfaces,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
172{
173 for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it)
174 draw_outline(*it, stroke_outer, stroke_holes, stroke_width);
175}

References draw_outline().

Here is the call graph for this function:

◆ draw_outline() [7/7]

void Slic3r::SVG::draw_outline ( const SurfacesPtr & surfaces,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
184{
185 for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it)
186 draw_outline(*(*it), stroke_outer, stroke_holes, stroke_width);
187}

References draw_outline().

Here is the call graph for this function:

◆ draw_text()

void Slic3r::SVG::draw_text ( const Point & pt,
const char * text,
const char * color,
int font_size = 20 )
321{
322 fprintf(this->f,
323 "<text x=\"%f\" y=\"%f\" font-family=\"sans-serif\" font-size=\"%dpx\" fill=\"%s\">%s</text>",
324 to_svg_x(pt(0)-origin(0)),
325 to_svg_y(pt(1)-origin(1)),
326 font_size*10, color, text);
327}

References f, origin, to_svg_x(), and to_svg_y().

Referenced by anonymous_namespace{EmbossJob.cpp}::create_mesh_per_glyph(), Slic3r::SurfaceCollection::export_to_svg(), Slic3r::GUI::ArrangeJob::prepare(), and priv::select_patches().

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

◆ export_expolygons() [1/6]

void Slic3r::SVG::export_expolygons ( const char * path,
const BoundingBox & bbox,
const Slic3r::ExPolygons & expolygons,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
static
382{
383 SVG svg(path, bbox);
384 svg.draw(expolygons);
385 svg.draw_outline(expolygons, stroke_outer, stroke_holes, stroke_width);
386 svg.Close();
387}
SVG()=default

References SVG(), Close(), draw(), draw_outline(), and path().

Referenced by Slic3r::detect_bottom_contacts(), Slic3r::detect_contacts(), Slic3r::PrintObject::discover_vertical_shells(), Slic3r::elephant_foot_compensation(), export_expolygons(), export_expolygons(), export_expolygons(), export_expolygons(), Slic3r::SupportGridPattern::extract_support(), Slic3r::fill_contact_layer(), Slic3r::PrintObjectSupportMaterial::generate(), Slic3r::TreeSupport3D::TreeModelVolumes::precalculate(), Slic3r::project_support_to_grid(), Slic3r::SupportMaterialInternal::remove_bridges_from_contacts(), Slic3r::segmentation_top_and_bottom_layers(), and Slic3r::slice_mesh().

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

◆ export_expolygons() [2/6]

void Slic3r::SVG::export_expolygons ( const char * path,
const Slic3r::ExPolygons & expolygons,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
inlinestatic
106 { export_expolygons(path, get_extents(expolygons), expolygons, stroke_outer, stroke_holes, stroke_width); }
static void export_expolygons(const char *path, const BoundingBox &bbox, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
Definition SVG.cpp:381
BoundingBox get_extents(const ExPolygonsWithIds &e)
Definition Emboss.cpp:1374

References export_expolygons(), Slic3r::get_extents(), and path().

Here is the call graph for this function:

◆ export_expolygons() [3/6]

void Slic3r::SVG::export_expolygons ( const char * path,
const std::vector< std::pair< Slic3r::ExPolygons, ExPolygonAttributes > > & expolygons_with_attributes )
static
397{
398 if (expolygons_with_attributes.empty())
399 return;
400
401 size_t num_legend = std::count_if(expolygons_with_attributes.begin(), expolygons_with_attributes.end(), [](const auto &v){ return ! v.second.legend.empty(); });
402 // Format in num_columns.
403 size_t num_columns = 3;
404 // Width of the column.
405 coord_t step_x = scale_(20.);
406 Point legend_size(scale_(1.) + num_columns * step_x, scale_(0.4 + 1.3 * (num_legend + num_columns - 1) / num_columns));
407
408 BoundingBox bbox = get_extents(expolygons_with_attributes.front().first);
409 for (size_t i = 0; i < expolygons_with_attributes.size(); ++ i)
410 bbox.merge(get_extents(expolygons_with_attributes[i].first));
411 // Legend y.
412 coord_t pos_y = bbox.max.y() + scale_(1.5);
413 bbox.merge(Point(std::max(bbox.min.x() + legend_size.x(), bbox.max.x()), bbox.max.y() + legend_size.y()));
414
415 SVG svg(path, bbox);
416 for (const auto &exp_with_attr : expolygons_with_attributes)
417 svg.draw(exp_with_attr.first, exp_with_attr.second.color_fill, exp_with_attr.second.fill_opacity);
418 for (const auto &exp_with_attr : expolygons_with_attributes) {
419 if (exp_with_attr.second.outline_width > 0) {
420 std::string color_contour = exp_with_attr.second.color_contour;
421 if (color_contour.empty())
422 color_contour = exp_with_attr.second.color_fill;
423 std::string color_holes = exp_with_attr.second.color_holes;
424 if (color_holes.empty())
425 color_holes = color_contour;
426 svg.draw_outline(exp_with_attr.first, color_contour, color_holes, exp_with_attr.second.outline_width);
427 }
428 }
429 for (const auto &exp_with_attr : expolygons_with_attributes)
430 if (exp_with_attr.second.radius_points > 0)
431 for (const ExPolygon &expoly : exp_with_attr.first)
432 svg.draw(to_points(expoly), exp_with_attr.second.color_points, exp_with_attr.second.radius_points);
433
434 // Export legend.
435 // 1st row
436 coord_t pos_x0 = bbox.min.x() + scale_(1.);
437 coord_t pos_x = pos_x0;
438 size_t i_legend = 0;
439 for (const auto &exp_with_attr : expolygons_with_attributes) {
440 if (! exp_with_attr.second.legend.empty()) {
441 svg.draw_legend(Point(pos_x, pos_y), exp_with_attr.second.legend.c_str(), exp_with_attr.second.color_fill.c_str());
442 if ((++ i_legend) % num_columns == 0) {
443 pos_x = pos_x0;
444 pos_y += scale_(1.3);
445 } else {
446 pos_x += step_x;
447 }
448 }
449 }
450 svg.Close();
451}
#define scale_(val)
Definition libslic3r.h:106
int64_t coord_t
Definition libslic3r.h:48
Points to_points(const ExPolygons &src)
Definition ExPolygon.hpp:222

References SVG(), Close(), draw(), draw_legend(), draw_outline(), Slic3r::get_extents(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::merge(), Slic3r::BoundingBoxBase< PointType, APointsType >::min, path(), scale_, and Slic3r::to_points().

Here is the call graph for this function:

◆ export_expolygons() [4/6]

void Slic3r::SVG::export_expolygons ( const std::string & path,
const BoundingBox & bbox,
const Slic3r::ExPolygons & expolygons,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
inlinestatic
104 { export_expolygons(path.c_str(), bbox, expolygons, stroke_outer, stroke_holes, stroke_width); }

References export_expolygons(), and path().

Here is the call graph for this function:

◆ export_expolygons() [5/6]

void Slic3r::SVG::export_expolygons ( const std::string & path,
const Slic3r::ExPolygons & expolygons,
std::string stroke_outer = "black",
std::string stroke_holes = "blue",
coordf_t stroke_width = 0 )
inlinestatic
108 { export_expolygons(path.c_str(), get_extents(expolygons), expolygons, stroke_outer, stroke_holes, stroke_width); }

References export_expolygons(), Slic3r::get_extents(), and path().

Here is the call graph for this function:

◆ export_expolygons() [6/6]

void Slic3r::SVG::export_expolygons ( const std::string & path,
const std::vector< std::pair< Slic3r::ExPolygons, ExPolygonAttributes > > & expolygons_with_attributes )
inlinestatic
180 { export_expolygons(path.c_str(), expolygons_with_attributes); }

References export_expolygons(), and path().

Here is the call graph for this function:

◆ get_path_d() [1/2]

std::string Slic3r::SVG::get_path_d ( const MultiPoint & mp,
bool closed = false ) const
private
296{
297 std::ostringstream d;
298 d << "M ";
299 for (Points::const_iterator p = mp.points.begin(); p != mp.points.end(); ++p) {
300 d << to_svg_x((*p)(0) - origin(0)) << " ";
301 d << to_svg_y((*p)(1) - origin(1)) << " ";
302 }
303 if (closed) d << "z";
304 return d.str();
305}

References origin, Slic3r::MultiPoint::points, to_svg_x(), and to_svg_y().

Referenced by draw(), draw(), draw(), draw(), and draw_outline().

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

◆ get_path_d() [2/2]

std::string Slic3r::SVG::get_path_d ( const Points & mp,
double scale,
bool closed = false ) const
private
308{
309 std::ostringstream d;
310 d << "M ";
311 for (Points::const_iterator p = path.begin(); p != path.end(); ++p) {
312 d << to_svg_x(scale * p->x() - origin(0)) << " ";
313 d << to_svg_y(scale * p->y() - origin(1)) << " ";
314 }
315 if (closed) d << "z";
316 return d.str();
317}

References origin, path(), scale(), to_svg_x(), and to_svg_y().

Here is the call graph for this function:

◆ is_opened()

bool Slic3r::SVG::is_opened ( )
inline
51{ return f != NULL; }

References f.

Referenced by Slic3r::GUI::ArrangeJob::check_unprintable(), Slic3r::SupportGridPattern::extract_support(), Slic3r::GUI::ArrangeJob::prepare(), and Slic3r::PrintObjectSupportMaterial::top_contact_layers().

Here is the caller graph for this function:

◆ open() [1/4]

bool Slic3r::SVG::open ( const char * filename)
46{
47 create_dir(afilename);
48 this->filename = afilename;
49 this->f = boost::nowide::fopen(afilename, "w");
50 if (this->f == NULL)
51 return false;
52 fprintf(this->f,
53 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
54 "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
55 "<svg height=\"2000\" width=\"2000\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"
56 " <marker id=\"endArrow\" markerHeight=\"8\" markerUnits=\"strokeWidth\" markerWidth=\"10\" orient=\"auto\" refX=\"1\" refY=\"5\" viewBox=\"0 0 10 10\">\n"
57 " <polyline fill=\"darkblue\" points=\"0,0 10,5 0,10 1,5\" />\n"
58 " </marker>\n"
59 );
60 fprintf(this->f, "<rect fill='white' stroke='none' x='0' y='0' width='%f' height='%f'/>\n", 2000.f, 2000.f);
61 return true;
62}
void create_dir(const std::string &filePath)
Definition SVG.cpp:29

References Slic3r::create_dir(), f, and filename.

Referenced by SVG(), SVG(), SVG(), SVG(), open(), and open().

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

◆ open() [2/4]

bool Slic3r::SVG::open ( const char * filename,
const BoundingBox & bbox,
const coord_t bbox_offset = scale_(1.),
bool flipY = true )
65{
66 create_dir(afilename);
67 this->filename = afilename;
68 this->origin = bbox.min - Point(bbox_offset, bbox_offset);
69 this->flipY = aflipY;
70 this->f = boost::nowide::fopen(afilename, "w");
71 if (f == NULL)
72 return false;
73 float w = to_svg_coord(bbox.max(0) - bbox.min(0) + 2 * bbox_offset);
74 float h = to_svg_coord(bbox.max(1) - bbox.min(1) + 2 * bbox_offset);
75 this->height = h;
76 fprintf(this->f,
77 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
78 "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
79 "<svg height=\"%f\" width=\"%f\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"
80 " <marker id=\"endArrow\" markerHeight=\"8\" markerUnits=\"strokeWidth\" markerWidth=\"10\" orient=\"auto\" refX=\"1\" refY=\"5\" viewBox=\"0 0 10 10\">\n"
81 " <polyline fill=\"darkblue\" points=\"0,0 10,5 0,10 1,5\" />\n"
82 " </marker>\n",
83 h, w);
84 fprintf(this->f, "<rect fill='white' stroke='none' x='0' y='0' width='%f' height='%f'/>\n", w, h);
85 return true;
86}
float height
Definition SVG.hpp:27

References Slic3r::create_dir(), f, filename, flipY, height, Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::min, origin, and to_svg_coord().

Here is the call graph for this function:

◆ open() [3/4]

bool Slic3r::SVG::open ( const std::string & filename)
inline
48 { return open(filename.c_str()); }

References filename, and open().

Here is the call graph for this function:

◆ open() [4/4]

bool Slic3r::SVG::open ( const std::string & filename,
const BoundingBox & bbox,
const coord_t bbox_offset = scale_(1.),
bool flipY = true )
inline
50 { return open(filename.c_str(), bbox, bbox_offset, flipY); }

References filename, flipY, and open().

Here is the call graph for this function:

◆ path()

void Slic3r::SVG::path ( const std::string & d,
bool fill,
coordf_t stroke_width,
const float fill_opacity )
private
278{
279 float lineWidth = 0.f;
280 if (! fill)
281 lineWidth = (stroke_width == 0) ? 2.f : to_svg_coord(stroke_width);
282
283 fprintf(
284 this->f,
285 " <path d=\"%s\" style=\"fill: %s; stroke: %s; stroke-width: %f; fill-type: evenodd\" %s fill-opacity=\"%f\" />\n",
286 d.c_str(),
287 fill ? this->fill.c_str() : "none",
288 this->stroke.c_str(),
289 lineWidth,
290 (this->arrows && !fill) ? " marker-end=\"url(#endArrow)\"" : "",
291 fill_opacity
292 );
293}

References f, fill, and to_svg_coord().

Referenced by draw(), draw(), draw(), draw(), draw_outline(), export_expolygons(), export_expolygons(), export_expolygons(), export_expolygons(), export_expolygons(), export_expolygons(), and get_path_d().

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

◆ to_svg_coord()

float Slic3r::SVG::to_svg_coord ( float x)
throw ( )
inlinestaticprivate
183{ return unscale<float>(x) * 10.f; }
T unscale(Q v)
Definition libslic3r.h:138

References Slic3r::unscale().

Referenced by draw(), draw(), draw(), open(), path(), to_svg_x(), and to_svg_y().

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

◆ to_svg_x()

float Slic3r::SVG::to_svg_x ( float x)
throw ( )
inlinestaticprivate
184{ return to_svg_coord(x); }

References to_svg_coord().

Referenced by draw(), draw(), draw(), draw_legend(), draw_text(), get_path_d(), and get_path_d().

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

◆ to_svg_y()

float Slic3r::SVG::to_svg_y ( float x) const
throw ( )
inlineprivate
185{ return flipY ? this->height - to_svg_coord(x) : to_svg_coord(x); }

References flipY, and to_svg_coord().

Referenced by draw(), draw(), draw(), draw_legend(), draw_text(), get_path_d(), and get_path_d().

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

Member Data Documentation

◆ arrows

bool Slic3r::SVG::arrows

Referenced by SVG(), SVG(), SVG(), SVG(), and draw().

◆ f

FILE* Slic3r::SVG::f
private

◆ filename

std::string Slic3r::SVG::filename
private

Referenced by SVG(), SVG(), SVG(), SVG(), open(), open(), open(), and open().

◆ fill

std::string Slic3r::SVG::fill

◆ flipY

bool Slic3r::SVG::flipY

Referenced by SVG(), SVG(), SVG(), SVG(), open(), open(), and to_svg_y().

◆ height

float Slic3r::SVG::height

Referenced by open().

◆ origin

Point Slic3r::SVG::origin

◆ stroke

std::string Slic3r::SVG::stroke

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/SVG.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/SVG.cpp