From 55aa0770cfac2e5437c90298018ef82e00004397 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 28 May 2024 09:53:55 +0200 Subject: [PATCH] Refactor method overrides and use std::move The virtual keyword was removed from override methods in various BeadingStrategy classes to improve clarity. The std::move function was also used in the BeadingStrategyFactory.cpp file to transfer ownership of a unique_ptr, improving efficiency and semantic accuracy. Contribute to NP-202 --- include/BeadingStrategy/LimitedBeadingStrategy.h | 2 +- .../OuterWallInsetBeadingStrategy.h | 2 +- .../RedistributeBeadingStrategy.h | 2 +- .../BeadingStrategy/WideningBeadingStrategy.h | 16 ++++++++-------- src/BeadingStrategy/BeadingStrategyFactory.cpp | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/BeadingStrategy/LimitedBeadingStrategy.h b/include/BeadingStrategy/LimitedBeadingStrategy.h index 42d34f86a4..3e15eefec2 100644 --- a/include/BeadingStrategy/LimitedBeadingStrategy.h +++ b/include/BeadingStrategy/LimitedBeadingStrategy.h @@ -35,7 +35,7 @@ class LimitedBeadingStrategy : public BeadingStrategy coord_t getOptimalThickness(coord_t bead_count) const override; coord_t getTransitionThickness(coord_t lower_bead_count) const override; coord_t getOptimalBeadCount(coord_t thickness) const override; - virtual std::string toString() const override; + std::string toString() const override; coord_t getTransitioningLength(coord_t lower_bead_count) const override; diff --git a/include/BeadingStrategy/OuterWallInsetBeadingStrategy.h b/include/BeadingStrategy/OuterWallInsetBeadingStrategy.h index c8c6eae31d..840c04f888 100644 --- a/include/BeadingStrategy/OuterWallInsetBeadingStrategy.h +++ b/include/BeadingStrategy/OuterWallInsetBeadingStrategy.h @@ -25,7 +25,7 @@ class OuterWallInsetBeadingStrategy : public BeadingStrategy coord_t getOptimalBeadCount(coord_t thickness) const override; coord_t getTransitioningLength(coord_t lower_bead_count) const override; - virtual std::string toString() const; + std::string toString() const override; private: BeadingStrategyPtr parent_; diff --git a/include/BeadingStrategy/RedistributeBeadingStrategy.h b/include/BeadingStrategy/RedistributeBeadingStrategy.h index 2f8304bf39..52d41e1a93 100644 --- a/include/BeadingStrategy/RedistributeBeadingStrategy.h +++ b/include/BeadingStrategy/RedistributeBeadingStrategy.h @@ -45,7 +45,7 @@ class RedistributeBeadingStrategy : public BeadingStrategy coord_t getTransitioningLength(coord_t lower_bead_count) const override; double getTransitionAnchorPos(coord_t lower_bead_count) const override; - virtual std::string toString() const; + std::string toString() const override; protected: /*! diff --git a/include/BeadingStrategy/WideningBeadingStrategy.h b/include/BeadingStrategy/WideningBeadingStrategy.h index bda69f345d..cd0f00c406 100644 --- a/include/BeadingStrategy/WideningBeadingStrategy.h +++ b/include/BeadingStrategy/WideningBeadingStrategy.h @@ -27,14 +27,14 @@ class WideningBeadingStrategy : public BeadingStrategy virtual ~WideningBeadingStrategy() override = default; - virtual Beading compute(coord_t thickness, coord_t bead_count) const override; - virtual coord_t getOptimalThickness(coord_t bead_count) const override; - virtual coord_t getTransitionThickness(coord_t lower_bead_count) const override; - virtual coord_t getOptimalBeadCount(coord_t thickness) const override; - virtual coord_t getTransitioningLength(coord_t lower_bead_count) const override; - virtual double getTransitionAnchorPos(coord_t lower_bead_count) const override; - virtual std::vector getNonlinearThicknesses(coord_t lower_bead_count) const override; - virtual std::string toString() const override; + Beading compute(coord_t thickness, coord_t bead_count) const override; + coord_t getOptimalThickness(coord_t bead_count) const override; + coord_t getTransitionThickness(coord_t lower_bead_count) const override; + coord_t getOptimalBeadCount(coord_t thickness) const override; + coord_t getTransitioningLength(coord_t lower_bead_count) const override; + double getTransitionAnchorPos(coord_t lower_bead_count) const override; + std::vector getNonlinearThicknesses(coord_t lower_bead_count) const override; + std::string toString() const override; protected: BeadingStrategyPtr parent_; diff --git a/src/BeadingStrategy/BeadingStrategyFactory.cpp b/src/BeadingStrategy/BeadingStrategyFactory.cpp index c929bd5d9f..8b2d289449 100644 --- a/src/BeadingStrategy/BeadingStrategyFactory.cpp +++ b/src/BeadingStrategy/BeadingStrategyFactory.cpp @@ -41,22 +41,22 @@ BeadingStrategyPtr BeadingStrategyFactory::makeStrategy( wall_add_middle_threshold, inward_distributed_center_wall_count); spdlog::debug("Applying the Redistribute meta-strategy with outer-wall width = {}, inner-wall width = {}", preferred_bead_width_outer, preferred_bead_width_inner); - ret = make_unique(preferred_bead_width_outer, minimum_variable_line_ratio, move(ret)); + ret = make_unique(preferred_bead_width_outer, minimum_variable_line_ratio, std::move(ret)); if (print_thin_walls) { spdlog::debug("Applying the Widening Beading meta-strategy with minimum input width {} and minimum output width {}.", min_feature_size, min_bead_width); - ret = make_unique(move(ret), min_feature_size, min_bead_width); + ret = make_unique(std::move(ret), min_feature_size, min_bead_width); } if (outer_wall_offset > 0) { spdlog::debug("Applying the OuterWallOffset meta-strategy with offset = {}", outer_wall_offset); - ret = make_unique(outer_wall_offset, move(ret)); + ret = make_unique(outer_wall_offset, std::move(ret)); } // Apply the LimitedBeadingStrategy last, since that adds a 0-width marker wall which other beading strategies shouldn't touch. spdlog::debug("Applying the Limited Beading meta-strategy with maximum bead count = {}", max_bead_count); - ret = make_unique(max_bead_count, move(ret)); + ret = make_unique(max_bead_count, std::move(ret)); return ret; } } // namespace cura