Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer

This commit is contained in:
enricoturri1966 2020-05-27 14:29:54 +02:00
commit 448d92df68
51 changed files with 313 additions and 332 deletions

View file

@ -11,13 +11,13 @@
#include "../libslic3r.h"
#include "../BoundingBox.hpp"
#include "../PrintConfig.hpp"
#include "../Utils.hpp"
namespace Slic3r {
class ExPolygon;
class Surface;
enum InfillPattern : int;
class InfillFailedException : public std::runtime_error {
public:

View file

@ -455,24 +455,19 @@ bool Model::looks_like_imperial_units() const
if (this->objects.size() == 0)
return false;
stl_vertex size = this->objects[0]->get_object_stl_stats().size;
for (ModelObject* obj : this->objects)
if (obj->get_object_stl_stats().volume < 9.0) // 9 = 3*3*3;
return true;
for (ModelObject* o : this->objects) {
auto sz = o->get_object_stl_stats().size;
if (size[0] < sz[0]) size[0] = sz[0];
if (size[1] < sz[1]) size[1] = sz[1];
if (size[2] < sz[2]) size[2] = sz[2];
}
return (size[0] < 3 && size[1] < 3 && size[2] < 3);
return false;
}
void Model::convert_from_imperial_units()
{
double in_to_mm = 25.4;
for (ModelObject* o : this->objects)
o->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm));
for (ModelObject* obj : this->objects)
if (obj->get_object_stl_stats().volume < 9.0) // 9 = 3*3*3;
obj->scale_mesh_after_creation(Vec3d(in_to_mm, in_to_mm, in_to_mm));
}
void Model::adjust_min_z()
@ -1273,6 +1268,27 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
return;
}
void ModelObject::merge()
{
if (this->volumes.size() == 1) {
// We can't merge meshes if there's just one volume
return;
}
TriangleMesh mesh;
for (ModelVolume* volume : volumes)
if (!volume->mesh().empty())
mesh.merge(volume->mesh());
mesh.repair();
this->clear_volumes();
ModelVolume* vol = this->add_volume(mesh);
if (!vol)
return;
}
// Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees,
// then the scaling in world coordinate system is not representable by the Geometry::Transformation structure.
// This situation is solved by baking in the instance transformation into the mesh vertices.

View file

@ -287,6 +287,7 @@ public:
bool needed_repair() const;
ModelObjectPtrs cut(size_t instance, coordf_t z, bool keep_upper = true, bool keep_lower = true, bool rotate_lower = false); // Note: z is in world coordinates
void split(ModelObjectPtrs* new_objects);
void merge();
// Support for non-uniform scaling of instances. If an instance is rotated by angles, which are not multiples of ninety degrees,
// then the scaling in world coordinate system is not representable by the Geometry::Transformation structure.
// This situation is solved by baking in the instance transformation into the mesh vertices.

View file

@ -1,4 +1,6 @@
#include "ModelArrange.hpp"
#include <libslic3r/Model.hpp>
#include "MTUtils.hpp"
namespace Slic3r {

View file

@ -1,11 +1,14 @@
#ifndef MODELARRANGE_HPP
#define MODELARRANGE_HPP
#include <libslic3r/Model.hpp>
#include <libslic3r/Arrange.hpp>
namespace Slic3r {
class Model;
class ModelInstance;
using ModelInstancePtrs = std::vector<ModelInstance*>;
using arrangement::ArrangePolygon;
using arrangement::ArrangePolygons;
using arrangement::ArrangeParams;

View file

@ -33,7 +33,7 @@ enum PrintHostType {
htOctoPrint, htDuet, htFlashAir, htAstroBox
};
enum InfillPattern {
enum InfillPattern : int {
ipRectilinear, ipMonotonous, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipCount,
};

View file

@ -11,7 +11,6 @@
#include "libslic3r.h"
#include "Utils.hpp"
#include "PrintConfig.hpp"
namespace Slic3r
{
@ -19,6 +18,7 @@ namespace Slic3r
class PrintConfig;
class PrintObjectConfig;
class ModelObject;
class DynamicPrintConfig;
// Parameters to guide object slicing and support generation.
// The slicing parameters account for a raft and whether the 1st object layer is printed with a normal or a bridging flow