PrusaSlicer-NonPlainar/xs/src/libslic3r/Geometry.hpp

68 lines
2.2 KiB
C++
Raw Normal View History

2013-11-22 21:38:30 +00:00
#ifndef slic3r_Geometry_hpp_
#define slic3r_Geometry_hpp_
#include "libslic3r.h"
#include "BoundingBox.hpp"
2016-03-19 14:33:58 +00:00
#include "ExPolygon.hpp"
2013-11-22 21:38:30 +00:00
#include "Polygon.hpp"
#include "Polyline.hpp"
2013-11-22 21:38:30 +00:00
#include "boost/polygon/voronoi.hpp"
using boost::polygon::voronoi_builder;
using boost::polygon::voronoi_diagram;
namespace Slic3r { namespace Geometry {
2013-11-22 21:38:30 +00:00
Polygon convex_hull(Points points);
Polygon convex_hull(const Polygons &polygons);
void chained_path(const Points &points, std::vector<Points::size_type> &retval, Point start_near);
void chained_path(const Points &points, std::vector<Points::size_type> &retval);
2013-11-23 22:21:59 +00:00
template<class T> void chained_path_items(Points &points, T &items, T &retval);
bool directions_parallel(double angle1, double angle2, double max_diff = 0);
template<class T> bool contains(const std::vector<T> &vector, const Point &point);
2014-11-15 21:41:22 +00:00
double rad2deg(double angle);
double rad2deg_dir(double angle);
double deg2rad(double angle);
void simplify_polygons(const Polygons &polygons, double tolerance, Polygons* retval);
2013-11-22 21:38:30 +00:00
class ArrangeItem {
public:
Pointf pos;
size_t index_x, index_y;
coordf_t dist;
};
class ArrangeItemIndex {
public:
coordf_t index;
ArrangeItem item;
ArrangeItemIndex(coordf_t _index, ArrangeItem _item) : index(_index), item(_item) {};
};
double linint(double value, double oldmin, double oldmax, double newmin, double newmax);
2015-12-02 17:06:18 +00:00
Pointfs arrange(size_t total_parts, Pointf part, coordf_t dist, const BoundingBoxf* bb);
class MedialAxis {
public:
Lines lines;
2016-03-19 14:33:58 +00:00
const ExPolygon* expolygon;
double max_width;
double min_width;
2016-03-19 14:33:58 +00:00
MedialAxis(double _max_width, double _min_width)
: max_width(_max_width), min_width(_min_width), expolygon(NULL) {};
void build(ThickPolylines* polylines);
void build(Polylines* polylines);
private:
typedef voronoi_diagram<double> VD;
VD vd;
std::set<const VD::edge_type*> edges, valid_edges;
2016-03-19 14:33:58 +00:00
std::map<const VD::edge_type*, std::pair<coordf_t,coordf_t> > thickness;
void process_edge_neighbors(const VD::edge_type* edge, ThickPolyline* polyline);
bool validate_edge(const VD::edge_type* edge);
const Line& retrieve_segment(const VD::cell_type* cell) const;
const Point& retrieve_endpoint(const VD::cell_type* cell) const;
};
} }
2013-11-22 21:38:30 +00:00
#endif