mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +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.
146 lines
4.9 KiB
C++
146 lines
4.9 KiB
C++
#ifndef slic3r_EmbossShape_hpp_
|
|
#define slic3r_EmbossShape_hpp_
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
#include <memory> // unique_ptr
|
|
#include <cereal/cereal.hpp>
|
|
#include <cereal/types/string.hpp>
|
|
#include <cereal/types/vector.hpp>
|
|
#include <cereal/types/optional.hpp>
|
|
#include <cereal/archives/binary.hpp>
|
|
#include <vector>
|
|
#include "Point.hpp" // Transform3d
|
|
#include "ExPolygon.hpp"
|
|
#include "ExPolygonSerialize.hpp"
|
|
#include "libslic3r.h"
|
|
#include "nanosvg/nanosvg.h" // NSVGimage
|
|
|
|
namespace Slic3r {
|
|
|
|
struct EmbossProjection{
|
|
// Emboss depth, Size in local Z direction
|
|
double depth = 1.; // [in loacal mm]
|
|
// NOTE: User should see and modify mainly world size not local
|
|
|
|
// Flag that result volume use surface cutted from source objects
|
|
bool use_surface = false;
|
|
|
|
bool operator==(const EmbossProjection &other) const {
|
|
return depth == other.depth && use_surface == other.use_surface;
|
|
}
|
|
|
|
// undo / redo stack recovery
|
|
template<class Archive> void serialize(Archive &ar) { ar(depth, use_surface); }
|
|
};
|
|
|
|
// Extend expolygons with information whether it was successfull healed
|
|
struct HealedExPolygons{
|
|
ExPolygons expolygons;
|
|
bool is_healed;
|
|
operator ExPolygons&() { return expolygons; }
|
|
};
|
|
|
|
// Help structure to identify expolygons grups
|
|
// e.g. emboss -> per glyph -> identify character
|
|
struct ExPolygonsWithId
|
|
{
|
|
// Identificator for shape
|
|
// In text it separate letters and the name is unicode value of letter
|
|
// Is svg it is id of path
|
|
unsigned id;
|
|
|
|
// shape defined by integer point contain only lines
|
|
// Curves are converted to sequence of lines
|
|
ExPolygons expoly;
|
|
|
|
// flag whether expolygons are fully healed(without duplication)
|
|
bool is_healed = true;
|
|
};
|
|
using ExPolygonsWithIds = std::vector<ExPolygonsWithId>;
|
|
|
|
/// <summary>
|
|
/// Contain plane shape information to be able emboss it and edit it
|
|
/// </summary>
|
|
struct EmbossShape
|
|
{
|
|
// shapes to to emboss separately over surface
|
|
ExPolygonsWithIds shapes_with_ids;
|
|
|
|
// Only cache for final shape
|
|
// It is calculated from ExPolygonsWithIds
|
|
// Flag is_healed --> whether union of shapes is healed
|
|
// Healed mean without selfintersection and point duplication
|
|
HealedExPolygons final_shape;
|
|
|
|
// scale of shape, multiplier to get 3d point in mm from integer shape
|
|
double scale = SCALING_FACTOR;
|
|
|
|
// Define how to emboss shape
|
|
EmbossProjection projection;
|
|
|
|
// !!! Volume stored in .3mf has transformed vertices.
|
|
// (baked transformation into vertices position)
|
|
// Only place for fill this is when load from .3mf
|
|
// This is correction for volume transformation
|
|
// Stored_Transform3d * fix_3mf_tr = Transform3d_before_store_to_3mf
|
|
std::optional<Slic3r::Transform3d> fix_3mf_tr;
|
|
|
|
struct SvgFile {
|
|
// File(.svg) path on local computer
|
|
// When empty can't reload from disk
|
|
std::string path;
|
|
|
|
// File path into .3mf(.zip)
|
|
// When empty svg is not stored into .3mf file yet.
|
|
// and will create dialog to delete private data on save.
|
|
std::string path_in_3mf;
|
|
|
|
// Loaded svg file data.
|
|
// !!! It is not serialized on undo/redo stack
|
|
std::shared_ptr<NSVGimage> image = nullptr;
|
|
|
|
// Loaded string data from file
|
|
std::shared_ptr<std::string> file_data = nullptr;
|
|
|
|
template<class Archive> void save(Archive &ar) const {
|
|
// Note: image is only cache it is not neccessary to store
|
|
|
|
// Store file data as plain string
|
|
// For Embossed text file_data are nullptr
|
|
ar(path, path_in_3mf, (file_data != nullptr) ? *file_data : std::string(""));
|
|
}
|
|
template<class Archive> void load(Archive &ar) {
|
|
// for restore shared pointer on file data
|
|
std::string file_data_str;
|
|
ar(path, path_in_3mf, file_data_str);
|
|
if (!file_data_str.empty())
|
|
file_data = std::make_unique<std::string>(file_data_str);
|
|
}
|
|
};
|
|
// When embossing shape is made by svg file this is source data
|
|
std::optional<SvgFile> svg_file;
|
|
|
|
// undo / redo stack recovery
|
|
template<class Archive> void save(Archive &ar) const
|
|
{
|
|
// final_shape is not neccessary to store - it is only cache
|
|
ar(shapes_with_ids, final_shape, scale, projection, svg_file);
|
|
cereal::save(ar, fix_3mf_tr);
|
|
}
|
|
template<class Archive> void load(Archive &ar)
|
|
{
|
|
ar(shapes_with_ids, final_shape, scale, projection, svg_file);
|
|
cereal::load(ar, fix_3mf_tr);
|
|
}
|
|
};
|
|
} // namespace Slic3r
|
|
|
|
// Serialization through the Cereal library
|
|
namespace cereal {
|
|
template<class Archive> void serialize(Archive &ar, Slic3r::ExPolygonsWithId &o) { ar(o.id, o.expoly, o.is_healed); }
|
|
template<class Archive> void serialize(Archive &ar, Slic3r::HealedExPolygons &o) { ar(o.expolygons, o.is_healed); }
|
|
}; // namespace cereal
|
|
|
|
#endif // slic3r_EmbossShape_hpp_
|