Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
53eadf0
Basically working sending full GCode at the end
wawanbreton Mar 23, 2026
03c1da2
Apply clang-format
wawanbreton Mar 23, 2026
a9f1f32
Resolve GCode templates at the end
wawanbreton Mar 24, 2026
434fcdd
Merge remote-tracking branch 'origin-um/main' into CURA-13049_process…
wawanbreton Mar 25, 2026
025b0eb
Calculate and replace end-of-print variables in engine
wawanbreton Mar 26, 2026
88fd672
Remove now-useless code
wawanbreton Mar 27, 2026
2be3b26
Calculate the initial extruder and print state on engine side
wawanbreton Mar 29, 2026
a38e53b
Remove warning since code is correct
wawanbreton Mar 30, 2026
ea9d876
Create the environments once and just add the local ones
wawanbreton Mar 31, 2026
9c4c88d
Multi-thread gcode parts resolving
wawanbreton Mar 31, 2026
5c34243
Update unit tests
wawanbreton Apr 2, 2026
7a401a9
Fix EmscriptenCommunication
wawanbreton Apr 2, 2026
c5b688c
Merge branch 'main' into CURA-13049_process-the-end-variable-replacem…
wawanbreton Apr 2, 2026
1c2e19b
Add documentation
wawanbreton Apr 2, 2026
317ad65
Fix crash when extruder is unused
wawanbreton Apr 3, 2026
fc4cbfd
Add first layer bounding box as GCode variable
wawanbreton Apr 3, 2026
d8fe46c
Calculate more accurate first layer bounding box
wawanbreton Apr 3, 2026
e53d0f9
Add list of used extruders as variable
wawanbreton Apr 3, 2026
6aa9f7c
Fix functions not being applied in formulas
wawanbreton Apr 8, 2026
82f9e4a
Add total print bounding box variable
wawanbreton Apr 8, 2026
b45f19f
Merge remote-tracking branch 'origin-um/main' into CURA-13049_process…
wawanbreton Apr 14, 2026
ecd268a
Merge remote-tracking branch 'origin/main' into CURA-13049_process-th…
wawanbreton Apr 16, 2026
0005a2d
Merge remote-tracking branch 'origin/main' into CURA-13049_process-th…
wawanbreton Apr 28, 2026
07d18e0
Apply clang-format
wawanbreton Apr 28, 2026
bed9dd8
Update unit tests
wawanbreton Apr 28, 2026
337babe
Polish documentation
wawanbreton Apr 28, 2026
bc55f7e
Remove now-useless header inclusion
wawanbreton Apr 28, 2026
da4b865
Add possibly missing headers
wawanbreton Apr 28, 2026
8de26ff
Fix Emscripten build
wawanbreton Apr 28, 2026
288faa5
Add defensive check
wawanbreton Apr 30, 2026
fa4dbbd
Use formulae engine from proper branch
wawanbreton Apr 30, 2026
fd4119e
Fix typo
wawanbreton Apr 30, 2026
7300d08
Add documentation
wawanbreton Apr 30, 2026
13f1704
Add documentation
wawanbreton Apr 30, 2026
58064fa
Merge branch 'main' into CURA-13049_process-the-end-variable-replacem…
HellAholic May 6, 2026
84a0b9e
(Try to) fix Windows build
wawanbreton May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ set(engine_SRCS # Except main.cpp.
src/FffGcodeWriter.cpp
src/FffPolygonGenerator.cpp
src/FffProcessor.cpp
src/gcodeExport.cpp
src/GCodePathConfig.cpp
src/GcodeTemplateResolver.cpp
src/infill.cpp
src/InfillOrderOptimizer.cpp
src/InsetOrderOptimizer.cpp
Expand All @@ -68,6 +66,7 @@ set(engine_SRCS # Except main.cpp.
src/PathAdapter.cpp
src/PathOrderMonotonic.cpp
src/Preheat.cpp
src/PrintInformation.cpp
src/PrimeTower/PrimeTower.cpp
src/PrimeTower/PrimeTowerNormal.cpp
src/PrimeTower/PrimeTowerInterleaved.cpp
Expand Down Expand Up @@ -116,6 +115,11 @@ set(engine_SRCS # Except main.cpp.
src/communication/EmscriptenCommunication.cpp
src/communication/Listener.cpp

src/gcode_export/gcodeExport.cpp
src/gcode_export/FixedGCodePart.cpp
src/gcode_export/ResolvedGCodePart.cpp
src/gcode_export/GcodeTemplateResolver.cpp

src/infill/AbstractLinesInfill.cpp
src/infill/ImageBasedDensityProvider.cpp
src/infill/NoZigZagConnectorProcessor.cpp
Expand Down
8 changes: 8 additions & 0 deletions Cura.proto
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ message PrintTimeMaterialEstimates { // The print time for each feature and mate
message MaterialEstimates {
int64 id = 1;
float material_amount = 2; // material used in the extruder
float material_length = 3; // Length if used filaments, in meters
float material_weight = 4; // Weight of used filament, in grams
float material_cost = 5;
string material_name = 6;
}

message InitialExtruder {
uint32 extruder_nr = 1;
}

message SettingList {
Expand Down
2 changes: 1 addition & 1 deletion conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "5.14.0-alpha.0"
commit: "unknown"
requirements:
- "cura-formulae-engine/1.0.0"
- "cura-formulae-engine/1.1.0"
- "scripta/[>=1.1.0]@ultimaker/testing"
- "libpng/1.6.48"
- "onetbb/2022.2.0"
Expand Down
13 changes: 12 additions & 1 deletion include/ExtruderPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "FanSpeedLayerTime.h"
#include "RetractionConfig.h"
#include "gcodeExport.h"
#include "gcode_export/gcodeExport.h"
#include "geometry/Point2LL.h"
#include "pathPlanning/GCodePath.h"
#include "pathPlanning/NozzleTempInsert.h"
Expand Down Expand Up @@ -131,6 +131,17 @@ class ExtruderPlan
*/
std::shared_ptr<const SliceMeshStorage> findFirstPrintedMesh() const;

/*! \brief Calculates whether this extruder plan actually has at least one extrusion move */
bool hasExtrusion() const;

/*!
* \brief Calculate the total bounding box of extrusion moves
* \note This is not 100% accurate since at this point we don't know the start position of the extruder plan. So if the very first
* move happens to be an extrusion move and the start position is the outermost of the bounding box, it will not be accounted
* for and the bounding box will be approximate.
*/
AABB calculateExtrusionBoundingBox() const;

private:
LayerIndex layer_nr_{ 0 }; //!< The layer number at which we are currently printing.
bool is_initial_layer_{ false }; //!< Whether this extruder plan is printed on the very first layer (which might be raft)
Expand Down
54 changes: 4 additions & 50 deletions include/FffGcodeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef GCODE_WRITER_H
#define GCODE_WRITER_H

#include <fstream>
#include <optional>

#include "ExtruderUse.h"
Expand All @@ -13,7 +12,8 @@
#include "LayerPlan.h"
#include "LayerPlanBuffer.h"
#include "LinesOrderingMethod.h"
#include "gcodeExport.h"
#include "PrintInformation.h"
#include "gcode_export/gcodeExport.h"
#include "utils/LayerVector.h"
#include "utils/NoCopy.h"
#include "utils/gettime.h"
Expand Down Expand Up @@ -61,11 +61,6 @@ class FffGcodeWriter : public NoCopy
*/
GCodeExport gcode;

/*!
* The gcode file to write to when using CuraEngine as command line tool.
*/
std::ofstream output_file;

//!< For each layer, the extruders to be used in that layer in the order in which they are going to be used
LayerVector<std::vector<ExtruderUse>> extruder_order_per_layer;

Expand All @@ -86,6 +81,8 @@ class FffGcodeWriter : public NoCopy

std::string slice_uuid; //!< The UUID of the current slice.

PrintInformation print_info_; //!< Global print information calculated along slicing

public:
/*
* \brief Construct a g-code writer.
Expand All @@ -95,49 +92,6 @@ class FffGcodeWriter : public NoCopy
*/
FffGcodeWriter();

/*!
* Set the target to write gcode to: to a file.
*
* Used when CuraEngine is used as command line tool.
*
* \param filename The filename of the file to which to write the gcode.
*/
bool setTargetFile(const char* filename);

/*!
* Set the target to write gcode to: an output stream.
*
* Used when CuraEngine is NOT used as command line tool.
*
* \param stream The stream to write gcode to.
*/
void setTargetStream(std::ostream* stream);

/*!
* Wether or not the extruder is actually used in the print, regardless of enablement.
*
* \param extruder_nr The extruder number for which to get the useage
* \return actual use y/n boolean
*/
bool getExtruderActualUse(int extruder_nr);

/*!
* Get the total extruded volume for a specific extruder in mm^3
*
* Retractions and unretractions don't contribute to this.
*
* \param extruder_nr The extruder number for which to get the total netto extruded volume
* \return total filament printed in mm^3
*/
double getTotalFilamentUsed(int extruder_nr);

/*!
* Get the total estimated print time in seconds for each feature
*
* \return total print time in seconds for each feature
*/
std::vector<Duration> getTotalPrintTimePerFeature();

/*!
* Write all the gcode for the current meshgroup.
* This is the primary function of this class.
Expand Down
43 changes: 0 additions & 43 deletions include/FffProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,49 +47,6 @@ class FffProcessor : public NoCopy
*/
TimeKeeper time_keeper; // TODO: use singleton time keeper

/*!
* Set the target to write gcode to: to a file.
*
* Used when CuraEngine is used as command line tool.
*
* \param filename The filename of the file to which to write the gcode.
*/
bool setTargetFile(const char* filename);

/*!
* Set the target to write gcode to: an output stream.
*
* Used when CuraEngine is NOT used as command line tool.
*
* \param stream The stream to write gcode to.
*/
void setTargetStream(std::ostream* stream);

/*!
* Wether or not the extruder is actually used in the print, regardless of enablement.
*
* \param extruder_nr The extruder number for which to get the useage
* \return actual use y/n boolean
*/
bool getExtruderActualUse(int extruder_nr);

/*!
* Get the total extruded volume for a specific extruder in mm^3
*
* Retractions and unretractions don't contribute to this.
*
* \param extruder_nr The extruder number for which to get the total netto extruded volume
* \return total filament printed in mm^3
*/
double getTotalFilamentUsed(int extruder_nr);

/*!
* Get the total estimated print time in seconds for each feature
*
* \return total print time in seconds for each feature
*/
std::vector<Duration> getTotalPrintTimePerFeature();

/*!
* Add the end gcode and set all temperatures to zero.
*/
Expand Down
31 changes: 0 additions & 31 deletions include/GcodeTemplateResolver.h

This file was deleted.

11 changes: 10 additions & 1 deletion include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "InsetOrderOptimizer.h"
#include "PathOrderOptimizer.h"
#include "SpaceFillType.h"
#include "gcodeExport.h"
#include "gcode_export/gcodeExport.h"
#include "geometry/LinesSet.h"
#include "geometry/MendedShape.h"
#include "geometry/Polygon.h"
Expand Down Expand Up @@ -917,6 +917,15 @@ class LayerPlan : public NoCopy
*/
std::shared_ptr<const SliceMeshStorage> findFirstPrintedMesh() const;

/*!
* \brief Find the first actually extruding extruder for this layer
* \return The first extruder actually extruding, or nullopt if there is no extrusion in this layer
*/
std::optional<size_t> findInitialExtruderNr() const;

/*! Calculate the actual extrusion bounding box in this layer */
AABB calculateExtrusionBoundingBox() const;

/*! Indicates whether this layer plan is empty, i.e. it has no extruder plan or they are all empty */
const bool empty() const;

Expand Down
40 changes: 40 additions & 0 deletions include/PrintInformation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2026 UltiMaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef PRINTINFORMATION_H
#define PRINTINFORMATION_H

#include <optional>
#include <string>
#include <vector>

#include "utils/AABB.h"

namespace cura
{

class LayerPlan;
class SliceDataStorage;

/*! \brief Contains the end-of-print info about used material for an extruder */
struct ExtruderPrintInformation
{
float filament_amount{}; // Material volume in mm3
float filament_length{}; // Filament length in m
float filament_weight{}; // Filament weight in grams
float filament_cost{}; // Filament cost (unspecified currency)
std::string material_name; // Material full name
};

struct PrintInformation
{
std::vector<std::optional<ExtruderPrintInformation>> extruders_info; // One per extruder, but no value if the extruder is unused
std::optional<size_t> initial_extruder_nr;
AABB initial_layer_bb;

void updateWithLayer(const LayerPlan* layer_plan);
};

} // namespace cura

#endif // PRINTINFORMATION_H
19 changes: 6 additions & 13 deletions include/communication/ArcusCommunication.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,8 @@ class ArcusCommunication : public Communication
*/
void connect(const std::string& ip, const uint16_t port);

/*
* \brief Indicate that we're beginning to send g-code.
*/
void beginGCode() override;

/*
* \brief Flush all g-code still in the stream into a message queued in the
* socket.
*/
void flushGCode() override;
/* \brief Sends a piece of GCode that is ready to be exported */
void sendGCodePart(const std::string& gcode_part) override;

/*
* \brief Indicates that for Arcus we don't need to send the g-code from
Expand Down Expand Up @@ -143,10 +135,11 @@ class ArcusCommunication : public Communication
void sendOptimizedLayerData() override;

/*
* \brief Send an estimate of how long the print would take and how much
* material it would use.
* \brief Send an estimate of how long the print would take and how much material it would use.
* \param time_estimates The calculated time estimations, per extruder
* \param print_information The calculated materials consumptions, per extruder
*/
void sendPrintTimeMaterialEstimates() const override;
void sendPrintInformation(const std::vector<cura::Duration>& time_estimates, const PrintInformation& print_information) const override;

/*
* \brief Communicate to Arcus what our progress is.
Expand Down
Loading
Loading