Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into optimized-prime-tower
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 8, 2023
2 parents a1b3e66 + 0c3e9d0 commit 92f0ec2
Show file tree
Hide file tree
Showing 18 changed files with 430 additions and 219 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CuraEngineConan(ConanFile):

def set_version(self):
if not self.version:
self.version = "5.6.0-alpha"
self.version = "5.6.0-beta.1"

def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
Expand Down
11 changes: 9 additions & 2 deletions include/FffGcodeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "settings/PathConfigStorage.h" //For the MeshPathConfigs subclass.
#include "utils/ExtrusionLine.h" //Processing variable-width paths.
#include "utils/NoCopy.h"
#include "utils/gettime.h"

namespace cura
{
Expand All @@ -26,7 +27,6 @@ class SliceDataStorage;
class SliceMeshStorage;
class SliceLayer;
class SliceLayerPart;
class TimeKeeper;

/*!
* Secondary stage in Fused Filament Fabrication processing: The generated polygons are used in the gcode generation.
Expand Down Expand Up @@ -140,6 +140,13 @@ class FffGcodeWriter : public NoCopy
void writeGCode(SliceDataStorage& storage, TimeKeeper& timeKeeper);

private:
struct ProcessLayerResult
{
LayerPlan* layer_plan;
double total_elapsed_time;
TimeKeeper::RegisteredTimes stages_times;
};

/*!
* \brief Set the FffGcodeWriter::fan_speed_layer_time_settings by
* retrieving all settings from the global/per-meshgroup settings.
Expand Down Expand Up @@ -211,7 +218,7 @@ class FffGcodeWriter : public NoCopy
* \param total_layers The total number of layers.
* \return The layer plans
*/
LayerPlan& processLayer(const SliceDataStorage& storage, LayerIndex layer_nr, const size_t total_layers) const;
ProcessLayerResult processLayer(const SliceDataStorage& storage, LayerIndex layer_nr, const size_t total_layers) const;

/*!
* This function checks whether prime blob should happen for any extruder on the first layer.
Expand Down
7 changes: 3 additions & 4 deletions include/LayerPlanBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#ifndef LAYER_PLAN_BUFFER_H
#define LAYER_PLAN_BUFFER_H

#include <list>
#include <vector>

#include "ExtruderPlan.h"
#include "LayerPlan.h"
#include "Preheat.h"
#include "gcodeExport.h"
#include "settings/Settings.h"
#include "settings/types/Duration.h"

#include <list>
#include <vector>

namespace cura
{

Expand All @@ -36,7 +36,6 @@ class GCodeExport;
class LayerPlanBuffer
{
friend class LayerPlan;
friend class LayerPlanBuffer;
GCodeExport& gcode;

Preheat preheat_config; //!< the nozzle and material temperature settings for each extruder train.
Expand Down
35 changes: 32 additions & 3 deletions include/PrimeTower.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,46 @@ class PrimeTower
*/
void addToGcode_denseInfill(LayerPlan& gcode_layer, const size_t extruder) const;

/*!
* \brief Add path plans for the prime tower extra outer rings to make the stronger base
* \param gcode_layer The gcode export to add the paths plans to
* \param extruder_nr The current extruder number
* \return True if something has actually been added, according to the extruder number
* and current layer.
*/
bool addToGcode_base(LayerPlan& gcode_layer, const size_t extruder_nr) const;

/*!
* \brief Add path plans for the prime tower extra inner rings to increase bed adhesion
* \param gcode_layer The gcode export to add the paths plans to
* \param extruder_nr The current extruder number
* \return True if something has actually been added, according to the extruder number
* and current layer.
*/
bool addToGcode_inset(LayerPlan& gcode_layer, const size_t extruder_nr) const;

#warning TBD documentation
void addToGcode_optimizedInfill(LayerPlan& gcode_layer, const std::vector<size_t>& extruders_to_prime_idx, const size_t current_extruder_nr) const;
/*!
* \brief Add path plans in the case an extruder is not to be actually primed, but we still
* want to print something to make the prime tower consistent.
* \param gcode_layer The gcode export to add the paths plans to
* \param extruders_to_prime_idx The indexes of the extra extruders which also don't require being primed on this layer
* \param current_extruder_nr The extruder currently being used
*/
void addToGcode_sparseInfill(LayerPlan& gcode_layer, const std::vector<size_t>& extruders_to_prime_idx, const size_t current_extruder_nr) const;

/*!
* \brief Find the list of extruders that don't actually need to be primed during this layer, and for which
* we want to print only the sparse infill to keep the prime tower consistent.
* \param gcode_layer The current gcode export
* \param required_extruder_prime The pre-computed list of extruders uses during this layer
* \param method The current prime tower strategy
* \param initial_list_idx A list potentially containing extruders that we already know can be used for
* sparse infill
* \return The indexes of extruders to be used for sparse infill
*/
std::vector<size_t> findExtrudersSparseInfill(
LayerPlan& gcode_layer,
const std::vector<ExtruderUse>& required_extruder_prime,
const size_t current_extruder_nr,
cura::PrimeTowerMethod method,
const std::vector<size_t>& initial_list_idx = {}) const;

Expand Down
76 changes: 53 additions & 23 deletions include/progress/Progress.h
Original file line number Diff line number Diff line change
@@ -1,72 +1,102 @@
//Copyright (c) 2018 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2023 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#ifndef PROGRESS_H
#define PROGRESS_H

#include <array>
#include <optional>
#include <string>
#include <string_view>

#include "utils/gettime.h"

namespace cura
{

class TimeKeeper;
struct LayerIndex;

#define N_PROGRESS_STAGES 7
static constexpr size_t N_PROGRESS_STAGES = 7;

/*!
* Class for handling the progress bar and the progress logging.
*
*
* The progress bar is based on a single slicing of a rather large model which needs some complex support;
* the relative timing of each stage is currently based on that of the slicing of dragon_65_tilted_large.stl
*/
class Progress
class Progress
{
public:
/*!
* The stage in the whole slicing process
* The stage in the whole slicing process
*/
enum class Stage : unsigned int
{
START = 0,
SLICING = 1,
PARTS = 2,
INSET_SKIN = 3,
SUPPORT = 4,
EXPORT = 5,
FINISH = 6
START = 0,
SLICING = 1,
PARTS = 2,
INSET_SKIN = 3,
SUPPORT = 4,
EXPORT = 5,
FINISH = 6
};

private:
static double times [N_PROGRESS_STAGES]; //!< Time estimates per stage
static std::string names[N_PROGRESS_STAGES]; //!< name of each stage
static double accumulated_times [N_PROGRESS_STAGES]; //!< Time past before each stage
static constexpr std::array<double, N_PROGRESS_STAGES> times{
0.0, // START = 0,
5.269, // SLICING = 1,
1.533, // PARTS = 2,
71.811, // INSET_SKIN = 3
51.009, // SUPPORT = 4,
154.62, // EXPORT = 5,
0.1 // FINISH = 6
};

static constexpr std::array<std::string_view, N_PROGRESS_STAGES> names{ "start", "slice", "layerparts", "inset+skin", "support", "export", "process" };
static std::array<double, N_PROGRESS_STAGES> accumulated_times; //!< Time past before each stage
static double total_timing; //!< An estimate of the total time
static std::optional<LayerIndex> first_skipped_layer; //!< The index of the layer for which we skipped time reporting
/*!
* Give an estimate between 0 and 1 of how far the process is.
*
*
* \param stage The current stage of processing
* \param stage_process How far we currently are in the \p stage
* \return An estimate of the overall progress.
*/
static float calcOverallProgress(Stage stage, float stage_progress);
static double calcOverallProgress(Stage stage, double stage_progress);

public:
static void init(); //!< Initialize some values needed in a fast computation of the progress
/*!
* Message progress over the CommandSocket and to the terminal (if the command line arg '-p' is provided).
*
*
* \param stage The current stage of processing
* \param progress_in_stage Any number giving the progress within the stage
* \param progress_in_stage_max The maximal value of \p progress_in_stage
*/
static void messageProgress(Stage stage, int progress_in_stage, int progress_in_stage_max);

/*!
* Message the progress stage over the command socket.
*
*
* \param stage The current stage
* \param timeKeeper The stapwatch keeping track of the timings for each stage (optional)
*/
static void messageProgressStage(Stage stage, TimeKeeper* timeKeeper);

/*!
* Message the layer progress over the command socket and into logging output.
*
* \param layer_nr The processed layer number
* \param total_layers The total number of layers to be processed
* \param total_time The total layer processing time, in seconds
* \param stage The detailed stages time reporting for this layer
* \param skip_threshold The time threshold under which we consider that the full layer time reporting should be skipped
* because it is not relevant
*/
static void messageProgressLayer(LayerIndex layer_nr, size_t total_layers, double total_time, const TimeKeeper::RegisteredTimes& stages, double skip_threshold = 0.1);
};


} // name space cura
#endif//PROGRESS_H
} // namespace cura
#endif // PROGRESS_H
44 changes: 24 additions & 20 deletions include/utils/SVG.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Copyright (c) 2022 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2022 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef SVG_H
#define SVG_H
Expand All @@ -19,7 +19,8 @@ class FPoint3;
class SVG : NoCopy
{
public:
enum class Color {
enum class Color
{
BLACK,
WHITE,
GRAY,
Expand All @@ -40,18 +41,20 @@ class SVG : NoCopy
Color color;
int r, g, b;
ColorObject(Color color)
: is_enum(true)
, color(color)
{}
: is_enum(true)
, color(color)
{
}
ColorObject(int r, int g, int b)
: is_enum(false)
, r(r)
, g(g)
, b(b)
{}
: is_enum(false)
, r(r)
, g(g)
, b(b)
{
}
};
private:

private:
std::string toString(const Color color) const;
std::string toString(const ColorObject& color) const;

Expand All @@ -65,6 +68,8 @@ class SVG : NoCopy

bool output_is_html;

void writePathPoint(const Point& p) const;

public:
SVG(std::string filename, const AABB aabb, const Point canvas_size = Point(1024, 1024), const ColorObject background = Color::NONE);
SVG(std::string filename, const AABB aabb, const double scale, const ColorObject background = Color::NONE);
Expand Down Expand Up @@ -103,10 +108,10 @@ class SVG : NoCopy

/*!
* \brief Draws a polyline on the canvas.
*
*
* The polyline is the set of line segments between each pair of consecutive
* points in the specified vector.
*
*
* \param polyline A set of points between which line segments must be
* drawn.
* \param color The colour of the line segments. If this is not specified,
Expand All @@ -122,23 +127,23 @@ class SVG : NoCopy

/*!
* \brief Draws a dashed line on the canvas from point A to point B.
*
*
* This is useful in the case where multiple lines may overlap each other.
*
*
* \param a The starting endpoint of the line.
* \param b The ending endpoint of the line.
* \param color The stroke colour of the line.
*/
void writeDashedLine(const Point& a,const Point& b, ColorObject color = Color::BLACK) const;
void writeDashedLine(const Point& a, const Point& b, ColorObject color = Color::BLACK) const;

template<typename... Args>
void printf(const char* txt, Args&&... args) const;

void writeText(const Point& p, const std::string& txt, const ColorObject color = Color::BLACK, const float font_size = 10) const;

void writePolygons(const Polygons& polys, const ColorObject color = Color::BLACK, const float stroke_width = 1) const;
void writePolygons(const Polygons& polys, const ColorObject color = Color::BLACK, const float stroke_width = 1, bool as_path = false) const;

void writePolygon(ConstPolygonRef poly, const ColorObject color = Color::BLACK, const float stroke_width = 1) const;
void writePolygon(ConstPolygonRef poly, const ColorObject color = Color::BLACK, const float stroke_width = 1, bool as_path = false) const;

void writePolylines(const Polygons& polys, const ColorObject color = Color::BLACK, const float stroke_width = 1) const;

Expand Down Expand Up @@ -187,7 +192,6 @@ class SVG : NoCopy
* \param font_size The size of the font to write the coordinates with.
*/
void writeCoordinateGrid(const coord_t grid_size = MM2INT(1), const Color color = Color::BLACK, const float stroke_width = 0.1, const float font_size = 10) const;

};

template<typename... Args>
Expand Down
Loading

0 comments on commit 92f0ec2

Please sign in to comment.