mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 19:01:02 +00:00
Merge remote-tracking branch 'prfork/cad-mainline' into cad-mainline
This commit is contained in:
@@ -128,7 +128,7 @@ done
|
|||||||
# --- main window ----------------------------------------------------------------------------
|
# --- main window ----------------------------------------------------------------------------
|
||||||
main="$(xdotool search --name "Untitled" 2>/dev/null | head -1 || true)"
|
main="$(xdotool search --name "Untitled" 2>/dev/null | head -1 || true)"
|
||||||
if [ -n "$main" ]; then
|
if [ -n "$main" ]; then
|
||||||
xdotool windowmove "$main" 0 0 windowsize "$main" ${GEOM/x/ } 2>/dev/null || true
|
xdotool windowmove "$main" 0 0 windowsize "$main" "$screen_w" "$screen_h" 2>/dev/null || true
|
||||||
xdotool windowactivate "$main" 2>/dev/null || true
|
xdotool windowactivate "$main" 2>/dev/null || true
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -2,25 +2,31 @@
|
|||||||
|
|
||||||
#include "libslic3r/SketchImport.hpp"
|
#include "libslic3r/SketchImport.hpp"
|
||||||
#include "libslic3r/Utils.hpp" // resources_dir
|
#include "libslic3r/Utils.hpp" // resources_dir
|
||||||
|
#include "test_utils.hpp" // ScopedTemporaryFile
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
|
|
||||||
|
// A 10x10 mm filled square, on disk because nanosvg reads from a file. The path
|
||||||
|
// must come from the system temp dir: a hardcoded /tmp is not writable on
|
||||||
|
// Windows, where the stream fails silently and the parse then sees no file.
|
||||||
|
static void write_square_svg(const std::string& path)
|
||||||
|
{
|
||||||
|
std::ofstream f(path);
|
||||||
|
f << "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"10mm\" height=\"10mm\" "
|
||||||
|
"viewBox=\"0 0 10 10\">"
|
||||||
|
"<path d=\"M0,0 L10,0 L10,10 L0,10 Z\" fill=\"#000000\"/></svg>";
|
||||||
|
REQUIRE(f.good());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("svg_to_regions parses a filled path into a region", "[SketchImport]")
|
TEST_CASE("svg_to_regions parses a filled path into a region", "[SketchImport]")
|
||||||
{
|
{
|
||||||
// A 10x10 mm filled square. Written to a temp file because nanosvg reads
|
ScopedTemporaryFile square(".svg");
|
||||||
// from disk.
|
write_square_svg(square.string());
|
||||||
const std::string path = "/tmp/snaporca_test_square.svg";
|
|
||||||
{
|
|
||||||
std::ofstream f(path);
|
|
||||||
f << "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"10mm\" height=\"10mm\" "
|
|
||||||
"viewBox=\"0 0 10 10\">"
|
|
||||||
"<path d=\"M0,0 L10,0 L10,10 L0,10 Z\" fill=\"#000000\"/></svg>";
|
|
||||||
}
|
|
||||||
|
|
||||||
ImportRegions regs = svg_to_regions(path, 1.0);
|
ImportRegions regs = svg_to_regions(square.string(), 1.0);
|
||||||
REQUIRE(regs.size() >= 1);
|
REQUIRE(regs.size() >= 1);
|
||||||
// Outer contour present with at least a few vertices.
|
// Outer contour present with at least a few vertices.
|
||||||
REQUIRE(regs[0].size() >= 1);
|
REQUIRE(regs[0].size() >= 1);
|
||||||
@@ -38,9 +44,13 @@ TEST_CASE("svg_to_regions parses a filled path into a region", "[SketchImport]")
|
|||||||
|
|
||||||
TEST_CASE("svg_to_regions rejects bad input gracefully", "[SketchImport]")
|
TEST_CASE("svg_to_regions rejects bad input gracefully", "[SketchImport]")
|
||||||
{
|
{
|
||||||
|
ScopedTemporaryFile square(".svg");
|
||||||
|
write_square_svg(square.string());
|
||||||
|
ScopedTemporaryFile missing(".svg"); // name reserved, never written
|
||||||
|
|
||||||
REQUIRE(svg_to_regions("", 1.0).empty());
|
REQUIRE(svg_to_regions("", 1.0).empty());
|
||||||
REQUIRE(svg_to_regions("/tmp/snaporca_does_not_exist.svg", 1.0).empty());
|
REQUIRE(svg_to_regions(missing.string(), 1.0).empty());
|
||||||
REQUIRE(svg_to_regions("/tmp/snaporca_test_square.svg", 0.0).empty()); // scale<=0
|
REQUIRE(svg_to_regions(square.string(), 0.0).empty()); // scale<=0
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("transform_regions moves and scales independently", "[SketchImport]")
|
TEST_CASE("transform_regions moves and scales independently", "[SketchImport]")
|
||||||
|
|||||||
Reference in New Issue
Block a user