mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 04:45:57 +08:00
merge wip
This commit is contained in:
parent
e0a5bbdcc5
commit
805e0b91b8
@ -218,10 +218,10 @@ public:
|
||||
bbox.min /= m_resolution;
|
||||
bbox.max /= m_resolution;
|
||||
// Trim with the cells.
|
||||
bbox.min.x() = std::max(bbox.min.x(), 0);
|
||||
bbox.min.y() = std::max(bbox.min.y(), 0);
|
||||
bbox.max.x() = std::min(bbox.max.x(), (coord_t)m_cols - 1);
|
||||
bbox.max.y() = std::min(bbox.max.y(), (coord_t)m_rows - 1);
|
||||
bbox.min.x() = std::max((coord_t)bbox.min.x(), (coord_t)0);
|
||||
bbox.min.y() = std::max((coord_t)bbox.min.y(), (coord_t)0);
|
||||
bbox.max.x() = std::min((coord_t)bbox.max.x(), (coord_t)m_cols - 1);
|
||||
bbox.max.y() = std::min((coord_t)bbox.max.y(), (coord_t)m_rows - 1);
|
||||
for (coord_t iy = bbox.min.y(); iy <= bbox.max.y(); ++ iy)
|
||||
for (coord_t ix = bbox.min.x(); ix <= bbox.max.x(); ++ ix)
|
||||
if (! visitor(iy, ix))
|
||||
|
@ -131,7 +131,6 @@ public:
|
||||
FlatenEntities(bool preserve_ordering) : preserve_ordering(preserve_ordering) {}
|
||||
FlatenEntities(ExtrusionEntityCollection pattern, bool preserve_ordering) : preserve_ordering(preserve_ordering) {
|
||||
to_fill.no_sort = pattern.no_sort;
|
||||
to_fill.orig_indices = pattern.orig_indices;
|
||||
}
|
||||
ExtrusionEntityCollection get() {
|
||||
return to_fill;
|
||||
|
@ -169,7 +169,7 @@ void FillGyroid::_fill_surface_single(
|
||||
bb.merge(_align_to_grid(bb.min, Point(2*M_PI*distance, 2*M_PI*distance)));
|
||||
|
||||
// generate pattern
|
||||
Polylines polylines_square = make_gyroid_waves(
|
||||
Polylines polylines = make_gyroid_waves(
|
||||
scale_(this->z),
|
||||
density_adjusted,
|
||||
this->spacing,
|
||||
|
@ -24,17 +24,6 @@ public:
|
||||
static constexpr double PatternTolerance = 0.2;
|
||||
|
||||
|
||||
// Correction applied to regular infill angle to maximize printing
|
||||
// speed in default configuration (degrees)
|
||||
static constexpr float CorrectionAngle = -45.;
|
||||
|
||||
// Density adjustment to have a good %of weight.
|
||||
static constexpr double DensityAdjust = 2.44;
|
||||
|
||||
// Gyroid upper resolution tolerance (mm^-2)
|
||||
static constexpr double PatternTolerance = 0.2;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void _fill_surface_single(
|
||||
const FillParams ¶ms,
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "../ClipperUtils.hpp"
|
||||
#include "../PolylineCollection.hpp"
|
||||
#include "../ExtrusionEntityCollection.hpp"
|
||||
#include "../Surface.hpp"
|
||||
#include <cmath>
|
||||
|
@ -338,6 +338,12 @@ double rad2deg_dir(double angle)
|
||||
return rad2deg(angle);
|
||||
}
|
||||
|
||||
Point
|
||||
circle_taubin_newton(const Points& input, size_t cycles)
|
||||
{
|
||||
return circle_taubin_newton(input.cbegin(), input.cend(), cycles);
|
||||
}
|
||||
|
||||
Point circle_taubin_newton(const Points::const_iterator& input_begin, const Points::const_iterator& input_end, size_t cycles)
|
||||
{
|
||||
Vec2ds tmp;
|
||||
@ -1293,108 +1299,5 @@ double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)
|
||||
#endif /* NDEBUG */
|
||||
return (axis.z() < 0) ? -angle : angle;
|
||||
}
|
||||
//-------------- for tests ----------------------//
|
||||
|
||||
Point
|
||||
circle_taubin_newton(const Points& input, size_t cycles)
|
||||
{
|
||||
return circle_taubin_newton(input.cbegin(), input.cend(), cycles);
|
||||
}
|
||||
|
||||
Point
|
||||
circle_taubin_newton(const Points::const_iterator& input_begin, const Points::const_iterator& input_end, size_t cycles)
|
||||
{
|
||||
Pointfs tmp;
|
||||
tmp.reserve(std::distance(input_begin, input_end));
|
||||
std::transform(input_begin, input_end, std::back_inserter(tmp), [](const Point& in) {return unscale(in); });
|
||||
return Point::new_scale(circle_taubin_newton(tmp.cbegin(), tmp.end(), cycles));
|
||||
}
|
||||
|
||||
Vec2d
|
||||
circle_taubin_newton(const Pointfs& input, size_t cycles)
|
||||
{
|
||||
return circle_taubin_newton(input.cbegin(), input.cend(), cycles);
|
||||
}
|
||||
|
||||
|
||||
/// Adapted from work in "Circular and Linear Regression: Fitting circles and lines by least squares", pg 126
|
||||
/// Returns a point corresponding to the center of a circle for which all of the points from input_begin to input_end
|
||||
/// lie on.
|
||||
Vec2d
|
||||
circle_taubin_newton(const Pointfs::const_iterator& input_begin, const Pointfs::const_iterator& input_end, size_t cycles)
|
||||
{
|
||||
// calculate the centroid of the data set
|
||||
const Vec2d sum = std::accumulate(input_begin, input_end, Vec2d(0, 0));
|
||||
const size_t n = std::distance(input_begin, input_end);
|
||||
const double n_flt = static_cast<double>(n);
|
||||
const Vec2d centroid = (sum / n_flt);
|
||||
|
||||
// Compute the normalized moments of the data set.
|
||||
double Mxx = 0, Myy = 0, Mxy = 0, Mxz = 0, Myz = 0, Mzz = 0;
|
||||
for (auto it = input_begin; it < input_end; ++it) {
|
||||
// center/normalize the data.
|
||||
double Xi = it->x() - centroid.x();
|
||||
double Yi = it->y() - centroid.y();
|
||||
double Zi = Xi*Xi + Yi * Yi;
|
||||
Mxy += (Xi*Yi);
|
||||
Mxx += (Xi*Xi);
|
||||
Myy += (Yi*Yi);
|
||||
Mxz += (Xi*Zi);
|
||||
Myz += (Yi*Zi);
|
||||
Mzz += (Zi*Zi);
|
||||
}
|
||||
|
||||
// divide by number of points to get the moments
|
||||
Mxx /= n_flt;
|
||||
Myy /= n_flt;
|
||||
Mxy /= n_flt;
|
||||
Mxz /= n_flt;
|
||||
Myz /= n_flt;
|
||||
Mzz /= n_flt;
|
||||
|
||||
// Compute the coefficients of the characteristic polynomial for the circle
|
||||
// eq 5.60
|
||||
const double Mz = Mxx + Myy ; // xx + yy = z
|
||||
const double Cov_xy = Mxx*Myy - Mxy * Mxy ; // this shows up a couple times so cache it here.
|
||||
const double C3 = 4.0*Mz ;
|
||||
const double C2 = -3.0*(Mz*Mz) - Mzz ;
|
||||
const double C1 = Mz*(Mzz - (Mz*Mz)) + 4.0*Mz*Cov_xy - (Mxz*Mxz) - (Myz*Myz) ;
|
||||
const double C0 = (Mxz*Mxz)*Myy + (Myz*Myz)*Mxx - 2.0*Mxz*Myz*Mxy - Cov_xy * (Mzz - (Mz*Mz)) ;
|
||||
|
||||
const double C22 = C2 + C2 ;
|
||||
const double C33 = C3 + C3 + C3 ;
|
||||
|
||||
// solve the characteristic polynomial with Newton's method.
|
||||
double xnew = 0.0;
|
||||
double ynew = 1e20;
|
||||
|
||||
for (size_t i = 0; i < cycles; ++i) {
|
||||
const double yold{ ynew };
|
||||
ynew = C0 + xnew * (C1 + xnew * (C2 + xnew * C3));
|
||||
if (std::abs(ynew) > std::abs(yold)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Geometry: Fit is going in the wrong direction.\n";
|
||||
return Vec2d(std::nan(""), std::nan(""));
|
||||
}
|
||||
const double Dy{ C1 + xnew * (C22 + xnew * C33) };
|
||||
|
||||
const double xold{ xnew };
|
||||
xnew = xold - (ynew / Dy);
|
||||
|
||||
if (std::abs((xnew - xold) / xnew) < 1e-12) i = cycles; // converged, we're done here
|
||||
|
||||
if (xnew < 0) {
|
||||
// reset, we went negative
|
||||
xnew = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// compute the determinant and the circle's parameters now that we've solved.
|
||||
double DET = xnew * xnew - xnew * Mz + Cov_xy;
|
||||
|
||||
Vec2d center(Mxz * (Myy - xnew) - Myz * Mxy, Myz * (Mxx - xnew) - Mxz * Mxy);
|
||||
center = center / (DET / 2);
|
||||
|
||||
return center + centroid;
|
||||
}
|
||||
|
||||
} }
|
||||
|
@ -83,13 +83,13 @@ void PerimeterGenerator::process()
|
||||
//store surface for bridge infill to avoid unsupported perimeters (but the first one, this one is always good)
|
||||
|
||||
if (this->config->no_perimeter_unsupported_algo != npuaNone
|
||||
&& this->lower_slices != NULL && !this->lower_slices->expolygons.empty()) {
|
||||
&& this->lower_slices != NULL && !this->lower_slices->empty()) {
|
||||
|
||||
for (surface_idx = 0; surface_idx < all_surfaces.size(); surface_idx++) {
|
||||
Surface *surface = &all_surfaces[surface_idx];
|
||||
ExPolygons last = union_ex(surface->expolygon.simplify_p(SCALED_RESOLUTION));
|
||||
//compute our unsupported surface
|
||||
ExPolygons unsupported = diff_ex(last, this->lower_slices->expolygons, true);
|
||||
ExPolygons unsupported = diff_ex(last, *this->lower_slices, true);
|
||||
if (!unsupported.empty()) {
|
||||
//remove small overhangs
|
||||
ExPolygons unsupported_filtered = offset2_ex(unsupported, double(-perimeter_spacing), double(perimeter_spacing));
|
||||
@ -103,9 +103,9 @@ void PerimeterGenerator::process()
|
||||
int numploy = 0;
|
||||
//only consider the bottom layer that intersect unsupported, to be sure it's only on our island.
|
||||
ExPolygonCollection lower_island(support);
|
||||
BridgeDetector detector(unsupported_filtered,
|
||||
lower_island,
|
||||
perimeter_spacing);
|
||||
BridgeDetector detector{ unsupported_filtered,
|
||||
lower_island.expolygons,
|
||||
perimeter_spacing };
|
||||
if (detector.detect_angle(Geometry::deg2rad(this->config->bridge_angle.value))) {
|
||||
ExPolygons bridgeable = union_ex(detector.coverage(-1, true));
|
||||
if (!bridgeable.empty()) {
|
||||
@ -292,10 +292,10 @@ void PerimeterGenerator::process()
|
||||
// Add perimeters on overhangs : initialization
|
||||
ExPolygons overhangs_unsupported;
|
||||
if (this->config->extra_perimeters && !last.empty()
|
||||
&& this->lower_slices != NULL && !this->lower_slices->expolygons.empty()) {
|
||||
&& this->lower_slices != NULL && !this->lower_slices->empty()) {
|
||||
//remove holes from lower layer, we only ant that for overhangs, not bridges!
|
||||
ExPolygons lower_without_holes;
|
||||
for (const ExPolygon &exp : this->lower_slices->expolygons)
|
||||
for (const ExPolygon &exp : *this->lower_slices)
|
||||
lower_without_holes.emplace_back(to_expolygon(exp.contour));
|
||||
overhangs_unsupported = diff_ex(last, lower_without_holes);
|
||||
if (!overhangs_unsupported.empty()) {
|
||||
@ -304,9 +304,9 @@ void PerimeterGenerator::process()
|
||||
//first, separate into islands (ie, each ExPlolygon)
|
||||
//only consider the bottom layer that intersect unsupported, to be sure it's only on our island.
|
||||
const ExPolygonCollection lower_island(diff_ex(last, overhangs_unsupported));
|
||||
BridgeDetector detector(overhangs_unsupported,
|
||||
lower_island,
|
||||
perimeter_spacing);
|
||||
BridgeDetector detector{ overhangs_unsupported,
|
||||
lower_island.expolygons,
|
||||
perimeter_spacing };
|
||||
if (detector.detect_angle(Geometry::deg2rad(this->config->bridge_angle.value))) {
|
||||
const ExPolygons bridgeable = union_ex(detector.coverage(-1, true));
|
||||
if (!bridgeable.empty()) {
|
||||
@ -516,7 +516,7 @@ void PerimeterGenerator::process()
|
||||
if (offset_top_surface > 0.9 * (config->perimeters <= 1 ? 0. : (perimeter_spacing * (config->perimeters - 1))))
|
||||
offset_top_surface -= 0.9 * (config->perimeters <= 1 ? 0. : (perimeter_spacing * (config->perimeters - 1)));
|
||||
else offset_top_surface = 0;
|
||||
ExPolygons upper_polygons = this->upper_slices->expolygons;
|
||||
ExPolygons upper_polygons = *this->upper_slices;
|
||||
ExPolygons top_polygons = diff_ex(last, (upper_polygons), true);
|
||||
ExPolygons inner_polygons = diff_ex(last, offset_ex(top_polygons, offset_top_surface), true);
|
||||
// increase a bit the inner space to fill the frontier between last and stored.
|
||||
|
@ -52,8 +52,8 @@ class PerimeterGenerator {
|
||||
public:
|
||||
// Inputs:
|
||||
const SurfaceCollection *slices;
|
||||
const ExPolygonCollection *upper_slices;
|
||||
const ExPolygonCollection *lower_slices;
|
||||
const ExPolygons *upper_slices;
|
||||
const ExPolygons *lower_slices;
|
||||
double layer_height;
|
||||
int layer_id;
|
||||
Flow perimeter_flow;
|
||||
|
@ -1864,7 +1864,7 @@ ExPolygons Print::_make_brim(const PrintObjectPtrs &objects, ExtrusionEntityColl
|
||||
ExPolygons islands;
|
||||
for (PrintObject *object : objects) {
|
||||
ExPolygons object_islands;
|
||||
for (ExPolygon &expoly : object->m_layers.front()->slices.expolygons)
|
||||
for (ExPolygon &expoly : object->m_layers.front()->slices)
|
||||
if(config().brim_inside_holes || config().brim_width_interior > 0)
|
||||
object_islands.push_back(expoly);
|
||||
else
|
||||
@ -1999,7 +1999,7 @@ ExPolygons Print::_make_brim_ears(const PrintObjectPtrs &objects, ExtrusionEntit
|
||||
ExPolygons islands;
|
||||
for (PrintObject *object : objects) {
|
||||
ExPolygons object_islands;
|
||||
for (ExPolygon &expoly : object->m_layers.front()->slices.expolygons)
|
||||
for (const ExPolygon &expoly : object->m_layers.front()->slices)
|
||||
if (config().brim_inside_holes || config().brim_width_interior > 0)
|
||||
object_islands.push_back(expoly);
|
||||
else
|
||||
|
@ -3688,7 +3688,7 @@ void PrintConfigDef::init_sla_params()
|
||||
def = this->add("pad_brim_size", coFloat);
|
||||
def->label = L("Pad brim size");
|
||||
def->tooltip = L("How far should the pad extend around the contained geometry");
|
||||
def->category = L("Pad");
|
||||
def->category = OptionCategory::pad;
|
||||
// def->tooltip = L("");
|
||||
def->sidetext = L("mm");
|
||||
def->min = 0;
|
||||
@ -3738,7 +3738,7 @@ void PrintConfigDef::init_sla_params()
|
||||
|
||||
def = this->add("pad_around_object_everywhere", coBool);
|
||||
def->label = L("Pad around object everywhere");
|
||||
def->category = L("Pad");
|
||||
def->category = OptionCategory::pad;
|
||||
def->tooltip = L("Force pad around object everywhere");
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
@ -28,7 +28,7 @@ struct Contour3D {
|
||||
indices.insert(indices.end(), ctr.indices.begin(), ctr.indices.end());
|
||||
|
||||
for(size_t n = s; n < indices.size(); n++) {
|
||||
Vec3i32& idx = indices[n]; idx.x() += s3; idx.y() += s3; idx.z() += s3;
|
||||
Vec3i32& idx = indices[n]; idx.x() +=(int32_t)s3; idx.y() += (int32_t)s3; idx.z() += (int32_t)s3;
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -637,7 +637,7 @@ void pad_blueprint(const TriangleMesh & mesh,
|
||||
TriangleMeshSlicer slicer(&mesh);
|
||||
|
||||
auto out = reserve_vector<ExPolygons>(heights.size());
|
||||
slicer.slice(heights, 0.f, &out, thrfn);
|
||||
slicer.slice(heights, &out, thrfn);
|
||||
|
||||
size_t count = 0;
|
||||
for(auto& o : out) count += o.size();
|
||||
|
@ -76,7 +76,7 @@ std::vector<ExPolygons> SupportTree::slice(
|
||||
std::copy(grid.begin(), maxzit, std::back_inserter(padgrid));
|
||||
|
||||
TriangleMeshSlicer pad_slicer(&pad_mesh);
|
||||
sup_slicer.closing_radius = cr;
|
||||
pad_slicer.closing_radius = cr;
|
||||
pad_slicer.slice(padgrid, &slices.back(), ctl().cancelfn);
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,8 @@ Head::Head(double r_big_mm,
|
||||
coord_t i1s1 = coord_t(idx1), i1s2 = coord_t(idx2);
|
||||
coord_t i2s1 = i1s1 + 1, i2s2 = i1s2 + 1;
|
||||
|
||||
mesh.indices.emplace_back(i1s1, i2s1, i2s2);
|
||||
mesh.indices.emplace_back(i1s1, i2s2, i1s2);
|
||||
mesh.indices.emplace_back((int32_t)i1s1, (int32_t)i2s1, (int32_t)i2s2);
|
||||
mesh.indices.emplace_back((int32_t)i1s1, (int32_t)i2s2, (int32_t)i1s2);
|
||||
}
|
||||
|
||||
auto i1s1 = coord_t(s1.points.size()) - coord_t(steps);
|
||||
|
@ -18,13 +18,13 @@ SCENARIO("denser infills: ")
|
||||
WHEN("dense infill to enlarged") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_5mm_center_notch }, model, config, false);
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_5mm_center_notch }, model, &config, false);
|
||||
print.process();
|
||||
PrintObject& object = *(print.objects().at(0));
|
||||
|
||||
@ -87,13 +87,13 @@ SCENARIO("denser infills: ")
|
||||
WHEN("dense infill to auto") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false);
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, &config, false);
|
||||
print.process();
|
||||
PrintObject& object = *(print.objects().at(0));
|
||||
THEN("correct number of fills") {
|
||||
@ -149,13 +149,13 @@ SCENARIO("denser infills: ")
|
||||
WHEN("dense infill to auto-not-full") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, config, false);
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.2));
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
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");
|
||||
Slic3r::Test::init_print(print, { Slic3r::Test::TestMesh::di_10mm_notch }, model, &config, false);
|
||||
print.process();
|
||||
PrintObject& object = *(print.objects().at(0));
|
||||
THEN("correct number of fills") {
|
||||
|
@ -235,30 +235,30 @@ TEST_CASE("Fill: extrude gcode and check it")
|
||||
double volume = (5 * 5 * 0.2);
|
||||
sample_mesh.repair();
|
||||
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_key_value("perimeters", new ConfigOptionInt(1));
|
||||
config->set_key_value("top_solid_layers", new ConfigOptionInt(1));
|
||||
config->set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("perimeters", new ConfigOptionInt(1));
|
||||
config.set_key_value("top_solid_layers", new ConfigOptionInt(1));
|
||||
config.set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
|
||||
config->set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
config->set_key_value("infill_overlap", new ConfigOptionFloatOrPercent(0.1, true));
|
||||
config.set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
config.set_key_value("infill_overlap", new ConfigOptionFloatOrPercent(0.1, true));
|
||||
|
||||
config->set_key_value("skirts", new ConfigOptionInt(0));
|
||||
config.set_key_value("skirts", new ConfigOptionInt(0));
|
||||
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.2)); // get a known number of layers
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.2)); // get a known number of layers
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
|
||||
config->set_key_value("extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("external_perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("solid_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("top_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("external_perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("solid_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("top_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
auto event_counter{ 0U };
|
||||
std::string stage;
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { sample_mesh }, model, config);
|
||||
Slic3r::Test::init_print(print, { sample_mesh }, model, &config);
|
||||
print.process();
|
||||
|
||||
std::string gcode_filepath{ "" };
|
||||
@ -289,8 +289,8 @@ TEST_CASE("Fill: extrude gcode and check it")
|
||||
}
|
||||
});
|
||||
|
||||
double perimeterRoundGapRemove = unscaled(print.objects()[0]->layers()[0]->slices.expolygons[0].contour.length()) * 0.1*0.1 * (2 - (PI / 2));
|
||||
double perimeterRoundGapAdd = unscaled(print.objects()[0]->layers()[0]->slices.expolygons[0].contour.length()) * 0.1*0.1 * ((PI / 2));
|
||||
double perimeterRoundGapRemove = unscaled(print.objects()[0]->layers()[0]->slices[0].contour.length()) * 0.1*0.1 * (2 - (PI / 2));
|
||||
double perimeterRoundGapAdd = unscaled(print.objects()[0]->layers()[0]->slices[0].contour.length()) * 0.1*0.1 * ((PI / 2));
|
||||
//for (Line &l : print.objects()[0]->layers()[0]->slices.expolygons[0].contour.lines()) {
|
||||
|
||||
//}
|
||||
@ -343,30 +343,30 @@ TEST_CASE("Fill: extrude gcode and check it")
|
||||
double volume = (PI * 25 * 0.2);
|
||||
sample_mesh.repair();
|
||||
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_key_value("perimeters", new ConfigOptionInt(1));
|
||||
config->set_key_value("top_solid_layers", new ConfigOptionInt(1));
|
||||
config->set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_key_value("perimeters", new ConfigOptionInt(1));
|
||||
config.set_key_value("top_solid_layers", new ConfigOptionInt(1));
|
||||
config.set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
|
||||
config->set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
config->set_key_value("infill_overlap", new ConfigOptionFloatOrPercent(0.1, true));
|
||||
config.set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
config.set_key_value("infill_overlap", new ConfigOptionFloatOrPercent(0.1, true));
|
||||
|
||||
config->set_key_value("skirts", new ConfigOptionInt(0));
|
||||
config.set_key_value("skirts", new ConfigOptionInt(0));
|
||||
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.2)); // get a known number of layers
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.2)); // get a known number of layers
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.2, false));
|
||||
|
||||
config->set_key_value("extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("external_perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("solid_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("top_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("external_perimeter_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("solid_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("top_infill_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
auto event_counter{ 0U };
|
||||
std::string stage;
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { sample_mesh }, model, config);
|
||||
Slic3r::Test::init_print(print, { sample_mesh }, model, &config);
|
||||
print.process();
|
||||
|
||||
std::string gcode_filepath{ "" };
|
||||
@ -397,8 +397,8 @@ TEST_CASE("Fill: extrude gcode and check it")
|
||||
}
|
||||
});
|
||||
|
||||
double perimeterRoundGapRemove = unscaled(print.objects()[0]->layers()[0]->slices.expolygons[0].contour.length()) * 0.1*0.1 * (2 - (PI / 2));
|
||||
double perimeterRoundGapAdd = unscaled(print.objects()[0]->layers()[0]->slices.expolygons[0].contour.length()) * 0.1*0.1 * ((PI / 2));
|
||||
double perimeterRoundGapRemove = unscaled(print.objects()[0]->layers()[0]->slices[0].contour.length()) * 0.1*0.1 * (2 - (PI / 2));
|
||||
double perimeterRoundGapAdd = unscaled(print.objects()[0]->layers()[0]->slices[0].contour.length()) * 0.1*0.1 * ((PI / 2));
|
||||
|
||||
double volumeExtrPerimeter = ExtrusionGetVolume{}.get(print.objects()[0]->layers()[0]->regions()[0]->perimeters);
|
||||
double volumeExtrInfill = ExtrusionGetVolume{}.get(print.objects()[0]->layers()[0]->regions()[0]->fills);
|
||||
|
@ -21,18 +21,18 @@ using namespace Slic3r;
|
||||
SCENARIO("Extrusion width specifics", "[!mayfail]") {
|
||||
GIVEN("A config with a skirt, brim, some fill density, 3 perimeters, and 1 bottom solid layer and a 20mm cube mesh") {
|
||||
// this is a sharedptr
|
||||
DynamicPrintConfig* config {Slic3r::DynamicPrintConfig::new_from_defaults()};
|
||||
config->set_key_value("skirts", new ConfigOptionInt{1});
|
||||
config->set_key_value("brim_width", new ConfigOptionFloat{2});
|
||||
config->set_key_value("perimeters", new ConfigOptionInt{3});
|
||||
config->set_key_value("fill_density", new ConfigOptionPercent{40});
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent{100, true});
|
||||
DynamicPrintConfig &config {Slic3r::DynamicPrintConfig::full_print_config()};
|
||||
config.set_key_value("skirts", new ConfigOptionInt{1});
|
||||
config.set_key_value("brim_width", new ConfigOptionFloat{2});
|
||||
config.set_key_value("perimeters", new ConfigOptionInt{3});
|
||||
config.set_key_value("fill_density", new ConfigOptionPercent{40});
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent{100, true});
|
||||
|
||||
WHEN("first layer width set to 2mm") {
|
||||
Slic3r::Model model;
|
||||
config->set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent{2.0, false});
|
||||
config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent{2.0, false});
|
||||
Print print;
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, &config);
|
||||
//std::cout << "model pos: " << model.objects.front()->instances.front()->get_offset().x() << ": " << model.objects.front()->instances.front()->get_offset().x() << "\n";
|
||||
//Print print;
|
||||
//for (auto* mo : model.objects)
|
||||
@ -45,7 +45,7 @@ SCENARIO("Extrusion width specifics", "[!mayfail]") {
|
||||
std::string gcode_filepath("");
|
||||
Slic3r::Test::gcode(gcode_filepath, print);
|
||||
GCodeReader parser {Slic3r::GCodeReader()};
|
||||
const double layer_height = config->opt_float("layer_height");
|
||||
const double layer_height = config.opt_float("layer_height");
|
||||
std::string gcode_from_file= read_to_string(gcode_filepath);
|
||||
parser.parse_buffer(gcode_from_file, [&E_per_mm_bottom, layer_height] (Slic3r::GCodeReader& self, const Slic3r::GCodeReader::GCodeLine& line)
|
||||
{
|
||||
|
@ -13,15 +13,15 @@ using namespace std::literals;
|
||||
|
||||
SCENARIO("PrintObject: Perimeter generation") {
|
||||
GIVEN("20mm cube and default config & 0.3 layer height") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
Model model{};
|
||||
config->set_key_value("fill_density", new ConfigOptionPercent(0));
|
||||
config->set_deserialize("layer_height", "0.3");
|
||||
config.set_key_value("fill_density", new ConfigOptionPercent(0));
|
||||
config.set_deserialize("layer_height", "0.3");
|
||||
|
||||
WHEN("make_perimeters() is called") {
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
PrintObject& object = *(print.objects().at(0));
|
||||
print.process();
|
||||
// there are 66.66666.... layers for 0.3mm in 20mm
|
||||
@ -50,15 +50,15 @@ SCENARIO("PrintObject: Perimeter generation") {
|
||||
|
||||
SCENARIO("Print: Skirt generation") {
|
||||
GIVEN("20mm cube and default config") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
Slic3r::Model model{};
|
||||
config->set_key_value("skirt_height", new ConfigOptionInt(1));
|
||||
config->set_key_value("skirt_distance", new ConfigOptionFloat(1));
|
||||
config.set_key_value("skirt_height", new ConfigOptionInt(1));
|
||||
config.set_key_value("skirt_distance", new ConfigOptionFloat(1));
|
||||
WHEN("Skirts is set to 2 loops") {
|
||||
config->set_key_value("skirts", new ConfigOptionInt(2));
|
||||
config.set_key_value("skirts", new ConfigOptionInt(2));
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
THEN("Skirt Extrusion collection has 2 loops in it") {
|
||||
REQUIRE(print.skirt().items_count() == 2);
|
||||
@ -83,18 +83,18 @@ void test_is_solid_infill(Print &p, size_t obj_id, size_t layer_id ) {
|
||||
|
||||
SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces to become internal.") {
|
||||
GIVEN("sliced 20mm cube and config with top_solid_surfaces = 2 and bottom_solid_surfaces = 1") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m { TestMesh::cube_20x20x20 };
|
||||
config->set_key_value("top_solid_layers", new ConfigOptionInt(2));
|
||||
config->set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
config->set_key_value("layer_height", new ConfigOptionFloat(0.5)); // get a known number of layers
|
||||
config->set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config->set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
config.set_key_value("top_solid_layers", new ConfigOptionInt(2));
|
||||
config.set_key_value("bottom_solid_layers", new ConfigOptionInt(1));
|
||||
config.set_key_value("layer_height", new ConfigOptionFloat(0.5)); // get a known number of layers
|
||||
config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("enforce_full_fill_volume", new ConfigOptionBool(true));
|
||||
Slic3r::Model model;
|
||||
auto event_counter {0U};
|
||||
std::string stage;
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
// Precondition: Ensure that the model has 2 solid top layers (39, 38)
|
||||
// and one solid bottom layer (0).
|
||||
@ -120,14 +120,14 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
|
||||
|
||||
SCENARIO("Print: Brim generation") {
|
||||
GIVEN("20mm cube and default config, 1mm first layer width") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m{ TestMesh::cube_20x20x20 };
|
||||
Slic3r::Model model{};
|
||||
config->set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(1, false));
|
||||
config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(1, false));
|
||||
WHEN("Brim is set to 3mm") {
|
||||
config->set_key_value("brim_width", new ConfigOptionFloat(3));
|
||||
config.set_key_value("brim_width", new ConfigOptionFloat(3));
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
//{
|
||||
// std::stringstream stri;
|
||||
@ -141,19 +141,19 @@ SCENARIO("Print: Brim generation") {
|
||||
}
|
||||
}
|
||||
WHEN("Brim is set to 6mm") {
|
||||
config->set_key_value("brim_width", new ConfigOptionFloat(6));
|
||||
config.set_key_value("brim_width", new ConfigOptionFloat(6));
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
THEN("Brim Extrusion collection has 6 loops in it") {
|
||||
REQUIRE(print.brim().items_count() == 6);
|
||||
}
|
||||
}
|
||||
WHEN("Brim is set to 6mm, extrusion width 0.5mm") {
|
||||
config->set_key_value("brim_width", new ConfigOptionFloat(6));
|
||||
config->set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
config.set_key_value("brim_width", new ConfigOptionFloat(6));
|
||||
config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(0.5, false));
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
double nbLoops = 6.0 / print.brim_flow().spacing();
|
||||
THEN("Brim Extrusion collection has " + std::to_string(nbLoops) + " loops in it (flow="+ std::to_string(print.brim_flow().spacing())+")") {
|
||||
@ -161,10 +161,10 @@ SCENARIO("Print: Brim generation") {
|
||||
}
|
||||
}
|
||||
WHEN("Brim ears activated, 3mm") {
|
||||
config->set_key_value("brim_width", new ConfigOptionFloat(3));
|
||||
config->set_key_value("brim_ears", new ConfigOptionBool(true));
|
||||
config.set_key_value("brim_width", new ConfigOptionFloat(3));
|
||||
config.set_key_value("brim_ears", new ConfigOptionBool(true));
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { m }, model, config);
|
||||
Slic3r::Test::init_print(print, { m }, model, &config);
|
||||
print.process();
|
||||
THEN("Brim ears Extrusion collection has 4 extrusions in it") {
|
||||
REQUIRE(print.brim().items_count() == 4);
|
||||
|
@ -11,23 +11,23 @@ using namespace Slic3r;
|
||||
SCENARIO("skirt test by merill", "") {
|
||||
|
||||
GIVEN("2 objects, don't complete individual object") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
// remove noise
|
||||
config->set_deserialize("top_solid_layers", "0");
|
||||
config->set_deserialize("bottom_solid_layers", "0");
|
||||
config->set_deserialize("fill_density", "0");
|
||||
config->set_deserialize("perimeters", "1");
|
||||
config->set_deserialize("complete_objects", "0");
|
||||
config->set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
config.set_deserialize("top_solid_layers", "0");
|
||||
config.set_deserialize("bottom_solid_layers", "0");
|
||||
config.set_deserialize("fill_density", "0");
|
||||
config.set_deserialize("perimeters", "1");
|
||||
config.set_deserialize("complete_objects", "0");
|
||||
config.set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
|
||||
WHEN("skirt with 3 layers is requested") {
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "0");
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "0");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -59,18 +59,18 @@ SCENARIO("skirt test by merill", "") {
|
||||
REQUIRE(layers_with_brim.size() == 0);
|
||||
}
|
||||
THEN("skirt_height is honored") {
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config->opt_int("skirt_height"));
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config.opt_int("skirt_height"));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("brim and skirt with 3 layers is requested") {
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "4");
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "4");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -102,18 +102,18 @@ SCENARIO("skirt test by merill", "") {
|
||||
REQUIRE(layers_with_brim.size() == 1);
|
||||
}
|
||||
THEN("skirt_height is honored") {
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config->opt_int("skirt_height"));
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config.opt_int("skirt_height"));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("brim is requested") {
|
||||
config->set_deserialize("skirts", "0");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "4");
|
||||
config.set_deserialize("skirts", "0");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "4");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -151,23 +151,23 @@ SCENARIO("skirt test by merill", "") {
|
||||
}
|
||||
|
||||
GIVEN("3 objects, complete individual object") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
// remove noise
|
||||
config->set_deserialize("top_solid_layers", "0");
|
||||
config->set_deserialize("bottom_solid_layers", "0");
|
||||
config->set_deserialize("fill_density", "0");
|
||||
config->set_deserialize("perimeters", "1");
|
||||
config->set_deserialize("complete_objects", "1");
|
||||
config->set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
config.set_deserialize("top_solid_layers", "0");
|
||||
config.set_deserialize("bottom_solid_layers", "0");
|
||||
config.set_deserialize("fill_density", "0");
|
||||
config.set_deserialize("perimeters", "1");
|
||||
config.set_deserialize("complete_objects", "1");
|
||||
config.set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
|
||||
WHEN("skirt with 3 layers is requested") {
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "0");
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "0");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20, TestMesh::pyramid }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20, TestMesh::pyramid }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -197,18 +197,18 @@ SCENARIO("skirt test by merill", "") {
|
||||
REQUIRE(layers_with_brim.size() == 0);
|
||||
}
|
||||
THEN("skirt_height is honored") {
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config->opt_int("skirt_height"));
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config.opt_int("skirt_height"));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("brim and skirt with 3 layers is requested") {
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "4");
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "4");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -240,18 +240,18 @@ SCENARIO("skirt test by merill", "") {
|
||||
REQUIRE(layers_with_brim.size() == 1);
|
||||
}
|
||||
THEN("skirt_height is honored") {
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config->opt_int("skirt_height"));
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config.opt_int("skirt_height"));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("brim is requested") {
|
||||
config->set_deserialize("skirts", "0");
|
||||
config->set_deserialize("skirt_height", "3");
|
||||
config->set_deserialize("brim_width", "4");
|
||||
config.set_deserialize("skirts", "0");
|
||||
config.set_deserialize("skirt_height", "3");
|
||||
config.set_deserialize("brim_width", "4");
|
||||
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config);
|
||||
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::map<double, bool> layers_with_brim;
|
||||
@ -290,22 +290,22 @@ SCENARIO("skirt test by merill", "") {
|
||||
}
|
||||
SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
|
||||
GIVEN("Configuration with a skirt height of 2") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("skirt_height", "2");
|
||||
config->set_deserialize("perimeters", "1");
|
||||
config->set_deserialize("support_material_speed", "99");
|
||||
config->set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("skirt_height", "2");
|
||||
config.set_deserialize("perimeters", "1");
|
||||
config.set_deserialize("support_material_speed", "99");
|
||||
config.set_key_value("gcode_comments", new ConfigOptionBool(true));
|
||||
|
||||
// avoid altering speeds unexpectedly
|
||||
config->set_deserialize("cooling", "0");
|
||||
config->set_deserialize("first_layer_speed", "100%");
|
||||
config.set_deserialize("cooling", "0");
|
||||
config.set_deserialize("first_layer_speed", "100%");
|
||||
|
||||
WHEN("multiple objects are printed") {
|
||||
auto gcode {std::stringstream("")};
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, config, false);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, model, &config, false);
|
||||
std::map<double, bool> layers_with_skirt;
|
||||
std::string gcode_filepath{ "" };
|
||||
Slic3r::Test::gcode(gcode_filepath, print);
|
||||
@ -316,7 +316,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
|
||||
layers_with_skirt[self.z()] = 1;
|
||||
}
|
||||
//if (self.z() > 0) {
|
||||
// if (line.extruding(self) && (line.new_F(self) == config->opt_float("support_material_speed") * 60.0) ) {
|
||||
// if (line.extruding(self) && (line.new_F(self) == config.opt_float("support_material_speed") * 60.0) ) {
|
||||
// layers_with_skirt[self.z()] = 1;
|
||||
// }
|
||||
//}
|
||||
@ -324,43 +324,43 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
|
||||
clean_file(gcode_filepath, "gcode");
|
||||
|
||||
THEN("skirt_height is honored") {
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config->opt_int("skirt_height"));
|
||||
REQUIRE(layers_with_skirt.size() == (size_t)config.opt_int("skirt_height"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GIVEN("A default configuration") {
|
||||
DynamicPrintConfig *config = Slic3r::DynamicPrintConfig::new_from_defaults();
|
||||
config->set_deserialize("support_material_speed", "99");
|
||||
DynamicPrintConfig &config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
config.set_deserialize("support_material_speed", "99");
|
||||
|
||||
// avoid altering speeds unexpectedly
|
||||
config->set_deserialize("cooling", "0");
|
||||
config->set_deserialize("first_layer_speed", "100%");
|
||||
config.set_deserialize("cooling", "0");
|
||||
config.set_deserialize("first_layer_speed", "100%");
|
||||
// remove noise from top/solid layers
|
||||
config->set_deserialize("top_solid_layers", "0");
|
||||
config->set_deserialize("bottom_solid_layers", "0");
|
||||
config.set_deserialize("top_solid_layers", "0");
|
||||
config.set_deserialize("bottom_solid_layers", "0");
|
||||
|
||||
WHEN("Brim width is set to 5") {
|
||||
config->set_deserialize("perimeters", "0");
|
||||
config->set_deserialize("skirts", "0");
|
||||
config->set_deserialize("brim_width", "5");
|
||||
config.set_deserialize("perimeters", "0");
|
||||
config.set_deserialize("skirts", "0");
|
||||
config.set_deserialize("brim_width", "5");
|
||||
THEN("Brim is generated") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, config, false);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, &config, false);
|
||||
print.process();
|
||||
REQUIRE(print.brim().entities.size()>0);
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Skirt area is smaller than the brim") {
|
||||
config->set_deserialize("skirts", "1");
|
||||
config->set_deserialize("brim_width", "10");
|
||||
config.set_deserialize("skirts", "1");
|
||||
config.set_deserialize("brim_width", "10");
|
||||
THEN("GCode generates successfully.") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, config, false);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, &config, false);
|
||||
std::string gcode_filepath{ "" };
|
||||
Slic3r::Test::gcode(gcode_filepath, print);
|
||||
std::string gcode_from_file = read_to_string(gcode_filepath);
|
||||
@ -370,13 +370,13 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
|
||||
}
|
||||
|
||||
WHEN("Skirt height is 0 and skirts > 0") {
|
||||
config->set_deserialize("skirts", "2");
|
||||
config->set_deserialize("skirt_height", "0");
|
||||
config.set_deserialize("skirts", "2");
|
||||
config.set_deserialize("skirt_height", "0");
|
||||
|
||||
THEN("GCode generates successfully.") {
|
||||
Model model{};
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, config, false);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, &config, false);
|
||||
std::string gcode_filepath{ "" };
|
||||
Slic3r::Test::gcode(gcode_filepath, print);
|
||||
std::string gcode_from_file = read_to_string(gcode_filepath);
|
||||
@ -398,33 +398,33 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
|
||||
|
||||
//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
|
||||
// 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);
|
||||
// Slic3r::Test::init_print(print, { TestMesh::overhang }, model, &config, false);
|
||||
// print.process();
|
||||
//
|
||||
// config->set_deserialize("support_material", "true"); // to prevent speeds to be altered
|
||||
// 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");
|
||||
config.set_deserialize("min_skirt_length", "20");
|
||||
auto gcode {std::stringstream("")};
|
||||
Slic3r::Model model;
|
||||
Print print{};
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, config, false);
|
||||
Slic3r::Test::init_print(print, { TestMesh::cube_20x20x20 }, model, &config, false);
|
||||
THEN("Gcode generation doesn't crash") {
|
||||
std::string gcode_filepath{ "" };
|
||||
Slic3r::Test::gcode(gcode_filepath, print);
|
||||
|
@ -68,8 +68,8 @@ bool _equiv(const T& a, const T& b, double epsilon) { return abs(a - b) < epsilo
|
||||
|
||||
Slic3r::Model model(const std::string& model_name, TriangleMesh&& _mesh);
|
||||
|
||||
void init_print(Print& print, std::initializer_list<TestMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config = Slic3r::DynamicPrintConfig::new_from_defaults(), bool comments = false);
|
||||
void init_print(Print& print, std::initializer_list<TriangleMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config = Slic3r::DynamicPrintConfig::new_from_defaults(), bool comments = false);
|
||||
void init_print(Print& print, std::initializer_list<TestMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config, bool comments = false);
|
||||
void init_print(Print& print, std::initializer_list<TriangleMesh> meshes, Slic3r::Model& model, DynamicPrintConfig* _config, bool comments = false);
|
||||
|
||||
void gcode(std::string& gcode, Print& print);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user