Skip to content

Commit

Permalink
Merge branch 'main' into fix-wall-ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
casperlamboo committed Jan 10, 2024
2 parents ddc10eb + f31b2c6 commit 71fd2ab
Show file tree
Hide file tree
Showing 82 changed files with 618 additions and 286 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ jobs:
output_file_path: "build/Release/benchmark_result.json"
data_dir: "dev/bench"
tool: "googlecpp"
alert_threshold: "125%"
alert_comment_cc_users: "@nallath, @jellespijker, @wawanbreton, @casperlamboo, @saumyaj3, @HellAholic"
secrets: inherit
10 changes: 9 additions & 1 deletion .github/workflows/gcodeanalyzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
run: |
for file in `ls ../NightlyTestModels/*.stl`;
do
./build/Release/CuraEngine slice --force-read-parent --force-read-nondefault -v -p -j ../Cura/resources/definitions/ultimaker_s3.def.json -l $file -o ../`basename $file .stl`.gcode
( time ./build/Release/CuraEngine slice --force-read-parent --force-read-nondefault -v -p -j ../Cura/resources/definitions/ultimaker_s3.def.json -l $file -o ../`basename $file .stl`.gcode ) 2> $file.time
done
working-directory: CuraEngine

Expand All @@ -190,6 +190,7 @@ jobs:
import sys
import os
import json
import re
from Charon.filetypes.GCodeFile import GCodeFile
sys.path.append(".")
Expand All @@ -204,6 +205,8 @@ jobs:
if ext.lower() != ".gcode":
continue
infilename = os.path.join(folder_path, filename)
with open(infilename + ".time", "r") as f:
timer = float(re.match(r"^.*?cpu (\d+\.\d+)", f.read())[1])
frame = GCodeAnalyzer.DataFrame(infilename)
Expand Down Expand Up @@ -291,6 +294,11 @@ jobs:
"unit": "Celcius",
"value": temperatures["50%"],
},
{
"name": f"Slicing time {basename}",
"unit": "s",
"value": timer,
},
]
with open("../output.json", "w") as outfile:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-test-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ jobs:
with:
event: ${{ github.event.workflow_run.event }}
conclusion: ${{ github.event.workflow_run.conclusion }}
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ jobs:
unit_test_cmd: 'ctest --output-junit engine_test.xml'
unit_test_dir: 'build/Release'
build: true
secrets: inherit

3 changes: 2 additions & 1 deletion include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "pathPlanning/GCodePath.h"
#include "pathPlanning/NozzleTempInsert.h"
#include "pathPlanning/TimeMaterialEstimates.h"
#include "raft.h"
#include "settings/PathConfigStorage.h"
#include "settings/types/LayerIndex.h"
#include "utils/ExtrusionJunction.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ class LayerPlan : public NoCopy
const SliceDataStorage& storage_; //!< The polygon data obtained from FffPolygonProcessor
const LayerIndex layer_nr_; //!< The layer number of this layer plan
const bool is_initial_layer_; //!< Whether this is the first layer (which might be raft)
const bool is_raft_layer_; //!< Whether this is a layer which is part of the raft
const Raft::LayerType layer_type_; //!< Which part of the raft, airgap or model this layer is.
coord_t layer_thickness_;

std::vector<Point2LL> layer_start_pos_per_extruder_; //!< The starting position of a layer for each extruder
Expand Down
6 changes: 0 additions & 6 deletions include/TreeSupportSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct TreeSupportSettings
, xy_min_distance(support_overrides == SupportDistPriority::Z_OVERRIDES_XY ? mesh_group_settings.get<coord_t>("support_xy_distance_overhang") : xy_distance)
, z_distance_top_layers(round_up_divide(mesh_group_settings.get<coord_t>("support_top_distance"), layer_height))
, z_distance_bottom_layers(round_up_divide(mesh_group_settings.get<coord_t>("support_bottom_distance"), layer_height))
, performance_interface_skip_layers(round_up_divide(mesh_group_settings.get<coord_t>("support_interface_skip_height"), layer_height))
, support_infill_angles(mesh_group_settings.get<std::vector<AngleDegrees>>("support_infill_angles"))
, support_roof_angles(mesh_group_settings.get<std::vector<AngleDegrees>>("support_roof_angles"))
, roof_pattern(mesh_group_settings.get<EFillMethod>("support_roof_pattern"))
Expand Down Expand Up @@ -268,11 +267,6 @@ struct TreeSupportSettings
*/
size_t z_distance_bottom_layers;

/*!
* \brief used for performance optimization at the support floor. Should have no impact on the resulting tree.
*/
size_t performance_interface_skip_layers;

/*!
* \brief User specified angles for the support infill.
*/
Expand Down
28 changes: 22 additions & 6 deletions include/raft.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//Copyright (c) 2018 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2018 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef RAFT_H
#define RAFT_H

#include "settings/types/LayerIndex.h"
#include "utils/Coord_t.h"

namespace cura
Expand All @@ -29,7 +30,7 @@ class Raft
/*!
* \brief Get the amount of layers to fill the airgap and initial layer with
* helper parts (support, prime tower, etc.).
*
*
* The initial layer gets a separate filler layer because we don't want to
* apply the layer_0_z_overlap to it.
*/
Expand All @@ -49,13 +50,28 @@ class Raft
/*!
* \brief Get the total amount of extra layers below zero because there is a
* raft.
*
*
* This includes the filler layers which are introduced in the air gap.
*/
static size_t getTotalExtraLayers();

enum LayerType
{
RaftBase,
RaftInterface,
RaftSurface,
Airgap,
Model
};

/*!
* \brief Get the type of layer at the given layer index.
* \param layer_index The layer index to get the type of.
* \return The type of layer at the given layer index.
*/
static LayerType getLayerType(LayerIndex layer_index);
};

}//namespace cura
} // namespace cura

#endif//RAFT_H
#endif // RAFT_H
6 changes: 5 additions & 1 deletion include/sliceDataStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ class SliceDataStorage : public NoCopy

std::vector<SkirtBrimLine> skirt_brim[MAX_EXTRUDERS]; //!< Skirt/brim polygons per extruder, ordered from inner to outer polygons.
Polygons support_brim; //!< brim lines for support, going from the edge of the support inward. \note Not ordered by inset.
Polygons raftOutline; // Storage for the outline of the raft. Will be filled with lines when the GCode is generated.

// Storage for the outline of the raft-parts. Will be filled with lines when the GCode is generated.
Polygons raftBaseOutline;
Polygons raftInterfaceOutline;
Polygons raftSurfaceOutline;

int max_print_height_second_to_last_extruder; //!< Used in multi-extrusion: the layer number beyond which all models are printed with the same extruder
std::vector<int> max_print_height_per_extruder; //!< For each extruder the highest layer number at which it is used.
Expand Down
6 changes: 3 additions & 3 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
};

std::vector<ParameterizedRaftPath> raft_outline_paths;
raft_outline_paths.emplace_back(ParameterizedRaftPath{ line_spacing, storage.raftOutline });
raft_outline_paths.emplace_back(ParameterizedRaftPath{ line_spacing, storage.raftBaseOutline });
if (storage.primeTower.enabled_)
{
const Polygons& raft_outline_prime_tower = storage.primeTower.getOuterPoly(layer_nr);
Expand Down Expand Up @@ -761,7 +761,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
Polygons raft_outline_path;
const coord_t small_offset = gcode_layer.configs_storage_.raft_interface_config.getLineWidth()
/ 2; // Do this manually because of micron-movement created in corners when insetting a polygon that was offset with round joint type.
raft_outline_path = storage.raftOutline.offset(-small_offset);
raft_outline_path = storage.raftInterfaceOutline.offset(-small_offset);
raft_outline_path = Simplify(interface_settings).polygon(raft_outline_path); // Remove those micron-movements.
const coord_t infill_outline_width = gcode_layer.configs_storage_.raft_interface_config.getLineWidth();
Polygons raft_lines;
Expand Down Expand Up @@ -903,7 +903,7 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
Polygons raft_outline_path;
const coord_t small_offset = gcode_layer.configs_storage_.raft_interface_config.getLineWidth()
/ 2; // Do this manually because of micron-movement created in corners when insetting a polygon that was offset with round joint type.
raft_outline_path = storage.raftOutline.offset(-small_offset);
raft_outline_path = storage.raftSurfaceOutline.offset(-small_offset);
raft_outline_path = Simplify(interface_settings).polygon(raft_outline_path); // Remove those micron-movements.
const coord_t infill_outline_width = gcode_layer.configs_storage_.raft_surface_config.getLineWidth();
Polygons raft_lines;
Expand Down
33 changes: 25 additions & 8 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ LayerPlan::LayerPlan(
, storage_(storage)
, layer_nr_(layer_nr)
, is_initial_layer_(layer_nr == 0 - static_cast<LayerIndex>(Raft::getTotalExtraLayers()))
, is_raft_layer_(layer_nr < 0 - static_cast<LayerIndex>(Raft::getFillerLayerCount()))
, layer_type_(Raft::getLayerType(layer_nr))
, layer_thickness_(layer_thickness)
, has_prime_tower_planned_per_extruder_(Application::getInstance().current_slice_->scene.extruders.size(), false)
, current_mesh_(nullptr)
Expand Down Expand Up @@ -124,11 +124,12 @@ LayerPlan::LayerPlan(
layer_start_pos_per_extruder_.emplace_back(extruder.settings_.get<coord_t>("layer_start_x"), extruder.settings_.get<coord_t>("layer_start_y"));
}
extruder_plans_.reserve(Application::getInstance().current_slice_->scene.extruders.size());
const auto is_raft_layer = layer_type_ == Raft::LayerType::RaftBase || layer_type_ == Raft::LayerType::RaftInterface || layer_type_ == Raft::LayerType::RaftSurface;
extruder_plans_.emplace_back(
current_extruder,
layer_nr,
is_initial_layer_,
is_raft_layer_,
is_raft_layer,
layer_thickness,
fan_speed_layer_time_settings_per_extruder[current_extruder],
storage.retraction_wipe_config_per_extruder[current_extruder].retraction_config);
Expand Down Expand Up @@ -156,12 +157,25 @@ Polygons LayerPlan::computeCombBoundary(const CombBoundary boundary_type)
const CombingMode mesh_combing_mode = Application::getInstance().current_slice_->scene.current_mesh_group->settings.get<CombingMode>("retraction_combing");
if (mesh_combing_mode != CombingMode::OFF && (layer_nr_ >= 0 || mesh_combing_mode != CombingMode::NO_SKIN))
{
if (layer_nr_ < 0)
{
comb_boundary = storage_.raftOutline.offset(MM2INT(0.1));
}
else
switch (layer_type_)
{
case Raft::LayerType::RaftBase:
comb_boundary = storage_.raftBaseOutline.offset(MM2INT(0.1));
break;

case Raft::LayerType::RaftInterface:
comb_boundary = storage_.raftInterfaceOutline.offset(MM2INT(0.1));
break;

case Raft::LayerType::RaftSurface:
comb_boundary = storage_.raftSurfaceOutline.offset(MM2INT(0.1));
break;

case Raft::LayerType::Airgap:
// do nothing for airgap
break;

case Raft::LayerType::Model:
for (const std::shared_ptr<SliceMeshStorage>& mesh_ptr : storage_.meshes)
{
const auto& mesh = *mesh_ptr;
Expand Down Expand Up @@ -216,6 +230,7 @@ Polygons LayerPlan::computeCombBoundary(const CombBoundary boundary_type)
}
}
}
break;
}
}
return comb_boundary;
Expand Down Expand Up @@ -255,11 +270,13 @@ bool LayerPlan::setExtruder(const size_t extruder_nr)
{ // first extruder plan in a layer might be empty, cause it is made with the last extruder planned in the previous layer
extruder_plans_.back().extruder_nr_ = extruder_nr;
}

const auto is_raft_layer = layer_type_ == Raft::LayerType::RaftBase || layer_type_ == Raft::LayerType::RaftInterface || layer_type_ == Raft::LayerType::RaftSurface;
extruder_plans_.emplace_back(
extruder_nr,
layer_nr_,
is_initial_layer_,
is_raft_layer_,
is_raft_layer,
layer_thickness_,
fan_speed_layer_time_settings_per_extruder_[extruder_nr],
storage_.retraction_wipe_config_per_extruder[extruder_nr].retraction_config);
Expand Down
9 changes: 2 additions & 7 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ TreeSupport::TreeSupport(const SliceDataStorage& storage)
{
added = true;
grouped_mesh.second.emplace_back(mesh_idx);
// Handle some settings that are only used for performance reasons. This ensures that a horrible set setting intended to improve performance can not reduce it
// drastically.
grouped_mesh.first.performance_interface_skip_layers
= std::min(grouped_mesh.first.performance_interface_skip_layers, next_settings.performance_interface_skip_layers);
}
}
if (! added)
Expand Down Expand Up @@ -2206,16 +2202,15 @@ void TreeSupport::finalizeInterfaceAndSupportAreas(std::vector<Polygons>& suppor
size_t layers_below = 0;
while (layers_below <= config.support_bottom_layers)
{
// One sample at 0 layers below, another at config.support_bottom_layers. In-between samples at config.performance_interface_skip_layers distance from each
// other.
// One sample at 0 layers below, another at config.support_bottom_layers. In-between samples at 1-layer distance from each other.
const size_t sample_layer
= static_cast<size_t>(std::max(0, (static_cast<int>(layer_idx) - static_cast<int>(layers_below)) - static_cast<int>(config.z_distance_bottom_layers)));
constexpr bool no_support = false;
constexpr bool no_prime_tower = false;
floor_layer.add(layer_outset.intersection(storage.getLayerOutlines(sample_layer, no_support, no_prime_tower)));
if (layers_below < config.support_bottom_layers)
{
layers_below = std::min(layers_below + config.performance_interface_skip_layers, config.support_bottom_layers);
layers_below = std::min(layers_below + 1UL, config.support_bottom_layers);
}
else
{
Expand Down
Loading

0 comments on commit 71fd2ab

Please sign in to comment.