#ifndef libslic3r_Triangulation_hpp_ #define libslic3r_Triangulation_hpp_ #include #include #include #include #include namespace Slic3r { class Triangulation { public: Triangulation() = delete; // define oriented connection of 2 vertices(defined by its index) using HalfEdge = std::pair; using HalfEdges = std::vector; using Indices = std::vector; /// /// Connect points by triangulation to create filled surface by triangles /// Input points have to be unique /// Inspiration for make unique points is Emboss::dilate_to_unique_points /// /// Points to connect /// Constraint for edges, pair is from point(first) to /// point(second), sorted lexicographically /// Triangles static Indices triangulate(const Points &points, const HalfEdges &half_edges); static Indices triangulate(const Polygon &polygon); static Indices triangulate(const Polygons &polygons); static Indices triangulate(const ExPolygon &expolygon); static Indices triangulate(const ExPolygons &expolygons); // Map for convert original index to set without duplication // from_index using Changes = std::vector; /// /// Create conversion map from original index into new /// with respect of duplicit point /// /// input set of points /// duplicit points collected from points /// Conversion map for point index static Changes create_changes(const Points &points, const Points &duplicits); /// /// Triangulation for expolygons, speed up when points are already collected /// NOTE: Not working properly for ExPolygons with multiple point on same coordinate /// You should check it by "collect_changes" /// /// Input shape to triangulation - define edges /// Points from expolygons /// Triangle indices static Indices triangulate(const ExPolygons &expolygons, const Points& points); /// /// Triangulation for expolygons containing multiple points with same coordinate /// /// Input shape to triangulation - define edge /// Points from expolygons /// Changes swap for indicies into points /// Triangle indices static Indices triangulate(const ExPolygons &expolygons, const Points& points, const Changes& changes); }; } // namespace Slic3r #endif // libslic3r_Triangulation_hpp_