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
101 lines
3.4 KiB
C++
101 lines
3.4 KiB
C++
#include <array>
|
|
#include <catch2/catch_all.hpp>
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/catch_approx.hpp>
|
|
|
|
#include "libslic3r/Point.hpp"
|
|
#include <cstdlib>
|
|
#include <cmath>
|
|
#include <libslic3r/SLA/Hollowing.hpp>
|
|
#include <utility>
|
|
|
|
|
|
using namespace Slic3r;
|
|
|
|
// First do a simple test of the hole raycaster.
|
|
TEST_CASE("Raycaster - find intersections of a line and cylinder")
|
|
{
|
|
sla::DrainHole hole{Vec3f(0,0,0), Vec3f(0,0,1), 5, 10};
|
|
std::array<std::pair<float, Vec3d>, 2> out;
|
|
Vec3f s;
|
|
Vec3f dir;
|
|
|
|
// Start inside the hole and cast perpendicular to its axis.
|
|
s = {-1.f, 0, 5.f};
|
|
dir = {1.f, 0, 0};
|
|
hole.get_intersections(s, dir, out);
|
|
REQUIRE(out[0].first == Catch::Approx(-4.f));
|
|
REQUIRE(out[1].first == Catch::Approx(6.f));
|
|
|
|
// Start outside and cast parallel to axis.
|
|
s = {0, 0, -1.f};
|
|
dir = {0, 0, 1.f};
|
|
hole.get_intersections(s, dir, out);
|
|
REQUIRE(std::abs(out[0].first - 1.f) < 0.001f);
|
|
REQUIRE(std::abs(out[1].first - 11.f) < 0.001f);
|
|
|
|
// Start outside and cast so that entry is in base and exit on the cylinder
|
|
s = {0, -1.f, -1.f};
|
|
dir = {0, 1.f, 1.f};
|
|
dir.normalize();
|
|
hole.get_intersections(s, dir, out);
|
|
REQUIRE(std::abs(out[0].first - std::sqrt(2.f)) < 0.001f);
|
|
REQUIRE(std::abs(out[1].first - std::sqrt(72.f)) < 0.001f);
|
|
}
|
|
|
|
#ifdef SLIC3R_HOLE_RAYCASTER
|
|
// Create a simple scene with a 20mm cube and a big hole in the front wall
|
|
// with 5mm radius. Then shoot rays from interesting positions and see where
|
|
// they land.
|
|
TEST_CASE("Raycaster with loaded drillholes", "[sla_raycast]")
|
|
{
|
|
// Load the cube and make it hollow.
|
|
TriangleMesh cube = load_model("20mm_cube.obj");
|
|
sla::HollowingConfig hcfg;
|
|
std::unique_ptr<TriangleMesh> cube_inside = sla::generate_interior(cube, hcfg);
|
|
REQUIRE(cube_inside);
|
|
|
|
// Helper bb
|
|
auto boxbb = cube.bounding_box();
|
|
|
|
// Create the big 10mm long drainhole in the front wall.
|
|
Vec3f center = boxbb.center().cast<float>();
|
|
Vec3f p = {center.x(), 0., center.z()};
|
|
Vec3f normal = {0.f, 1.f, 0.f};
|
|
float radius = 5.f;
|
|
float hole_length = 10.;
|
|
sla::DrainHoles holes = { sla::DrainHole{p, normal, radius, hole_length} };
|
|
|
|
cube.merge(*cube_inside);
|
|
|
|
sla::IndexedMesh emesh{cube};
|
|
emesh.load_holes(holes);
|
|
|
|
Vec3d s = center.cast<double>();
|
|
// Fire from center, should hit the interior wall
|
|
auto hit = emesh.query_ray_hit(s, {0, 1., 0.});
|
|
REQUIRE(hit.distance() == Catch::Approx(boxbb.size().x() / 2 - hcfg.min_thickness));
|
|
|
|
// Fire upward from hole center, hit distance equals the radius (hits the
|
|
// side of the hole cut.
|
|
s.y() = hcfg.min_thickness / 2;
|
|
hit = emesh.query_ray_hit(s, {0, 0., 1.});
|
|
REQUIRE(hit.distance() == Catch::Approx(radius));
|
|
|
|
// Fire from outside, hit the back side of the cube interior
|
|
s.y() = -1.;
|
|
hit = emesh.query_ray_hit(s, {0, 1., 0.});
|
|
REQUIRE(hit.distance() == Catch::Approx(boxbb.max.y() - hcfg.min_thickness - s.y()));
|
|
|
|
// Fire downwards from above the hole cylinder. Has to go through the cyl.
|
|
// as it was not there.
|
|
s = center.cast<double>();
|
|
s.z() = boxbb.max.z() - hcfg.min_thickness - 1.;
|
|
hit = emesh.query_ray_hit(s, {0, 0., -1.});
|
|
REQUIRE(hit.distance() == Catch::Approx(s.z() - boxbb.min.z() - hcfg.min_thickness));
|
|
|
|
// Check for support tree correctness
|
|
test_support_model_collision("20mm_cube.obj", {}, hcfg, holes);
|
|
}
|
|
#endif
|