Make the libslic3r Headers Compile on Their Own

Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Left out: I18N.hpp, which errors on purpose when included from GUI code, and VoxelizeCSGMesh.hpp and SLA/bicubic.h, which nothing includes and which no longer compile at all.
This commit is contained in:
Hanif Koh
2026-10-02 21:46:20 +08:00
parent fdf8ef7852
commit 67108725de
17 changed files with 35 additions and 0 deletions
+2
View File
@@ -2,6 +2,8 @@
#define CSGMESH_HPP
#include <libslic3r/AnyPtr.hpp>
#include <libslic3r/Point.hpp>
#include <libslic3r/TriangleMesh.hpp>
#include <admesh/stl.h>
namespace Slic3r { namespace csg {
+1
View File
@@ -2,6 +2,7 @@
#define CSGMESHCOPY_HPP
#include "CSGMesh.hpp"
#include "libslic3r/libslic3r.h"
namespace Slic3r { namespace csg {
@@ -4,6 +4,8 @@
#include <stack>
#include <vector>
#include <boost/log/trivial.hpp>
#include "CSGMesh.hpp"
#include "libslic3r/Execution/ExecutionTBB.hpp"
+1
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include <clipper2/clipper2_z.hpp>
#include <libslic3r/ExPolygon.hpp>
#include <libslic3r/Point.hpp>
namespace Slic3r { namespace Clipper2ZUtils {
+1
View File
@@ -1,6 +1,7 @@
#ifndef slic3r_Format_3mf_hpp_
#define slic3r_Format_3mf_hpp_
#include <expat.h>
#include <string>
namespace Slic3r {
// PrusaFileParser is used to check 3mf file is from Prusa
+1
View File
@@ -5,6 +5,7 @@ namespace Slic3r {
class Model;
class DynamicPrintConfig;
struct ConfigSubstitutionContext;
// Load the content of an amf file into the given model and configuration.
extern bool load_amf(const char* path, DynamicPrintConfig* config, ConfigSubstitutionContext* config_substitutions, Model* model, bool* use_inches);
+4
View File
@@ -2,6 +2,10 @@
#define slic3r_Format_OBJ_hpp_
#include "libslic3r/Color.hpp"
#include "objparser.hpp"
#include "libslic3r/Point.hpp"
#include <admesh/stl.h>
#include <functional>
#include <map>
#include <unordered_map>
namespace Slic3r {
+1
View File
@@ -6,6 +6,7 @@
#include <array>
#include <unordered_map>
#include <istream>
#include <memory>
namespace ObjParser {
+3
View File
@@ -1,4 +1,7 @@
#pragma once
#include <string>
namespace Slic3r {
class Model;
@@ -11,12 +11,14 @@
#include <regex>
#include <memory>
#include <map>
#include <unordered_map>
#include "AdaptivePAInterpolator.hpp"
namespace Slic3r {
// Forward declaration of GCode class
class GCode;
class PrintConfig;
/**
* @brief Class for processing G-code layers with adaptive pressure advance.
+2
View File
@@ -2,6 +2,7 @@
#define slic3r_CoolingBuffer_hpp_
#include "../libslic3r.h"
#include "../Point.hpp"
#include <map>
#include <string>
#include <cfloat>
@@ -10,6 +11,7 @@ namespace Slic3r {
class GCode;
class Layer;
class PrintConfig;
struct PerExtruderAdjustments;
// A standalone G-code filter, to control cooling of the print.
@@ -2,6 +2,7 @@
#define slic3r_GCode_PressureEqualizer_hpp_
#include "../libslic3r.h"
#include "../ExtrusionEntity.hpp"
#include "../PrintConfig.hpp"
#include <queue>
+1
View File
@@ -6,6 +6,7 @@
#include <string>
#include <vector>
#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <boost/bind/bind.hpp>
#include <boost/thread.hpp>
+2
View File
@@ -7,6 +7,8 @@
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iomanip>
// Marching squares
//
+5
View File
@@ -1,8 +1,13 @@
#ifndef Slic3r_MeasureUtils_hpp_
#define Slic3r_MeasureUtils_hpp_
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include "Point.hpp"
namespace Slic3r {
namespace Measure {
+4
View File
@@ -2,7 +2,11 @@
#define slic3r_MutablePriorityQueue_hpp_
#include <assert.h>
#include <cstddef>
#include <limits>
#include <type_traits>
#include <utility>
#include <vector>
constexpr auto InvalidQueueID = std::numeric_limits<size_t>::max();
template<typename T, typename IndexSetter, typename LessPredicate, const bool ResetIndexWhenRemoved = false>
class MutablePriorityQueue
+2
View File
@@ -3,6 +3,8 @@
#include <functional>
#include <vector>
#include <admesh/stl.h>
#include "Polygon.hpp"
#include "ExPolygon.hpp"