Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into smaller-prime-tower
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Jun 25, 2024
2 parents d6813bc + f4abac6 commit d1bae90
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 47 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ target_compile_definitions(_CuraEngine
$<$<CONFIG:Debug>:ASSERT_INSANE_OUTPUT>
$<$<CONFIG:Debug>:USE_CPU_TIME>
$<$<CONFIG:Debug>:DEBUG>
$<$<CONFIG:RelWithDebInfo>:ASSERT_INSANE_OUTPUT>
$<$<CONFIG:RelWithDebInfo>:USE_CPU_TIME>
$<$<CONFIG:RelWithDebInfo>:DEBUG>
)

enable_sanitizers(_CuraEngine)
Expand Down
7 changes: 6 additions & 1 deletion include/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ class Application : NoCopy
#endif // ARCUS

/*!
* \brief Print the header and license to the stderr channel.
* \brief Print the header to the stderr channel.
*/
void printHeader() const;

/*!
* \brief Print the license to the stderr channel.
*/
void printLicense() const;

Expand Down
8 changes: 7 additions & 1 deletion include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class InsetOrderOptimizer
const size_t wall_x_extruder_nr,
const ZSeamConfig& z_seam_config,
const std::vector<VariableWidthLines>& paths,
const Point2LL& model_center_point,
const Shape& disallowed_areas_for_seams = {});

/*!
Expand Down Expand Up @@ -107,6 +108,7 @@ class InsetOrderOptimizer
const ZSeamConfig& z_seam_config_;
const std::vector<VariableWidthLines>& paths_;
const LayerIndex layer_nr_;
const Point2LL model_center_point_; // Center of the model (= all meshes) axis-aligned bounding-box.
Shape disallowed_areas_for_seams_;

std::vector<std::vector<const Polygon*>> inset_polys_; // vector of vectors holding the inset polygons
Expand All @@ -119,8 +121,12 @@ class InsetOrderOptimizer
* 'best' vertex on that polygon. Under certain circumstances, the seam-placing algorithm can
* however still deviate from this, for example when the seam-point placed here isn't suppored
* by the layer below.
*
* \param closed_line The polygon to insert the seam point in. (It's assumed to be closed at least.)
*
* \return The index of the inserted seam point, or std::nullopt if no seam point was inserted.
*/
void insertSeamPoint(ExtrusionLine& closed_line);
std::optional<size_t> insertSeamPoint(ExtrusionLine& closed_line);

/*!
* Determine if the paths should be reversed
Expand Down
9 changes: 8 additions & 1 deletion include/PathOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ class PathOrderOptimizer
* Add a new polygon to be optimized.
* \param polygon The polygon to optimize.
*/
void addPolygon(const Path& polygon)
void addPolygon(const Path& polygon, std::optional<size_t> force_start_index = std::nullopt)
{
constexpr bool is_closed = true;
paths_.emplace_back(polygon, is_closed);
paths_.back().force_start_index_ = force_start_index;
}

/*!
Expand Down Expand Up @@ -695,6 +696,12 @@ class PathOrderOptimizer
return vert;
}

if (path.force_start_index_.has_value())
{
// Start index already known, since we forced it, return.
return path.force_start_index_.value();
}

// Precompute segments lengths because we are going to need them multiple times
std::vector<coord_t> segments_sizes(path.converted_->size());
coord_t total_length = 0;
Expand Down
6 changes: 6 additions & 0 deletions include/path_ordering.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ struct PathOrdering
*/
bool backwards_;

/*!
* Force the start point of the path to be at a specific location.
* Will only happen if not empty, and this point is actually on the path.
*/
std::optional<size_t> force_start_index_;

/*!
* Get vertex data from the custom path type.
*
Expand Down
5 changes: 5 additions & 0 deletions include/sliceDataStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ class SliceDataStorage : public NoCopy
const int extruder_nr = -1,
const bool include_models = true) const;

/*!
* Get the axis-aligned bounding-box of the complete model (all meshes).
*/
AABB3D getModelBoundingBox() const;

/*!
* Get the extruders used.
*
Expand Down
15 changes: 15 additions & 0 deletions include/utils/linearAlg2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ class LinearAlg2D
return -1;
}

/*!
* A single-shot line-segment/line-segment intersection that returns the parameters and doesn't require a grid-calculation beforehand.
*
* \param p1 The start point of the first line segment.
* \param p2 The end point of the first line segment.
* \param p3 The start point of the second line segment.
* \param p4 The end point of the second line segment.
* \param t The parameter of the intersection on the first line segment (intersection = p1 + t * (p2 - p1)).
* \param u The parameter of the intersection on the second line segment (intersection = p3 + u * (p4 - p3)).
*
* \return Whether the two line segments intersect.
*/
static bool segmentSegmentIntersection(const Point2LL& p1, const Point2LL& p2, const Point2LL& p3, const Point2LL& p4, float& t, float& u);
static bool lineLineIntersection(const Point2LL& p1, const Point2LL& p2, const Point2LL& p3, const Point2LL& p4, float& t, float& u);

static bool lineLineIntersection(const Point2LL& a, const Point2LL& b, const Point2LL& c, const Point2LL& d, Point2LL& output);

/*!
Expand Down
42 changes: 41 additions & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,49 @@ void Application::printHelp() const
fmt::print("\n");
}

void Application::printLicense() const
void Application::printHeader() const
{
fmt::print("\n");
fmt::print("Cura_SteamEngine version {}\n", CURA_ENGINE_VERSION);

#ifdef DEBUG
fmt::print("\n");
fmt::print(" _______ ________ _______ __ __ ______\n");
fmt::print("/ \\ / |/ \\ / | / | / \\\n");
fmt::print("███████ |████████/ ███████ |██ | ██ |/██████ |\n");
fmt::print("██ | ██ |██ |__ ██ |__██ |██ | ██ |██ | _██/\n");
fmt::print("██ | ██ |██ | ██ ██< ██ | ██ |██ |/ |\n");
fmt::print("██ | ██ |█████/ ███████ |██ | ██ |██ |████ |\n");
fmt::print("██ |__██ |██ |_____ ██ |__██ |██ \\__██ |██ \\__██ |\n");
fmt::print("██ ██/ ██ |██ ██/ ██ ██/ ██ ██/\n");
fmt::print("███████/ ████████/ ███████/ ██████/ ██████/\n");
fmt::print("\n");
fmt::print(" __ __ ______ _______ ________\n");
fmt::print("/ \\ / | / \\ / \\ / |\n");
fmt::print("██ \\ /██ |/██████ |███████ |████████/\n");
fmt::print("███ \\ /███ |██ | ██ |██ | ██ |██ |__\n");
fmt::print("████ /████ |██ | ██ |██ | ██ |██ |\n");
fmt::print("██ ██ ██/██ |██ | ██ |██ | ██ |█████/\n");
fmt::print("██ |███/ ██ |██ \\__██ |██ |__██ |██ |_____\n");
fmt::print("██ | █/ ██ |██ ██/ ██ ██/ ██ |\n");
fmt::print("██/ ██/ ██████/ ███████/ ████████/\n");
fmt::print("\n");

fmt::print("#########################################################\n");
fmt::print("#########################################################\n");
fmt::print("## WARNING: This version of CuraEngine has been built ##\n");
fmt::print("## in developper mode. This may impact performances, ##\n");
fmt::print("## provoke unexpected results or crashes. ##\n");
fmt::print("## If you downloaded an official version of CuraEngine ##\n");
fmt::print("## and see this message, please report the issue. ##\n");
fmt::print("#########################################################\n");
fmt::print("#########################################################\n");
#endif
}

void Application::printLicense() const
{
fmt::print("\n");
fmt::print("Copyright (C) 2024 Ultimaker\n");
fmt::print("\n");
fmt::print("This program is free software: you can redistribute it and/or modify\n");
Expand Down Expand Up @@ -184,6 +223,7 @@ void Application::run(const size_t argc, char** argv)
argc_ = argc;
argv_ = argv;

printHeader();
printLicense();
Progress::init();

Expand Down
28 changes: 19 additions & 9 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
base_extruder_nr,
base_extruder_nr,
z_seam_config,
raft_paths);
raft_paths,
storage.getModelBoundingBox().flatten().getMiddle());
wall_orderer.addToLayer();
}

Expand Down Expand Up @@ -865,7 +866,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
interface_extruder_nr,
interface_extruder_nr,
z_seam_config,
raft_paths);
raft_paths,
storage.getModelBoundingBox().flatten().getMiddle());
wall_orderer.addToLayer();
}

Expand Down Expand Up @@ -1028,7 +1030,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
surface_extruder_nr,
surface_extruder_nr,
z_seam_config,
raft_paths);
raft_paths,
storage.getModelBoundingBox().flatten().getMiddle());
wall_orderer.addToLayer();
}

Expand Down Expand Up @@ -2297,7 +2300,8 @@ bool FffGcodeWriter::processSingleLayerInfill(
extruder_nr,
extruder_nr,
z_seam_config,
tool_paths);
tool_paths,
storage.getModelBoundingBox().flatten().getMiddle());
added_something |= wall_orderer.addToLayer();
}
}
Expand Down Expand Up @@ -2739,7 +2743,8 @@ bool FffGcodeWriter::processInsets(
mesh.settings.get<ExtruderTrain&>("wall_0_extruder_nr").extruder_nr_,
mesh.settings.get<ExtruderTrain&>("wall_x_extruder_nr").extruder_nr_,
z_seam_config,
part.wall_toolpaths);
part.wall_toolpaths,
storage.getModelBoundingBox().flatten().getMiddle());
added_something |= wall_orderer.addToLayer();
}
return added_something;
Expand Down Expand Up @@ -3164,7 +3169,8 @@ void FffGcodeWriter::processSkinPrintFeature(
skin_extruder_nr,
skin_extruder_nr,
z_seam_config,
skin_paths);
skin_paths,
storage.getModelBoundingBox().flatten().getMiddle());
added_something |= wall_orderer.addToLayer();
}
}
Expand Down Expand Up @@ -3450,6 +3456,7 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer
extruder_nr,
z_seam_config,
wall_toolpaths,
storage.getModelBoundingBox().flatten().getMiddle(),
disallowed_area_for_seams);
added_something |= wall_orderer.addToLayer();
}
Expand Down Expand Up @@ -3628,7 +3635,8 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer
extruder_nr,
extruder_nr,
z_seam_config,
wall_toolpaths_here);
wall_toolpaths_here,
storage.getModelBoundingBox().flatten().getMiddle());
added_something |= wall_orderer.addToLayer();
}
}
Expand Down Expand Up @@ -3763,7 +3771,8 @@ bool FffGcodeWriter::addSupportRoofsToGCode(const SliceDataStorage& storage, con
roof_extruder_nr,
roof_extruder_nr,
z_seam_config,
roof_paths);
roof_paths,
storage.getModelBoundingBox().flatten().getMiddle());
wall_orderer.addToLayer();
}
gcode_layer.addLinesByOptimizer(roof_lines, current_roof_config, (pattern == EFillMethod::ZIG_ZAG) ? SpaceFillType::PolyLines : SpaceFillType::Lines);
Expand Down Expand Up @@ -3876,7 +3885,8 @@ bool FffGcodeWriter::addSupportBottomsToGCode(const SliceDataStorage& storage, L
bottom_extruder_nr,
bottom_extruder_nr,
z_seam_config,
bottom_paths);
bottom_paths,
storage.getModelBoundingBox().flatten().getMiddle());
wall_orderer.addToLayer();
}
gcode_layer.addLinesByOptimizer(
Expand Down
Loading

0 comments on commit d1bae90

Please sign in to comment.