Initial port of Arachne from Cura.
This commit is contained in:
parent
4015a83acb
commit
556e2b71cc
51 changed files with 7833 additions and 5 deletions
130
src/libslic3r/Arachne/WallToolPaths.hpp
Normal file
130
src/libslic3r/Arachne/WallToolPaths.hpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
// 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 <memory>
|
||||
|
||||
#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<coord_t>(0.5);
|
||||
constexpr coord_t meshfix_maximum_deviation = scaled<coord_t>(0.025);
|
||||
constexpr coord_t meshfix_maximum_extrusion_area_deviation = scaled<coord_t>(2.);
|
||||
|
||||
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 nominal_bead_width The nominal bead width 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, const coord_t nominal_bead_width, const size_t inset_count, const coord_t wall_0_inset, const PrintConfig &print_config);
|
||||
|
||||
/*!
|
||||
* 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, const coord_t bead_width_0, const coord_t bead_width_x, const size_t inset_count, const coord_t wall_0_inset, const PrintConfig &print_config);
|
||||
|
||||
/*!
|
||||
* Generates the Toolpaths
|
||||
* \return A reference to the newly create ToolPaths
|
||||
*/
|
||||
const VariableWidthPaths& generate();
|
||||
|
||||
/*!
|
||||
* Gets the toolpaths, if this called before \p generate() it will first generate the Toolpaths
|
||||
* \return a reference to the toolpaths
|
||||
*/
|
||||
const VariableWidthPaths& getToolPaths();
|
||||
|
||||
BinJunctions getBinJunctions(std::set<size_t> &bins_with_index_zero_insets);
|
||||
|
||||
/*!
|
||||
* 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 computeInnerContour();
|
||||
|
||||
/*!
|
||||
* 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(VariableWidthPaths& toolpaths);
|
||||
|
||||
/*!
|
||||
* Stitches toolpaths together to form contours.
|
||||
*
|
||||
* All toolpaths are used. Paths that are not closed will get closed in the
|
||||
* output by virtue of becoming polygons. As such, the input is expected to
|
||||
* consist of almost completely closed contours, which may be split up into
|
||||
* different polylines.
|
||||
* This function combines those polylines into the polygons they are
|
||||
* probably intended to depict.
|
||||
* \param input The paths to stitch together.
|
||||
* \param stitch_distance Any endpoints closer than this distance can be
|
||||
* stitched together. An additional line segment will bridge the gap.
|
||||
* \param output Where to store the output polygons.
|
||||
*/
|
||||
static void stitchContours(const VariableWidthPaths& input, const coord_t stitch_distance, Polygons& output) ;
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* 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(VariableWidthPaths& toolpaths/*, const Settings& settings*/);
|
||||
|
||||
private:
|
||||
const Polygons& outline; //<! A reference to the outline polygon that is the designated area
|
||||
coord_t bead_width_0; //<! The nominal or first extrusion line width with which libArachne generates its walls
|
||||
coord_t bead_width_x; //<! The subsequently extrusion line width with which libArachne generates its walls if WallToolPaths was called with the nominal_bead_width Constructor this is the same as bead_width_0
|
||||
size_t inset_count; //<! The maximum number of walls to generate
|
||||
coord_t wall_0_inset; //<! How far to inset the outer wall. Should only be applied when printing the actual walls, not extra infill/skin/support walls.
|
||||
BeadingStrategyType strategy_type; //<! The wall generating strategy
|
||||
bool print_thin_walls; //<! Whether to enable the widening beading meta-strategy for thin features
|
||||
coord_t min_feature_size; //<! The minimum size of the features that can be widened by the widening beading meta-strategy. Features thinner than that will not be printed
|
||||
coord_t min_bead_width; //<! The minimum bead size to use when widening thin model features with the widening beading meta-strategy
|
||||
double small_area_length; //<! The length of the small features which are to be filtered out, this is squared into a surface
|
||||
bool toolpaths_generated; //<! Are the toolpaths generated
|
||||
VariableWidthPaths toolpaths; //<! The generated toolpaths
|
||||
Polygons inner_contour; //<! The inner contour of the generated toolpaths
|
||||
const PrintConfig &print_config;
|
||||
};
|
||||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
#endif // CURAENGINE_WALLTOOLPATHS_H
|
Loading…
Add table
Add a link
Reference in a new issue