mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 23:31:19 +00:00
* 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
189 lines
7.7 KiB
C++
189 lines
7.7 KiB
C++
#ifndef slic3r_PerimeterGenerator_hpp_
|
|
#define slic3r_PerimeterGenerator_hpp_
|
|
|
|
#include "Point.hpp"
|
|
#include "Surface.hpp"
|
|
#include "libslic3r.h"
|
|
#include <functional>
|
|
#include <cstddef>
|
|
#include <boost/container_hash/hash.hpp>
|
|
#include <optional>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include "Layer.hpp"
|
|
#include "Flow.hpp"
|
|
#include "Polygon.hpp"
|
|
#include "PrintConfig.hpp"
|
|
#include "Config.hpp"
|
|
#include "ExPolygon.hpp"
|
|
|
|
namespace Slic3r { class ExtrusionEntityCollection; }
|
|
namespace Slic3r { class SurfaceCollection; }
|
|
|
|
namespace Slic3r {
|
|
struct FuzzySkinConfig
|
|
{
|
|
FuzzySkinType type;
|
|
coord_t thickness;
|
|
coord_t point_distance;
|
|
bool fuzzy_first_layer;
|
|
NoiseType noise_type;
|
|
double noise_scale;
|
|
int noise_octaves;
|
|
double noise_persistence;
|
|
FuzzySkinMode mode;
|
|
int ripples_per_layer;
|
|
double ripple_offset;
|
|
int layers_between_ripple_offset;
|
|
int layer_id;
|
|
|
|
bool operator==(const FuzzySkinConfig& r) const
|
|
{
|
|
return type == r.type
|
|
&& thickness == r.thickness
|
|
&& point_distance == r.point_distance
|
|
&& fuzzy_first_layer == r.fuzzy_first_layer
|
|
&& noise_type == r.noise_type
|
|
&& noise_scale == r.noise_scale
|
|
&& noise_octaves == r.noise_octaves
|
|
&& noise_persistence == r.noise_persistence
|
|
&& mode == r.mode
|
|
&& ripples_per_layer == r.ripples_per_layer
|
|
&& ripple_offset == r.ripple_offset
|
|
&& layers_between_ripple_offset == r.layers_between_ripple_offset;
|
|
}
|
|
|
|
bool operator!=(const FuzzySkinConfig& r) const { return !(*this == r); }
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
template<> struct hash<Slic3r::FuzzySkinConfig>
|
|
{
|
|
size_t operator()(const Slic3r::FuzzySkinConfig& c) const noexcept
|
|
{
|
|
std::size_t seed = std::hash<Slic3r::FuzzySkinType>{}(c.type);
|
|
boost::hash_combine(seed, std::hash<coord_t>{}(c.thickness));
|
|
boost::hash_combine(seed, std::hash<coord_t>{}(c.point_distance));
|
|
boost::hash_combine(seed, std::hash<bool>{}(c.fuzzy_first_layer));
|
|
boost::hash_combine(seed, std::hash<Slic3r::NoiseType>{}(c.noise_type));
|
|
boost::hash_combine(seed, std::hash<double>{}(c.noise_scale));
|
|
boost::hash_combine(seed, std::hash<int>{}(c.noise_octaves));
|
|
boost::hash_combine(seed, std::hash<double>{}(c.noise_persistence));
|
|
boost::hash_combine(seed, std::hash<Slic3r::FuzzySkinMode>{}(c.mode));
|
|
boost::hash_combine(seed, std::hash<int>{}(c.ripples_per_layer));
|
|
boost::hash_combine(seed, std::hash<double>{}(c.ripple_offset));
|
|
boost::hash_combine(seed, std::hash<int>{}(c.layers_between_ripple_offset));
|
|
return seed;
|
|
}
|
|
};
|
|
} // namespace std
|
|
|
|
namespace Slic3r {
|
|
|
|
class PerimeterGenerator {
|
|
public:
|
|
// Inputs:
|
|
const SurfaceCollection *slices;
|
|
const LayerRegionPtrs *compatible_regions;
|
|
const ExPolygons *upper_slices;
|
|
const SurfaceCollection *upper_slices_same_region;
|
|
const ExPolygons *lower_slices;
|
|
double layer_height;
|
|
int layer_id;
|
|
coordf_t slice_z;
|
|
Flow perimeter_flow;
|
|
Flow ext_perimeter_flow;
|
|
Flow overhang_flow;
|
|
Flow solid_infill_flow;
|
|
const PrintRegionConfig *config;
|
|
const PrintObjectConfig *object_config;
|
|
const PrintConfig *print_config;
|
|
// Outputs:
|
|
ExtrusionEntityCollection *loops;
|
|
ExtrusionEntityCollection *gap_fill;
|
|
SurfaceCollection *fill_surfaces;
|
|
//BBS
|
|
ExPolygons *fill_no_overlap;
|
|
|
|
//BBS
|
|
Flow smaller_ext_perimeter_flow;
|
|
std::vector<Polygons> m_lower_polygons_series;
|
|
std::vector<Polygons> m_external_lower_polygons_series;
|
|
std::vector<Polygons> m_smaller_external_lower_polygons_series;
|
|
|
|
bool has_fuzzy_skin = false;
|
|
bool has_fuzzy_hole = false;
|
|
// Preserve construction order so overlap precedence remains deterministic.
|
|
std::vector<std::pair<FuzzySkinConfig, ExPolygons>> regions_by_fuzzify;
|
|
// Area resting on the layer below, where fuzzy skin is allowed. Unset means no restriction.
|
|
std::optional<ExPolygons> fuzzy_supported_area;
|
|
|
|
PerimeterGenerator(
|
|
// Input:
|
|
const SurfaceCollection* slices,
|
|
const LayerRegionPtrs *compatible_regions,
|
|
double layer_height,
|
|
coordf_t slice_z,
|
|
Flow flow,
|
|
const PrintRegionConfig* config,
|
|
const PrintObjectConfig* object_config,
|
|
const PrintConfig* print_config,
|
|
const bool spiral_mode,
|
|
const double model_rotation_rad,
|
|
// Output:
|
|
// Loops with the external thin walls
|
|
ExtrusionEntityCollection* loops,
|
|
// Gaps without the thin walls
|
|
ExtrusionEntityCollection* gap_fill,
|
|
// Infills without the gap fills
|
|
SurfaceCollection* fill_surfaces,
|
|
//BBS
|
|
ExPolygons* fill_no_overlap)
|
|
: slices(slices), compatible_regions(compatible_regions), upper_slices(nullptr), lower_slices(nullptr), layer_height(layer_height),
|
|
slice_z(slice_z), layer_id(-1), perimeter_flow(flow), ext_perimeter_flow(flow),
|
|
overhang_flow(flow), solid_infill_flow(flow),
|
|
config(config), object_config(object_config), print_config(print_config),
|
|
m_spiral_vase(spiral_mode),
|
|
m_scaled_resolution(scaled<double>(print_config->resolution.value > EPSILON ? print_config->resolution.value : EPSILON)),
|
|
m_model_rotation_rad(model_rotation_rad),
|
|
loops(loops), gap_fill(gap_fill), fill_surfaces(fill_surfaces), fill_no_overlap(fill_no_overlap),
|
|
m_ext_mm3_per_mm(-1), m_mm3_per_mm(-1), m_mm3_per_mm_overhang(-1), m_ext_mm3_per_mm_smaller_width(-1)
|
|
{}
|
|
|
|
void process_classic();
|
|
void process_arachne();
|
|
|
|
void add_infill_contour_for_arachne( ExPolygons infill_contour, int loops, coord_t ext_perimeter_spacing, coord_t perimeter_spacing, coord_t min_perimeter_infill_spacing, coord_t spacing, bool is_inner_part );
|
|
|
|
double ext_mm3_per_mm() const { return m_ext_mm3_per_mm; }
|
|
double mm3_per_mm() const { return m_mm3_per_mm; }
|
|
double mm3_per_mm_overhang() const { return m_mm3_per_mm_overhang; }
|
|
//BBS
|
|
double smaller_width_ext_mm3_per_mm() const { return m_ext_mm3_per_mm_smaller_width; }
|
|
Polygons lower_slices_polygons() const { return m_lower_slices_polygons; }
|
|
// ORCA: the slices less the slivers the wall generator prints nothing for, so they never count as support.
|
|
ExPolygons printable_slices(const ExPolygons &slices) const;
|
|
|
|
private:
|
|
std::vector<Polygons> generate_lower_polygons_series(float width);
|
|
void split_top_surfaces(const ExPolygons &orig_polygons, ExPolygons &top_fills, ExPolygons &non_top_polygons, ExPolygons &fill_clip) const;
|
|
void apply_extra_perimeters(ExPolygons& infill_area);
|
|
void process_no_bridge(Surfaces& all_surfaces, coord_t perimeter_spacing, coord_t ext_perimeter_width);
|
|
|
|
private:
|
|
bool m_spiral_vase;
|
|
double m_scaled_resolution;
|
|
double m_model_rotation_rad;
|
|
double m_ext_mm3_per_mm;
|
|
double m_mm3_per_mm;
|
|
double m_mm3_per_mm_overhang;
|
|
//BBS
|
|
double m_ext_mm3_per_mm_smaller_width;
|
|
Polygons m_lower_slices_polygons;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|