// Copyright (c) 2020 Ultimaker B.V. // CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef CURAENGINE_WALLTOOLPATHS_H #define CURAENGINE_WALLTOOLPATHS_H #include #include #include "BeadingStrategy/BeadingStrategyFactory.hpp" #include "utils/ExtrusionLine.hpp" #include "../Polygon.hpp" #include "../PrintConfig.hpp" namespace Slic3r::Arachne { constexpr bool fill_outline_gaps = true; constexpr coord_t meshfix_maximum_resolution = scaled(0.5); constexpr coord_t meshfix_maximum_deviation = scaled(0.025); constexpr coord_t meshfix_maximum_extrusion_area_deviation = scaled(2.); class WallToolPathsParams { public: float min_bead_width; float min_feature_size; float wall_transition_length; float wall_transition_angle; float wall_transition_filter_deviation; int wall_distribution_count; }; class WallToolPaths { public: /*! * A class that creates the toolpaths given an outline, nominal bead width and maximum amount of walls * \param outline An outline of the area in which the ToolPaths are to be generated * \param bead_width_0 The bead width of the first wall used in the generation of the toolpaths * \param bead_width_x The bead width of the inner walls used in the generation of the toolpaths * \param inset_count The maximum number of parallel extrusion lines that make up the wall * \param wall_0_inset How far to inset the outer wall, to make it adhere better to other walls. */ WallToolPaths(const Polygons& outline, coord_t bead_width_0, coord_t bead_width_x, size_t inset_count, coord_t wall_0_inset, coordf_t layer_height, const WallToolPathsParams ¶ms); /*! * Generates the Toolpaths * \return A reference to the newly create ToolPaths */ const std::vector &generate(); /*! * Gets the toolpaths, if this called before \p generate() it will first generate the Toolpaths * \return a reference to the toolpaths */ const std::vector &getToolPaths(); /*! * Compute the inner contour of the walls. This contour indicates where the walled area ends and its infill begins. * The inside can then be filled, e.g. with skin/infill for the walls of a part, or with a pattern in the case of * infill with extra infill walls. */ void separateOutInnerContour(); /*! * Gets the inner contour of the area which is inside of the generated tool * paths. * * If the walls haven't been generated yet, this will lazily call the * \p generate() function to generate the walls with variable width. * The resulting polygon will snugly match the inside of the variable-width * walls where the walls get limited by the LimitedBeadingStrategy to a * maximum wall count. * If there are no walls, the outline will be returned. * \return The inner contour of the generated walls. */ const Polygons& getInnerContour(); /*! * Removes empty paths from the toolpaths * \param toolpaths the VariableWidthPaths generated with \p generate() * \return true if there are still paths left. If all toolpaths were removed it returns false */ static bool removeEmptyToolPaths(std::vector &toolpaths); /*! * Get the order constraints of the insets when printing walls per region / hole. * Each returned pair consists of adjacent wall lines where the left has an inset_idx one lower than the right. * * Odd walls should always go after their enclosing wall polygons. * * \param outer_to_inner Whether the wall polygons with a lower inset_idx should go before those with a higher one. */ static std::unordered_set, boost::hash>> getRegionOrder(const std::vector &input, bool outer_to_inner); protected: /*! * Stitch the polylines together and form closed polygons. * * Works on both toolpaths and inner contours simultaneously. */ static void stitchToolPaths(std::vector &toolpaths, coord_t bead_width_x); /*! * Remove polylines shorter than half the smallest line width along that polyline. */ static void removeSmallLines(std::vector &toolpaths); /*! * Simplifies the variable-width toolpaths by calling the simplify on every line in the toolpath using the provided * settings. * \param settings The settings as provided by the user * \return */ static void simplifyToolPaths(std::vector &toolpaths); private: const Polygons& outline; // toolpaths; //