Skip to content

Commit

Permalink
Fix remaining warning in prime tower classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Jun 2, 2024
1 parent 80cffb6 commit c9c45dc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
5 changes: 1 addition & 4 deletions include/sliceDataStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,7 @@ class SliceDataStorage : public NoCopy
*/
SliceDataStorage();

~SliceDataStorage()
{
delete prime_tower_;
}
~SliceDataStorage();

/*!
* Get all outlines within a given layer.
Expand Down
16 changes: 8 additions & 8 deletions include/utils/LayerVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,24 @@ class LayerVector
return value_type{};
}

[[nodiscard]] LayerIndex getLayer(const const_iterator& iterator) const
[[nodiscard]] LayerIndex getLayer(const const_iterator& it) const
{
return std::distance(begin(), iterator) - delta_;
return std::distance(begin(), it) - static_cast<difference_type>(delta_);
}

[[nodiscard]] LayerIndex getLayer(const iterator& iterator) const
[[nodiscard]] LayerIndex getLayer(const iterator& it) const
{
return std::distance(begin(), iterator) - delta_;
return std::distance(begin(), it) - static_cast<difference_type>(delta_);
}

[[nodiscard]] LayerIndex getLayer(const const_reverse_iterator& iterator) const
[[nodiscard]] LayerIndex getLayer(const const_reverse_iterator& it) const
{
return std::distance(iterator, rend()) - 1 - delta_;
return std::distance(it, rend()) - 1 - static_cast<difference_type>(delta_);
}

[[nodiscard]] LayerIndex getLayer(const reverse_iterator& iterator) const
[[nodiscard]] LayerIndex getLayer(const reverse_iterator& it) const
{
return std::distance(iterator, rend()) - 1 - delta_;
return std::distance(it, rend()) - 1 - static_cast<difference_type>(delta_);
}

void pop_back()
Expand Down
33 changes: 18 additions & 15 deletions src/PrimeTower/PrimeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ PrimeTower::PrimeTower()

for (coord_t z = 0; z < base_height; z += layer_height)
{
double brim_radius_factor = std::pow((1.0 - static_cast<double>(z) / base_height), base_curve_magnitude);
coord_t extra_radius = base_extra_radius * brim_radius_factor;
double brim_radius_factor = std::pow((1.0 - static_cast<double>(z) / static_cast<double>(base_height)), base_curve_magnitude);
coord_t extra_radius = std::llrint(static_cast<double>(base_extra_radius) * brim_radius_factor);
base_occupied_outline_.push_back(outer_poly_.offset(extra_radius));
}
}
Expand Down Expand Up @@ -366,21 +366,24 @@ bool PrimeTower::extruderRequiresPrime(const std::vector<bool>& extruder_is_used

void PrimeTower::gotoStartLocation(LayerPlan& gcode_layer, const size_t extruder_nr) const
{
if (gcode_layer.getLayerNr() != 0)
// Layer number may be negative, make it positive (or null) to apply modulo operator
LayerIndex layer_nr = gcode_layer.getLayerNr();
while (layer_nr < 0)
{
size_t current_start_location_idx = ((((extruder_nr + 1) * gcode_layer.getLayerNr()) % number_of_prime_tower_start_locations_) + number_of_prime_tower_start_locations_)
% number_of_prime_tower_start_locations_;

const ClosestPointPolygon wipe_location = prime_tower_start_locations_[current_start_location_idx];
const ExtruderTrain& train = Application::getInstance().current_slice_->scene.extruders[extruder_nr];
const coord_t inward_dist = train.settings_.get<coord_t>("machine_nozzle_size") * 3 / 2;
const coord_t start_dist = train.settings_.get<coord_t>("machine_nozzle_size") * 2;
const Point2LL prime_end = PolygonUtils::moveInsideDiagonally(wipe_location, inward_dist);
const Point2LL outward_dir = wipe_location.location_ - prime_end;
const Point2LL prime_start = wipe_location.location_ + normal(outward_dir, start_dist);

gcode_layer.addTravel(prime_start);
layer_nr += number_of_prime_tower_start_locations_;
}

size_t current_start_location_idx = ((extruder_nr + 1) * static_cast<size_t>(layer_nr)) % number_of_prime_tower_start_locations_;

const ClosestPointPolygon wipe_location = prime_tower_start_locations_[current_start_location_idx];
const ExtruderTrain& train = Application::getInstance().current_slice_->scene.extruders[extruder_nr];
const coord_t inward_dist = train.settings_.get<coord_t>("machine_nozzle_size") * 3 / 2;
const coord_t start_dist = train.settings_.get<coord_t>("machine_nozzle_size") * 2;
const Point2LL prime_end = PolygonUtils::moveInsideDiagonally(wipe_location, inward_dist);
const Point2LL outward_dir = wipe_location.location_ - prime_end;
const Point2LL prime_start = wipe_location.location_ + normal(outward_dir, start_dist);

gcode_layer.addTravel(prime_start);
}

} // namespace cura
5 changes: 5 additions & 0 deletions src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ SliceDataStorage::SliceDataStorage()
machine_size.include(machine_max);
}

SliceDataStorage::~SliceDataStorage()
{
delete prime_tower_;
}

Shape SliceDataStorage::getLayerOutlines(
const LayerIndex layer_nr,
const bool include_support,
Expand Down

0 comments on commit c9c45dc

Please sign in to comment.