-
-
Notifications
You must be signed in to change notification settings - Fork 890
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51e8acd
commit 503c6d1
Showing
20 changed files
with
212 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2024 UltiMaker | ||
// CuraEngine is released under the terms of the AGPLv3 or higher | ||
|
||
#ifndef PATHEXPORTER_CONSUMPTIONESTIMATIONEXPORTER_H | ||
#define PATHEXPORTER_CONSUMPTIONESTIMATIONEXPORTER_H | ||
|
||
#include <map> | ||
#include <optional> | ||
|
||
#include "path_export/PathExporter.h" | ||
#include "settings/types/Duration.h" | ||
|
||
namespace cura | ||
{ | ||
|
||
class ConsumptionEstimationExporter : public PathExporter | ||
{ | ||
public: | ||
const std::map<PrintFeatureType, Duration>& getDurations() const; | ||
|
||
const std::map<size_t, double>& getExtrusionAmounts() const; | ||
|
||
void writeExtrusion( | ||
const Point3LL& p, | ||
const Velocity& speed, | ||
const size_t extruder_nr, | ||
const double extrusion_mm3_per_mm, | ||
const coord_t line_width, | ||
const coord_t line_thickness, | ||
const PrintFeatureType feature, | ||
const bool update_extrusion_offset) override; | ||
|
||
void writeTravelMove(const Point3LL& position, const Velocity& speed, const PrintFeatureType feature) override; | ||
|
||
void writeLayerEnd(const LayerIndex& layer_index, const coord_t z, const coord_t layer_thickness) override; | ||
|
||
void writeLayerStart(const LayerIndex& layer_index, const Point3LL& start_position) override; | ||
|
||
private: | ||
std::optional<double> getDistanceToLastPosition(const Point3LL& p) const; | ||
|
||
void addDuration(const std::optional<double>& distance, const Velocity& speed, PrintFeatureType feature); | ||
|
||
private: | ||
std::map<PrintFeatureType, Duration> durations_; | ||
std::map<size_t, double> extrusions_amounts_; | ||
std::optional<Point3LL> last_position_; | ||
}; | ||
|
||
} // namespace cura | ||
|
||
#endif // PATHEXPORTER_CONSUMPTIONESTIMATIONEXPORTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright (c) 2024 UltiMaker | ||
// CuraEngine is released under the terms of the AGPLv3 or higher | ||
|
||
#include "path_export/ConsumptionEstimationExporter.h" | ||
|
||
#include <settings/types/Velocity.h> | ||
|
||
namespace cura | ||
{ | ||
|
||
const std::map<PrintFeatureType, Duration>& ConsumptionEstimationExporter::getDurations() const | ||
{ | ||
return durations_; | ||
} | ||
|
||
const std::map<size_t, double>& ConsumptionEstimationExporter::getExtrusionAmounts() const | ||
{ | ||
return extrusions_amounts_; | ||
} | ||
|
||
void ConsumptionEstimationExporter::writeExtrusion( | ||
const Point3LL& p, | ||
const Velocity& speed, | ||
const size_t extruder_nr, | ||
const double extrusion_mm3_per_mm, | ||
const coord_t /*line_width*/, | ||
const coord_t /*line_thickness*/, | ||
const PrintFeatureType feature, | ||
const bool /*update_extrusion_offset*/) | ||
{ | ||
std::optional<double> distance = getDistanceToLastPosition(p); | ||
addDuration(distance, speed, feature); | ||
|
||
if (distance.has_value()) [[likely]] | ||
{ | ||
double extrusion_amount = distance.value() * extrusion_mm3_per_mm; | ||
|
||
if (auto iterator = extrusions_amounts_.find(extruder_nr); iterator != extrusions_amounts_.end()) [[likely]] | ||
{ | ||
iterator->second += extrusion_amount; | ||
} | ||
else | ||
{ | ||
extrusions_amounts_.insert({ extruder_nr, extrusion_amount }); | ||
} | ||
} | ||
|
||
last_position_ = p; | ||
} | ||
|
||
void ConsumptionEstimationExporter::writeTravelMove(const Point3LL& position, const Velocity& speed, const PrintFeatureType feature) | ||
{ | ||
std::optional<double> distance = getDistanceToLastPosition(position); | ||
addDuration(distance, speed, feature); | ||
|
||
last_position_ = position; | ||
} | ||
|
||
void ConsumptionEstimationExporter::writeLayerEnd(const LayerIndex& /*layer_index*/, const coord_t /*z*/, const coord_t /*layer_thickness*/) | ||
{ | ||
} | ||
|
||
void ConsumptionEstimationExporter::writeLayerStart(const LayerIndex& /*layer_index*/, const Point3LL& /*start_position*/) | ||
{ | ||
} | ||
std::optional<double> ConsumptionEstimationExporter::getDistanceToLastPosition(const Point3LL& p) const | ||
{ | ||
if (last_position_.has_value()) [[likely]] | ||
{ | ||
return (p - last_position_.value()).vSizeMM(); | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
|
||
void ConsumptionEstimationExporter::addDuration(const std::optional<double>& distance, const Velocity& speed, PrintFeatureType feature) | ||
{ | ||
if (distance.has_value()) [[likely]] | ||
{ | ||
const Duration duration = distance.value() / speed; | ||
|
||
if (auto iterator = durations_.find(feature); iterator != durations_.end()) | ||
{ | ||
iterator->second += duration; | ||
} | ||
else | ||
{ | ||
durations_.insert({ feature, duration }); | ||
} | ||
} | ||
} | ||
|
||
} // namespace cura |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.