forked from slic3r/Slic3r
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support zip-deflated AMF files in libslic3r.
Includes basic tests. Implements slic3r#4511
- Loading branch information
1 parent
38b5418
commit 7c58218
Showing
7 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<amf unit="millimeter"> | ||
<metadata type="cad">Slic3r 1.3.1-dev</metadata> | ||
<object id="0"> | ||
<metadata type="name">20mmbox.stl</metadata> | ||
<mesh> | ||
<vertices> | ||
<vertex> | ||
<coordinates> | ||
<x>10</x> | ||
<y>10</y> | ||
<z>0</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>-10</x> | ||
<y>-10</y> | ||
<z>0</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>-10</x> | ||
<y>10</y> | ||
<z>0</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>10</x> | ||
<y>-10</y> | ||
<z>0</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>10</x> | ||
<y>-10</y> | ||
<z>10</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>-10</x> | ||
<y>10</y> | ||
<z>10</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>-10</x> | ||
<y>-10</y> | ||
<z>10</z> | ||
</coordinates> | ||
</vertex> | ||
<vertex> | ||
<coordinates> | ||
<x>10</x> | ||
<y>10</y> | ||
<z>10</z> | ||
</coordinates> | ||
</vertex> | ||
</vertices> | ||
<volume> | ||
<metadata type="name">20mmbox.stl</metadata> | ||
<triangle> | ||
<v1>0</v1> | ||
<v2>1</v2> | ||
<v3>2</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>1</v1> | ||
<v2>0</v2> | ||
<v3>3</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>4</v1> | ||
<v2>5</v2> | ||
<v3>6</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>5</v1> | ||
<v2>4</v2> | ||
<v3>7</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>0</v1> | ||
<v2>4</v2> | ||
<v3>3</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>4</v1> | ||
<v2>0</v2> | ||
<v3>7</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>4</v1> | ||
<v2>1</v2> | ||
<v3>3</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>1</v1> | ||
<v2>4</v2> | ||
<v3>6</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>5</v1> | ||
<v2>1</v2> | ||
<v3>6</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>1</v1> | ||
<v2>5</v2> | ||
<v3>2</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>5</v1> | ||
<v2>0</v2> | ||
<v3>2</v3> | ||
</triangle> | ||
<triangle> | ||
<v1>0</v1> | ||
<v2>5</v2> | ||
<v3>7</v3> | ||
</triangle> | ||
</volume> | ||
</mesh> | ||
</object> | ||
<constellation id="1"> | ||
<instance objectid="0"> | ||
<deltax>67.5</deltax> | ||
<deltay>35</deltay> | ||
<rz>0</rz> | ||
<scale>1</scale> | ||
</instance> | ||
</constellation> | ||
</amf> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <catch.hpp> | ||
#include <test_options.hpp> | ||
#include "IO.hpp" | ||
|
||
using namespace Slic3r; | ||
using namespace std::literals::string_literals; | ||
|
||
SCENARIO("Reading deflated AMF files") { | ||
GIVEN("Compressed AMF file of a 20mm cube") { | ||
Model model; | ||
WHEN("file is read") { | ||
bool result_code = IO::AMF::read(std::string(testfile_dir) + "test_amf/20mmbox_deflated.amf"s, &model); | ||
THEN("Does not return false.") { | ||
REQUIRE(result_code == true); | ||
} | ||
THEN("Model object contains a single ModelObject.") { | ||
REQUIRE(model.objects.size() == 1); | ||
} | ||
} | ||
WHEN("single file is read with some subdirectories") { | ||
bool result_code = IO::AMF::read(std::string(testfile_dir) + "test_amf/20mmbox_deflated-in_directories.amf"s, &model); | ||
THEN("Read returns false.") { | ||
REQUIRE(result_code == true); | ||
} | ||
THEN("Model object contains no ModelObjects.") { | ||
REQUIRE(model.objects.size() == 1); | ||
} | ||
} | ||
WHEN("file is read with unsupported file structure (multiple files)") { | ||
bool result_code = IO::AMF::read(std::string(testfile_dir) + "test_amf/20mmbox_deflated-mult_files.amf"s, &model); | ||
THEN("Read returns false.") { | ||
REQUIRE(result_code == false); | ||
} | ||
THEN("Model object contains no ModelObjects.") { | ||
REQUIRE(model.objects.size() == 0); | ||
} | ||
} | ||
} | ||
GIVEN("Uncompressed AMF file of a 20mm cube") { | ||
Model model; | ||
WHEN("file is read") { | ||
bool result_code = IO::AMF::read(std::string(testfile_dir) + "test_amf/20mmbox.amf"s, &model); | ||
THEN("Does not return false.") { | ||
REQUIRE(result_code == true); | ||
} | ||
THEN("Model object contains a single ModelObject.") { | ||
REQUIRE(model.objects.size() == 1); | ||
} | ||
} | ||
WHEN("nonexistant file is read") { | ||
bool result_code = IO::AMF::read(std::string(testfile_dir) + "test_amf/20mmbox-doesnotexist.amf"s, &model); | ||
THEN("Read returns false.") { | ||
REQUIRE(result_code == false); | ||
} | ||
THEN("Model object contains no ModelObject.") { | ||
REQUIRE(model.objects.size() == 0); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters