slic3r / Slic3r

Open Source toolpath generator for 3D printers
https://slic3r.org/
GNU Affero General Public License v3.0
3.33k stars 1.29k forks source link

libslic3r - Issues #5145

Open Yejneshwar opened 2 years ago

Yejneshwar commented 2 years ago

Version

2.4.2

Operating system type + version

Ubuntu 20

Behavior

There seem to be a lot of slices missing When using the exact same config as in the GUI ( export .ini from GUI and load with Slic3r::Config::new_from_ini ). libslic3r has been added to the project and the included Slic3r::TriangleMesh::make_cube(20, 20, 20) works fine. what am I missing here?

use below code to reproduce.

#include <iostream>
#include <IO.hpp>
#include <Model.hpp>
#include <TriangleMesh.hpp>
#include <iostream>
#include <fstream>

#include <regex>
#include <libslic3r.h>
#include <GCodeReader.hpp>
#include <libslic3r/Config.hpp>
#include <libslic3r/Print.hpp>
#include <libslic3r/GCodeTimeEstimator.hpp>

int main(int, char**) {
    //Slic3r::TriangleMesh mesh = Slic3r::TriangleMesh::make_cube(20, 20, 20);
    Slic3r::TriangleMesh mesh;
    bool loaded = Slic3r::IO::STL::read("./Venom.stl", &mesh);
    mesh.repair();

    std::cout << "STL File loaded : " << loaded << std::endl;

    //std::cout << "Needed repair : " << mesh.needed_repair() << std::endl;
    auto config{ Slic3r::Config::new_from_ini("./config2.ini")};
    auto gcode{ std::stringstream("") };
    config->set("support_material", true);
    config->set("support_material_buildplate_only", true);

    Slic3r::Model model;

    shared_Print print{ std::make_shared<Slic3r::Print>() };
    print->apply_config(config);
        auto* object{ model.add_object() };
        object->name += "object.stl"s;
        object->add_volume(mesh);
        object->repair();

        auto* inst{ object->add_instance() };
        inst->rotation = 0;
        inst->scaling_factor = 1.0;

    model.arrange_objects(print->config.min_object_distance());
    //model.align_to_ground();
    model.center_instances_around_point(Slic3r::Pointf(0, 0));
    model.repair();

    for (auto* mo : model.objects) {
        print->auto_assign_extruders(mo);
        print->add_model_object(mo);
    }

    print->validate();
    print->process();
    print->export_gcode(gcode, false);
    std::ofstream outFile;
    outFile.open("file.gcode", ios::out);
    outFile << gcode.rdbuf();
    outFile.close();
    std::cout << print->total_cost << std::endl;
    std::cout << print->total_used_filament << std::endl;
    std::cout << print->total_weight << std::endl;

    //std::cout << gcode.str() << std::endl;

}

output console prints

  Unable to close this loop having 1 points
  Unable to close this loop having 1 points
  Unable to close this loop having 1 points
  Unable to close this loop having 1 points
  Unable to close this loop having 1 points
  Unable to close this loop having 2 points
  Unable to close this loop having 2 points
  Unable to close this loop having 50 points
  Unable to close this loop having 32 points
  Unable to close this loop having 22 points
  Unable to close this loop having 34 points
  Unable to close this loop having 43 points
  Unable to close this loop having 266 points
  Unable to close this loop having 236 points
  Unable to close this loop having 89 points
  Unable to close this loop having 357 points
  Unable to close this loop having 131 points
  Unable to close this loop having 224 points
  Unable to close this loop having 129 points
  Unable to close this loop having 263 points
  ......omitted for brevity

expected result [ sliced with GUI ]

Capture41

Actual result [ sliced with code above ]

Capture42

CLI build from source shows the same. CLI used from the distributions exits with segmentation fault. GUI works fine with no changes to default settings.

Issue 2 [ works fine with GUI ]

With the A.stl file attached, if the perimeter is greater than 0 the gcode generation fails at https://github.com/slic3r/Slic3r/blob/b1a5500f427700ac3dffc0e7d9535ea65f993537/xs/src/libslic3r/ExPolygon.cpp#L407

STL/Config (.ZIP) where problem occurs

Link to venom.stl since file too large : https://drive.google.com/file/d/1dtifHooBk2UiLmlku7sgTuojQgg26p36/view?usp=sharing Other related files: upload-github.zip

supermerill commented 2 years ago

second issue is a thinwall/gapfill error.