#ifndef slic3r_ExPolygonsIndex_hpp_ #define slic3r_ExPolygonsIndex_hpp_ #include "ExPolygon.hpp" namespace Slic3r { /// /// Index into ExPolygons /// Identify expolygon, its contour (or hole) and point /// struct ExPolygonsIndex { // index of ExPolygons uint32_t expolygons_index; // index of Polygon // 0 .. contour // N .. hole[N-1] uint32_t polygon_index; // index of point in polygon uint32_t point_index; bool is_contour() const { return polygon_index == 0; } bool is_hole() const { return polygon_index != 0; } uint32_t hole_index() const { return polygon_index - 1; } }; /// /// Keep conversion from ExPolygonsIndex to Index and vice versa /// ExPolygonsIndex .. contour(or hole) point from ExPolygons /// Index .. continous number /// /// index is used to address lines and points as result from function /// Slic3r::to_lines, Slic3r::to_points /// class ExPolygonsIndices { std::vector> m_offsets; // for check range of index uint32_t m_count; // count of points public: ExPolygonsIndices(const ExPolygons &shapes); /// /// Convert to one index number /// /// Compose of adress into expolygons /// Index uint32_t cvt(const ExPolygonsIndex &id) const; /// /// Separate to multi index /// /// adress into expolygons /// ExPolygonsIndex cvt(uint32_t index) const; /// /// Check whether id is last point in polygon /// /// Identify point in expolygon /// True when id is last point in polygon otherwise false bool is_last_point(const ExPolygonsIndex &id) const; /// /// Count of points in expolygons /// /// Count of points in expolygons uint32_t get_count() const; }; } // namespace Slic3r #endif // slic3r_ExPolygonsIndex_hpp_