Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced (#16099)

* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced

Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes.

clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer.

* Remove Unused Project Includes From Files With Platform-Specific Code

A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block.

* Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass

The platform-file pass treated pchheader.hpp as an ordinary header and
emptied it, and left GUI_Preview.hpp and 14 other files relying on
headers they no longer reached directly.

* Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call

* Include Headers That Files Reached Through Ones the Cleanup Removed

* Drop Includes Duplicated by the Cleanup or by Main's Own Additions

* Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
This commit is contained in:
HanifKoh
2026-10-05 16:47:17 +08:00
committed by GitHub
parent 86153752e6
commit 4895bc03b4
623 changed files with 1512 additions and 753 deletions
@@ -19,6 +19,9 @@
#include <cctype>
#include <string>
#include <utility>
#include "libslic3r/Config.hpp"
#include "libslic3r/GCodeWriter.hpp"
#include "libslic3r/PrintConfig.hpp"
namespace Slic3r {
@@ -6,7 +6,6 @@
#include "../ExPolygon.hpp"
#include "../Geometry.hpp"
#include "../ClipperUtils.hpp"
#include "../SVG.hpp"
#include "libslic3r/Line.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/Point.hpp"
@@ -31,6 +30,10 @@
#include <boost/range/adaptor/reversed.hpp>
#include <vector>
#include <utility>
#include "libslic3r/Extruder.hpp"
#include "libslic3r/GCodeWriter.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/SurfaceCollection.hpp"
namespace Slic3r {
@@ -1,13 +1,13 @@
#ifndef slic3r_AvoidCrossingPerimeters_hpp_
#define slic3r_AvoidCrossingPerimeters_hpp_
#include "../libslic3r.h"
#include "../ExPolygon.hpp"
#include "../EdgeGrid.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/BoundingBox.hpp"
#include <vector>
#include "libslic3r/MultiMaterialSegmentation.hpp"
namespace Slic3r {
+1
View File
@@ -23,6 +23,7 @@
#include <atomic>
#include <utility>
#include <vector>
#include "libslic3r/Model.hpp"
namespace Slic3r {
+2 -3
View File
@@ -1,15 +1,12 @@
#ifndef slic3r_ConflictChecker_hpp_
#define slic3r_ConflictChecker_hpp_
#include "../Utils.hpp"
#include "../Model.hpp"
#include "../Print.hpp"
#include "../Layer.hpp"
#include "libslic3r/Line.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include <queue>
@@ -20,6 +17,8 @@
#include <vector>
#include <optional>
namespace Slic3r { class ExtrusionEntityCollection; }
namespace Slic3r {
struct LineWithID
+3
View File
@@ -30,6 +30,9 @@
#endif
#include <assert.h>
#include "libslic3r/Config.hpp"
#include "libslic3r/GCodeWriter.hpp"
#include "libslic3r/PrintConfig.hpp"
namespace Slic3r {
-1
View File
@@ -1,7 +1,6 @@
#ifndef slic3r_CoolingBuffer_hpp_
#define slic3r_CoolingBuffer_hpp_
#include "../libslic3r.h"
#include "../Point.hpp"
#include <cstddef>
#include <map>
+2
View File
@@ -33,6 +33,8 @@
#include <boost/log/trivial.hpp>
#include <string>
#include <string_view>
#include "libslic3r/Config.hpp"
#include "libslic3r/GCodeWriter.hpp"
*/
-3
View File
@@ -2,11 +2,8 @@
#define slic3r_GCode_FanMover_hpp_
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../ExtrusionEntity.hpp"
#include "../Point.hpp"
#include "../GCodeReader.hpp"
#include "../GCodeWriter.hpp"
#include <cstdint>
+2 -1
View File
@@ -1,9 +1,9 @@
#include "libslic3r/ArcFitter.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/CustomGCode.hpp"
#include "libslic3r/Exception.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/CommonDefs.hpp"
#include "libslic3r/ArcFitter.hpp"
#include "ExtrusionEntity.hpp"
#include "libslic3r/GCodeReader.hpp"
#include "GCodeWriter.hpp"
@@ -73,6 +73,7 @@
#include <chrono>
#include "Geometry/ArcWelder.hpp"
#include "libslic3r/MultiNozzleUtils.hpp"
static const float DEFAULT_TOOLPATH_WIDTH = 0.4f;
static const float DEFAULT_TOOLPATH_HEIGHT = 0.2f;
@@ -17,6 +17,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include "libslic3r/Print.hpp"
namespace Slic3r {
+2 -2
View File
@@ -3,10 +3,8 @@
#ifndef slic3r_OrderingStrategies_hpp_
#define slic3r_OrderingStrategies_hpp_
#include "../libslic3r.h"
#include "../Point.hpp"
#include <cstddef>
#include "libslic3r/PrintConfig.hpp"
#ifndef SLIC3R_TEST_HARNESS
#include "../Print.hpp"
@@ -17,6 +15,8 @@
#include <utility>
#include <vector>
namespace Slic3r { enum class PrintOrder; }
namespace Slic3r {
// --- Path improvement (operate on index vectors into `centers`) ---
+1 -2
View File
@@ -13,9 +13,7 @@
#include <algorithm>
#include <string>
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../LocalesUtils.hpp"
#include "../GCode.hpp"
#include "PressureEqualizer.hpp"
@@ -23,6 +21,7 @@
#include "libslic3r/Exception.hpp"
#include "fast_float/fast_float.h"
#include "GCodeWriter.hpp"
#include "libslic3r/Config.hpp"
namespace Slic3r {
@@ -1,7 +1,6 @@
#ifndef slic3r_GCode_PressureEqualizer_hpp_
#define slic3r_GCode_PressureEqualizer_hpp_
#include "../libslic3r.h"
#include "../ExtrusionEntity.hpp"
#include "../PrintConfig.hpp"
#include <string>
+2
View File
@@ -20,6 +20,8 @@
#include <Eigen/Geometry>
#include <vector>
#include <cstddef>
#include "libslic3r/Config.hpp"
#include "libslic3r/PrintConfig.hpp"
namespace Slic3r {
@@ -12,6 +12,8 @@
#include "libslic3r/Polygon.hpp"
#include "RetractWhenCrossingPerimeters.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/SurfaceCollection.hpp"
namespace Slic3r {
-5
View File
@@ -14,11 +14,6 @@
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/AABBTreeIndirect.hpp"
#include "libslic3r/KDTreeIndirect.hpp"
namespace Slic3r {
@@ -16,7 +16,6 @@
#include <memory>
#include <regex>
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "libslic3r/Exception.hpp"
#include "libslic3r/GCode/PchipInterpolatorHelper.hpp"
@@ -26,6 +25,7 @@
#include <boost/log/trivial.hpp>
#include <sstream>
#include <string>
#include "libslic3r/Config.hpp"
namespace Slic3r {
@@ -1,12 +1,13 @@
#ifndef slic3r_GCode_SmallAreaInfillFlowCompensator_hpp_
#define slic3r_GCode_SmallAreaInfillFlowCompensator_hpp_
#include "../libslic3r.h"
#include "../PrintConfig.hpp"
#include "../ExtrusionEntity.hpp"
#include "PchipInterpolatorHelper.hpp"
#include <memory>
#include <vector>
#include <cstdint>
class PchipInterpolatorHelper;
namespace Slic3r { enum ExtrusionRole : uint8_t; }
namespace Slic3r {
+2 -1
View File
@@ -1,5 +1,4 @@
#include "SpiralVase.hpp"
#include "GCode.hpp"
#include "libslic3r/libslic3r.h"
#include <algorithm>
#include <cstddef>
@@ -8,6 +7,8 @@
#include <limits>
#include <vector>
#include <string>
#include "libslic3r/GCodeReader.hpp"
#include "libslic3r/PrintConfig.hpp"
namespace Slic3r {
+1 -1
View File
@@ -1,12 +1,12 @@
#ifndef slic3r_SpiralVase_hpp_
#define slic3r_SpiralVase_hpp_
#include "../libslic3r.h"
#include "../GCodeReader.hpp"
#include "libslic3r/PrintConfig.hpp"
#include <cstddef>
#include <string>
#include <vector>
#include "libslic3r/Config.hpp"
namespace Slic3r {
-1
View File
@@ -1,5 +1,4 @@
#include "Thumbnails.hpp"
#include "../miniz_extension.hpp"
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/Point.hpp"
+2 -2
View File
@@ -4,9 +4,7 @@
#include "../Point.hpp"
#include "../PrintConfig.hpp"
#include "../enum_bitmask.hpp"
#include "libslic3r/Config.hpp"
#include "ThumbnailData.hpp"
#include "../enum_bitmask.hpp"
#include <cstddef>
#include <string>
@@ -17,6 +15,8 @@
#include <boost/beast/core/detail/base64.hpp>
namespace Slic3r { class ConfigBase; }
namespace Slic3r {
enum class ThumbnailError : int { InvalidVal, OutOfRange, InvalidExt };
using ThumbnailErrors = enum_bitmask<ThumbnailError>;
@@ -18,6 +18,9 @@
#include <limits>
#include "libslic3r/Utils.hpp"
#include "libslic3r/Polyline.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/Slicing.hpp"
constexpr int FILTER_THRESHOLD = 5;
constexpr int MAX_CANDIDATE_SIZE = 5;
+3 -1
View File
@@ -9,7 +9,9 @@
#include "libslic3r/Point.hpp"
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/Print.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/MultiMaterialSegmentation.hpp"
namespace Slic3r { enum class PrintSequence; }
namespace Slic3r {
+5
View File
@@ -52,6 +52,11 @@
#include <unordered_map>
#include <libslic3r.h>
#include "libslic3r/ExPolygon.hpp"
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Polygon.hpp"
#include "libslic3r/SurfaceCollection.hpp"
namespace Slic3r {
+4 -2
View File
@@ -18,13 +18,15 @@
#include <boost/container/small_vector.hpp>
#include <vector>
#include "../FilamentGroup.hpp"
#include "../FilamentMixer.hpp"
#include "../MultiNozzleUtils.hpp"
#include "../ExtrusionEntity.hpp"
#include "../ObjectID.hpp"
#include "../PrintConfig.hpp"
namespace Slic3r { class ExtrusionEntity; }
namespace Slic3r { class ExtrusionEntityCollection; }
namespace Slic3r { enum ExtrusionRole : uint8_t; }
namespace Slic3r {
class Print;
+1
View File
@@ -14,6 +14,7 @@
#include <optional>
#include <tuple>
#include <utility>
#include "libslic3r/Polyline.hpp"
namespace Slic3r {
+1
View File
@@ -34,6 +34,7 @@
#include "libslic3r/TriangleMesh.hpp"
#include "Triangulation.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/Config.hpp"
namespace Slic3r
+1 -1
View File
@@ -37,10 +37,10 @@
#include "libslic3r/Polyline.hpp"
#include "PrintConfig.hpp"
#include "Surface.hpp"
#include "Fill/FillRectilinear.hpp"
#include "libslic3r/libslic3r.h"
#include <boost/algorithm/string/predicate.hpp>
#include "libslic3r/Config.hpp"
namespace Slic3r
+2
View File
@@ -16,6 +16,8 @@
#include "libslic3r/Point.hpp"
#include "libslic3r/Polygon.hpp"
#include "WipeTower.hpp"
#include "libslic3r/BoundingBox.hpp"
#include "libslic3r/PrintConfig.hpp"
namespace Slic3r
{
@@ -12,6 +12,7 @@
#include <cstddef>
#include <set>
#include <vector>
#include "libslic3r/clonable_ptr.hpp"
namespace Slic3r {