Skip to content

Commit

Permalink
AMF bugfix
Browse files Browse the repository at this point in the history
clean tests
  • Loading branch information
supermerill committed Jul 8, 2019
1 parent b2db3ad commit bc4f73a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/libslic3r/Format/AMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ bool store_amf(std::string &path, Model *model, const DynamicPrintConfig *config
mz_zip_archive archive;
mz_zip_zero_struct(&archive);

mz_bool res = mz_zip_writer_init_file(&archive, path.c_str(), 0);
if (!open_zip_writer(&archive, path)) return false;

std::stringstream stream;
Expand Down
2 changes: 1 addition & 1 deletion src/test/GUI/test_cli.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include <fstream>
Expand Down
7 changes: 2 additions & 5 deletions src/test/libslic3r/test_denserinfill.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include "../test_data.hpp"
Expand All @@ -24,7 +24,6 @@ SCENARIO("denser infills: ")
config->set_key_value("infill_dense", new ConfigOptionBool(true));
config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaEnlarged));
config->save("C:\\Users\\Admin\\Desktop\\config_def.ini");
std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n";
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_5mm_center_notch }, model, config, false);
print.process();
PrintObject& object = *(print.objects().at(0));
Expand Down Expand Up @@ -66,7 +65,7 @@ SCENARIO("denser infills: ")
srfSparse = srfDense;
srfDense = &object.layers()[21]->regions()[0]->fill_surfaces.surfaces[0];
}
std::cout << "sparse area = " << unscaled(unscaled(srfSparse->area())) << " , dense area = " << unscaled(unscaled(srfDense->area())) << "\n";
//std::cout << "sparse area = " << unscaled(unscaled(srfSparse->area())) << " , dense area = " << unscaled(unscaled(srfDense->area())) << "\n";
REQUIRE(unscaled(unscaled(srfSparse->area())) > unscaled(unscaled(srfDense->area())));
REQUIRE(object.layers()[22]->regions()[0]->fills.entities.size() == 2); //sparse + solid-bridge
REQUIRE(object.layers()[22]->regions()[0]->fill_surfaces.surfaces.size() == 2);
Expand Down Expand Up @@ -94,7 +93,6 @@ SCENARIO("denser infills: ")
config->set_key_value("infill_dense", new ConfigOptionBool(true));
config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaAutomatic));
config->save("C:\\Users\\Admin\\Desktop\\config_def.ini");
std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n";
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false);
print.process();
PrintObject& object = *(print.objects().at(0));
Expand Down Expand Up @@ -157,7 +155,6 @@ SCENARIO("denser infills: ")
config->set_key_value("infill_dense", new ConfigOptionBool(true));
config->set_key_value("infill_dense_algo", new ConfigOptionEnum<DenseInfillAlgo>(dfaAutoNotFull));
config->save("C:\\Users\\Admin\\Desktop\\config_def.ini");
std::cout << "dense infill : " << config->opt_bool("infill_dense") << "\n";
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false);
print.process();
PrintObject& object = *(print.objects().at(0));
Expand Down
2 changes: 1 addition & 1 deletion src/test/libslic3r/test_flow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>

Expand Down
5 changes: 3 additions & 2 deletions src/test/libslic3r/test_model.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include "../../libslic3r/Config.hpp"
Expand Down Expand Up @@ -35,7 +35,8 @@ SCENARIO("Model construction") {
REQUIRE(mo->volumes.front()->is_modifier() == false);
}
THEN("Mesh is equivalent to input mesh.") {
REQUIRE(sample_mesh.vertices() == mo->volumes.front()->mesh.vertices());
TriangleMesh trimesh = mo->volumes.front()->mesh();
REQUIRE(sample_mesh.vertices() == trimesh.vertices());
}
ModelInstance* inst = mo->add_instance();
inst->set_rotation(Vec3d(0,0,0));
Expand Down
5 changes: 3 additions & 2 deletions src/test/libslic3r/test_print.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include <string>
Expand All @@ -11,11 +11,12 @@ using namespace Slic3r;
using namespace std::literals;

SCENARIO("PrintObject: Perimeter generation") {
GIVEN("20mm cube and default config") {
GIVEN("20mm cube and default config & 0.3 layer height") {
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
TestMesh m = TestMesh::cube_20x20x20;
Model model{};
config->set_key_value("fill_density", new ConfigOptionPercent(0));
config->set_deserialize("layer_height", "0.3");

WHEN("make_perimeters() is called") {
Print print{};
Expand Down
47 changes: 24 additions & 23 deletions src/test/libslic3r/test_skirt_brim.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include "../test_data.hpp"
Expand Down Expand Up @@ -396,28 +396,29 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
}
}

WHEN("Object is plated with overhang support and a brim") {
config->set_deserialize("layer_height", "0.4");
config->set_deserialize("first_layer_height", "0.4");
config->set_deserialize("skirts", "1");
config->set_deserialize("skirt_distance", "0");
config->set_deserialize("support_material_speed", "99");
config->set_deserialize("perimeter_extruder", "1");
config->set_deserialize("support_material_extruder", "2");
config->set_deserialize("cooling", "0"); // to prevent speeds to be altered
config->set_deserialize("first_layer_speed", "100%"); // to prevent speeds to be altered

Slic3r::Model model;
Print print{};
Slic3r::Test::init_print(print, { TestMesh::overhang }, model, config, false);
print.process();

config->set_deserialize("support_material", "true"); // to prevent speeds to be altered

THEN("skirt length is large enough to contain object with support") {
REQUIRE(true); //TODO
}
}
//TODO review this test that fail because "there are no layer" and it test nothing anyway
//WHEN("Object is plated with overhang support and a brim") {
// config->set_deserialize("layer_height", "0.4");
// config->set_deserialize("first_layer_height", "0.4");
// config->set_deserialize("skirts", "1");
// config->set_deserialize("skirt_distance", "0");
// config->set_deserialize("support_material_speed", "99");
// config->set_deserialize("perimeter_extruder", "1");
// config->set_deserialize("support_material_extruder", "2");
// config->set_deserialize("cooling", "0"); // to prevent speeds to be altered
// config->set_deserialize("first_layer_speed", "100%"); // to prevent speeds to be altered

// Slic3r::Model model;
// Print print{};
// Slic3r::Test::init_print(print, { TestMesh::overhang }, model, config, false);
// print.process();
//
// config->set_deserialize("support_material", "true"); // to prevent speeds to be altered

// THEN("skirt length is large enough to contain object with support") {
// REQUIRE(true); //TODO
// }
//}
WHEN("Large minimum skirt length is used.") {
config->set_deserialize("min_skirt_length", "20");
auto gcode {std::stringstream("")};
Expand Down
4 changes: 2 additions & 2 deletions src/test/libslic3r/test_thin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define CATCH_CONFIG_DISABLE
//#define CATCH_CONFIG_DISABLE

#include <catch.hpp>
#include "../test_data.hpp"
Expand Down Expand Up @@ -105,7 +105,7 @@ SCENARIO("thin walls: ")
Lines lines = res[0].lines();
double min_angle = 1, max_angle = -1;
//std::cout << "first angle=" << lines[0].ccw(lines[1].b) << "\n";
for (int idx = 2; idx < lines.size()-2; idx++){
for (int idx = 1; idx < lines.size()-1; idx++){
double angle = lines[idx - 1].ccw(lines[idx].b);
if (std::abs(angle) - EPSILON < 0) angle = 0;
//if (angle < 0) std::cout << unscale_(lines[idx - 1].a.x()) << ":" << unscale_(lines[idx - 1].a.y()) << " -> " << unscale_(lines[idx - 1].b.x()) << ":" << unscale_(lines[idx - 1].b.y()) << " -> " << unscale_(lines[idx].b.x()) << ":" << unscale_(lines[idx].b.y()) << "\n";
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void init_print(Print& print, std::initializer_list<TestMesh> meshes, Slic3r::Mo
print.apply(model, *config);

std::string err = print.validate();
std::cout << "validate result : " << err << ", mempty print? " << print.empty() << "\n";
//std::cout << "validate result : " << err << ", mempty print? " << print.empty() << "\n";

}
void init_print(Print& print, std::initializer_list<TriangleMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config, bool comments) {
Expand Down

0 comments on commit bc4f73a

Please sign in to comment.