Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add small perimeter length in user interface #4593

Closed
wants to merge 3 commits into from

Conversation

gennartan
Copy link

Closed last pull request at #4581 because I did not succeed to remove all the useless space I removed.
Here is a new pull request taking into account the comments made on previous pull request.

Copy link
Member

@lordofhyphens lordofhyphens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a short test for this feature that implements the following:

  • Given: A cylinder with diameter 10mm, and a config that sets 1 perimeter, no infill, external speed = 100mm/s and small perimeter speed = 15mm/s
  • When slicing a the model with small_perimeter_length = 6.5
  • Then: the speed chosen for the second layer's perimeter is 6000mm/minute in gcode (F6000).
  • When slicing a the model with small_perimeter_length = 10.1
  • Then: the speed chosen for the second layer's perimeter is 900mm/minute in gcode (F900).

def->sidetext = "mm";
def->cli = "small-perimeter-length=f";
def->min = 0;
def->default_value = new ConfigOptionFloat(6.5*2*PI);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead and leave this a 6.5 and change the usage in xs/src/libslic3r/GCode.cpp to
scale_(this->config.get_abs_value("small_perimeter_length")) * 2 * PI

@lordofhyphens
Copy link
Member

To add the test:

Create a new file in https://github.com/slic3r/Slic3r/tree/master/src/test/libslic3r called test_gcode.cpp

Put the following contents in there to start:

#include <catch.hpp>
#include "GCodeWriter.hpp"
#include "test_options.hpp"
#include "test_data.hpp"

using namespace Slic3r;
using namespace std::literals::string_literals;

SCENARIO( "Small perimeter gcode speeds" ) {
  GIVEN( "A cylinder with diameter 10mm, and a config that sets 1 perimeter, no infill, external speed = 100mm/s and small perimeter speed = 15mm/s") {
    config_ptr test_config = Slic3r::Config::new_from_defaults();
    test_config->set("small_perimeter_length", 10); 
    test_config->set("external_perimeter_speed", 100);
    test_config->set("perimeters", 1);
    test_config->set("fill_density", "0%");
    test_config->set("top_solid_layers", 0);
    test_config->set("top_bottom_layers", 0);
    test_config->set("gcode_comments", true);
    test_config->set("cooling", false);
    Model test_model;
    auto setup = init_print(TriangleMesh::make_cylinder(10, 10), test_model, test_config);
    WHEN( "slicing the model with small_perimeter_length = 6.5" ) {
      print->process();
      Slic3r::Test::gcode(gcode, print);
      auto exported {gcode.str()};
      THEN( "the speed chosen for the second layer's perimeter is 6000mm/minute in gcode (F6000)." ) {
        int speed = 0;
        auto reader {GCodeReader()};
        reader.apply_config(print->config);
        reader.parse(exported, [&speed] (GCodeReader& self, const GCodeReader::GCodeLine& line) 
          {
            // code to read speed from gcode goes here, see
            // https://github.com/slic3r/Slic3r/blob/master/xs/src/libslic3r/GCodeReader.hpp
            // for documentation of GCodeReader and GCodeLine
            // and test_printgcode.cpp for examples in how it's used.
          });
        REQUIRE(speed == 6000);
      }
    }
    WHEN( "slicing the model with small_perimeter_length = 15" ) {
    test_config->set("small_perimeter_length", 15); 
      THEN( "the speed used for the second layer's perimeter is 900mm/minute in gcode (F900)." ) {
        int speed = 0;
        auto reader {GCodeReader()};
        reader.apply_config(print->config);
        reader.parse(exported, [&speed] (GCodeReader& self, const GCodeReader::GCodeLine& line) 
          {
            // code to read speed from gcode goes here, see
            // https://github.com/slic3r/Slic3r/blob/master/xs/src/libslic3r/GCodeReader.hpp
            // for documentation of GCodeReader and GCodeLine
            // and test_printgcode.cpp for examples in how it's used.
          });
        REQUIRE(speed == 900);
      }
    }
  }
} 

@lordofhyphens lordofhyphens added the Feature request This is an idea for a new feature in Slic3r label Nov 19, 2018
@lordofhyphens
Copy link
Member

Then add ${TESTDIR}/libslic3r/test_gcode.cpp at the end of the list at https://github.com/slic3r/Slic3r/blob/master/src/CMakeLists.txt#L284

@gennartan
Copy link
Author

Hello @lordofhyphens , I do not figure out how to get the speed of the perimeter while doing the test you described above.
Is the speed in the F variable (feedrate) of the Gcode ? I suppuse it is not that because I get a constant value, that does not depends on the diameter of the cylinder :/

@lordofhyphens
Copy link
Member

F in gcode is the speed.
E is extrusion, X/Y/Z are coordinates.

@lordofhyphens
Copy link
Member

@gennartan generally, Slic3r puts any speed changes on its own line.

@gennartan gennartan closed this Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request This is an idea for a new feature in Slic3r
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants