From c2cd43094130d45522c565f26900a346265e0d48 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Tue, 26 May 2020 11:09:38 +0200
Subject: [PATCH] Few more include chains broken

---
 src/libslic3r/GCode.cpp                     |  1 +
 src/libslic3r/GCode.hpp                     |  5 ++++-
 src/libslic3r/GCode/PrintExtents.cpp        |  1 +
 src/libslic3r/GCode/ThumbnailData.cpp       |  1 -
 src/libslic3r/GCode/ThumbnailData.hpp       |  2 +-
 src/libslic3r/GCode/ToolOrdering.cpp        |  2 +-
 src/libslic3r/GCode/ToolOrdering.hpp        |  2 ++
 src/libslic3r/Print.hpp                     | 20 ++++++-----------
 src/libslic3r/PrintObject.cpp               | 25 +++++++++++++++++++++
 src/slic3r/GUI/BackgroundSlicingProcess.hpp | 10 ++++-----
 src/slic3r/GUI/GLCanvas3D.cpp               |  1 +
 11 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp
index b5890f578..51dd9f929 100644
--- a/src/libslic3r/GCode.cpp
+++ b/src/libslic3r/GCode.cpp
@@ -7,6 +7,7 @@
 #include "GCode/PrintExtents.hpp"
 #include "GCode/WipeTower.hpp"
 #include "ShortestPath.hpp"
+#include "Print.hpp"
 #include "Utils.hpp"
 #include "libslic3r.h"
 
diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp
index 2daf0fe16..8d4733783 100644
--- a/src/libslic3r/GCode.hpp
+++ b/src/libslic3r/GCode.hpp
@@ -8,7 +8,6 @@
 #include "MotionPlanner.hpp"
 #include "Point.hpp"
 #include "PlaceholderParser.hpp"
-#include "Print.hpp"
 #include "PrintConfig.hpp"
 #include "GCode/CoolingBuffer.hpp"
 #include "GCode/SpiralVase.hpp"
@@ -32,6 +31,10 @@ namespace Slic3r {
 class GCode;
 class GCodePreviewData;
 
+namespace { struct Item; }
+struct PrintInstance;
+using PrintObjectPtrs = std::vector<PrintObject*>;
+
 class AvoidCrossingPerimeters {
 public:
     
diff --git a/src/libslic3r/GCode/PrintExtents.cpp b/src/libslic3r/GCode/PrintExtents.cpp
index 7a8271e30..4a6624531 100644
--- a/src/libslic3r/GCode/PrintExtents.cpp
+++ b/src/libslic3r/GCode/PrintExtents.cpp
@@ -6,6 +6,7 @@
 #include "../BoundingBox.hpp"
 #include "../ExtrusionEntity.hpp"
 #include "../ExtrusionEntityCollection.hpp"
+#include "../Layer.hpp"
 #include "../Print.hpp"
 
 #include "PrintExtents.hpp"
diff --git a/src/libslic3r/GCode/ThumbnailData.cpp b/src/libslic3r/GCode/ThumbnailData.cpp
index 09d564e95..a5941bff1 100644
--- a/src/libslic3r/GCode/ThumbnailData.cpp
+++ b/src/libslic3r/GCode/ThumbnailData.cpp
@@ -1,4 +1,3 @@
-#include "libslic3r/libslic3r.h"
 #include "ThumbnailData.hpp"
 
 namespace Slic3r {
diff --git a/src/libslic3r/GCode/ThumbnailData.hpp b/src/libslic3r/GCode/ThumbnailData.hpp
index 473ef274b..2a302ed85 100644
--- a/src/libslic3r/GCode/ThumbnailData.hpp
+++ b/src/libslic3r/GCode/ThumbnailData.hpp
@@ -24,4 +24,4 @@ typedef std::function<void(ThumbnailsList & thumbnails, const Vec2ds & sizes, bo
 
 } // namespace Slic3r
 
-#endif // slic3r_ThumbnailData_hpp_
\ No newline at end of file
+#endif // slic3r_ThumbnailData_hpp_
diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp
index db398f06c..011420e71 100644
--- a/src/libslic3r/GCode/ToolOrdering.cpp
+++ b/src/libslic3r/GCode/ToolOrdering.cpp
@@ -1,5 +1,6 @@
 #include "Print.hpp"
 #include "ToolOrdering.hpp"
+#include "Layer.hpp"
 
 // #define SLIC3R_DEBUG
 
@@ -15,7 +16,6 @@
 
 #include <libslic3r.h>
 
-#include "../GCodeWriter.hpp"
 
 namespace Slic3r {
 
diff --git a/src/libslic3r/GCode/ToolOrdering.hpp b/src/libslic3r/GCode/ToolOrdering.hpp
index 5fe27516d..e2e07533f 100644
--- a/src/libslic3r/GCode/ToolOrdering.hpp
+++ b/src/libslic3r/GCode/ToolOrdering.hpp
@@ -14,6 +14,8 @@ namespace Slic3r {
 class Print;
 class PrintObject;
 class LayerTools;
+namespace CustomGCode { struct Item; }
+class PrintRegion;
 
 
 
diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp
index 54ebceeb6..5fb395fb1 100644
--- a/src/libslic3r/Print.hpp
+++ b/src/libslic3r/Print.hpp
@@ -4,10 +4,9 @@
 #include "PrintBase.hpp"
 
 #include "BoundingBox.hpp"
+#include "ExtrusionEntityCollection.hpp"
 #include "Flow.hpp"
 #include "Point.hpp"
-#include "Layer.hpp"
-#include "Model.hpp"
 #include "Slicing.hpp"
 #include "GCode/ToolOrdering.hpp"
 #include "GCode/WipeTower.hpp"
@@ -23,6 +22,8 @@ class ModelObject;
 class GCode;
 class GCodePreviewData;
 enum class SlicingMode : uint32_t;
+class Layer;
+class SupportLayer;
 
 // Print step IDs for keeping track of the print state.
 enum PrintStep {
@@ -147,18 +148,11 @@ public:
     const Layer* 	get_layer(int idx) const { return m_layers[idx]; }
     Layer* 			get_layer(int idx) 		 { return m_layers[idx]; }
     // Get a layer exactly at print_z.
-    const Layer*	get_layer_at_printz(coordf_t print_z) const {
-        auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; });
-		return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it;
-	}
-    Layer*			get_layer_at_printz(coordf_t print_z) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z)); }
+    const Layer*	get_layer_at_printz(coordf_t print_z) const;
+    Layer*			get_layer_at_printz(coordf_t print_z);
     // Get a layer approximately at print_z.
-    const Layer*	get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const {
-        coordf_t limit = print_z - epsilon;
-        auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; });
-        return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it;
-	}
-    Layer*			get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); }
+    const Layer*	get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const;
+    Layer*			get_layer_at_printz(coordf_t print_z, coordf_t epsilon);
 
     // print_z: top of the layer; slice_z: center of the layer.
     Layer* add_layer(int id, coordf_t height, coordf_t print_z, coordf_t slice_z);
diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp
index 5174fd6e9..a5cb54485 100644
--- a/src/libslic3r/PrintObject.cpp
+++ b/src/libslic3r/PrintObject.cpp
@@ -4,6 +4,7 @@
 #include "ElephantFootCompensation.hpp"
 #include "Geometry.hpp"
 #include "I18N.hpp"
+#include "Layer.hpp"
 #include "SupportMaterial.hpp"
 #include "Surface.hpp"
 #include "Slicing.hpp"
@@ -2829,4 +2830,28 @@ void PrintObject::project_and_append_custom_supports(
     } // loop over ModelVolumes
 }
 
+
+
+const Layer* PrintObject::get_layer_at_printz(coordf_t print_z) const {
+    auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [print_z](const Layer *layer) { return layer->print_z < print_z; });
+    return (it == m_layers.end() || (*it)->print_z != print_z) ? nullptr : *it;
+}
+
+
+
+Layer* PrintObject::get_layer_at_printz(coordf_t print_z) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z)); }
+
+
+
+// Get a layer approximately at print_z.
+const Layer* PrintObject::get_layer_at_printz(coordf_t print_z, coordf_t epsilon) const {
+    coordf_t limit = print_z - epsilon;
+    auto it = Slic3r::lower_bound_by_predicate(m_layers.begin(), m_layers.end(), [limit](const Layer *layer) { return layer->print_z < limit; });
+    return (it == m_layers.end() || (*it)->print_z > print_z + epsilon) ? nullptr : *it;
+}
+
+
+
+Layer* PrintObject::get_layer_at_printz(coordf_t print_z, coordf_t epsilon) { return const_cast<Layer*>(std::as_const(*this).get_layer_at_printz(print_z, epsilon)); }
+
 } // namespace Slic3r
diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp
index efaea1d11..38e9e1075 100644
--- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp
+++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp
@@ -5,22 +5,22 @@
 #include <condition_variable>
 #include <mutex>
 
-#include <boost/filesystem/path.hpp>
-
 #include <wx/event.h>
 
-#include "libslic3r/Print.hpp"
+#include "libslic3r/PrintBase.hpp"
+#include "libslic3r/GCode/ThumbnailData.hpp"
 #include "libslic3r/Format/SL1.hpp"
 #include "slic3r/Utils/PrintHost.hpp"
 
 
+namespace boost { namespace filesystem { class path; } }
+
 namespace Slic3r {
 
 class DynamicPrintConfig;
 class GCodePreviewData;
 class Model;
 class SLAPrint;
-class SL1Archive;
 
 class SlicingStatusEvent : public wxEvent
 {
@@ -86,7 +86,7 @@ public:
 
 	// Apply config over the print. Returns false, if the new config values caused any of the already
 	// processed steps to be invalidated, therefore the task will need to be restarted.
-	Print::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
+    PrintBase::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config);
 	// After calling the apply() function, set_task() may be called to limit the task to be processed by process().
 	// This is useful for calculating SLA supports for a single object only.
 	void 		set_task(const PrintBase::TaskParams &params);
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 90a82f76d..1266fef4c 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -9,6 +9,7 @@
 #include "libslic3r/GCode/ThumbnailData.hpp"
 #include "libslic3r/Geometry.hpp"
 #include "libslic3r/ExtrusionEntity.hpp"
+#include "libslic3r/Layer.hpp"
 #include "libslic3r/Utils.hpp"
 #include "libslic3r/Technologies.hpp"
 #include "libslic3r/Tesselate.hpp"