mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-02-01 16:38:43 +03:00
update src and test
This commit is contained in:
50
tests/sla_print/sla_parabola_tests.cpp
Normal file
50
tests/sla_print/sla_parabola_tests.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "sla_test_utils.hpp"
|
||||
|
||||
#include <libslic3r/SLA/SupportIslands/ParabolaUtils.hpp>
|
||||
|
||||
using namespace Slic3r;
|
||||
using namespace Slic3r::sla;
|
||||
|
||||
void parabola_check_length(const ParabolaSegment ¶bola)
|
||||
{
|
||||
auto diffPoint = parabola.to - parabola.from;
|
||||
double min = sqrt(diffPoint.x() * diffPoint.x() +
|
||||
diffPoint.y() * diffPoint.y());
|
||||
double max = static_cast<double>(diffPoint.x()) + diffPoint.y();
|
||||
double len = ParabolaUtils::length(parabola);
|
||||
double len2 = ParabolaUtils::length_by_sampling(parabola, 1.);
|
||||
CHECK(fabs(len2 - len) < 1.);
|
||||
CHECK(len >= min);
|
||||
CHECK(len <= max);
|
||||
}
|
||||
|
||||
// after generalization put to ParabolaUtils
|
||||
double getParabolaY(const Parabola ¶bola, double x)
|
||||
{
|
||||
double f = ParabolaUtils::focal_length(parabola);
|
||||
Vec2d perp = parabola.directrix.normal().cast<double>();
|
||||
// work only for test cases
|
||||
if (perp.y() > 0.) perp *= -1.;
|
||||
perp.normalize();
|
||||
Vec2d v = parabola.focus.cast<double>() + perp * f;
|
||||
return 1 / (4 * f) * (x - v.x()) * (x - v.x()) + v.y();
|
||||
}
|
||||
|
||||
TEST_CASE("Parabola length", "[SupGen][Voronoi][Parabola]")
|
||||
{
|
||||
using namespace Slic3r::sla;
|
||||
double scale = 1e6;
|
||||
// U shape parabola
|
||||
Parabola parabola_x2(Line({-1. * scale, -.25 * scale},
|
||||
{1. * scale, -.25 * scale}),
|
||||
Point(0. * scale, .25 * scale));
|
||||
|
||||
double from_x = 1 * scale;
|
||||
double to_x = 3 * scale;
|
||||
Point from(from_x, getParabolaY(parabola_x2, from_x));
|
||||
Point to(to_x, getParabolaY(parabola_x2, to_x));
|
||||
ParabolaSegment parabola_segment(parabola_x2, from, to);
|
||||
parabola_check_length(parabola_segment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user