Skip to content

Commit 3ccf945

Browse files
committed
Add infill generator
CURA-12250
1 parent 3b68765 commit 3ccf945

File tree

12 files changed

+678
-20
lines changed

12 files changed

+678
-20
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set(engine_SRCS # Except main.cpp.
9999

100100
src/feature_generation/FeatureGenerator.cpp include/feature_generation/FeatureGenerator.h
101101
src/feature_generation/MeshFeatureGenerator.cpp include/feature_generation/MeshFeatureGenerator.h
102+
src/feature_generation/MeshInfillGenerator.cpp include/feature_generation/MeshInfillGenerator.h
102103
src/feature_generation/MeshInsetsGenerator.cpp include/feature_generation/MeshInsetsGenerator.h
103104
src/feature_generation/SkirtBrimAppender.cpp include/feature_generation/SkirtBrimAppender.h
104105

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2024 UltiMaker
2+
// CuraEngine is released under the terms of the AGPLv3 or higher
3+
4+
#pragma once
5+
6+
#include <utils/Coord_t.h>
7+
8+
#include "feature_generation/MeshFeatureGenerator.h"
9+
10+
namespace cura
11+
{
12+
13+
class Shape;
14+
15+
class MeshInfillGenerator : public MeshFeatureGenerator
16+
{
17+
public:
18+
explicit MeshInfillGenerator(const std::shared_ptr<SliceMeshStorage>& mesh);
19+
20+
bool isActive() const override;
21+
22+
protected:
23+
void generateFeatures(const SliceDataStorage& storage, const LayerPlanPtr& layer_plan, const std::vector<ExtruderPlanPtr>& extruder_plans, const SliceLayerPart& part)
24+
const override;
25+
26+
private:
27+
/*!
28+
* \brief Add thicker (multiple layers) sparse infill for a given part in a
29+
* layer plan.
30+
*
31+
* \param gcodeLayer The initial planning of the gcode of the layer.
32+
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
33+
* \param extruder_nr The extruder for which to print all features of the
34+
* mesh which should be printed with this extruder.
35+
* \param mesh_config The line config with which to print a print feature.
36+
* \param part The part for which to create gcode.
37+
* \return Whether this function added anything to the layer plan.
38+
*/
39+
void processMultiLayerInfill(const LayerPlanPtr& layer_plan, const ExtruderPlanPtr& extruder_plan, const SliceLayerPart& part) const;
40+
41+
/*!
42+
* \brief Add normal sparse infill for a given part in a layer.
43+
* \param gcodeLayer The initial planning of the gcode of the layer.
44+
* \param mesh The mesh for which to add to the layer plan \p gcodeLayer.
45+
* \param extruder_nr The extruder for which to print all features of the
46+
* mesh which should be printed with this extruder
47+
* \param mesh_config The line config with which to print a print feature.
48+
* \param part The part for which to create gcode.
49+
* \return Whether this function added anything to the layer plan.
50+
*/
51+
void processSingleLayerInfill(const SliceDataStorage& storage, const LayerPlanPtr& layer_plan, const ExtruderPlanPtr& extruder_plan, const SliceLayerPart& part) const;
52+
53+
bool
54+
partitionInfillBySkinAbove(Shape& infill_below_skin, Shape& infill_not_below_skin, const LayerPlanPtr& layer_plan, const SliceLayerPart& part, coord_t infill_line_width) const;
55+
56+
private:
57+
const coord_t infill_line_distance_;
58+
};
59+
60+
} // namespace cura

include/feature_generation/MeshInsetsGenerator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
namespace cura
99
{
1010

11-
class SliceLayerPart;
12-
1311
class MeshInsetsGenerator : public MeshFeatureGenerator
1412
{
1513
public:

include/geometry/ClosedPolyline.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ class ClosedPolyline : public Polyline
9393
return ! explicitely_closed_;
9494
}
9595

96+
/*! @see Polyline::isClosed() */
97+
[[nodiscard]] bool isClosed() const override
98+
{
99+
return true;
100+
}
101+
96102
/*! @see Polyline::addClosingSegment() */
97103
[[nodiscard]] size_t segmentsCount() const override;
98104

include/geometry/OpenPolyline.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ class OpenPolyline : public Polyline
7272
return false; // Definitely not
7373
}
7474

75+
/*! @see Polyline::isClosed() */
76+
[[nodiscard]] bool isClosed() const override
77+
{
78+
return false;
79+
}
80+
7581
/*! @see Polyline::segmentsCount() */
7682
[[nodiscard]] size_t segmentsCount() const override
7783
{

include/geometry/Polyline.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ class Polyline : public PointsSet
7474
*/
7575
[[nodiscard]] virtual bool hasClosingSegment() const = 0;
7676

77+
/*!
78+
* \brief Indicates whether this polyline represents a closed or an open line
79+
*/
80+
[[nodiscard]] virtual bool isClosed() const = 0;
81+
7782
/*!
7883
* \brief Gets the total number of "full" segments in the polyline. Calling this is also safe if
7984
* there are not enough points to make a valid polyline, so it can also be a good

include/print_operation/ContinuousExtruderMoveSequence.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
#pragma once
55

66
#include "geometry/Point3LL.h"
7+
#include "print_operation/ContinuousExtruderMoveSequencePtr.h"
78
#include "print_operation/PrintOperationSequence.h"
89

910
namespace cura
1011
{
11-
12+
struct ExtrusionLine;
13+
struct Velocity;
14+
struct ExtrusionJunction;
15+
class Polyline;
1216
class ExtruderMove;
1317
class SliceMeshStorage;
1418
class PlanExporter;
@@ -20,6 +24,10 @@ class ContinuousExtruderMoveSequence : public PrintOperationSequence
2024
public:
2125
explicit ContinuousExtruderMoveSequence(bool closed, const Point3LL& start_position = Point3LL());
2226

27+
static ContinuousExtruderMoveSequencePtr makeFrom(const ExtrusionLine& extrusion_line, const Velocity& speed);
28+
29+
static ContinuousExtruderMoveSequencePtr makeFrom(const Polyline& polyline, const coord_t line_width, const Velocity& speed);
30+
2331
void appendExtruderMove(const std::shared_ptr<ExtruderMove>& extruder_move);
2432

2533
std::optional<Point3LL> findStartPosition() const override;

include/print_operation/FeatureExtrusion.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66

77
#include "GCodePathConfig.h"
88
#include "print_operation/ContinuousExtruderMoveSequencePtr.h"
9+
#include "print_operation/FeatureExtrusionPtr.h"
910
#include "print_operation/PrintOperationSequence.h"
1011

1112
namespace cura
1213
{
1314

15+
class Shape;
16+
1417
class FeatureExtrusion : public PrintOperationSequence
1518
{
1619
public:

src/FffGcodeWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "bridge.h"
3030
#include "communication/Communication.h" //To send layer view data.
3131
#include "feature_generation/FeatureGenerator.h"
32+
#include "feature_generation/MeshInfillGenerator.h"
3233
#include "feature_generation/MeshInsetsGenerator.h"
3334
#include "geometry/LinesSet.h"
3435
#include "geometry/OpenPolyline.h"
@@ -194,6 +195,7 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
194195
for (const std::shared_ptr<SliceMeshStorage>& mesh : storage.meshes)
195196
{
196197
feature_generators_.push_back(std::make_shared<MeshInsetsGenerator>(mesh));
198+
feature_generators_.push_back(std::make_shared<MeshInfillGenerator>(mesh));
197199
}
198200

199201
// Filter out generators that are actually useless in this context. Not highly useful, but helps for debugging.

0 commit comments

Comments
 (0)