mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 05:11:13 +08:00
visualization inside of test with macro
This commit is contained in:
parent
69c58505cd
commit
ea1e6c0e8f
@ -16,6 +16,8 @@
|
|||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
using namespace Slic3r::sla;
|
using namespace Slic3r::sla;
|
||||||
|
|
||||||
|
//#define STORE_SAMPLE_INTO_SVG_FILES
|
||||||
|
|
||||||
TEST_CASE("Overhanging point should be supported", "[SupGen]") {
|
TEST_CASE("Overhanging point should be supported", "[SupGen]") {
|
||||||
|
|
||||||
// Pyramid with 45 deg slope
|
// Pyramid with 45 deg slope
|
||||||
@ -451,7 +453,7 @@ SampleConfig create_sample_config(double size) {
|
|||||||
|
|
||||||
#include <libslic3r/Geometry.hpp>
|
#include <libslic3r/Geometry.hpp>
|
||||||
#include <libslic3r/VoronoiOffset.hpp>
|
#include <libslic3r/VoronoiOffset.hpp>
|
||||||
TEST_CASE("Sampling speed test on FrogLegs", "[VoronoiSkeleton]")
|
TEST_CASE("Sampling speed test on FrogLegs", "[hide], [VoronoiSkeleton]")
|
||||||
{
|
{
|
||||||
TriangleMesh mesh = load_model("frog_legs.obj");
|
TriangleMesh mesh = load_model("frog_legs.obj");
|
||||||
TriangleMeshSlicer slicer{&mesh};
|
TriangleMeshSlicer slicer{&mesh};
|
||||||
@ -474,7 +476,7 @@ TEST_CASE("Sampling speed test on FrogLegs", "[VoronoiSkeleton]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Speed align", "[VoronoiSkeleton]")
|
TEST_CASE("Speed align", "[hide], [VoronoiSkeleton]")
|
||||||
{
|
{
|
||||||
SampleConfig cfg = create_sample_config(3e7);
|
SampleConfig cfg = create_sample_config(3e7);
|
||||||
cfg.max_align_distance = 1000;
|
cfg.max_align_distance = 1000;
|
||||||
@ -497,9 +499,12 @@ TEST_CASE("Speed align", "[VoronoiSkeleton]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#include <libslic3r/SLA/SupportPointGenerator.hpp>
|
|
||||||
#include <libslic3r/SLA/SupportIslands/LineUtils.hpp>
|
#include <libslic3r/SLA/SupportIslands/LineUtils.hpp>
|
||||||
TEST_CASE("speed sampling", "[SupGen]") {
|
/// <summary>
|
||||||
|
/// Check speed of sampling,
|
||||||
|
/// for be sure that code is not optimized out store result to svg or print count.
|
||||||
|
/// </summary>
|
||||||
|
TEST_CASE("speed sampling", "[hide], [SupGen]") {
|
||||||
double size = 3e7;
|
double size = 3e7;
|
||||||
float samples_per_mm2 = 0.01f;
|
float samples_per_mm2 = 0.01f;
|
||||||
ExPolygons islands = createTestIslands(size);
|
ExPolygons islands = createTestIslands(size);
|
||||||
@ -528,6 +533,8 @@ TEST_CASE("speed sampling", "[SupGen]") {
|
|||||||
}
|
}
|
||||||
std::cout << "All points " << all << std::endl;*/
|
std::cout << "All points " << all << std::endl;*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef STORE_SAMPLE_INTO_SVG_FILES
|
||||||
for (size_t i = 0; i < result1.size(); ++i) {
|
for (size_t i = 0; i < result1.size(); ++i) {
|
||||||
size_t island_index = i % islands.size();
|
size_t island_index = i % islands.size();
|
||||||
ExPolygon &island = islands[island_index];
|
ExPolygon &island = islands[island_index];
|
||||||
@ -542,16 +549,21 @@ TEST_CASE("speed sampling", "[SupGen]") {
|
|||||||
svg.draw_text({0., 5e6}, ("uniform samples " + std::to_string(result2[i].size())).c_str(), "green");
|
svg.draw_text({0., 5e6}, ("uniform samples " + std::to_string(result2[i].size())).c_str(), "green");
|
||||||
for (Vec2f &p : result2[i])
|
for (Vec2f &p : result2[i])
|
||||||
svg.draw((p * 1e6).cast<coord_t>(), "green", 1e6);
|
svg.draw((p * 1e6).cast<coord_t>(), "green", 1e6);
|
||||||
}//*/
|
}
|
||||||
|
#endif // STORE_SAMPLE_INTO_SVG_FILES
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Small islands should be supported in center", "[SupGen][VoronoiSkeleton]")
|
/// <summary>
|
||||||
|
/// Check for correct sampling of island
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
TEST_CASE("Small islands should be supported in center", "[SupGen], [VoronoiSkeleton]")
|
||||||
{
|
{
|
||||||
double size = 3e7;
|
double size = 3e7;
|
||||||
SampleConfig cfg = create_sample_config(size);
|
SampleConfig cfg = create_sample_config(size);
|
||||||
ExPolygons islands = createTestIslands(size);
|
ExPolygons islands = createTestIslands(size);
|
||||||
|
|
||||||
// TODO: remove next 3 lines, debug sharp triangle
|
// TODO: remove next 4 lines, debug sharp triangle
|
||||||
auto triangle = PolygonUtils::create_isosceles_triangle(8. * size, 40. * size);
|
auto triangle = PolygonUtils::create_isosceles_triangle(8. * size, 40. * size);
|
||||||
islands = {ExPolygon(triangle)};
|
islands = {ExPolygon(triangle)};
|
||||||
//auto test_island = create_tiny_wide_test_2(3 * size, 2 / 3. * size);
|
//auto test_island = create_tiny_wide_test_2(3 * size, 2 / 3. * size);
|
||||||
@ -560,13 +572,13 @@ TEST_CASE("Small islands should be supported in center", "[SupGen][VoronoiSkelet
|
|||||||
for (ExPolygon &island : islands) {
|
for (ExPolygon &island : islands) {
|
||||||
size_t debug_index = &island - &islands.front();
|
size_t debug_index = &island - &islands.front();
|
||||||
auto points = test_island_sampling(island, cfg);
|
auto points = test_island_sampling(island, cfg);
|
||||||
//cgal_test(points, island);
|
|
||||||
double angle = 3.14 / 3; // cca 60 degree
|
double angle = 3.14 / 3; // cca 60 degree
|
||||||
|
|
||||||
island.rotate(angle);
|
island.rotate(angle);
|
||||||
auto pointsR = test_island_sampling(island, cfg);
|
auto pointsR = test_island_sampling(island, cfg);
|
||||||
//for (Point &p : pointsR) p.rotate(-angle);
|
|
||||||
// points should be equal to pointsR
|
// points count should be the same
|
||||||
|
//CHECK(points.size() == pointsR.size())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +655,7 @@ void store_sample(const std::vector<Vec2f> &samples, const ExPolygon& island)
|
|||||||
svg.draw(Line(start + Point(i*mm, 0.), start + Point((i+1)*mm, 0.)), "black", 1e6);
|
svg.draw(Line(start + Point(i*mm, 0.), start + Point((i+1)*mm, 0.)), "black", 1e6);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Compare sampling test")
|
TEST_CASE("Compare sampling test", "[hide]")
|
||||||
{
|
{
|
||||||
enum class Sampling {
|
enum class Sampling {
|
||||||
old,
|
old,
|
||||||
@ -661,17 +673,27 @@ TEST_CASE("Compare sampling test")
|
|||||||
ExPolygons islands_big = createTestIslands(3e6);
|
ExPolygons islands_big = createTestIslands(3e6);
|
||||||
islands.insert(islands.end(), islands_big.begin(), islands_big.end());
|
islands.insert(islands.end(), islands_big.begin(), islands_big.end());
|
||||||
|
|
||||||
islands = {ExPolygon(PolygonUtils::create_rect(size1 / 2, size1))};
|
|
||||||
|
|
||||||
for (ExPolygon &island : islands) {
|
for (ExPolygon &island : islands) {
|
||||||
size_t debug_index = &island - &islands.front();
|
size_t debug_index = &island - &islands.front();
|
||||||
auto samples = sample(island);
|
auto samples = sample(island);
|
||||||
|
#ifdef STORE_SAMPLE_INTO_SVG_FILES
|
||||||
store_sample(samples, island);
|
store_sample(samples, island);
|
||||||
|
#endif // STORE_SAMPLE_INTO_SVG_FILES
|
||||||
|
|
||||||
double angle = 3.14 / 3; // cca 60 degree
|
double angle = 3.14 / 3; // cca 60 degree
|
||||||
island.rotate(angle);
|
island.rotate(angle);
|
||||||
samples = sample(island);
|
samples = sample(island);
|
||||||
|
#ifdef STORE_SAMPLE_INTO_SVG_FILES
|
||||||
store_sample(samples, island);
|
store_sample(samples, island);
|
||||||
|
#endif // STORE_SAMPLE_INTO_SVG_FILES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Disable visualization", "[hide]")
|
||||||
|
{
|
||||||
|
CHECK(true);
|
||||||
|
#ifdef STORE_SAMPLE_INTO_SVG_FILES
|
||||||
|
CHECK(false);
|
||||||
|
#endif // STORE_SAMPLE_INTO_SVG_FILES
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user