mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-08 00:01:09 +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.
50 lines
2.4 KiB
C++
50 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "Point.hpp"
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
namespace Slic3r {
|
|
|
|
class ModelObject;
|
|
|
|
// A face of an object's convex hull that the object can rest on. These are the faces the
|
|
// "Lay on Face" gizmo offers and the ones the CLI --ground-* options choose from.
|
|
//
|
|
// Frames: "object" coordinates have the volume transformations applied but not the instance
|
|
// transformation. "Instance" coordinates additionally have the instance rotation, scale and
|
|
// mirror applied, but not its offset.
|
|
struct LayOnFacePlane
|
|
{
|
|
Vec3d normal; // outward unit normal, object coordinates
|
|
Vec3d center; // centroid of the outline, object coordinates; on the face's mean plane
|
|
float area; // mm², instance coordinates
|
|
Pointf3s outline; // convex outline in the plane frame, where the face is horizontal
|
|
Transform3d to_plane_frame; // rotation from instance coordinates to the plane frame
|
|
};
|
|
|
|
// Candidate faces of the object's model parts, largest first. The instance transformation
|
|
// (without offset) is applied before measuring, so faces too small to rest on are dropped
|
|
// by their printed size: under 5 mm², a side under 1 mm, or an inner angle under 1°.
|
|
std::vector<LayOnFacePlane> lay_on_face_planes(const ModelObject &object, const Transform3d &instance_matrix_no_offset);
|
|
|
|
// Index of the largest plane, or -1 if `planes` is empty. Of planes with the same area, such as
|
|
// the top and bottom of a box, the one already facing down the most wins, so flat parts stay put.
|
|
int find_largest_plane(const std::vector<LayOnFacePlane> &planes);
|
|
|
|
// Index of the plane whose normal is closest to `direction` (object coordinates),
|
|
// or -1 if `planes` is empty.
|
|
int find_plane_by_normal(const std::vector<LayOnFacePlane> &planes, const Vec3d &direction);
|
|
|
|
// Index of the plane whose face contains `point` (object coordinates) within `tolerance` mm, or -1
|
|
// if there is none. `instance_matrix_no_offset` is the one the planes were computed with.
|
|
int find_plane_at_point(const std::vector<LayOnFacePlane> &planes, const Transform3d &instance_matrix_no_offset,
|
|
const Vec3d &point, double tolerance);
|
|
|
|
// Rotates the instance so that `normal` (object coordinates) points down, the same rotation as
|
|
// the gizmo applies, then drops the instance so its lowest point is at z = 0.
|
|
void lay_on_face(ModelObject &object, size_t instance_idx, const Vec3d &normal);
|
|
|
|
} // namespace Slic3r
|