diff --git a/include/SkeletalTrapezoidationGraph.h b/include/SkeletalTrapezoidationGraph.h index ab6e589d16..01eb198f94 100644 --- a/include/SkeletalTrapezoidationGraph.h +++ b/include/SkeletalTrapezoidationGraph.h @@ -19,28 +19,29 @@ class STHalfEdge : public HalfEdge distToGoUp() const; STHalfEdge* getNextUnconnected(); @@ -50,6 +51,7 @@ class STHalfEdgeNode : public HalfEdgeNode +class SkeletalTrapezoidationGraph : public HalfEdgeGraph { using edge_t = STHalfEdge; using node_t = STHalfEdgeNode; -public: +public: /*! * If an edge is too small, collapse it and its twin and fix the surrounding edges to ensure a consistent graph. - * + * * Don't collapse support edges, unless we can collapse the whole quad. - * + * * o-, * | "-o * | | > Don't collapse this edge only. @@ -87,7 +89,7 @@ class SkeletalTrapezoidationGraph: public HalfEdgeGraph getSource(const edge_t& edge); }; -} -#endif +} // namespace cura +#endif diff --git a/include/gcodeExport.h b/include/gcodeExport.h index 29582eb649..b3b4ef6fe4 100644 --- a/include/gcodeExport.h +++ b/include/gcodeExport.h @@ -19,8 +19,8 @@ #include "sliceDataStorage.h" #include "timeEstimate.h" #include "utils/AABB3D.h" //To track the used build volume for the Griffin header. -#include "utils/Point2LL.h" #include "utils/NoCopy.h" +#include "utils/Point2LL.h" namespace cura { @@ -128,7 +128,7 @@ class GCodeExport : public NoCopy double extrusion_offset_factor_; //!< default 1 Point3LL current_position_; //!< The last build plate coordinates written to gcode (which might be different from actually written gcode coordinates when the extruder offset is - //!< encoded in the gcode) + //!< encoded in the gcode) Velocity current_speed_; //!< The current speed (F values / 60) in mm/s Acceleration current_print_acceleration_; //!< The current acceleration (in mm/s^2) used for print moves (and also for travel moves if the gcode flavor doesn't have separate //!< travel acceleration) diff --git a/include/infill/LightningLayer.h b/include/infill/LightningLayer.h index e9cd2b77c0..fe5a079e43 100644 --- a/include/infill/LightningLayer.h +++ b/include/infill/LightningLayer.h @@ -4,15 +4,15 @@ #ifndef LIGHTNING_LAYER_H #define LIGHTNING_LAYER_H -#include "../utils/SquareGrid.h" -#include "../utils/polygonUtils.h" -#include "infill/LightningTreeNode.h" - #include #include #include #include +#include "../utils/SquareGrid.h" +#include "../utils/polygonUtils.h" +#include "infill/LightningTreeNode.h" + namespace cura { using LightningTreeNodeSPtr = std::shared_ptr; diff --git a/include/infill/NoZigZagConnectorProcessor.h b/include/infill/NoZigZagConnectorProcessor.h index 82724ac95f..002fb0fb7b 100644 --- a/include/infill/NoZigZagConnectorProcessor.h +++ b/include/infill/NoZigZagConnectorProcessor.h @@ -1,5 +1,5 @@ -//Copyright (c) 2018 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2018 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H #define INFILL_NO_ZIGZAG_CONNECTOR_PROCESSOR_H @@ -18,9 +18,13 @@ class NoZigZagConnectorProcessor : public ZigzagConnectorProcessor { public: NoZigZagConnectorProcessor(const PointMatrix& rotation_matrix, Polygons& result) - : ZigzagConnectorProcessor(rotation_matrix, result, - false, false, // settings for zig-zag end pieces, no use here - false, 0) // settings for skipping some zags, no use here + : ZigzagConnectorProcessor( + rotation_matrix, + result, + false, + false, // settings for zig-zag end pieces, no use here + false, + 0) // settings for skipping some zags, no use here { } diff --git a/include/pathPlanning/CombPath.h b/include/pathPlanning/CombPath.h index b1811352ea..6559e8c7ee 100644 --- a/include/pathPlanning/CombPath.h +++ b/include/pathPlanning/CombPath.h @@ -1,5 +1,5 @@ -//Copyright (c) 2018 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2018 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef PATH_PLANNING_COMB_PATH_H #define PATH_PLANNING_COMB_PATH_H @@ -9,12 +9,12 @@ namespace cura { -class CombPath : public std::vector //!< A single path either inside or outise the parts +class CombPath : public std::vector //!< A single path either inside or outise the parts { public: bool cross_boundary = false; //!< Whether the path crosses a boundary. }; -}//namespace cura +} // namespace cura -#endif//PATH_PLANNING_COMB_PATH_H +#endif // PATH_PLANNING_COMB_PATH_H diff --git a/include/pathPlanning/LinePolygonsCrossings.h b/include/pathPlanning/LinePolygonsCrossings.h index 551577ae2e..5fb641dd9b 100644 --- a/include/pathPlanning/LinePolygonsCrossings.h +++ b/include/pathPlanning/LinePolygonsCrossings.h @@ -57,9 +57,9 @@ class LinePolygonsCrossings PointMatrix transformation_matrix_; //!< The transformation which rotates everything such that the scanline is aligned with the x-axis. Point2LL transformed_start_point_; //!< The LinePolygonsCrossings::startPoint as transformed by Comb::transformation_matrix such that it has (roughly) the same Y as - //!< transformed_endPoint + //!< transformed_endPoint Point2LL transformed_end_point_; //!< The LinePolygonsCrossings::endPoint as transformed by Comb::transformation_matrix such that it has (roughly) the same Y as - //!< transformed_startPoint + //!< transformed_startPoint /*! diff --git a/include/plugins/slots.h b/include/plugins/slots.h index c519553114..296e3f649b 100644 --- a/include/plugins/slots.h +++ b/include/plugins/slots.h @@ -4,6 +4,11 @@ #ifndef PLUGINS_SLOTS_H #define PLUGINS_SLOTS_H +#include +#include +#include +#include + #include "WallToolPaths.h" #include "cura/plugins/slots/broadcast/v0/broadcast.grpc.pb.h" #include "cura/plugins/slots/gcode_paths/v0/modify.grpc.pb.h" @@ -21,11 +26,6 @@ #include "utils/polygon.h" #include "utils/types/char_range_literal.h" -#include -#include -#include -#include - namespace cura { namespace plugins diff --git a/include/plugins/types.h b/include/plugins/types.h index 1a9ab54d59..eb443d0b27 100644 --- a/include/plugins/types.h +++ b/include/plugins/types.h @@ -4,16 +4,16 @@ #ifndef PLUGINS_TYPES_H #define PLUGINS_TYPES_H -#include "cura/plugins/v0/slot_id.pb.h" -#include "utils/Point2LL.h" -#include "utils/polygon.h" - -#include - #include #include #include +#include + +#include "cura/plugins/v0/slot_id.pb.h" +#include "utils/Point2LL.h" +#include "utils/polygon.h" + namespace fmt { // Custom formatter for humanreadable slot_id's diff --git a/include/sliceDataStorage.h b/include/sliceDataStorage.h index 3442f0b08d..7fced685eb 100644 --- a/include/sliceDataStorage.h +++ b/include/sliceDataStorage.h @@ -18,8 +18,8 @@ #include "settings/types/LayerIndex.h" #include "utils/AABB.h" #include "utils/AABB3D.h" -#include "utils/Point2LL.h" #include "utils/NoCopy.h" +#include "utils/Point2LL.h" #include "utils/polygon.h" // libArachne diff --git a/include/utils/MinimumSpanningTree.h b/include/utils/MinimumSpanningTree.h index 9e0f53d4cf..599ab2273b 100644 --- a/include/utils/MinimumSpanningTree.h +++ b/include/utils/MinimumSpanningTree.h @@ -1,12 +1,12 @@ -//Copyright (c) 2018 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2018 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef MINIMUMSPANNINGTREE_H #define MINIMUMSPANNINGTREE_H -#include #include #include +#include #include "Point2LL.h" @@ -26,7 +26,8 @@ class MinimumSpanningTree * While edges are meant to be undirected, these do have a start and end * point. */ - struct Edge { + struct Edge + { /** * The point at which this edge starts. */ @@ -37,6 +38,7 @@ class MinimumSpanningTree */ const Point2LL end; }; + public: MinimumSpanningTree() = default; /*! @@ -76,7 +78,6 @@ class MinimumSpanningTree AdjacencyGraph_t prim(std::vector vertices) const; }; -} +} // namespace cura #endif /* MINIMUMSPANNINGTREE_H */ - diff --git a/include/utils/PolygonsSegmentIndex.h b/include/utils/PolygonsSegmentIndex.h index b5462a7a16..ab37fa2f06 100644 --- a/include/utils/PolygonsSegmentIndex.h +++ b/include/utils/PolygonsSegmentIndex.h @@ -1,5 +1,5 @@ -//Copyright (c) 2020 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2020 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef UTILS_POLYGONS_SEGMENT_INDEX_H #define UTILS_POLYGONS_SEGMENT_INDEX_H @@ -8,7 +8,7 @@ #include "PolygonsPointIndex.h" -namespace cura +namespace cura { /*! @@ -29,4 +29,4 @@ class PolygonsSegmentIndex : public PolygonsPointIndex } // namespace cura -#endif//UTILS_POLYGONS_SEGMENT_INDEX_H +#endif // UTILS_POLYGONS_SEGMENT_INDEX_H diff --git a/include/utils/SVG.h b/include/utils/SVG.h index 82646e1df6..81c5b078af 100644 --- a/include/utils/SVG.h +++ b/include/utils/SVG.h @@ -8,8 +8,8 @@ #include "AABB.h" #include "ExtrusionLine.h" //To accept variable-width paths. -#include "Point2LL.h" #include "NoCopy.h" +#include "Point2LL.h" namespace cura { diff --git a/include/utils/orderOptimizer.h b/include/utils/orderOptimizer.h index e990cecbac..cf3abaa2ba 100644 --- a/include/utils/orderOptimizer.h +++ b/include/utils/orderOptimizer.h @@ -1,25 +1,27 @@ -//Copyright (c) 2018 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2018 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #ifndef UTILS_ORDER_OPTIMIZER_H #define UTILS_ORDER_OPTIMIZER_H #include -#include #include #include // pair +#include + #include "Point2LL.h" -namespace cura { - +namespace cura +{ + /*! * Order optimization class. - * + * * Utility class for optimizing the path order by minimizing the cyclic distance traveled between several items. - * + * * The path is heuristically optimized in a way such that each node is visited and the salesman which is travelling ends up where he started. */ -template +template class OrderOptimizer { public: @@ -38,13 +40,13 @@ class OrderOptimizer std::list optimize(const Point2LL& start_position); }; -template +template void OrderOptimizer::addItem(const Point2LL location, const T item) { items.emplace_back(location, item); } -template +template std::list OrderOptimizer::optimize(const Point2LL& start_position) { // Use the nearest mesh ordering @@ -62,7 +64,7 @@ std::list OrderOptimizer::optimize(const Point2LL& start_position) } const Point2LL* last_item_position = &start_position; - while (!item_idx_list.empty()) + while (! item_idx_list.empty()) { coord_t shortest_distance = POINT_MAX; size_t shortest_distance_item_idx = -1; @@ -89,6 +91,6 @@ std::list OrderOptimizer::optimize(const Point2LL& start_position) } -}//namespace cura +} // namespace cura -#endif//UTILS_ORDER_OPTIMIZER_H +#endif // UTILS_ORDER_OPTIMIZER_H diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 9ad194fb47..a9932a7116 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -662,8 +662,8 @@ void LayerPlan::addWallLine( { // if we are accelerating after a bridge line, the segment length is less than the whole line length Point2LL segment_end = (speed_factor == 1 || distance_to_line_end < acceleration_segment_len) - ? line_end - : cur_point + (line_end - cur_point) * acceleration_segment_len / distance_to_line_end; + ? line_end + : cur_point + (line_end - cur_point) * acceleration_segment_len / distance_to_line_end; // flow required for the next line segment - when accelerating after a bridge segment, the flow is increased in inverse proportion to the speed_factor // so the slower the feedrate, the greater the flow - the idea is to get the extruder back to normal pressure as quickly as possible diff --git a/src/infill/LightningDistanceField.cpp b/src/infill/LightningDistanceField.cpp index 923eb1e8b8..1afea87a24 100644 --- a/src/infill/LightningDistanceField.cpp +++ b/src/infill/LightningDistanceField.cpp @@ -28,8 +28,9 @@ LightningDistanceField::LightningDistanceField(const coord_t& radius, const Poly [&radius](const UnsupCell& a, const UnsupCell& b) { constexpr coord_t prime_for_hash = 191; - return std::abs(b.dist_to_boundary_ - a.dist_to_boundary_) > radius ? a.dist_to_boundary_ < b.dist_to_boundary_ - : (std::hash{}(a.loc_) % prime_for_hash) < (std::hash{}(b.loc_) % prime_for_hash); + return std::abs(b.dist_to_boundary_ - a.dist_to_boundary_) > radius + ? a.dist_to_boundary_ < b.dist_to_boundary_ + : (std::hash{}(a.loc_) % prime_for_hash) < (std::hash{}(b.loc_) % prime_for_hash); }); for (auto it = unsupported_points_.begin(); it != unsupported_points_.end(); ++it) { diff --git a/src/infill/LightningLayer.cpp b/src/infill/LightningLayer.cpp index cd689e1bfc..6cefaff8be 100644 --- a/src/infill/LightningLayer.cpp +++ b/src/infill/LightningLayer.cpp @@ -1,5 +1,5 @@ -//Copyright (c) 2022 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2022 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #include "infill/LightningLayer.h" //The class we're implementing. @@ -8,9 +8,9 @@ #include "infill/LightningDistanceField.h" #include "infill/LightningTreeNode.h" #include "sliceDataStorage.h" -#include "utils/linearAlg2D.h" #include "utils/SVG.h" #include "utils/SparsePointGridInclusive.h" +#include "utils/linearAlg2D.h" using namespace cura; @@ -34,25 +34,22 @@ Point2LL GroundingLocation::p() const void LightningLayer::fillLocator(SparseLightningTreeNodeGrid& tree_node_locator) { - std::function add_node_to_locator_func = - [&tree_node_locator](LightningTreeNodeSPtr node) - { - tree_node_locator.insert(node->getLocation(), node); - }; + std::function add_node_to_locator_func = [&tree_node_locator](LightningTreeNodeSPtr node) + { + tree_node_locator.insert(node->getLocation(), node); + }; for (auto& tree : tree_roots) { tree->visitNodes(add_node_to_locator_func); } } -void LightningLayer::generateNewTrees -( +void LightningLayer::generateNewTrees( const Polygons& current_overhang, const Polygons& current_outlines, const LocToLineGrid& outlines_locator, const coord_t supporting_radius, - const coord_t wall_supporting_radius -) + const coord_t wall_supporting_radius) { LightningDistanceField distance_field(supporting_radius, current_outlines, current_overhang); @@ -64,16 +61,8 @@ void LightningLayer::generateNewTrees Point2LL unsupported_location; while (distance_field.tryGetNextPoint(&unsupported_location)) { - GroundingLocation grounding_loc = - getBestGroundingLocation - ( - unsupported_location, - current_outlines, - outlines_locator, - supporting_radius, - wall_supporting_radius, - tree_node_locator - ); + GroundingLocation grounding_loc + = getBestGroundingLocation(unsupported_location, current_outlines, outlines_locator, supporting_radius, wall_supporting_radius, tree_node_locator); LightningTreeNodeSPtr new_parent; LightningTreeNodeSPtr new_child; @@ -89,16 +78,14 @@ void LightningLayer::generateNewTrees } } -GroundingLocation LightningLayer::getBestGroundingLocation -( +GroundingLocation LightningLayer::getBestGroundingLocation( const Point2LL& unsupported_location, const Polygons& current_outlines, const LocToLineGrid& outline_locator, const coord_t supporting_radius, const coord_t wall_supporting_radius, const SparseLightningTreeNodeGrid& tree_node_locator, - const LightningTreeNodeSPtr& exclude_tree -) + const LightningTreeNodeSPtr& exclude_tree) { ClosestPolygonPoint cpp = PolygonUtils::findClosest(unsupported_location, current_outlines); Point2LL node_location = cpp.p(); @@ -114,12 +101,8 @@ GroundingLocation LightningLayer::getBestGroundingLocation for (auto& candidate_wptr : candidate_trees) { auto candidate_sub_tree = candidate_wptr.lock(); - if - ( - (candidate_sub_tree && candidate_sub_tree != exclude_tree) && - ! (exclude_tree && exclude_tree->hasOffspring(candidate_sub_tree)) && - ! PolygonUtils::polygonCollidesWithLineSegment(unsupported_location, candidate_sub_tree->getLocation(), outline_locator, &dummy) - ) + if ((candidate_sub_tree && candidate_sub_tree != exclude_tree) && ! (exclude_tree && exclude_tree->hasOffspring(candidate_sub_tree)) + && ! PolygonUtils::polygonCollidesWithLineSegment(unsupported_location, candidate_sub_tree->getLocation(), outline_locator, &dummy)) { const coord_t candidate_dist = candidate_sub_tree->getWeightedDistance(unsupported_location, supporting_radius); if (candidate_dist < current_dist) @@ -141,13 +124,7 @@ GroundingLocation LightningLayer::getBestGroundingLocation } } -bool LightningLayer::attach -( - const Point2LL& unsupported_location, - const GroundingLocation& grounding_loc, - LightningTreeNodeSPtr& new_child, - LightningTreeNodeSPtr& new_root -) +bool LightningLayer::attach(const Point2LL& unsupported_location, const GroundingLocation& grounding_loc, LightningTreeNodeSPtr& new_child, LightningTreeNodeSPtr& new_root) { // Update trees & distance fields. if (grounding_loc.boundary_location) @@ -164,14 +141,12 @@ bool LightningLayer::attach } } -void LightningLayer::reconnectRoots -( +void LightningLayer::reconnectRoots( std::vector& to_be_reconnected_tree_roots, const Polygons& current_outlines, const LocToLineGrid& outline_locator, const coord_t supporting_radius, - const coord_t wall_supporting_radius -) + const coord_t wall_supporting_radius) { constexpr coord_t tree_connecting_ignore_offset = 100; @@ -202,18 +177,10 @@ void LightningLayer::reconnectRoots } } - const coord_t tree_connecting_ignore_width = wall_supporting_radius - tree_connecting_ignore_offset; // Ideally, the boundary size in which the valence rule is ignored would be configurable. - GroundingLocation ground = - getBestGroundingLocation - ( - root_ptr->getLocation(), - current_outlines, - outline_locator, - supporting_radius, - tree_connecting_ignore_width, - tree_node_locator, - root_ptr - ); + const coord_t tree_connecting_ignore_width + = wall_supporting_radius - tree_connecting_ignore_offset; // Ideally, the boundary size in which the valence rule is ignored would be configurable. + GroundingLocation ground + = getBestGroundingLocation(root_ptr->getLocation(), current_outlines, outline_locator, supporting_radius, tree_connecting_ignore_width, tree_node_locator, root_ptr); if (ground.boundary_location) { if (ground.boundary_location.value().p() == root_ptr->getLocation()) @@ -234,8 +201,8 @@ void LightningLayer::reconnectRoots { assert(ground.tree_node); assert(ground.tree_node != root_ptr); - assert(!root_ptr->hasOffspring(ground.tree_node)); - assert(!ground.tree_node->hasOffspring(root_ptr)); + assert(! root_ptr->hasOffspring(ground.tree_node)); + assert(! ground.tree_node->hasOffspring(root_ptr)); auto attach_ptr = root_ptr->closestNode(ground.tree_node->getLocation()); attach_ptr->reroot(); diff --git a/src/infill/NoZigZagConnectorProcessor.cpp b/src/infill/NoZigZagConnectorProcessor.cpp index 5deaa551ac..1ffa6532f4 100644 --- a/src/infill/NoZigZagConnectorProcessor.cpp +++ b/src/infill/NoZigZagConnectorProcessor.cpp @@ -1,27 +1,27 @@ -//Copyright (c) 2022 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. - -#include "utils/macros.h" +// Copyright (c) 2022 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #include "infill/NoZigZagConnectorProcessor.h" +#include "utils/macros.h" + -namespace cura +namespace cura { void NoZigZagConnectorProcessor::registerVertex(const Point2LL&) { - //No need to add anything. + // No need to add anything. } void NoZigZagConnectorProcessor::registerScanlineSegmentIntersection(const Point2LL&, int) { - //No need to add anything. + // No need to add anything. } void NoZigZagConnectorProcessor::registerPolyFinished() { - //No need to add anything. + // No need to add anything. } -} // namespace cura +} // namespace cura diff --git a/src/layerPart.cpp b/src/layerPart.cpp index 2a47dd8563..b0fb7ece93 100644 --- a/src/layerPart.cpp +++ b/src/layerPart.cpp @@ -1,16 +1,16 @@ -//Copyright (c) 2023 UltiMaker -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2023 UltiMaker +// CuraEngine is released under the terms of the AGPLv3 or higher. #include "layerPart.h" -#include "sliceDataStorage.h" -#include "slicer.h" + +#include "progress/Progress.h" #include "settings/EnumSettings.h" //For ESurfaceMode. #include "settings/Settings.h" -#include "progress/Progress.h" -#include "utils/ThreadPool.h" - +#include "sliceDataStorage.h" +#include "slicer.h" #include "utils/PolylineStitcher.h" #include "utils/Simplify.h" //Simplifying the layers after creating them. +#include "utils/ThreadPool.h" /* The layer-part creation step is the first step in creating actual useful data for 3D printing. @@ -24,7 +24,8 @@ And all every bit inside a single part can be printed without the nozzle leaving It's also the first step that stores the result in the "data storage" so all other steps can access it. */ -namespace cura { +namespace cura +{ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, SlicerLayer* layer) { @@ -35,7 +36,7 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl const bool union_all_remove_holes = settings.get("meshfix_union_all_remove_holes"); if (union_all_remove_holes) { - for(unsigned int i=0; ipolygons.size(); i++) + for (unsigned int i = 0; i < layer->polygons.size(); i++) { if (layer->polygons[i].orientation()) layer->polygons[i].reverse(); @@ -45,7 +46,7 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl std::vector result; const bool union_layers = settings.get("meshfix_union_all"); const ESurfaceMode surface_only = settings.get("magic_mesh_surface_mode"); - if (surface_only == ESurfaceMode::SURFACE && !union_layers) + if (surface_only == ESurfaceMode::SURFACE && ! union_layers) { // Don't do anything with overlapping areas; no union nor xor result.reserve(layer->polygons.size()); for (const PolygonRef poly : layer->polygons) @@ -59,7 +60,7 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl result = layer->polygons.splitIntoParts(union_layers || union_all_remove_holes); } - for(auto & part : result) + for (auto& part : result) { storageLayer.parts.emplace_back(); storageLayer.parts.back().outline = part; @@ -76,12 +77,15 @@ void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer) const auto total_layers = slicer->layers.size(); assert(mesh.layers.size() == total_layers); - cura::parallel_for(0, total_layers, [slicer, &mesh](size_t layer_nr) - { - SliceLayer& layer_storage = mesh.layers[layer_nr]; - SlicerLayer& slice_layer = slicer->layers[layer_nr]; - createLayerWithParts(mesh.settings, layer_storage, &slice_layer); - }); + cura::parallel_for( + 0, + total_layers, + [slicer, &mesh](size_t layer_nr) + { + SliceLayer& layer_storage = mesh.layers[layer_nr]; + SlicerLayer& slice_layer = slicer->layers[layer_nr]; + createLayerWithParts(mesh.settings, layer_storage, &slice_layer); + }); for (LayerIndex layer_nr = total_layers - 1; layer_nr >= 0; layer_nr--) { @@ -94,4 +98,4 @@ void createLayerParts(SliceMeshStorage& mesh, Slicer* slicer) } } -}//namespace cura +} // namespace cura diff --git a/src/plugins/converters.cpp b/src/plugins/converters.cpp index c637f44c45..2f8eabd151 100644 --- a/src/plugins/converters.cpp +++ b/src/plugins/converters.cpp @@ -4,6 +4,10 @@ #include "plugins/converters.h" +#include +#include +#include + #include "GCodePathConfig.h" #include "WallToolPaths.h" #include "pathPlanning/GCodePath.h" @@ -12,10 +16,6 @@ #include "settings/types/LayerIndex.h" #include "utils/polygon.h" -#include -#include -#include - namespace cura::plugins { diff --git a/src/utils/Matrix4x3D.cpp b/src/utils/Matrix4x3D.cpp index 225be8db8a..43b255379f 100644 --- a/src/utils/Matrix4x3D.cpp +++ b/src/utils/Matrix4x3D.cpp @@ -1,9 +1,10 @@ // Copyright (c) 2022 Ultimaker B.V. // CuraEngine is released under the terms of the AGPLv3 or higher. +#include "utils/Matrix4x3D.h" //The definitions we're implementing. + #include "settings/types/Ratio.h" //Scale factor. #include "utils/Point2LL.h" //Conversion directly into integer-based coordinates. -#include "utils/Matrix4x3D.h" //The definitions we're implementing. #include "utils/Point3D.h" //This matrix gets applied to floating point coordinates. namespace cura diff --git a/src/utils/MinimumSpanningTree.cpp b/src/utils/MinimumSpanningTree.cpp index f32b104913..36e7c48e97 100644 --- a/src/utils/MinimumSpanningTree.cpp +++ b/src/utils/MinimumSpanningTree.cpp @@ -1,17 +1,18 @@ -//Copyright (c) 2022 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2022 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #include "utils/MinimumSpanningTree.h" -#include #include +#include namespace cura { -MinimumSpanningTree::MinimumSpanningTree(std::vector vertices) : adjacency_graph(prim(vertices)) +MinimumSpanningTree::MinimumSpanningTree(std::vector vertices) + : adjacency_graph(prim(vertices)) { - //Just copy over the fields. + // Just copy over the fields. } auto MinimumSpanningTree::prim(std::vector vertices) const -> AdjacencyGraph_t @@ -19,7 +20,7 @@ auto MinimumSpanningTree::prim(std::vector vertices) const -> Adjacenc AdjacencyGraph_t result; if (vertices.empty()) { - return result; //No vertices, so we can't create edges either. + return result; // No vertices, so we can't create edges either. } // If there's only one vertex, we can't go creating any edges so just add the point to the adjacency list with no // edges @@ -33,8 +34,8 @@ auto MinimumSpanningTree::prim(std::vector vertices) const -> Adjacenc result.reserve(vertices.size()); std::vector vertices_list(vertices.begin(), vertices.end()); - std::unordered_map smallest_distance; //The shortest distance to the current tree. - std::unordered_map smallest_distance_to; //Which point the shortest distance goes towards. + std::unordered_map smallest_distance; // The shortest distance to the current tree. + std::unordered_map smallest_distance_to; // Which point the shortest distance goes towards. smallest_distance.reserve(vertices_list.size()); smallest_distance_to.reserve(vertices_list.size()); for (size_t vertex_index = 1; vertex_index < vertices_list.size(); vertex_index++) @@ -44,40 +45,43 @@ auto MinimumSpanningTree::prim(std::vector vertices) const -> Adjacenc smallest_distance_to[&vert] = &vertices_list[0]; } - while (result.size() < vertices_list.size()) //All of the vertices need to be in the tree at the end. + while (result.size() < vertices_list.size()) // All of the vertices need to be in the tree at the end. { - //Choose the closest vertex to connect to that is not yet in the tree. - //This search is O(V) right now, which can be made down to O(log(V)). This reduces the overall time complexity from O(V*V) to O(V*log(E)). - //However that requires an implementation of a heap that supports the decreaseKey operation, which is not in the std library. - //TODO: Implement this? + // Choose the closest vertex to connect to that is not yet in the tree. + // This search is O(V) right now, which can be made down to O(log(V)). This reduces the overall time complexity from O(V*V) to O(V*log(E)). + // However that requires an implementation of a heap that supports the decreaseKey operation, which is not in the std library. + // TODO: Implement this? using MapValue = std::pair; - const auto closest = std::min_element(smallest_distance.begin(), smallest_distance.end(), - [](const MapValue& a, const MapValue& b) { - return a.second < b.second; - }); + const auto closest = std::min_element( + smallest_distance.begin(), + smallest_distance.end(), + [](const MapValue& a, const MapValue& b) + { + return a.second < b.second; + }); - //Add this point to the graph and remove it from the candidates. + // Add this point to the graph and remove it from the candidates. const Point2LL* closest_point = closest->first; const Point2LL other_end = *smallest_distance_to[closest_point]; if (result.find(*closest_point) == result.end()) { result[*closest_point] = std::vector(); } - result[*closest_point].push_back({*closest_point, other_end}); + result[*closest_point].push_back({ *closest_point, other_end }); if (result.find(other_end) == result.end()) { result[other_end] = std::vector(); } - result[other_end].push_back({other_end, *closest_point}); - smallest_distance.erase(closest_point); //Remove it so we don't check for these points again. + result[other_end].push_back({ other_end, *closest_point }); + smallest_distance.erase(closest_point); // Remove it so we don't check for these points again. smallest_distance_to.erase(closest_point); - //Update the distances of all points that are not in the graph. + // Update the distances of all points that are not in the graph. for (std::pair point_and_distance : smallest_distance) { const coord_t new_distance = vSize2(*closest_point - *point_and_distance.first); const coord_t old_distance = point_and_distance.second; - if (new_distance < old_distance) //New point is closer. + if (new_distance < old_distance) // New point is closer. { smallest_distance[point_and_distance.first] = new_distance; smallest_distance_to[point_and_distance.first] = closest_point; @@ -95,8 +99,14 @@ std::vector MinimumSpanningTree::adjacentNodes(Point2LL node) const if (adjacency_entry != adjacency_graph.end()) { const auto& edges = adjacency_entry->second; - std::transform(edges.begin(), edges.end(), std::back_inserter(result), - [&node](const Edge& e) { return (e.start == node) ? e.end : e.start; }); + std::transform( + edges.begin(), + edges.end(), + std::back_inserter(result), + [&node](const Edge& e) + { + return (e.start == node) ? e.end : e.start; + }); } return result; } @@ -106,7 +116,7 @@ std::vector MinimumSpanningTree::leaves() const std::vector result; for (std::pair> node : adjacency_graph) { - if (node.second.size() <= 1) //Leaves are nodes that have only one adjacent edge, or just the one node if the tree contains one node. + if (node.second.size() <= 1) // Leaves are nodes that have only one adjacent edge, or just the one node if the tree contains one node. { result.push_back(node.first); } @@ -117,10 +127,16 @@ std::vector MinimumSpanningTree::leaves() const std::vector MinimumSpanningTree::vertices() const { std::vector result; - using MapValue = std::pair>; - std::transform(adjacency_graph.begin(), adjacency_graph.end(), std::back_inserter(result), - [](const MapValue& node) { return node.first; }); + using MapValue = std::pair>; + std::transform( + adjacency_graph.begin(), + adjacency_graph.end(), + std::back_inserter(result), + [](const MapValue& node) + { + return node.first; + }); return result; } -} +} // namespace cura diff --git a/src/utils/PolygonsSegmentIndex.cpp b/src/utils/PolygonsSegmentIndex.cpp index 08b6238586..0b402a03f6 100644 --- a/src/utils/PolygonsSegmentIndex.cpp +++ b/src/utils/PolygonsSegmentIndex.cpp @@ -1,23 +1,29 @@ -//Copyright (c) 2022 Ultimaker B.V. -//CuraEngine is released under the terms of the AGPLv3 or higher. +// Copyright (c) 2022 Ultimaker B.V. +// CuraEngine is released under the terms of the AGPLv3 or higher. #include "utils/PolygonsSegmentIndex.h" namespace cura { -PolygonsSegmentIndex::PolygonsSegmentIndex() : PolygonsPointIndex() {} +PolygonsSegmentIndex::PolygonsSegmentIndex() + : PolygonsPointIndex() +{ +} -PolygonsSegmentIndex::PolygonsSegmentIndex(const Polygons* polygons, unsigned int poly_idx, unsigned int point_idx) : PolygonsPointIndex(polygons, poly_idx, point_idx) {} +PolygonsSegmentIndex::PolygonsSegmentIndex(const Polygons* polygons, unsigned int poly_idx, unsigned int point_idx) + : PolygonsPointIndex(polygons, poly_idx, point_idx) +{ +} Point2LL PolygonsSegmentIndex::from() const { return PolygonsPointIndex::p(); } - + Point2LL PolygonsSegmentIndex::to() const { return PolygonsSegmentIndex::next().p(); } -} +} // namespace cura diff --git a/src/utils/VoxelUtils.cpp b/src/utils/VoxelUtils.cpp index b55f40c0ce..ddac6713d5 100644 --- a/src/utils/VoxelUtils.cpp +++ b/src/utils/VoxelUtils.cpp @@ -153,7 +153,7 @@ bool VoxelUtils::walkDilatedAreas(const Polygons& polys, coord_t z, const Dilati { Polygons translated = polys; const Point3LL translation = (Point3LL(1, 1, 1) - kernel.kernel_size_ % 2) * cell_size_ / 2 // offset half a cell when using a n even kernel - - cell_size_ / 2; // offset half a cell so that the dots of spreadDotsArea are centered on the middle of the cell isntead of the lower corners. + - cell_size_ / 2; // offset half a cell so that the dots of spreadDotsArea are centered on the middle of the cell isntead of the lower corners. if (translation.x_ && translation.y_) { translated.translate(Point2LL(translation.x_, translation.y_));