Skip to content

Commit

Permalink
Refactor method overrides and use std::move
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jellespijker committed May 28, 2024
1 parent 51cc6a3 commit 55aa077
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/BeadingStrategy/LimitedBeadingStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion include/BeadingStrategy/OuterWallInsetBeadingStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion include/BeadingStrategy/RedistributeBeadingStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/*!
Expand Down
16 changes: 8 additions & 8 deletions include/BeadingStrategy/WideningBeadingStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<coord_t> 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<coord_t> getNonlinearThicknesses(coord_t lower_bead_count) const override;
std::string toString() const override;

protected:
BeadingStrategyPtr parent_;
Expand Down
8 changes: 4 additions & 4 deletions src/BeadingStrategy/BeadingStrategyFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RedistributeBeadingStrategy>(preferred_bead_width_outer, minimum_variable_line_ratio, move(ret));
ret = make_unique<RedistributeBeadingStrategy>(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<WideningBeadingStrategy>(move(ret), min_feature_size, min_bead_width);
ret = make_unique<WideningBeadingStrategy>(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<OuterWallInsetBeadingStrategy>(outer_wall_offset, move(ret));
ret = make_unique<OuterWallInsetBeadingStrategy>(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<LimitedBeadingStrategy>(max_bead_count, move(ret));
ret = make_unique<LimitedBeadingStrategy>(max_bead_count, std::move(ret));
return ret;
}
} // namespace cura

0 comments on commit 55aa077

Please sign in to comment.