Skip to content

Commit

Permalink
Clean code and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Jun 12, 2024
1 parent ac2408a commit 9939da9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
18 changes: 11 additions & 7 deletions include/utils/LayerVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ namespace cura
/*!
* \brief The LayerVector class mimics a std::vector but with the index being a LayerIndex, thus it can have negative
* values (for raft layers).
* \note At instantiation, LayerVector will call Raft::getTotalExtraLayers() so it requires the settings to be setup.
* After that, it is assumed that this value will not change while the vector is used.
* \note When calling the init() method, LayerVector will call Raft::getTotalExtraLayers() so it requires the settings
* to be setup. This is the reason why this is not done in the constructor, and has to be called manually.
* After that, it is assumed that this value will not change as long as the vector is used.
* \warning It is assumed that items are inserted in layer order, and without missing items, like a std::vector would do
*/
template<class T>
Expand All @@ -33,15 +34,13 @@ class LayerVector
using difference_type = typename std::vector<value_type>::difference_type;

public:
LayerVector()
{
}
LayerVector() = default;

/*!
* \brief Initializes the vector for use
* \param contains_raft_layers Indicates whether this vector will contain raft layers
* \param total_print_layers The number of print layers (not including raft layers). This is only for pre-reserving
* stored data and can be safely omitted.
* \param print_layers The number of print layers (not including raft layers). This is only for pre-reserving
* stored data and can be safely omitted.
* \note It is not mandatory to call this method if you do not intend to store raft layers, but still good practice
*/
void init(bool contains_raft_layers, size_t print_layers = 0)
Expand Down Expand Up @@ -145,6 +144,11 @@ class LayerVector
return end();
}

/*!
* \brief Safe method to retrieve an element from the list
* \param pos The position of the element to be retrieved
* \return The element at the given position, or if there is none, a default-constructed value.
*/
value_type get(const LayerIndex& pos) const noexcept
{
LayerIndex::value_type index = pos + delta_;
Expand Down
9 changes: 0 additions & 9 deletions include/utils/polygonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,15 +715,6 @@ class PolygonUtils
namespace std
{

/*template<typename S, typename T>
struct hash<std::pair<S, T>>
{
size_t operator()(const std::pair<S, T>& pair) const
{
return 31 * std::hash<S>()(pair.first) + 59 * std::hash<T>()(pair.second);
}
};*/

template<>
struct hash<cura::ClosestPointPolygon>
{
Expand Down
2 changes: 1 addition & 1 deletion src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ size_t FffGcodeWriter::findUsedExtruderIndex(const SliceDataStorage& storage, co
}
else
{
// Asking for extruder on an empty layer, get the one from layer below
// Asking for extruder on an empty layer, get the last one from layer below
return findUsedExtruderIndex(storage, layer_nr - 1, true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ Shape SliceDataStorage::getMachineBorder(int checking_extruder_nr) const
Point2LL translation(extruder_settings.get<coord_t>("machine_nozzle_offset_x"), extruder_settings.get<coord_t>("machine_nozzle_offset_y"));
prime_pos -= translation;
Shape prime_polygons;
prime_polygons.emplace_back(PolygonUtils::makeCircle(prime_pos, prime_clearance, 32));
prime_polygons.emplace_back(PolygonUtils::makeCircle(prime_pos, prime_clearance, 64));
disallowed_areas = disallowed_areas.unionPolygons(prime_polygons);
}

Expand Down

0 comments on commit 9939da9

Please sign in to comment.