2013-07-14 13:05:55 +02:00
|
|
|
#ifndef slic3r_Surface_hpp_
|
|
|
|
#define slic3r_Surface_hpp_
|
|
|
|
|
2015-12-08 00:39:54 +01:00
|
|
|
#include "libslic3r.h"
|
2013-07-14 13:05:55 +02:00
|
|
|
#include "ExPolygon.hpp"
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2016-09-26 12:42:44 +02:00
|
|
|
enum SurfaceType { stTop, stBottom, stBottomBridge, stInternal, stInternalSolid, stInternalBridge, stInternalVoid, stPerimeter };
|
2013-07-14 13:05:55 +02:00
|
|
|
|
|
|
|
class Surface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SurfaceType surface_type;
|
2014-11-09 16:23:50 +01:00
|
|
|
ExPolygon expolygon;
|
2013-07-14 13:05:55 +02:00
|
|
|
double thickness; // in mm
|
|
|
|
unsigned short thickness_layers; // in layers
|
2014-04-21 23:21:15 +02:00
|
|
|
double bridge_angle; // in radians, ccw, 0 = East, only 0+ (negative means undefined)
|
2013-07-14 13:05:55 +02:00
|
|
|
unsigned short extra_perimeters;
|
2014-11-09 16:23:50 +01:00
|
|
|
|
|
|
|
Surface(SurfaceType _surface_type, const ExPolygon &_expolygon)
|
|
|
|
: surface_type(_surface_type), expolygon(_expolygon),
|
|
|
|
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
|
|
|
|
{};
|
2015-10-26 23:23:03 +01:00
|
|
|
operator Polygons() const;
|
2013-09-06 18:36:38 +02:00
|
|
|
double area() const;
|
2013-11-23 00:07:04 +01:00
|
|
|
bool is_solid() const;
|
2014-02-10 13:19:44 +01:00
|
|
|
bool is_external() const;
|
2014-12-09 01:08:58 +01:00
|
|
|
bool is_internal() const;
|
2014-03-25 01:11:28 +01:00
|
|
|
bool is_bottom() const;
|
2013-11-23 00:07:04 +01:00
|
|
|
bool is_bridge() const;
|
2013-07-14 13:05:55 +02:00
|
|
|
};
|
|
|
|
|
2013-07-18 19:09:07 +02:00
|
|
|
typedef std::vector<Surface> Surfaces;
|
2013-11-23 18:15:59 +01:00
|
|
|
typedef std::vector<Surface*> SurfacesPtr;
|
2013-07-18 19:09:07 +02:00
|
|
|
|
2016-09-26 12:42:44 +02:00
|
|
|
inline Polygons to_polygons(const SurfacesPtr &src)
|
|
|
|
{
|
|
|
|
Polygons polygons;
|
|
|
|
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it) {
|
|
|
|
polygons.push_back((*it)->expolygon.contour);
|
|
|
|
for (Polygons::const_iterator ith = (*it)->expolygon.holes.begin(); ith != (*it)->expolygon.holes.end(); ++ith) {
|
|
|
|
polygons.push_back(*ith);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return polygons;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SLIC3R_CPPVER > 11
|
|
|
|
inline Polygons to_polygons(SurfacesPtr &&src)
|
|
|
|
{
|
|
|
|
Polygons polygons;
|
|
|
|
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) {
|
|
|
|
polygons.push_back(std::move((*it)->expolygon.contour));
|
|
|
|
for (Polygons::const_iterator ith = (*it)->expolygon.holes.begin(); ith != (*it)->expolygon.holes.end(); ++ith) {
|
|
|
|
polygons.push_back(std::move(*ith));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return polygons;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-13 13:30:00 +02:00
|
|
|
extern BoundingBox get_extents(const Surface &surface);
|
|
|
|
extern BoundingBox get_extents(const Surfaces &surfaces);
|
|
|
|
extern BoundingBox get_extents(const SurfacesPtr &surfaces);
|
|
|
|
|
2016-09-26 12:42:44 +02:00
|
|
|
class SVG;
|
|
|
|
|
|
|
|
extern const char* surface_type_to_color_name(const SurfaceType surface_type);
|
|
|
|
extern void export_surface_type_legend_to_svg(SVG &svg, const Point &pos);
|
|
|
|
extern Point export_surface_type_legend_to_svg_box_size();
|
|
|
|
extern bool export_to_svg(const char *path, const Surfaces &surfaces, const float transparency = 1.f);
|
|
|
|
|
2013-07-14 13:05:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|