mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-09 08:41:14 +00:00
* Add Missing Includes Across src/libslic3r Every libslic3r source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, with libslic3r headers spelled libslic3r/... so they resolve outside the library's private include paths. MultiMaterialSegmentation.hpp, Support/SupportParameters.hpp and Format/STEP.hpp are made self-contained by hand. * 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. * Add the Includes Missing From the Hand-Fixed libslic3r Headers clang-tidy would not edit these headers while they failed to compile on their own, so the first pass skipped them. With the headers now self-contained, a second pass adds the rest. * Keep Windows Setup Ahead of the Added libslic3r Includes Print.cpp and Thread.cpp open with a _WIN32 block that has to come first; without the precompiled header, Print.cpp otherwise reaches windows.h through OCCT with NONLS defined and boost/regex fails. OpenVDBUtils.cpp and SLA/SupportTreeBuilder.cpp had includes inside #ifndef NOMINMAX, which libslic3r defines on Windows, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory. * Re-Add libslic3r Includes After the Clipper2 2.0.1 Migration Rebasing onto main took main's version of the files the Clipper2 migration rewrote, so their added includes are restored here, along with includes for main's new code. Clipper2's individual headers are now ignored by clang-tidy: they only build the Z variant through clipper2_z.hpp, which defines USINGZ first, so including clipper.core.h and the like directly broke ClipperZUtils.cpp.
111 lines
4.6 KiB
C++
111 lines
4.6 KiB
C++
#ifndef FILAMENT_GROUP_UTILS_HPP
|
|
#define FILAMENT_GROUP_UTILS_HPP
|
|
|
|
#include <set>
|
|
#include <unordered_map>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include <exception>
|
|
|
|
#include "PrintConfig.hpp"
|
|
#include "MultiNozzleUtils.hpp"
|
|
|
|
namespace Slic3r
|
|
{
|
|
namespace FilamentGroupUtils
|
|
{
|
|
struct Color
|
|
{
|
|
unsigned char r = 0;
|
|
unsigned char g = 0;
|
|
unsigned char b = 0;
|
|
unsigned char a = 255;
|
|
Color(unsigned char r_ = 0, unsigned char g_ = 0, unsigned char b_ = 0, unsigned a_ = 255) :r(r_), g(g_), b(b_), a(a_) {}
|
|
Color(const std::string& hexstr);
|
|
bool operator<(const Color& other) const;
|
|
bool operator==(const Color& other) const;
|
|
bool operator!=(const Color& other) const;
|
|
std::string to_hex_str(bool include_alpha = false) const;
|
|
};
|
|
|
|
|
|
struct FilamentInfo {
|
|
Color color;
|
|
std::string type;
|
|
bool is_support;
|
|
// How this filament is used across the model. Orca's shipping grouping
|
|
// algorithm does not read it yet; defaulted so a default-built FilamentInfo
|
|
// is deterministic. The nozzle-centric engine consumes it later.
|
|
FilamentUsageType usage_type = FilamentUsageType::ModelOnly;
|
|
};
|
|
|
|
struct MachineFilamentInfo: public FilamentInfo {
|
|
int extruder_id;
|
|
bool is_extended;
|
|
bool operator<(const MachineFilamentInfo& other) const;
|
|
};
|
|
|
|
|
|
class FilamentGroupException: public std::exception {
|
|
public:
|
|
enum ErrorCode {
|
|
EmptyAmsFilaments,
|
|
ConflictLimits,
|
|
Unknown
|
|
};
|
|
|
|
private:
|
|
ErrorCode code_;
|
|
std::string message_;
|
|
|
|
public:
|
|
FilamentGroupException(ErrorCode code, const std::string& message)
|
|
: code_(code), message_(message) {}
|
|
|
|
ErrorCode code() const noexcept {
|
|
return code_;
|
|
}
|
|
|
|
const char* what() const noexcept override {
|
|
return message_.c_str();
|
|
}
|
|
};
|
|
|
|
std::vector<int> calc_max_group_size(const std::vector<std::map<int, int>>& ams_counts,bool ignore_ext_filament);
|
|
|
|
std::vector<std::vector<MachineFilamentInfo>> build_machine_filaments(const std::vector<std::vector<DynamicPrintConfig>>& filament_configs, const std::vector<std::map<int, int>>& ams_counts, bool ignore_ext_filament);
|
|
|
|
bool collect_unprintable_limits(const std::vector<std::set<int>>& physical_unprintables, const std::vector<std::set<int>>& geometric_unprintables, std::vector<std::set<int>>& unprintable_limits);
|
|
|
|
bool remove_intersection(std::set<int>& a, std::set<int>& b);
|
|
|
|
void extract_indices(const std::vector<unsigned int>& used_filaments, const std::vector<std::set<int>>& unprintable_elems, std::vector<std::set<int>>& unprintable_idxs);
|
|
|
|
void extract_unprintable_limit_indices(const std::vector<std::set<int>>& unprintable_elems, const std::vector<unsigned int>& used_filaments, std::map<int, int>& unplaceable_limits);
|
|
|
|
void extract_unprintable_limit_indices(const std::vector<std::set<int>>& unprintable_elems, const std::vector<unsigned int>& used_filaments, std::unordered_map<int, std::vector<int>>& unplaceable_limits);
|
|
|
|
bool check_printable(const std::vector<std::set<int>>& groups, const std::map<int, int>& unprintable);
|
|
|
|
// Nozzle-centric grouping helpers. The estimate helpers read a LayeredNozzleGroupResult's
|
|
// per-layer extruder/nozzle usage; the two builders support building the grouping context
|
|
// (extruder->nozzle inventory) and writing back a resolved map onto only the used-filament
|
|
// slots.
|
|
int get_estimate_extruder_change_count(const std::vector<std::vector<unsigned int>>& layer_filaments, const MultiNozzleUtils::LayeredNozzleGroupResult& extruder_nozzle_info);
|
|
|
|
int get_estimate_nozzle_change_count(const std::vector<std::vector<unsigned int>>& layer_filaments, const MultiNozzleUtils::LayeredNozzleGroupResult& extruder_nozzle_info);
|
|
|
|
std::pair<int, int> get_estimate_extruder_filament_change_count(const MultiNozzleUtils::LayeredNozzleGroupResult& extruder_nozzle_info);
|
|
|
|
std::map<int, std::vector<int>> build_extruder_nozzle_list(const std::vector<MultiNozzleUtils::NozzleInfo>& nozzle_list);
|
|
|
|
std::vector<int> update_used_filament_values(const std::vector<int>& old_values, const std::vector<int>& new_values, const std::vector<unsigned int>& used_filaments);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif |