diff options
author | bubnikv <bubnikv@gmail.com> | 2016-09-26 13:42:44 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2016-09-26 13:42:44 +0300 |
commit | 4a13efd081f6d2dae03a34f649337bf424147e39 (patch) | |
tree | 4d814a488f4397bf19d0cd23b7ff9fd758653a46 /xs/src/libslic3r/Surface.cpp | |
parent | a50603008294e49f14d5610871915f413bec829d (diff) |
Surface / Surface Collection - optimization routines for filtering,
routines for visualization.
Diffstat (limited to 'xs/src/libslic3r/Surface.cpp')
-rw-r--r-- | xs/src/libslic3r/Surface.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Surface.cpp b/xs/src/libslic3r/Surface.cpp index 5df2dd99a..384540d87 100644 --- a/xs/src/libslic3r/Surface.cpp +++ b/xs/src/libslic3r/Surface.cpp @@ -1,5 +1,6 @@ #include "BoundingBox.hpp" #include "Surface.hpp" +#include "SVG.hpp" namespace Slic3r { @@ -82,4 +83,65 @@ BoundingBox get_extents(const SurfacesPtr &surfaces) return bbox; } +const char* surface_type_to_color_name(const SurfaceType surface_type) +{ + switch (surface_type) { + case stTop: return "rgb(255,0,0)"; // "red"; + case stBottom: return "rgb(0,255,0)"; // "green"; + case stBottomBridge: return "rgb(0,0,255)"; // "blue"; + case stInternal: return "rgb(255,255,128)"; // yellow + case stInternalSolid: return "rgb(255,0,255)"; // magenta + case stInternalBridge: return "rgb(0,255,255)"; + case stInternalVoid: return "rgb(128,128,128)"; + case stPerimeter: return "rgb(128,0,0)"; // maroon + default: return "rgb(64,64,64)"; + }; +} + +Point export_surface_type_legend_to_svg_box_size() +{ + return Point(scale_(1.+10.*8.), scale_(3.)); +} + +void export_surface_type_legend_to_svg(SVG &svg, const Point &pos) +{ + // 1st row + coord_t pos_x0 = pos.x + scale_(1.); + coord_t pos_x = pos_x0; + coord_t pos_y = pos.y + scale_(1.5); + coord_t step_x = scale_(10.); + svg.draw_legend(Point(pos_x, pos_y), "perimeter" , surface_type_to_color_name(stPerimeter)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "top" , surface_type_to_color_name(stTop)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "bottom" , surface_type_to_color_name(stBottom)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "bottom bridge" , surface_type_to_color_name(stBottomBridge)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "invalid" , surface_type_to_color_name(SurfaceType(-1))); + // 2nd row + pos_x = pos_x0; + pos_y = pos.y+scale_(2.8); + svg.draw_legend(Point(pos_x, pos_y), "internal" , surface_type_to_color_name(stInternal)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "internal solid" , surface_type_to_color_name(stInternalSolid)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "internal bridge", surface_type_to_color_name(stInternalBridge)); + pos_x += step_x; + svg.draw_legend(Point(pos_x, pos_y), "internal void" , surface_type_to_color_name(stInternalVoid)); +} + +bool export_to_svg(const char *path, const Surfaces &surfaces, const float transparency) +{ + BoundingBox bbox; + for (Surfaces::const_iterator surface = surfaces.begin(); surface != surfaces.end(); ++surface) + bbox.merge(get_extents(surface->expolygon)); + + SVG svg(path, bbox); + for (Surfaces::const_iterator surface = surfaces.begin(); surface != surfaces.end(); ++surface) + svg.draw(surface->expolygon, surface_type_to_color_name(surface->surface_type), transparency); + svg.Close(); + return true; +} + } |