Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions include/SkirtBrim.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class SkirtBrim
* @param width The maximum inside brim width to be generated
* @param line_width The line width used to print the support inside brim
*/
void generateSupportInsideBrim(const Settings& settings, const Shape& support_outline, const size_t width, const size_t line_width);
void generateSupportInsideBrim(const Settings& settings, const Shape& support_outline, const coord_t width, const coord_t line_width);

/*!
* Generates the outside part of the support brim
Expand All @@ -236,7 +236,7 @@ class SkirtBrim
* @param line_width The line width used to print the support inside brim
* @param exclusion_area The exclusion areas on which the brim is not allowed to grow
*/
void generateSupportOutsideBrim(const Shape& support_outline, const size_t width, const size_t line_width, const Shape& exclusion_area);
void generateSupportOutsideBrim(const Shape& support_outline, const coord_t width, const coord_t line_width, const Shape& exclusion_area);

public:
/*!
Expand Down
6 changes: 3 additions & 3 deletions src/MeshGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,15 @@ bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const fs::path& filename, const
bool load_success = false;
bool has_uv = false;

const fs::path base_filename = filename.stem();
const std::string base_filename = filename.stem().string();
std::string extension = filename.extension().string();
extension = extension.substr(1, extension.size()); // Remove the initial '.'
ranges::transform(extension, extension.begin(), static_cast<int (*)(int)>(std::tolower)); // To lowercase

if (extension == "stl")
{
// Check for corresponding UV and PNG files
const fs::path uv_filename = fs::path(base_filename).replace_extension("uv");
const fs::path uv_filename = fs::path(base_filename + ".uv");

std::vector<Point2F> uv_coordinates;
has_uv = loadUVCoordinatesFromFile(uv_filename, uv_coordinates);
Expand Down Expand Up @@ -579,7 +579,7 @@ bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const fs::path& filename, const

spdlog::info("loading '{}' took {:03.3f} seconds", filename.string(), load_timer.restart());

mesh.mesh_name_ = base_filename.string();
mesh.mesh_name_ = base_filename;
meshgroup->meshes.push_back(mesh);
}

Expand Down
6 changes: 3 additions & 3 deletions src/SkirtBrim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ std::vector<Shape> SkirtBrim::generateAllowedAreas(const std::vector<Outline>& s
return allowed_areas_per_extruder;
}

void SkirtBrim::generateSupportInsideBrim(const Settings& settings, const Shape& support_outline, const size_t width, const size_t line_width)
void SkirtBrim::generateSupportInsideBrim(const Settings& settings, const Shape& support_outline, const coord_t width, const coord_t line_width)
{
const coord_t support_brim_minimum_hole_area = MM2_2INT(settings.get<size_t>("support_brim_minimum_hole_area"));
const coord_t support_brim_minimum_hole_area = MM2_2INT(settings.get<coord_t>("support_brim_minimum_hole_area"));

PolygonUtils::InsetOutset base_insets = PolygonUtils::generateInsetOutset(support_outline, -width, line_width);
for (Shape& base_inset : base_insets.walls)
Expand All @@ -699,7 +699,7 @@ void SkirtBrim::generateSupportInsideBrim(const Settings& settings, const Shape&
}
}

void SkirtBrim::generateSupportOutsideBrim(const Shape& support_outline, const size_t width, const size_t line_width, const Shape& exclusion_area)
void SkirtBrim::generateSupportOutsideBrim(const Shape& support_outline, const coord_t width, const coord_t line_width, const Shape& exclusion_area)
{
PolygonUtils::InsetOutset base_outsets = PolygonUtils::generateInsetOutset(support_outline, width, line_width);

Expand Down
59 changes: 51 additions & 8 deletions src/arachne/SkeletalTrapezoidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,20 +2211,30 @@ void SkeletalTrapezoidation::generateLocalMaximaSingleBeads()
{
Point2LL p_;
coord_t width_;
size_t acc_;
size_t accumulator_;

LocalMaximaPoint(const Point2LL& p, coord_t width)
: p_(p)
, width_(width)
, acc_(1)
, accumulator_(1)
{
}

void operator+=(const LocalMaximaPoint& other)
{
p_ = (p_ * acc_ + other.p_ * other.acc_) / (acc_ + other.acc_);
width_ = (width_ * acc_ + other.width_ * other.acc_) / (acc_ + other.acc_);
acc_ += other.acc_;
p_ += p_ + other.p_;
width_ += width_ + other.width_;
accumulator_ += other.accumulator_;
}

Point2LL getAveragePoint() const
{
return p_ / static_cast<coord_t>(accumulator_);
}

coord_t getAverageWidth() const
{
return width_ / static_cast<coord_t>(accumulator_);
}
};

Expand All @@ -2247,11 +2257,16 @@ void SkeletalTrapezoidation::generateLocalMaximaSingleBeads()
}
else
{
// lines will be removed if they are wider then they are long, if we detect such lines we don't want to print
// nothing since this will leave unpredictable gaps in the print. If we detect such small lines we will instead
// replace them with a small circle to fill the gap.
const auto max_local_maxima_dist = (beading_strategy_.getOptimalWidth() * 3) / 2;
const auto max_local_maxima_dist2 = max_local_maxima_dist * max_local_maxima_dist;
const auto it = ranges::find_if(
local_maxima_points,
[&](const LocalMaximaPoint& local_maxima_point)
{
return vSize2(local_maxima_point.p_ - node.p_) < 10 * 10;
return vSize2(local_maxima_point.p_ - node.p_) < max_local_maxima_dist2;
});

if (it != local_maxima_points.end())
Expand All @@ -2266,9 +2281,37 @@ void SkeletalTrapezoidation::generateLocalMaximaSingleBeads()
}
}

for (const auto& local_maxima_point : local_maxima_points)
bool replace_with_local_maxima = generated_toolpaths.empty() || generated_toolpaths[0].empty();
coord_t total_path_length = 0;
if (! replace_with_local_maxima)
{
addCircleToToolpath(local_maxima_point.p_, local_maxima_point.width_, 0);
coord_t min_width = std::numeric_limits<coord_t>::max();
for (const auto& line : generated_toolpaths[0])
{
total_path_length += line.length();
for (const ExtrusionJunction& j : line)
{
min_width = std::min(min_width, j.w_);
}
}
replace_with_local_maxima |= total_path_length <= min_width / 2;
}

if (replace_with_local_maxima)
{
if (generated_toolpaths.empty())
{
generated_toolpaths.emplace_back();
}
else
{
generated_toolpaths[0].clear();
}

for (const auto& local_maxima_point : local_maxima_points)
{
addCircleToToolpath(local_maxima_point.getAveragePoint(), local_maxima_point.getAverageWidth(), 0);
}
}
}
//
Expand Down
Loading